static plugins

wip static plugins

add remaining datasources

wip

formatting
This commit is contained in:
Mathis Logemann 2022-01-29 12:52:23 +01:00
parent 7bccb2a280
commit 2d846dd5f3
47 changed files with 333 additions and 110 deletions

View file

@ -56,6 +56,7 @@ mapnik_option(USE_LOG "enables logging output. See log severity level." OFF)
set(USE_LOG_SEVERITY "1" CACHE STRING "sets the logging severity (only applies when USE_LOG is ON")
mapnik_option(USE_STATS "Enable statistics reporting" OFF)
mapnik_option(STATIC_PLUGINS "statically link plugins into libmapnik" OFF)
mapnik_option(USE_PLUGIN_INPUT_CSV "adds plugin input csv" ON)
mapnik_option(USE_PLUGIN_INPUT_GDAL "adds plugin input gdal" ON)
mapnik_option(USE_PLUGIN_INPUT_GEOBUF "adds plugin input geobuf" ON)
@ -344,6 +345,16 @@ if(NOT WIN32)
list(APPEND MAPNIK_OPTIONAL_LIBS ${CMAKE_DL_LIBS})
endif()
if(MAPNIK_STATIC_PLUGINS)
list(APPEND MAPNIK_COMPILE_DEFS MAPNIK_STATIC_PLUGINS)
endif()
# when building static, this have to be public so that all depending libs know about
if(NOT BUILD_SHARED_LIBS)
list(APPEND MAPNIK_COMPILE_DEFS MAPNIK_STATIC_DEFINE)
endif()
# force utf-8 source code processing
# see https://docs.microsoft.com/de-de/cpp/build/reference/utf-8-set-source-and-executable-character-sets-to-utf-8?view=msvc-170
add_compile_options("$<$<C_COMPILER_ID:MSVC>:/utf-8>")
@ -377,9 +388,18 @@ target_compile_definitions(core INTERFACE ${MAPNIK_COMPILE_DEFS})
mapnik_install(core)
# forward declaring libraries to consume them when building static plugins (circle deps between mapnik <-> plugin_target)
add_library(mapnik "")
add_library(mapnik::mapnik ALIAS mapnik)
add_library(wkt STATIC "")
add_library(mapnik::wkt ALIAS wkt)
add_library(json STATIC "")
add_library(mapnik::json ALIAS json)
# end forward declaration
add_subdirectory(deps)
add_subdirectory(src)
add_subdirectory(plugins)
add_subdirectory(src)
add_subdirectory(utils)
add_subdirectory(demo)
if(BUILD_BENCHMARK)

View file

