Skip to content
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

Add triangulate property to geojsonToBinary #2571

Merged
merged 7 commits into from
Aug 2, 2023

Conversation

felixpalmer
Copy link
Collaborator

Background

We have found that the geojsonToBinary function can be very slow (multiple seconds) when processing large polygons due to the triangulation done via earcut. This PR adds a new optional parameter to disable the triangulation. By defaulting to true we maintain back compatibility but enable fast processing when needed (e.g. for a realtime API).

The result is that the output data structure doesn't include the polygons.triangles property. deck.gl is able to cope with this and will perform the tesselation at render time, much like it does when rendering GeoJSON.

Changelist

  • Add new parameter to geojsonToBinary
  • Implementation in flat-geojson-to-binary.ts
  • Doc & test update

Copy link
Collaborator

@ibgreen ibgreen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice clean PR.

  • It would be nice to also add a bullet to the whats-new page.
  • It would be good to mention on the doc page that the new option is only available from v4.0 to avoid confusion.

I generally refer to what earcut does as polygon tesselation. Thinking that maybe the option should be called tesselate instead of triangulate.

If you need this asap, please backport to 3.4-release branch and notify @belom88 so that it makes it into the weekly patch release.

We'd probably not mention it in the 3.4 docs as it is a late patch.

@ibgreen ibgreen added the enhancement New feature or request label Aug 1, 2023
@felixpalmer felixpalmer merged commit 8247945 into master Aug 2, 2023
@felixpalmer felixpalmer deleted the felix/geojson-to-binary-triangulate branch August 2, 2023 07:50
felixpalmer added a commit that referenced this pull request Aug 2, 2023
@belom88 belom88 added this to the v3.4.9 milestone Aug 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants