geo_fencer

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

README

geo_fencer

Simple Geo fence library

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FenceIndex

type FenceIndex interface {
	// Set the GeoFence
	Set(name string, fence GeoFence)
	// Get the GeoFence at the key, return nil if doesn't exist
	Get(name string) GeoFence
	// Add a feature to the GeoFence at the key
	Add(name string, feature *geo.Feature) error
	// Search for the coordinate at the key
	Search(name string, c geo.Coordinate) ([]*geo.Feature, error)
	// List the keys of the indexed fences
	Keys() []string
}

FenceIndex is a dictionary of multiple fences. Useful if you have multiple data sets that need to be searched

func LoadFenceIndex

func LoadFenceIndex(fenceType GeoFenceType, resolution int, fenceName string, geoJsonString *string) (fences FenceIndex, err error)

func NewFenceIndex

func NewFenceIndex() FenceIndex

Returns a thread-safe FenceIndex

type GeoFence

type GeoFence interface {
	// Indexes this feature
	Add(f *geo.Feature)
	// Get all features that contain this coordinate
	Get(c geo.Coordinate) []*geo.Feature
}

func GetFence

func GetFence(label GeoFenceType, zoom int) (fence GeoFence, err error)

func NewFence

func NewFence() GeoFence

type GeoFenceType

type GeoFenceType string
const (
	GeoFenceTypeS2    GeoFenceType = "s2"
	GeoFenceTypeBbox  GeoFenceType = "bbox"
	GeoFenceTypeBrute GeoFenceType = "brute"
	GeoFenceTypeRtree GeoFenceType = "rtree"
)

type MutexFenceIndex

type MutexFenceIndex struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewMutexFenceIndex

func NewMutexFenceIndex() *MutexFenceIndex

func (*MutexFenceIndex) Add

func (m *MutexFenceIndex) Add(name string, feature *geo.Feature) error

func (*MutexFenceIndex) Get

func (m *MutexFenceIndex) Get(name string) GeoFence

func (*MutexFenceIndex) Keys

func (m *MutexFenceIndex) Keys() []string

func (*MutexFenceIndex) Search

func (m *MutexFenceIndex) Search(name string, c geo.Coordinate) ([]*geo.Feature, error)

func (*MutexFenceIndex) Set

func (m *MutexFenceIndex) Set(name string, fence GeoFence)

type UnsafeFenceIndex

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

func NewUnsafeFenceIndex

func NewUnsafeFenceIndex() *UnsafeFenceIndex

func (*UnsafeFenceIndex) Add

func (u *UnsafeFenceIndex) Add(name string, feature *geo.Feature) (err error)

func (*UnsafeFenceIndex) Get

func (u *UnsafeFenceIndex) Get(name string) (fence GeoFence)

func (*UnsafeFenceIndex) Keys

func (u *UnsafeFenceIndex) Keys() (keys []string)

func (*UnsafeFenceIndex) Search

func (u *UnsafeFenceIndex) Search(name string, c geo.Coordinate) (matchs []*geo.Feature, err error)

func (*UnsafeFenceIndex) Set

func (u *UnsafeFenceIndex) Set(name string, fence GeoFence)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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