refactor datasource plugins

fix merge

remove old DATASOURCE_PLUGIN call

fix memory_datasource

wip

wip

fix temp return

fix install

wip before_unload

linux

remove docker

remove docker

comments

add windows error message if libmapnik=static and plugins=dynamic

fix false plugin macro

plugin default de/constructor to remove UB

simplyfy plugin targets - add fpic

fix makro

simplyfy

use unique_ptr for plugin handle

rename option static plugins

replace local init with fnc call

call setup everywhere

init datasource_static
This commit is contained in:
Mathis Logemann 2022-02-02 17:20:29 +01:00
parent 8a1f2579e9
commit 42f465f842
74 changed files with 474 additions and 519 deletions

View file

@ -1,3 +0,0 @@
build
.vs
.vscode

View file

@ -1,55 +0,0 @@
name: Docker Image CI
on:
push:
branches:
- "**"
tags:
- "v*.*.*"
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: "recursive"
- name: Docker meta
id: meta
uses: docker/metadata-action@v3
with:
# list of Docker images to use as base name for tags
images: |
ghcr.io/mathisloge/mapnik
# generate Docker tags based on the following events/attributes
tags: |
type=schedule
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to GHCR
if: github.event_name != 'pull_request'
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v2
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

View file

@ -29,6 +29,11 @@ add_feature_info(BUILD_TESTING BUILD_TESTING "Adds tests")
mapnik_option(INSTALL_DEPENDENCIES "if ON, all dependencies (eg. required dlls) will be copied into CMAKE_INSTALL_PREFIX/MAPNIK_BIN_DIR." ON) mapnik_option(INSTALL_DEPENDENCIES "if ON, all dependencies (eg. required dlls) will be copied into CMAKE_INSTALL_PREFIX/MAPNIK_BIN_DIR." ON)
mapnik_option(BUILD_SHARED_LIBS "build mapnik dynamic(ON) or static(OFF)" ON) mapnik_option(BUILD_SHARED_LIBS "build mapnik dynamic(ON) or static(OFF)" ON)
mapnik_option(BUILD_SHARED_PLUGINS "build dynamic plugins" ${BUILD_SHARED_LIBS}) # use BUILD_SHARED_LIBS as default option
if(WIN32 AND BUILD_SHARED_PLUGINS AND NOT BUILD_SHARED_LIBS)
message(FATAL_ERROR "static libmapnik and dynamic plugins won't work correctly")
endif()
mapnik_option(USE_EXTERNAL_MAPBOX_GEOMETRY "Use a external mapnik/geometry.hpp. If off, use the submodule" OFF) mapnik_option(USE_EXTERNAL_MAPBOX_GEOMETRY "Use a external mapnik/geometry.hpp. If off, use the submodule" OFF)
mapnik_option(USE_EXTERNAL_MAPBOX_POLYLABEL "Use a external mapnik/polylabel. If off, use the submodule" OFF) mapnik_option(USE_EXTERNAL_MAPBOX_POLYLABEL "Use a external mapnik/polylabel. If off, use the submodule" OFF)
mapnik_option(USE_EXTERNAL_MAPBOX_PROTOZERO "Use a external mapnik/protozero. If off, use the submodule" OFF) mapnik_option(USE_EXTERNAL_MAPBOX_PROTOZERO "Use a external mapnik/protozero. If off, use the submodule" OFF)
@ -56,7 +61,6 @@ 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") 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(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_CSV "adds plugin input csv" ON)
mapnik_option(USE_PLUGIN_INPUT_GDAL "adds plugin input gdal" ON) mapnik_option(USE_PLUGIN_INPUT_GDAL "adds plugin input gdal" ON)
mapnik_option(USE_PLUGIN_INPUT_GEOBUF "adds plugin input geobuf" ON) mapnik_option(USE_PLUGIN_INPUT_GEOBUF "adds plugin input geobuf" ON)
@ -345,11 +349,9 @@ if(NOT WIN32)
list(APPEND MAPNIK_OPTIONAL_LIBS ${CMAKE_DL_LIBS}) list(APPEND MAPNIK_OPTIONAL_LIBS ${CMAKE_DL_LIBS})
endif() endif()
if(MAPNIK_STATIC_PLUGINS) if(NOT BUILD_SHARED_PLUGINS)
list(APPEND MAPNIK_COMPILE_DEFS MAPNIK_STATIC_PLUGINS) list(APPEND MAPNIK_COMPILE_DEFS MAPNIK_STATIC_PLUGINS)
endif() endif()
# when building static, this have to be public so that all depending libs know about # when building static, this have to be public so that all depending libs know about
if(NOT BUILD_SHARED_LIBS) if(NOT BUILD_SHARED_LIBS)
list(APPEND MAPNIK_COMPILE_DEFS MAPNIK_STATIC_DEFINE) list(APPEND MAPNIK_COMPILE_DEFS MAPNIK_STATIC_DEFINE)
@ -388,6 +390,7 @@ target_compile_definitions(core INTERFACE ${MAPNIK_COMPILE_DEFS})
mapnik_install(core) mapnik_install(core)
###
# forward declaring libraries to consume them when building static plugins (circle deps between mapnik <-> plugin_target) # forward declaring libraries to consume them when building static plugins (circle deps between mapnik <-> plugin_target)
add_library(mapnik "") add_library(mapnik "")
add_library(mapnik::mapnik ALIAS mapnik) add_library(mapnik::mapnik ALIAS mapnik)
@ -396,6 +399,7 @@ add_library(mapnik::wkt ALIAS wkt)
add_library(json STATIC "") add_library(json STATIC "")
add_library(mapnik::json ALIAS json) add_library(mapnik::json ALIAS json)
# end forward declaration # end forward declaration
###
add_subdirectory(deps) add_subdirectory(deps)
add_subdirectory(plugins) add_subdirectory(plugins)
@ -416,22 +420,22 @@ feature_summary(FILENAME "${CMAKE_CURRENT_BINARY_DIR}/packages.log" WHAT PACKAGE
include(MapnikExport) include(MapnikExport)
include(MapnikExportPkgConfig) include(MapnikExportPkgConfig)
install(DIRECTORY include/ DESTINATION ${MAPNIK_INCLUDE_DIR}) install(DIRECTORY include/ DESTINATION "${MAPNIK_INCLUDE_DIR}")
install(DIRECTORY deps/agg/include/ DESTINATION ${MAPNIK_INCLUDE_DIR}) install(DIRECTORY deps/agg/include/ DESTINATION "${MAPNIK_INCLUDE_DIR}")
install(DIRECTORY deps/mapnik DESTINATION ${MAPNIK_INCLUDE_DIR}) install(DIRECTORY deps/mapnik DESTINATION "${MAPNIK_INCLUDE_DIR}")
install(DIRECTORY fonts/ DESTINATION ${FONTS_INSTALL_DIR} FILES_MATCHING PATTERN "*.py" EXCLUDE PATTERN "*") install(DIRECTORY fonts/ DESTINATION "${FONTS_INSTALL_DIR}" FILES_MATCHING PATTERN "*.py" EXCLUDE PATTERN "*")
if(NOT USE_EXTERNAL_MAPBOX_GEOMETRY) if(NOT USE_EXTERNAL_MAPBOX_GEOMETRY)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/deps/mapbox/geometry/include/ DESTINATION ${MAPNIK_INCLUDE_DIR}) install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/deps/mapbox/geometry/include/" DESTINATION "${MAPNIK_INCLUDE_DIR}")
endif() endif()
if(NOT USE_EXTERNAL_MAPBOX_POLYLABEL) if(NOT USE_EXTERNAL_MAPBOX_POLYLABEL)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/deps/mapbox/polylabel/include/ DESTINATION ${MAPNIK_INCLUDE_DIR}) install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/deps/mapbox/polylabel/include/" DESTINATION "${MAPNIK_INCLUDE_DIR}")
endif() endif()
if(NOT USE_EXTERNAL_MAPBOX_PROTOZERO) if(NOT USE_EXTERNAL_MAPBOX_PROTOZERO)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/deps/mapbox/protozero/include/ DESTINATION ${MAPNIK_INCLUDE_DIR}) install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/deps/mapbox/protozero/include/" DESTINATION "${MAPNIK_INCLUDE_DIR}")
endif() endif()
if(NOT USE_EXTERNAL_MAPBOX_VARIANT) if(NOT USE_EXTERNAL_MAPBOX_VARIANT)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/deps/mapbox/variant/include/ DESTINATION ${MAPNIK_INCLUDE_DIR}) install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/deps/mapbox/variant/include/" DESTINATION "${MAPNIK_INCLUDE_DIR}")
endif() endif()
mapnik_install_targets() mapnik_install_targets()

View file

@ -1,41 +0,0 @@
FROM ubuntu:21.04
LABEL description="mapnik"
ARG DEBIAN_FRONTEND=noninteractive
RUN mkdir /app
COPY . /app
WORKDIR /app
RUN apt update
RUN apt install -y gpg wget
RUN wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | tee /usr/share/keyrings/kitware-archive-keyring.gpg >/dev/null
RUN echo 'deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ focal main' | tee /etc/apt/sources.list.d/kitware.list >/dev/null
RUN apt update
RUN apt install -y \
cmake \
ninja-build \
build-essential
ENV BUILD_DEPENDENCIES="libicu-dev \
libfreetype6-dev \
libharfbuzz-dev \
libxml2-dev \
libjpeg-dev \
libtiff-dev \
libwebp-dev \
libcairo2-dev \
libproj-dev \
libgdal-dev \
libboost-filesystem-dev \
libboost-program-options-dev \
libboost-regex-dev \
"
RUN apt install -y $BUILD_DEPENDENCIES
RUN cmake --preset linux-gcc-release -DBUILD_DEMO_VIEWER=OFF -DBUILD_TESTING=OFF -DBUILD_DEMO_CPP=OFF -DBUILD_BENCHMARK=OFF
RUN cmake --build --preset linux-gcc-release
RUN cmake --build --preset linux-gcc-release --target install
WORKDIR /
RUN rm -rf /app

