Skip to content

Fix Snap with Circles in GeometryCollection - #17699

Open
Thanatos9404 wants to merge 1 commit into
openlayers:mainfrom
Thanatos9404:fix-snap-circle-in-collection
Open

Thanatos9404 wants to merge 1 commit into
openlayers:mainfrom
Thanatos9404:fix-snap-circle-in-collection

Conversation

@Thanatos9404

@Thanatos9404 Thanatos9404 commented Oct 19, 2026 •

Copy link
Copy Markdown

Fixes #17095

@IQBAL-HAMEED17 offered to work on this in December 2025 and I couldn't find a PR since, so I went ahead. Happy to close this if you have something in progress.

Snap used the feature geometry's type to decide whether a segment belongs to a circle. For a Circle inside a GeometryCollection that type is 'GeometryCollection', so the vertices of the polygon approximating the circle were snapped to, and with vertex: false the pointer snapped to its straight segments instead of the circle.

Segments created for a Circle now carry it in a new optional circle property, and snapTo uses that instead of the feature type. The segmenters option is unchanged. Self intersections of the circle's polygon are no longer added, so its closing vertex isn't snapped to as an intersection.

Behaviour changes: segments from a custom Circle segmenter inside a collection now count as part of the circle, as they already did for Circle features. Members of a collection are now segmented with the segmenters as this, which fixes a TypeError for nested collections.

Tests: new Snap tests for a circle in a GeometryCollection (also nested, and with intersection: true) fail without this change and pass with it.

Snap decided whether to snap to the exact circle by looking at the type
of the feature geometry. For a Circle inside a GeometryCollection that
type is 'GeometryCollection', so the vertices of the polygon that
approximates the circle were snapped to as vertices, and its segments
as straight edges.

Remember the Circle for the segments that are created for it, also when
the segmenter is called for a member of a GeometryCollection, store it
with the segment data, and use that when snapping.

Segments of the same circle are no longer intersected with each other.
They only meet where the first and the last segment of the polygon
share a vertex, and that intersection would otherwise be snapped to
instead of the circle.

This branch has not been deployed

No deployments
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.

Snap interaction not working correctly with Circles in GeometryCollection

1 participant