object

# `geospatial`

Geospatial predicates over geographic coordinates represented as `(Latitude,Longitude)`.

Availability:
`logtalk_load(geospatial(loader))`
Author: Paulo Moura
Version: 0:2:0
Date: 2026-02-25
Compilation flags:
`static, context_switching_calls`
Implements:
`public` geospatial_protocol
Uses:
list
Remarks:

> - Distance unit: Kilometers.

> - Coordinate ranges: Latitude values must be in the `[-90.0,90.0]` range and longitude values in the `[-180.0,180.0]` range.

Inherited public predicates:
along_track_distance/4 bbox_contains/2 bbox_expand/3 bbox_from_coordinates/2 bbox_intersects/2 bbox_union/3 bounding_box/3 clockwise_polygon/2 close_polygon/2 coordinates_bounding_box/2 counterclockwise_polygon/2 cross_track_distance/4 destination_point/4 equirectangular_inverse/4 equirectangular_projection/4 final_bearing/3 haversine_distance/3 initial_bearing/3 interpolate_great_circle/4 interpolate_rhumb/4 is_clockwise_polygon/1 is_valid_polygon/1 mean_center/2 midpoint/3 minimum_enclosing_circle/3 nearest_coordinate/5 nearest_point_on_polyline/4 nearest_point_on_segment/4 normalize_coordinate/2 normalize_polygon_orientation/3 point_in_polygon/2 point_to_polyline_distance/3 polygon_area/2 polygon_bounding_box/2 polygon_centroid/2 polygon_orientation/2 polygon_perimeter/2 polygon_perimeter/3 polygons_intersect/2 polyline_length/2 polyline_length/3 polyline_resample/3 polyline_simplify/3 polyline_split_at_distance/4 rhumb_bearing/3 rhumb_destination_point/4 rhumb_distance/3 rhumb_midpoint/3 route_distance/2 route_distance/3 route_distance/4 valid_coordinate/1 vincenty_distance/3 within_distance/4

## Public predicates

### `distance/4`

Computes the distance in kilometers between two coordinates using a selected metric. Supported metrics are `haversine`, `vincenty`, and `rhumb`.

Compilation flags:
`static`
Template:
`distance(Coordinate1,Coordinate2,Metric,Distance)`
Mode and number of proofs:
`distance(+compound,+compound,+atom,-float)` - `zero_or_one`

### `distance/5`

Computes the distance between two coordinates using a selected metric and output unit. Supported metrics are `haversine`, `vincenty`, and `rhumb`. Valid `Unit` argument values are `kilometers`, `meters`, `miles`, and `nautical_miles`.

Compilation flags:
`static`
Template:
`distance(Coordinate1,Coordinate2,Metric,Unit,Distance)`
Mode and number of proofs:
`distance(+compound,+compound,+atom,+atom,-float)` - `zero_or_one`

## Protected predicates

(no local declarations; see entity ancestors if any)

## Private predicates

(no local declarations; see entity ancestors if any)

## Operators

(none)

See also

geospatial_protocol, numberlist