OutlineWalk

class OutlineWalk(ring: List<GeoPosition>, startIndex: Int = 0, reversed: Boolean = false, closed: Boolean = true)

Walking once round the outline of a shape, from a starting corner, the way a pen draws it: pathTo is what the pen has drawn when it is a given part of the way round, and pointAt is where the pen is.

The distance is the length along the edges, as WWK draws them (great-circle arcs, see GreatCircle), so the pen moves at the same speed on a long edge as on a short one, and a cut in the middle of an edge lies on the drawn edge. An edge's length is the angle at the centre of the globe, only meaningful against the other edges of the same walk, which is what fraction needs.

The walk is closed (the outline of a shape) and ends back at the start, unless closed is false: then it is a route, from the first point to the last, which the pen does not come back from. Fewer than 2 points have nothing to walk.

Parameters

startIndex

the corner the pen starts at (an index into ring); a route always starts at its first point, so it must be 0.

reversed

whether it goes the other way round, against the order of ring.

Constructors

Link copied to clipboard
constructor(ring: List<GeoPosition>, startIndex: Int = 0, reversed: Boolean = false, closed: Boolean = true)

Properties

Link copied to clipboard

The whole way round, as the sum of the angles of the edges (radians).

Functions

Link copied to clipboard
fun bearingAt(fraction: Double): Double

The direction the pen is going at fraction of the way, in radians clockwise from north (see GreatCircle.bearing): along the arc of the edge it is on, so on a long edge the direction changes as it goes. At the very end it is the direction it arrived in.

Link copied to clipboard

How far round the walk the corner at index (an index into the points it was made from, for a route) is: 0 for the first, 1 for the last.

Link copied to clipboard

The stretch the pen drew between from and to (both fractions of the way round, like pathTo): from where it was at from, by the corners in between, to where it was at to. It begins and ends exactly where pathTo had the pen, so stretches that follow each other join up. When to is not after from there is no stretch, only the one point.

Link copied to clipboard
fun pathTo(fraction: Double): List<GeoPosition>

What the pen has drawn at fraction of the way round: the corners it has passed, then the point it is at. At 0 that is only the start (too little for a line: the caller shows nothing yet), at 1 the whole outline, ending on the start again. Between two corners the last point is on the arc WWK draws between them, so the line it makes with the corner before is the drawn edge cut short.

Link copied to clipboard
fun pointAt(fraction: Double): GeoPosition

Where the pen is when it is fraction (0 at the start, 1 back at the start; outside that it stops at the ends) of the way round.