itowns icon indicating copy to clipboard operation
itowns copied to clipboard

Change Coordinates constructor to match epsg coordinates order

Open jailln opened this issue 3 years ago • 2 comments

The order of lat / long coordinates is reversed in the Coordinate.js constructor: the constructor expects long / lat / altitude while the order or axes is generally lat / long, especially for EPSG:4326 according to the specs. It can be a little bit confusing and lead to errors and I think it should be changed to lat / long / altitude.

jailln avatar Nov 04 '21 14:11 jailln

Yes, I noticed that it isn't clear. I will read this article to find solution on the order of the EPSG:4326axes.

A non breaking change solution is needed, surely with a system parameter (axesOrder).

It is also necessary to manage the other possible projections of Coordinates.

gchoqueux avatar Nov 04 '21 15:11 gchoqueux

Interesting article! I agree that a non breaking change would be better.

I agree with you for other possible projections. In addition, a small shortcut is taken in the current implementation: EPSG:4326 is assumed to be 3D (with an altitude value) while it is actually 2D (only lat / long); its 3D counterpart is EPSG:4979 (lat / long / alt). Moreover, instantiating a Coordinates object with EPSG:4979 with long/lat/altitude throws an error (probably because EPSG:4979 is not defined with proj4.defs()). Even if the confusion between EPSG:4326 and EPSG:4979 is common, I think we should clarify this in the code by at least defining EPSG:4979 by default and make sure that it works when defining coordinates with this code.

jailln avatar Nov 04 '21 16:11 jailln