Conversation
…ot converted again Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
FelixAbrahamsson
approved these changes
Sep 21, 2026
FelixAbrahamsson
left a comment
Collaborator
There was a problem hiding this comment.
Good catch, the median check is a clever way to handle that ambiguity.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
read_kmm2recognises a Norway ("Banenor") file byNorKmmToKmmin theVERheader and converts its coordinate columns from WGS84 degrees to SWEREF99 TM. Newer files carry the same header (NorKmmToKmm2_1.03) but already store projected northing/easting in those columns:Converting metres as if they were degrees produces garbage. On
20260519_025932_2011T.kmm2, 17 423 of 17 712 rows came out with coordinates nowhere near Scandinavia. Everything built on the library — the deepinspection provider's positions worker, wire's processing job — ingests that silently.Fix
Decide from the values, since the header cannot tell the two apart: a latitude is at most 90, a Scandinavian northing is in the millions.
latlon_to_swerefconverts only when the columns hold degrees (is_degrees, on the medians so a malformed row cannot flip it); projected files pass through unchanged.The projected files are zone 33 ETRS89 (UTM 33N), which shares its projection parameters with SWEREF99 TM, so passing them through is correct to within the datum difference (centimetres). Checked against Bane NOR's official network: read this way, the 2026 file's open-air positions lie a median 0.1 m from the track centre line.
Testing
tests/norway_projected.kmm2: the four positions of the existingtests/norway.kmm2, synthetically re-written in the newer layout (projected coordinates, float kilometre/metre, datetime column). The test asserts both fixtures land on the same northing/easting and recover the same latitude/longitude.uv run pytest: 16 passed.blackandflake8clean on the changed file.Needs a release (
v0.1.11) before the deepinspection positions worker, pinned atkmm>=0.1.10,<0.2, picks it up.🤖 Generated with Claude Code