Spatial
Calcite is aiming to implement OpenGIS Simple Features Implementation Specification for SQL, version 1.2.1, a standard implemented by spatial databases such as PostGIS and H2GIS.
We also aim to add optimizer support for spatial indexes and other forms of query optimization.
Introduction
A spatial database is a database that is optimized for storing and query data that represents objects defined in a geometric space.
Calcite’s support for spatial data includes:
- A GEOMETRY data type and
sub-types including
POINT
,LINESTRING
andPOLYGON
- Spatial functions (prefixed
ST_
; we have implemented about 35 of the 150 in the OpenGIS specification)
and will at some point also include query rewrites to use spatial indexes.
Enabling spatial support
Though the GEOMETRY
data type is built-in, the functions are not enabled by
default. You need to add fun=spatial
to the JDBC connect string to enable
the functions. For example, sqlline
:
Acknowledgements
Calcite’s OpenGIS implementation uses the Esri geometry API. Thanks for the help we received from their community.
While developing this feature, we made extensive use of the PostGIS documentation and tests, and the H2GIS documentation, and consulted both as reference implementations when the specification wasn’t clear. Thank you to these awesome projects.