View file

@ -2,6 +2,7 @@
#define MAPNIK_BENCH_FRAMEWORK_HPP #define MAPNIK_BENCH_FRAMEWORK_HPP
// mapnik // mapnik
#include <mapnik/mapnik.hpp>
#include <mapnik/debug.hpp> #include <mapnik/debug.hpp>
#include <mapnik/params.hpp> #include <mapnik/params.hpp>
#include <mapnik/value/types.hpp> #include <mapnik/value/types.hpp>
@ -124,6 +125,7 @@ inline int handle_args(int argc, char** argv, mapnik::parameters& params)
#define BENCHMARK(test_class, name) \ #define BENCHMARK(test_class, name) \
int main(int argc, char** argv) \ int main(int argc, char** argv) \
{ \ { \
mapnik::setup(); \
try \ try \
{ \ { \
mapnik::parameters params; \ mapnik::parameters params; \

View file

@ -30,6 +30,7 @@ struct bench_func : benchmark::test_case
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
mapnik::setup();
return benchmark::sequencer(argc, argv) return benchmark::sequencer(argc, argv)
.BENCH_FUNC1(mapnik::util::normalize_angle, +3) .BENCH_FUNC1(mapnik::util::normalize_angle, +3)
.BENCH_FUNC1(mapnik::util::normalize_angle, +6) .BENCH_FUNC1(mapnik::util::normalize_angle, +6)

View file

@ -349,6 +349,7 @@ class test7 : public benchmark::test_case
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
mapnik::setup();
return benchmark::sequencer(argc, argv) return benchmark::sequencer(argc, argv)
.run<test4>("calloc") .run<test4>("calloc")
.run<test1>("malloc/memcpy") .run<test1>("malloc/memcpy")

View file

@ -36,6 +36,7 @@ class test : public benchmark::test_case
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
mapnik::setup();
mapnik::parameters params; mapnik::parameters params;
benchmark::handle_args(argc, argv, params); benchmark::handle_args(argc, argv, params);
test test_runner(params); test test_runner(params);

View file

@ -59,6 +59,7 @@ class test : public benchmark::test_case
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
mapnik::setup();
mapnik::parameters params; mapnik::parameters params;
benchmark::handle_args(argc, argv, params); benchmark::handle_args(argc, argv, params);
bool success = mapnik::freetype_engine::register_fonts("./fonts", true); bool success = mapnik::freetype_engine::register_fonts("./fonts", true);

View file

@ -101,6 +101,7 @@ class test2 : public benchmark::test_case
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
mapnik::setup();
int return_value = 0; int return_value = 0;
try try
{ {

View file

@ -74,5 +74,6 @@ class test_numeric : public benchmark::test_case
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
mapnik::setup();
return benchmark::sequencer(argc, argv).run<test_static>("static_cast").run<test_numeric>("numeric_cast").done(); return benchmark::sequencer(argc, argv).run<test_static>("static_cast").run<test_numeric>("numeric_cast").done();
} }

View file

@ -92,6 +92,7 @@ class test_offset : public benchmark::test_case
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
mapnik::setup();
mapnik::parameters params; mapnik::parameters params;
benchmark::handle_args(argc, argv, params); benchmark::handle_args(argc, argv, params);
int return_value = 0; int return_value = 0;

View file

@ -510,6 +510,7 @@ expected_count << "\n"; valid = false;
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
mapnik::setup();
mapnik::parameters params; mapnik::parameters params;
benchmark::handle_args(argc, argv, params); benchmark::handle_args(argc, argv, params);

View file

@ -43,6 +43,7 @@ class test : public benchmark::test_case
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
mapnik::setup();
mapnik::parameters params; mapnik::parameters params;
benchmark::handle_args(argc, argv, params); benchmark::handle_args(argc, argv, params);
mapnik::datasource_cache::instance().register_datasources("./plugins/input/"); mapnik::datasource_cache::instance().register_datasources("./plugins/input/");

View file

@ -60,6 +60,7 @@ class test : public benchmark::test_case
// echo -180 -60 | cs2cs -f "%.10f" epsg:4326 +to epsg:3857 // echo -180 -60 | cs2cs -f "%.10f" epsg:4326 +to epsg:3857
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
mapnik::setup();
mapnik::box2d<double> from(-180, -80, 180, 80); mapnik::box2d<double> from(-180, -80, 180, 80);
mapnik::box2d<double> to(-20037508.3427892476, -15538711.0963092316, 20037508.3427892476, 15538711.0963092316); mapnik::box2d<double> to(-20037508.3427892476, -15538711.0963092316, 20037508.3427892476, 15538711.0963092316);
std::string from_str("epsg:4326"); std::string from_str("epsg:4326");

View file

@ -95,6 +95,7 @@ class test : public benchmark::test_case
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
mapnik::setup();
int return_value = 0; int return_value = 0;
try try
{ {

View file

@ -150,6 +150,7 @@ class test : public benchmark::test_case
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
mapnik::setup();
int return_value = 0; int return_value = 0;
try try
{ {

View file

@ -106,6 +106,7 @@ class test3 : public benchmark::test_case
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
mapnik::setup();
mapnik::parameters params; mapnik::parameters params;
benchmark::handle_args(argc, argv, params); benchmark::handle_args(argc, argv, params);
int return_value = 0; int return_value = 0;

View file

@ -20,6 +20,7 @@
* *
*****************************************************************************/ *****************************************************************************/
#include <mapnik/mapnik.hpp>
#include <mapnik/map.hpp> #include <mapnik/map.hpp>
#include <mapnik/layer.hpp> #include <mapnik/layer.hpp>
#include <mapnik/rule.hpp> #include <mapnik/rule.hpp>
@ -52,7 +53,7 @@ int main(int, char**)
"+proj=lcc +ellps=GRS80 +lat_0=49 +lon_0=-95 +lat+1=49 +lat_2=77 +datum=NAD83 +units=m +no_defs"; "+proj=lcc +ellps=GRS80 +lat_0=49 +lon_0=-95 +lat+1=49 +lat_2=77 +datum=NAD83 +units=m +no_defs";
const std::string srs_merc = "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 " const std::string srs_merc = "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 "
"+units=m +nadgrids=@null +wktext +no_defs +over"; "+units=m +nadgrids=@null +wktext +no_defs +over";
mapnik::setup();
try try
{ {
std::cout << " running demo ... \n"; std::cout << " running demo ... \n";

View file

@ -23,12 +23,14 @@
#include <QSettings> #include <QSettings>
#include <mapnik/datasource_cache.hpp> #include <mapnik/datasource_cache.hpp>
#include <mapnik/font_engine_freetype.hpp> #include <mapnik/font_engine_freetype.hpp>
#include <mapnik/mapnik.hpp>
#include "mainwindow.hpp" #include "mainwindow.hpp"
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
using mapnik::datasource_cache; using mapnik::datasource_cache;
using mapnik::freetype_engine; using mapnik::freetype_engine;
mapnik::setup();
try try
{ {
#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0) #if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)

View file

@ -24,7 +24,7 @@
#define MAPNIK_CONFIG_HPP #define MAPNIK_CONFIG_HPP
// Windows DLL support // Windows DLL support
// clang-format off
#ifdef _WIN32 #ifdef _WIN32
#ifdef MAPNIK_STATIC_DEFINE #ifdef MAPNIK_STATIC_DEFINE
# define MAPNIK_DECL # define MAPNIK_DECL
@ -47,14 +47,6 @@
# pragma warning(disable : 4996) //_CRT_SECURE_NO_DEPRECATE # pragma warning(disable : 4996) //_CRT_SECURE_NO_DEPRECATE
# endif # endif
#else #else
#define MAPNIK_DECL __declspec(dllimport)
#endif
#pragma warning(disable: 4251)
#pragma warning(disable: 4275)
#if (_MSC_VER >= 1400) // vc8
#pragma warning(disable: 4996) //_CRT_SECURE_NO_DEPRECATE
#endif
#else
# if __GNUC__ >= 4 # if __GNUC__ >= 4
# define MAPNIK_EXP __attribute__ ((visibility ("default"))) # define MAPNIK_EXP __attribute__ ((visibility ("default")))
# define MAPNIK_DECL __attribute__ ((visibility ("default"))) # define MAPNIK_DECL __attribute__ ((visibility ("default")))
@ -65,7 +57,7 @@
# define MAPNIK_IMP # define MAPNIK_IMP
# endif # endif
#endif #endif
// clang-format on
#define PROJ_ENVELOPE_POINTS 20 #define PROJ_ENVELOPE_POINTS 20
#endif // MAPNIK_CONFIG_HPP #endif // MAPNIK_CONFIG_HPP

View file

@ -0,0 +1,9 @@
#ifndef MAPNIK_MAPNIK_HPP
#define MAPNIK_MAPNIK_HPP
#include "config.hpp"
namespace mapnik {
MAPNIK_DECL void setup();
}
#endif

View file

@ -26,12 +26,14 @@
// mapnik // mapnik
#include <mapnik/datasource.hpp> #include <mapnik/datasource.hpp>
#include <mapnik/feature_layer_desc.hpp> #include <mapnik/feature_layer_desc.hpp>
#include <mapnik/datasource_plugin.hpp>
// stl // stl
#include <deque> #include <deque>
namespace mapnik { namespace mapnik {
DATASOURCE_PLUGIN_DEF(memory_datasource_plugin, memory)
class MAPNIK_DECL memory_datasource : public datasource class MAPNIK_DECL memory_datasource : public datasource
{ {
friend class memory_featureset; friend class memory_featureset;

View file

@ -25,9 +25,9 @@
// mapnik // mapnik
#include <mapnik/util/noncopyable.hpp> #include <mapnik/util/noncopyable.hpp>
// stl // stl
#include <string> #include <string>
#include <memory>
namespace mapnik { namespace mapnik {
@ -50,8 +50,7 @@ class PluginInfo : util::noncopyable
private: private:
std::string filename_; std::string filename_;
std::string name_; std::unique_ptr<mapnik_lib_t> module_;
mapnik_lib_t* module_;
}; };
} // namespace mapnik } // namespace mapnik

View file

@ -1,6 +1,7 @@
#ifndef MAPNIK_WARNING_HPP #ifndef MAPNIK_WARNING_HPP
#define MAPNIK_WARNING_HPP #define MAPNIK_WARNING_HPP
// clang-format off
#if defined(_MSC_VER) #if defined(_MSC_VER)
#define MAPNIK_DISABLE_WARNING_PUSH __pragma(warning( push )) #define MAPNIK_DISABLE_WARNING_PUSH __pragma(warning( push ))
#define MAPNIK_DISABLE_WARNING_POP __pragma(warning( pop )) #define MAPNIK_DISABLE_WARNING_POP __pragma(warning( pop ))
@ -132,4 +133,5 @@
#define MAPNIK_DISABLE_UNUSED_VARIABLE #define MAPNIK_DISABLE_UNUSED_VARIABLE
#define MAPNIK_DISABLE_MISMATCHED_TAGS #define MAPNIK_DISABLE_MISMATCHED_TAGS
#endif #endif
// clang-format on
#endif #endif

View file

@ -1,12 +1,31 @@
set(_plugin_prefix "") set(_plugin_prefix "")
set(_plugin_suffix ".input") set(_plugin_suffix ".input")
set(_plugin_library_output "${MAPNIK_OUTPUT_DIR}/plugins/input")
set(_plugin_runtime_output "${MAPNIK_OUTPUT_DIR}")
set(_plugin_archive_output "${MAPNIK_OUTPUT_DIR}/lib")
set(_plugin_fpic ON)
set(_plugin_linkage MODULE) set(_plugin_linkage MODULE)
set(_plugin_source_visibility PRIVATE) set(_plugin_visibility PRIVATE)
if(MAPNIK_STATIC_PLUGINS) if(MAPNIK_STATIC_PLUGINS)
set(_plugin_linkage INTERFACE) set(_plugin_linkage INTERFACE)
set(_plugin_visibility INTERFACE) set(_plugin_visibility INTERFACE)
endif() endif()
macro(add_plugin_target plugin_target output_name)
add_library(${plugin_target} ${_plugin_linkage})
set_target_properties(${plugin_target} PROPERTIES
OUTPUT_NAME "${output_name}"
POSITION_INDEPENDENT_CODE ${_plugin_fpic}
PREFIX "${_plugin_prefix}"
SUFFIX "${_plugin_suffix}"
LIBRARY_OUTPUT_DIRECTORY "${_plugin_library_output}"
RUNTIME_OUTPUT_DIRECTORY "${_plugin_runtime_output}"
ARCHIVE_OUTPUT_DIRECTORY "${_plugin_archive_output}"
)
mapnik_install_plugin(${plugin_target})
endmacro()
add_subdirectory(base) add_subdirectory(base)
# add a list with all build plugins so the copy dependencies command can wait for all build events # add a list with all build plugins so the copy dependencies command can wait for all build events

View file

@ -9,3 +9,4 @@ target_include_directories(datasource-base INTERFACE
target_link_libraries(datasource-base INTERFACE mapnik::core) target_link_libraries(datasource-base INTERFACE mapnik::core)
mapnik_install(datasource-base) mapnik_install(datasource-base)
install(DIRECTORY include/ DESTINATION "${MAPNIK_INCLUDE_DIR}")

View file

@ -1,17 +1,18 @@
#ifndef DATASOURCE_PLUGIN_HPP #ifndef DATASOURCE_PLUGIN_HPP
#define DATASOURCE_PLUGIN_HPP #define DATASOURCE_PLUGIN_HPP
#include <string> #include <string>
#include <mapnik/datasource.hpp>
#include <mapnik/config.hpp> #include <mapnik/config.hpp>
#include <mapnik/datasource.hpp>
namespace mapnik { namespace mapnik {
class MAPNIK_DECL datasource_plugin class MAPNIK_DECL datasource_plugin
{ {
public: public:
datasource_plugin() {} datasource_plugin() = default;
virtual ~datasource_plugin() {} virtual ~datasource_plugin() = default;
virtual void init_once() const = 0; virtual void after_load() const = 0;
virtual const std::string& name() const = 0; virtual void before_unload() const = 0;
virtual const char* name() const = 0;
virtual datasource_ptr create(parameters const& params) const = 0; virtual datasource_ptr create(parameters const& params) const = 0;
}; };
} // namespace mapnik } // namespace mapnik
@ -21,20 +22,23 @@ class MAPNIK_DECL datasource_plugin
{ \ { \
public: \ public: \
static constexpr const char* kName = #pluginname; \ static constexpr const char* kName = #pluginname; \
void init_once() const override; \ void after_load() const override; \
const std::string& name() const override; \ void before_unload() const override; \
const char* name() const override; \
mapnik::datasource_ptr create(mapnik::parameters const& params) const override; \ mapnik::datasource_ptr create(mapnik::parameters const& params) const override; \
}; };
#define DATASOURCE_PLUGIN_IMPL(classname, pluginclassname) \ #define DATASOURCE_PLUGIN_IMPL(classname, pluginclassname) \
const std::string& classname::name() const { return kName; } \ const char* classname::name() const { return kName; } \
mapnik::datasource_ptr classname::create(mapnik::parameters const& params) const \ mapnik::datasource_ptr classname::create(mapnik::parameters const& params) const \
{ \ { \
return std::make_shared<pluginclassname>(params); \ return std::make_shared<pluginclassname>(params); \
} }
#define DATASOURCE_PLUGIN_EMPTY_INIT(classname) \ #define DATASOURCE_PLUGIN_EMPTY_AFTER_LOAD(classname) \
void classname::init_once() const {} void classname::after_load() const {}
#define DATASOURCE_PLUGIN_EMPTY_BEFORE_UNLOAD(classname) \
void classname::before_unload() const {}
#ifndef MAPNIK_STATIC_PLUGINS #ifndef MAPNIK_STATIC_PLUGINS
#define DATASOURCE_PLUGIN_EXPORT(classname) \ #define DATASOURCE_PLUGIN_EXPORT(classname) \

View file

@ -1,4 +1,5 @@
add_library(input-csv ${_plugin_linkage}) add_plugin_target(input-csv "csv")
target_sources(input-csv ${_plugin_visibility} target_sources(input-csv ${_plugin_visibility}
csv_datasource.cpp csv_datasource.cpp
csv_featureset.cpp csv_featureset.cpp
@ -12,12 +13,3 @@ target_link_libraries(input-csv ${_plugin_visibility}
mapnik::json mapnik::json
mapnik::datasource-base mapnik::datasource-base
) )
set_target_properties(input-csv PROPERTIES
OUTPUT_NAME "csv"
PREFIX "${_plugin_prefix}"
SUFFIX "${_plugin_suffix}"
LIBRARY_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}/plugins/input"
RUNTIME_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
ARCHIVE_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}/lib"
)
mapnik_install_plugin(input-csv)

View file

@ -67,7 +67,8 @@ using mapnik::parameters;
DATASOURCE_PLUGIN_IMPL(csv_datasource_plugin, csv_datasource); DATASOURCE_PLUGIN_IMPL(csv_datasource_plugin, csv_datasource);
DATASOURCE_PLUGIN_EXPORT(csv_datasource_plugin); DATASOURCE_PLUGIN_EXPORT(csv_datasource_plugin);
DATASOURCE_PLUGIN_EMPTY_INIT(csv_datasource_plugin); DATASOURCE_PLUGIN_EMPTY_AFTER_LOAD(csv_datasource_plugin);
DATASOURCE_PLUGIN_EMPTY_BEFORE_UNLOAD(csv_datasource_plugin);
csv_datasource::csv_datasource(parameters const& params) csv_datasource::csv_datasource(parameters const& params)
: datasource(params) : datasource(params)

View file

@ -1,6 +1,6 @@
find_package(GDAL REQUIRED) find_package(GDAL REQUIRED)
add_library(input-gdal ${_plugin_linkage}) add_plugin_target(input-gdal "gdal")
target_sources(input-gdal ${_plugin_visibility} target_sources(input-gdal ${_plugin_visibility}
gdal_datasource.cpp gdal_datasource.cpp
gdal_featureset.cpp gdal_featureset.cpp
@ -11,12 +11,4 @@ target_link_libraries(input-gdal ${_plugin_visibility}
mapnik::datasource-base mapnik::datasource-base
${GDAL_LIBRARIES} ${GDAL_LIBRARIES}
) )
set_target_properties(input-gdal PROPERTIES
OUTPUT_NAME "gdal"
PREFIX "${_plugin_prefix}"
SUFFIX "${_plugin_suffix}"
LIBRARY_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}/plugins/input"
RUNTIME_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
ARCHIVE_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}/lib"
)
mapnik_install_plugin(input-gdal)

View file

@ -44,13 +44,16 @@ using mapnik::featureset_ptr;
using mapnik::layer_descriptor; using mapnik::layer_descriptor;
using mapnik::query; using mapnik::query;
static std::once_flag once_flag;
DATASOURCE_PLUGIN_IMPL(gdal_datasource_plugin, gdal_datasource); DATASOURCE_PLUGIN_IMPL(gdal_datasource_plugin, gdal_datasource);
DATASOURCE_PLUGIN_EXPORT(gdal_datasource_plugin); DATASOURCE_PLUGIN_EXPORT(gdal_datasource_plugin);
void gdal_datasource_plugin::init_once() const void gdal_datasource_plugin::after_load() const
{ {
std::call_once(once_flag, []() { GDALAllRegister(); }); GDALAllRegister();
}
void gdal_datasource_plugin::before_unload() const
{
GDALDestroyDriverManager();
} }
gdal_datasource::gdal_datasource(parameters const& params) gdal_datasource::gdal_datasource(parameters const& params)

View file

@ -1,4 +1,5 @@
add_library(input-geobuf ${_plugin_linkage}) add_plugin_target(input-geobuf "geobuf")
target_sources(input-geobuf ${_plugin_visibility} target_sources(input-geobuf ${_plugin_visibility}
geobuf_datasource.cpp geobuf_datasource.cpp
geobuf_featureset.cpp geobuf_featureset.cpp
@ -7,12 +8,4 @@ target_link_libraries(input-geobuf ${_plugin_visibility}
mapnik::mapnik mapnik::mapnik
mapnik::datasource-base mapnik::datasource-base
) )
set_target_properties(input-geobuf PROPERTIES
OUTPUT_NAME "geobuf"
PREFIX "${_plugin_prefix}"
SUFFIX "${_plugin_suffix}"
LIBRARY_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}/plugins/input"
RUNTIME_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
ARCHIVE_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}/lib"
)
mapnik_install_plugin(input-geobuf)

View file

@ -50,7 +50,8 @@ using mapnik::parameters;
DATASOURCE_PLUGIN_IMPL(geobuf_datasource_plugin, geobuf_datasource); DATASOURCE_PLUGIN_IMPL(geobuf_datasource_plugin, geobuf_datasource);
DATASOURCE_PLUGIN_EXPORT(geobuf_datasource_plugin); DATASOURCE_PLUGIN_EXPORT(geobuf_datasource_plugin);
DATASOURCE_PLUGIN_EMPTY_INIT(geobuf_datasource_plugin); DATASOURCE_PLUGIN_EMPTY_AFTER_LOAD(geobuf_datasource_plugin);
DATASOURCE_PLUGIN_EMPTY_BEFORE_UNLOAD(geobuf_datasource_plugin);
struct attr_value_converter struct attr_value_converter
{ {

View file

@ -1,4 +1,4 @@
add_library(input-geojson ${_plugin_linkage}) add_plugin_target(input-geojson "geojson")
target_sources(input-geojson ${_plugin_visibility} target_sources(input-geojson ${_plugin_visibility}
geojson_datasource.cpp geojson_datasource.cpp
geojson_featureset.cpp geojson_featureset.cpp
@ -10,12 +10,3 @@ target_link_libraries(input-geojson ${_plugin_visibility}
mapnik::json mapnik::json
mapnik::datasource-base mapnik::datasource-base
) )
set_target_properties(input-geojson PROPERTIES
OUTPUT_NAME "geojson"
PREFIX "${_plugin_prefix}"
SUFFIX "${_plugin_suffix}"
LIBRARY_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}/plugins/input"
RUNTIME_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
ARCHIVE_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}/lib"
)
mapnik_install_plugin(input-geojson)

View file

@ -69,7 +69,8 @@ using mapnik::parameters;
DATASOURCE_PLUGIN_IMPL(geojson_datasource_plugin, geojson_datasource); DATASOURCE_PLUGIN_IMPL(geojson_datasource_plugin, geojson_datasource);
DATASOURCE_PLUGIN_EXPORT(geojson_datasource_plugin); DATASOURCE_PLUGIN_EXPORT(geojson_datasource_plugin);
DATASOURCE_PLUGIN_EMPTY_INIT(geojson_datasource_plugin); DATASOURCE_PLUGIN_EMPTY_AFTER_LOAD(geojson_datasource_plugin);
DATASOURCE_PLUGIN_EMPTY_BEFORE_UNLOAD(geojson_datasource_plugin);
struct attr_value_converter struct attr_value_converter
{ {

View file

@ -1,6 +1,6 @@
find_package(GDAL REQUIRED) find_package(GDAL REQUIRED)
add_library(input-ogr ${_plugin_linkage}) add_plugin_target(input-ogr "ogr")
target_sources(input-ogr ${_plugin_visibility} target_sources(input-ogr ${_plugin_visibility}
ogr_converter.cpp ogr_converter.cpp
ogr_datasource.cpp ogr_datasource.cpp
@ -13,12 +13,3 @@ target_link_libraries(input-ogr ${_plugin_visibility}
mapnik::datasource-base mapnik::datasource-base
${GDAL_LIBRARIES} ${GDAL_LIBRARIES}
) )
set_target_properties(input-ogr PROPERTIES
OUTPUT_NAME "ogr"
PREFIX "${_plugin_prefix}"
SUFFIX "${_plugin_suffix}"
LIBRARY_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}/plugins/input"
RUNTIME_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
ARCHIVE_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}/lib"
)
mapnik_install_plugin(input-ogr)

View file

@ -33,6 +33,7 @@
#include <mapnik/timer.hpp> #include <mapnik/timer.hpp>
#include <mapnik/util/utf_conv_win.hpp> #include <mapnik/util/utf_conv_win.hpp>
#include <mapnik/util/trim.hpp> #include <mapnik/util/trim.hpp>
#include <mapnik/datasource_plugin.hpp>
#include <mapnik/warning.hpp> #include <mapnik/warning.hpp>
MAPNIK_DISABLE_WARNING_PUSH MAPNIK_DISABLE_WARNING_PUSH
@ -49,8 +50,6 @@ MAPNIK_DISABLE_WARNING_POP
using mapnik::datasource; using mapnik::datasource;
using mapnik::parameters; using mapnik::parameters;
DATASOURCE_PLUGIN(ogr_datasource)
using mapnik::attribute_descriptor; using mapnik::attribute_descriptor;
using mapnik::box2d; using mapnik::box2d;
using mapnik::coord2d; using mapnik::coord2d;
@ -65,11 +64,19 @@ static std::once_flag once_flag;
DATASOURCE_PLUGIN_IMPL(ogr_datasource_plugin, ogr_datasource); DATASOURCE_PLUGIN_IMPL(ogr_datasource_plugin, ogr_datasource);
DATASOURCE_PLUGIN_EXPORT(ogr_datasource_plugin); DATASOURCE_PLUGIN_EXPORT(ogr_datasource_plugin);
void ogr_datasource_plugin::init_once() const
void ogr_datasource_plugin::after_load() const
{ {
// initialize ogr formats // initialize ogr formats
// NOTE: in GDAL >= 2.0 this is the same as GDALAllRegister() // NOTE: in GDAL >= 2.0 this is the same as GDALAllRegister()
std::call_once(once_flag, []() { OGRRegisterAll(); }); OGRRegisterAll();
}
void ogr_datasource_plugin::before_unload() const
{
// initialize ogr formats
// NOTE: in GDAL >= 2.0 this is the same as GDALDestroyDriverManager()
OGRCleanupAll();
} }
ogr_datasource::ogr_datasource(parameters const& params) ogr_datasource::ogr_datasource(parameters const& params)

View file

@ -1,6 +1,6 @@
find_package(PostgreSQL REQUIRED) find_package(PostgreSQL REQUIRED)
add_library(input-pgraster ${_plugin_linkage}) add_plugin_target(input-pgraster "pgraster")
target_sources(input-pgraster ${_plugin_visibility} target_sources(input-pgraster ${_plugin_visibility}
pgraster_datasource.cpp pgraster_datasource.cpp
pgraster_featureset.cpp pgraster_featureset.cpp
@ -11,12 +11,3 @@ target_link_libraries(input-pgraster ${_plugin_visibility}
mapnik::datasource-base mapnik::datasource-base
PostgreSQL::PostgreSQL PostgreSQL::PostgreSQL
) )
set_target_properties(input-pgraster PROPERTIES
OUTPUT_NAME "pgraster"
PREFIX "${_plugin_prefix}"
SUFFIX "${_plugin_suffix}"
LIBRARY_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}/plugins/input"
RUNTIME_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
ARCHIVE_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}/lib"
)
mapnik_install_plugin(input-pgraster)

View file

@ -53,7 +53,9 @@ MAPNIK_DISABLE_WARNING_POP
DATASOURCE_PLUGIN_IMPL(pgraster_datasource_plugin, pgraster_datasource); DATASOURCE_PLUGIN_IMPL(pgraster_datasource_plugin, pgraster_datasource);
DATASOURCE_PLUGIN_EXPORT(pgraster_datasource_plugin); DATASOURCE_PLUGIN_EXPORT(pgraster_datasource_plugin);
DATASOURCE_PLUGIN_EMPTY_INIT(pgraster_datasource_plugin); DATASOURCE_PLUGIN_EMPTY_AFTER_LOAD(pgraster_datasource_plugin);
DATASOURCE_PLUGIN_EMPTY_BEFORE_UNLOAD(pgraster_datasource_plugin);
const std::string pgraster_datasource::RASTER_COLUMNS = "raster_columns"; const std::string pgraster_datasource::RASTER_COLUMNS = "raster_columns";
const std::string pgraster_datasource::RASTER_OVERVIEWS = "raster_overviews"; const std::string pgraster_datasource::RASTER_OVERVIEWS = "raster_overviews";

View file

@ -1,6 +1,6 @@
find_package(PostgreSQL REQUIRED) find_package(PostgreSQL REQUIRED)
add_library(input-postgis ${_plugin_linkage}) add_plugin_target(input-postgis "postgis")
target_sources(input-postgis ${_plugin_visibility} target_sources(input-postgis ${_plugin_visibility}
postgis_datasource.cpp postgis_datasource.cpp
postgis_featureset.cpp postgis_featureset.cpp
@ -10,12 +10,3 @@ target_link_libraries(input-postgis ${_plugin_visibility}
mapnik::datasource-base mapnik::datasource-base
PostgreSQL::PostgreSQL PostgreSQL::PostgreSQL
) )
set_target_properties(input-postgis PROPERTIES
OUTPUT_NAME "postgis"
PREFIX "${_plugin_prefix}"
SUFFIX "${_plugin_suffix}"
LIBRARY_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}/plugins/input"
RUNTIME_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
ARCHIVE_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}/lib"
)
mapnik_install_plugin(input-postgis)

View file

@ -50,7 +50,8 @@ MAPNIK_DISABLE_WARNING_POP
DATASOURCE_PLUGIN_IMPL(postgis_datasource_plugin, postgis_datasource); DATASOURCE_PLUGIN_IMPL(postgis_datasource_plugin, postgis_datasource);
DATASOURCE_PLUGIN_EXPORT(postgis_datasource_plugin); DATASOURCE_PLUGIN_EXPORT(postgis_datasource_plugin);
DATASOURCE_PLUGIN_EMPTY_INIT(postgis_datasource_plugin); DATASOURCE_PLUGIN_EMPTY_AFTER_LOAD(postgis_datasource_plugin);
DATASOURCE_PLUGIN_EMPTY_BEFORE_UNLOAD(postgis_datasource_plugin);
const std::string postgis_datasource::GEOMETRY_COLUMNS = "geometry_columns"; const std::string postgis_datasource::GEOMETRY_COLUMNS = "geometry_columns";
const std::string postgis_datasource::SPATIAL_REF_SYS = "spatial_ref_system"; const std::string postgis_datasource::SPATIAL_REF_SYS = "spatial_ref_system";

View file

@ -1,4 +1,4 @@
add_library(input-raster ${_plugin_linkage}) add_plugin_target(input-raster "raster")
target_sources(input-raster ${_plugin_visibility} target_sources(input-raster ${_plugin_visibility}
raster_datasource.cpp raster_datasource.cpp
raster_featureset.cpp raster_featureset.cpp
@ -8,12 +8,3 @@ target_link_libraries(input-raster ${_plugin_visibility}
mapnik::mapnik mapnik::mapnik
mapnik::datasource-base mapnik::datasource-base
) )
set_target_properties(input-raster PROPERTIES
OUTPUT_NAME "raster"
PREFIX "${_plugin_prefix}"
SUFFIX "${_plugin_suffix}"
LIBRARY_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}/plugins/input"
RUNTIME_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
ARCHIVE_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}/lib"
)
mapnik_install_plugin(input-raster)

View file

@ -45,7 +45,8 @@ using mapnik::query;
DATASOURCE_PLUGIN_IMPL(raster_datasource_plugin, raster_datasource); DATASOURCE_PLUGIN_IMPL(raster_datasource_plugin, raster_datasource);
DATASOURCE_PLUGIN_EXPORT(raster_datasource_plugin); DATASOURCE_PLUGIN_EXPORT(raster_datasource_plugin);
DATASOURCE_PLUGIN_EMPTY_INIT(raster_datasource_plugin); DATASOURCE_PLUGIN_EMPTY_AFTER_LOAD(raster_datasource_plugin);
DATASOURCE_PLUGIN_EMPTY_BEFORE_UNLOAD(raster_datasource_plugin);
raster_datasource::raster_datasource(parameters const& params) raster_datasource::raster_datasource(parameters const& params)
: datasource(params) : datasource(params)

View file

@ -1,4 +1,4 @@
add_library(input-shape ${_plugin_linkage}) add_plugin_target(input-shape "shape")
target_sources(input-shape ${_plugin_visibility} target_sources(input-shape ${_plugin_visibility}
dbfile.cpp dbfile.cpp
dbf_test.cpp dbf_test.cpp
@ -11,12 +11,3 @@ target_link_libraries(input-shape ${_plugin_visibility}
mapnik::mapnik mapnik::mapnik
mapnik::datasource-base mapnik::datasource-base
) )
set_target_properties(input-shape PROPERTIES
OUTPUT_NAME "shape"
PREFIX "${_plugin_prefix}"
SUFFIX "${_plugin_suffix}"
LIBRARY_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}/plugins/input"
RUNTIME_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
ARCHIVE_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}/lib"
)
mapnik_install_plugin(input-shape)

View file

@ -49,7 +49,8 @@ MAPNIK_DISABLE_WARNING_POP
DATASOURCE_PLUGIN_IMPL(shape_datasource_plugin, shape_datasource); DATASOURCE_PLUGIN_IMPL(shape_datasource_plugin, shape_datasource);
DATASOURCE_PLUGIN_EXPORT(shape_datasource_plugin); DATASOURCE_PLUGIN_EXPORT(shape_datasource_plugin);
DATASOURCE_PLUGIN_EMPTY_INIT(shape_datasource_plugin); DATASOURCE_PLUGIN_EMPTY_AFTER_LOAD(shape_datasource_plugin);
DATASOURCE_PLUGIN_EMPTY_BEFORE_UNLOAD(shape_datasource_plugin);
using mapnik::attribute_descriptor; using mapnik::attribute_descriptor;
using mapnik::Boolean; using mapnik::Boolean;

View file

@ -1,6 +1,6 @@
find_package(SQLite3 REQUIRED) find_package(SQLite3 REQUIRED)
add_library(input-sqlite ${_plugin_linkage}) add_plugin_target(input-sqlite "sqlite")
target_sources(input-sqlite ${_plugin_visibility} target_sources(input-sqlite ${_plugin_visibility}
sqlite_datasource.cpp sqlite_datasource.cpp
sqlite_featureset.cpp sqlite_featureset.cpp
@ -10,12 +10,3 @@ target_link_libraries(input-sqlite ${_plugin_visibility}
mapnik::datasource-base mapnik::datasource-base
SQLite::SQLite3 SQLite::SQLite3
) )
set_target_properties(input-sqlite PROPERTIES
OUTPUT_NAME "sqlite"
PREFIX "${_plugin_prefix}"
SUFFIX "${_plugin_suffix}"
LIBRARY_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}/plugins/input"
RUNTIME_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
ARCHIVE_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}/lib"
)
mapnik_install_plugin(input-sqlite)

View file

@ -52,7 +52,8 @@ using mapnik::query;
DATASOURCE_PLUGIN_IMPL(sqlite_datasource_plugin, sqlite_datasource); DATASOURCE_PLUGIN_IMPL(sqlite_datasource_plugin, sqlite_datasource);
DATASOURCE_PLUGIN_EXPORT(sqlite_datasource_plugin); DATASOURCE_PLUGIN_EXPORT(sqlite_datasource_plugin);
DATASOURCE_PLUGIN_EMPTY_INIT(sqlite_datasource_plugin); DATASOURCE_PLUGIN_EMPTY_AFTER_LOAD(sqlite_datasource_plugin);
DATASOURCE_PLUGIN_EMPTY_BEFORE_UNLOAD(sqlite_datasource_plugin);
sqlite_datasource::sqlite_datasource(parameters const& params) sqlite_datasource::sqlite_datasource(parameters const& params)
: datasource(params) : datasource(params)

View file

@ -1,4 +1,4 @@
add_library(input-topojson ${_plugin_linkage}) add_plugin_target(input-topojson "topojson")
target_sources(input-topojson ${_plugin_visibility} target_sources(input-topojson ${_plugin_visibility}
topojson_datasource.cpp topojson_datasource.cpp
topojson_featureset.cpp topojson_featureset.cpp
@ -8,12 +8,3 @@ target_link_libraries(input-topojson ${_plugin_visibility}
mapnik::json mapnik::json
mapnik::datasource-base mapnik::datasource-base
) )
set_target_properties(input-topojson PROPERTIES
OUTPUT_NAME "topojson"
PREFIX "${_plugin_prefix}"
SUFFIX "${_plugin_suffix}"
LIBRARY_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}/plugins/input"
RUNTIME_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
ARCHIVE_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}/lib"
)
mapnik_install_plugin(input-topojson)

View file

@ -44,7 +44,8 @@ using mapnik::parameters;
DATASOURCE_PLUGIN_IMPL(topojson_datasource_plugin, topojson_datasource); DATASOURCE_PLUGIN_IMPL(topojson_datasource_plugin, topojson_datasource);
DATASOURCE_PLUGIN_EXPORT(topojson_datasource_plugin); DATASOURCE_PLUGIN_EXPORT(topojson_datasource_plugin);
DATASOURCE_PLUGIN_EMPTY_INIT(topojson_datasource_plugin); DATASOURCE_PLUGIN_EMPTY_AFTER_LOAD(topojson_datasource_plugin);
DATASOURCE_PLUGIN_EMPTY_BEFORE_UNLOAD(topojson_datasource_plugin);
struct attr_value_converter struct attr_value_converter
{ {

View file

@ -43,6 +43,7 @@ if(MAPNIK_STATIC_PLUGINS)
endif() endif()
set_target_properties(mapnik PROPERTIES set_target_properties(mapnik PROPERTIES
POSITION_INDEPENDENT_CODE ON
DEBUG_POSTFIX "${MAPNIK_DEBUG_POSTFIX}" DEBUG_POSTFIX "${MAPNIK_DEBUG_POSTFIX}"
OUTPUT_NAME "mapnik" OUTPUT_NAME "mapnik"
PREFIX "lib" PREFIX "lib"
@ -106,6 +107,7 @@ target_sources(mapnik PRIVATE
layer.cpp layer.cpp
load_map.cpp load_map.cpp
map.cpp map.cpp
mapnik.cpp
mapped_memory_cache.cpp mapped_memory_cache.cpp
marker_cache.cpp marker_cache.cpp
marker_helpers.cpp marker_helpers.cpp

View file

@ -0,0 +1,19 @@
#ifndef MAPNIK_CREATE_IMAGE_READER_HPP
#define MAPNIK_CREATE_IMAGE_READER_HPP
namespace mapnik {
#ifdef HAVE_JPEG
void register_jpeg_reader();
#endif
#ifdef HAVE_PNG
void register_png_reader();
#endif
#ifdef HAVE_TIFF
void register_tiff_reader();
#endif
#ifdef HAVE_WEBP
void register_webp_reader();
#endif
} // namespace mapnik
#endif

View file

@ -24,6 +24,7 @@
#include <mapnik/debug.hpp> #include <mapnik/debug.hpp>
#include <mapnik/datasource.hpp> #include <mapnik/datasource.hpp>
#include <mapnik/datasource_cache.hpp> #include <mapnik/datasource_cache.hpp>
#include <mapnik/datasource_plugin.hpp>
#include <mapnik/config_error.hpp> #include <mapnik/config_error.hpp>
#include <mapnik/params.hpp> #include <mapnik/params.hpp>
#include <mapnik/plugin.hpp> #include <mapnik/plugin.hpp>
@ -71,11 +72,9 @@ datasource_ptr datasource_cache::create(parameters const& params)
throw config_error(std::string("Could not create datasource. Required ") + "parameter 'type' is missing"); throw config_error(std::string("Could not create datasource. Required ") + "parameter 'type' is missing");
} }
datasource_ptr ds;
#ifdef MAPNIK_STATIC_PLUGINS #ifdef MAPNIK_STATIC_PLUGINS
// return if it's created, raise otherwise // return if it's created, raise otherwise
ds = create_static_datasource(params); datasource_ptr ds = create_static_datasource(params);
if (ds) if (ds)
{ {
return ds; return ds;
@ -114,16 +113,14 @@ datasource_ptr datasource_cache::create(parameters const& params)
#ifdef __GNUC__ #ifdef __GNUC__
__extension__ __extension__
#endif #endif
create_ds create_datasource = reinterpret_cast<create_ds>(itr->second->get_symbol("create")); datasource_plugin* create_datasource = reinterpret_cast<datasource_plugin*>(itr->second->get_symbol("plugin"));
if (!create_datasource) if (!create_datasource)
{ {
throw std::runtime_error(std::string("Cannot load symbols: ") + itr->second->get_error()); throw std::runtime_error(std::string("Cannot load symbols: ") + itr->second->get_error());
} }
ds = datasource_ptr(create_datasource(params), datasource_deleter()); return create_datasource->create(params);
return ds;
} }
std::string datasource_cache::plugin_directories() std::string datasource_cache::plugin_directories()

View file

@ -33,11 +33,6 @@
#include <stdexcept> #include <stdexcept>
#include <unordered_map> #include <unordered_map>
#define REGISTER_STATIC_DATASOURCE_PLUGIN(classname) \
{ \
std::string{classname::kName}, std::make_shared<classname>() \
}
// static plugin linkage // static plugin linkage
#ifdef MAPNIK_STATIC_PLUGINS #ifdef MAPNIK_STATIC_PLUGINS
#if defined(MAPNIK_STATIC_PLUGIN_CSV) #if defined(MAPNIK_STATIC_PLUGIN_CSV)
@ -90,9 +85,12 @@
#endif #endif
#endif #endif
#define REGISTER_STATIC_DATASOURCE_PLUGIN(classname) \
ds_map.emplace(std::string{classname::kName}, std::make_shared<classname>())
namespace mapnik { namespace mapnik {
#ifdef MAPNIK_STATIC_PLUGINS #ifdef MAPNIK_STATIC_PLUGINS
template<typename T> template<typename T>
datasource_ptr ds_generator(parameters const& params) datasource_ptr ds_generator(parameters const& params)
{ {
@ -102,54 +100,54 @@ datasource_ptr ds_generator(parameters const& params)
typedef datasource_ptr (*ds_generator_ptr)(parameters const& params); typedef datasource_ptr (*ds_generator_ptr)(parameters const& params);
using datasource_map = std::unordered_map<std::string, std::shared_ptr<datasource_plugin>>; using datasource_map = std::unordered_map<std::string, std::shared_ptr<datasource_plugin>>;
static datasource_map ds_map static datasource_map ds_map{};
void init_datasource_cache_static()
{ {
#if defined(MAPNIK_STATIC_PLUGIN_CSV) #if defined(MAPNIK_STATIC_PLUGIN_CSV)
REGISTER_STATIC_DATASOURCE_PLUGIN(csv_datasource_plugin), REGISTER_STATIC_DATASOURCE_PLUGIN(csv_datasource_plugin);
#endif #endif
#if defined(MAPNIK_STATIC_PLUGIN_GDAL) #if defined(MAPNIK_STATIC_PLUGIN_GDAL)
REGISTER_STATIC_DATASOURCE_PLUGIN(gdal_datasource_plugin), REGISTER_STATIC_DATASOURCE_PLUGIN(gdal_datasource_plugin);
#endif #endif
#if defined(MAPNIK_STATIC_PLUGIN_GEOBUF) #if defined(MAPNIK_STATIC_PLUGIN_GEOBUF)
REGISTER_STATIC_DATASOURCE_PLUGIN(geobuf_datasource_plugin), REGISTER_STATIC_DATASOURCE_PLUGIN(geobuf_datasource_plugin);
#endif #endif
#if defined(MAPNIK_STATIC_PLUGIN_GEOJSON) #if defined(MAPNIK_STATIC_PLUGIN_GEOJSON)
REGISTER_STATIC_DATASOURCE_PLUGIN(geojson_datasource_plugin), REGISTER_STATIC_DATASOURCE_PLUGIN(geojson_datasource_plugin);
#endif #endif
#if defined(MAPNIK_STATIC_PLUGIN_OCCI) #if defined(MAPNIK_STATIC_PLUGIN_OCCI)
REGISTER_STATIC_DATASOURCE_PLUGIN(occi_datasource_plugin), REGISTER_STATIC_DATASOURCE_PLUGIN(occi_datasource_plugin);
#endif #endif
#if defined(MAPNIK_STATIC_PLUGIN_OGR) #if defined(MAPNIK_STATIC_PLUGIN_OGR)
REGISTER_STATIC_DATASOURCE_PLUGIN(ogr_datasource_plugin), REGISTER_STATIC_DATASOURCE_PLUGIN(ogr_datasource_plugin);
#endif #endif
#if defined(MAPNIK_STATIC_PLUGIN_PGRASTER) #if defined(MAPNIK_STATIC_PLUGIN_PGRASTER)
REGISTER_STATIC_DATASOURCE_PLUGIN(pgraster_datasource_plugin), REGISTER_STATIC_DATASOURCE_PLUGIN(pgraster_datasource_plugin);
#endif #endif
#if defined(MAPNIK_STATIC_PLUGIN_OSM) #if defined(MAPNIK_STATIC_PLUGIN_OSM)
REGISTER_STATIC_DATASOURCE_PLUGIN(osm_datasource_plugin), REGISTER_STATIC_DATASOURCE_PLUGIN(osm_datasource_plugin);
#endif #endif
#if defined(MAPNIK_STATIC_PLUGIN_POSTGIS) #if defined(MAPNIK_STATIC_PLUGIN_POSTGIS)
REGISTER_STATIC_DATASOURCE_PLUGIN(postgis_datasource_plugin), REGISTER_STATIC_DATASOURCE_PLUGIN(postgis_datasource_plugin);
#endif #endif
#if defined(MAPNIK_STATIC_PLUGIN_RASTER) #if defined(MAPNIK_STATIC_PLUGIN_RASTER)
REGISTER_STATIC_DATASOURCE_PLUGIN(raster_datasource_plugin), REGISTER_STATIC_DATASOURCE_PLUGIN(raster_datasource_plugin);
#endif #endif
#if defined(MAPNIK_STATIC_PLUGIN_RASTERLITE) #if defined(MAPNIK_STATIC_PLUGIN_RASTERLITE)
REGISTER_STATIC_DATASOURCE_PLUGIN(rasterlite_datasource_plugin), REGISTER_STATIC_DATASOURCE_PLUGIN(rasterlite_datasource_plugin);
#endif #endif
#if defined(MAPNIK_STATIC_PLUGIN_SHAPE) #if defined(MAPNIK_STATIC_PLUGIN_SHAPE)
REGISTER_STATIC_DATASOURCE_PLUGIN(shape_datasource_plugin), REGISTER_STATIC_DATASOURCE_PLUGIN(shape_datasource_plugin);
#endif #endif
#if defined(MAPNIK_STATIC_PLUGIN_SQLITE) #if defined(MAPNIK_STATIC_PLUGIN_SQLITE)
REGISTER_STATIC_DATASOURCE_PLUGIN(sqlite_datasource_plugin), REGISTER_STATIC_DATASOURCE_PLUGIN(sqlite_datasource_plugin);
#endif #endif
#if defined(MAPNIK_STATIC_PLUGIN_TOPOJSON) #if defined(MAPNIK_STATIC_PLUGIN_TOPOJSON)
REGISTER_STATIC_DATASOURCE_PLUGIN(topojson_datasource_plugin), REGISTER_STATIC_DATASOURCE_PLUGIN(topojson_datasource_plugin);
#endif #endif
}; };
#endif
#ifdef MAPNIK_STATIC_PLUGINS
datasource_ptr create_static_datasource(parameters const& params) datasource_ptr create_static_datasource(parameters const& params)
{ {
datasource_ptr ds; datasource_ptr ds;

View file

@ -91,7 +91,6 @@ class jpeg_reader : public image_reader
static void attach_stream(j_decompress_ptr cinfo, input_stream* in); static void attach_stream(j_decompress_ptr cinfo, input_stream* in);
}; };
namespace {
image_reader* create_jpeg_reader(std::string const& filename) image_reader* create_jpeg_reader(std::string const& filename)
{ {
return new jpeg_reader<std::filebuf>(filename); return new jpeg_reader<std::filebuf>(filename);
@ -101,10 +100,11 @@ image_reader* create_jpeg_reader2(char const* data, size_t size)
{ {
return new jpeg_reader<mapnik::util::char_array_buffer>(data, size); return new jpeg_reader<mapnik::util::char_array_buffer>(data, size);
} }
void register_jpeg_reader()
{
const bool registered = register_image_reader("jpeg", create_jpeg_reader); const bool registered = register_image_reader("jpeg", create_jpeg_reader);
const bool registered2 = register_image_reader("jpeg", create_jpeg_reader2); const bool registered2 = register_image_reader("jpeg", create_jpeg_reader2);
} // namespace }
// ctors // ctors
template<typename T> template<typename T>

41
src/mapnik.cpp Normal file
View file

@ -0,0 +1,41 @@
#include <mapnik/mapnik.hpp>
#include <mutex> // call once
#include "create_image_reader.hpp"
namespace mapnik {
static void setup_once();
void setup()
{
static std::once_flag init_flag;
std::call_once(init_flag, setup_once);
}
#ifdef MAPNIK_STATIC_PLUGINS
extern void init_datasource_cache_static();
#endif
static void register_image_readers();
void setup_once()
{
#ifdef MAPNIK_STATIC_PLUGINS
init_datasource_cache_static(); // defined in datasource_cache_static.cpp
#endif
register_image_readers();
}
void register_image_readers()
{
#ifdef HAVE_JPEG
register_jpeg_reader();
#endif
#ifdef HAVE_PNG
register_png_reader();
#endif
#ifdef HAVE_TIFF
register_tiff_reader();
#endif
#ifdef HAVE_WEBP
register_webp_reader();
#endif
}
} // namespace mapnik

View file

@ -35,10 +35,15 @@
using mapnik::datasource; using mapnik::datasource;
using mapnik::parameters; using mapnik::parameters;
DATASOURCE_PLUGIN(mapnik::memory_datasource)
DATASOURCE_PLUGIN_EXPORT(mapnik::memory_datasource_plugin)
namespace mapnik { namespace mapnik {
DATASOURCE_PLUGIN_IMPL(memory_datasource_plugin, memory_datasource);
DATASOURCE_PLUGIN_EMPTY_AFTER_LOAD(memory_datasource_plugin);
DATASOURCE_PLUGIN_EMPTY_BEFORE_UNLOAD(memory_datasource_plugin);
struct accumulate_extent struct accumulate_extent
{ {
accumulate_extent(box2d<double>& ext) accumulate_extent(box2d<double>& ext)
@ -67,7 +72,7 @@ struct accumulate_extent
const char* memory_datasource::name() const char* memory_datasource::name()
{ {
return "memory"; return mapnik::memory_datasource_plugin::kName;
} }
memory_datasource::memory_datasource(parameters const& _params) memory_datasource::memory_datasource(parameters const& _params)

View file

@ -47,51 +47,13 @@ namespace mapnik {
struct _mapnik_lib_t struct _mapnik_lib_t
{ {
std::string name;
handle dl; handle dl;
}; _mapnik_lib_t()
: name{"unknown"}
PluginInfo::PluginInfo(std::string const& filename, std::string const& library_name) , dl{0}
: filename_(filename) {}
, name_() ~_mapnik_lib_t()
, module_(new mapnik_lib_t)
{
#ifdef _WIN32
if (module_)
module_->dl = LoadLibraryA(filename.c_str());
if (module_ && module_->dl)
{
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
if (module_)
module_->dl = dlopen(filename.c_str(), RTLD_LAZY);
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();
}
}
#else
throw std::runtime_error("no support for loading dynamic objects (Mapnik not compiled with -DMAPNIK_HAS_DLCFN)");
#endif
#endif
}
PluginInfo::~PluginInfo()
{
if (module_)
{ {
#ifdef MAPNIK_SUPPORTS_DLOPEN #ifdef MAPNIK_SUPPORTS_DLOPEN
/* /*
@ -105,16 +67,45 @@ PluginInfo::~PluginInfo()
in the case that gdal is linked as a shared library. This workaround therefore in the case that gdal is linked as a shared library. This workaround therefore
prevents crashes with gdal 1.11.x and gdal 2.x when using a static libgdal. prevents crashes with gdal 1.11.x and gdal 2.x when using a static libgdal.
*/ */
if (module_->dl && name_ != "gdal" && name_ != "ogr") if (dl /*&& name_ != "gdal" && name_ != "ogr"*/) // is the gdal issue sill present? We are now
// unregister all drivers for ogal and gdal (todo:
// before_unload call)
{ {
#ifndef MAPNIK_NO_DLCLOSE #ifndef MAPNIK_NO_DLCLOSE
dlclose(module_->dl), module_->dl = 0; dlclose(dl);
dl = 0;
#endif #endif
} }
#endif #endif
delete module_;
} }
};
PluginInfo::PluginInfo(std::string const& filename, std::string const& library_name)
: filename_(filename)
, module_{std::make_unique<mapnik_lib_t>()}
{
#if defined(_WIN32)
if (module_)
module_->dl = LoadLibraryA(filename.c_str());
#elif defined(MAPNIK_HAS_DLCFN)
if (module_)
module_->dl = dlopen(filename.c_str(), RTLD_LAZY);
#else
throw std::runtime_error("no support for loading dynamic objects (Mapnik not compiled with -DMAPNIK_HAS_DLCFN)");
#endif
#if defined(MAPNIK_HAS_DLCFN) || defined(_WIN32)
if (module_ && module_->dl)
{
datasource_plugin* plugin{reinterpret_cast<datasource_plugin*>(get_symbol("plugin"))};
if (!plugin)
throw std::runtime_error("plugin has a false interface"); //! todo: better error text
module_->name = plugin->name();
plugin->after_load();
} }
#endif
}
PluginInfo::~PluginInfo() {}
void* PluginInfo::get_symbol(std::string const& sym_name) const void* PluginInfo::get_symbol(std::string const& sym_name) const
{ {
@ -127,13 +118,13 @@ void* PluginInfo::get_symbol(std::string const& sym_name) const
std::string const& PluginInfo::name() const std::string const& PluginInfo::name() const
{ {
return name_; return module_->name;
} }
bool PluginInfo::valid() const bool PluginInfo::valid() const
{ {
#ifdef MAPNIK_SUPPORTS_DLOPEN #ifdef MAPNIK_SUPPORTS_DLOPEN
if (module_ && module_->dl && !name_.empty()) if (module_ && module_->dl && !module_->name.empty())
return true; return true;
#endif #endif
return false; return false;
@ -141,7 +132,7 @@ bool PluginInfo::valid() const
std::string PluginInfo::get_error() const std::string PluginInfo::get_error() const
{ {
return std::string("could not open: '") + name_ + "'"; return std::string("could not open: '") + module_->name + "'";
} }
void PluginInfo::init() void PluginInfo::init()

View file

@ -80,8 +80,6 @@ class png_reader : public image_reader
static void png_read_data(png_structp png_ptr, png_bytep data, png_size_t length); static void png_read_data(png_structp png_ptr, png_bytep data, png_size_t length);
}; };
namespace {
image_reader* create_png_reader(std::string const& filename) image_reader* create_png_reader(std::string const& filename)
{ {
return new png_reader<std::filebuf>(filename); return new png_reader<std::filebuf>(filename);
@ -92,9 +90,11 @@ image_reader* create_png_reader2(char const* data, std::size_t size)
return new png_reader<mapnik::util::char_array_buffer>(data, size); return new png_reader<mapnik::util::char_array_buffer>(data, size);
} }
void register_png_reader()
{
const bool registered = register_image_reader("png", create_png_reader); const bool registered = register_image_reader("png", create_png_reader);
const bool registered2 = register_image_reader("png", create_png_reader2); const bool registered2 = register_image_reader("png", create_png_reader2);
} // namespace }
void user_error_fn(png_structp /*png_ptr*/, png_const_charp error_msg) void user_error_fn(png_structp /*png_ptr*/, png_const_charp error_msg)
{ {

View file

@ -104,8 +104,6 @@ int tiff_map_proc(thandle_t, tdata_t*, toff_t*)
} }
} // namespace detail } // namespace detail
namespace {
image_reader* create_tiff_reader(std::string const& filename) image_reader* create_tiff_reader(std::string const& filename)
{ {
#if defined(MAPNIK_MEMORY_MAPPED_FILE) #if defined(MAPNIK_MEMORY_MAPPED_FILE)
@ -120,9 +118,10 @@ image_reader* create_tiff_reader2(char const* data, std::size_t size)
return new tiff_reader<mapnik::util::char_array_buffer>(data, size); return new tiff_reader<mapnik::util::char_array_buffer>(data, size);
} }
void register_tiff_reader()
{
const bool registered = register_image_reader("tiff", create_tiff_reader); const bool registered = register_image_reader("tiff", create_tiff_reader);
const bool registered2 = register_image_reader("tiff", create_tiff_reader2); const bool registered2 = register_image_reader("tiff", create_tiff_reader2);
}
} // namespace
} // namespace mapnik } // namespace mapnik

View file

@ -110,7 +110,6 @@ class webp_reader : public image_reader
void init(); void init();
}; };
namespace {
image_reader* create_webp_reader(char const* data, std::size_t size) image_reader* create_webp_reader(char const* data, std::size_t size)
{ {
return new webp_reader<external_buffer_policy>(data, size); return new webp_reader<external_buffer_policy>(data, size);
@ -121,10 +120,11 @@ image_reader* create_webp_reader2(std::string const& filename)
return new webp_reader<internal_buffer_policy>(filename); return new webp_reader<internal_buffer_policy>(filename);
} }
void register_webp_reader()
{
const bool registered = register_image_reader("webp", create_webp_reader); const bool registered = register_image_reader("webp", create_webp_reader);
const bool registered2 = register_image_reader("webp", create_webp_reader2); const bool registered2 = register_image_reader("webp", create_webp_reader2);
}
} // namespace
// ctor // ctor
template<typename T> template<typename T>

View file

@ -1,6 +1,7 @@
#define CATCH_CONFIG_MAIN #define CATCH_CONFIG_MAIN
#include "catch.hpp" #include "catch.hpp"
#include <mapnik/mapnik.hpp>
#include <mapnik/map.hpp> #include <mapnik/map.hpp>
#include <mapnik/memory_datasource.hpp> #include <mapnik/memory_datasource.hpp>
#include <mapnik/json/feature_parser.hpp> #include <mapnik/json/feature_parser.hpp>
@ -22,6 +23,7 @@ const std::string
TEST_CASE("agg_rasterizer_integer_overflow") TEST_CASE("agg_rasterizer_integer_overflow")
{ {
mapnik::setup();
SECTION("coordinates_do_not_overflow_and_polygon_is_rendered") SECTION("coordinates_do_not_overflow_and_polygon_is_rendered")
{ {
auto expected_color = mapnik::color("white"); auto expected_color = mapnik::color("white");

View file

@ -1,6 +1,7 @@
#define CATCH_CONFIG_MAIN #define CATCH_CONFIG_MAIN
#include "catch.hpp" #include "catch.hpp"
#include <mapnik/mapnik.hpp>
#include <mapnik/datasource_cache.hpp> #include <mapnik/datasource_cache.hpp>
#include <mapnik/debug.hpp> #include <mapnik/debug.hpp>
#include <mapnik/util/fs.hpp> #include <mapnik/util/fs.hpp>
@ -11,6 +12,7 @@
TEST_CASE("datasource_cache") TEST_CASE("datasource_cache")
{ {
mapnik::setup();
SECTION("registration") SECTION("registration")
{ {
try try

View file

@ -1,6 +1,7 @@
#define CATCH_CONFIG_MAIN #define CATCH_CONFIG_MAIN
#include "catch.hpp" #include "catch.hpp"
#include <mapnik/mapnik.hpp>
#include <mapnik/font_engine_freetype.hpp> #include <mapnik/font_engine_freetype.hpp>
#include <mapnik/util/fs.hpp> #include <mapnik/util/fs.hpp>
#include <mapnik/map.hpp> #include <mapnik/map.hpp>
@ -13,6 +14,7 @@
TEST_CASE("font") TEST_CASE("font")
{ {
mapnik::setup();
SECTION("registration") SECTION("registration")
{ {
try try

View file

@ -1,6 +1,7 @@
#define CATCH_CONFIG_MAIN #define CATCH_CONFIG_MAIN
#include "catch.hpp" #include "catch.hpp"
#include <mapnik/mapnik.hpp>
#include <mapnik/map.hpp> #include <mapnik/map.hpp>
#include <mapnik/load_map.hpp> #include <mapnik/load_map.hpp>
#include <mapnik/save_map.hpp> #include <mapnik/save_map.hpp>
@ -142,6 +143,7 @@ const bool registered =
TEST_CASE("map xml I/O") TEST_CASE("map xml I/O")
{ {
mapnik::setup();
// make sure plugins are loaded // make sure plugins are loaded
REQUIRE(registered); REQUIRE(registered);

View file

@ -2,6 +2,7 @@
#include "catch.hpp" #include "catch.hpp"
#include <string> #include <string>
#include <mapnik/mapnik.hpp>
#include <mapnik/util/fs.hpp> #include <mapnik/util/fs.hpp>
#include <mapnik/datasource_cache.hpp> #include <mapnik/datasource_cache.hpp>
#include <boost/filesystem/convenience.hpp> #include <boost/filesystem/convenience.hpp>
@ -20,6 +21,7 @@ int main(int argc, char** argv)
session.cli(cli); session.cli(cli);
int result = session.applyCommandLine(argc, argv); int result = session.applyCommandLine(argc, argv);
mapnik::setup();
if (!plugin_path.empty()) if (!plugin_path.empty())
{ {
if (!mapnik::util::exists(plugin_path)) if (!mapnik::util::exists(plugin_path))

View file

@ -23,6 +23,7 @@
#include "runner.hpp" #include "runner.hpp"
#include "config.hpp" #include "config.hpp"
#include <mapnik/mapnik.hpp>
#include <mapnik/datasource_cache.hpp> #include <mapnik/datasource_cache.hpp>
#include <mapnik/font_engine_freetype.hpp> #include <mapnik/font_engine_freetype.hpp>
@ -166,6 +167,7 @@ int main(int argc, char** argv)
return 1; return 1;
} }
mapnik::setup();
#ifdef MAPNIK_LOG #ifdef MAPNIK_LOG
std::string log_level(vm["log"].as<std::string>()); std::string log_level(vm["log"].as<std::string>());
log_levels_map::const_iterator level_iter = log_levels.find(log_level); log_levels_map::const_iterator level_iter = log_levels.find(log_level);

View file

@ -23,6 +23,7 @@
#include <iostream> #include <iostream>
#include <string> #include <string>
#include <mapnik/mapnik.hpp>
#include <mapnik/geometry.hpp> #include <mapnik/geometry.hpp>
#include <mapnik/feature.hpp> #include <mapnik/feature.hpp>
#include <mapnik/params.hpp> #include <mapnik/params.hpp>
@ -40,6 +41,7 @@ int main(int argc, char** argv)
std::cerr << "Geometry to WKB converter\n"; std::cerr << "Geometry to WKB converter\n";
mapnik::setup();
mapnik::datasource_cache::instance().register_datasources("/opt/mapnik/lib/mapnik/input/"); mapnik::datasource_cache::instance().register_datasources("/opt/mapnik/lib/mapnik/input/");
std::string filename(argv[1]); std::string filename(argv[1]);

View file

@ -24,6 +24,7 @@
#include <vector> #include <vector>
#include <string> #include <string>
#include <fstream> #include <fstream>
#include <mapnik/mapnik.hpp>
#include <mapnik/version.hpp> #include <mapnik/version.hpp>
#include <mapnik/util/fs.hpp> #include <mapnik/util/fs.hpp>
#include <mapnik/quad_tree.hpp> #include <mapnik/quad_tree.hpp>
@ -62,6 +63,7 @@ int main(int argc, char** argv)
{ {
// using namespace mapnik; // using namespace mapnik;
namespace po = boost::program_options; namespace po = boost::program_options;
mapnik::setup();
bool verbose = false; bool verbose = false;
bool validate_features = false; bool validate_features = false;
unsigned int depth = DEFAULT_DEPTH; unsigned int depth = DEFAULT_DEPTH;

View file

@ -1,3 +1,4 @@
#include <mapnik/mapnik.hpp>
#include <mapnik/map.hpp> #include <mapnik/map.hpp>
#include <mapnik/load_map.hpp> #include <mapnik/load_map.hpp>
#include <mapnik/agg_renderer.hpp> #include <mapnik/agg_renderer.hpp>
@ -21,6 +22,8 @@ int main(int argc, char** argv)
{ {
namespace po = boost::program_options; namespace po = boost::program_options;
mapnik::setup();
bool verbose = false; bool verbose = false;
bool auto_open = false; bool auto_open = false;
int return_value = 0; int return_value = 0;

View file

@ -27,6 +27,7 @@
#include <boost/algorithm/string.hpp> #include <boost/algorithm/string.hpp>
#include <boost/program_options.hpp> #include <boost/program_options.hpp>
#include <mapnik/mapnik.hpp>
#include <mapnik/datasource.hpp> #include <mapnik/datasource.hpp>
#include <mapnik/geometry/box2d.hpp> #include <mapnik/geometry/box2d.hpp>
#include <mapnik/feature.hpp> #include <mapnik/feature.hpp>
@ -60,6 +61,7 @@ int main(int argc, char** argv)
double ratio = DEFAULT_RATIO; double ratio = DEFAULT_RATIO;
vector<string> ogr_files; vector<string> ogr_files;
mapnik::setup();
try try
{ {
po::options_description desc("ogrindex utility"); po::options_description desc("ogrindex utility");

View file

@ -24,6 +24,7 @@
#include "pgsql2sqlite.hpp" #include "pgsql2sqlite.hpp"
#include <mapnik/datasource.hpp> #include <mapnik/datasource.hpp>
#include <mapnik/wkb.hpp> #include <mapnik/wkb.hpp>
#include <mapnik/mapnik.hpp>
#include "connection_manager.hpp" #include "connection_manager.hpp"
#include <mapnik/warning.hpp> #include <mapnik/warning.hpp>
@ -46,6 +47,7 @@ int main(int argc, char** argv)
po::options_description desc("Postgresql/PostGIS to SQLite3 converter\n Options"); po::options_description desc("Postgresql/PostGIS to SQLite3 converter\n Options");
std::string usage = "usage: pgsql2sqlite --dbname db --table planet_osm_line --file osm.sqlite --query \"select * " std::string usage = "usage: pgsql2sqlite --dbname db --table planet_osm_line --file osm.sqlite --query \"select * "
"from planet_osm_line\""; "from planet_osm_line\"";
mapnik::setup();
try try
{ {
// clang-format off // clang-format off

View file

@ -23,6 +23,7 @@
#include <iostream> #include <iostream>
#include <vector> #include <vector>
#include <string> #include <string>
#include <mapnik/mapnik.hpp>
#include <mapnik/version.hpp> #include <mapnik/version.hpp>
#include <mapnik/util/fs.hpp> #include <mapnik/util/fs.hpp>
#include <mapnik/quad_tree.hpp> #include <mapnik/quad_tree.hpp>
@ -58,6 +59,7 @@ int main(int argc, char** argv)
double ratio = DEFAULT_RATIO; double ratio = DEFAULT_RATIO;
std::vector<std::string> shape_files; std::vector<std::string> shape_files;
mapnik::setup();
try try
{ {
po::options_description desc("shapeindex utility"); po::options_description desc("shapeindex utility");

View file

@ -26,6 +26,7 @@
#include <string> #include <string>
#include <cmath> #include <cmath>
#include <mapnik/mapnik.hpp>
#include <mapnik/version.hpp> #include <mapnik/version.hpp>
#include <mapnik/debug.hpp> #include <mapnik/debug.hpp>
#include <mapnik/marker.hpp> #include <mapnik/marker.hpp>
@ -160,6 +161,7 @@ int main(int argc, char** argv)
bool strict = false; bool strict = false;
int status = 0; int status = 0;
std::vector<std::string> svg_files; std::vector<std::string> svg_files;
mapnik::setup();
mapnik::logger::instance().set_severity(mapnik::logger::error); mapnik::logger::instance().set_severity(mapnik::logger::error);
double scale_factor = 1.0; double scale_factor = 1.0;
std::string usage = "Usage: svg2png [options] <svg-file(s)>"; std::string usage = "Usage: svg2png [options] <svg-file(s)>";