Ticket #15701: CorrelateGpxWithImages_newSpeedEle.patch
File CorrelateGpxWithImages_newSpeedEle.patch, 4.9 KB (added by , 7 years ago) |
---|
-
src/org/openstreetmap/josm/gui/layer/geoimage/ImageEntry.java
455 455 } 456 456 457 457 /** 458 * Queries whether the GPS data changed. 458 * Queries whether the GPS data changed. The flag value from the temporary 459 * copy is returned if that copy exists. 459 460 * @return {@code true} if GPS data changed, {@code false} otherwise 460 461 * @since 6392 461 462 */ 462 463 public boolean hasNewGpsData() { 464 if (tmp != null) 465 return tmp.isNewGpsData; 463 466 return isNewGpsData; 464 467 } 465 468 -
test/unit/org/openstreetmap/josm/gui/layer/geoimage/CorrelateGpxWithImagesTest.java
2 2 package org.openstreetmap.josm.gui.layer.geoimage; 3 3 4 4 import static org.junit.Assert.assertEquals; 5 import static org.junit.Assert.assertFalse; 6 import static org.junit.Assert.assertTrue; 5 7 6 8 import java.util.Arrays; 7 9 import java.util.Collections; … … 51 53 assertEquals(1, gpx.tracks.iterator().next().getSegments().size()); 52 54 assertEquals(185, gpx.tracks.iterator().next().getSegments().iterator().next().getWayPoints().size()); 53 55 56 final ImageEntry ib = new ImageEntry(); 57 ib.setExifTime(DateUtils.fromString("2016:01:03 11:54:58")); // 5 minutes before start of GPX 58 ib.createTmp(); 54 59 final ImageEntry i0 = new ImageEntry(); 55 60 i0.setExifTime(DateUtils.fromString("2016:01:03 11:59:54")); // 4 sec before start of GPX 56 61 i0.createTmp(); … … 64 69 i3.setExifTime(DateUtils.fromString("2016:01:03 12:05:05")); 65 70 i3.createTmp(); 66 71 67 assertEquals(4, CorrelateGpxWithImages.matchGpxTrack(Arrays.asList(i 0, i1, i2, i3), gpx, 0));72 assertEquals(4, CorrelateGpxWithImages.matchGpxTrack(Arrays.asList(ib, i0, i1, i2, i3), gpx, 0)); 68 73 assertEquals(new CachedLatLon(47.19286847859621, 8.79732714034617), i0.getPos()); // start of track 69 74 assertEquals(new CachedLatLon(47.196979885920882, 8.79541271366179), i1.getPos()); // exact match 70 75 assertEquals(new CachedLatLon(47.197319911792874, 8.792139580473304), i3.getPos()); // exact match 71 76 assertEquals(new CachedLatLon((47.197131179273129 + 47.197186248376966) / 2, (8.792974585667253 + 8.792809881269932) / 2), 72 77 i2.getPos()); // interpolated 78 assertFalse(ib.hasNewGpsData()); 79 assertTrue(i0.hasNewGpsData()); 80 assertTrue(i1.hasNewGpsData()); 81 assertTrue(i2.hasNewGpsData()); 82 assertTrue(i3.hasNewGpsData()); 83 // First waypoint has no speed in matchGpxTrack(). Speed is calculated 84 // and not taken from GPX track. 85 assertEquals(null, ib.getSpeed()); 86 assertEquals(null, i0.getSpeed()); 87 assertEquals(new Double(11.675317966018756), i1.getSpeed(), 0.000001); 88 assertEquals(new Double(24.992418392716967), i2.getSpeed(), 0.000001); 89 assertEquals(new Double(27.307968754679223), i3.getSpeed(), 0.000001); 90 assertEquals(null, ib.getElevation()); 91 assertEquals(new Double(471.86), i0.getElevation(), 0.000001); 92 assertEquals(new Double(489.29), i1.getElevation(), 0.000001); 93 assertEquals(new Double((490.40 + 489.75) / 2), i2.getElevation(), 0.000001); 94 assertEquals(new Double(486.368333333), i3.getElevation(), 0.000001); 95 assertEquals(null, ib.getGpsTime()); 96 assertEquals(DateUtils.fromString("2016:01:03 11:59:54"), i0.getGpsTime()); // original time is kept 97 assertEquals(DateUtils.fromString("2016:01:03 12:04:01"), i1.getGpsTime()); 98 assertEquals(DateUtils.fromString("2016:01:03 12:04:57"), i2.getGpsTime()); 99 assertEquals(DateUtils.fromString("2016:01:03 12:05:05"), i3.getGpsTime()); 73 100 } 74 101 75 102 /** -
data_nodist/2094047.gpx
33 33 <trkseg> 34 34 <trkpt lat="47.19286847859621" lon="8.79732714034617"> 35 35 <ele>471.86000000000001</ele> 36 <speed>12.399</speed> 36 37 <time>2016-01-03T11:59:58Z</time> 37 38 </trkpt> 38 39 <trkpt lat="47.192921955138445" lon="8.797342479228973"> … … 277 278 </trkpt> 278 279 <trkpt lat="47.196979885920882" lon="8.79541271366179"> 279 280 <ele>489.29000000000002</ele> 281 <speed>7.38</speed> 280 282 <time>2016-01-03T12:04:01Z</time> 281 283 </trkpt> 282 284 <trkpt lat="47.196987261995673" lon="8.795355297625065">