Documentation ¶
Index ¶
- Variables
- func SetDropPBLoc(opt *Option)
- type ExampleCombinedFinder
- type Finder
- func (f *Finder) GetLocation(lng float64, lat float64) (*pb.Location, error)
- func (f *Finder) GetLocationName(lng float64, lat float64) string
- func (f *Finder) GetLocationNames(lng float64, lat float64) ([]string, error)
- func (f *Finder) GetLocationShapeByName(name string) (*pb.Location, error)
- func (f *Finder) LocationNames() []string
- type FuzzyFinder
- type Option
- type OptionFunc
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNoLocationFound = errors.New("pinpoint: no location found")
Functions ¶
func SetDropPBLoc ¶
func SetDropPBLoc(opt *Option)
SetDropPBLoc will make Finder not save github.com/deslittle/pinpoint/pb.Location in memory
Types ¶
type ExampleCombinedFinder ¶ added in v0.3.0
type ExampleCombinedFinder struct {
// contains filtered or unexported fields
}
combinedFinder is an example implimentation using the `pinpoint-us-states` repo which combines both FuzzyFinder and Finder.
It's designed for performance first and allow some not so correct return at some area.
func NewExampleCombinedFinder ¶ added in v0.3.0
func NewExampleCombinedFinder() (*ExampleCombinedFinder, error)
func (*ExampleCombinedFinder) GetLocationName ¶ added in v0.3.0
func (f *ExampleCombinedFinder) GetLocationName(lng float64, lat float64) string
func (*ExampleCombinedFinder) GetLocationNames ¶ added in v0.3.0
func (f *ExampleCombinedFinder) GetLocationNames(lng float64, lat float64) ([]string, error)
func (*ExampleCombinedFinder) LocationNames ¶ added in v0.3.0
func (f *ExampleCombinedFinder) LocationNames() []string
type Finder ¶
type Finder struct {
// contains filtered or unexported fields
}
Finder is based on point-in-polygon search algo.
Memeory will use about 100MB if lite data and 1G if full data. Performance is very stable and very accuate.
func NewFinderFromCompressed ¶
func NewFinderFromCompressed(input *pb.CompressedLocations, opts ...OptionFunc) (*Finder, error)
func NewFinderFromPB ¶
func NewFinderFromPB(input *pb.Locations, opts ...OptionFunc) (*Finder, error)
func NewFinderFromRawJSON ¶
func NewFinderFromRawJSON(input *convert.BoundaryFile, opts ...OptionFunc) (*Finder, error)
func (*Finder) GetLocation ¶
func (*Finder) GetLocationName ¶
GetLocationName will use alphabet order and return first matched result.
Example ¶
package main import ( "fmt" pinpoint "github.com/deslittle/pinpoint" usstates "github.com/deslittle/pinpoint-us-states" "github.com/deslittle/pinpoint/pb" "google.golang.org/protobuf/proto" ) func main() { input := &pb.Locations{} // Lite data, about 16.7MB //dataFile := usstates.LiteData // Full data, about 83.5MB dataFile := usstates.FullData if err := proto.Unmarshal(dataFile, input); err != nil { panic(err) } finder, _ := pinpoint.NewFinderFromPB(input) // Need to use a point not so close to New York border for Fuzzy Search loc, err := finder.GetLocation(-74.03440821618342, 40.71579135708155) fmt.Printf("%v %v\n", loc.GetName(), err) }
Output: 34 <nil>
func (*Finder) GetLocationNames ¶
func (*Finder) GetLocationShapeByName ¶
Example ¶
package main import ( "fmt" pinpoint "github.com/deslittle/pinpoint" usstates "github.com/deslittle/pinpoint-us-states" "github.com/deslittle/pinpoint/pb" "google.golang.org/protobuf/proto" ) func main() { input := &pb.Locations{} // Lite data, about 16.7MB dataFile := usstates.FullData if err := proto.Unmarshal(dataFile, input); err != nil { panic(err) } finder, _ := pinpoint.NewFinderFromPB(input) pbloc, err := finder.GetLocationShapeByName("34") fmt.Printf("%v %v\n", pbloc.GetName(), err) }
Output: 34 <nil>
func (*Finder) LocationNames ¶
type FuzzyFinder ¶
type FuzzyFinder struct {
// contains filtered or unexported fields
}
FuzzyFinder use a tile map to store location name. Data are made by github.com/deslittle/pinpoint/cmd/preindexlocpb which powerd by github.com/deslittle/pinpoint/preindex.PreIndexLocations.
func NewFuzzyFinderFromPB ¶
func NewFuzzyFinderFromPB(input *pb.PreindexLocations) (*FuzzyFinder, error)
func (*FuzzyFinder) GetLocationName ¶
func (f *FuzzyFinder) GetLocationName(lng float64, lat float64) string
Example ¶
package main import ( "fmt" pinpoint "github.com/deslittle/pinpoint" usstates "github.com/deslittle/pinpoint-us-states" "github.com/deslittle/pinpoint/pb" "google.golang.org/protobuf/proto" ) func main() { input := &pb.PreindexLocations{} if err := proto.Unmarshal(usstates.PreindexData, input); err != nil { panic(err) } finder, _ := pinpoint.NewFuzzyFinderFromPB(input) loc := finder.GetLocationName(-74.666645, 40.736032) fmt.Println(loc) }
Output: 34
func (*FuzzyFinder) GetLocationNames ¶
func (f *FuzzyFinder) GetLocationNames(lng float64, lat float64) ([]string, error)
type OptionFunc ¶
type OptionFunc = func(opt *Option)
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
combinegeojson
CLI tool to combine multiple geojson files into one.
|
CLI tool to combine multiple geojson files into one. |
compresslocpb
CLI tool to reduce polygon filesize
|
CLI tool to reduce polygon filesize |
filtergeojson
CLI tool to combine multiple geojson files into one.
|
CLI tool to combine multiple geojson files into one. |
geojson2locpb
CLI tool to convert GeoJSON based Location boundary to pinpoints's Probuf format.
|
CLI tool to convert GeoJSON based Location boundary to pinpoints's Probuf format. |
namegeojson
CLI tool to convert GeoJSON based Location boundary to pinpoints's Probuf format.
|
CLI tool to convert GeoJSON based Location boundary to pinpoints's Probuf format. |
pinpoint
pinpoint-cli tool for local query.
|
pinpoint-cli tool for local query. |
preindexlocpb
CLI tool to preindex location shape.
|
CLI tool to preindex location shape. |
reducelocpb
CLI tool to reduce polygon filesize
|
CLI tool to reduce polygon filesize |
Package preindex
|
Package preindex |
Package reduce could reduce Polygon size both polygon lines and float precise.
|
Package reduce could reduce Polygon size both polygon lines and float precise. |