geo

package
v0.0.0-...-a3207ce Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const EarthRadius = 6378137

EarthRadius is the radius of the Earth in meter, UTM, WGS84

Variables

This section is empty.

Functions

func Angle

func Angle(a, o, b *Point) float64

Angle calculates the angle <AOB> the angle value: [0, 180] in degree

lat /|\
     |     a *
     |      /
     |     /
     |  o *------* b
     |
     +---------------> lon

func Distance

func Distance(p1, p2 *Point) float64

Distance ...

func Rad

func Rad(degree float64) float64

Rad ...

Types

type Bbox

type Bbox struct {
	Left   float64 `json:"left"`
	Right  float64 `json:"right"`
	Top    float64 `json:"top"`
	Bottom float64 `json:"buttom"`
}

Bbox ...

func (*Bbox) IsInside

func (b *Bbox) IsInside(pt *Point) bool

IsInside ...

func (*Bbox) String

func (b *Bbox) String() string

String ...

type Line

type Line struct {
	Points []*Point
}

Line ...

func NewLine

func NewLine(pts []*Point) *Line

NewLine ...

type OnSide

type OnSide int

OnSide ...

const (
	// MiddleSide ...
	MiddleSide OnSide = 0
	// LeftSide ...
	LeftSide OnSide = 1
	// RightSide ...
	RightSide OnSide = -1
)

func Side

func Side(a, b, p *Point) OnSide

Side is calc point p on which side of (a->b)

a *
  | \
  |  \
  v   \
  |    * p
  |
b *

vector a->b: ab = b - a vector a->p: ap = p - a cross-product: m = ab x ap m > 0: p on the left m < 0: p on the right m = 0: p on the middle

type Point

type Point struct {
	Lat float64 `json:"lat"`
	Lon float64 `json:"lon"`
}

Point is GPS point

func (*Point) DistanceWith

func (p *Point) DistanceWith(pt *Point) float64

DistanceWith ...

func (*Point) String

func (p *Point) String() string

String ...

Jump to

Keyboard shortcuts

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