SZ-ORM PostGIS Extension
Provides PostgreSQL PostGIS spatial geometry query capabilities, supporting three implementations:
- In-memory implementation (
Memory): Pure Rust geometry computation, no database connection, suitable for testing and benchmarking - Stub implementation (
Stub): Generates PostGIS SQL string but does not execute, suitable for debugging - Real implementation (
RealPg, requiresreal-postgisfeature): Connects to PostgreSQL via tokio-postgres
Supported Geometry Types
Point: PointLineString: Line stringPolygon: Polygon (with holes)MultiPoint/MultiLineString/MultiPolygon: Multi-geometry
All geometry types carry SRID (coordinate reference system ID), default WGS84 (SRID=4326).
Supported Spatial Operations
| Method | SQL equivalent | Description |
|---|---|---|
st_distance |
ST_Distance |
Distance between two points |
st_contains |
ST_Contains |
Contains check |
st_within |
ST_Within |
Within check |
st_intersects |
ST_Intersects |
Intersects check |
st_area |
ST_Area |
Area calculation |
st_length |
ST_Length |
Length calculation |
st_buffer |
ST_Buffer |
Buffer zone |
st_union |
ST_Union |
Geometry union |
add_geometry_column |
AddGeometryColumn |
Add geometry column |
create_spatial_index |
CREATE INDEX ... USING GIST |
Spatial index |
Quick Start
use ;
#
# async