benbovy / spherely

Manipulation and analysis of geometric objects on the sphere.
https://spherely.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
119 stars 8 forks source link

Usage of lat/lng vs lng/lat in constructors #41

Closed jorisvandenbossche closed 1 month ago

jorisvandenbossche commented 2 months ago

At the moment, the constructors use the lat/lng order convention from s2:

>>> spherely.Point(50, 4)
POINT (4 50)

But then, as you can see above, the WKT repr uses lng/lat, because that is (AFAIK) generally how WKT (or WKB) is expected to be expressed.

However, that is quite confusing, because that means you can't just copy the coordinates from some WKT string to the constructor ..

I was checking with R's s2 how they do that, but I don't directly see such explicit constructors from coordinates for a geography object. They do have an explicit s2_lnglat to create a S2LatLng object, and indeed they also use lng/lat order there, but because of the name of the function that is also directly clear.

jorisvandenbossche commented 2 months ago

Ah, and I see there is also an explicit Point constructor https://r-spatial.github.io/s2/reference/s2_geog_point.html, which is also using lng/lat order.

jorisvandenbossche commented 2 months ago

And bigquery seems to do the same: https://cloud.google.com/bigquery/docs/reference/standard-sql/geography_functions#st_geogpoint

benbovy commented 1 month ago

lng/lat order is now used in geometry creation functions added in #51.