Documentation ¶
Index ¶
- Constants
- Variables
- func Degree2Radians(degree float64) float64
- func Extent(g TileGridder, t Tile) (*geom.Extent, error)
- func MvtPixelRationForZoom(g TileGridder, zoom Zoom) float64
- func PixelRatioForZoom(g TileGridder, zoom Zoom, tileDim uint64) float64
- func PtFromLatLon(lat, lon float64) geom.Point
- func Radians2Degree(radians float64) float64
- func RangeFamilyAt(tile Tile, zoom Zoom, yield func(Tile) bool)
- type Grid
- type Grid4326
- type Tile
- type TileGridder
- type Zoom
Constants ¶
const ( // DefaultTileSize is the tile size used if the given tile size is 0. DefaultTileSize = 256 // Lat4326Max is the maximum degree for latitude on an SRID 4326 map Lat4326Max = 85.05112 // Lon4326Max is the maximum degree for longitude on an SRID 4326 map Lon4326Max = 180 )
const MaxZoom = 22
MaxZoom is the lowest zoom (furthest in)
const MvtTileDim = 4096.0
MvtTileDim is the number of pixels in a tile
Variables ¶
var (
ErrNilBounds = errors.New("slippy: Bounds cannot be nil")
)
Functions ¶
func Degree2Radians ¶
Degree2Radians converts degrees to radians
func MvtPixelRationForZoom ¶
func MvtPixelRationForZoom(g TileGridder, zoom Zoom) float64
MvtPixelRationForZoom returns the ratio of pixels to projected units at the given zoom. This assumes an MVT tile is being used.
func PixelRatioForZoom ¶
func PixelRatioForZoom(g TileGridder, zoom Zoom, tileDim uint64) float64
PixelRatioForZoom returns the ratio of pixels to projected units at the given zoom. Multiply this value by the pixel count in tile.buffer to get the expected conversion.
if zoom is larger the MaxZoom, it will be set to MaxZoom if tileDim is 0, it will be set to MvtTileDim
func PtFromLatLon ¶
func Radians2Degree ¶
Radians2Degree converts radians to degrees
func RangeFamilyAt ¶
RangeFamilyAt returns an iterator function that will call the yield function with every related tile at the requested zoom. This will include the provided tile itself. (if the same zoom is provided). The parent (overlapping tile at a lower zoom level), or children (overlapping tiles at a higher zoom level).
Types ¶
type Grid4326 ¶
type Grid4326 struct {
// contains filtered or unexported fields
}
func (Grid4326) FromNative ¶
FromNative will convert a pt in 3857 coordinates and a zoom to a Tile coordinate
type Tile ¶
Tile describes a slippy tile.
func FromBounds ¶
func FromBounds(g TileGridder, bounds geom.PtMinMaxer, z Zoom) ([]Tile, error)
FromBounds returns a list of tiles that make up the bound given. The bounds should be defined as the following lng/lat points [4]float64{west,south,east,north}
The only errors this generates are if the bounds is nil, or any errors grid returns from transformation the bounds points.
func NewTileMinMaxer ¶
func NewTileMinMaxer(g TileGridder, ext geom.MinMaxer) (Tile, error)
func (Tile) FamilyAt ¶
FamilyAt returns an iterator function that will call the yield function with every related tile at the requested zoom. This will include the provided tile itself. (if the same zoom is provided). The parent (overlapping tile at a lower zoom level), or children (overlapping tiles at a higher zoom level).
This function is structured so that it can take advantage of go1.23's Range Funcs. e.g.: for tile := range aTile.FamilyAt(10) { fmt.Printf("got tile: %v\n",tile) }
type TileGridder ¶
type TileGridder interface { // SRID returns the SRID of the coordinate system of the // implementer. The geometries returned by the other methods // will be in these coordinates. SRID() proj.EPSGCode // Size returns a tile where the X and Y are the size of that zoom's // tile grid. AKA: // Tile{z, MaxX + 1, MaxY + 1 Size(z Zoom) (Tile, bool) // FromNative converts from a point (in the Grid's coordinates system) and zoom // to a tile. FromNative(z Zoom, pt geom.Point) (tile Tile, err error) // ToNative returns the tiles upper left point. ok will be false if // the tile is not valid. A note on implementation is that this method // should be able to take tiles with x and y values 1 higher than the max, // this is to fetch the bottom right corner of the grid ToNative(Tile) (pt geom.Point, err error) }
TileGridder contains the tile layout, including ability to get WGS84 coordinates for tile extents