Documentation ¶
Overview ¶
Package gridserver serves tiles with the plus codes grid. This parses the request, and generates either a GeoJSON or PNG image response.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetImageFont ¶
SetImageFont parses a TTF font and uses it for the image labels.
Types ¶
type GeodeticTMS ¶
type GeodeticTMS struct {
// contains filtered or unexported fields
}
GeodeticTMS provides a EPSG:4326 projection. The top zoom level is scaled to two tiles. Zoom levels are not square but rectangular. Although TMS tiles are numbered from south to north, raster coordinates are numbered from north to south. This code is indebted to the gdal2tiles.py from OSGEO GDAL.
func (*GeodeticTMS) LatLngToRaster ¶
func (g *GeodeticTMS) LatLngToRaster(lat, lng float64, zoom float64) (x, y float64)
LatLngToRaster converts a WGS84 latitude and longitude to absolute pixel values. Note that the pixel origin is at top left.
func (*GeodeticTMS) String ¶
func (g *GeodeticTMS) String() string
String provides the name of the projection.
func (*GeodeticTMS) TileLatLngBounds ¶
func (g *GeodeticTMS) TileLatLngBounds(tx, ty, zoom int) (latlo, lnglo, lathi, lnghi float64)
TileLatLngBounds returns bounds of a TMS tile in latitude/longitude using WGS84 datum.
func (*GeodeticTMS) TileOrigin ¶
func (g *GeodeticTMS) TileOrigin(tx, ty, zoom int) (x, y float64)
TileOrigin returns the left and top of the tile in raster pixels.
type MercatorTMS ¶
type MercatorTMS struct {
// contains filtered or unexported fields
}
MercatorTMS provides a spherical mercator projection using TMS tile specifications. Although TMS tiles are numbered from south to north, raster coordinates are numbered from north to south. This code is indebted to the gdal2tiles.py from OSGEO GDAL.
func (*MercatorTMS) LatLngToRaster ¶
func (m *MercatorTMS) LatLngToRaster(lat, lng float64, zoom float64) (x, y float64)
LatLngToRaster converts a WGS84 latitude and longitude to absolute pixel values. Note that the pixel origin is at top left.
func (*MercatorTMS) String ¶
func (m *MercatorTMS) String() string
String provides the name of the projection.
func (*MercatorTMS) TileLatLngBounds ¶
func (m *MercatorTMS) TileLatLngBounds(tx, ty, zoom int) (latlo, lnglo, lathi, lnghi float64)
TileLatLngBounds returns bounds of a TMS tile in latitude/longitude using WGS84 datum.
func (*MercatorTMS) TileOrigin ¶
func (m *MercatorTMS) TileOrigin(tx, ty, zoom int) (x, y float64)
TileOrigin returns the left and top of the tile in raster pixels.
type Projection ¶
type Projection interface { TileOrigin(tx, ty, zoom int) (float64, float64) TileLatLngBounds(tx, ty, zoom int) (float64, float64, float64, float64) LatLngToRaster(float64, float64, float64) (x, y float64) String() string }
Projection defines the interface for types that convert between pixel and lat/lng coordinates.
type TileFormat ¶
type TileFormat int
TileFormat specifies the types of tiles to generate.
const ( // JSONTile indicates the tile output should be GeoJSON. JSONTile TileFormat = 0 // ImageTile indicates the tile output should be a PNG image. ImageTile TileFormat = 1 )
type TileOptions ¶
type TileOptions struct { Format TileFormat LineColor color.Color LabelColor color.Color Projection Projection ZoomAdjust int }
TileOptions are settings to adjust how the tiles are generated.
func NewTileOptions ¶
func NewTileOptions() *TileOptions
NewTileOptions returns a default set of options.
func (TileOptions) String ¶
func (o TileOptions) String() string
String returns a string representation of the options.
type TileRef ¶
type TileRef struct { Z int X int Y int Options *TileOptions SW *LatLng NE *LatLng // contains filtered or unexported fields }
TileRef represents a TMS tile reference, based on x/y/z values. It provides the tile bounding box, and a function to convert lat/lng into pixel references.
func MakeTileRef ¶
func MakeTileRef(x, y, z int, opts *TileOptions) *TileRef
MakeTileRef constructs the tile reference.
func (*TileRef) GeoJSON ¶
func (t *TileRef) GeoJSON() (*geojson.FeatureCollection, error)
GeoJSON returns a GeoJSON object for the tile. Objects (lines etc) may extend outside the tile dimensions, so clipping objects to match tile boundaries is up to the client.
func (*TileRef) LatLngToPixel ¶
LatLngToPixel converts a lat/lng pair in degrees to pixel values relative to the NW corner of the tile.