geo

package
v0.0.0-...-63ab681 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2017 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Mercator = Projection{
	Project: func(p *Point) {
		p.SetX(mercatorPole / 180.0 * p.Lng())

		y := math.Log(math.Tan((90.0+p.Lat())*math.Pi/360.0)) / math.Pi * mercatorPole
		p.SetY(math.Max(-mercatorPole, math.Min(y, mercatorPole)))
	},
	Inverse: func(p *Point) {
		p.SetLng(p.X() * 180.0 / mercatorPole)
		p.SetLat(180.0 / math.Pi * (2*math.Atan(math.Exp((p.Y()/mercatorPole)*math.Pi)) - math.Pi/2.0))
	},
}

Mercator projection, performs EPSG:3857, sometimes also described as EPSG:900913.

Functions

This section is empty.

Types

type Cell

type Cell struct {
	X   float64 // Cell center X
	Y   float64 // Cell center Y
	H   float64 // Half cell size
	D   float64 // Distance from cell center to polygon
	Max float64 // max distance to polygon within a cell
}

func NewCell

func NewCell(x float64, y float64, h float64, p Polygon) *Cell

type Point

type Point [2]float64

A Point is a simple Lng/Lat 2d point.

func NewPointFromLatLng

func NewPointFromLatLng(lat, lng float64) *Point

Creates a point from a latitude and longitude

func Polylabel

func Polylabel(polygon Polygon, precision float64, debug bool) Point

func (*Point) Lat

func (p *Point) Lat() float64

Lat returns the latitude/vertical component of the point.

func (*Point) Lng

func (p *Point) Lng() float64

Lng returns the longitude/horizontal component of the point.

func (*Point) SetLat

func (p *Point) SetLat(lat float64) *Point

SetLat sets the latitude/vertical component of the point.

func (*Point) SetLng

func (p *Point) SetLng(lng float64) *Point

SetLng sets the longitude/horizontal component of the point.

func (*Point) SetX

func (p *Point) SetX(x float64) *Point

SetX sets the x/horizontal component of the point.

func (*Point) SetY

func (p *Point) SetY(y float64) *Point

SetY sets the y/vertical component of the point.

func (*Point) Transform

func (p *Point) Transform(projector Projector) *Point

Transform applies a given projection or inverse projection to the current point.

func (*Point) X

func (p *Point) X() float64

X returns the x/horizontal component of the point.

func (*Point) Y

func (p *Point) Y() float64

Y returns the y/vertical component of the point.

type Polygon

type Polygon struct {
	Rings [][]Point
}

func (*Polygon) Transform

func (p *Polygon) Transform(projector Projector)

type PriorityQueue

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

PriorityQueue represents the queue

func NewPriorityQueue

func NewPriorityQueue() PriorityQueue

New initializes an empty priority queue.

func (*PriorityQueue) Insert

func (p *PriorityQueue) Insert(v interface{}, priority float64)

Insert inserts a new element into the queue. No action is performed on duplicate elements.

func (*PriorityQueue) Len

func (p *PriorityQueue) Len() int

Len returns the number of elements in the queue.

func (*PriorityQueue) Pop

func (p *PriorityQueue) Pop() (interface{}, error)

Pop removes the element with the highest priority from the queue and returns it. In case of an empty queue, an error is returned.

func (*PriorityQueue) UpdatePriority

func (p *PriorityQueue) UpdatePriority(x interface{}, newPriority float64)

UpdatePriority changes the priority of a given item. If the specified item is not present in the queue, no action is performed.

type Projection

type Projection struct {
	Project Projector
	Inverse Projector
}

A Projection is a set of projectors to map forward and backwards to the projected space.

type Projector

type Projector func(p *Point)

A Projector is a function that converts the given point to a different space.

Jump to

Keyboard shortcuts

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