Fix water areas rendering as a straight-edged wedge#1120
Open
Teddy563 wants to merge 1 commit into
Open
Conversation
…a wedge clip_water_ring_to_bbox assumed the ring it received was already a closed loop. When ring assembly leaves a fragment open (for example a multipolygon relation whose member way was not loaded), the ensure-closed step connects the last point back to the first with a straight chord. Sutherland-Hodgman then clips that chord-closed shape, the downstream closure checks accept it, and the area floods as a straight-edged water wedge. Add a ring_is_closed guard at the top of the function: a ring with fewer than three points, or whose first and last node are neither the same id nor within one block of each other, returns None. Sibling rings that are properly closed still render, so the result is partial water rather than a wedge. Includes unit tests for open, shared-id, coincident, and degenerate rings.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Some water areas were rendering as a big triangle or rectangle of water with a
straight diagonal edge cutting across the map (see screenshots).
The cause is in
clip_water_ring_to_bbox. It expects a closed ring, but sometimesa ring comes in open (for example when a multipolygon's member way did not load).
The code then closes it by drawing a straight line from the last point back to the
first, and that straight line gets flooded as water.
The fix just checks if the ring is actually closed before filling it. If it is not,
it gets skipped instead of being forced shut. Closed rings render exactly as before,
so you get partial water instead of a wedge. Added a few unit tests for the closed
and open cases.
Screenshots
Left half is before, right half is after.