geo

package
v0.0.0-...-26b209a Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2022 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// According to Wikipedia, the Earth's radius is about 6,371km
	EARTH_RADIUS = 6371
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Circle

type Circle struct {
	Type        string
	Radius      float64
	Coordinates []float64
}

func (*Circle) CircleBound

func (c *Circle) CircleBound() (LatLng, float64)

func (*Circle) Contains

func (c *Circle) Contains(latlng LatLng) bool

type Feature

type Feature struct {
	Type       string
	Geometry   Geometry
	Properties *Properties
}

type Geometry

type Geometry interface {
	Contains(latlng LatLng) bool

	CircleBound() (LatLng, float64)
}

Geometry is a geometric shape that can be used to verify whether Geo point is contained in there or not.

type LatLng

type LatLng struct {
	Lat float64
	Lng float64
}

func (*LatLng) GreatCircleDistance

func (p *LatLng) GreatCircleDistance(p2 *LatLng) float64

GreatCircleDistance: Calculates the Haversine distance between two points in kilometers. Original Implementation from: http://www.movable-type.co.uk/scripts/latlong.html

type Point

type Point struct {
	Type        string
	Coordinates []float64
}

func (*Point) CircleBound

func (p *Point) CircleBound() (LatLng, float64)

func (*Point) Contains

func (p *Point) Contains(latlng LatLng) bool

type Polygon

type Polygon struct {
	Type string
	// contains filtered or unexported fields
}

Polygon is representing a polygon line structure.

func NewPolygon

func NewPolygon(coordinates [][][]float64) *Polygon

NewPolygon creates a new polygon for the provided coordinates.

func (*Polygon) CircleBound

func (p *Polygon) CircleBound() (LatLng, float64)

func (*Polygon) Contains

func (p *Polygon) Contains(latlng LatLng) bool

Contains checks whether the LatLng is contained in the polygon. It returns true if the LatLng is contained in the polygon and false otherwise.

type Properties

type Properties struct {
	Name string
}

type Rectangle

type Rectangle struct {
	Type        string
	Coordinates [][]float64
}

func (*Rectangle) CircleBound

func (r *Rectangle) CircleBound() (LatLng, float64)

func (*Rectangle) Contains

func (r *Rectangle) Contains(latlng LatLng) bool

Jump to

Keyboard shortcuts

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