Changeset 11288 in josm for trunk/src/org/openstreetmap/josm/gui/layer/geoimage/CorrelateGpxWithImages.java
- Timestamp:
- 2016-11-20T17:33:33+01:00 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/layer/geoimage/CorrelateGpxWithImages.java
r11017 r11288 38 38 import java.util.Objects; 39 39 import java.util.TimeZone; 40 import java.util.concurrent.TimeUnit; 40 41 import java.util.zip.GZIPInputStream; 41 42 … … 408 409 TimeZone tz = TimeZone.getTimeZone(tzStr); 409 410 410 String tzDesc = new StringBuilder(tzStr).append(" (")411 .append(new Timezone(tz.getRawOffset() / 3600000.0).formatTimezone())412 .append(')').toString();411 String tzDesc = tzStr + " (" + 412 new Timezone(((double) tz.getRawOffset()) / TimeUnit.HOURS.toMillis(1)).formatTimezone() + 413 ')'; 413 414 vtTimezones.add(tzDesc); 414 415 } … … 426 427 } 427 428 428 cbTimezones.setSelectedItem( new StringBuilder(defaultTz.getID()).append(" (")429 .append(new Timezone(defaultTz.getRawOffset() / 3600000.0).formatTimezone())430 .append(')').toString());429 cbTimezones.setSelectedItem(defaultTz.getID() + " (" + 430 new Timezone(((double) defaultTz.getRawOffset()) / TimeUnit.HOURS.toMillis(1)).formatTimezone() + 431 ')'); 431 432 432 433 gc.gridx = 1; … … 815 816 return tr("No gpx selected"); 816 817 817 final long offsetMs = ((long) (timezone.getHours() * 3600 * 1000)) + delta.getMilliseconds(); // in milliseconds818 final long offsetMs = ((long) (timezone.getHours() * TimeUnit.HOURS.toMillis(1))) + delta.getMilliseconds(); // in milliseconds 818 819 lastNumMatched = matchGpxTrack(dateImgLst, selGpx.data, offsetMs); 819 820 … … 846 847 847 848 final Offset offset = Offset.milliseconds( 848 delta.getMilliseconds() + Math.round(timezone.getHours() * 60 * 60 * 1000));849 delta.getMilliseconds() + Math.round(timezone.getHours() * TimeUnit.HOURS.toMillis(1))); 849 850 final int dayOffset = offset.getDayOffset(); 850 851 final Pair<Timezone, Offset> timezoneOffsetPair = offset.withoutDayOffset().splitOutTimezone(); … … 897 898 898 899 delta = Offset.milliseconds(100L * sldSeconds.getValue() 899 + 1000L * 60 * sldMinutes.getValue()900 + 1000L * 60 * 60 * 24 * dayOffset);900 + TimeUnit.MINUTES.toMillis(sldMinutes.getValue()) 901 + TimeUnit.DAYS.toMillis(dayOffset)); 901 902 902 903 tfTimezone.getDocument().removeDocumentListener(statusBarUpdater); … … 1146 1147 // Time between the track point and the previous one, 5 sec if first point, i.e. photos take 1147 1148 // 5 sec before the first track point can be assumed to be take at the starting position 1148 long interval = prevWpTime > 0 ? Math.abs(curWpTime - prevWpTime) : 5*1000;1149 long interval = prevWpTime > 0 ? Math.abs(curWpTime - prevWpTime) : TimeUnit.SECONDS.toMillis(5); 1149 1150 int ret = 0; 1150 1151 … … 1432 1433 1433 1434 int getDayOffset() { 1434 final double diffInH = getMilliseconds() / 1000. / 60 / 60; // hours1435 1436 1435 // Find day difference 1437 return (int) Math.round( diffInH / 24);1436 return (int) Math.round(((double) getMilliseconds()) / TimeUnit.DAYS.toMillis(1)); 1438 1437 } 1439 1438 1440 1439 Offset withoutDayOffset() { 1441 return milliseconds(getMilliseconds() - getDayOffset() * 24L * 60L * 60L * 1000L);1440 return milliseconds(getMilliseconds() - TimeUnit.DAYS.toMillis(getDayOffset())); 1442 1441 } 1443 1442 1444 1443 Pair<Timezone, Offset> splitOutTimezone() { 1445 1444 // In hours 1446 double tz = withoutDayOffset().getSeconds() / 3600.0;1445 final double tz = ((double) withoutDayOffset().getSeconds()) / TimeUnit.HOURS.toSeconds(1); 1447 1446 1448 1447 // Due to imprecise clocks we might get a "+3:28" timezone, which should obviously be 3:30 with 1449 1448 // -2 minutes offset. This determines the real timezone and finds offset. 1450 1449 final double timezone = (double) Math.round(tz * 2) / 2; // hours, rounded to one decimal place 1451 final long delta = Math.round(getMilliseconds() - timezone * 60 * 60 * 1000); // milliseconds1450 final long delta = Math.round(getMilliseconds() - timezone * TimeUnit.HOURS.toMillis(1)); 1452 1451 return Pair.create(new Timezone(timezone), Offset.milliseconds(delta)); 1453 1452 }
Note:
See TracChangeset
for help on using the changeset viewer.