polygon

package
v0.0.0-...-623ea98 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const EarthRadiusKm = 6371.0 // Earth's radius in kilometers

Constants

Variables

This section is empty.

Functions

func GenerateAllTilesForRadius

func GenerateAllTilesForRadius(tileRadius float64, nbFaces int) map[Quadkey]Polygon

GenerateAllTilesForRadius generates all tiles and their polygons for a given radius.

func IsPointInPolygon

func IsPointInPolygon(point Point, polygon []Point) bool

IsPointInPolygon checks if a given point (latitude, longitude) is inside a polygon

func LatLonToTileXY

func LatLonToTileXY(lat, lon float64, zoom int) (int, int)

LatLonToTileXY converts lat/lon to tile coordinates.

func TileXYToLatLon

func TileXYToLatLon(x, y, zoom int) (float64, float64)

TileXYToLatLon converts tile coordinates to lat/lon.

Types

type Coordinate

type Coordinate struct {
	C float64 // Coordinate value in degrees
}

Coordinate represents a geographic coordinate value

func (Coordinate) ToDegrees

func (c Coordinate) ToDegrees() float64

ToDegrees converts the Coordinate object from radians to degrees

func (Coordinate) ToRadians

func (c Coordinate) ToRadians() float64

ToRadians converts the Coordinate object from degrees to radians

type Edge

type Edge struct {
	Start Point
	End   Point
}

type Edge3D

type Edge3D struct {
	Start Point3D
	End   Point3D
}

Edge3D represents an edge in 3D space.

type LatLong

type LatLong struct {
	Lat Coordinate // Latitude in degrees
	Lon Coordinate // Longitude in degrees
}

LatLong represents a geographic coordinate pair in WGS84 format

func (LatLong) LatDegrees

func (ll LatLong) LatDegrees() float64

LatDegrees returns the latitude in degrees

func (LatLong) LatRadians

func (ll LatLong) LatRadians() float64

LatRadians returns the latitude in radians

func (LatLong) LonDegrees

func (ll LatLong) LonDegrees() float64

LonDegrees returns the longitude in degrees

func (LatLong) LonRadians

func (ll LatLong) LonRadians() float64

LonRadians returns the longitude in radians

func (LatLong) ToDegrees

func (ll LatLong) ToDegrees() LatLong

ToDegrees converts both latitude and longitude to degrees

func (LatLong) ToRadians

func (ll LatLong) ToRadians() LatLong

ToRadians converts both latitude and longitude to radians

type Point

type Point struct {
	Latitude  float64 // Latitude (Y-axis)
	Longitude float64 // Longitude (X-axis)
}

type Point3D

type Point3D struct {
	Latitude  float64
	Longitude float64
	Altitude  float64
}

Point3D represents a point in 3D space.

type Polygon

type Polygon struct {
	Center     Quadkey // The center Quadkey of the polygon
	NbFaces    int     // Number of faces in the polygon
	Radius     float64 // Radius of the polygon in meters
	Boundaries []Point // Vertices (points) of the polygon's boundary
}

Polygon represents a geographic polygon.

func NewPolygon

func NewPolygon(nbFaces int, center LatLong, level int, radius float64) Polygon

NewPolygon creates a new Polygon given the number of faces, center coordinates, zoom level, and radius.

type Quadkey

type Quadkey struct {
	Latitude  float64
	Longitude float64
	Level     int
}

func NewQuadkey

func NewQuadkey(lat float64, long float64, level int) Quadkey

func (*Quadkey) DistanceTo

func (q *Quadkey) DistanceTo(other Point) float64

DistanceTo computes the great-circle distance between two Quadkeys using the haversine formula

func (*Quadkey) Key

func (q *Quadkey) Key() string

Jump to

Keyboard shortcuts

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