wookay / H3.jl

H3.jl ⬡ provides a Julia version of H3, Hexagonal hierarchical geospatial indexing system. https://github.com/uber/h3
Other
25 stars 4 forks source link

Compact doesn't always return the same number of valid H3 indexes #2

Closed mattswoon closed 5 years ago

mattswoon commented 5 years ago

Compact always returns an array of the same length of the input h3Set, however some of the returned elements are not H3Indexes of the compacted set. Doing a list comprehension to get the valid ones yields inconsistent results.

Attached is a set of H3Indexes and a jupyter notebook demonstrating the above. compact_issue.zip And a screenshot for readability: image.

My guess is that undef happens to luck onto valid H3Indexes so my suggested fix is to initialize the compactedSet with zeros (an H3Index that is guaranteed to be invalid - see here), and potentially incorporate the list comprehension to return only the valid H3Indexes before returning.

Happy to put up a pull request.

wookay commented 5 years ago

thanks for the detail report!