Spatial.sol
library and plan to release it under an open source license. Developing the library entails tackling several technical challenges, and to build a production-quality library will be quite involved.Spatial.sol
is required for many of the location-based dapps and spatial contracts we envision, including the verifiable spatial data registries described here. We are researching which functions the library should include, and will look to Turf.js for inspiration. Some functions we expect to include are:isPolygon
, isLine
and so onsqrt
degreesToNanoradians.
distance
, area
, centroid
, length
, perimeter
bearing
, rhumbBearing
boundingBox, convexHull
pointInBbox
, pointInPolygon
, intersects
difference
, dissolve
, intersect
, union
, etc.Spatial.sol
has a dependency: Trigonometry.sol
, developed and open sourced by Sikorka (docs, code). This library appears to have been abandoned a few years ago, and lacks a tangent
method, which is useful in some operations like the bearing between two points. Spatial.sol
will require an audited Trigonometry.sol
to be secure.eth-spatial.js
, to abstract some of the complexities of supplying spatial data to contracts using Spatial.sol. Our goal is to ease the developer experience - we expect that many developers will be working with GeoJSON in the client.eth-spatial.js
will be designed to seamlessly accept common data formats used on the web (starting with GeoJSON) and prepare the spatial data for use in contracts that use the Spatial.sol
library. One example process here will be converting decimal degrees to integers to be used in the contract, possibly nanoradians.eth-spatial.js
to easily convert from on-chain spatial data to web-ready GeoJSON. We may look into developing a subgraph to index on-chain geospatial data - the final step to fetching this data will be presenting it in a format that interoperates with common spatial data libraries like Leaflet, Mapbox GL JS etc. An eth-spatial.py
library would also probably be helpful, as would implementations in other languages - future work to do.