Skip to content

refactor: correct order of the latitude and longitude in (*OsrmApiResponse).ToProto() method#2

Open
mgiks wants to merge 1 commit into
SelfMadeEngineerCode:mainfrom
mgiks:refactor
Open

refactor: correct order of the latitude and longitude in (*OsrmApiResponse).ToProto() method#2
mgiks wants to merge 1 commit into
SelfMadeEngineerCode:mainfrom
mgiks:refactor

Conversation

@mgiks
Copy link
Copy Markdown

@mgiks mgiks commented Jun 2, 2026

OSRM API's routing service returns coordinates in the order of longitude first and latitude second. For some reason the OSRM's docs don't explicitly specify that, but you can check that by sending a request to their api endpoint. Currently the trip service's (*OsrmApiResponse).ToProto() method parses the data in incorrect order, thus making latitude value be longitude and vice versa.

Additionally, react-leaflet's Polyline component expects to receive values for 'positions' attribute in the order of latitude first and longitude second. (https://react-leaflet.js.org/docs/api-components/#polyline) 'LatLngExpression' type's name hints to the correct order.

api

OSRM API's routing service returns coordinates in the order of
longitude first and latitude second. For some reason the OSRM's
docs don't explicitly specify that, but you can check that by sending
a request to their api endpoint. Currently the trip service's
(*OsrmApiResponse).ToProto() method parses the data in incorrect order,
thus making latitude value be longitude and vice versa.

Additionally, react-leaflet's Polyline component expects to receive
values for 'positions' attribute in the order of latitude first and
longitude second. (https://react-leaflet.js.org/docs/api-components/#polyline)
'LatLngExpression' type's name hints to the correct order.
@mgiks
Copy link
Copy Markdown
Author

mgiks commented Jun 2, 2026

Hello there, Tiago! I'm not very well-versed in creating pull requests, so I hope I've done everything correctly. Would love to hear your feedback!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant