Documentation
¶
Overview ¶
Package geo provides geo-spatial indexing and search capabilities for cortexdb
Index ¶
- Constants
- type BoundingBox
- type Coordinate
- type DistanceUnit
- type GeoIndex
- func (g *GeoIndex) Clear()
- func (g *GeoIndex) Delete(id string) bool
- func (g *GeoIndex) GetPoint(id string) (*GeoPoint, bool)
- func (g *GeoIndex) Insert(point GeoPoint) error
- func (g *GeoIndex) SearchBoundingBox(bbox BoundingBox) ([]GeoPoint, error)
- func (g *GeoIndex) SearchKNN(center Coordinate, k int) ([]GeoSearchResult, error)
- func (g *GeoIndex) SearchPolygon(polygon []Coordinate) ([]GeoPoint, error)
- func (g *GeoIndex) SearchRadius(center Coordinate, radius float64, unit DistanceUnit) ([]GeoSearchResult, error)
- func (g *GeoIndex) Size() int
- type GeoPoint
- type GeoSearchResult
Constants ¶
const ( // EarthRadiusKM is the Earth's radius in kilometers EarthRadiusKM = 6371.0 // EarthRadiusMiles is the Earth's radius in miles EarthRadiusMiles = 3959.0 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BoundingBox ¶
type BoundingBox struct {
MinLat float64 `json:"min_lat"`
MaxLat float64 `json:"max_lat"`
MinLng float64 `json:"min_lng"`
MaxLng float64 `json:"max_lng"`
}
BoundingBox represents a rectangular geographic area
type Coordinate ¶
Coordinate represents a geographic coordinate
type DistanceUnit ¶
type DistanceUnit string
DistanceUnit represents the unit for distance calculations
const ( Kilometers DistanceUnit = "km" Miles DistanceUnit = "miles" Meters DistanceUnit = "meters" )
type GeoIndex ¶
type GeoIndex struct {
// contains filtered or unexported fields
}
GeoIndex provides geo-spatial indexing and search
func (*GeoIndex) SearchBoundingBox ¶
func (g *GeoIndex) SearchBoundingBox(bbox BoundingBox) ([]GeoPoint, error)
SearchBoundingBox finds all points within a bounding box
func (*GeoIndex) SearchKNN ¶
func (g *GeoIndex) SearchKNN(center Coordinate, k int) ([]GeoSearchResult, error)
SearchKNN finds the k nearest neighbors to a point
func (*GeoIndex) SearchPolygon ¶
func (g *GeoIndex) SearchPolygon(polygon []Coordinate) ([]GeoPoint, error)
SearchPolygon finds all points within a polygon (simplified for convex polygons)
func (*GeoIndex) SearchRadius ¶
func (g *GeoIndex) SearchRadius(center Coordinate, radius float64, unit DistanceUnit) ([]GeoSearchResult, error)
SearchRadius finds all points within a given radius from a center point
type GeoPoint ¶
type GeoPoint struct {
ID string `json:"id"`
Coordinate Coordinate `json:"coordinate"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
}
GeoPoint represents a point with ID and coordinates
type GeoSearchResult ¶
GeoSearchResult represents a search result with distance