Skip to content

Commit

Permalink
improve GPX parsing error message (#712)
Browse files Browse the repository at this point in the history
  • Loading branch information
ptpt authored Feb 23, 2025
1 parent 8fd99ee commit 4f0b470
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 7 additions & 1 deletion mapillary_tools/geotag/geotag_images_from_gpx_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,13 @@ def __init__(
num_processes: T.Optional[int] = None,
):
super().__init__()
tracks = parse_gpx(source_path)
try:
tracks = parse_gpx(source_path)
except Exception as ex:
raise RuntimeError(
f"Error parsing GPX {source_path}: {ex.__class__.__name__}: {ex}"
)

if 1 < len(tracks):
LOG.warning(
"Found %s tracks in the GPX file %s. Will merge points in all the tracks as a single track for interpolation",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,13 @@ def extract_points(self) -> T.Sequence[geo.Point]:
if not path:
return []

gpx_tracks = geotag_images_from_gpx_file.parse_gpx(path)
try:
gpx_tracks = geotag_images_from_gpx_file.parse_gpx(path)
except Exception as ex:
raise RuntimeError(
f"Error parsing GPX {path}: {ex.__class__.__name__}: {ex}"
)

if 1 < len(gpx_tracks):
LOG.warning(
"Found %s tracks in the GPX file %s. Will merge points in all the tracks as a single track for interpolation",
Expand Down

0 comments on commit 4f0b470

Please sign in to comment.