TileStache.Goodies.Proj4Projection module¶
Projection that supports any projection that can be expressed in Proj.4 format.
The projection is configured by a projection definition in the Proj.4 format, the resolution of the zoom levels that the projection should support, the tile size, and a transformation that defines how to tile coordinates are calculated.
An example, instantiating a projection for EPSG:2400 (RT90 2.5 gon W):
- Proj4Projection(‘+proj=tmerc +lat_0=0 +lon_0=15.80827777777778 +k=1’
- +’ +x_0=1500000 +y_0=0 +ellps=bessel +units=m +no_defs’, [8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1], transformation=Transformation(1, 0, 0, 0, -1, 0))
This example defines 14 zoom levels, where each level doubles the resolution, where the most zoomed out level uses 8192 projected units (meters, in this case) per pixel. The tiles are adressed using XYZ scheme, with the origin at (0, 0): the x component of the transformation is 1, the y component is -1 (tile rows increase from north to south). Tile size defaults to 256x256 pixels.
The same projection, included in a TileStache configuration file:
“example”: {
“provider”: {“name”: “mapnik”, “mapfile”: “examples/style.xml”}, “projection”: “TileStache.Goodies.Proj4Projection:Proj4Projection(‘+proj=tmerc +lat_0=0 +lon_0=15.80827777777778 +k=1 +x_0=1500000 +y_0=0 +ellps=bessel +units=m +no_defs’, [8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1], transformation=Transformation(1, 0, 0, 0, -1, 0))”}
“Module:Class()” syntax described in http://tilestache.org/doc/#projections.
For more details about tiling, projections, zoom levels and transformations, see http://blog.kartena.se/local-projections-in-a-world-of-spherical-mercator/
-
class
TileStache.Goodies.Proj4Projection.Proj4Projection(srs, resolutions, tile_size=256, transformation=<ModestMaps.Geo.Transformation instance>)¶ Bases:
ModestMaps.Geo.LinearProjectionProjection that supports any projection that can be expressed in Proj.4 format.
Required attributes:
- srs:
- The Proj.4 definition of the projection to use, as a string
- resolutions:
- An array of the zoom levels’ resolutions, expressed as the number of projected units per pixel on each zoom level. The array is ordered with outermost zoom level first (0 is most zoomed out).
Optional attributes:
- tile_size:
- The size of a tile in pixels, default is 256.
- transformation:
- Transformation to apply to the projected coordinates to convert them to tile coordinates. Defaults to Transformation(1, 0, 0, 1, 0), which gives row = projected_y * scale, column = projected_x * scale
-
coordinateLocation(coord)¶ TODO: write me.
-
coordinateProj(coord)¶ Convert from Coordinate object to a Point object in the defined projection
-
findZoom(resolution)¶
-
locationCoordinate(location)¶
-
locationProj(location)¶ Convert from Location object to a Point object in the defined projection
-
projCoordinate(point, zoom=None)¶ Convert from Point object in the defined projection to a Coordinate object
-
projLocation(point)¶ Convert from Point object in the defined projection to a Location object
-
project(point, scale)¶
-
unproject(point, scale)¶