Re: [josm-dev] [PATCH] Image Direction / Compass Camera images

2010-05-18 Thread Florian Lohoff
Hi,
could it be that the josm build is not done on a utf-8 clean machine?

On Mon, May 17, 2010 at 05:11:58PM +0200, Florian Lohoff wrote:
 + if (entry.getExifImgDir() != null) {
 +osd.append(tr(\nDirection {0}°, 
 Math.round(entry.getExifImgDir(;
 + }

The ° gets garbled - it works in my environment - seems okay in the 
the josm git - but in the josm-latest its shown as 2 rectangles
in the image viewer - So my guess is that its a utf-8 in the svn/git repo
and the build machine is an iso-8859-Something and intereprets the multibyte
character as individual characters ...

Flo
-- 
Florian Lohoff f...@zz.de
Es ist ein grobes Missverständnis und eine Fehlwahrnehmung, dem Staat
im Internet Zensur- und Überwachungsabsichten zu unterstellen.
- - Bundesminister Dr. Wolfgang Schäuble -- 10. Juli in Berlin 


signature.asc
Description: Digital signature
___
josm-dev mailing list
josm-dev@openstreetmap.org
http://lists.openstreetmap.org/listinfo/josm-dev


Re: [josm-dev] [PATCH] Image Direction / Compass Camera images

2010-05-17 Thread Florian Lohoff
On Sat, May 15, 2010 at 11:30:01PM +0200, Sebastian Klein wrote:
 Sure, if you donate a camera, I'll fully implement it. ;)
 
 Seriously, there is a lot to do and we cannot add each extension that is 
 used by a single hardware model. But it's a damn cool feature. 
 Hopefully, there will be other vendors and models supporting this!

Don't tell anyone i touched java - I have something rudimentary working
which draws a little triangle arrow below the camera icon when activating it 
e.g. clicking on the picture icon - It does only so when there is a
GPS Image Direction tag in the exif header. I had no clue about java but
someone might hint me through some design/style issues ... Especially
i think there is some overhead in the exception reading the exif tags as
this 

+Metadata metadata = 
JpegMetadataReader.readMetadata(e.getFile());
+Directory directory = 
metadata.getDirectory(GpsDirectory.class);

is called twice ... Probably unnecessary 

Here is a small screenshot how it will look:

http://silicon-verl.de/home/flo/tmp/screenshot-josm3260-imgdir1.png


diff --git a/src/org/openstreetmap/josm/gui/layer/geoimage/GeoImageLayer.java 
b/src/org/openstreetmap/josm/gui/layer/geoimage/GeoImageLayer.java
index eb56404..28a06b3 100644
--- a/src/org/openstreetmap/josm/gui/layer/geoimage/GeoImageLayer.java
+++ b/src/org/openstreetmap/josm/gui/layer/geoimage/GeoImageLayer.java
@@ -467,9 +468,36 @@ public class GeoImageLayer extends Layer implements 
PropertyChangeListener {
 g.setColor(new Color(128, 0, 0, 122));
 g.fillRect(p.x - d.width / 2, p.y - d.height / 2, d.width, 
d.height);
 } else {
+   if (e.getExifImgDir() != null) {
+   double arrowlength = 25;
+   double arrowwidth = 18;
+
+   double dir = e.getExifImgDir();
+   // Rotate 90° CCW 
+   double headdir = ( dir  90 ) ? dir + 270 : dir 
- 90;
+   double leftdir = ( headdir  90 ) ? headdir + 
270 : headdir - 90;
+   double rightdir = ( headdir  270 ) ? headdir - 
270 : headdir + 90;
+
+   double ptx = p.x + 
Math.cos(Math.toRadians(headdir)) * arrowlength;
+   double pty = p.y + 
Math.sin(Math.toRadians(headdir)) * arrowlength;
+
+   double ltx = p.x + 
Math.cos(Math.toRadians(leftdir)) * arrowwidth/2;
+   double lty = p.y + 
Math.sin(Math.toRadians(leftdir)) * arrowwidth/2;
+
+   double rtx = p.x + 
Math.cos(Math.toRadians(rightdir)) * arrowwidth/2;
+   double rty = p.y + 
Math.sin(Math.toRadians(rightdir)) * arrowwidth/2;
+
+   g.setColor(Color.white);
+   int[] xar = {(int) ltx, (int) ptx, (int) rtx, 
(int) ltx};
+   int[] yar = {(int) lty, (int) pty, (int) rty, 
(int) lty};
+   g.fillPolygon(xar, yar, 4);
+   }
+
 selectedIcon.paintIcon(mv, g,
 p.x - selectedIcon.getIconWidth() / 2,
 p.y - selectedIcon.getIconHeight() / 2);
+
+ 
 }
 }
 }
@@ -536,6 +564,15 @@ public class GeoImageLayer extends Layer implements 
PropertyChangeListener {
 e.setExifCoor(null);
 e.setPos(null);
 }
+
+   try {
+Metadata metadata = JpegMetadataReader.readMetadata(e.getFile());
+Directory directory = metadata.getDirectory(GpsDirectory.class);
+Rational direction = 
directory.getRational(GpsDirectory.TAG_GPS_IMG_DIRECTION);
+
+   e.setExifImgDir(direction.doubleValue());
+   } catch (CompoundException p) {
+   }
 }
 
 public void showNextPhoto() {
diff --git a/src/org/openstreetmap/josm/gui/layer/geoimage/ImageEntry.java 
b/src/org/openstreetmap/josm/gui/layer/geoimage/ImageEntry.java
index 2b199e9..a73297a 100644
--- a/src/org/openstreetmap/josm/gui/layer/geoimage/ImageEntry.java
+++ b/src/org/openstreetmap/josm/gui/layer/geoimage/ImageEntry.java
@@ -19,6 +19,7 @@ import org.openstreetmap.josm.data.coor.LatLon;
 final public class ImageEntry implements ComparableImageEntry, Cloneable {
 private File file;
 private LatLon exifCoor;
+private Double exifImgDir;
 private Date exifTime;
 Image thumbnail;
 
@@ -77,6 +78,10 @@ final public class ImageEntry implements 
ComparableImageEntry, Cloneable {
 LatLon getExifCoor() {
 return exifCoor;
 }
+public Double getExifImgDir() {
+   return exifImgDir;
+}
+
 /**
  * setter methods
  */
@@ -104,6 +109,9 @@ final public class ImageEntry implements