3.2. DataSource
A <Datasource>
can appear in two places: as a named data surce template under <Map>
or as an actual data source in a <Layer>
. A data soure template can provide default values for actual layer data sources, e.g. when using a PostGis database as data source a data source template can provide all the connection parameters, so that actual layer data sources only have to provide actual SQL queries.
Example:
<Map>
<!-- Datasource template -->
<Datasource name="gis">
<Parameter name="type">postgis</Parameter>
<Parameter name="host">gis-db</Parameter>
<Parameter name="port">5432</Parameter>
<Parameter name="dbname">gis</Parameter>
<Parameter name="user">maposmatic</Parameter>
<Parameter name="password">secret</Parameter>
</Datasource>
<!-- actual Datasource using the template above for default values -->
<Layer name="layer-1">
<Datasource base="gis">
<Parameter name="table">
` SELECT ...
</Parameter>
</Datasource>
</Layer>
</Map>
Mapnik supports several different kinds of data sources, and actually has a plugin interface for these, so that plugins for more data sources can be added "on the fly" without having to rebuild Mapnik itself.
The set of plugins that come with Mapnik itself are caled core plugins. Some former core plugins that are no longer maintained, or never left experimental status, have been moved to a separate non-core plugins repository, and there is also a small number of plugins by outside contributores, which we will refer to as exra data sources below.