geo

package
v0.0.13-a Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2016 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EarthRad = 6372800 //meters
	RadToDeg = 180 / math.Pi
	DegToRad = math.Pi / 180
)
View Source
const (
	PolygonFeature = "polygon"
	LineFeature    = "line"
	PointFeature   = "point"
)

Variables

View Source
var (
	RtreeMinChildren = 25
	RtreeMaxChildren = 50
)

Functions

func QuadKey

func QuadKey(c Coordinate, zoom int) tiles.Quadkey

func UnmarshalGeojsonFeature

func UnmarshalGeojsonFeature(raw string) (feature *geojson.Feature, err error)

Types

type Box

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

func NewBox

func NewBox(min, max Coordinate) (box Box, err error)

func (Box) Contains

func (b Box) Contains(coords ...Coordinate) (in bool)

func (Box) NorthEast

func (b Box) NorthEast() Coordinate

func (Box) SouthWest

func (b Box) SouthWest() Coordinate

type BruteFence

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

func NewBruteFence

func NewBruteFence() *BruteFence

func (*BruteFence) Add

func (b *BruteFence) Add(f *Feature)

func (*BruteFence) Get

func (b *BruteFence) Get(c Coordinate) []*Feature

func (*BruteFence) Size

func (b *BruteFence) Size() int

type Coordinate

type Coordinate struct {
	Lat, Lon float64
}

func (Coordinate) Difference

func (c Coordinate) Difference(o Coordinate) (d Coordinate)

func (Coordinate) Distance

func (cd Coordinate) Distance(od Coordinate) float64

Distance between coordinates in meters

func (Coordinate) String

func (c Coordinate) String() string

func (Coordinate) ToRad

func (c Coordinate) ToRad() Coordinate

func (Coordinate) ToTile

func (c Coordinate) ToTile(zoom int) (tile tiles.Tile)

func (Coordinate) X

func (c Coordinate) X() float64

func (Coordinate) Y

func (c Coordinate) Y() float64

type Feature

type Feature struct {
	ID         interface{}
	Geometry   []*Shape
	Type       string
	Properties map[string]interface{}
}

func GeojsonFeatureAdapter

func GeojsonFeatureAdapter(gj *geojson.Feature) (feature *Feature, err error)

Flatten all the points of a feature into single list. This can hel in identifying which tiles are going to be created

func MakeFeature

func MakeFeature(length int) *Feature

func NewFeature

func NewFeature(geometryType string, geometry ...*Shape) *Feature

func NewLineFeature

func NewLineFeature(geometry ...*Shape) *Feature

func NewPointFeature

func NewPointFeature(geometry ...*Shape) *Feature

func NewPolygonFeature

func NewPolygonFeature(geometry ...*Shape) *Feature

func (*Feature) AddShape

func (f *Feature) AddShape(s *Shape)

func (*Feature) Center

func (f *Feature) Center() (avg Coordinate)

func (*Feature) Contains

func (f *Feature) Contains(c Coordinate) bool

Only checks as exterior ring TODO account for interior rings

func (*Feature) Tags

func (f *Feature) Tags(key string) string

type Fence

type Fence interface {
	Add(f *Feature)
	GetFeatures(f *Feature) []*Feature
	Size() int
}

type GeojsonSource

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

func NewGeojsonSource

func NewGeojsonSource(path string, filter []string) *GeojsonSource

func (*GeojsonSource) Publish

func (gj *GeojsonSource) Publish() (features chan *Feature, err error)

type Rfence

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

func NewRfence

func NewRfence() *Rfence

func (*Rfence) Add

func (r *Rfence) Add(f *Feature)

func (*Rfence) Get

func (r *Rfence) Get(c Coordinate) []*Feature

func (*Rfence) Size

func (r *Rfence) Size() int

type Rnode

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

func (*Rnode) Bounds

func (n *Rnode) Bounds() *rtreego.Rect

implements rtree.Spatial

func (*Rnode) Feature

func (n *Rnode) Feature() *Feature

func (*Rnode) Value

func (n *Rnode) Value() interface{}

type Rtree

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

func NewRtree

func NewRtree() *Rtree

func (*Rtree) Contains

func (r *Rtree) Contains(c Coordinate) []*Rnode

func (*Rtree) Insert

func (r *Rtree) Insert(s *Shape, data interface{})

func (*Rtree) Intersections

func (r *Rtree) Intersections(q *Shape) []*Rnode

type Shape

type Shape struct {
	Coordinates []Coordinate
}

func MakeShape

func MakeShape(length int) *Shape

func NewShape

func NewShape(coords ...Coordinate) *Shape

func ShapeFromString

func ShapeFromString(raw string) (shp *Shape, err error)

[[lon,lat]...]

func (*Shape) Add

func (s *Shape) Add(c ...Coordinate)

func (*Shape) Append

func (s *Shape) Append(o *Shape)

func (*Shape) BoundingBox

func (s *Shape) BoundingBox() Box

func (*Shape) Contains

func (s *Shape) Contains(c Coordinate) bool

func (*Shape) Edges

func (s *Shape) Edges() <-chan []Coordinate

func (*Shape) Head

func (s *Shape) Head() Coordinate

func (*Shape) IsClockwise

func (s *Shape) IsClockwise() bool

func (*Shape) IsClosed

func (s *Shape) IsClosed() bool

Only shapes that contain an area can be closed (>3 Coordinates)

func (*Shape) Length

func (s *Shape) Length() int

Number of coordinates

func (*Shape) Reverse

func (s *Shape) Reverse()

func (*Shape) Tail

func (s *Shape) Tail() Coordinate

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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