Fill geofences with geohashes
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
doc
testdata
.gitignore
LICENSE
README.md
hashfill.go
hashfill_test.go
predicates.go
predicates_test.go

README.md

GoDoc Go Report Card

Usage

Hashfill is a library for computing the set of geohashes which are contained by a geofence. It can either produce a set of hashes which are completely contained or one which also includes where the boundaries intersect. It currently operates on geom.Polygon objects from the https://github.com/twpayne/go-geom pacakge. Converting from geojson is simple and this package may offer a utility in the future.

geofence := readFileAsGeometry("testdata/regents.geojson")
filler := hashfill.NewRecursiveFiller(
  hashfill.WithMaxPrecision(8),
)

hashes, err := filler.Fill(geofence, hashfill.FillIntersects)

Would result in something that could be visualized as:

Options

  • WithMaxPrecision - Sets the max hash precision the algorithm will generate hashes for.
  • WithFixedPrecision - Causes the fully contained geohashes to still be divided into the hashes of the max precision.
  • WithPredicates - Can be used to supply your own functions for Intersect and Contains rather than the built in ones.

Improvements

TODO:

  • [] Fix bug in geofences with holes.
  • [] Corner based check optimisations (+ hybrid)
  • [] Cache poly to geom operation in predicates.
  • [] Add benchmarks