Package-level declarations

Types

Link copied to clipboard
Link copied to clipboard
data class NearestPointOnLineResult(val point: Position, val distance: Double, val location: Double, val index: Int)

Result values from nearestPointOnLine.

Link copied to clipboard
enum Units : Enum<Units>

Supported units of measurement in Turf.

Properties

Link copied to clipboard
const val AREA_EARTH_RADIUS: Int = 6378137
Link copied to clipboard
const val EARTH_RADIUS: Double = 6371008.8

Radius of the Earth used with the Harvesine formula. Approximated using a spherical (non-ellipsoid) Earth.

Functions

Link copied to clipboard
fun along(line: LineString, distance: Double, units: Units = Units.Kilometers): Position

Takes a LineString and returns a position at a specified distance along the line.

Link copied to clipboard
fun area(geometry: Geometry): Double

Takes a geometry and returns its area in square meters.

Link copied to clipboard
fun bbox(feature: Feature): BoundingBox

Takes a feature and calculates the bbox of the feature's geometry, and returns a bounding box.

fun bbox(featureCollection: FeatureCollection): BoundingBox

Takes a feature collection and calculates a bbox that covers all features in the collection.

fun bbox(geometry: Geometry): BoundingBox
fun bbox(geometry: LineString): BoundingBox
fun bbox(geometry: MultiPoint): BoundingBox
fun bbox(geometry: MultiPolygon): BoundingBox
fun bbox(geometry: Point): BoundingBox
fun bbox(geometry: Polygon): BoundingBox

Takes a geometry and calculates the bbox of all input features, and returns a bounding box.

Link copied to clipboard

Takes a bbox and returns an equivalent Polygon.

Link copied to clipboard
fun bearing(start: Position, end: Position, final: Boolean = false): Double

Takes two positions (start, end) and finds the geographic bearing between them, i.e. the angle measured in degrees from the north line (0 degrees)

Link copied to clipboard

Converts any bearing angle from the north line direction (positive clockwise) and returns an angle between 0-360 degrees (positive clockwise), 0 being the north line

Link copied to clipboard
fun booleanPointInPolygon(point: Point, polygon: MultiPolygon, ignoreBoundary: Boolean = false): Boolean

Takes a Point and a MultiPolygon and determines if the point resides inside the polygon. The polygon can be convex or concave. The function accounts for holes.

fun booleanPointInPolygon(point: Point, polygon: Polygon, ignoreBoundary: Boolean = false): Boolean

Takes a Point and a Polygon and determines if the point resides inside the polygon. The polygon can be convex or concave. The function accounts for holes.

Link copied to clipboard
fun center(feature: Feature): Point

Takes any kind of Feature and returns the center point. It will create a BoundingBox around the given Feature and calculates the center point of it.

fun center(geometry: Geometry): Point

It overloads the center(feature: Feature) method.

Link copied to clipboard
fun computeBbox(coordinates: List<Position>): BoundingBox
Link copied to clipboard
fun convertArea(area: Double, from: Units = Units.Meters, to: Units = Units.Kilometers): Double

Converts an area to the requested unit. Valid units: Acres, Miles, Inches, Yards, Meters, Kilometers, Centimeters, Feet

Link copied to clipboard
fun convertLength(length: Double, from: Units = Units.Meters, to: Units = Units.Kilometers): Double

Converts a length to the requested unit

Link copied to clipboard
fun destination(origin: Position, distance: Double, bearing: Double, units: Units = Units.Kilometers): Position

Takes a position and calculates the location of a destination position given a distance in degrees, radians, miles, or kilometers; and bearing in degrees. This uses the Haversine formula to account for global curvature.

Link copied to clipboard
fun distance(from: Position, to: Position, units: Units = Units.Kilometers): Double

Calculates the distance between two positions. This uses the Haversine formula to account for global curvature.

Link copied to clipboard
fun length(lineString: LineString, units: Units): Double

Calculates the length of the given LineString in the given Units.

fun length(multiLineString: MultiLineString, units: Units): Double

Calculates the combined length of all LineStrings from the given MultiLineString in the given Units.

fun length(multiPolygon: MultiPolygon, units: Units): Double

Calculates the combined length of perimeter the Polygons in the MultiPolygon in the given Units. Any holes in the polygons will be included in the length.

fun length(polygon: Polygon, units: Units): Double

Calculates the length of perimeter the given Polygon in the given Units. Any holes in the polygon will be included in the length.

Link copied to clipboard
fun lengthToDegrees(distance: Double, units: Units = Units.Kilometers): Double

Convert a distance measurement (assuming a spherical Earth) from a real-world unit into degrees.

Link copied to clipboard
fun lengthToRadians(distance: Double, units: Units = Units.Kilometers): Double

Convert a distance measurement (assuming a spherical Earth) from a real-world unit into radians.

Link copied to clipboard

Returns intersecting points between two LineStrings.

Link copied to clipboard
fun lineSlice(start: Position, stop: Position, line: LineString): LineString

Takes a LineString, a start and a stop Position and returns a subsection of the line between those points. The start and stop points do not need to fall exactly on the line.

Link copied to clipboard
fun midpoint(point1: Position, point2: Position): Position

Takes two Positions and returns a point midway between them. The midpoint is calculated geodesically, meaning the curvature of the earth is taken into account.

Link copied to clipboard
fun nearestPointOnLine(line: LineString, point: Position, units: Units = Units.Kilometers): NearestPointOnLineResult

Finds the closest Position along a LineString to a given position

fun nearestPointOnLine(lines: MultiLineString, point: Position, units: Units = Units.Kilometers): NearestPointOnLineResult

Finds the closest Position along a MultiLineString to a given position

Link copied to clipboard
fun radiansToLength(radians: Double, units: Units = Units.Kilometers): Double

Convert a distance measurement (assuming a spherical Earth) from radians to a more friendly unit.

Link copied to clipboard
fun squareGrid(bbox: BoundingBox, cellWidth: Double, cellHeight: Double, units: Units = Units.Kilometers): FeatureCollection

Creates a square grid within a BoundingBox.

Link copied to clipboard