rawgeo

package module
v0.0.0-...-36dbb96 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2017 License: MIT Imports: 14 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

RawGeo

Build Status    Godoc Reference

Building block for building geospatial indexes using geohashes.

Features

  • Use the Geohash algorithm to index and search data.
  • Index (lat, lng, ID) data in a kv file.
  • Find nearest neighbors from lag, lng within a given radius sorted by distance.
  • Don't designed to store data (should be handled by another component).

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Log               = log.New()
	ErrNotFound       = errors.New("key does not exist")
	ErrMissingID      = errors.New("missing ID")
	ErrInvalidLatLong = errors.New("invalid lat/long")
)

Functions

This section is empty.

Types

type Point

type Point struct {
	ID      string
	Geohash string

	// These fields are computed query time and will be ignored when indexing
	Distance float64
	Lat, Lng float64
}

func NewPointFromGeohash

func NewPointFromGeohash(id, geohash string) *Point

func (*Point) DistanceFrom

func (p *Point) DistanceFrom(point *Point) float64

Implements the equirectangular approximation from www.movable-type.co.uk/scripts/latlong.html (Pythagoras’ theorem on an equirectangular projection)

Returns the approximate distance in meters

type RawGeo

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

func New

func New(path string) (*RawGeo, error)

New initializes/loads a `RawGeo` index at the given path

func (*RawGeo) Close

func (rg *RawGeo) Close() error

Close gracefully closes the opened index

func (*RawGeo) Destroy

func (rg *RawGeo) Destroy() error

Destroy will try to remove the index file

func (*RawGeo) Index

func (rg *RawGeo) Index(point *Point) error

Put index the given entry in the given index (you have to care about duplicate IDs)

func (*RawGeo) Query

func (rg *RawGeo) Query(lat, lng, radius float64) ([]*Point, error)

Query will returns all the points found in the given radius (in meters) sorted by distance to the query

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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