opentripplanner / OpenTripPlanner

An open source multi-modal trip planner
http://www.opentripplanner.org
Other
2.21k stars 1.03k forks source link

Inconsistent ways to represent coordinates #6013

Open habrahamsson-skanetrafiken opened 2 months ago

habrahamsson-skanetrafiken commented 2 months ago

Is your feature request related to a problem? Please describe.

Different parts of the OTP code base are using different ways to represent coordinates.

These are the main ways:

Using unstructured x, y and lat, long values are a bit error prone since it is easy to get the order wrong. At the call site it's not obvious which of these is the correct: new Vertex(lat, lon) or new Vertex(lon, lat) since it depends on if the Vertex class operates on x, y or on lat, lon.

Goal / high level use-case

Treating coordinates in a consistent way within OTP would make code less brittle and easier to maintain.

Describe the solution you'd like

Consistently use our internal data object WgsCoordinate for representing coordinates.

Describe alternatives you've considered

t2gran commented 2 months ago

The jts Coordinate uses (x, y, z) while the WgsCoordinate only has (lat,long), all doubles. The memory footprint would be 16 + 3 x 8 vs 16 + 2 x 8 bytes. In addition there is 8 bytes for each reference. If memory is an issue, we could also change the WgsCoordinate to use integers for the lat/long - the precision is good enough. Hopefully we will be able to inline WgsCoordinate later.