Geospatial Operations
Astral provides verifiable spatial computations backed by PostGIS — the gold standard in geospatial databases with 20+ years of production use. All operations return Policy Attestations — signed results that can be used offchain or submitted onchain to trigger smart contract logic.PostGIS uses GEOS (Geometry Engine Open Source) under the hood for geometry operations. GEOS is the C++ library that powers most professional geospatial software.
Available Operations
Measurements
Operations that return numeric results (as NumericPolicyAttestations):| Operation | Description | Unit | Geometry Types | PostGIS Function |
|---|---|---|---|---|
distance | Nearest distance between two geometries | meters | Any | ST_Distance |
area | Area of a polygon | square meters | Polygon, MultiPolygon | ST_Area |
length | Length of a line | meters | LineString, MultiLineString | ST_Length |
Predicates
Operations that return boolean results (as BooleanPolicyAttestations):| Operation | Description | PostGIS Function |
|---|---|---|
contains | Is geometry B entirely inside geometry A? | ST_Contains |
within | Is geometry within a specified radius of target? | ST_DWithin |
intersects | Do geometries share any space? | ST_Intersects |
Operation Examples
Code snippets need testing — Verify against actual implementation before use.
Distance
Calculate the nearest distance between two geometries in meters. For polygons, this returns the minimum distance between their boundaries.Contains
Check if a geometry is entirely inside a container geometry.Within
Check if a geometry is within a specified radius of a target — essentially a radius check.Intersects
Check if two geometries share any space (overlap, touch, or cross).Area
Calculate the area of a polygon (must be Polygon or MultiPolygon).Length
Calculate the length of a line (must be LineString or MultiLineString).Units
All measurements use metric units only:| Measurement | Unit |
|---|---|
| Distance | meters |
| Length | meters |
| Area | square meters |
Radius (in within) | meters |
No unit conversion options are provided. Developers should convert client-side if needed.
Precision
Results are stored with centimeter precision to enable deterministic, reproducible computation:| Type | Precision | Storage |
|---|---|---|
| Distance/Length | 0.01m | Scaled integer (cm) |
| Area | 0.0001 m² | Scaled integer (cm²) |
We’re actively testing the reliability of deterministic geospatial computation with this precision approach. This is an area of ongoing research in the beta implementation.
Compute Options
All operations require these parameters:We only support official EAS deployments on supported chains. See the SDK overview for the chain list.
Future Operations
Post-MVP, we plan to add:| Operation | Type | Description |
|---|---|---|
disjoint | Predicate | Do geometries not touch? |
buffer | Transformation | Create buffer zone around geometry |
centroid | Transformation | Find center point |
union | Transformation | Merge geometries |
intersection | Transformation | Overlapping area |
Client-Side Operations with Turf.js
We recommend Turf.js for client-side geospatial operations. Use Turf.js for instant UX feedback, and Astral for verifiable attestations:| Use Case | Tool | Why |
|---|---|---|
| Real-time UI feedback | Turf.js | Instant, free, runs client-side |
| Verifiable computation | Astral | Signed attestation for onchain actions |
Next: Policy Attestations
Learn about the signed outputs of geospatial operations