Skip to content

polygonToCells: remove ring tracing step#599

Closed
kalenikaliaksandr wants to merge 1 commit intouber:masterfrom
kalenikaliaksandr:kalenik-polyfill-remove-ring-tracing
Closed

polygonToCells: remove ring tracing step#599
kalenikaliaksandr wants to merge 1 commit intouber:masterfrom
kalenikaliaksandr:kalenik-polyfill-remove-ring-tracing

Conversation

@kalenikaliaksandr
Copy link
Copy Markdown

@kalenikaliaksandr kalenikaliaksandr commented Apr 14, 2022

polygonToCells algorithm basically seems to have following steps:

  1. find hexagons lying on polygons outer and inner rings
  2. do breadth-first search starting from every found hexagon and check if next neighbour hexagon center contained by polygon

First step with ring hexagons tracing seems unnecessary for me because in breadth-first search any point from polygon can be used as start point and all others will be found eventually.

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 14, 2022

CLA assistant check
All committers have signed the CLA.

@coveralls
Copy link
Copy Markdown

coveralls commented Apr 15, 2022

Coverage Status

Coverage decreased (-0.4%) to 98.303% when pulling d4c92e5 on kalenikaliaksandr:kalenik-polyfill-remove-ring-tracing into ac534dc on uber:master.

@kalenikaliaksandr kalenikaliaksandr force-pushed the kalenik-polyfill-remove-ring-tracing branch from 8cfbb5c to d4c92e5 Compare April 15, 2022 01:05
@nrabinowitz
Copy link
Copy Markdown
Collaborator

Thank you for your submission. In the future, it might make sense to discuss in our Slack channel or in a GitHub issue before putting together a PR.

The reason we include the step of tracing the outlines is that the cells returned by polyfill may not be contiguous. The current polyfill algorithm only takes cells whose centers fall within the polygon, so there are many cases in which a simple flood fill won't work - imagine for example a "barbell" shape with two areas filled with cells, separated by a arbitrarily long "bar" with no cells. Depending on the scale of the shapes and the resolution of the cells, there may be many cases like this in a given dataset. Outline tracing was the best option we could come up with that handles all of these cases. We'd welcome other more efficient approaches here.

It looks like we don't have good test cases for these issues, however - I would have hoped the tests would fail in this PR, but they don't, which suggests a gap in our unit tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

4 participants