Skip to content

fix(mapmatching): type GeoJSONGeometry.Coordinates as [][]float64#7

Merged
backevik merged 1 commit into
mainfrom
fix/linestring-coordinates-type
Jul 1, 2026
Merged

fix(mapmatching): type GeoJSONGeometry.Coordinates as [][]float64#7
backevik merged 1 commit into
mainfrom
fix/linestring-coordinates-type

Conversation

@backevik

@backevik backevik commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Summary

  • GeoJSONGeometry.Coordinates was typed as any, requiring callers to assert []interface{} and then []interface{} for each pair before extracting float64 values
  • The Map Matching API always returns a LineString when geometries=geojson is set, so [][]float64 is the correct and complete type
  • Callers can now index directly: pair[0] = longitude, pair[1] = latitude

Test plan

  • Added TestMapMatch_GeometryDecoded verifying the real JSON decodes into [][]float64 with correct values
  • Tested against the live Mapbox API: 31-coordinate LineString decoded correctly
  • All existing tests pass

The Map Matching API always returns a LineString geometry when
geometries=geojson is set. Using [][]float64 instead of any removes
all type assertion boilerplate from callers and makes the axis order
([longitude, latitude]) explicit in the type.
@backevik backevik force-pushed the fix/linestring-coordinates-type branch from a7c1bbb to 43318f1 Compare July 1, 2026 11:50
@backevik backevik merged commit 5edfea0 into main Jul 1, 2026
1 check passed
@backevik backevik deleted the fix/linestring-coordinates-type branch July 1, 2026 11:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant