Documentation ¶
Index ¶
- Variables
- func BoundingBoxContains(lon, lat, minLon, minLat, maxLon, maxLat float64) bool
- func DegreesToRadians(d float64) float64
- func ExtractGeoPoint(thing interface{}) (lon, lat float64, success bool)
- func Haversin(lon1, lat1, lon2, lat2 float64) float64
- func MortonHash(lon, lat float64) uint64
- func MortonUnhashLat(hash uint64) float64
- func MortonUnhashLon(hash uint64) float64
- func ParseDistance(d string) (float64, error)
- func ParseDistanceUnit(u string) (float64, error)
- func RadiansToDegrees(r float64) float64
- func RectFromPointDistance(lon, lat, dist float64) (float64, float64, float64, float64, error)
- func RectIntersects(aMinX, aMinY, aMaxX, aMaxY, bMinX, bMinY, bMaxX, bMaxY float64) bool
- func RectWithin(aMinX, aMinY, aMaxX, aMaxY, bMinX, bMinY, bMaxX, bMaxY float64) bool
Constants ¶
This section is empty.
Variables ¶
var GeoBits uint = 32
GeoBits is the number of bits used for a single geo point Currently this is 32bits for lon and 32bits for lat
Functions ¶
func BoundingBoxContains ¶
BoundingBoxContains checks whether the lon/lat point is within the box
func DegreesToRadians ¶
DegreesToRadians converts an angle in degrees to radians
func ExtractGeoPoint ¶
ExtractGeoPoint takes an arbitrary interface{} and tries it's best to interpret it is as geo point. Supported formats: Container: slice length 2 (GeoJSON)
first element lon, second element lat
map[string]interface{}
exact keys lat and lon or lng
struct
w/exported fields case-insensitive match on lat and lon or lng
struct
satisfying Later and Loner or Lnger interfaces
in all cases values must be some sort of numeric-like thing: int/uint/float
func Haversin ¶
Haversin computes the distance between two points. This implemenation uses the sloppy math implemenations which trade off accuracy for performance. The distance returned is in kilometers.
func MortonHash ¶
MortonHash computes the morton hash value for the provided geo point This point is ordered as lon, lat.
func MortonUnhashLat ¶
MortonUnhashLat extracts the latitude value from the provided morton hash.
func MortonUnhashLon ¶
MortonUnhashLon extracts the longitude value from the provided morton hash.
func ParseDistance ¶
ParseDistance attempts to parse a distance string and return distance in meters. Example formats supported: "5in" "5inch" "7yd" "7yards" "9ft" "9feet" "11km" "11kilometers" "3nm" "3nauticalmiles" "13mm" "13millimeters" "15cm" "15centimeters" "17mi" "17miles" "19m" "19meters" If the unit cannot be determined, the entire string is parsed and the unit of meters is assumed. If the number portion cannot be parsed, 0 and the parse error are returned.
func ParseDistanceUnit ¶
ParseDistanceUnit attempts to parse a distance unit and return the multiplier for converting this to meters. If the unit cannot be parsed then 0 and the error message is returned.
func RadiansToDegrees ¶
RadiansToDegrees converts an angle in radians to degress
func RectFromPointDistance ¶
func RectIntersects ¶
RectIntersects checks whether rectangles a and b intersect
func RectWithin ¶
RectWithin checks whether box a is within box b
Types ¶
This section is empty.