Package | Link |
---|---|
Geohash.SpatialIndex.Core | |
Geohash.SpatialIndex.SpatialRelations |
Build the index:
var index = new GeohashSpatialIndex<int>(
new DefaultGeohasher(),
new DefaultTrieMap<int>(),
precision: 9);
Fill the index with geometries:
foreach(var obj in gisObjects)
index.Insert(obj.Geometry, obj);
Query the index:
var result = index.Query(geom)
You can also use one of the provided spatial relation functions provided which is backed by NetTopologySuite:
var relations = new GeohashSpatialIndexRelations<MyGisObjType>(index);
var result = relations.STIntersects(myGeom);
A spatial index backed by geohashing and Trie (prefix tree) maps. Geometries are encoded as geohashes and stored in a prefix tree, and reverse lookups are performing by encoding the queried geometry and using the prefix tree as an inverted lookup index. The index size can be tuned with the precision parameter. The geohasher and prefix tree map providers can be injected by implementing the IGeohasher
and/or IGeohashTrieMap<TEntryList, T>
interfaces. This library ships with default implementations that uses rm.Trie and geohash-dotnet.
Below is an example with an index covering a set of polygons along the norwegian coastline:
Another example, an index covering some polygons in inner Oslo Fjord:
A final example, some polygons related to offshore installations in the north sea: