Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Willyham/hashfill
Fill geofences with geohashes
https://github.com/Willyham/hashfill
geofences geohash golang golang-package
Last synced: 7 days ago
JSON representation
Fill geofences with geohashes
- Host: GitHub
- URL: https://github.com/Willyham/hashfill
- Owner: Willyham
- License: mit
- Created: 2017-11-10T11:56:58.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2024-01-27T05:33:34.000Z (10 months ago)
- Last Synced: 2024-08-01T19:45:08.929Z (3 months ago)
- Topics: geofences, geohash, golang, golang-package
- Language: Go
- Size: 1.2 MB
- Stars: 41
- Watchers: 0
- Forks: 12
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![GoDoc](http://godoc.org/github.com/Willyham/hashfill?status.png)](http://godoc.org/github.com/Willyham/hashfill) [![Go Report Card](https://goreportcard.com/badge/github.com/Willyham/hashfill)](https://goreportcard.com/report/github.com/Willyham/hashfill)
## 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](go-geom) pacakge. Converting from geojson is simple and this
package may offer a utility in the future.```golang
func readFileAsGeometry(t *testing.T, file string) (*geom.Polygon, error) {
data, err := ioutil.ReadFile(file)
if err != nil {
return nil, err
}poly := new(geom.T)
err = geojson.Unmarshal(data, poly)
if err != nil {
return nil, err
}return nil, (*poly).(*geom.Polygon)
}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:
![](./doc/fill.png)
### Installation
This library depends on headers from the `geos` library. You can install with `brew install geos` or `dnf install geos-devel` on RPM based linux distros.
### 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