Turfjs / turf

A modular geospatial engine written in JavaScript and TypeScript
https://turfjs.org/
MIT License
9.4k stars 944 forks source link

Support 3D geometries #2534

Open kevinschaich opened 1 year ago

kevinschaich commented 1 year ago

Is it possible to support 3D geometries with an optional z / altitude / elevation coordinate?

This is now supported by the GeoJSON spec.

smallsaucepan commented 1 year ago

Thanks for raising this @kevinschaich. To what extent are you requesting support? Let's say the spectrum runs from "let people provide z coords but ignore them for calculations" all the way up to "fully incorporate altitude variations in to all functionality".

Do you have a particular use case? Or are you getting errors when supplying a z coord?

pvy commented 1 year ago

E.g. bezierSpline ignores the z coordinate and returns two-dimensional coordinates.

Other 2D functions could project points onto a plane and work inside it.

kevinschaich commented 1 year ago

Ignore z coordinate would be a great first step.

I imagine things get much more complicated if you're doing the actual operations – the GeoJSON spec says:

An OPTIONAL third-position element SHALL be the height in meters above or below the WGS 84 reference ellipsoid.

so that would mean the three coordinates are not in the same units ([lon <WGS84 decimal degrees>, lat <WGS84 decimal degrees>, alt <meters>]).

Do all the functions share a common parser step at the beginning? If so, would be easy to just strip off the third coordinate and then pass that in.