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

Polygon winding order #67

Open
kylebarron opened this issue Oct 9, 2023 · 1 comment
Open

Polygon winding order #67

kylebarron opened this issue Oct 9, 2023 · 1 comment

Comments

@kylebarron
Copy link
Member

kylebarron commented Oct 9, 2023

The deck.gl SolidPolygonLayer has a render option _windingOrder which says

This prop is only effective with _normalize: false. It specifies the winding order of rings in the polygon data, one of:

  • 'CW': outer-ring is clockwise, and holes are counter-clockwise
  • 'CCW': outer-ring is counter-clockwise, and holes are clockwise

The proper value depends on the source of your data. Most geometry formats enforce a specific winding order. Incorrectly set winding order will cause an extruded polygon's surfaces to be flipped, affecting culling and the lighting effect.

Thus, this is probably not the highest priority, given that it only happens with extruded polygons, but should be fixed eventually.

In GEOS, polygon winding order is unspecified, so we'd need to check/force it manually. There's no vectorized shapely function to do this, ref shapely/shapely#1366. So the options are either:

  • non-vectorized shapely implementation of orient. This would be unacceptably slow.
  • geoarrow-based orient implementation in python. This would be ideal but not likely to be imminently implemented.
  • JS-based orientation implementation. This either brings in a wasm implementation (not ideal here) or implements a custom JS function on geoarrow arrays (preferred, but the tooling for geoarrow in pure JS isn't there yet)

So the end goal here is:

  • Implement a fast winding order algorithm in rust on geoarrow memory to do in python.
  • Implement an orientation checking function in pure JS on geoarrow memory (maybe in geoarrow/deck.gl-layers for now)
  • Set the geoarrow winding order flag when winding order is checked/validated in python so it doesn't get done again in js.

Ref geoarrow/deck.gl-layers#36

@kylebarron
Copy link
Member Author

Note that geoarrow-js now has a winding order check and fix https://github.com/geoarrow/geoarrow-js/blob/main/src/algorithm/winding.ts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant