Skip to content

Skip malformed NMEA sentences with a warning - #895

Merged
caglarpir merged 1 commit into
mapillary:mainfrom
caglarpir:nmea-skip-bad-sentences
Oct 23, 2026
Merged

caglarpir merged 1 commit into
mapillary:mainfrom
caglarpir:nmea-skip-bad-sentences

Conversation

@caglarpir

Copy link
Copy Markdown
Contributor

Stacked on #894; review the last commit.

One malformed RMC or GGA sentence failed the whole file, as not a valid
NMEA file, and since NMEA files are read from any talker, so did one
from a talker that v0.14.7 did not read. A log of 222 sentences with one
more, a $GLGGA sentence whose checksum does not match, failed all 113
images geotagged from it, where v0.14.7 geotagged 106 of them, the 7
others being duplicates of the previous image. A video geotagged from
such a log failed too. v0.14.7 crashed on a malformed $GPGGA sentence.

A sentence that does not parse, whose checksum does not match, or with a
field a fix is read from that does not parse, is now skipped, and one
warning per file says how many were skipped and quotes the first, with
its line number and what is wrong with it. pynmea2 leaves a field it
cannot parse a string: a malformed time failed the file, and a malformed
altitude crashed process with a traceback, for images and videos alike.
Void sentences and sentences without a fix are skipped as before,
without a warning. A file of which no fix can be read and that has
malformed sentences still fails as not a valid NMEA file.

On that log the 106 images get the same positions, times, directions and
altitudes as with v0.14.7 and as from the log without the bad sentence,
and the 7 others are duplicates as before.

Unit and integration tests, doctests, mypy --python-version 3.9, ruff check, ruff format --check and usort diff are clean.

One malformed RMC or GGA sentence failed the whole file, as not a valid
NMEA file, and since NMEA files are read from any talker, so did one
from a talker that v0.14.7 did not read. A log of 222 sentences with one
more, a $GLGGA sentence whose checksum does not match, failed all 113
images geotagged from it, where v0.14.7 geotagged 106 of them, the 7
others being duplicates of the previous image. A video geotagged from
such a log failed too. v0.14.7 crashed on a malformed $GPGGA sentence.

A sentence that does not parse, whose checksum does not match, or with a
field a fix is read from that does not parse, is now skipped, and one
warning per file says how many were skipped and quotes the first, with
its line number and what is wrong with it. pynmea2 leaves a field it
cannot parse a string: a malformed time failed the file, and a malformed
altitude crashed process with a traceback, for images and videos alike.
Void sentences and sentences without a fix are skipped as before,
without a warning. A file of which no fix can be read and that has
malformed sentences still fails as not a valid NMEA file.

On that log the 106 images get the same positions, times, directions and
altitudes as with v0.14.7 and as from the log without the bad sentence,
and the 7 others are duplicates as before.
@caglarpir
caglarpir force-pushed the nmea-skip-bad-sentences branch from e9395a9 to 71217a6 Compare October 23, 2026 13:04
@caglarpir
caglarpir merged commit 2b028b2 into mapillary:main Oct 23, 2026
26 of 31 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