Skip to content

Commit

Permalink
see #21144 - see #21334 - add debug logs + fix coverity 1464077 (Logi…
Browse files Browse the repository at this point in the history
…cally dead code: nextWp cannot be null with the isLast branch, but Eclipse doesn't see it)

git-svn-id: https://josm.openstreetmap.de/svn/trunk@18243 0c6e7542-c601-0410-84e7-c038aed88b3b
  • Loading branch information
don-vip committed Oct 3, 2021
1 parent 139f3ca commit e43d48d
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/org/openstreetmap/josm/data/gpx/GpxImageCorrelation.java
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ public static int matchGpxTrack(List<? extends GpxImageEntry> images, GpxData se
if (trkTag && prevWp != null) {
ret += matchPoints(images, prevWp, prevWpTime, prevWp, prevWpTime, offset, false, trkTagTime, null, dirpos);
}
Logging.debug("Correlated {0} total points", ret);
return ret;
}

Expand Down Expand Up @@ -210,7 +211,6 @@ static Double getElevation(WayPoint wp) {
private static int matchPoints(List<? extends GpxImageEntry> images, WayPoint prevWp, long prevWpTime, WayPoint curWp, long curWpTime,
long offset, boolean interpolate, int tagTime, WayPoint nextWp, GpxImageDirectionPositionSettings dirpos) {

int ret = 0;
final boolean isLast = nextWp == null;

// i is the index of the timewise last photo that has the same or earlier EXIF time
Expand All @@ -221,10 +221,18 @@ private static int matchPoints(List<? extends GpxImageEntry> images, WayPoint pr
i = getLastIndexOfListBefore(images, curWpTime);
}

if (Logging.isDebugEnabled()) {
Logging.debug("Correlating images for i={1} - curWp={2}/{3} - prevWp={4}/{5} - nextWp={6} - tagTime={7} - interpolate={8}",
i, curWp, curWpTime, prevWp, prevWpTime, nextWp, tagTime, interpolate);
}

// no photos match
if (i < 0)
if (i < 0) {
Logging.debug("Correlated nothing, no photos match");
return 0;
}

int ret = 0;
Double speed = null;
Double prevElevation = null;

Expand Down Expand Up @@ -272,7 +280,8 @@ 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;
@SuppressWarnings("null")
LatLon nextCoorForDirection = nextWp.getCoor();
while (i >= 0) {
final GpxImageEntry curImg = images.get(i);
final long imgTime = curImg.getExifInstant().toEpochMilli();
Expand Down Expand Up @@ -317,6 +326,7 @@ private static int matchPoints(List<? extends GpxImageEntry> images, WayPoint pr
i--;
}
}
Logging.debug("Correlated {0} image(s)", ret);
return ret;
}

Expand Down

0 comments on commit e43d48d

Please sign in to comment.