Changeset 18315 in josm


Ignore:
Timestamp:
2021-11-07T15:01:40+01:00 (3 years ago)
Author:
Don-vip
Message:

see #21486 - don't try to read int/long/float/double missing GPX metadata

Location:
trunk/src/org/openstreetmap/josm
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/gpx/GpxImageEntry.java

    r18252 r18315  
    732732
    733733        try {
    734             if (dirExif != null) {
     734            if (dirExif != null && dirExif.containsTag(ExifIFD0Directory.TAG_ORIENTATION)) {
    735735                setExifOrientation(dirExif.getInt(ExifIFD0Directory.TAG_ORIENTATION));
    736736            }
     
    740740
    741741        try {
    742             if (dir != null) {
     742            if (dir != null && dir.containsTag(JpegDirectory.TAG_IMAGE_WIDTH) && dir.containsTag(JpegDirectory.TAG_IMAGE_HEIGHT)) {
    743743                // there are cases where these do not match width and height stored in dirExif
    744744                setWidth(dir.getInt(JpegDirectory.TAG_IMAGE_WIDTH));
  • trunk/src/org/openstreetmap/josm/tools/ExifReader.java

    r18014 r18315  
    177177     */
    178178    public static LatLon readLatLon(GpsDirectory dirGps) throws MetadataException {
    179         if (dirGps != null && dirGps.getTagCount() > 1) {
     179        if (dirGps != null && dirGps.containsTag(GpsDirectory.TAG_LATITUDE) && dirGps.containsTag(GpsDirectory.TAG_LONGITUDE)) {
    180180            double lat = readAxis(dirGps, GpsDirectory.TAG_LATITUDE, GpsDirectory.TAG_LATITUDE_REF, 'S');
    181181            double lon = readAxis(dirGps, GpsDirectory.TAG_LONGITUDE, GpsDirectory.TAG_LONGITUDE_REF, 'W');
     
    297297    public static Double readElevation(File filename) {
    298298        try {
    299             final Metadata metadata = JpegMetadataReader.readMetadata(filename);
    300             final GpsDirectory dirGps = metadata.getFirstDirectoryOfType(GpsDirectory.class);
    301             return readElevation(dirGps);
     299            return readElevation(JpegMetadataReader.readMetadata(filename).getFirstDirectoryOfType(GpsDirectory.class));
    302300        } catch (JpegProcessingException | IOException e) {
    303301            Logging.error(e);
    304         }
    305         return null;
     302            return null;
     303        }
    306304    }
    307305
Note: See TracChangeset for help on using the changeset viewer.