Python: module TileStache.Goodies.Providers.MirrorOSM

TileStache.Goodies.Providers.MirrorOSM | index

`Populate an OSM rendering database using tiled data requests.
This provider is unusual in that requests for tiles have the side effect of
running osm2pgsql to populate a PostGIS database of OSM data from a remote API
source. Returned tiles are just text confirmations that the process has been
successful, while the stored data is expected to be used in other providers
to render OSM data. It would be normal to use this provider outside the regular
confines of a web server, perhaps with a call to tilestache-seed.py governed
by a cron job or some other out-of-band process.
MirrorOSM is made tenable by MapQuest's hosting of the XAPI service:
http://open.mapquestapi.com/xapi/
Osm2pgsql is an external utility:
http://wiki.openstreetmap.org/wiki/Osm2pgsql
Example configuration:
"mirror-osm":
{
"provider":
{
"class": "TileStache.Goodies.Providers.MirrorOSM:Provider",
"kwargs":
{
"username": "osm",
"database": "planet",
"api_base": "http://open.mapquestapi.com/xapi/"
}
}
}
Provider parameters:
database:
Required Postgres database name.
username:
Required Postgres user name.
password:
Optional Postgres password.
hostname:
Optional Postgres host name.
table_prefix:
Optional table prefix for osm2pgsql. Defaults to "mirrorosm" if omitted.
Four tables will be created with this prefix: <prefix>_point, <prefix>_line,
<prefix>_polygon, and <prefix>_roads. Must result in valid table names!
api_base:
Optional OSM API base URL. Because we don't want to overtax the main OSM
API, this defaults to MapQuest's XAPI, "http://open.mapquestapi.com/xapi/".
The trailing slash must be included, up to but not including the "api/0.6"
portion of a URL. If you're careful to limit your usage, the primary
OSM API can be specified with "http://api.openstreetmap.org/".
osm2pgsql:
Optional filesystem path to osm2pgsql, just in case it's someplace outside
/usr/bin or /usr/local/bin. Defaults to "osm2pgsql --utf8-sanitize".
Additional arguments such as "--keep-coastlines" can be added to this string,
e.g. "/home/user/bin/osm2pgsql --keep-coastlines --utf8-sanitize".`

Modules
`` |  |
PIL.Image |  |  |

Classes
`` |  | ConfirmationResponse Provider
class ConfirmationResponse
`` | `Wrapper class for confirmation responses. TileStache.getTile() expects to be able to save one of these to a buffer.`
| Methods defined here: __init__(self, coord, content, success) do_I_have_to_draw_you_a_picture(self) `Return a little thumbs-up / thumbs-down image with text in it.` save(self, out, format)
class Provider
`` |  | Methods defined here: __init__(self, layer, database, username, password=None, hostname=None, table_prefix='mirrorosm', api_base='http://open.mapquestapi.com/xapi/', osm2pgsql='osm2pgsql --utf8-sanitize') getTypeByExtension(self, extension) `Get mime-type and format by file extension. This only accepts "txt".` renderTile(self, width, height, srs, coord) `Render a single tile, return a ConfirmationResponse instance.`

Functions
`` |  | clean_up_tables(db, tmp_prefix) `Drop all temporary tables created by prepare_data().` close(...) `close(fd) Close a file descriptor (for low level IO).` coordinate_latlon_bbox(coord, projection) `Return an (xmin, ymin, xmax, ymax) bounding box for a projected tile.` create_tables(db, prefix, tmp_prefix) `Create permanent tables for OSM data. No-op if they already exist.` download_api_data(filename, coord, api_base, projection) `Download API data for a tile to a named file, return size in kilobytes.` populate_tables(db, prefix, tmp_prefix, bounds) `Move prepared OSM data from temporary to permanent tables. Replace existing data and work within a single transaction.` prepare_data(filename, tmp_prefix, dbargs, osm2pgsql, projection) `Stage OSM data into a temporary set of tables using osm2pgsql.` time(...) `time() -> floating point number Return the current time in seconds since the Epoch. Fractions of a second may be present if the system clock provides them.` unlink(...) `unlink(path) Remove a file (same as remove(path)).` write(...) `write(fd, string) -> byteswritten Write a string to a file descriptor.`

Data
`` |  | PIPE = -1 stderr = <open file '<stderr>', mode 'w'>