Skip to content

Commit

Permalink
see #21144 - fix #21334 - fix correlated image direction when positio…
Browse files Browse the repository at this point in the history
…n is between 2 gpx points

git-svn-id: https://josm.openstreetmap.de/svn/trunk@18237 0c6e7542-c601-0410-84e7-c038aed88b3b
  • Loading branch information
don-vip committed Sep 29, 2021
1 parent 1a11093 commit 97f1525
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/org/openstreetmap/josm/data/gpx/GpxImageCorrelation.java
Original file line number Diff line number Diff line change
Expand Up @@ -272,22 +272,23 @@ private static int matchPoints(List<? extends GpxImageEntry> images, WayPoint pr
} else if (prevWp != null) {
// This code gives a simple linear interpolation of the coordinates between current and
// previous track point assuming a constant speed in between
LatLon nextCoorForDirection = nextWp != null ? nextWp.getCoor() : null;
while (i >= 0) {
final GpxImageEntry curImg = images.get(i);
final GpxImageEntry curTmp = curImg.getTmp();
final long imgTime = curImg.getExifInstant().toEpochMilli();
if (imgTime < prevWpTime) {
break;
}
final GpxImageEntry curTmp = curImg.getTmp();
if (!curTmp.hasNewGpsData()) {
// The values of timeDiff are between 0 and 1, it is not seconds but a dimensionless variable
final double timeDiff = (double) (imgTime - prevWpTime) / Math.abs(curWpTime - prevWpTime);
final boolean shiftXY = dirpos.getShiftImageX() != 0d || dirpos.getShiftImageY() != 0d;
final LatLon prevCoor = prevWp.getCoor();
final LatLon curCoor = curWp.getCoor();
LatLon position = prevCoor.interpolate(curCoor, timeDiff);
if (nextWp != null && (shiftXY || dirpos.isSetImageDirection())) {
double direction = curCoor.bearing(nextWp.getCoor());
if (nextCoorForDirection != null && (shiftXY || dirpos.isSetImageDirection())) {
double direction = position.bearing(nextCoorForDirection);
if (dirpos.isSetImageDirection()) {
curTmp.setExifImgDir(computeDirection(direction, dirpos.getImageDirectionAngleOffset()));
}
Expand All @@ -310,6 +311,7 @@ private static int matchPoints(List<? extends GpxImageEntry> images, WayPoint pr
curTmp.flagNewGpsData();
curImg.tmpUpdated();

nextCoorForDirection = curCoor;
ret++;
}
i--;
Expand Down

0 comments on commit 97f1525

Please sign in to comment.