mapnik-org/mapnik — Issue #620: Allow late-binding of datasources
Author: artemp
Created: 2011-10-11 08:05:26+00:00
State: open
Labels: Core_Library

Currently when you create a Datasource it immediately (in the constructor) checks to see whether the file/database/table/etc is available.

For cascadenik we now have a compile option which instantiates mapnik objects (including datasources) and then serializes them out to XML. This obviously is a bit annoying if the production DB/data/etc need to be available.

Proposal:

* Change the constructor signature of datasources to be `datasource(const mapnik::parameters& params, bool bind=true)`. It will still check for the right parameters (eg. `table` parameter for postgis datasource, `file` parameter for shape, etc) but NOT attempt to verify that they exist or are accessible.
* Add a public `void bind()` method to the datasources which does the same work the constructor used to do - checking files exist, connecting to DBs, sorting out extents, etc. If it's called more than once it no-ops.
* `bind()` would be called by the constructor when `bind=true` (the default), so existing behaviour doesn't change.
* `envelope()`, `features()`, and `features_at_point()` would all check for bound-ness and call bind() if they're not.
* the `bind()` method and the `bind` constructor parameter would be exposed through the python bindings.