Changeset 4772 in josm


Ignore:
Timestamp:
Jan 8, 2012 5:14:32 PM (18 months ago)
Author:
bastiK
Message:

fixed #7228 - HTC Sensation uses / as date separator, date parsed wrong when geotagging

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/tools/ExifReader.java

    r4241 r4772  
    2222 
    2323    @SuppressWarnings("unchecked") public static Date readTime(File filename) throws ParseException { 
    24         Date date = null; 
    2524        try { 
    2625            Metadata metadata = JpegMetadataReader.readMetadata(filename); 
     26            String dateStr = null; 
     27            OUTER: 
    2728            for (Iterator<Directory> dirIt = metadata.getDirectoryIterator(); dirIt.hasNext();) { 
    2829                for (Iterator<Tag> tagIt = dirIt.next().getTagIterator(); tagIt.hasNext();) { 
    2930                    Tag tag = tagIt.next(); 
    30                     if (tag.getTagType() == 0x9003) 
    31                         return DateParser.parse(tag.getDescription()); 
    32                     if (tag.getTagType() == 0x132 || tag.getTagType() == 0x9004) 
    33                         date = DateParser.parse(tag.getDescription()); 
     31                    if (tag.getTagType() == ExifDirectory.TAG_DATETIME_ORIGINAL /* 0x9003 */) { 
     32                        dateStr = tag.getDescription(); 
     33                        break OUTER; // prefer this tag 
     34                    } 
     35                    if (tag.getTagType() == ExifDirectory.TAG_DATETIME /* 0x0132 */ || 
     36                        tag.getTagType() == ExifDirectory.TAG_DATETIME_DIGITIZED /* 0x9004 */) { 
     37                        dateStr = tag.getDescription(); 
     38                    } 
    3439                } 
    3540            } 
     41            dateStr = dateStr.replace('/', ':'); // workaround for HTC Sensation bug, see #7228 
     42            return DateParser.parse(dateStr); 
    3643        } catch (ParseException e) { 
    3744            throw e; 
     
    3946            e.printStackTrace(); 
    4047        } 
    41         return date; 
     48        return null; 
    4249    } 
    4350 
Note: See TracChangeset for help on using the changeset viewer.