TileStache.Geography module¶
The geography bits of TileStache.
A Projection defines the relationship between the rendered tiles and the underlying geographic data. Generally, just one popular projection is used for most web maps, “spherical mercator”.
Built-in projections: - spherical mercator - WGS84
Example use projection in a layer definition:
- “layer-name”: {
- “projection”: “spherical mercator”, ...
}
You can define your own projection, with a module and object name as arguments:
- “layer-name”: {
- ... “projection”: “Module:Object”
}
The object must include methods that convert between coordinates, points, and locations. See the included mercator and WGS84 implementations for example. You can also instantiate a projection class using this syntax:
- “layer-name”: {
- ... “projection”: “Module:Object()”
}
-
class
TileStache.Geography.SphericalMercator¶ Bases:
ModestMaps.Geo.MercatorProjectionSpherical mercator projection for most commonly-used web map tile scheme.
This projection is identified by the name “spherical mercator” in the TileStache config. The simplified projection used here is described in greater detail at: http://trac.openlayers.org/wiki/SphericalMercator
-
coordinateProj(coord)¶ Convert from Coordinate object to a Point object in EPSG:900913
-
locationProj(location)¶ Convert from Location object to a Point object in EPSG:900913
-
projCoordinate(point)¶ Convert from Point object in EPSG:900913 to a Coordinate object
-
projLocation(point)¶ Convert from Point object in EPSG:900913 to a Location object
-
srs= '+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over'¶
-
-
class
TileStache.Geography.WGS84¶ Bases:
ModestMaps.Geo.LinearProjectionUnprojected projection for the other commonly-used web map tile scheme.
This projection is identified by the name “WGS84” in the TileStache config.
-
coordinateProj(coord)¶ Convert from Coordinate object to a Point object in EPSG:4326
-
locationProj(location)¶ Convert from Location object to a Point object in EPSG:4326
-
projCoordinate(point)¶ Convert from Point object in EPSG:4326 to a Coordinate object
-
projLocation(point)¶ Convert from Point object in EPSG:4326 to a Location object
-
srs= '+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs'¶
-
-
TileStache.Geography.getProjectionByName(name)¶ Retrieve a projection object by name.
Raise an exception if the name doesn’t work out.