geo

package
v0.0.0-...-0b1034d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 6, 2017 License: Apache-2.0 Imports: 6 Imported by: 0

README

geo support in bleve

First, all of this geo code is a Go adaptation of the Lucene 5.3.2 sandbox geo support.

Notes

  • All of the APIs will use float64 for lon/lat values.
  • When describing a point in function arguments or return values, we always use the order lon, lat.
  • High level APIs will use TopLeft and BottomRight to describe bounding boxes. This may not map cleanly to min/max lon/lat when crossing the dateline. The lower level APIs will use min/max lon/lat and require the higher-level code to split boxes accordingly.

Documentation

Index

Constants

This section is empty.

Variables

View Source
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

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

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

func ComputeBoundingBox

func ComputeBoundingBox(centerLon, centerLat,
	radius float64) (upperLeftLon float64, upperLeftLat float64,
	lowerRightLon float64, lowerRightLat float64)

ComputeBoundingBox will compute a bounding box around the provided point which surrounds a circle of the provided radius (in meters).

func DegreesToRadians

func DegreesToRadians(d float64) float64

DegreesToRadians converts an angle in degrees to radians

func ExtractGeoPoint

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

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

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

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

func MortonUnhashLat(hash uint64) float64

MortonUnhashLat extracts the latitude value from the provided morton hash.

func MortonUnhashLon

func MortonUnhashLon(hash uint64) float64

MortonUnhashLon extracts the longitude value from the provided morton hash.

func ParseDistance

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

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

func RadiansToDegrees(r float64) float64

RadiansToDegrees converts an angle in radians to degress

func RectIntersects

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

RectIntersects checks whether rectangles a and b intersect

func RectWithin

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

RectWithin checks whether box a is within box b

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL