GeoSpock database optimized SQL functions

The GeoSpock database Presto plug-in optimizes the following geospatial functions:

SQL function Returns Description
ST_Contains(g1,g2) boolean

Returns 1 (TRUE) or 0 (FALSE) to indicate whether one geometry, g1, completely contains the other geometry, g2. This tests the opposite relationship to ST_Within().

ST_Within(g1,g2) boolean

Returns 1 (TRUE) or 0 (FALSE) to indicate whether the first geometry, g1, is spatially within a second geometry, g2. This tests the opposite relationship as ST_Contains().

ST_Distance(g1,g2)

double

Calculates the shortest distance between two spatial objects.The distance is measured in degrees.

line_locate_point(line, point) double

Calculates where on a line (line) a point (point) lies or interpolates it onto the line, then returns the fraction of distance from the start point as a measurement.

The first argument must be of type LineString using the WKT notation.

The second argument must be of type Point using the WKT notation.

ST_Intersects(g1,g2) boolean

Returns 1 (TRUE) if any part of two geometries intersect or touch at a single point.

Custom GeoSpock SQL functions

The GeoSpock database Presto plug-in includes the following customized functions for defining geofences:

Custom function

Type

Description

GS_Distance_Within(sg1,sg2,dist) boolean

Returns 1 (true) if the two spatial objects are within the specified distance of one another.

Define each spatial object as a SphericalGeometry.

Specify the distance in meters.

GS_great_circle_distance_within(lon1,lat1,lon2,lat2,dist)

boolean

Returns 1 (true) if the two locations are within the specified distance of one another.

A location is defined using latitude and longitude coordinates in decimal degrees (in WGS84).

Specify the distance in meters.