Documentation ¶
Overview ¶
Package geocollection provides a data structure for storing and quickly searching for items based on geographic coordinates on Earth.
Index ¶
- Constants
- func EarthDistanceMeters(p1, p2 s2.Point) float64
- func NewPointFromLatLng(latitude, longitude float64) s2.Point
- type Collection
- func (c Collection) Delete(key interface{})
- func (c Collection) GetItems(pageSize, startIndex int) []interface{}
- func (c Collection) ItemByKey(key interface{}) interface{}
- func (c Collection) ItemsWithinDistance(latitude, longitude, distanceMeters float64, params SearchCoveringParameters) ([]interface{}, SearchCoveringResult)
- func (c Collection) Set(key, contents interface{}, latitude, longitude float64)
- type LocationCollection
- type SearchCoveringParameters
- type SearchCoveringResult
Constants ¶
const EarthRadiusMeters = 6371008.8
EarthRadiusMeters is an approximate representation of the earth's radius in meters.
Variables ¶
This section is empty.
Functions ¶
func EarthDistanceMeters ¶
EarthDistanceMeters calculates the distance in meters between two points on the surface of the Earth
func NewPointFromLatLng ¶
NewPointFromLatLng constructs an s2 point from a lat/lon ordered pair
Types ¶
type Collection ¶ added in v0.2.0
type Collection struct {
// contains filtered or unexported fields
}
Collection implements the GeoLocationCollection interface and provides a location based cache
func NewCollection ¶ added in v0.2.0
func NewCollection() Collection
NewCollection creates a new collection
func (Collection) Delete ¶ added in v0.2.0
func (c Collection) Delete(key interface{})
Delete removes an item by its key from the collection.
func (Collection) GetItems ¶ added in v0.7.0
func (c Collection) GetItems(pageSize, startIndex int) []interface{}
GetItems get the items form the collection based on arg pageSize, startIndex
func (Collection) ItemByKey ¶ added in v0.3.0
func (c Collection) ItemByKey(key interface{}) interface{}
ItemByKey returns the contents stored in the collection by its key instead of by a geolocation lookup
func (Collection) ItemsWithinDistance ¶ added in v0.2.0
func (c Collection) ItemsWithinDistance( latitude, longitude, distanceMeters float64, params SearchCoveringParameters, ) ([]interface{}, SearchCoveringResult)
ItemsWithinDistance returns all contents stored in the collection within distanceMeters radius from the provided latitude an longitude. Note that this is an approximation and items further than distanceMeters may be returned, but it is guaranteed that all item ids returned are within distanceMeters. The caller of this function must specify all parameters used to generate cell covering as well as whether or not the coverer will use the standard covering algorithm or the fast covering algorithm which may be less precise.
func (Collection) Set ¶ added in v0.2.0
func (c Collection) Set(key, contents interface{}, latitude, longitude float64)
Set adds an item with a given key to the geo collection at a particular latitude and longitude. If the given key already exists in the collection, it is created, otherwise the contents and location is updated to the new values.
type LocationCollection ¶ added in v0.2.0
type LocationCollection interface { Set(key, contents interface{}, latitude, longitude float64) Delete(key interface{}) ItemsWithinDistance(latitude, longitude, distanceMeters float64, params SearchCoveringParameters) ([]interface{}, SearchCoveringResult) ItemByKey(key interface{}) interface{} GetItems(pageSize, startIndex int) []interface{} }
LocationCollection defines the interface for interacting with Geo-based collections
type SearchCoveringParameters ¶
type SearchCoveringParameters struct { LevelMod int `json:"level_mod"` MaxCells int `json:"max_cells"` MaxLevel int `json:"max_level"` MinLevel int `json:"min_level"` UseFastCovering bool `json:"use_fast_covering"` }
SearchCoveringParameters controls the algorithm and parameters used by S2 to determine the covering for the requested search area
type SearchCoveringResult ¶
type SearchCoveringResult [][][]float64
SearchCoveringResult are the boundaries of the cells used in the requested search