GeoUtils

object GeoUtils

Basic reusable geo-spatial utility methods

Types

Link copied to clipboard

used to define the orientation of 3 points -1 = Clockwise 0 = Colinear 1 = Counter-clockwise

Properties

Link copied to clipboard
const val EARTH_MEAN_RADIUS_METERS: Double = 6371008.7714

mean earth axis in meters

Link copied to clipboard
const val MAX_LAT_INCL: Double = 90.0

Maximum latitude value.

Link copied to clipboard

max latitude value in radians

Link copied to clipboard
const val MAX_LON_INCL: Double = 180.0

Maximum longitude value.

Link copied to clipboard

max longitude value in radians

Link copied to clipboard
const val MIN_LAT_INCL: Double

Minimum latitude value.

Link copied to clipboard

min latitude value in radians

Link copied to clipboard
const val MIN_LON_INCL: Double

Minimum longitude value.

Link copied to clipboard

min longitude value in radians

Functions

Link copied to clipboard
fun checkLatitude(latitude: Double)

validates latitude value is within standard +/-90 coordinate bounds

Link copied to clipboard
fun checkLongitude(longitude: Double)

validates longitude value is within standard +/-180 coordinate bounds

Link copied to clipboard

binary search to find the exact sortKey needed to match the specified radius any sort key lte this is a query match.

Link copied to clipboard
fun lineCrossesLine(a1x: Double, a1y: Double, b1x: Double, b1y: Double, a2x: Double, a2y: Double, b2x: Double, b2y: Double): Boolean

uses orient method to compute whether two line segments cross

Link copied to clipboard
fun lineCrossesLineWithBoundary(a1x: Double, a1y: Double, b1x: Double, b1y: Double, a2x: Double, a2y: Double, b2x: Double, b2y: Double): Boolean

uses orient method to compute whether two line segments cross; boundaries included - returning true for lines that terminate on each other.

Link copied to clipboard
fun lineOverlapLine(a1x: Double, a1y: Double, b1x: Double, b1y: Double, a2x: Double, a2y: Double, b2x: Double, b2y: Double): Boolean

uses orient method to compute whether two line overlap each other

Link copied to clipboard
fun orient(ax: Double, ay: Double, bx: Double, by: Double, cx: Double, cy: Double): Int

Returns a positive value if points a, b, and c are arranged in counter-clockwise order, negative value if clockwise, zero if collinear.

Link copied to clipboard
fun relate(minLat: Double, maxLat: Double, minLon: Double, maxLon: Double, lat: Double, lon: Double, distanceSortKey: Double, axisLat: Double): PointValues.Relation

Compute the relation between the provided box and distance query. This only works for boxes that do not cross the dateline.

Link copied to clipboard

Returns the trigonometric sine of an angle converted as a cos operation.

Link copied to clipboard
fun within90LonDegrees(lon: Double, minLon: Double, maxLon: Double): Boolean

Return whether all points of [minLon,maxLon] are within 90 degrees of lon.