lookup

package
v0.0.0-...-943c59f Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2017 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateBuntDB

func CreateBuntDB(dbFile, locationFile string) error

CreateBuntDB is called by the CLI tool -create. This removes any existing keys before doing the import.

Types

type ByDistance

type ByDistance struct{ Locations }

ByDistance is a convenience type for sorting locations by their distance.

func (ByDistance) Less

func (s ByDistance) Less(i, j int) bool

type DB

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

DB contains the underlying buntdb for Geo lookups, and in the future may not even be buntdb.

func TryOpenDB

func TryOpenDB(dbFile, locationFile string) (*DB, error)

TryOpenDB opens dbFile if it exists, otherwise it reads locationFile. If locationFile also does not exist, a builtin dataset is used.

This complexity is so that the command line server example can be run with no required files or flags.

Caller must call Close() on DB when done.

func (*DB) Close

func (lu *DB) Close() error

Close closes the underlying DB. Must call when done with your *DB.

func (*DB) FindNearest

func (lu *DB) FindNearest(lat, lon float64, maxResults int) (Locations, error)

FindNearest returns up to maxResults near lat/lon. Naive implementation.

type Location

type Location struct {
	Name     string
	Lat      float64
	Lon      float64
	Distance float64
}

Location holds one positions data as returned from the DB.

type Locations

type Locations []*Location

func (Locations) Len

func (s Locations) Len() int

func (Locations) Swap

func (s Locations) Swap(i, j int)

Jump to

Keyboard shortcuts

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