Changeset 18130 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2021-08-09T22:08:44+02:00 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/gpx/GpxImageCorrelation.java
r18123 r18130 81 81 boolean firstSegment = true; 82 82 for (List<WayPoint> wps : segs) { 83 for (int i = 0; i < wps.size(); i++) { 83 int size = wps.size(); 84 for (int i = 0; i < size; i++) { 84 85 final WayPoint curWp = wps.get(i); 85 86 // Interpolate timestamps in the segment, if one or more waypoints miss them … … 90 91 double totalDist = 0; 91 92 List<Pair<Double, WayPoint>> nextWps = new ArrayList<>(); 92 for (int j = i; j < wps.size(); j++) {93 for (int j = i; j < size; j++) { 93 94 totalDist += wps.get(j - 1).getCoor().greatCircleDistance(wps.get(j).getCoor()); 94 95 nextWps.add(new Pair<>(totalDist, wps.get(j))); … … 139 140 } 140 141 } 141 ret += matchPoints(images, prevWp, prevWpTime, curWp, curWpTime, offset, interpolate, tagTime, false, dirpos); 142 WayPoint nextWp = i < size - 1 ? wps.get(i + 1) : null; 143 ret += matchPoints(images, prevWp, prevWpTime, curWp, curWpTime, offset, interpolate, tagTime, nextWp, dirpos); 142 144 prevWp = curWp; 143 145 prevWpTime = curWpTime; … … 146 148 } 147 149 if (trkTag && prevWp != null) { 148 ret += matchPoints(images, prevWp, prevWpTime, prevWp, prevWpTime, offset, false, trkTagTime, true, dirpos);150 ret += matchPoints(images, prevWp, prevWpTime, prevWp, prevWpTime, offset, false, trkTagTime, null, dirpos); 149 151 } 150 152 return ret; … … 207 209 208 210 private static int matchPoints(List<? extends GpxImageEntry> images, WayPoint prevWp, long prevWpTime, WayPoint curWp, long curWpTime, 209 long offset, boolean interpolate, int tagTime, boolean isLast, GpxImageDirectionPositionSettings dirpos) {211 long offset, boolean interpolate, int tagTime, WayPoint nextWp, GpxImageDirectionPositionSettings dirpos) { 210 212 211 213 int ret = 0; 214 final boolean isLast = nextWp == null; 212 215 213 216 // i is the index of the timewise last photo that has the same or earlier EXIF time … … 254 257 } else { 255 258 curTmp.setPos(curWp.getCoor()); 259 } 260 if (nextWp != null && dirpos.isSetImageDirection()) { 261 double direction = curWp.getCoor().bearing(nextWp.getCoor()); 262 curTmp.setExifImgDir(computeDirection(direction, dirpos.getImageDirectionAngleOffset())); 256 263 } 257 264 curTmp.setGpsTime(curImg.getExifInstant().minusMillis(offset)); … … 280 287 final LatLon curCoor = curWp.getCoor(); 281 288 LatLon position = prevCoor.interpolate(curCoor, timeDiff); 282 if ( shiftXY || dirpos.isSetImageDirection()) {283 double direction = prevCoor.bearing(curCoor);289 if (nextWp != null && (shiftXY || dirpos.isSetImageDirection())) { 290 double direction = curCoor.bearing(nextWp.getCoor()); 284 291 if (dirpos.isSetImageDirection()) { 285 curTmp.setExifImgDir( (Utils.toDegrees(direction) + dirpos.getImageDirectionAngleOffset()) % 360d);292 curTmp.setExifImgDir(computeDirection(direction, dirpos.getImageDirectionAngleOffset())); 286 293 } 287 294 if (shiftXY) { … … 310 317 } 311 318 return ret; 319 } 320 321 private static double computeDirection(double direction, double angleOffset) { 322 return (Utils.toDegrees(direction) + angleOffset) % 360d; 312 323 } 313 324
Note:
See TracChangeset
for help on using the changeset viewer.