5 ms·
* Some standards such as ISO 6709 (Standard representation of geographic point location by coordinates) describe points as (latitude, longitude). * Others suc
by arjvik 1y ago
* Some standards such as ISO 6709 (Standard representation of geographic point location by coordinates) describe points as (latitude, longitude).
* Others such as RFC 7946 (GeoJSON) describes points as (longitude, latitude).
Using (hypothetical) std::flip to reify these APIs seems like a loaded footgun - someone is bound to accidentally use it {zero, two} times to convert between orders when it needs to be used once and wreak havoc.
- wk_end 1y agoNo more of a loaded footgun than trying to do it manually, I don't think. Geographic points should probably be represented as a labeled structure to prevent confusion and passed into functions as such. Using two separate libraries with mutually incompatible error-prone APIs as described is the real loaded footgun IMO. If you can't find better libraries, write wrappers; if you don't have time to write/maintain wrappers, pray. Anything else is just a bandaid.
- jandrewrogers 1y agoProbably no better or worse than the alternative. That aside, the example doesn't understand the standards in question. The governing standard for geospatial data representation is ISO 19125, which defines (longitude, latitude) order. GeoJSON naturally conforms to ISO 19125 since it is a format for processing data on computers. ISO 6709 is essentially a print formatting standard and orthogonal to storing geospatial data on computers. That some data file formats happen to be human readable does not make ISO 6709 apply. If you are processing geospatial data on computers the correct order is always (longitude, latitude).
- usefulcat 1y ago> someone is bound to accidentally use it {zero, two} times That risk is inherent to the problem at hand, and has nothing to do with std::flip.
- Dylan16807 1y agoYou can reduce the risk with types. If you use flip, you're not doing that, which makes flip not a very good solution here.
- addaon 1y agoYep. The right solution here is to make latitude and longitude distinct types. The way to turn that into an even wronger solution is to create a helper just_apply(function, lat, long) that passes the arguments to the function in the (hopefully unique) order that successfully works; so flip if needed, based on function’s type signature.