geo

package
v0.0.0-...-61ccda9 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2022 License: AGPL-3.0 Imports: 4 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LegalCoord

func LegalCoord(lat, long float64) bool

LegalCoord returns true if the given coordinates are legal. lat=-90 and lon=-180 are permitted because they're useful in search rectangles.

func Overlaps

func Overlaps(a, b *Rectangle) bool

Overlaps checks if rectangle 'a' and 'b' are overlapping. Returns true for rectangles that just touch (==).

Types

type Point

type Point struct {
	Lat  float64 //latitude, eg. 29.260799° N
	Long float64 //longitude, eg. 94.87287° W
}

Point is a set of <latitude, longitude> coordinates.

func (Point) DistanceTo

func (a Point) DistanceTo(b Point) float64

DistanceTo returns the point's distance to another point.

func (Point) MarshalJSON

func (p Point) MarshalJSON() ([]byte, error)

MarshalJSON returns the GeoJSON representation of the coordinates.

func (*Point) UnmarshalJSON

func (p *Point) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the JSON-data in b to a Point-object.

type Rectangle

type Rectangle struct {
	// contains filtered or unexported fields
}

Rectangle consists of two <lat,long> Points. "max" contains the point with the highest latitude and the hightest longitude "min" contains the point with the lowest latitude and the lowest longitude

func NewRectangle

func NewRectangle(minLat, minLong, maxLat, maxLong float64) (*Rectangle, error)

NewRectangle returns a pointer to a new Rectangle.

func SplitViewRect

func SplitViewRect(minLat, minLong, maxLat, maxLong float64) []Rectangle

SplitViewRect maps any rectangular view of the earth to a set of non-overlapping, valid rectangles. More than one rectangle is needed if the view crosses the date line or a pole. (the latter is'nt supported yet)

func (*Rectangle) Area

func (a *Rectangle) Area() float64

Area returns the area of the rectangle.

func (*Rectangle) AreaDifference

func (a *Rectangle) AreaDifference(b *Rectangle) float64

AreaDifference returns the difference in area between two rectangles.

func (*Rectangle) Center

func (a *Rectangle) Center() Point

Center returns the center point of the Rectangle.

func (*Rectangle) ContainsPoint

func (a *Rectangle) ContainsPoint(p Point) bool

ContainsPoint checks if the Rectangle contains a given point.

func (*Rectangle) ContainsRectangle

func (a *Rectangle) ContainsRectangle(b *Rectangle) bool

ContainsRectangle checks if the Rectangle contains a given other Rectangle.

func (*Rectangle) MBRWith

func (a *Rectangle) MBRWith(r *Rectangle) *Rectangle

MBRWith returns the minimum bounding rectangle which contains both of the rectangles.

func (*Rectangle) Margin

func (a *Rectangle) Margin() float64

Margin returns the margin of the rectangle.

func (*Rectangle) Max

func (a *Rectangle) Max() Point

Max returns the highest (most north-eastern) <lat,long> Point of the rectangle.

func (*Rectangle) Min

func (a *Rectangle) Min() Point

Min returns the lowest (most south-western) <lat,long> Point of the rectangle.

func (*Rectangle) OverlapWith

func (a *Rectangle) OverlapWith(b *Rectangle) float64

OverlapWith returns the area of the overlapping area of the two rectangles.

Jump to

Keyboard shortcuts

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