https://github.com/akhenakh/insidetree
A tree datastructure to store s2 cells and perform fast point in polygons lookup
https://github.com/akhenakh/insidetree
datastructure geo go s2 spatial
Last synced: about 1 year ago
JSON representation
A tree datastructure to store s2 cells and perform fast point in polygons lookup
- Host: GitHub
- URL: https://github.com/akhenakh/insidetree
- Owner: akhenakh
- License: bsd-3-clause
- Created: 2018-08-10T16:21:25.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2020-01-17T16:24:39.000Z (over 6 years ago)
- Last Synced: 2025-03-27T13:39:59.139Z (about 1 year ago)
- Topics: datastructure, geo, go, s2, spatial
- Language: Go
- Size: 494 KB
- Stars: 6
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://cloud.drone.io/akhenakh/insidetree)
insidetree
==========
This datastructure is specialized in indexing S2 cells to perform stab queries (Point in Polygons).
For explanations about s2 and the tree used in this package look at this [great blogpost](https://blog.zen.ly/geospatial-indexing-on-hilbert-curves-2379b929addc)
It's an alternative of using an interval tree like [in this other project](https://github.com/akhenakh/regionagogo) exposed [in this blogpost](https://blog.nobugware.com/post/2016/geo_db_s2_region_polygon/).
```go
tree := NewTree()
// index you cells using Index()
tree.Index(cell, "Red building")
// test for cell of any levels
insideCell := s2.CellIDFromLatLng(s2.LatLngFromDegrees(46.83808, -71.28046))
results := tree.Stab(insideCell)
// results[0] == "Red Building"
```