ggsearch

package module
v0.0.0-...-0f1edd8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 24, 2016 License: MIT Imports: 2 Imported by: 0

README

GoDoc

ggsearch is a package for performing fast K-closest lookups of places on Earth.

The distinguishing feature of ggsearch is that it does not require a bounding box for querying. ggsearch builds a sparse grid index of the places and performs queries by iterating the grid tiles in a spiral fashion.

Documentation

Documentation is available on godoc.org.

Here is an example showing how to use ggsearch.

Performance

ggsearch was built for speed. On a t2.micro AWS instance a Web service running ggsearch queried a data set of 40,000 places in 5 ms/request.

Caveats

ggsearch is built for querying populated areas and as such querying near the poles is not going to produce the right results.

License

Released under the MIT license.

Documentation

Overview

ggsearch is a package for performing fast K-closest lookups of places on Earth.

The distinguishing feature of ggsearch is that it does not require a bounding box for querying. ggsearch builds a sparse grid index of the places and performs queries by iterating the grid tiles in a spiral fashion.

Example

Here is an example showing how to use ggsearch: https://github.com/p/go-geo-grid-search/tree/master/examples/simple.go

Performance

ggsearch was built for speed. On a t2.micro AWS instance a Web service running ggsearch queried a data set of 40,000 places in 5 ms/request.

Caveats

ggsearch is built for querying populated areas and as such querying near the poles is not going to produce the right results.

License

Released under the MIT license.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Filter

type Filter func(Locatable) bool

Type of filtering callbacks.

type Locatable

type Locatable interface {
	// Returns latitude of this object in degrees
	Lat() float64
	// Returns longitude of this object in degrees
	Lng() float64
}

ggsearch stores and queries objects implementing Locatable interface.

type Result

type Result struct {
	// contains filtered or unexported fields
}

Search result, provides access to the original Locatable object and distance from query point to this object.

func (Result) Distance

func (s Result) Distance() float64

Returns the distance, in miles, from the Locatable object in this search result to the query point.

func (Result) Locatable

func (s Result) Locatable() Locatable

Returns the Locatable object for this search result.

type Searcher

type Searcher struct {
	// contains filtered or unexported fields
}

Searcher maintains the grid index over Locatables in a data set and performs K-closest queries.

func NewSearcher

func NewSearcher(lat_tiles, lng_tiles int) Searcher

Creates a new Searcher with the specified number of horizontal and vertical tiles.

func (Searcher) AddLocatable

func (s Searcher) AddLocatable(locatable Locatable)

Adds an object satisfying the Locatable interface to this Searcher.

func (Searcher) Search

func (s Searcher) Search(filter *Filter, lat, lng float64, limit int) []Result

Performs a K-closest search around the point identified by lat and lng which must be given in degrees. Limit specifies how many objects to return. Filter is optional and if given, will be invoked for each object to determine if the object should be in the result set.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL