h3-java icon indicating copy to clipboard operation
h3-java copied to clipboard

[Feature Req] Polyfill for multi level inclusion/exclusion

Open alexjikim opened this issue 5 years ago • 1 comments

Curious if there is any plan to add polyfill support for more complex geofences that have inclusions within 'holes'

For instance in s2, inclusion/exclusion is determined by the number of geofences a point is contained by and therefore doesn't require an explicit 'holes' input in the api.

Snippet from s2 java comments: /*

  • An S2Polygon is an S2Region object that represents a polygon. A polygon
  • consists of zero or more {@link S2Loop loops} representing "shells" and
  • "holes". All loops should be oriented CCW, i.e. the shell or hole is on the
  • left side of the loop. Loops may be specified in any order. A point is
  • defined to be inside the polygon if it is contained by an odd number of
  • loops. */

alexjikim avatar Dec 29 '18 08:12 alexjikim

Thanks for the suggestion!

The short answer is that we don't have a specific plan to improve this, but we are considering revising our approach to geo polygon data structures in the next major version, and may consider multi-polygon support for polyfill. The holes API is admittedly a little awkward, but it follows the GeoJSON semantics of requiring the caller to identify the outside loop and any holes and put them in appropriate order. To date, we have not required loop coordinates to follow a specific winding order, but we may add this restraint in the next major version as well.

nrabinowitz avatar Dec 31 '18 17:12 nrabinowitz