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

Fix numerical stability in computing area #482

Merged
merged 1 commit into from
Jul 30, 2020
Merged

Conversation

rmanoka
Copy link
Contributor

@rmanoka rmanoka commented Jul 26, 2020

We modify fn twice_signed_ring_area in winding_order.rs to first shift the coordinates by the min over the geometry, before computing the area. The logic is correct as long as the input LineString is closed. To the best of my understanding, this is the case.

Also added a test to verify stability. Closes #481

+ add check for closed in `twice_signed_ring_area`
+ shift coordinates to smaller numbers before computing area
+ add test for stability of area with shifts
+ add test to verify open `LineString` returns `None` as
  `winding_order`
@rmanoka
Copy link
Contributor Author

rmanoka commented Jul 26, 2020

As per discussions with @urschrei , we now check and return 0 in twice_signed_ring_area if the LineString is not closed. The only visible change due to this is that open LineString will now return None for winding_order; this seems like the correct behavior. Also added a test for this case.

@urschrei urschrei merged commit e184814 into georust:master Jul 30, 2020
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.

Numerical stability of area
2 participants