Skip to content

Fix water areas rendering as a straight-edged wedge#1120

Open
Teddy563 wants to merge 1 commit into
louis-e:mainfrom
Teddy563:fix/water-ring-wedge
Open

Fix water areas rendering as a straight-edged wedge#1120
Teddy563 wants to merge 1 commit into
louis-e:mainfrom
Teddy563:fix/water-ring-wedge

Conversation

@Teddy563

Copy link
Copy Markdown
Contributor

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 sometimes
a 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.

fixed_broken fixed_broken2

…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.
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.

1 participant