2013-05-16 21:03:30 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
*
|
|
|
|
* This file is part of Mapnik (c++ mapping toolkit)
|
|
|
|
*
|
2017-05-05 13:02:01 +02:00
|
|
|
* Copyright (C) 2017 Artem Pavlenko
|
2013-05-16 21:03:30 +02:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
// mapnik
|
|
|
|
#include <mapnik/datasource_cache.hpp>
|
2014-07-23 23:02:36 +02:00
|
|
|
#include <mapnik/datasource.hpp>
|
2013-05-16 21:03:30 +02:00
|
|
|
|
|
|
|
#ifdef MAPNIK_STATIC_PLUGINS
|
|
|
|
#include <mapnik/params.hpp>
|
|
|
|
|
|
|
|
// boost
|
|
|
|
#include <boost/assign/list_of.hpp>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// stl
|
|
|
|
#include <stdexcept>
|
2015-06-18 11:08:35 +02:00
|
|
|
#include <unordered_map>
|
2013-05-16 21:03:30 +02:00
|
|
|
|
|
|
|
// static plugin linkage
|
|
|
|
#ifdef MAPNIK_STATIC_PLUGINS
|
|
|
|
#if defined(MAPNIK_STATIC_PLUGIN_CSV)
|
2014-11-11 23:42:53 +01:00
|
|
|
#include "input/csv/csv_datasource.hpp"
|
2013-05-16 21:03:30 +02:00
|
|
|
#endif
|
|
|
|
#if defined(MAPNIK_STATIC_PLUGIN_GDAL)
|
2014-11-11 23:42:53 +01:00
|
|
|
#include "input/gdal/gdal_datasource.hpp"
|
2013-05-16 21:03:30 +02:00
|
|
|
#endif
|
|
|
|
#if defined(MAPNIK_STATIC_PLUGIN_GEOJSON)
|
2014-11-11 23:42:53 +01:00
|
|
|
#include "input/geojson/geojson_datasource.hpp"
|
2013-05-16 21:03:30 +02:00
|
|
|
#endif
|
|
|
|
#if defined(MAPNIK_STATIC_PLUGIN_GEOS)
|
2014-11-11 23:42:53 +01:00
|
|
|
#include "input/geos/geos_datasource.hpp"
|
2013-05-16 21:03:30 +02:00
|
|
|
#endif
|
|
|
|
#if defined(MAPNIK_STATIC_PLUGIN_KISMET)
|
2014-11-11 23:42:53 +01:00
|
|
|
#include "input/kismet/kismet_datasource.hpp"
|
2013-05-16 21:03:30 +02:00
|
|
|
#endif
|
|
|
|
#if defined(MAPNIK_STATIC_PLUGIN_OCCI)
|
2014-11-11 23:42:53 +01:00
|
|
|
#include "input/occi/occi_datasource.hpp"
|
2013-05-16 21:03:30 +02:00
|
|
|
#endif
|
|
|
|
#if defined(MAPNIK_STATIC_PLUGIN_OGR)
|
2014-11-11 23:42:53 +01:00
|
|
|
#include "input/ogr/ogr_datasource.hpp"
|
2013-05-16 21:03:30 +02:00
|
|
|
#endif
|
|
|
|
#if defined(MAPNIK_STATIC_PLUGIN_OSM)
|
2014-11-11 23:42:53 +01:00
|
|
|
#include "input/osm/osm_datasource.hpp"
|
2013-05-16 21:03:30 +02:00
|
|
|
#endif
|
|
|
|
#if defined(MAPNIK_STATIC_PLUGIN_POSTGIS)
|
2014-11-11 23:42:53 +01:00
|
|
|
#include "input/postgis/postgis_datasource.hpp"
|
2013-05-16 21:03:30 +02:00
|
|
|
#endif
|
|
|
|
#if defined(MAPNIK_STATIC_PLUGIN_RASTER)
|
2014-11-11 23:42:53 +01:00
|
|
|
#include "input/raster/raster_datasource.hpp"
|
2013-05-16 21:03:30 +02:00
|
|
|
#endif
|
|
|
|
#if defined(MAPNIK_STATIC_PLUGIN_RASTERLITE)
|
2014-11-11 23:42:53 +01:00
|
|
|
#include "input/rasterlite/rasterlite_datasource.hpp"
|
2013-05-16 21:03:30 +02:00
|
|
|
#endif
|
|
|
|
#if defined(MAPNIK_STATIC_PLUGIN_SHAPE)
|
2014-11-11 23:42:53 +01:00
|
|
|
#include "input/shape/shape_datasource.hpp"
|
2013-05-16 21:03:30 +02:00
|
|
|
#endif
|
|
|
|
#if defined(MAPNIK_STATIC_PLUGIN_SQLITE)
|
2014-11-11 23:42:53 +01:00
|
|
|
#include "input/sqlite/sqlite_datasource.hpp"
|
2013-05-16 21:03:30 +02:00
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
namespace mapnik {
|
|
|
|
|
|
|
|
#ifdef MAPNIK_STATIC_PLUGINS
|
|
|
|
template<typename T>
|
|
|
|
datasource_ptr ds_generator(parameters const& params)
|
|
|
|
{
|
2013-09-20 15:00:11 +02:00
|
|
|
return std::make_shared<T>(params);
|
2013-05-16 21:03:30 +02:00
|
|
|
}
|
|
|
|
|
2014-11-11 23:42:53 +01:00
|
|
|
typedef datasource_ptr (*ds_generator_ptr)(parameters const& params);
|
2015-06-18 11:08:35 +02:00
|
|
|
using datasource_map = std::unordered_map<std::string, ds_generator_ptr>;
|
2013-05-16 21:03:30 +02:00
|
|
|
|
|
|
|
static datasource_map ds_map = boost::assign::map_list_of
|
|
|
|
#if defined(MAPNIK_STATIC_PLUGIN_CSV)
|
|
|
|
(std::string("csv"), &ds_generator<csv_datasource>)
|
|
|
|
#endif
|
|
|
|
#if defined(MAPNIK_STATIC_PLUGIN_GDAL)
|
|
|
|
(std::string("gdal"), &ds_generator<gdal_datasource>)
|
|
|
|
#endif
|
|
|
|
#if defined(MAPNIK_STATIC_PLUGIN_GEOJSON)
|
|
|
|
(std::string("geojson"), &ds_generator<geojson_datasource>)
|
|
|
|
#endif
|
|
|
|
#if defined(MAPNIK_STATIC_PLUGIN_OCCI)
|
|
|
|
(std::string("occi"), &ds_generator<occi_datasource>)
|
|
|
|
#endif
|
|
|
|
#if defined(MAPNIK_STATIC_PLUGIN_OGR)
|
|
|
|
(std::string("ogr"), &ds_generator<ogr_datasource>)
|
|
|
|
#endif
|
|
|
|
#if defined(MAPNIK_STATIC_PLUGIN_OSM)
|
|
|
|
(std::string("osm"), &ds_generator<osm_datasource>)
|
|
|
|
#endif
|
|
|
|
#if defined(MAPNIK_STATIC_PLUGIN_POSTGIS)
|
|
|
|
(std::string("postgis"), &ds_generator<postgis_datasource>)
|
|
|
|
#endif
|
|
|
|
#if defined(MAPNIK_STATIC_PLUGIN_RASTER)
|
|
|
|
(std::string("raster"), &ds_generator<raster_datasource>)
|
|
|
|
#endif
|
|
|
|
#if defined(MAPNIK_STATIC_PLUGIN_RASTERLITE)
|
|
|
|
(std::string("rasterlite"), &ds_generator<rasterlite_datasource>)
|
|
|
|
#endif
|
|
|
|
#if defined(MAPNIK_STATIC_PLUGIN_SHAPE)
|
|
|
|
(std::string("shape"), &ds_generator<shape_datasource>)
|
|
|
|
#endif
|
|
|
|
#if defined(MAPNIK_STATIC_PLUGIN_SQLITE)
|
|
|
|
(std::string("sqlite"), &ds_generator<sqlite_datasource>)
|
|
|
|
#endif
|
|
|
|
;
|
|
|
|
#endif
|
|
|
|
|
2013-07-23 21:51:22 +02:00
|
|
|
#ifdef MAPNIK_STATIC_PLUGINS
|
2013-05-16 21:03:30 +02:00
|
|
|
datasource_ptr create_static_datasource(parameters const& params)
|
|
|
|
{
|
|
|
|
datasource_ptr ds;
|
|
|
|
boost::optional<std::string> type = params.get<std::string>("type");
|
|
|
|
datasource_map::iterator it = ds_map.find(*type);
|
|
|
|
if (it != ds_map.end())
|
|
|
|
{
|
|
|
|
ds = it->second(params);
|
|
|
|
}
|
|
|
|
return ds;
|
|
|
|
}
|
2013-07-23 21:51:22 +02:00
|
|
|
#else
|
|
|
|
datasource_ptr create_static_datasource(parameters const& /*params*/)
|
|
|
|
{
|
|
|
|
return datasource_ptr();
|
|
|
|
}
|
|
|
|
#endif
|
2013-05-16 21:03:30 +02:00
|
|
|
|
|
|
|
std::vector<std::string> get_static_datasource_names()
|
|
|
|
{
|
|
|
|
std::vector<std::string> names;
|
|
|
|
|
|
|
|
#ifdef MAPNIK_STATIC_PLUGINS
|
|
|
|
datasource_map::iterator it = ds_map.begin();
|
|
|
|
while (it != ds_map.end())
|
|
|
|
{
|
|
|
|
names.push_back(it->first);
|
|
|
|
|
|
|
|
it++;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return names;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|