Ticket #6162: geoimage.2.patch

File geoimage.2.patch, 2.9 KB (added by *Martin*, 15 years ago)

improved patch

  • core/src/org/openstreetmap/josm/gui/layer/geoimage/GeoImageLayer.java

     
    4646import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor;
    4747import org.openstreetmap.josm.gui.ExtendedDialog;
    4848import org.openstreetmap.josm.gui.MapFrame;
     49import org.openstreetmap.josm.gui.MapFrame.MapModeChangeListener;
    4950import org.openstreetmap.josm.gui.MapView;
     51import org.openstreetmap.josm.gui.MapView.LayerChangeListener;
    5052import org.openstreetmap.josm.gui.PleaseWaitRunnable;
    51 import org.openstreetmap.josm.gui.MapFrame.MapModeChangeListener;
    52 import org.openstreetmap.josm.gui.MapView.LayerChangeListener;
    5353import org.openstreetmap.josm.gui.dialogs.LayerListDialog;
    5454import org.openstreetmap.josm.gui.dialogs.LayerListPopup;
    5555import org.openstreetmap.josm.gui.layer.GpxLayer;
     
    504504
    505505    private static void extractExif(ImageEntry e) {
    506506
    507         int deg;
     507        double deg;
    508508        double min, sec;
    509509        double lon, lat;
    510510        Metadata metadata = null;
     
    524524
    525525            Rational[] components = dir.getRationalArray(GpsDirectory.TAG_GPS_LONGITUDE);
    526526
    527             deg = components[0].intValue();
    528             min = components[1].floatValue();
    529             sec = components[2].floatValue();
     527            deg = components[0].doubleValue();
     528            min = components[1].doubleValue();
     529            sec = components[2].doubleValue();
    530530
    531             lon = (deg + (min / 60) + (sec / 3600));
    532 
    533             if (Double.isNaN(lon))
     531            if (Double.isNaN(deg) && Double.isNaN(min) && Double.isNaN(sec))
    534532                throw new IllegalArgumentException();
    535533
     534            lon = (Double.isNaN(deg) ? 0 : deg + (Double.isNaN(min) ? 0 : (min / 60)) + (Double.isNaN(sec) ? 0 : (sec / 3600)));
     535
    536536            if (dir.getString(GpsDirectory.TAG_GPS_LONGITUDE_REF).charAt(0) == 'W') {
    537537                lon = -lon;
    538538            }
     
    541541
    542542            components = dir.getRationalArray(GpsDirectory.TAG_GPS_LATITUDE);
    543543
    544             deg = components[0].intValue();
    545             min = components[1].floatValue();
    546             sec = components[2].floatValue();
     544            deg = components[0].doubleValue();
     545            min = components[1].doubleValue();
     546            sec = components[2].doubleValue();
    547547
    548             lat = (deg + (min / 60) + (sec / 3600));
     548            if (Double.isNaN(deg) && Double.isNaN(min) && Double.isNaN(sec))
     549                throw new IllegalArgumentException();
    549550
     551            lat = (Double.isNaN(deg) ? 0 : deg + (Double.isNaN(min) ? 0 : (min / 60)) + (Double.isNaN(sec) ? 0 : (sec / 3600)));
     552
    550553            if (Double.isNaN(lat))
    551554                throw new IllegalArgumentException();
    552555