Ticket #11710: 11710-V2.patch
| File 11710-V2.patch, 7.9 KB (added by , 5 years ago) |
|---|
-
src/org/openstreetmap/josm/data/gpx/GpxImageEntry.java
### Eclipse Workspace Patch 1.0 #P josm-11710
571 571 elevation = tmp.elevation; 572 572 gpsTime = tmp.gpsTime; 573 573 exifImgDir = tmp.exifImgDir; 574 isNewGpsData = tmp.isNewGpsData;574 isNewGpsData = isNewGpsData || tmp.isNewGpsData; 575 575 tmp = null; 576 576 } 577 577 tmpUpdated(); -
src/org/openstreetmap/josm/data/gpx/GpxImageCorrelation.java
229 229 break; 230 230 } 231 231 long tagms = TimeUnit.MINUTES.toMillis(tagTime); 232 if ( curTmp.getPos() == null&&232 if (!curTmp.hasNewGpsData() && 233 233 (Math.abs(time - curWpTime) <= tagms 234 234 || Math.abs(prevWpTime - time) <= tagms)) { 235 235 if (prevWp != null && time < curWpTime - half) { … … 255 255 if (imgTime < prevWpTime) { 256 256 break; 257 257 } 258 if ( curTmp.getPos() == null) {258 if (!curTmp.hasNewGpsData()) { 259 259 // The values of timeDiff are between 0 and 1, it is not seconds but a dimensionless variable 260 260 double timeDiff = (double) (imgTime - prevWpTime) / Math.abs(curWpTime - prevWpTime); 261 261 curTmp.setPos(prevWp.getCoor().interpolate(curWp.getCoor(), timeDiff)); -
src/org/openstreetmap/josm/gui/layer/geoimage/CorrelateGpxWithImages.java
1090 1090 // Construct a list of images that have a date, and sort them on the date. 1091 1091 List<ImageEntry> dateImgLst = getSortedImgList(); 1092 1092 // Create a temporary copy for each image 1093 for (ImageEntry ie : dateImgLst){1094 i e.createTmp();1095 i e.getTmp().setPos(null);1096 } 1093 dateImgLst.forEach(i -> { 1094 i.createTmp(); 1095 i.getTmp().unflagNewGpsData(); 1096 }); 1097 1097 1098 1098 GpxDataWrapper selGpx = selectedGPX(false); 1099 1099 if (selGpx == null) -
test/unit/org/openstreetmap/josm/data/gpx/GpxImageCorrelationTest.java
64 64 i0.createTmp(); 65 65 final GpxImageEntry i1 = new GpxImageEntry(); 66 66 i1.setExifTime(DateUtils.parseInstant("2016:01:03 12:04:01")); 67 i1.setPos(new CachedLatLon(2, 3)); //existing position inside the track, should always be overridden 67 68 i1.createTmp(); 68 69 final GpxImageEntry i2 = new GpxImageEntry(); 69 70 i2.setExifTime(DateUtils.parseInstant("2016:01:03 12:04:57")); … … 80 81 final GpxImageEntry i6 = new GpxImageEntry(); //between two tracks, closer to second (more than 1 minute from any track) 81 82 i6.setExifTime(DateUtils.parseInstant("2016:01:03 12:07:45")); 82 83 i6.createTmp(); 84 final GpxImageEntry i7 = new GpxImageEntry(); 85 i7.setExifTime(DateUtils.parseInstant("2021:01:01 00:00:00")); 86 i7.setPos(new CachedLatLon(1, 2)); //existing position outside the track, should never be null (either overridden or keeping old position, see #11710) 87 i7.createTmp(); 83 88 84 List<GpxImageEntry> images = Arrays.asList(ib, i0, i1, i2, i3, i4, i5, i6 );89 List<GpxImageEntry> images = Arrays.asList(ib, i0, i1, i2, i3, i4, i5, i6, i7); 85 90 86 91 // TEST #1: default settings 87 92 // tag images within 2 minutes to tracks/segments, interpolate between segments only … … 98 103 i5.getPos()); // tagged to last WP of first track, because closer and within 2 min (default setting) 99 104 assertEquals(new CachedLatLon(47.20138901844621, 8.774476982653141), 100 105 i6.getPos()); // tagged to first WP of second track, because closer and within 2 min (default setting) 101 assertFalse(ib.hasNewGpsData()); 106 assertEquals(new CachedLatLon(1, 2), i7.getPos()); //existing EXIF data is kept 107 assertFalse(ib.hasNewGpsData() || i7.hasNewGpsData()); 102 108 assertTrue(i0.hasNewGpsData() && i1.hasNewGpsData() && i2.hasNewGpsData() && i3.hasNewGpsData() 103 109 && i4.hasNewGpsData() && i5.hasNewGpsData() && i6.hasNewGpsData()); 104 110 // First waypoint has no speed in matchGpxTrack(). Speed is calculated … … 147 153 148 154 // TEST #3: Disable all interpolation and allow tagging within 1 minute of a track. i0-i5 are tagged. 149 155 // i6 will not be tagged, because it's 68 seconds away from the next waypoint in either direction 156 // i7 will keep the old position 150 157 151 158 s.putBoolean("geoimage.trk.tag", true); 152 159 s.putBoolean("geoimage.trk.tag.time", true); … … 165 172 assertEquals(new CachedLatLon(47.197568312311816, 8.790292849679897), i4.getPos()); 166 173 assertEquals(new CachedLatLon(47.19819249585271, 8.78536943346262), i5.getPos()); 167 174 assertEquals(null, i6.getPos()); 175 assertEquals(new CachedLatLon(1, 2), i7.getPos()); 168 176 169 177 clearTmp(images); 170 178 171 179 // TEST #4: Force tagging (parameter forceTags=true, no change of configuration). All images will be tagged 172 180 // i5-i6 will now be interpolated, therefore it will have an elevation and different coordinates than in tests above 181 // i7 will be at the end of the track 173 182 174 assertEquals( 8, GpxImageCorrelation.matchGpxTrack(images, gpx, 0, true));183 assertEquals(9, GpxImageCorrelation.matchGpxTrack(images, gpx, 0, true)); 175 184 assertEquals(new CachedLatLon(47.19286847859621, 8.79732714034617), ib.getPos()); 176 185 assertEquals(new CachedLatLon(47.19286847859621, 8.79732714034617), i0.getPos()); 177 186 assertEquals(new CachedLatLon(47.196979885920882, 8.79541271366179), i1.getPos()); … … 184 193 assertEquals(Double.valueOf(447.894014085), i5.getElevation(), 0.000001); 185 194 assertEquals(Double.valueOf(437.395070423), i6.getElevation(), 0.000001); 186 195 196 assertEquals(new CachedLatLon(47.20126815140247, 8.77192972227931), i7.getPos()); 197 187 198 clearTmp(images); 188 199 189 200 // TEST #5: Force tagging (parameter forceTags=false, but configuration changed). … … 201 212 s.putBoolean("geoimage.seg.int.time", false); 202 213 s.putBoolean("geoimage.seg.int.dist", false); 203 214 204 assertEquals( 8, GpxImageCorrelation.matchGpxTrack(images, gpx, 0, false));215 assertEquals(9, GpxImageCorrelation.matchGpxTrack(images, gpx, 0, false)); 205 216 assertEquals(new CachedLatLon(47.19286847859621, 8.79732714034617), ib.getPos()); 206 217 assertEquals(new CachedLatLon(47.19286847859621, 8.79732714034617), i0.getPos()); 207 218 assertEquals(new CachedLatLon(47.196979885920882, 8.79541271366179), i1.getPos()); … … 214 225 assertEquals(Double.valueOf(447.894014085), i5.getElevation(), 0.000001); 215 226 assertEquals(Double.valueOf(437.395070423), i6.getElevation(), 0.000001); 216 227 228 assertEquals(new CachedLatLon(47.20126815140247, 8.77192972227931), i7.getPos()); 229 217 230 clearTmp(images); 218 231 219 232 // TEST #6: Disable tagging but allow interpolation when tracks are less than 500m apart. i0-i4 are tagged.
