Documentation
¶
Index ¶
- Constants
- func GetHash(lat, lng float64) (string, error)
- func Haversine(a, b *Location) float64
- func IsCoordinateValid(lat, lng float64) bool
- func IsNearPolyline(point *Location, polyline []*Location, threshold float64) bool
- func MergeHashes(hashes []string, minMergedCnt int) []string
- func PointToSegmentDistance(point, start, end *Location) float64
- func RadiusSearch(lat, lng, radius, tolerance float64, f PrecisionDynamicFunc) []string
- type Direction
- type GeoTrieRoot
- type Location
- type Precision
- type PrecisionDynamicFunc
Constants ¶
const ( DirectionBaseAngle float64 = 45 DirectionSplitAngle float64 = 22.5 )
const EarthRadius = 6371008.7714
Variables ¶
This section is empty.
Functions ¶
func IsCoordinateValid ¶
func IsNearPolyline ¶
IsNearPolyline
Is point near the line ¶
Param:
point: the location of point polyline: the list of point of line threshold: distance(meter)
func MergeHashes ¶
func PointToSegmentDistance ¶
PointToSegmentDistance
The distance from point to line ¶
Param:
point: the location of point start: the start location of line end: the end location of line
func RadiusSearch ¶
func RadiusSearch(lat, lng, radius, tolerance float64, f PrecisionDynamicFunc) []string
RadiusSearch Get geohashes by coordinate and radius
Params:
lat: latitude lng: longitude radius: radius(meter) tolerance: the tolerance to check is rectangle is intersected with circle, (0, 1.0] f: the custom function to get start and maximum precision by radius
Types ¶
type GeoTrieRoot ¶
type GeoTrieRoot struct {
// contains filtered or unexported fields
}
func NewGeoTrie ¶
func NewGeoTrie() *GeoTrieRoot
func (*GeoTrieRoot) AllLeaf ¶
func (t *GeoTrieRoot) AllLeaf() []string
func (*GeoTrieRoot) Has ¶
func (t *GeoTrieRoot) Has(key string) bool
func (*GeoTrieRoot) Insert ¶
func (t *GeoTrieRoot) Insert(key string) bool
type Location ¶
func GetPointAtDistance ¶
GetPointAtDistance
Calculates the destination coordinates given a starting point, distance (radius), and bearing (direction) ¶
Param:
point: point location radius: the distance to travel from the center, in meters angle: the direction of travel in degrees (0 = North, 90 = East, 180 = South, 270 = West)
type Precision ¶
type Precision uint
func GetPrecisionDynamic ¶
GetPrecisionDynamic
get the start precision and maximum precision, this is only a preset configuration, you could replace it with your function