@ -23,6 +23,9 @@ endfunction()
# Install plugins
#
function(mapnik_install_plugin _target)
if(MAPNIK_STATIC_PLUGINS)
return()
endif()
install(TARGETS ${_target}
RUNTIME DESTINATION ${PLUGINS_INSTALL_DIR}
COMPONENT MapnikPluginRuntime

View file

@ -26,13 +26,21 @@
// Windows DLL support
#ifdef _WIN32
# define MAPNIK_EXP __declspec (dllexport)
# define MAPNIK_IMP __declspec (dllimport)
# ifdef MAPNIK_EXPORTS
# define MAPNIK_DECL __declspec (dllexport)
# else
# define MAPNIK_DECL __declspec (dllimport)
#ifdef MAPNIK_STATIC_DEFINE
# define MAPNIK_DECL
# define MAPNIK_EXP
#else
# define MAPNIK_EXP __declspec(dllexport)
# ifndef MAPNIK_DECL
# ifdef MAPNIK_EXPORTS
/* We are building this library */
# define MAPNIK_DECL __declspec(dllexport)
# else
/* We are using this library */
# define MAPNIK_DECL __declspec(dllimport)
# endif
# endif
#endif
# pragma warning( disable: 4251 )
# pragma warning( disable: 4275 )
# if (_MSC_VER >= 1400) // vc8

View file

@ -136,15 +136,15 @@ using datasource_ptr = std::shared_ptr<datasource>;
#define DATASOURCE_PLUGIN(classname)
#else
#define DATASOURCE_PLUGIN(classname) \
extern "C" MAPNIK_EXP const char * datasource_name() \
extern "C" MAPNIK_DECL const char * datasource_name() \
{ \
return classname::name(); \
} \
extern "C" MAPNIK_EXP datasource* create(parameters const& params) \
extern "C" MAPNIK_DECL datasource* create(parameters const& params) \
{ \
return new classname(params); \
} \
extern "C" MAPNIK_EXP void destroy(datasource *ds) \
extern "C" MAPNIK_DECL void destroy(datasource *ds) \
{ \
delete ds; \
}

View file

@ -24,6 +24,7 @@
#define MAPNIK_WEBP_IO_HPP
// mapnik
#include <mapnik/config.hpp>
#include <mapnik/image.hpp>
#include <mapnik/util/conversions.hpp>
@ -51,26 +52,7 @@ int webp_stream_write(const uint8_t* data, size_t data_size, const WebPPicture*
return true;
}
std::string webp_encoding_error(WebPEncodingError error)
{
std::string os;
switch (error)
{
case VP8_ENC_ERROR_OUT_OF_MEMORY: os = "memory error allocating objects"; break;
case VP8_ENC_ERROR_BITSTREAM_OUT_OF_MEMORY: os = "memory error while flushing bits"; break;
case VP8_ENC_ERROR_NULL_PARAMETER: os = "a pointer parameter is NULL"; break;
case VP8_ENC_ERROR_INVALID_CONFIGURATION: os = "configuration is invalid"; break;
case VP8_ENC_ERROR_BAD_DIMENSION: os = "picture has invalid width/height"; break;
case VP8_ENC_ERROR_PARTITION0_OVERFLOW: os = "partition is bigger than 512k"; break;
case VP8_ENC_ERROR_PARTITION_OVERFLOW: os = "partition is bigger than 16M"; break;
case VP8_ENC_ERROR_BAD_WRITE: os = "error while flushing bytes"; break;
case VP8_ENC_ERROR_FILE_TOO_BIG: os = "file is bigger than 4G"; break;
default:
mapnik::util::to_string(os,error);
os = "unknown error (" + os + ")"; break;
}
return os;
}
std::string MAPNIK_DECL webp_encoding_error(WebPEncodingError error);
template <typename T2>
inline int import_image(T2 const& im_in,

View file

@ -1,5 +1,13 @@
set(_plugin_prefix "")
set(_plugin_suffix ".input")
set(_plugin_linkage MODULE)
set(_plugin_source_visibility PRIVATE)
if(MAPNIK_STATIC_PLUGINS)
set(_plugin_linkage INTERFACE)
set(_plugin_visibility INTERFACE)
endif()
add_subdirectory(base)
# add a list with all build plugins so the copy dependencies command can wait for all build events
set(m_build_plugins "")
@ -51,7 +59,7 @@ endif()
#
# Copy all plugin dlls, so that these are in the main output dir, since cmake copies those into ${MAPNIK_OUTPUT_DIR}/plugins/input, too.
#
if(WIN32)
if(NOT MAPNIK_STATIC_PLUGINS AND WIN32)
list(LENGTH m_build_plugins m_number_plugins)
if(m_number_plugins GREATER 0)
string(CONFIGURE

View file

@ -0,0 +1,11 @@
add_library(datasource-base INTERFACE)
add_library(mapnik::datasource-base ALIAS datasource-base)
target_include_directories(datasource-base INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
target_link_libraries(datasource-base INTERFACE mapnik::core)
mapnik_install(datasource-base)

View file

@ -0,0 +1,42 @@
#ifndef DATASOURCE_PLUGIN_HPP
#define DATASOURCE_PLUGIN_HPP
#include <string>
#include <mapnik/datasource.hpp>
#include <mapnik/config.hpp>
namespace mapnik
{
class MAPNIK_DECL datasource_plugin
{
public:
datasource_plugin() {}
virtual ~datasource_plugin() {}
virtual void init_once() const = 0;
virtual const std::string& name() const = 0;
virtual datasource_ptr create(parameters const &params) const= 0;
};
}
#define DATASOURCE_PLUGIN_DEF(classname, pluginname) class classname : public mapnik::datasource_plugin {\
public:\
static constexpr const char* kName = #pluginname;\
void init_once() const override;\
const std::string& name() const override;\
mapnik::datasource_ptr create(mapnik::parameters const &params) const override;\
};
#define DATASOURCE_PLUGIN_IMPL(classname, pluginclassname) const std::string& classname::name() const { return kName; } \
mapnik::datasource_ptr classname::create(mapnik::parameters const &params) const { return std::make_shared<pluginclassname>(params); }
#define DATASOURCE_PLUGIN_EMPTY_INIT(classname) void classname::init_once() const {}
#ifndef MAPNIK_STATIC_PLUGINS
#define DATASOURCE_PLUGIN_EXPORT(classname) extern "C" MAPNIK_EXP classname plugin; \
classname plugin;
#else
#define DATASOURCE_PLUGIN_EXPORT(classname) // export classname
#endif
#endif

View file

@ -1,14 +1,16 @@
add_library(input-csv MODULE
add_library(input-csv ${_plugin_linkage})
target_sources(input-csv ${_plugin_visibility}
csv_datasource.cpp
csv_featureset.cpp
csv_index_featureset.cpp
csv_inline_featureset.cpp
csv_utils.cpp
)
target_link_libraries(input-csv PRIVATE
target_link_libraries(input-csv ${_plugin_visibility}
mapnik::mapnik
mapnik::wkt
mapnik::json
mapnik::datasource-base
)
set_target_properties(input-csv PROPERTIES
OUTPUT_NAME "csv"

View file

@ -65,7 +65,10 @@ MAPNIK_DISABLE_WARNING_POP
using mapnik::datasource;
using mapnik::parameters;
DATASOURCE_PLUGIN(csv_datasource)
DATASOURCE_PLUGIN_IMPL(csv_datasource_plugin, csv_datasource);
DATASOURCE_PLUGIN_EXPORT(csv_datasource_plugin);
DATASOURCE_PLUGIN_EMPTY_INIT(csv_datasource_plugin);
csv_datasource::csv_datasource(parameters const& params)
: datasource(params),

View file

@ -48,6 +48,8 @@ MAPNIK_DISABLE_WARNING_POP
#include <vector>
#include <string>
#include <mapnik/datasource_plugin.hpp>
template <std::size_t Max, std::size_t Min>
struct csv_linear : boost::geometry::index::linear<Max,Min> {};
@ -70,6 +72,9 @@ struct options_type<csv_linear<Max,Min> >
};
}}}}}
DATASOURCE_PLUGIN_DEF(csv_datasource_plugin, csv);
class csv_datasource : public mapnik::datasource,
private csv_utils::csv_file_parser
{

View file

@ -1,12 +1,14 @@
find_package(GDAL REQUIRED)
add_library(input-gdal MODULE
add_library(input-gdal ${_plugin_linkage})
target_sources(input-gdal ${_plugin_visibility}
gdal_datasource.cpp
gdal_featureset.cpp
)
target_include_directories(input-gdal PRIVATE ${GDAL_INCLUDE_DIRS})
target_link_libraries(input-gdal PRIVATE
target_include_directories(input-gdal ${_plugin_visibility} ${GDAL_INCLUDE_DIRS})
target_link_libraries(input-gdal ${_plugin_visibility}
mapnik::mapnik
mapnik::datasource-base
${GDAL_LIBRARIES}
)
set_target_properties(input-gdal PROPERTIES

View file

@ -37,8 +37,6 @@
using mapnik::datasource;
using mapnik::parameters;
DATASOURCE_PLUGIN(gdal_datasource)
using mapnik::box2d;
using mapnik::coord2d;
using mapnik::query;
@ -48,9 +46,9 @@ using mapnik::datasource_exception;
static std::once_flag once_flag;
extern "C" MAPNIK_EXP void on_plugin_load()
{
// initialize gdal formats
DATASOURCE_PLUGIN_IMPL(gdal_datasource_plugin, gdal_datasource);
DATASOURCE_PLUGIN_EXPORT(gdal_datasource_plugin);
void gdal_datasource_plugin::init_once() const {
std::call_once(once_flag,[](){
GDALAllRegister();
});

View file

@ -31,7 +31,7 @@
#include <mapnik/geometry/box2d.hpp>
#include <mapnik/coord.hpp>
#include <mapnik/feature_layer_desc.hpp>
#include <mapnik/datasource_plugin.hpp>
// boost
#include <boost/optional.hpp>
@ -42,6 +42,8 @@
// gdal
#include <gdal_priv.h>
DATASOURCE_PLUGIN_DEF(gdal_datasource_plugin, gdal);
class gdal_datasource : public mapnik::datasource
{
public:

View file

@ -1,8 +1,12 @@
add_library(input-geobuf MODULE
add_library(input-geobuf ${_plugin_linkage})
target_sources(input-geobuf ${_plugin_visibility}
geobuf_datasource.cpp
geobuf_featureset.cpp
)
target_link_libraries(input-geobuf PRIVATE mapnik::mapnik)
target_link_libraries(input-geobuf ${_plugin_visibility}
mapnik::mapnik
mapnik::datasource-base
)
set_target_properties(input-geobuf PROPERTIES
OUTPUT_NAME "geobuf"
PREFIX "${_plugin_prefix}"

View file

@ -48,7 +48,9 @@
using mapnik::datasource;
using mapnik::parameters;
DATASOURCE_PLUGIN(geobuf_datasource)
DATASOURCE_PLUGIN_IMPL(geobuf_datasource_plugin, geobuf_datasource);
DATASOURCE_PLUGIN_EXPORT(geobuf_datasource_plugin);
DATASOURCE_PLUGIN_EMPTY_INIT(geobuf_datasource_plugin);
struct attr_value_converter
{

View file

@ -32,6 +32,7 @@
#include <mapnik/coord.hpp>
#include <mapnik/feature_layer_desc.hpp>
#include <mapnik/unicode.hpp>
#include <mapnik/datasource_plugin.hpp>
// boost
#include <boost/optional.hpp>
#include <mapnik/warning.hpp>
@ -75,6 +76,7 @@ struct options_type<geobuf_linear<Max,Min> >
}}}}}
DATASOURCE_PLUGIN_DEF(geobuf_datasource_plugin, geobuf);
class geobuf_datasource : public mapnik::datasource
{
public:

View file

@ -1,12 +1,14 @@
add_library(input-geojson MODULE
add_library(input-geojson ${_plugin_linkage})
target_sources(input-geojson ${_plugin_visibility}
geojson_datasource.cpp
geojson_featureset.cpp
geojson_index_featureset.cpp
geojson_memory_index_featureset.cpp
)
target_link_libraries(input-geojson PRIVATE
target_link_libraries(input-geojson ${_plugin_visibility}
mapnik::mapnik
mapnik::json
mapnik::datasource-base
)
set_target_properties(input-geojson PROPERTIES
OUTPUT_NAME "geojson"

View file

@ -67,7 +67,9 @@ MAPNIK_DISABLE_WARNING_POP
using mapnik::datasource;
using mapnik::parameters;
DATASOURCE_PLUGIN(geojson_datasource)
DATASOURCE_PLUGIN_IMPL(geojson_datasource_plugin, geojson_datasource);
DATASOURCE_PLUGIN_EXPORT(geojson_datasource_plugin);
DATASOURCE_PLUGIN_EMPTY_INIT(geojson_datasource_plugin);
struct attr_value_converter
{

View file

@ -32,6 +32,7 @@
#include <mapnik/coord.hpp>
#include <mapnik/feature_layer_desc.hpp>
#include <mapnik/unicode.hpp>
#include <mapnik/datasource_plugin.hpp>
#include <mapnik/warning.hpp>
MAPNIK_DISABLE_WARNING_PUSH
@ -73,6 +74,8 @@ struct options_type<geojson_linear<Max,Min> >
}}}}}
DATASOURCE_PLUGIN_DEF(geojson_datasource_plugin, geojson);
class geojson_datasource : public mapnik::datasource
{
public:

View file

@ -1,14 +1,16 @@
find_package(GDAL REQUIRED)
add_library(input-ogr MODULE
add_library(input-ogr ${_plugin_linkage})
target_sources(input-ogr ${_plugin_visibility}
ogr_converter.cpp
ogr_datasource.cpp
ogr_featureset.cpp
ogr_index_featureset.cpp
)
target_include_directories(input-ogr PRIVATE ${GDAL_INCLUDE_DIRS})
target_link_libraries(input-ogr PRIVATE
target_include_directories(input-ogr ${_plugin_visibility} ${GDAL_INCLUDE_DIRS})
target_link_libraries(input-ogr ${_plugin_visibility}
mapnik::mapnik
mapnik::datasource-base
${GDAL_LIBRARIES}
)
set_target_properties(input-ogr PROPERTIES

View file

@ -49,8 +49,6 @@ MAPNIK_DISABLE_WARNING_POP
using mapnik::datasource;
using mapnik::parameters;
DATASOURCE_PLUGIN(ogr_datasource)
using mapnik::box2d;
using mapnik::coord2d;
using mapnik::query;
@ -63,8 +61,9 @@ using mapnik::filter_at_point;
static std::once_flag once_flag;
extern "C" MAPNIK_EXP void on_plugin_load()
{
DATASOURCE_PLUGIN_IMPL(ogr_datasource_plugin, ogr_datasource);
DATASOURCE_PLUGIN_EXPORT(ogr_datasource_plugin);
void ogr_datasource_plugin::init_once() const {
// initialize ogr formats
// NOTE: in GDAL >= 2.0 this is the same as GDALAllRegister()
std::call_once(once_flag,[](){

View file

@ -31,6 +31,7 @@
#include <mapnik/geometry/box2d.hpp>
#include <mapnik/coord.hpp>
#include <mapnik/feature_layer_desc.hpp>
#include <mapnik/datasource_plugin.hpp>
// boost
#include <boost/optional.hpp>
@ -47,6 +48,8 @@ MAPNIK_DISABLE_WARNING_PUSH
MAPNIK_DISABLE_WARNING_POP
#include "ogr_layer_ptr.hpp"
DATASOURCE_PLUGIN_DEF(ogr_datasource_plugin, ogr);
class ogr_datasource : public mapnik::datasource
{
public:

View file

@ -1,12 +1,14 @@
find_package(PostgreSQL REQUIRED)
add_library(input-pgraster MODULE
add_library(input-pgraster ${_plugin_linkage})
target_sources(input-pgraster ${_plugin_visibility}
pgraster_datasource.cpp
pgraster_featureset.cpp
pgraster_wkb_reader.cpp
)
target_link_libraries(input-pgraster PRIVATE
target_link_libraries(input-pgraster ${_plugin_visibility}
mapnik::mapnik
mapnik::datasource-base
PostgreSQL::PostgreSQL
)
set_target_properties(input-pgraster PROPERTIES

View file

@ -51,7 +51,9 @@ MAPNIK_DISABLE_WARNING_POP
#include <set>
#include <sstream>
DATASOURCE_PLUGIN(pgraster_datasource)
DATASOURCE_PLUGIN_IMPL(pgraster_datasource_plugin, pgraster_datasource);
DATASOURCE_PLUGIN_EXPORT(pgraster_datasource_plugin);
DATASOURCE_PLUGIN_EMPTY_INIT(pgraster_datasource_plugin);
const std::string pgraster_datasource::RASTER_COLUMNS = "raster_columns";
const std::string pgraster_datasource::RASTER_OVERVIEWS = "raster_overviews";

View file

@ -37,6 +37,7 @@
#include <mapnik/feature_layer_desc.hpp>
#include <mapnik/unicode.hpp>
#include <mapnik/value/types.hpp>
#include <mapnik/datasource_plugin.hpp>
// boost
#include <boost/optional.hpp>
@ -74,6 +75,7 @@ struct pgraster_overview
};
DATASOURCE_PLUGIN_DEF(pgraster_datasource_plugin, pgraster);
class pgraster_datasource : public datasource
{
public:

View file

@ -1,11 +1,13 @@
find_package(PostgreSQL REQUIRED)
add_library(input-postgis MODULE
add_library(input-postgis ${_plugin_linkage})
target_sources(input-postgis ${_plugin_visibility}
postgis_datasource.cpp
postgis_featureset.cpp
)
target_link_libraries(input-postgis PRIVATE
target_link_libraries(input-postgis ${_plugin_visibility}
mapnik::mapnik
mapnik::datasource-base
PostgreSQL::PostgreSQL
)
set_target_properties(input-postgis PROPERTIES

View file

@ -49,7 +49,9 @@ MAPNIK_DISABLE_WARNING_POP
#include <set>
#include <sstream>
DATASOURCE_PLUGIN(postgis_datasource)
DATASOURCE_PLUGIN_IMPL(postgis_datasource_plugin, postgis_datasource);
DATASOURCE_PLUGIN_EXPORT(postgis_datasource_plugin);
DATASOURCE_PLUGIN_EMPTY_INIT(postgis_datasource_plugin);
const std::string postgis_datasource::GEOMETRY_COLUMNS = "geometry_columns";
const std::string postgis_datasource::SPATIAL_REF_SYS = "spatial_ref_system";

View file

@ -34,6 +34,7 @@
#include <mapnik/unicode.hpp>
#include <mapnik/value/types.hpp>
#include <mapnik/attribute.hpp>
#include <mapnik/datasource_plugin.hpp>
// boost
#include <boost/optional.hpp>
@ -62,6 +63,7 @@ using mapnik::coord2d;
using CnxPool_ptr = std::shared_ptr< ConnectionManager::PoolType>;
DATASOURCE_PLUGIN_DEF(postgis_datasource_plugin, postgis);
class postgis_datasource : public datasource
{
public:

View file

@ -1,9 +1,13 @@
add_library(input-raster MODULE
add_library(input-raster ${_plugin_linkage})
target_sources(input-raster ${_plugin_visibility}
raster_datasource.cpp
raster_featureset.cpp
raster_info.cpp
)
target_link_libraries(input-raster PRIVATE mapnik::mapnik)
target_link_libraries(input-raster ${_plugin_visibility}
mapnik::mapnik
mapnik::datasource-base
)
set_target_properties(input-raster PROPERTIES
OUTPUT_NAME "raster"
PREFIX "${_plugin_prefix}"

View file

@ -43,7 +43,9 @@ using mapnik::datasource;
using mapnik::parameters;
using mapnik::image_reader;
DATASOURCE_PLUGIN(raster_datasource)
DATASOURCE_PLUGIN_IMPL(raster_datasource_plugin, raster_datasource);
DATASOURCE_PLUGIN_EXPORT(raster_datasource_plugin);
DATASOURCE_PLUGIN_EMPTY_INIT(raster_datasource_plugin);
raster_datasource::raster_datasource(parameters const& params)
: datasource(params),

View file

@ -31,6 +31,7 @@
#include <mapnik/geometry/box2d.hpp>
#include <mapnik/coord.hpp>
#include <mapnik/feature_layer_desc.hpp>
#include <mapnik/datasource_plugin.hpp>
// boost
#include <boost/optional.hpp>
@ -40,6 +41,7 @@
#include <vector>
#include <string>
DATASOURCE_PLUGIN_DEF(raster_datasource_plugin, raster);
class raster_datasource : public mapnik::datasource
{

View file

@ -1,4 +1,5 @@
add_library(input-shape MODULE
add_library(input-shape ${_plugin_linkage})
target_sources(input-shape ${_plugin_visibility}
dbfile.cpp
dbf_test.cpp
shape_datasource.cpp
@ -6,7 +7,10 @@ add_library(input-shape MODULE
shape_index_featureset.cpp
shape_io.cpp shape_utils.cpp
)
target_link_libraries(input-shape PRIVATE mapnik::mapnik)
target_link_libraries(input-shape ${_plugin_visibility}
mapnik::mapnik
mapnik::datasource-base
)
set_target_properties(input-shape PROPERTIES
OUTPUT_NAME "shape"
PREFIX "${_plugin_prefix}"

View file

@ -47,7 +47,9 @@ MAPNIK_DISABLE_WARNING_POP
#include <sstream>
#include <stdexcept>
DATASOURCE_PLUGIN(shape_datasource)
DATASOURCE_PLUGIN_IMPL(shape_datasource_plugin, shape_datasource);
DATASOURCE_PLUGIN_EXPORT(shape_datasource_plugin);
DATASOURCE_PLUGIN_EMPTY_INIT(shape_datasource_plugin);
using mapnik::String;
using mapnik::Double;

View file

@ -32,6 +32,7 @@
#include <mapnik/coord.hpp>
#include <mapnik/feature_layer_desc.hpp>
#include <mapnik/value/types.hpp>
#include <mapnik/datasource_plugin.hpp>
// boost
#include <boost/optional.hpp>
@ -50,6 +51,8 @@ using mapnik::featureset_ptr;
using mapnik::layer_descriptor;
using mapnik::coord2d;
DATASOURCE_PLUGIN_DEF(shape_datasource_plugin, shape);
class shape_datasource : public datasource
{
public:

View file

@ -1,12 +1,13 @@
find_package(SQLite3 REQUIRED)
add_library(input-sqlite MODULE
add_library(input-sqlite ${_plugin_linkage})
target_sources(input-sqlite ${_plugin_visibility}
sqlite_datasource.cpp
sqlite_featureset.cpp
)
add_library(mapnik::plugin::input::sqlite ALIAS input-sqlite)
target_link_libraries(input-sqlite PRIVATE
target_link_libraries(input-sqlite ${_plugin_visibility}
mapnik::mapnik
mapnik::datasource-base
SQLite::SQLite3
)
set_target_properties(input-sqlite PROPERTIES

View file

@ -50,7 +50,9 @@ using mapnik::datasource_exception;
using mapnik::datasource;
using mapnik::parameters;
DATASOURCE_PLUGIN(sqlite_datasource)
DATASOURCE_PLUGIN_IMPL(sqlite_datasource_plugin, sqlite_datasource);
DATASOURCE_PLUGIN_EXPORT(sqlite_datasource_plugin);
DATASOURCE_PLUGIN_EMPTY_INIT(sqlite_datasource_plugin);
sqlite_datasource::sqlite_datasource(parameters const& params)
: datasource(params),

View file

@ -33,6 +33,7 @@
#include <mapnik/feature_layer_desc.hpp>
#include <mapnik/wkb.hpp>
#include <mapnik/value/types.hpp>
#include <mapnik/datasource_plugin.hpp>
// boost
#include <boost/optional.hpp>
@ -45,6 +46,8 @@
// sqlite
#include "sqlite_connection.hpp"
DATASOURCE_PLUGIN_DEF(sqlite_datasource_plugin, sqlite);
class sqlite_datasource : public mapnik::datasource
{
public:

View file

@ -1,11 +1,12 @@
add_library(input-topojson MODULE
add_library(input-topojson ${_plugin_linkage})
target_sources(input-topojson ${_plugin_visibility}
topojson_datasource.cpp
topojson_featureset.cpp
)
add_library(mapnik::plugin::input::topojson ALIAS input-topojson)
target_link_libraries(input-topojson PRIVATE
target_link_libraries(input-topojson ${_plugin_visibility}
mapnik::mapnik
mapnik::json
mapnik::datasource-base
)
set_target_properties(input-topojson PROPERTIES
OUTPUT_NAME "topojson"

View file

@ -42,7 +42,9 @@
using mapnik::datasource;
using mapnik::parameters;
DATASOURCE_PLUGIN(topojson_datasource)
DATASOURCE_PLUGIN_IMPL(topojson_datasource_plugin, topojson_datasource);
DATASOURCE_PLUGIN_EXPORT(topojson_datasource_plugin);
DATASOURCE_PLUGIN_EMPTY_INIT(topojson_datasource_plugin);
struct attr_value_converter
{

View file

@ -33,6 +33,7 @@
#include <mapnik/feature_layer_desc.hpp>
#include <mapnik/unicode.hpp>
#include <mapnik/json/topology.hpp>
#include <mapnik/datasource_plugin.hpp>
#include <mapnik/warning.hpp>
MAPNIK_DISABLE_WARNING_PUSH
@ -52,6 +53,8 @@ MAPNIK_DISABLE_WARNING_POP
#include <deque>
#include <memory>
DATASOURCE_PLUGIN_DEF(topojson_datasource_plugin, topojson);
class topojson_datasource : public mapnik::datasource
{
public:

View file

@ -1,15 +1,46 @@
add_subdirectory(json)
add_subdirectory(wkt)
add_library(mapnik "")
add_library(mapnik::mapnik ALIAS mapnik)
if(BUILD_SHARED_LIBS)
# private as this should only be visibile when building, to dllexport/dllimport correctly
target_compile_definitions(mapnik PRIVATE MAPNIK_EXPORTS)
endif()
target_link_libraries(mapnik PUBLIC mapnik::core)
target_link_libraries(mapnik PRIVATE mapnik::agg)
target_link_libraries(mapnik PUBLIC mapnik::core mapnik::datasource-base)
target_link_libraries(mapnik PRIVATE
mapnik::agg
# expr: if(MAPNIK_STATIC_PLUGINS == ON && <target> is build) then add link target
$<$<AND:$<BOOL:${MAPNIK_STATIC_PLUGINS}>,$<TARGET_EXISTS:input-csv>>:input-csv>
$<$<AND:$<BOOL:${MAPNIK_STATIC_PLUGINS}>,$<TARGET_EXISTS:input-gdal>>:input-gdal>
$<$<AND:$<BOOL:${MAPNIK_STATIC_PLUGINS}>,$<TARGET_EXISTS:input-geobuf>>:input-geobuf>
$<$<AND:$<BOOL:${MAPNIK_STATIC_PLUGINS}>,$<TARGET_EXISTS:input-geojson>>:input-geojson>
$<$<AND:$<BOOL:${MAPNIK_STATIC_PLUGINS}>,$<TARGET_EXISTS:input-ogr>>:input-ogr>
$<$<AND:$<BOOL:${MAPNIK_STATIC_PLUGINS}>,$<TARGET_EXISTS:input-pgraster>>:input-pgraster>
$<$<AND:$<BOOL:${MAPNIK_STATIC_PLUGINS}>,$<TARGET_EXISTS:input-postgis>>:input-postgis>
$<$<AND:$<BOOL:${MAPNIK_STATIC_PLUGINS}>,$<TARGET_EXISTS:input-raster>>:input-raster>
$<$<AND:$<BOOL:${MAPNIK_STATIC_PLUGINS}>,$<TARGET_EXISTS:input-shape>>:input-shape>
$<$<AND:$<BOOL:${MAPNIK_STATIC_PLUGINS}>,$<TARGET_EXISTS:input-sqlite>>:input-sqlite>
$<$<AND:$<BOOL:${MAPNIK_STATIC_PLUGINS}>,$<TARGET_EXISTS:input-topojson>>:input-topojson>
)
target_compile_definitions(mapnik PRIVATE
# expr: if(MAPNIK_STATIC_PLUGINS == ON && <target> is build) then add build definition
$<$<AND:$<BOOL:${MAPNIK_STATIC_PLUGINS}>,$<TARGET_EXISTS:input-csv>>:MAPNIK_STATIC_PLUGIN_CSV>
$<$<AND:$<BOOL:${MAPNIK_STATIC_PLUGINS}>,$<TARGET_EXISTS:input-gdal>>:MAPNIK_STATIC_PLUGIN_GDAL>
$<$<AND:$<BOOL:${MAPNIK_STATIC_PLUGINS}>,$<TARGET_EXISTS:input-geobuf>>:MAPNIK_STATIC_PLUGIN_GEOBUF>
$<$<AND:$<BOOL:${MAPNIK_STATIC_PLUGINS}>,$<TARGET_EXISTS:input-geojson>>:MAPNIK_STATIC_PLUGIN_GEOJSON>
$<$<AND:$<BOOL:${MAPNIK_STATIC_PLUGINS}>,$<TARGET_EXISTS:input-ogr>>:MAPNIK_STATIC_PLUGIN_OGR>
$<$<AND:$<BOOL:${MAPNIK_STATIC_PLUGINS}>,$<TARGET_EXISTS:input-pgraster>>:MAPNIK_STATIC_PLUGIN_PGRASTER>
$<$<AND:$<BOOL:${MAPNIK_STATIC_PLUGINS}>,$<TARGET_EXISTS:input-postgis>>:MAPNIK_STATIC_PLUGIN_POSTGIS>
$<$<AND:$<BOOL:${MAPNIK_STATIC_PLUGINS}>,$<TARGET_EXISTS:input-raster>>:MAPNIK_STATIC_PLUGIN_RASTER>
$<$<AND:$<BOOL:${MAPNIK_STATIC_PLUGINS}>,$<TARGET_EXISTS:input-shape>>:MAPNIK_STATIC_PLUGIN_SHAPE>
$<$<AND:$<BOOL:${MAPNIK_STATIC_PLUGINS}>,$<TARGET_EXISTS:input-sqlite>>:MAPNIK_STATIC_PLUGIN_SQLITE>
$<$<AND:$<BOOL:${MAPNIK_STATIC_PLUGINS}>,$<TARGET_EXISTS:input-topojson>>:MAPNIK_STATIC_PLUGIN_TOPOJSON>
)
if(MAPNIK_STATIC_PLUGINS)
target_include_directories(mapnik PRIVATE "${PROJECT_SOURCE_DIR}/plugins")
endif()
set_target_properties(mapnik PROPERTIES
DEBUG_POSTFIX "${MAPNIK_DEBUG_POSTFIX}"
@ -32,6 +63,7 @@ if(MSVC)
target_compile_options(mapnik PUBLIC "/bigobj" "/wd4068" "/wd4661" "/wd4910")
endif()
target_sources(mapnik PRIVATE
cairo_io.cpp
color_factory.cpp
@ -258,7 +290,10 @@ if(USE_TIFF)
endif()
if(USE_WEBP)
target_sources(mapnik PRIVATE webp_reader.cpp)
target_sources(mapnik PRIVATE
webp_reader.cpp
webp_io.cpp
)
endif()
if(USE_GRID_RENDERER)

View file

@ -26,15 +26,16 @@
#ifdef MAPNIK_STATIC_PLUGINS
#include <mapnik/params.hpp>
// boost
#include <boost/assign/list_of.hpp>
#include <mapnik/datasource_plugin.hpp>
#endif
// stl
#include <stdexcept>
#include <unordered_map>
#define REGISTER_STATIC_DATASOURCE_PLUGIN(classname) {std::string{classname::kName}, std::make_shared<classname>()}
// static plugin linkage
#ifdef MAPNIK_STATIC_PLUGINS
#if defined(MAPNIK_STATIC_PLUGIN_CSV)
@ -43,6 +44,9 @@
#if defined(MAPNIK_STATIC_PLUGIN_GDAL)
#include "input/gdal/gdal_datasource.hpp"
#endif
#if defined(MAPNIK_STATIC_PLUGIN_GEOBUF)
#include "input/geobuf/geobuf_datasource.hpp"
#endif
#if defined(MAPNIK_STATIC_PLUGIN_GEOJSON)
#include "input/geojson/geojson_datasource.hpp"
#endif
@ -58,6 +62,9 @@
#if defined(MAPNIK_STATIC_PLUGIN_OGR)
#include "input/ogr/ogr_datasource.hpp"
#endif
#if defined(MAPNIK_STATIC_PLUGIN_PGRASTER)
#include "input/pgraster/pgraster_datasource.hpp"
#endif
#if defined(MAPNIK_STATIC_PLUGIN_OSM)
#include "input/osm/osm_datasource.hpp"
#endif
@ -76,6 +83,9 @@
#if defined(MAPNIK_STATIC_PLUGIN_SQLITE)
#include "input/sqlite/sqlite_datasource.hpp"
#endif
#if defined(MAPNIK_STATIC_PLUGIN_TOPOJSON)
#include "input/topojson/topojson_datasource.hpp"
#endif
#endif
namespace mapnik {
@ -88,43 +98,52 @@ datasource_ptr ds_generator(parameters const& params)
}
typedef datasource_ptr (*ds_generator_ptr)(parameters const& params);
using datasource_map = std::unordered_map<std::string, ds_generator_ptr>;
using datasource_map = std::unordered_map<std::string, std::shared_ptr<datasource_plugin>>;
static datasource_map ds_map = boost::assign::map_list_of
static datasource_map ds_map{
#if defined(MAPNIK_STATIC_PLUGIN_CSV)
(std::string("csv"), &ds_generator<csv_datasource>)
REGISTER_STATIC_DATASOURCE_PLUGIN(csv_datasource_plugin),
#endif
#if defined(MAPNIK_STATIC_PLUGIN_GDAL)
(std::string("gdal"), &ds_generator<gdal_datasource>)
REGISTER_STATIC_DATASOURCE_PLUGIN(gdal_datasource_plugin),
#endif
#if defined(MAPNIK_STATIC_PLUGIN_GEOBUF)
REGISTER_STATIC_DATASOURCE_PLUGIN(geobuf_datasource_plugin),
#endif
#if defined(MAPNIK_STATIC_PLUGIN_GEOJSON)
(std::string("geojson"), &ds_generator<geojson_datasource>)
REGISTER_STATIC_DATASOURCE_PLUGIN(geojson_datasource_plugin),
#endif
#if defined(MAPNIK_STATIC_PLUGIN_OCCI)
(std::string("occi"), &ds_generator<occi_datasource>)
REGISTER_STATIC_DATASOURCE_PLUGIN(occi_datasource_plugin),
#endif
#if defined(MAPNIK_STATIC_PLUGIN_OGR)
(std::string("ogr"), &ds_generator<ogr_datasource>)
REGISTER_STATIC_DATASOURCE_PLUGIN(ogr_datasource_plugin),
#endif
#if defined(MAPNIK_STATIC_PLUGIN_PGRASTER)
REGISTER_STATIC_DATASOURCE_PLUGIN(pgraster_datasource_plugin),
#endif
#if defined(MAPNIK_STATIC_PLUGIN_OSM)
(std::string("osm"), &ds_generator<osm_datasource>)
REGISTER_STATIC_DATASOURCE_PLUGIN(osm_datasource_plugin),
#endif
#if defined(MAPNIK_STATIC_PLUGIN_POSTGIS)
(std::string("postgis"), &ds_generator<postgis_datasource>)
REGISTER_STATIC_DATASOURCE_PLUGIN(postgis_datasource_plugin),
#endif
#if defined(MAPNIK_STATIC_PLUGIN_RASTER)
(std::string("raster"), &ds_generator<raster_datasource>)
REGISTER_STATIC_DATASOURCE_PLUGIN(raster_datasource_plugin),
#endif
#if defined(MAPNIK_STATIC_PLUGIN_RASTERLITE)
(std::string("rasterlite"), &ds_generator<rasterlite_datasource>)
REGISTER_STATIC_DATASOURCE_PLUGIN(rasterlite_datasource_plugin),
#endif
#if defined(MAPNIK_STATIC_PLUGIN_SHAPE)
(std::string("shape"), &ds_generator<shape_datasource>)
REGISTER_STATIC_DATASOURCE_PLUGIN(shape_datasource_plugin),
#endif
#if defined(MAPNIK_STATIC_PLUGIN_SQLITE)
(std::string("sqlite"), &ds_generator<sqlite_datasource>)
REGISTER_STATIC_DATASOURCE_PLUGIN(sqlite_datasource_plugin),
#endif
;
#if defined(MAPNIK_STATIC_PLUGIN_TOPOJSON)
REGISTER_STATIC_DATASOURCE_PLUGIN(topojson_datasource_plugin),
#endif
};
#endif
#ifdef MAPNIK_STATIC_PLUGINS
@ -135,7 +154,7 @@ datasource_ptr create_static_datasource(parameters const& params)
datasource_map::iterator it = ds_map.find(*type);
if (it != ds_map.end())
{
ds = it->second(params);
ds = it->second->create(params);
}
return ds;
}

View file

@ -1,4 +1,4 @@
add_library(json STATIC
target_sources(json PRIVATE
extract_bounding_boxes_x3.cpp
feature_from_geojson.cpp
feature_grammar_x3.cpp
@ -13,7 +13,6 @@ add_library(json STATIC
topojson_grammar_x3.cpp
unicode_string_grammar_x3.cpp
)
add_library(mapnik::json ALIAS json)
target_include_directories(json PRIVATE
${JPEG_INCLUDE_DIR}

View file

@ -23,6 +23,8 @@
#include <mapnik/plugin.hpp>
#include <stdexcept>
#include <mapnik/datasource_plugin.hpp>
#ifdef _WIN32
#define NOMINMAX
#include <windows.h>
@ -58,12 +60,11 @@ PluginInfo::PluginInfo(std::string const& filename,
if (module_) module_->dl = LoadLibraryA(filename.c_str());
if (module_ && module_->dl)
{
callable_returning_string name_call = reinterpret_cast<callable_returning_string>(dlsym(module_->dl, library_name.c_str()));
if (name_call) name_ = name_call();
callable_returning_void init_once = reinterpret_cast<callable_returning_void>(dlsym(module_->dl, "on_plugin_load"));
if (init_once) {
init_once();
}
datasource_plugin* plugin = reinterpret_cast<datasource_plugin*>(dlsym(module_->dl, "plugin"));
if(!plugin)
throw std::runtime_error("plugin has a false interface"); //! todo: better error text
name_ = plugin->name();
plugin->init_once();
}
#else
#ifdef MAPNIK_HAS_DLCFN

24
src/webp_io.cpp Normal file
View file

@ -0,0 +1,24 @@
#include <mapnik/webp_io.hpp>
namespace mapnik {
std::string MAPNIK_DECL webp_encoding_error(WebPEncodingError error) {
std::string os;
switch (error)
{
case VP8_ENC_ERROR_OUT_OF_MEMORY: os = "memory error allocating objects"; break;
case VP8_ENC_ERROR_BITSTREAM_OUT_OF_MEMORY: os = "memory error while flushing bits"; break;
case VP8_ENC_ERROR_NULL_PARAMETER: os = "a pointer parameter is NULL"; break;
case VP8_ENC_ERROR_INVALID_CONFIGURATION: os = "configuration is invalid"; break;
case VP8_ENC_ERROR_BAD_DIMENSION: os = "picture has invalid width/height"; break;
case VP8_ENC_ERROR_PARTITION0_OVERFLOW: os = "partition is bigger than 512k"; break;
case VP8_ENC_ERROR_PARTITION_OVERFLOW: os = "partition is bigger than 16M"; break;
case VP8_ENC_ERROR_BAD_WRITE: os = "error while flushing bytes"; break;
case VP8_ENC_ERROR_FILE_TOO_BIG: os = "file is bigger than 4G"; break;
default:
mapnik::util::to_string(os,error);
os = "unknown error (" + os + ")"; break;
}
return os;
}
}

View file

@ -1,10 +1,9 @@
add_library(wkt STATIC
target_sources(wkt PRIVATE
geometry_to_wkt.cpp
mapnik_wkt_generator_grammar.cpp
wkt_factory.cpp
wkt_grammar_x3.cpp
)
add_library(mapnik::wkt ALIAS wkt)
target_include_directories(wkt PRIVATE
${MAPNIK_INCLUDE_PATH}