I’ve created a brainstorming document for geo spatial queries:
Anyone who is interested please take a look and provide suggestions on what we can implement in the first version.
Supported GIS features are the 7 OpenGIS simple features:
Types of supported columns
- Features are in a 2-D Euclidean space. All calculations done in 2-D.
Features are lat-long positions on Earth. Calculations are done using an ellipsoidal (round-earth) model. Polygons have a left-hand orientation. Default model for earth: http://spatialreference.org/ref/epsg/wgs-84/ (https://en.wikipedia.org/wiki/World_Geodetic_System)
Well Known Text (WKT) & Well Known Binary (WKB)
Input/output format can be WKT or GeoJson.
Storage format should be WKB (as expected by RocksDB spatial index)
Go implementation of all 3 formats: https://github.com/twpayne/go-geom
Possible query operators:
- within (mongo, sql, postgis, mysql): whether one geometry is completely within another E.g. Find me all restaurants whose location is within ‘polygon representing border of Menlo Park’
- intersect (mongo, sql, postgis, mysql): whether two geometries intersect each other E.g. find me all US states whose borders intersect ‘polygon for route 66’
- disjoint(sql, postgis, mysql): not intersect
- distance (sql, postgis, mysql): return minimum distance
Useful for nearest neighbor queries (MongoDB uses near and does not expose the distance)
E.g. find me all gas stations whose location is closest to my location, sort ascending by distance.
RocksDB Spatial indexing:
Supports indexing bounding boxes. Index can be used to query all intersecting bounding boxes at a “level”. Supports multiple “levels” in the same index.
Note: This is not an actual R-tree index, but rather a single level index. Multiple levels are managed by the client by specifying the “level” for each feature.
Calculations are done in euclidean space. We will have to apply a geographic calculation on top of that.
Build our own index as described: https://msdn.microsoft.com/en-us/library/bb895265.aspx
- PostGIS: http://postgis.net/docs/manual-2.2
- Mongo DB queries: https://docs.mongodb.com/manual/reference/operator/query-geospatial/
- SQL Server: https://msdn.microsoft.com/en-US/library/bb933790.aspx
- MySQL: https://dev.mysql.com/doc/refman/5.7/en/spatial-extensions.html
- GeoSparQL: http://www.opengeospatial.org/standards/geosparql