Skip to content

Report a GPX file that images cannot be geotagged from as an error per image - #864

Merged
caglarpir merged 2 commits into
mapillary:mainfrom
caglarpir:report-invalid-gpx-for-images
Oct 22, 2026
Merged

caglarpir merged 2 commits into
mapillary:mainfrom
caglarpir:report-invalid-gpx-for-images

Conversation

@caglarpir

Copy link
Copy Markdown
Contributor

Stacked on #863; review the last commit.

Problem

Images geotagged from a GPX file that cannot be read crashed the whole run with a traceback, while a video given the same file gets a MapillaryInvalidGPXError in its description (#845):

mapillary_tools process SEQUENCE_DIR --geotag_source gpx --geotag_source_path truncated.gpx
# RuntimeError: Error parsing GPX truncated.gpx: GPXXMLSyntaxException

A path that does not exist failed with a RuntimeError too, and a GPX with no timestamped point with an AssertionError. An NMEA file crashed in the same cases, and also on a sentence without a time or date (TypeError) or a file with no RMC sentence (UnboundLocalError).

Fix

Every image gets a MapillaryInvalidGPXError saying what is wrong with the file: not found, no timestamped points, or not a valid GPX/NMEA file. The run exits as for any other file that fails to process. The error is final: the file was given to geotag these images, so a mistyped path fails them, as it did, instead of leaving them to the next geotag source without a word.

Verification

  • A truncated GPX and a 24-byte text file each give 11 × MapillaryInvalidGPXError on an 11-image sequence, exit 6 (was a traceback). A void-RMC NMEA file and a GGA-only one do the same.
  • --geotag_source gpx --geotag_source exif --geotag_source_path /typo.gpx fails all images with "GPX file not found: /typo.gpx", instead of geotagging them from EXIF without a word.
  • Valid GPX and NMEA files give the same descriptions as before.
  • New unit tests and an integration test. Unit and integration tests, doctests, mypy --python-version 3.9, ruff check, ruff format --check and usort diff are clean.

A misspelled source type, as in --geotag_source foo or gpx,foo, failed
with a ValueError traceback ("'foo' is not a valid SourceType"), and a
JSON source with a key the schema does not know, such as

    {"source": "gpx", "path": "track.gpx"}

failed with a jsonschema ValidationError traceback. Both exited 1, as for
a crash.

They now raise MapillaryBadParameterError (exit code 2), naming the
supported source types and their aliases, or what the schema rejected
("'path' was unexpected"). This covers --geotag_source and
--video_geotag_source in process and video_process, which parse them the
same way.
…r image

A truncated GPX file, or a file that is no GPX at all, given as the GPX
to geotag images from failed the whole run with a RuntimeError traceback
("Error parsing GPX ...: GPXXMLSyntaxException"). A video geotagged from
the same file gets a MapillaryInvalidGPXError in its description. A GPX
path that does not exist failed with a RuntimeError too, and a GPX file
with no timestamped point with an AssertionError. An NMEA file failed
with a traceback in each of these cases, and when a sentence had no time
or date (TypeError), such as the void ones a receiver writes before its
first fix, or when the file had no RMC sentence to give the date
(UnboundLocalError).

Every image now gets a MapillaryInvalidGPXError in the description,
saying what is wrong with the file, and the run exits as for any other
file that fails to process. The file was given to geotag the images
from, so a mistyped path fails them, as it did, rather than leaving
them to the next geotag source without a word.
@meta-cla meta-cla Bot added the cla signed label Oct 22, 2026
@caglarpir
caglarpir merged commit 80d254a into mapillary:main Oct 22, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant