Documentation ¶
Overview ¶
Service location stores the user location and provides automatic checkins and geocoding.
Index ¶
- Constants
- Variables
- func EncodeGeohash(latitude, longitude float64, precision int) string
- func HaversineDistance(p1, p2 Location) float64
- type BoundingBox
- type BoundingBoxSlice
- type Cluster
- type ClusterGenerator
- type ClusterStatus
- type Dependencies
- type GeoAddress
- type GeoName
- type GeoPlace
- type Geofence
- type GeofenceEventPayload
- type Location
- type Service
Constants ¶
View Source
const API_URL = "https://nominatim.openstreetmap.org"
Variables ¶
View Source
var ( ErrWrongNumberOfCols = errors.New("Number of fields and columns differs") ErrNoTimestamp = errors.New("No time found") ErrNoLatLng = errors.New("No latitude or longitude found") )
View Source
var Module = &services.Module{ Name: "location", Version: "1.0", NewInstance: NewService, }
View Source
var MsgAddressNotFound = sarif.Message{
Action: "err/location/address/notfound",
Text: "Requested address could not be found",
}
View Source
var MsgNotFound = sarif.Message{
Action: "err/location/notfound",
Text: "No matching location found.",
}
Functions ¶
func EncodeGeohash ¶
func HaversineDistance ¶
Types ¶
type BoundingBox ¶
type BoundingBox struct { LatMin float64 `json:"lat_min"` LatMax float64 `json:"lat_max"` LngMin float64 `json:"lng_min"` LngMax float64 `json:"lng_max"` }
func DecodeGeohash ¶
func DecodeGeohash(geohash string) *BoundingBox
func (*BoundingBox) Contains ¶
func (b *BoundingBox) Contains(loc Location) bool
func (*BoundingBox) GetBounds ¶
func (g *BoundingBox) GetBounds() []float64
func (*BoundingBox) SetBounds ¶
func (g *BoundingBox) SetBounds(b []float64)
type BoundingBoxSlice ¶
type BoundingBoxSlice BoundingBox
func (*BoundingBoxSlice) UnmarshalJSON ¶
func (b *BoundingBoxSlice) UnmarshalJSON(j []byte) (err error)
type Cluster ¶
type Cluster struct { Location Status ClusterStatus `json:"status"` Start Location `json:"start,omitempty"` End Location `json:"end,omitempty"` }
type ClusterGenerator ¶
type ClusterGenerator struct { MinInterval time.Duration MaxDistance float64 // contains filtered or unexported fields }
func NewClusterGenerator ¶
func NewClusterGenerator() *ClusterGenerator
func (*ClusterGenerator) Advance ¶
func (g *ClusterGenerator) Advance(l Location) bool
func (*ClusterGenerator) ClearCompleted ¶
func (g *ClusterGenerator) ClearCompleted()
func (*ClusterGenerator) Completed ¶
func (g *ClusterGenerator) Completed() []Cluster
func (*ClusterGenerator) Current ¶
func (g *ClusterGenerator) Current() Cluster
func (*ClusterGenerator) LastCompleted ¶
func (g *ClusterGenerator) LastCompleted() Cluster
type ClusterStatus ¶
type ClusterStatus int
const ( UnconfirmedCluster ClusterStatus = iota ConfirmedCluster CompletedCluster )
type Dependencies ¶
type GeoAddress ¶
type GeoAddress struct { HouseNumber string `json:"house_number"` Building string `json:"building"` Road string `json:"road"` Residential string `json:"residential"` Suburb string `json:"suburb"` Village string `json:"village"` Town string `json:"town"` CityDistrict string `json:"city_district"` City string `json:"city"` County string `json:"county"` PostCode string `json:"postcode"` State string `json:"state"` Country string `json:"country"` CountryCode string `json:"country_code"` Continent string `json:"continent"` }
type GeoPlace ¶
type GeoPlace struct { BoundingBox BoundingBoxSlice `json:"boundingbox,[]string"` Latitude float64 `json:"lat,string"` Longitude float64 `json:"lon,string"` Name string `json:"display_name"` Class string `json:"class"` Type string `json:"type"` Address GeoAddress `json:"address"` NameDetails GeoName `json:"namedetails,omitempty"` }
func ReverseGeocode ¶
type Geofence ¶
type Geofence struct { BoundingBox Name string `json:"name,omitempty"` Address string `json:"address,omitempty"` GeohashMin string `json:"geohash_min,omitempty"` GeohashMax string `json:"geohash_max,omitempty"` }
type GeofenceEventPayload ¶
type GeofenceEventPayload struct { Location Location `json:"loc"` Fence Geofence `json:"fence"` Status string `json:"status"` }
func (GeofenceEventPayload) String ¶
func (m GeofenceEventPayload) String() string
type Location ¶
type Location struct { Time time.Time `json:"time,omitempty"` Latitude float64 `json:"latitude"` Longitude float64 `json:"longitude"` Geohash string `json:"geohash,omitempty"` Accuracy float64 `json:"accuracy"` Source string `json:"source,omitempty"` Address string `json:"address,omitempty"` Distance float64 `json:"distance,omitempty"` Speed float64 `json:"speed,omitempty"` }
type Service ¶
type Service struct { sarif.Client Store *store.Store Clusters *ClusterGenerator }
func NewService ¶
func NewService(deps *Dependencies) *Service
Click to show internal directories.
Click to hide internal directories.