Giter Site home page Giter Site logo

hashfill's Introduction

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.

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:

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

hashfill's People

Contributors

willyham avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hashfill's Issues

Go import error

While importing this package, getting the error.

github.com/paulsmith/gogeos/geos

In file included from ../../go/src/github.com/paulsmith/gogeos/geos/coordseq.go:4:
./geos.h:1:10: fatal error: 'geos_c.h' file not found
#include <geos_c.h>
^~~~~~~~~~
1 error generated.

And github.com/paulsmith/gogeos/geos page giving 404 error.

All tiles returned with same precision.

Hi, as I understand your algorithm should return fully completed tiles with min precision and only uncompleted ones with max precision. May be there is misunderstanding from my side.
I always get array of geohashes with precision I defined as max precision.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.