bleve: Index | Files

package geo

import ""


Package Files

geo.go geo_dist.go geohash.go parse.go sloppy.go


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

func BoundingBoxContains Uses

func BoundingBoxContains(lon, lat, minLon, minLat, maxLon, maxLat float64) bool

BoundingBoxContains checks whether the lon/lat point is within the box

func DegreesToRadians Uses

func DegreesToRadians(d float64) float64

DegreesToRadians converts an angle in degrees to radians

func ExtractGeoPoint Uses

func ExtractGeoPoint(thing interface{}) (lon, lat float64, success bool)

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

string (coordinates separated by comma, or a geohash)

first element lat, second element lon


exact keys lat and lon or lng


w/exported fields case-insensitive match on lat and lon or lng


satisfying Later and Loner or Lnger interfaces

in all cases values must be some sort of numeric-like thing: int/uint/float

func GeoHashDecode Uses

func GeoHashDecode(hash string) (lat, lng float64)

Decode the string geohash to a (lat, lng) point.

func Haversin Uses

func Haversin(lon1, lat1, lon2, lat2 float64) float64

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 Uses

func MortonHash(lon, lat float64) uint64

MortonHash computes the morton hash value for the provided geo point This point is ordered as lon, lat.

func MortonUnhashLat Uses

func MortonUnhashLat(hash uint64) float64

MortonUnhashLat extracts the latitude value from the provided morton hash.

func MortonUnhashLon Uses

func MortonUnhashLon(hash uint64) float64

MortonUnhashLon extracts the longitude value from the provided morton hash.

func ParseDistance Uses

func ParseDistance(d string) (float64, error)

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 Uses

func ParseDistanceUnit(u string) (float64, error)

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 Uses

func RadiansToDegrees(r float64) float64

RadiansToDegrees converts an angle in radians to degress

func RectFromPointDistance Uses

func RectFromPointDistance(lon, lat, dist float64) (float64, float64, float64, float64, error)

func RectIntersects Uses

func RectIntersects(aMinX, aMinY, aMaxX, aMaxY, bMinX, bMinY, bMaxX, bMaxY float64) bool

RectIntersects checks whether rectangles a and b intersect

func RectWithin Uses

func RectWithin(aMinX, aMinY, aMaxX, aMaxY, bMinX, bMinY, bMaxX, bMaxY float64) bool

RectWithin checks whether box a is within box b

Package geo imports 6 packages (graph) and is imported by 54 packages. Updated 2018-11-15. Refresh now. Tools for package owners.