Ignore:
Timestamp:
2016-09-21T12:17:21+02:00 (8 years ago)
Author:
simon04
Message:

fix #13668 - Simplify ImageEntry#extractExif

File:
1 edited

Legend:

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

    r10420 r11037  
    55import java.io.File;
    66import java.io.IOException;
    7 import java.util.Calendar;
    87import java.util.Collections;
    98import java.util.Date;
    10 import java.util.GregorianCalendar;
    11 import java.util.TimeZone;
    129
    1310import org.openstreetmap.josm.Main;
     
    524521        }
    525522
    526         // Time and date. We can have these cases:
    527         // 1) GPS_TIME_STAMP not set -> date/time will be null
    528         // 2) GPS_DATE_STAMP not set -> use EXIF date or set to default
    529         // 3) GPS_TIME_STAMP and GPS_DATE_STAMP are set
    530         int[] timeStampComps = dirGps.getIntArray(GpsDirectory.TAG_TIME_STAMP);
    531         if (timeStampComps != null) {
    532             int gpsHour = timeStampComps[0];
    533             int gpsMin = timeStampComps[1];
    534             int gpsSec = timeStampComps[2];
    535             Calendar cal = new GregorianCalendar(TimeZone.getTimeZone("UTC"));
    536 
    537             // We have the time. Next step is to check if the GPS date stamp is set.
    538             // dirGps.getString() always succeeds, but the return value might be null.
    539             String dateStampStr = dirGps.getString(GpsDirectory.TAG_DATE_STAMP);
    540             if (dateStampStr != null && dateStampStr.matches("^\\d+:\\d+:\\d+$")) {
    541                 String[] dateStampComps = dateStampStr.split(":");
    542                 cal.set(Calendar.YEAR, Integer.parseInt(dateStampComps[0]));
    543                 cal.set(Calendar.MONTH, Integer.parseInt(dateStampComps[1]) - 1);
    544                 cal.set(Calendar.DAY_OF_MONTH, Integer.parseInt(dateStampComps[2]));
    545             } else {
    546                 // No GPS date stamp in EXIF data. Copy it from EXIF time.
    547                 // Date is not set if EXIF time is not available.
    548                 if (hasExifTime()) {
    549                     // Time not set yet, so we can copy everything, not just date.
    550                     cal.setTime(getExifTime());
    551                 }
    552             }
    553 
    554             cal.set(Calendar.HOUR_OF_DAY, gpsHour);
    555             cal.set(Calendar.MINUTE, gpsMin);
    556             cal.set(Calendar.SECOND, gpsSec);
    557 
    558             setExifGpsTime(cal.getTime());
     523        final Date gpsDate = dirGps.getGpsDate();
     524        if (gpsDate != null) {
     525            setExifGpsTime(gpsDate);
    559526        }
    560527    }
Note: See TracChangeset for help on using the changeset viewer.