SpanMover

object SpanMover

Moves one vertex of a shape together with the vertices hidden between it and its neighbouring "anchors", so a stretch of a border can be reshaped by dragging one of a few handles instead of every one of its points.

Dragging an anchor moves it fully; the vertices between the previous anchor and it follow in proportion to how far along that stretch they are (0 at the previous anchor, 1 at the dragged vertex), and likewise those between it and the next anchor (1 at the dragged vertex, 0 at the next anchor). The anchors themselves, and every vertex beyond them, stay where they are. The stretch bends smoothly instead of leaving the hidden points behind as a zig-zag.

The displacement is a difference in latitude and longitude degrees, which is exact enough for the size of an editing gesture; "how far along" is measured on the sphere, by great-circle distance along the stretch.

Functions

Link copied to clipboard
fun move(vertices: List<Vertex>, movedId: VertexId, prevId: VertexId?, nextId: VertexId?, newPosition: GeoPosition, isClosed: Boolean): List<Vertex>

A copy of vertices with movedId at newPosition and the vertices between prevId and it, and between it and nextId, moved in proportion. Either neighbour may be null (an end of an open path has no neighbour on one side): that side then has no stretch. isClosed says the vertices form a ring, so a stretch may run past the end of the list back to its start. Returns vertices unchanged if movedId isn't among them.