-
Notifications
You must be signed in to change notification settings - Fork 962
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bbox-polygon support 6 position BBox #1238
Comments
Gday @md8n Yep I think I we'd be happy to support 3D bounding boxes, what do you think @DenisCarriere ? My preference would be to see it added as an option defaulting to false given that 90% of users probably wouldn't need it, perhaps called something like If you can put in a pull request along those lines that would be great! Perhaps before you do we'll just get clarification from Denis. Thanks, |
The code I have at the moment doesn't care if the supplied bounding box is 2D or 3D - it just works, and returns a 2D Polygon. |
Having some issues publishing a canary. |
I'm 👍 if we do the following logic to
Someone just needs to write up a PR with that appropriate logic.
|
There are several possible permutations for translating BBox2d | BBox3d to Polygon2d | Polygon3d - which is why I agree with:
As regards the TypeScript definition for BBOx geojson.d.ts defines it as follows:
Which is exactly what's required. I think it would be best to support BBox2d <=> BBox3d conversions as a separate function
The two values of
However, from experience, the following are reasonable coercions:
And finally, the ordering
|
FYI on the Typescript definition, the TurfJS So any changes that are made in TurfJS's https://github.com/Turfjs/turf/blob/master/packages/turf-helpers/lib/geojson.d.ts#L46-L48 @md8n I support your train of thought 👍 |
https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/geojson/index.d.ts#L31 In the end we'd also want
|
@md8n Agreed, there's lot of changes that I would suggest in the Typescript definition, however moving outside of
I also like Turf's def (kinda biased because I made it... 😁 ) |
First of all let's make my Position suggestion a separate issue from the BBox 2d | 3d support. ... and with that - here's a discussion on it ...
I'm assuming that probably the main reason why the existing geojson/index.d.ts defines it that why is either it provides deliberate backwards compatibility with the previous version of the GeoJSON spec, or (more likely) no one got around to changing it 😁. My concern, is that the further we are away from the spec then the more chance there is for subtle errors creeping in, especially when in use. Leveraging TypeScript for what its good at, in this case defining some type as a union of other types, gets everything (because Position touches everything) a lot closer to the spec. |
bbox-polygon currently only support 4 position (2D) BBox values, although 6 position (3D) BBox values are obviously valid BBoxes.
It's trivial to support translating a 6 position BBox to a (2D) Polygon.
I've already produced an update to index.js and test.js in turf-bbox-polygon that supports both 4 and 6 position (2D & 3D) BBox values to 2D Polygons.
Optionally (pardon the pun) a member could be added to options as a flag to convert a 3D BBox to a 3D Polygon (I haven't done this).
The text was updated successfully, but these errors were encountered: