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

Drop small inners #1180

Merged
merged 3 commits into from Mar 22, 2017
Merged

Drop small inners #1180

merged 3 commits into from Mar 22, 2017

Conversation

zerebubuth
Copy link
Member

At mid and low zooms, polygons with lots of small inners cause problems for simplification, validation, intercut and MVT generation. Dropping these small holes means that some operations are slightly faster, and many are more robust.

Matt Amos added 2 commits March 21, 2017 16:38
At mid and low zooms, polygons with lots of small inners cause problems for simplification, validation, intercut and MVT generation. Dropping these small holes means that some operations are slightly faster, and many are more robust.
return None

meters_per_pixel_area = calc_meters_per_pixel_area(zoom)
area_tolerance = meters_per_pixel_area**2 * pixel_area
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to square meters_per_pixel_area here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well spotted!

Yes, I seem to have been confused about whether that was a linear or area ratio. D'oh!

Fixed in 71488a5.

polys = []
for g in shape.geoms:
new_g = _drop_small_inners(g, area_tolerance)
if new_g:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this ever falsey?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, yes, as an object it's probably always truthy. I've swapped that for what I really meant; does the remaining polygon have any area? I think we can omit validity checks, as deleting inners seems like it should always leave a valid polygon still valid.

Fixed in 71488a5.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, yes, as an object it's probably always truthy. I've swapped that for what I really meant; does the remaining polygon have any area?

Perhaps that's what shapely already does? I didn't check, but even so an area check is more explicit.

I think we can omit validity checks, as deleting inners seems like it should always leave a valid polygon still valid.

Yea, I had the same reasoning. 👍

Explicitly check for empty polygons, as a truthy Polygon object can still be empty.
@zerebubuth zerebubuth merged commit 150b660 into master Mar 22, 2017
@zerebubuth zerebubuth deleted the zerebubuth/drop-small-inners branch March 22, 2017 11:04
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

Successfully merging this pull request may close these issues.

None yet

3 participants