Changeset 3261 in josm for trunk


Ignore:
Timestamp:
2010-05-17T18:13:34+02:00 (14 years ago)
Author:
bastiK
Message:

applied patch by flo: Add support for direction tag in photo EXIF header (got permission to put his test photo in the repository)

Location:
trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/layer/geoimage/GeoImageLayer.java

    r2990 r3261  
    468468                    g.fillRect(p.x - d.width / 2, p.y - d.height / 2, d.width, d.height);
    469469                } else {
     470                    if (e.getExifImgDir() != null) {
     471                        double arrowlength = 25;
     472                        double arrowwidth = 18;
     473
     474                        double dir = e.getExifImgDir();
     475                        // Rotate 90° CCW
     476                        double headdir = ( dir < 90 ) ? dir + 270 : dir - 90;
     477                        double leftdir = ( headdir < 90 ) ? headdir + 270 : headdir - 90;
     478                        double rightdir = ( headdir > 270 ) ? headdir - 270 : headdir + 90;
     479
     480                        double ptx = p.x + Math.cos(Math.toRadians(headdir)) * arrowlength;
     481                        double pty = p.y + Math.sin(Math.toRadians(headdir)) * arrowlength;
     482
     483                        double ltx = p.x + Math.cos(Math.toRadians(leftdir)) * arrowwidth/2;
     484                        double lty = p.y + Math.sin(Math.toRadians(leftdir)) * arrowwidth/2;
     485
     486                        double rtx = p.x + Math.cos(Math.toRadians(rightdir)) * arrowwidth/2;
     487                        double rty = p.y + Math.sin(Math.toRadians(rightdir)) * arrowwidth/2;
     488
     489                        g.setColor(Color.white);
     490                        int[] xar = {(int) ltx, (int) ptx, (int) rtx, (int) ltx};
     491                        int[] yar = {(int) lty, (int) pty, (int) rty, (int) lty};
     492                        g.fillPolygon(xar, yar, 4);
     493                    }
     494
    470495                    selectedIcon.paintIcon(mv, g,
    471496                            p.x - selectedIcon.getIconWidth() / 2,
    472497                            p.y - selectedIcon.getIconHeight() / 2);
     498
    473499                }
    474500            }
     
    528554            }
    529555
     556
     557            // compass direction value
     558
     559            Rational direction = null;
     560           
     561            try {
     562                direction = dir.getRational(GpsDirectory.TAG_GPS_IMG_DIRECTION);
     563            } catch (CompoundException p) {
     564                direction = null;
     565            }
     566
    530567            // Store values
    531568
    532569            e.setExifCoor(new LatLon(lat, lon));
    533570            e.setPos(e.getExifCoor());
     571            if (direction != null) {
     572                e.setExifImgDir(direction.doubleValue());
     573            }
    534574
    535575        } catch (CompoundException p) {
  • trunk/src/org/openstreetmap/josm/gui/layer/geoimage/ImageEntry.java

    r2931 r3261  
    2020    private File file;
    2121    private LatLon exifCoor;
     22    private Double exifImgDir;
    2223    private Date exifTime;
    2324    Image thumbnail;
     
    7879        return exifCoor;
    7980    }
     81    public Double getExifImgDir() {
     82        return exifImgDir;
     83    }
     84
    8085    /**
    8186     * setter methods
     
    105110        this.exifCoor = exifCoor;
    106111    }
     112    void setExifImgDir(double exifDir) {
     113        this.exifImgDir = exifDir;
     114    }
    107115
    108116    @Override
  • trunk/src/org/openstreetmap/josm/gui/layer/geoimage/ImageViewerDialog.java

    r3252 r3261  
    239239                osd.append(tr("\n{0} km/h", Math.round(entry.getSpeed())));
    240240            }
     241            if (entry.getExifImgDir() != null) {
     242                osd.append(tr("\nDirection {0}°", Math.round(entry.getExifImgDir())));
     243            }
    241244            //if (entry.getPos()  != null) {
    242245            //    osd.append(tr("\nlat: {0}, lon: {1}", Double.toString(entry.getPos().lat()), Double.toString(entry.getPos().lon())));
Note: See TracChangeset for help on using the changeset viewer.