Back to

Package tegola

Latest Go to latest

The highest tagged major version is .

Published: Sep 12, 2020 | License: MIT | Module:


Package tegola describes the basic geometeries that can be used to convert to and from.



const (
	WebMercator = 3857
	WGS84       = 4326
const (
	DefaultEpislon    = 10.0
	DefaultExtent     = 4096
	DefaultTileBuffer = 64.0
	MaxZ              = 22


var (
	WebMercatorBounds = &geom.Extent{-20026376.39, -20048966.10, 20026376.39, 20048966.10}
	WGS84Bounds       = &geom.Extent{-180.0, -85.0511, 180.0, 85.0511}
var UnknownConversionError = fmt.Errorf("do not know how to convert value to requested value")

func GeometeryDecorator

func GeometeryDecorator(g Geometry, ptsPerLine int, comment string, ptDecorator func(pt Point) string) string

func GeometryAsJSON

func GeometryAsJSON(g Geometry, w io.Writer) error

func GeometryAsMap

func GeometryAsMap(g Geometry) map[string]interface{}

func GeometryAsString

func GeometryAsString(g Geometry) string

func IsCollectionEqual

func IsCollectionEqual(c1, c2 Collection) bool

CollectionIsEqual will check to see if the provided collections are equal. This function does not check to see if the collections contain any recursive structures, and if there are any recursive structures it will hang. If the collections contains any unknown geometries it will be assumed to not match.

func IsGeometryEqual

func IsGeometryEqual(g1, g2 Geometry) bool

GeometryIsEqual will check to see if the two given geometeries are equal. This function does not check to see if there are any recursive structures if there are any recursive structures it will hang. If the type of the geometry is unknown, it is assumed that it does not match any other geometries.

func IsLineStringEqual

func IsLineStringEqual(l1, l2 LineString) bool

IsLineStringEqual will check to see if the two linesstrings provided are equal.

func IsMultiLineEqual

func IsMultiLineEqual(ml1, ml2 MultiLine) bool

IsMultiLineEqual will check to see if the two Multilines that are provided are equal.

func IsMultiPointEqual

func IsMultiPointEqual(mp1, mp2 MultiPoint) bool

IsMultiPointEqual will check to see if the two provided multipoints are equal

func IsMultiPolygonEqual

func IsMultiPolygonEqual(mp1, mp2 MultiPolygon) bool

MultiPolygonIsEqual will check to see if the two provided multi-polygons are equal.

func IsPoint3Equal

func IsPoint3Equal(p1, p2 Point3) bool

IsPoint3Equal will check to see if the two 3d tegola points are equal.

func IsPointEqual

func IsPointEqual(p1, p2 Point) bool

IsPointEqual will check to see if the two tegola points are equal.

func IsPolygonEqual

func IsPolygonEqual(p1, p2 Polygon) bool

PolygonIsEqual will check to see if the two provided polygons are equal.

func LineAsPointPairs

func LineAsPointPairs(l LineString) (pp []float64)

func Tile2Lat

func Tile2Lat(y, z uint64) float64

func Tile2Lon

func Tile2Lon(x, z uint64) float64

type Collection

type Collection interface {
	Geometries() []Geometry

Collection is a collections of different geometries.

type Geometry

type Geometry interface{}

Geometry describes a geometry.

type LineString

type LineString interface {
	Subpoints() []Point

LineString is a Geometry of a line.

type MultiLine

type MultiLine interface {
	Lines() []LineString

MultiLine is a Geometry with multiple individual lines.

type MultiPoint

type MultiPoint interface {
	Points() []Point

MultiPoint is a Geometry with multiple individual points.

type MultiPolygon

type MultiPolygon interface {
	Polygons() []Polygon

MultiPolygon describes a Geometry multiple intersecting polygons. There should only one exterior polygon, and the rest of the polygons should be interior polygons. The interior polygons will exclude the area from the exterior polygon.

type Point

type Point interface {
	X() float64
	Y() float64

Point is how a point should look like.

type Point3

type Point3 interface {
	Z() float64

Point3 is a point with three dimensions; at current is just converted and treated as a point.

type Polygon

type Polygon interface {
	Sublines() []LineString

Polygon is a multi-line Geometry where all the lines connect to form an enclose space.

type Tile

type Tile struct {
	Z         uint
	X         uint
	Y         uint
	Lat       float64
	Long      float64
	Tolerance float64
	Extent    float64
	Buffer    float64
	// contains filtered or unexported fields

Tile slippy map tilenames

func NewTile

func NewTile(z, x, y uint) (t *Tile)

NewTile will return a non-nil tile object.

func NewTileLatLong

func NewTileLatLong(z uint, lat, lon float64) (t *Tile)

NewTileLatLong will return a non-nil tile object.

func (*Tile) Bounds

func (t *Tile) Bounds() [4]float64

Bounds returns the bounds of the Tile as defined by the North most Longitude, East most Latitude, South most Longitude, West most Latitude.

func (*Tile) Deg2Num

func (t *Tile) Deg2Num() (x, y int)

func (*Tile) FromPixel

func (t *Tile) FromPixel(srid int, pt [2]float64) (npt [2]float64, err error)

func (*Tile) Init

func (t *Tile) Init()

func (*Tile) Num2Deg

func (t *Tile) Num2Deg() (lat, lng float64)

func (*Tile) PixelBufferedBounds

func (t *Tile) PixelBufferedBounds() (bounds [4]float64, err error)

func (*Tile) ToPixel

func (t *Tile) ToPixel(srid int, pt [2]float64) (npt [2]float64, err error)

func (*Tile) ZEpislon

func (t *Tile) ZEpislon() float64

This is from Leafty

func (*Tile) ZLevel

func (t *Tile) ZLevel() uint

Returns web mercator zoom level

func (*Tile) ZRes

func (t *Tile) ZRes() float64

ZRes takes a web mercator zoom level and returns the pixel resolution for that scale, assuming t.Extent x t.Extent pixel tiles. Non-integer zoom levels are accepted. ported from: 40075016.6855785 is the equator in meters for WGS84 at z=0

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier