-
Notifications
You must be signed in to change notification settings - Fork 16
/
geofence.go
46 lines (35 loc) · 1.25 KB
/
geofence.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package regionagogo
import (
"github.com/akhenakh/regionagogo/geostore"
"github.com/golang/geo/s2"
)
var (
defaultCoverer = &s2.RegionCoverer{MinLevel: 1, MaxLevel: 24, MaxCells: 32}
)
// GeoFenceDB is the main interface to store and query your geo database
type GeoFenceDB interface {
// returns a Fence by it's storage id
FenceByID(loopID uint64) *Fence
// returns the fence for the corresponding lat, lng coordinates
StubbingQuery(lat, lng float64, opts ...QueryOptionsFunc) (Fences, error)
// RectQuery perform rectangular query ur upper right bl bottom left
RectQuery(urlat, urlng, bllat, bllng float64, opts ...QueryOptionsFunc) (Fences, error)
// RadiusQuery is performing a radius query
RadiusQuery(lat, lng, radius float64, opts ...QueryOptionsFunc) (Fences, error)
// Store a Fence into the DB
StoreFence(rs *geostore.FenceStorage, cover []uint64) error
// Close the DB
Close() error
}
type QueryOptionsFunc func(*QueryOptions)
// queryOptions used to pass options to DB queries
type QueryOptions struct {
// Returns all fences when multiple fences match
MultipleFences bool
}
// WithMultipleFences enable multi fences in responses
func WithMultipleFences(mf bool) QueryOptionsFunc {
return func(o *QueryOptions) {
o.MultipleFences = mf
}
}