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
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.
The area of a rectangle in square degrees.
Returns the bounding box of any 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 point meters)
A spatial4j circle around the given point or lat,long, with radius in
(dist-at-idx linestring idx)
Distance between the linestring's point at the given index and the subsequent point.
(distance a b)
Distance between two points, in 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 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 a b)
Distance between two points, in degrees.
The SpatialContext of the earth, as according to spatial4j.
Earth's equatorial circumference, in meters
Earth's radius at the equator, in meters.
Earth's mean circumference, in meters.
Earth's mean radius, in meters.
Earth's circumference around a meridian, in meters.
Earth's radius at the poles, in meters.
Returns an approximate radius for the earth, at some point. Based on the
geodetic model for an oblate spheroid.
(geohash-point lat long)
Returns a WGS84Point used by the geohash library.
(h3-point lat long)
Returns a GeoCoord used by the H3 library.
Returns the height of a shape, in degrees.
(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.
ShapeFactory for producing spatial4j Shapes from JTSGeometries based
(jts-point lat long)
Returns a Point used by JTS.
Get geodesic length of a (jts) linestring by summing lengths of successive points
(point-between c1 c2 dist)
(radians->distance radians radius)
Converts radians to meter distance on the surface of the earth. Assumes
earth mean 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
Default distribution is :uniform.
(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 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.
(to-jts this srid)
Convert anything to a projected JTS Geometry.
Convert anything to a Shape.
(spatial4j-point lat long)
A spatial4j point on the earth.
(steradians->area steradians radius)
Converts steradians to square meters on the surface of the earth. Assumes
earth mean radius.
Returns the width of a shape, in degrees.
(within-dist? p1 p2 dist)