Skip to content

Conversation

@zerebubuth
Copy link
Member

Building merging expands building footprints using buffer, simplifies them and then contracts them back. This means that a saddle point, where two buildings meet, creates two buffered out points which then collapse back onto exactly the same point when buffered negatively. This can, but doesn't usually, result in a topological error, and creates an invalid polygon.

Instead of this, we can buffer out by a very, very slightly smaller value, which should tie-break the points coming back in, and mean that there's enough precision for the inside/outside or left-of/right-of tests to work properly.

error when two points on opposing sides collapse exactly back onto eachother

Building merging expands building footprints using `buffer`, simplifies them and then contracts them back. This means that a saddle point, where two buildings meet, creates two buffered out points which then collapse back onto exactly the same point when buffered negatively. This can, but doesn't usually, result in a topological error, and creates an invalid polygon.

Instead of this, we can buffer out by a very, very slightly smaller value, which should tie-break the points coming back in, and mean that there's enough precision for the inside/outside or left-of/right-of tests to work properly.
'439040713D0A070C6B5941666666666692904085EB51A80D6B5941333333'
'3333B99040EC51B84E066B594100000000006A9040B81E85AB046B59415C'
'8FC2F528439040713D0A070C6B5941'.decode('hex')
)
Copy link
Member

Choose a reason for hiding this comment

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

Would the wkt be equally opaque 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.

Pretty much. I've also had issues before where the WKT is lower precision and so doesn't exhibit the problem, but I'll go check.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yup, I tried a version of the test with WKT instead of WKB and it doesn't trigger the same bug. Creating simpler geometries (e.g: box(1,2,3,4)) also failed to reproduce. Unfortunately, I think we're stuck with the opaque WKB 😞

@zerebubuth zerebubuth merged commit 935a6ee into master Nov 15, 2018
@zerebubuth zerebubuth deleted the zerebubuth/fix-buffer-topology-problem branch November 15, 2018 09:34
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.

2 participants