geo.spatial

Provides common interfaces for working with spatial objects and geodesics.
All units are in meters/radians/steradians unless otherwise specified.
Provides static spatial contexts for the earth, and some constants like the
earth's radii and circumferences, along with points like the poles.

Defines protocols for unified access to Points and Shapes, to allow different
geometry libraries to interoperate.

Basic utility functions for unit conversion; e.g. degrees<->radians.

Functions for computing earth radii, surface distances, and surface areas.

Constructors for shapes like bounding-boxes and circles, and utility
functions over shapes for their heights, centers, areas, etc. Can also
compute relationships between shapes: their intersections, contains, disjoint
statuses, etc.

area

(area rect)
The area of a rectangle in square meters. Note that spatial4j's term 'area'
actually refers to solid angle, not area; we convert by multiplying by the
earth's radius at the midpoint of the rectangle.

area-in-square-degrees

(area-in-square-degrees rect)
The area of a rectangle in square degrees.

bounding-box

(bounding-box shape)
Returns the bounding box of any shape.

center

(center shape)
Returns the centroid of a spatial4j shape. Note that .getCenter does bad
things for JTS shapes that cross the international dateline, so we use use
(center (bounding-box x)) for JTS stuff.

circle

(circle point meters)
A spatial4j circle around the given point or lat,long, with radius in
meters.

crosses-dateline?

(crosses-dateline? jts-geom)

degrees->radians

(degrees->radians degrees)

dist-at-idx

(dist-at-idx linestring idx)
Distance between the linestring's point at the given index and the subsequent point.

distance

(distance a b)
Distance between two points, in meters

distance->radians

(distance->radians meters)(distance->radians meters radius)
Converts distance, in meters on the surface of the earth, to radians.
Assumes earth mean radius.

distance-at-point->radians

(distance-at-point->radians meters point)
Converts a distance near a point on the earth into radians; using a more
accurate model of the radius of the earth near that point.

distance-in-degrees

(distance-in-degrees a b)
Distance between two points, in degrees.

earth

The SpatialContext of the earth, as according to spatial4j.

earth-equatorial-circumference

Earth's equatorial circumference, in meters

earth-equatorial-radius

Earth's radius at the equator, in meters.

earth-equatorial-radius-squared

earth-mean-circumference

Earth's mean circumference, in meters.

earth-mean-radius

Earth's mean radius, in meters.

earth-meridional-circumference

Earth's circumference around a meridian, in meters.

earth-polar-radius

Earth's radius at the poles, in meters.

earth-polar-radius-squared

earth-radius

(earth-radius point)
Returns an approximate radius for the earth, at some point. Based on the
geodetic model for an oblate spheroid.

geohash-point

(geohash-point point)(geohash-point lat long)
Returns a WGS84Point used by the geohash library.

h3-point

(h3-point point)(h3-point lat long)
Returns a GeoCoord used by the H3 library.

height

(height shape)
Returns the height of a shape, in degrees.

intersects?

(intersects? a b)
Do two shapes intersect in any way? Note that spatial4j's relate() considers
intersection *different* from containment, e.g. if A completely surrounds B,
their relation is not INTERSECTS. Spatial4j has a intersects() function on
relations (the one used here) which considers two shapes intersecting if
their intersection is non-empty; i.e. they are not disjoint.

jts-earth

ShapeFactory for producing spatial4j Shapes from JTSGeometries based

jts-point

(jts-point point)(jts-point lat long)
Returns a Point used by JTS.

length

(length linestring)
Get geodesic length of a (jts) linestring by summing lengths of successive points

north-pole

Point

protocol

members

latitude

(latitude this)

longitude

(longitude this)

to-geohash-point

(to-geohash-point this)

to-h3-point

(to-h3-point this)

to-spatial4j-point

(to-spatial4j-point this)

point

point-between

(point-between c1 c2 dist)

radians->degrees

(radians->degrees radians)

radians->distance

(radians->distance radians)(radians->distance radians radius)
Converts radians to meter distance on the surface of the earth. Assumes
earth mean radius.

rand-point-in-radius

(rand-point-in-radius center-lat center-lon radius-meters)(rand-point-in-radius center-lat center-lon radius-meters distribution)
Get a random point around the given latitude and longitude within the given radius.

(rand-point-in-radius 34.05656 -118.41881 100)
(rand-point-in-radius 34.05656 -118.41881 100 :clustered)
(rand-point-in-radius 34.05656 -118.41881 100 (fn [] 1))

Returns org.locationtech.spatial4j.shape.jts.JtsPoint; Use geo.spatial/latitude and geo.spatial/longitude
to retrieve raw coords.

Accepts an optional 4th argument for customizing the distribution. Can be either :uniform or :clustered
for built-in distributions, or a custom fn.

Distribution fn should return a float between 0.0 and 1.0 when invoked.

The built-in :clustered distribution uses a linear distribution of radius, which results in points
clustered more heavily toward the center of the radius.

:uniform uses an exponential distribution of radius which results in points being spread evenly across
the circle.

Default distribution is :uniform.

relate

(relate a b)
The relationship between two shapes. Returns a keyword:

:contains    a contains b
:within      a falls within b
:intersects  a and b have at least one point in common
:disjoint    a and b have no points in common

resegment

(resegment linestring segment-length)
Repartitions a JTS LineString into multiple contiguous linestrings, each up to the
provided length (in meters). Final segment may be less than the requested length.
Length of individual segments may vary a bit but total length should remain the same.

Shapelike

protocol

members

to-jts

(to-jts this)(to-jts this srid)
Convert anything to a projected JTS Geometry.

to-shape

(to-shape this)
Convert anything to a Shape.

south-pole

spatial4j-point

(spatial4j-point point)(spatial4j-point lat long)
A spatial4j point on the earth.

square

(square x)

square-degree-in-steradians

square-degrees->steradians

(square-degrees->steradians steradians)

steradians->area

(steradians->area steradians)(steradians->area steradians radius)
Converts steradians to square meters on the surface of the earth. Assumes
earth mean radius.

vincenty-distance-calculator

width

(width shape)
Returns the width of a shape, in degrees.

within-dist?

(within-dist? p1 p2 dist)