LocationTech Spatial4j is a general purpose spatial / geospatial ASL licensed open-source Java library. Its core capabilities are 3-fold: to provide common geospatially-aware shapes, to provide distance calculations and other math, and to read and write the shapes to strings.
- Shape classes that are geospatially aware(*)
- Shapes: Point, Rectangle, Circle, Polygon (via JTS)
- shape intersection logic, yielding: disjoint, contains, within, intersects
- bounding box
- area calculation
- Distance math
- Spherical: Law of Cosines, Haversine, Vincenty
- Input and Output of shapes to strings using WKT, GeoJSON, and integration with the Jackson-databind serialization framework
- Integration with JTS to adapt its shapes to Spatial4j’s interfaces, including adding some geospatial awareness
- No runtime dependencies unless JTS is needed
In addition, the code is well tested and it’s monitored via Travis-CI continuous integration.
(*) Geospatial awareness, AKA "geodetic" means it is aware of the implications of the international dateline (aka anti-meridian) and poles. It can’t pretend the earth is flat and infinitely large.