GeoEncodingUtils

reusable geopoint encoding methods

Types

Link copied to clipboard
class Component2DPredicate(latShift: Int, lonShift: Int, latBase: Int, lonBase: Int, maxLatDelta: Int, maxLonDelta: Int, relations: ByteArray, val tree: Component2D) : GeoEncodingUtils.Grid

A predicate that checks whether a given point is within a component2D geometry.

Link copied to clipboard
class DistancePredicate(latShift: Int, lonShift: Int, latBase: Int, lonBase: Int, maxLatDelta: Int, maxLonDelta: Int, relations: ByteArray, lat: Double, lon: Double, distanceKey: Double) : GeoEncodingUtils.Grid

A predicate that checks whether a given point is within a distance of another point.

Link copied to clipboard
open class Grid(latShift: Int, lonShift: Int, latBase: Int, lonBase: Int, maxLatDelta: Int, maxLonDelta: Int, relations: ByteArray)

Properties

Link copied to clipboard
const val BITS: Short = 32

number of bits used for quantizing latitude and longitude values

Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard

Create a predicate that checks whether points are within a geometry. It works the same way as .createDistancePredicate.

Link copied to clipboard

Create a predicate that checks whether points are within a distance of a given point. It works by computing the bounding box around the circle that is defined by the given points/distance and splitting it into between 1024 and 4096 smaller boxes (4096*0.75^2=2304 on average). Then for each sub box, it computes the relation between this box and the distance query. Finally at search time, it first computes the sub box that the point belongs to, most of the time, no distance computation will need to be performed since all points from the sub box will either be in or out of the circle.

Link copied to clipboard
fun decodeLatitude(encoded: Int): Double

Turns quantized value from .encodeLatitude back into a double.

fun decodeLatitude(src: ByteArray, offset: Int): Double

Turns quantized value from byte array back into a double.

Link copied to clipboard
fun decodeLongitude(encoded: Int): Double

Turns quantized value from .encodeLongitude back into a double.

fun decodeLongitude(src: ByteArray, offset: Int): Double

Turns quantized value from byte array back into a double.

Link copied to clipboard
fun encodeLatitude(latitude: Double): Int

Quantizes double (64 bit) latitude into 32 bits (rounding down: in the direction of -90)

Link copied to clipboard
fun encodeLatitudeCeil(latitude: Double): Int

Quantizes double (64 bit) latitude into 32 bits (rounding up: in the direction of +90)

Link copied to clipboard
fun encodeLongitude(longitude: Double): Int

Quantizes double (64 bit) longitude into 32 bits (rounding down: in the direction of -180)

Link copied to clipboard
fun encodeLongitudeCeil(longitude: Double): Int

Quantizes double (64 bit) longitude into 32 bits (rounding up: in the direction of +180)