Documentation ¶
Index ¶
- Constants
- Variables
- func BoundingBoxContains(lon, lat, minLon, minLat, maxLon, maxLat float64) bool
- func BoundingRectangleForPolygon(polygon []Point) (float64, float64, float64, float64, error)
- func DecodeGeoHash(geoHash string) (float64, float64)
- func DegreesToRadians(d float64) float64
- func EncodeGeoHash(lat, lon float64) string
- func ExtractCircle(thing interface{}) ([]float64, string, bool)
- func ExtractGeoPoint(thing interface{}) (lon, lat float64, success bool)
- func ExtractGeoShapeCoordinates(coordValue interface{}, typ string) ([][][][]float64, string, bool)
- func ExtractGeometryCollection(thing interface{}) ([][][][][]float64, []string, bool)
- func GetSpatialAnalyzerPlugin(typ string) index.SpatialAnalyzerPlugin
- 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 NewBoundedPolygon(coordinates []Point) *boundedPolygon
- func NewBoundedRectangle(minLat, minLon, maxLat, maxLon float64) *boundedRectangle
- func NewGeoCircle(points []float64, radius string) index.GeoJSON
- func NewGeoCircleShape(cp []float64, radius string) (index.GeoJSON, []byte, error)
- func NewGeoEnvelope(points [][]float64) index.GeoJSON
- func NewGeoJsonLinestring(points [][]float64) index.GeoJSON
- func NewGeoJsonMultiPoint(points [][]float64) index.GeoJSON
- func NewGeoJsonMultiPolygon(points [][][][]float64) index.GeoJSON
- func NewGeoJsonMultilinestring(points [][][]float64) index.GeoJSON
- func NewGeoJsonPoint(points []float64) index.GeoJSON
- func NewGeoJsonPolygon(points [][][]float64) index.GeoJSON
- func NewGeoJsonShape(coordinates [][][][]float64, typ string) (index.GeoJSON, []byte, error)
- func NewGeometryCollection(coordinates [][][][][]float64, typs []string) (index.GeoJSON, []byte, error)
- func NewPointDistance(centerLat, centerLon, dist float64) *pointDistance
- func ParseDistance(d string) (float64, error)
- func ParseDistanceUnit(u string) (float64, error)
- func ParseGeoJSONShape(input json.RawMessage) (index.GeoJSON, error)
- func ParseGeoShapeField(thing interface{}) (interface{}, string, 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
- func RegisterSpatialAnalyzerPlugin(plugin index.SpatialAnalyzerPlugin)
- type Point
- func (p *Point) Contains(s index.GeoJSON) (bool, error)
- func (p *Point) IndexTokens(s *S2SpatialAnalyzerPlugin) []string
- func (p *Point) Intersects(s index.GeoJSON) (bool, error)
- func (p *Point) QueryTokens(s *S2SpatialAnalyzerPlugin) []string
- func (p *Point) Type() string
- func (p *Point) Value() ([]byte, error)
- type S2SpatialAnalyzerPlugin
Constants ¶
const ( PointType = "point" MultiPointType = "multipoint" LineStringType = "linestring" MultiLineStringType = "multilinestring" PolygonType = "polygon" MultiPolygonType = "multipolygon" GeometryCollectionType = "geometrycollection" CircleType = "circle" EnvelopeType = "envelope" )
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
var GlueBytes = []byte("##")
GlueBytes primarily for quicker filtering of docvalues during the filtering phase.
var GlueBytesOffset = len(GlueBytes)
Functions ¶
func BoundingBoxContains ¶
BoundingBoxContains checks whether the lon/lat point is within the box
func DecodeGeoHash ¶
DecodeGeoHash decodes the string geohash faster with higher precision. This api is in experimental phase.
func DegreesToRadians ¶
DegreesToRadians converts an angle in degrees to radians
func EncodeGeoHash ¶
func ExtractCircle ¶
ExtractCircle takes an interface{} and tries it's best to interpret the center point coordinates and the radius for a given circle shape.
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
string (coordinates separated by comma, or a geohash)
first element lat, second element lon
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 ExtractGeoShapeCoordinates ¶
ExtractGeoShapeCoordinates takes an interface{} and tries it's best to interpret the coordinates for any of the given geoshape typ like a point, multipoint, linestring, multilinestring, polygon, multipolygon,
func ExtractGeometryCollection ¶
ExtractGeometryCollection takes an interface{} and tries it's best to interpret all the member geojson shapes within it.
func GetSpatialAnalyzerPlugin ¶
func GetSpatialAnalyzerPlugin(typ string) index.SpatialAnalyzerPlugin
GetSpatialAnalyzerPlugin retrieves the given implementation type.
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 NewBoundedPolygon ¶
func NewBoundedPolygon(coordinates []Point) *boundedPolygon
func NewBoundedRectangle ¶
func NewBoundedRectangle(minLat, minLon, maxLat, maxLon float64) *boundedRectangle
func NewGeoCircleShape ¶
NewGeoCircleShape instantiate a circle shape and prefix the byte contents with certain glue bytes that can be used later while filering the doc values.
func NewGeoEnvelope ¶
func NewGeoJsonLinestring ¶
func NewGeoJsonMultiPoint ¶
func NewGeoJsonMultiPolygon ¶
func NewGeoJsonPoint ¶
func NewGeoJsonPolygon ¶
func NewGeoJsonShape ¶
func NewGeometryCollection ¶
func NewGeometryCollection(coordinates [][][][][]float64, typs []string) (index.GeoJSON, []byte, error)
NewGeometryCollection instantiate a geometrycollection and prefix the byte contents with certain glue bytes that can be used later while filering the doc values.
func NewPointDistance ¶
func NewPointDistance(centerLat, centerLon, dist float64) *pointDistance
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 ParseGeoJSONShape ¶
func ParseGeoJSONShape(input json.RawMessage) (index.GeoJSON, error)
func ParseGeoShapeField ¶
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
func RegisterSpatialAnalyzerPlugin ¶
func RegisterSpatialAnalyzerPlugin(plugin index.SpatialAnalyzerPlugin)
RegisterSpatialAnalyzerPlugin registers the given plugin implementation.
Types ¶
type Point ¶
Point represents a geo point.
func (*Point) IndexTokens ¶
func (p *Point) IndexTokens(s *S2SpatialAnalyzerPlugin) []string
func (*Point) QueryTokens ¶
func (p *Point) QueryTokens(s *S2SpatialAnalyzerPlugin) []string
type S2SpatialAnalyzerPlugin ¶
type S2SpatialAnalyzerPlugin struct {
// contains filtered or unexported fields
}
S2SpatialAnalyzerPlugin is an implementation of the index.SpatialAnalyzerPlugin interface.
func (*S2SpatialAnalyzerPlugin) GetIndexTokens ¶
func (s *S2SpatialAnalyzerPlugin) GetIndexTokens(queryShape index.GeoJSON) []string
func (*S2SpatialAnalyzerPlugin) GetQueryTokens ¶
func (s *S2SpatialAnalyzerPlugin) GetQueryTokens(queryShape index.GeoJSON) []string
func (*S2SpatialAnalyzerPlugin) Type ¶
func (s *S2SpatialAnalyzerPlugin) Type() string