Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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: 24 days ago
JSON representation

A tree datastructure to store s2 cells and perform fast point in polygons lookup

Awesome Lists containing this project

README

        

[![Build Status](https://cloud.drone.io/api/badges/akhenakh/insidetree/status.svg)](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"
```