geoarrow / geoarrow-rs

GeoArrow in Rust, Python, and JavaScript (WebAssembly) with vectorized geometry operations
http://geoarrow.org/geoarrow-rs/
Apache License 2.0
257 stars 17 forks source link

Add earcutr #653

Open deanm0000 opened 4 months ago

deanm0000 commented 4 months ago

I noticed that the deck.gl layers does earcut on the client but it'd be nice to create geometry source data that has already been earcutted for better performance. https://github.com/frewsxcv/earcutr

kylebarron commented 4 months ago

In theory we could bind to earcutr here, but it won't be that useful for deck.gl-layers. The output of earcut is a different length of data than the number of rows, so it doesn't really fit into an Arrow table or Parquet file. And on the frontend earcut is already done on 8 worker threads, so it's not a big slowdown

deanm0000 commented 4 months ago

I'm getting, what seems to be, significant time spent earcutting. Here's a profile...

image

I'm not sure what you mean about a different number of rows. I'm thinking that each row is its own polygon that gets earcut independently of other rows and so the new List that makes up the polygon will be a different length but I don't know why it'd be a different number of rows.

kylebarron commented 4 months ago

earcut should be on a separate worker by default https://github.com/geoarrow/deck.gl-layers/blob/25fdeafe2d9c591570bab975ebea43ae82e97a8d/src/solid-polygon-layer.ts#L69-L75.