Skip to content

Commit

Permalink
Lots of spammy logs in gpx interpolation logic (not changed any logic…
Browse files Browse the repository at this point in the history
… (yet))
  • Loading branch information
RudyTheDev committed May 28, 2022
1 parent a64959d commit 4884833
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
11 changes: 11 additions & 0 deletions mapillary_tools/geo.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,3 +184,14 @@ def interpolate_lat_lon(points: List[Point], timestamp: datetime.datetime) -> Po
else:
alt = None
return Point(lat=lat, lon=lon, alt=alt, angle=angle, time=timestamp)


# my hackery - a copy of interpolate_lat_lon but only the raw index for debug
def interpolate_idx(points: List[Point], timestamp: datetime.datetime) -> int:
if not points:
raise ValueError("Expect non-empty points")
# Make sure that points are sorted:
# for cur, nex in pairwise(points):
# assert cur.time <= nex.time, "Points not sorted"
idx = bisect.bisect_left([x.time for x in points], timestamp)
return idx
14 changes: 13 additions & 1 deletion mapillary_tools/geotag/geotag_from_gpx.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
MapillaryGPXEmptyError,
)
from ..exif_read import ExifRead
from ..geo import interpolate_lat_lon, Point
from ..geo import interpolate_lat_lon, Point, interpolate_idx


LOG = logging.getLogger(__name__)
Expand Down Expand Up @@ -105,10 +105,17 @@ def to_description(self) -> T.List[types.ImageDescriptionFileOrError]:
Point(lat=p.lat, lon=p.lon, alt=p.alt, time=p.time, angle=None)
for p in track
]

# my hackery - gpx timestamps
LOG.debug("GPX start timestamp: %s", types.datetime_to_map_capture_time(sorted_points[0].time))
LOG.debug("GPX end timestamp: %s", types.datetime_to_map_capture_time(sorted_points[-1].time))

for exif_time, image in sorted_images:
exif_time = exif_time + datetime.timedelta(seconds=image_time_offset)

# my hackery - extra spammy per-image timestamp
#LOG.debug("Image timestamp (offset): %s", exif_time)

if exif_time < sorted_points[0].time:
delta = sorted_points[0].time - exif_time
exc2 = MapillaryOutsideGPXTrackError(
Expand Down Expand Up @@ -140,6 +147,11 @@ def to_description(self) -> T.List[types.ImageDescriptionFileOrError]:
continue

interpolated = interpolate_lat_lon(sorted_points, exif_time)

# my hackery - resulting interpolated point
idx = interpolate_idx(sorted_points, exif_time)
LOG.debug(f"GPX interpolated point lat, lon: {round(interpolated.lat, 6)}, {round(interpolated.lon, 6)} ({idx} / {len(sorted_points)}) @ {exif_time}")

point = types.GPXPointAngle(
point=types.GPXPoint(
time=exif_time,
Expand Down

0 comments on commit 4884833

Please sign in to comment.