Merge pull request #4291 from mathisloge/feature/cmake-static
Feature/cmake static plugins
This commit is contained in:
commit
4e064b8b8e
130 changed files with 1053 additions and 988 deletions
16
.github/actions/run_tests/action.yml
vendored
16
.github/actions/run_tests/action.yml
vendored
|
@ -27,14 +27,14 @@ runs:
|
||||||
|
|
||||||
- name: Test visuals (windows)
|
- name: Test visuals (windows)
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
working-directory: build/${{ inputs.cmake-preset }}/out
|
working-directory: build/out
|
||||||
shell: "pwsh"
|
shell: "pwsh"
|
||||||
if: runner.os == 'Windows'
|
if: runner.os == 'Windows'
|
||||||
run: OpenCppCoverage --modules *libmapnik* --modules mapnik*.exe --modules *.input --sources ${{ github.workspace }} --export_type binary --input_coverage=${{ github.workspace }}/ctest.cov --cover_children -- .\mapnik-test-visual.exe -j (Get-CimInstance -ClassName Win32_ComputerSystem).NumberOfLogicalProcessors --output-dir ./visual-test-result
|
run: OpenCppCoverage --modules *libmapnik* --modules mapnik*.exe --modules *.input --sources ${{ github.workspace }} --export_type binary --input_coverage=${{ github.workspace }}/ctest.cov --cover_children -- .\mapnik-test-visual.exe -j (Get-CimInstance -ClassName Win32_ComputerSystem).NumberOfLogicalProcessors --output-dir ./visual-test-result
|
||||||
|
|
||||||
- name: Test visuals (linux & mac)
|
- name: Test visuals (linux & mac)
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
working-directory: build/${{ inputs.cmake-preset }}/out
|
working-directory: build/out
|
||||||
shell: "bash"
|
shell: "bash"
|
||||||
if: runner.os != 'Windows'
|
if: runner.os != 'Windows'
|
||||||
run: |
|
run: |
|
||||||
|
@ -45,7 +45,7 @@ runs:
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Pack visual test results
|
- name: Pack visual test results
|
||||||
working-directory: build/${{ inputs.cmake-preset }}/out
|
working-directory: build/out
|
||||||
shell: "pwsh"
|
shell: "pwsh"
|
||||||
run: tar cfvz visual-test-results.tar.gz ./visual-test-result
|
run: tar cfvz visual-test-results.tar.gz ./visual-test-result
|
||||||
|
|
||||||
|
@ -60,16 +60,16 @@ runs:
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: ${{ inputs.cmake-preset }}-visual-tests-${{ steps.run-guid.outputs.GUID }}
|
name: ${{ inputs.cmake-preset }}-visual-tests-${{ steps.run-guid.outputs.GUID }}
|
||||||
path: build/${{ inputs.cmake-preset }}/out/visual-test-results.tar.gz
|
path: build/out/visual-test-results.tar.gz
|
||||||
|
|
||||||
- name: Run Benchmarks
|
- name: Run Benchmarks
|
||||||
working-directory: build/${{ inputs.cmake-preset }}/out
|
working-directory: build/out
|
||||||
if: runner.os != 'Windows'
|
if: runner.os != 'Windows'
|
||||||
shell: "pwsh"
|
shell: "pwsh"
|
||||||
run: ./run_benchmarks
|
run: ./run_benchmarks
|
||||||
|
|
||||||
- name: Collect coverage (linux & macos)
|
- name: Collect coverage (linux & macos)
|
||||||
working-directory: build/${{ inputs.cmake-preset }}
|
working-directory: build
|
||||||
if: runner.os != 'Windows'
|
if: runner.os != 'Windows'
|
||||||
shell: "bash"
|
shell: "bash"
|
||||||
run: |
|
run: |
|
||||||
|
@ -81,10 +81,10 @@ runs:
|
||||||
if: runner.os != 'Windows'
|
if: runner.os != 'Windows'
|
||||||
uses: codecov/codecov-action@v3
|
uses: codecov/codecov-action@v3
|
||||||
with:
|
with:
|
||||||
files: build/${{ inputs.cmake-preset }}/coverage.info
|
files: build/coverage.info
|
||||||
|
|
||||||
- name: Upload coverage to Codecov (windows)
|
- name: Upload coverage to Codecov (windows)
|
||||||
if: runner.os == 'Windows'
|
if: runner.os == 'Windows'
|
||||||
uses: codecov/codecov-action@v3
|
uses: codecov/codecov-action@v3
|
||||||
with:
|
with:
|
||||||
files: build/${{ inputs.cmake-preset }}/out/mapnik-test-visual.cov
|
files: build/out/mapnik-test-visual.cov
|
||||||
|
|
3
.github/workflows/build_and_test.yml
vendored
3
.github/workflows/build_and_test.yml
vendored
|
@ -32,6 +32,7 @@ jobs:
|
||||||
matrix:
|
matrix:
|
||||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
os: [macos-latest, windows-latest, ubuntu-latest]
|
||||||
memory-mapped: ["OFF", "ON"]
|
memory-mapped: ["OFF", "ON"]
|
||||||
|
static-build: ["OFF", "ON"]
|
||||||
include:
|
include:
|
||||||
- os: ubuntu-latest
|
- os: ubuntu-latest
|
||||||
mono: mono
|
mono: mono
|
||||||
|
@ -82,7 +83,7 @@ jobs:
|
||||||
echo "PRESET=${{ steps.lc_platform.outputs.lowercase }}-ci" >>${GITHUB_ENV}
|
echo "PRESET=${{ steps.lc_platform.outputs.lowercase }}-ci" >>${GITHUB_ENV}
|
||||||
|
|
||||||
- name: Configure CMake
|
- name: Configure CMake
|
||||||
run: cmake -DUSE_MEMORY_MAPPED_FILE=${{ matrix.memory-mapped }} --preset ${{ env.PRESET }}
|
run: cmake -DUSE_MEMORY_MAPPED_FILE=${{ matrix.memory-mapped }} -DBUILD_SHARED_LIBS=${{ matrix.static-build }} --preset ${{ env.PRESET }}
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: cmake --build --preset ${{ env.PRESET }}
|
run: cmake --build --preset ${{ env.PRESET }}
|
||||||
|
|
|
@ -12,6 +12,12 @@ For a complete change history, see the git log.
|
||||||
#### Notice
|
#### Notice
|
||||||
|
|
||||||
- Mapnik now requires C++14 compliant compiler (`-std=c++14`)
|
- Mapnik now requires C++14 compliant compiler (`-std=c++14`)
|
||||||
|
- Mapnik now supports CMake as a build system. See [#4191](https://github.com/mapnik/mapnik/pull/4191) and the [docs](https://github.com/mapnik/mapnik/blob/master/docs/cmake-usage.md) for more info.
|
||||||
|
|
||||||
|
#### Breaking Changes
|
||||||
|
|
||||||
|
- Reworked datasource plugin system. Plugins now need to implement a class with the macros in `datasource_plugin.hpp` ([#4291](https://github.com/mapnik/mapnik/pull/4291))
|
||||||
|
- mapnik now has a global `mapnik::setup()` method which have to be called before any other functions of mapnik. Defined in `mapnik.hpp`. Currently there is a auto setup functionality. It can be disabled using the cmake option `DISABLE_MAPNIK_AUTOSETUP=ON`. Note: In order not to insert this change into every code base, it is currently still called during the dynamic initialisation time. However, if mapnik is compiled statically, this function must be called. ([#4291](https://github.com/mapnik/mapnik/pull/4291))
|
||||||
|
|
||||||
#### Core
|
#### Core
|
||||||
|
|
||||||
|
@ -27,6 +33,7 @@ For a complete change history, see the git log.
|
||||||
- Slightly improved `sql_utils::table_from_sql` ([2587bb3](https://github.com/mapnik/mapnik/commit/2587bb3a1d8db397acfa8dcc2d332da3a8a9399f))
|
- Slightly improved `sql_utils::table_from_sql` ([2587bb3](https://github.com/mapnik/mapnik/commit/2587bb3a1d8db397acfa8dcc2d332da3a8a9399f))
|
||||||
- Added wrappers for proper quoting in SQL query construction: `sql_utils::identifier`, `sql_utils::literal` ([7b21713](https://github.com/mapnik/mapnik/commit/7b217133e2749b82c2638551045c4edbece15086))
|
- Added wrappers for proper quoting in SQL query construction: `sql_utils::identifier`, `sql_utils::literal` ([7b21713](https://github.com/mapnik/mapnik/commit/7b217133e2749b82c2638551045c4edbece15086))
|
||||||
- Added two-argument `sql_utils::unquote`, `sql_utils::unquote_copy` that also collapse inner quotes ([a4e8ea2](https://github.com/mapnik/mapnik/commit/a4e8ea21be297d89bbf36ba594d6c661a7a9ac81))
|
- Added two-argument `sql_utils::unquote`, `sql_utils::unquote_copy` that also collapse inner quotes ([a4e8ea2](https://github.com/mapnik/mapnik/commit/a4e8ea21be297d89bbf36ba594d6c661a7a9ac81))
|
||||||
|
- Fixed mapnik static build with static plugins ([#4291](https://github.com/mapnik/mapnik/pull/4291))
|
||||||
- Reworked mapnik::enumeration<...> ([#4372](https://github.com/mapnik/mapnik/pull/4372))
|
- Reworked mapnik::enumeration<...> ([#4372](https://github.com/mapnik/mapnik/pull/4372))
|
||||||
|
|
||||||
#### Plugins
|
#### Plugins
|
||||||
|
|
108
CMakeLists.txt
108
CMakeLists.txt
|
@ -16,6 +16,7 @@ message(STATUS "mapnik version: ${PROJECT_VERSION}")
|
||||||
# https://cliutils.gitlab.io/modern-cmake/chapters/features/ides.html
|
# https://cliutils.gitlab.io/modern-cmake/chapters/features/ides.html
|
||||||
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
||||||
|
|
||||||
|
set(CMAKE_FIND_PACKAGE_TARGETS_GLOBAL ON) # with newer cmake versions put all find_package in global scope
|
||||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
||||||
include(FeatureSummary)
|
include(FeatureSummary)
|
||||||
include(MapnikOption)
|
include(MapnikOption)
|
||||||
|
@ -27,8 +28,13 @@ include(CTest)
|
||||||
add_feature_info(BUILD_TESTING BUILD_TESTING "Adds tests")
|
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
|
||||||
|
mapnik_option(BUILD_SHARED_CRT "(only windows with msvc) use msvc shared crt" ON)
|
||||||
|
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,6 +62,8 @@ 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(DISABLE_MAPNIK_AUTOSETUP "disables the autosetup. Need to call mapnik::setup() then" 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)
|
||||||
|
@ -87,18 +95,6 @@ mapnik_option(USE_GLIBC_WORKAROUND "see https://github.com/mapnik/mapnik/pull/37
|
||||||
feature_summary(WHAT ENABLED_FEATURES DISABLED_FEATURES)
|
feature_summary(WHAT ENABLED_FEATURES DISABLED_FEATURES)
|
||||||
feature_summary(FILENAME "${CMAKE_CURRENT_BINARY_DIR}/features.log" WHAT ENABLED_FEATURES DISABLED_FEATURES)
|
feature_summary(FILENAME "${CMAKE_CURRENT_BINARY_DIR}/features.log" WHAT ENABLED_FEATURES DISABLED_FEATURES)
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 14 CACHE STRING "Sets the c++ standard. c++14 is minimum.")
|
|
||||||
message(STATUS "Using c++${CMAKE_CXX_STANDARD}")
|
|
||||||
# https://cmake.org/cmake/help/latest/prop_tgt/CXX_EXTENSIONS.html
|
|
||||||
set(CXX_EXTENSIONS OFF CACHE STRING "Enables the compiler specific extensions.") # Fallsback to -std=c++<ver> if off
|
|
||||||
message(STATUS "Using c++ extensions: ${CXX_EXTENSIONS}")
|
|
||||||
# https://cmake.org/cmake/help/latest/prop_tgt/CXX_STANDARD_REQUIRED.html#prop_tgt:CXX_STANDARD_REQUIRED
|
|
||||||
set(CXX_STANDARD_REQUIRED ON) # require the specified CMAKE_CXX_STANDARD
|
|
||||||
|
|
||||||
# add debug postfix to the libraries
|
|
||||||
set(MAPNIK_DEBUG_POSTFIX "d" CACHE STRING "sets the debug library postfix on mapnik, wkt and json")
|
|
||||||
message(STATUS "postfix for debug libraries: ${MAPNIK_DEBUG_POSTFIX}")
|
|
||||||
|
|
||||||
include(GNUInstallDirs)
|
include(GNUInstallDirs)
|
||||||
# See for more details: https://cmake.org/cmake/help/latest/manual/cmake-buildsystem.7.html
|
# See for more details: https://cmake.org/cmake/help/latest/manual/cmake-buildsystem.7.html
|
||||||
set(MAPNIK_BIN_DIR ${CMAKE_INSTALL_BINDIR} CACHE STRING "Install directory for binaries")
|
set(MAPNIK_BIN_DIR ${CMAKE_INSTALL_BINDIR} CACHE STRING "Install directory for binaries")
|
||||||
|
@ -123,9 +119,29 @@ set(MAPNIK_COMPILE_DEFS "")
|
||||||
set(MAPNIK_OPTIONAL_LIBS "")
|
set(MAPNIK_OPTIONAL_LIBS "")
|
||||||
set(MAPNIK_OPTIONAL_LIBS_INCLUDE "")
|
set(MAPNIK_OPTIONAL_LIBS_INCLUDE "")
|
||||||
|
|
||||||
|
#############################
|
||||||
|
#############################
|
||||||
# Begin project configuration
|
# Begin project configuration
|
||||||
|
#############################
|
||||||
|
#############################
|
||||||
|
|
||||||
|
set(CMAKE_CXX_STANDARD 14 CACHE STRING "Sets the c++ standard. c++14 is minimum.")
|
||||||
|
set(CMAKE_CXX_STANDARD_REQUIRED ON) # require the specified CMAKE_CXX_STANDARD
|
||||||
|
set(CMAKE_CXX_EXTENSIONS OFF CACHE STRING "Enables the compiler specific extensions.") # Fallsback to -std=c++<ver> if off
|
||||||
|
message(STATUS "Using c++${CMAKE_CXX_STANDARD}")
|
||||||
|
message(STATUS "Using c++ extensions: ${CXX_EXTENSIONS}")
|
||||||
|
|
||||||
|
# add debug postfix to the libraries
|
||||||
|
set(CMAKE_DEBUG_POSTFIX "d" CACHE STRING "sets the debug library postfix on mapnik, wkt and json")
|
||||||
|
message(STATUS "postfix for debug libraries: ${CMAKE_DEBUG_POSTFIX}")
|
||||||
|
|
||||||
|
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>$<$<BOOL:${BUILD_SHARED_CRT}>:DLL>")
|
||||||
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}")
|
||||||
|
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}")
|
||||||
|
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}/lib")
|
||||||
|
|
||||||
# needs to be before the first call of find_boost.
|
# needs to be before the first call of find_boost.
|
||||||
|
list(APPEND MAPNIK_COMPILE_DEFS BOOST_SPIRIT_X3_HIDE_CXX17_WARNING)
|
||||||
if(USE_MULTITHREADED)
|
if(USE_MULTITHREADED)
|
||||||
set(Boost_USE_MULTITHREADED ON)
|
set(Boost_USE_MULTITHREADED ON)
|
||||||
list(APPEND MAPNIK_COMPILE_DEFS MAPNIK_THREADSAFE)
|
list(APPEND MAPNIK_COMPILE_DEFS MAPNIK_THREADSAFE)
|
||||||
|
@ -134,7 +150,7 @@ else()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
find_package(PkgConfig)
|
mapnik_find_package(PkgConfig REQUIRED)
|
||||||
mapnik_find_threads()
|
mapnik_find_threads()
|
||||||
mapnik_find_package(ICU REQUIRED COMPONENTS uc i18n data)
|
mapnik_find_package(ICU REQUIRED COMPONENTS uc i18n data)
|
||||||
|
|
||||||
|
@ -163,7 +179,7 @@ else()
|
||||||
# It might be possible that in future version harfbuzz could only be found via pkg-config.
|
# It might be possible that in future version harfbuzz could only be found via pkg-config.
|
||||||
# harfbuzz related discussion: https://github.com/harfbuzz/harfbuzz/issues/2653
|
# harfbuzz related discussion: https://github.com/harfbuzz/harfbuzz/issues/2653
|
||||||
message(STATUS "harfbuzz not found via cmake. Searching via pkg-config...")
|
message(STATUS "harfbuzz not found via cmake. Searching via pkg-config...")
|
||||||
pkg_check_modules(harfbuzz REQUIRED IMPORTED_TARGET harfbuzz>=${HARFBUZZ_MIN_VERSION})
|
mapnik_pkg_check_modules(harfbuzz REQUIRED IMPORTED_TARGET harfbuzz>=${HARFBUZZ_MIN_VERSION})
|
||||||
list(APPEND MAPNIK_OPTIONAL_LIBS PkgConfig::harfbuzz)
|
list(APPEND MAPNIK_OPTIONAL_LIBS PkgConfig::harfbuzz)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@ -290,20 +306,15 @@ if(USE_TIFF)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(USE_WEBP)
|
if(USE_WEBP)
|
||||||
mapnik_find_package(WebP REQUIRED)
|
mapnik_pkg_check_modules(WebP REQUIRED IMPORTED_TARGET libwebp)
|
||||||
list(APPEND MAPNIK_COMPILE_DEFS HAVE_WEBP)
|
list(APPEND MAPNIK_COMPILE_DEFS HAVE_WEBP)
|
||||||
list(APPEND MAPNIK_OPTIONAL_LIBS WebP::WebP)
|
list(APPEND MAPNIK_OPTIONAL_LIBS PkgConfig::WebP)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(USE_CAIRO)
|
if(USE_CAIRO)
|
||||||
if(WIN32)
|
mapnik_pkg_check_modules(Cairo REQUIRED IMPORTED_TARGET cairo)
|
||||||
mapnik_find_package(Cairo REQUIRED)
|
|
||||||
list(APPEND MAPNIK_OPTIONAL_LIBS Cairo::Cairo)
|
|
||||||
else()
|
|
||||||
pkg_check_modules(Cairo REQUIRED IMPORTED_TARGET cairo)
|
|
||||||
list(APPEND MAPNIK_OPTIONAL_LIBS PkgConfig::Cairo)
|
|
||||||
endif()
|
|
||||||
list(APPEND MAPNIK_COMPILE_DEFS HAVE_CAIRO)
|
list(APPEND MAPNIK_COMPILE_DEFS HAVE_CAIRO)
|
||||||
|
list(APPEND MAPNIK_OPTIONAL_LIBS PkgConfig::Cairo)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(USE_PROJ)
|
if(USE_PROJ)
|
||||||
|
@ -312,7 +323,7 @@ if(USE_PROJ)
|
||||||
# currently the cmake files are not installed, when installing proj via apt-get. So search via pkg-config
|
# currently the cmake files are not installed, when installing proj via apt-get. So search via pkg-config
|
||||||
if(NOT PROJ_FOUND)
|
if(NOT PROJ_FOUND)
|
||||||
message(STATUS "PROJ not found via FindPROJ. Searching via pkg-config...")
|
message(STATUS "PROJ not found via FindPROJ. Searching via pkg-config...")
|
||||||
pkg_check_modules(PROJ REQUIRED IMPORTED_TARGET proj>=${PROJ_MIN_VERSION})
|
mapnik_pkg_check_modules(PROJ REQUIRED IMPORTED_TARGET proj>=${PROJ_MIN_VERSION})
|
||||||
string(REGEX MATCH "([0-9]+)\.([0-9]+)\.([0-9]+)" _dummy "${PROJ_VERSION}")
|
string(REGEX MATCH "([0-9]+)\.([0-9]+)\.([0-9]+)" _dummy "${PROJ_VERSION}")
|
||||||
set(PROJ_VERSION_MAJOR "${CMAKE_MATCH_1}")
|
set(PROJ_VERSION_MAJOR "${CMAKE_MATCH_1}")
|
||||||
set(PROJ_VERSION_MINOR "${CMAKE_MATCH_2}")
|
set(PROJ_VERSION_MINOR "${CMAKE_MATCH_2}")
|
||||||
|
@ -344,10 +355,24 @@ if(NOT WIN32)
|
||||||
list(APPEND MAPNIK_OPTIONAL_LIBS ${CMAKE_DL_LIBS})
|
list(APPEND MAPNIK_OPTIONAL_LIBS ${CMAKE_DL_LIBS})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(NOT BUILD_SHARED_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()
|
||||||
|
|
||||||
|
if(DISABLE_MAPNIK_AUTOSETUP)
|
||||||
|
list(APPEND MAPNIK_COMPILE_DEFS MAPNIK_DISABLE_AUTOSETUP)
|
||||||
|
endif()
|
||||||
|
|
||||||
# force utf-8 source code processing
|
# 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
|
# 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>")
|
add_compile_options(
|
||||||
add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/utf-8>")
|
"$<$<CXX_COMPILER_ID:MSVC>:/utf-8>"
|
||||||
|
"$<$<CXX_COMPILER_ID:MSVC>:/EHsc>"
|
||||||
|
)
|
||||||
|
|
||||||
add_library(core INTERFACE)
|
add_library(core INTERFACE)
|
||||||
add_library(mapnik::core ALIAS core)
|
add_library(mapnik::core ALIAS core)
|
||||||
|
@ -377,9 +402,20 @@ 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)
|
||||||
|
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(deps)
|
||||||
add_subdirectory(src)
|
|
||||||
add_subdirectory(plugins)
|
add_subdirectory(plugins)
|
||||||
|
add_subdirectory(src)
|
||||||
add_subdirectory(utils)
|
add_subdirectory(utils)
|
||||||
add_subdirectory(demo)
|
add_subdirectory(demo)
|
||||||
if(BUILD_BENCHMARK)
|
if(BUILD_BENCHMARK)
|
||||||
|
@ -396,23 +432,23 @@ 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}")
|
||||||
file(GLOB TTF_FONT_FILES "fonts/*/*/*.ttf")
|
file(GLOB TTF_FONT_FILES "fonts/*/*/*.ttf")
|
||||||
install(FILES ${TTF_FONT_FILES} DESTINATION ${FONTS_INSTALL_DIR})
|
install(FILES ${TTF_FONT_FILES} DESTINATION "${FONTS_INSTALL_DIR}")
|
||||||
|
|
||||||
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()
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
{
|
{
|
||||||
"name": "default-build-dir",
|
"name": "default-build-dir",
|
||||||
"hidden": true,
|
"hidden": true,
|
||||||
"binaryDir": "${sourceDir}/build/${presetName}"
|
"binaryDir": "${sourceDir}/build"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "debug-build",
|
"name": "debug-build",
|
||||||
|
@ -180,8 +180,9 @@
|
||||||
"cacheVariables": {
|
"cacheVariables": {
|
||||||
"BUILD_TESTING": "ON",
|
"BUILD_TESTING": "ON",
|
||||||
"BUILD_DEMO_VIEWER": "OFF",
|
"BUILD_DEMO_VIEWER": "OFF",
|
||||||
"CMAKE_TOOLCHAIN_FILE": "vcpkg/scripts/buildsystems/vcpkg.cmake"
|
"DISABLE_MAPNIK_AUTOSETUP": "ON"
|
||||||
}
|
},
|
||||||
|
"toolchainFile": "vcpkg/scripts/buildsystems/vcpkg.cmake"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "windows-ci",
|
"name": "windows-ci",
|
||||||
|
@ -192,10 +193,10 @@
|
||||||
],
|
],
|
||||||
"cacheVariables": {
|
"cacheVariables": {
|
||||||
"INSTALL_DEPENDENCIES": "ON",
|
"INSTALL_DEPENDENCIES": "ON",
|
||||||
"ADDITIONAL_LIBARIES_PATHS": "${sourceDir}/build/${presetName}/vcpkg_installed/x64-windows/bin"
|
"ADDITIONAL_LIBARIES_PATHS": "${sourceDir}/build/vcpkg_installed/x64-windows/bin"
|
||||||
},
|
},
|
||||||
"environment": {
|
"environment": {
|
||||||
"PROJ_LIB": "${sourceDir}/build/${presetName}/vcpkg_installed/x64-windows/share/proj"
|
"PROJ_LIB": "${sourceDir}/build/vcpkg_installed/x64-windows/share/proj"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -210,7 +211,7 @@
|
||||||
"CMAKE_CXX_FLAGS": "--coverage"
|
"CMAKE_CXX_FLAGS": "--coverage"
|
||||||
},
|
},
|
||||||
"environment": {
|
"environment": {
|
||||||
"PROJ_LIB": "${sourceDir}/build/${presetName}/vcpkg_installed/x64-linux/share/proj"
|
"PROJ_LIB": "${sourceDir}/build/vcpkg_installed/x64-linux/share/proj"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -239,7 +240,7 @@
|
||||||
"CMAKE_CXX_FLAGS": "-fprofile-arcs -ftest-coverage"
|
"CMAKE_CXX_FLAGS": "-fprofile-arcs -ftest-coverage"
|
||||||
},
|
},
|
||||||
"environment": {
|
"environment": {
|
||||||
"PROJ_LIB": "${sourceDir}/build/${presetName}/vcpkg_installed/x64-osx/share/proj"
|
"PROJ_LIB": "${sourceDir}/build/vcpkg_installed/x64-osx/share/proj"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
|
@ -1879,6 +1879,7 @@ if not preconfigured:
|
||||||
env.Prepend(CPPPATH = '#deps/mapbox/geometry/include')
|
env.Prepend(CPPPATH = '#deps/mapbox/geometry/include')
|
||||||
env.Prepend(CPPPATH = '#deps/mapbox/protozero/include')
|
env.Prepend(CPPPATH = '#deps/mapbox/protozero/include')
|
||||||
env.Prepend(CPPPATH = '#deps/mapbox/polylabel/include')
|
env.Prepend(CPPPATH = '#deps/mapbox/polylabel/include')
|
||||||
|
env.Prepend(CPPPATH = '#plugins/input/base/include')
|
||||||
# prepend deps dir for auxillary headers
|
# prepend deps dir for auxillary headers
|
||||||
env.Prepend(CPPPATH = '#deps')
|
env.Prepend(CPPPATH = '#deps')
|
||||||
|
|
||||||
|
|
|
@ -31,11 +31,12 @@ function(mapnik_create_benchmark)
|
||||||
set(TARGET_NAME "mapnik-benchmark-${BENCHNAME}")
|
set(TARGET_NAME "mapnik-benchmark-${BENCHNAME}")
|
||||||
add_executable(${TARGET_NAME} ${ARGV0})
|
add_executable(${TARGET_NAME} ${ARGV0})
|
||||||
target_include_directories(${TARGET_NAME} PRIVATE include)
|
target_include_directories(${TARGET_NAME} PRIVATE include)
|
||||||
target_link_libraries(${TARGET_NAME} PRIVATE mapnik::agg mapnik::mapnik)
|
target_link_libraries(${TARGET_NAME} PRIVATE
|
||||||
|
mapnik::agg
|
||||||
|
mapnik::mapnik
|
||||||
|
ICU::data ICU::i18n ICU::uc # needed for the static build (TODO: why isn't this correctly propagated from mapnik::mapnik?)
|
||||||
|
)
|
||||||
set_target_properties(${TARGET_NAME} PROPERTIES
|
set_target_properties(${TARGET_NAME} PROPERTIES
|
||||||
LIBRARY_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
|
|
||||||
RUNTIME_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
|
|
||||||
ARCHIVE_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}/lib"
|
|
||||||
OUTPUT_NAME "${BENCHNAME}"
|
OUTPUT_NAME "${BENCHNAME}"
|
||||||
)
|
)
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
|
@ -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; \
|
||||||
|
|
|
@ -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)
|
||||||
|
|
|
@ -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")
|
||||||
|
|
|
@ -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);
|
||||||
|
|
|
@ -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);
|
||||||
|
|
|
@ -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
|
||||||
{
|
{
|
||||||
|
|
|
@ -76,5 +76,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();
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -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);
|
||||||
|
|
||||||
|
|
|
@ -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/");
|
||||||
|
|
|
@ -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");
|
||||||
|
|
|
@ -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
|
||||||
{
|
{
|
||||||
|
|
|
@ -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
|
||||||
{
|
{
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -1,98 +0,0 @@
|
||||||
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
|
||||||
# file Copyright.txt or https://cmake.org/licensing for details.
|
|
||||||
|
|
||||||
#[=======================================================================[.rst:
|
|
||||||
FindCairo
|
|
||||||
-----------
|
|
||||||
|
|
||||||
Find Cairo 2D graphics library.
|
|
||||||
|
|
||||||
|
|
||||||
Imported Targets
|
|
||||||
^^^^^^^^^^^^^^^^
|
|
||||||
This module defines :prop_tgt:`IMPORTED` target ``Cairo::Cairo``, if
|
|
||||||
cairo has been found.
|
|
||||||
|
|
||||||
Result variables
|
|
||||||
^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
This module will set the following variables in your project:
|
|
||||||
|
|
||||||
``CAIRO_FOUND``
|
|
||||||
True if cairo headers and library were found.
|
|
||||||
``CAIRO_INCLUDE_DIRS``
|
|
||||||
Directory where cairo headers are located.
|
|
||||||
``CAIRO_LIBRARIES``
|
|
||||||
cairo libraries to link against.
|
|
||||||
``CAIRO_VERSION_MAJOR``
|
|
||||||
The major version of cairo
|
|
||||||
``CAIRO_VERSION_MINOR``
|
|
||||||
The minor version of cairo
|
|
||||||
``CAIRO_VERSION_PATCH``
|
|
||||||
The patch version of cairo
|
|
||||||
``CAIRO_VERSION_STRING``
|
|
||||||
version number as a string (ex: "1.16.0")
|
|
||||||
#]=======================================================================]
|
|
||||||
|
|
||||||
if(NOT CAIRO_LIBRARY)
|
|
||||||
find_path(CAIRO_INCLUDE_DIR NAMES cairo.h HINTS ${PC_CAIRO_INCLUDEDIR} ${PC_CAIRO_INCLUDE_DIR} PATH_SUFFIXES cairo)
|
|
||||||
find_library(CAIRO_LIBRARY_RELEASE NAMES ${Cairo_NAMES} cairo HINTS ${PC_CAIRO_LIBDIR} ${PC_CAIRO_LIBRARY_DIRS})
|
|
||||||
find_library(CAIRO_LIBRARY_DEBUG NAMES ${Cairo_NAMES} cairod HINTS ${PC_CAIRO_LIBDIR} ${PC_CAIRO_LIBRARY_DIRS})
|
|
||||||
include(SelectLibraryConfigurations)
|
|
||||||
select_library_configurations(CAIRO)
|
|
||||||
else()
|
|
||||||
file(TO_CMAKE_PATH "${CAIRO_LIBRARY}" CAIRO_LIBRARY)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(CAIRO_INCLUDE_DIR AND NOT CAIRO_VERSION)
|
|
||||||
if(EXISTS "${CAIRO_INCLUDE_DIR}/cairo-version.h")
|
|
||||||
file(READ "${CAIRO_INCLUDE_DIR}/cairo-version.h" CAIRO_VERSION_CONTENT)
|
|
||||||
|
|
||||||
string(REGEX MATCH "#define +CAIRO_VERSION_MAJOR +([0-9]+)" _dummy "${CAIRO_VERSION_CONTENT}")
|
|
||||||
set(CAIRO_VERSION_MAJOR "${CMAKE_MATCH_1}")
|
|
||||||
|
|
||||||
string(REGEX MATCH "#define +CAIRO_VERSION_MINOR +([0-9]+)" _dummy "${CAIRO_VERSION_CONTENT}")
|
|
||||||
set(CAIRO_VERSION_MINOR "${CMAKE_MATCH_1}")
|
|
||||||
|
|
||||||
string(REGEX MATCH "#define +CAIRO_VERSION_MICRO +([0-9]+)" _dummy "${CAIRO_VERSION_CONTENT}")
|
|
||||||
set(CAIRO_VERSION_PATCH "${CMAKE_MATCH_1}")
|
|
||||||
|
|
||||||
set(CAIRO_VERSION "${CAIRO_VERSION_MAJOR}.${CAIRO_VERSION_MINOR}.${CAIRO_VERSION_PATCH}")
|
|
||||||
set(CAIRO_VERSION_STRING ${CAIRO_VERSION})
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
include(FindPackageHandleStandardArgs)
|
|
||||||
find_package_handle_standard_args(Cairo
|
|
||||||
REQUIRED_VARS
|
|
||||||
CAIRO_LIBRARY
|
|
||||||
CAIRO_INCLUDE_DIR
|
|
||||||
VERSION_VAR
|
|
||||||
CAIRO_VERSION_STRING
|
|
||||||
)
|
|
||||||
mark_as_advanced(CAIRO_INCLUDE_DIR CAIRO_LIBRARY)
|
|
||||||
|
|
||||||
if (CAIRO_FOUND)
|
|
||||||
set(CAIRO_LIBRARIES ${CAIRO_LIBRARY})
|
|
||||||
set(CAIRO_INCLUDE_DIRS ${CAIRO_INCLUDE_DIR})
|
|
||||||
if(NOT TARGET Cairo::Cairo)
|
|
||||||
add_library(Cairo::Cairo UNKNOWN IMPORTED)
|
|
||||||
set_target_properties(Cairo::Cairo PROPERTIES
|
|
||||||
INTERFACE_INCLUDE_DIRECTORIES ${CAIRO_INCLUDE_DIR}
|
|
||||||
IMPORTED_LINK_INTERFACE_LANGUAGES C)
|
|
||||||
|
|
||||||
if(CAIRO_LIBRARY_RELEASE)
|
|
||||||
set_property(TARGET Cairo::Cairo APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
|
|
||||||
set_target_properties(Cairo::Cairo PROPERTIES IMPORTED_LOCATION_RELEASE "${CAIRO_LIBRARY_RELEASE}")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(CAIRO_LIBRARY_DEBUG)
|
|
||||||
set_property(TARGET Cairo::Cairo APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG)
|
|
||||||
set_target_properties(Cairo::Cairo PROPERTIES IMPORTED_LOCATION_DEBUG "${CAIRO_LIBRARY_DEBUG}")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(NOT CAIRO_LIBRARY_RELEASE AND NOT CAIRO_LIBRARY_DEBUG)
|
|
||||||
set_target_properties(Cairo::Cairo PROPERTIES IMPORTED_LOCATION "${CAIRO_LIBRARY}")
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
endif ()
|
|
|
@ -1,97 +0,0 @@
|
||||||
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
|
||||||
# file Copyright.txt or https://cmake.org/licensing for details.
|
|
||||||
|
|
||||||
#[=======================================================================[.rst:
|
|
||||||
FindWebP
|
|
||||||
-------
|
|
||||||
|
|
||||||
Finds the WebP library.
|
|
||||||
|
|
||||||
Imported Targets
|
|
||||||
^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
This module provides the following imported targets, if found:
|
|
||||||
|
|
||||||
``WebP::WebP``
|
|
||||||
The WebP library
|
|
||||||
|
|
||||||
Result Variables
|
|
||||||
^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
This will define the following variables:
|
|
||||||
|
|
||||||
``WebP_FOUND``
|
|
||||||
True if the system has the WebP library.
|
|
||||||
``WebP_VERSION``
|
|
||||||
The version of the WebP library which was found.
|
|
||||||
``WebP_INCLUDE_DIRS``
|
|
||||||
Include directories needed to use WebP.
|
|
||||||
``WebP_LIBRARIES``
|
|
||||||
Libraries needed to link to WebP.
|
|
||||||
|
|
||||||
Cache Variables
|
|
||||||
^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
The following cache variables may also be set:
|
|
||||||
|
|
||||||
``WebP_INCLUDE_DIR``
|
|
||||||
The directory containing ``decode.h``.
|
|
||||||
``WebP_LIBRARY``
|
|
||||||
The path to the Foo library.
|
|
||||||
|
|
||||||
#]=======================================================================]
|
|
||||||
|
|
||||||
if(NOT WebP_LIBRARY)
|
|
||||||
find_package(PkgConfig QUIET)
|
|
||||||
pkg_check_modules(PC_WebP QUIET libwebp)
|
|
||||||
set(WebP_VERSION ${PC_WebP_VERSION})
|
|
||||||
find_path(WebP_INCLUDE_DIR NAMES decode.h HINTS ${PC_WebP_INCLUDEDIR} ${PC_WebP_INCLUDE_DIR} PATH_SUFFIXES webp)
|
|
||||||
find_library(WebP_LIBRARY_RELEASE NAMES ${WebP_NAMES} webp HINTS ${PC_WebP_LIBDIR} ${PC_WebP_LIBRARY_DIRS})
|
|
||||||
find_library(WebP_LIBRARY_DEBUG NAMES ${WebP_NAMES} webpd HINTS ${PC_WebP_LIBDIR} ${PC_WebP_LIBRARY_DIRS})
|
|
||||||
include(SelectLibraryConfigurations)
|
|
||||||
select_library_configurations(WebP)
|
|
||||||
else()
|
|
||||||
file(TO_CMAKE_PATH "${WebP_LIBRARY}" WebP_LIBRARY)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if ("${WebP_FIND_VERSION}" VERSION_GREATER "${WebP_VERSION}")
|
|
||||||
if (WebP_VERSION)
|
|
||||||
message(FATAL_ERROR "Required version (" ${WebP_FIND_VERSION} ") is higher than found version (" ${PC_WebP_VERSION} ")")
|
|
||||||
else ()
|
|
||||||
message(WARNING "Cannot determine WebP version without pkg-config")
|
|
||||||
endif ()
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
include(FindPackageHandleStandardArgs)
|
|
||||||
find_package_handle_standard_args(WebP
|
|
||||||
REQUIRED_VARS
|
|
||||||
WebP_LIBRARY
|
|
||||||
WebP_INCLUDE_DIR
|
|
||||||
VERSION_VAR WebP_VERSION
|
|
||||||
)
|
|
||||||
mark_as_advanced(WebP_INCLUDE_DIR WebP_LIBRARY)
|
|
||||||
|
|
||||||
if (WebP_FOUND)
|
|
||||||
set(WebP_LIBRARIES ${WebP_LIBRARY})
|
|
||||||
set(WebP_INCLUDE_DIRS ${WebP_INCLUDE_DIR})
|
|
||||||
if(NOT TARGET WebP::WebP)
|
|
||||||
add_library(WebP::WebP UNKNOWN IMPORTED)
|
|
||||||
set_target_properties(WebP::WebP PROPERTIES
|
|
||||||
INTERFACE_INCLUDE_DIRECTORIES ${WebP_INCLUDE_DIR}
|
|
||||||
IMPORTED_LINK_INTERFACE_LANGUAGES C)
|
|
||||||
|
|
||||||
if(WebP_LIBRARY_RELEASE)
|
|
||||||
set_property(TARGET WebP::WebP APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
|
|
||||||
set_target_properties(WebP::WebP PROPERTIES IMPORTED_LOCATION_RELEASE "${WebP_LIBRARY_RELEASE}")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(WebP_LIBRARY_DEBUG)
|
|
||||||
set_property(TARGET WebP::WebP APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG)
|
|
||||||
set_target_properties(WebP::WebP PROPERTIES IMPORTED_LOCATION_DEBUG "${WebP_LIBRARY_DEBUG}")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(NOT WebP_LIBRARY_RELEASE AND NOT WebP_LIBRARY_DEBUG)
|
|
||||||
set_target_properties(WebP::WebP PROPERTIES IMPORTED_LOCATION "${WebP_LIBRARY}")
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
endif ()
|
|
|
@ -1,5 +1,7 @@
|
||||||
include(CMakePackageConfigHelpers)
|
include(CMakePackageConfigHelpers)
|
||||||
|
|
||||||
|
### exports mapnik cmake config files (mapnikConfigVersion and mapnikConfig)
|
||||||
|
function(mapnik_export_cmake_config)
|
||||||
# export mapnik configuration
|
# export mapnik configuration
|
||||||
write_basic_package_version_file(
|
write_basic_package_version_file(
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/mapnikConfigVersion.cmake"
|
"${CMAKE_CURRENT_BINARY_DIR}/mapnikConfigVersion.cmake"
|
||||||
|
@ -7,28 +9,38 @@ write_basic_package_version_file(
|
||||||
COMPATIBILITY ExactVersion
|
COMPATIBILITY ExactVersion
|
||||||
)
|
)
|
||||||
get_property(MAPNIK_UTILITIES GLOBAL PROPERTY MAPNIK_UTILITIES)
|
get_property(MAPNIK_UTILITIES GLOBAL PROPERTY MAPNIK_UTILITIES)
|
||||||
list(JOIN MAPNIK_DEPENDENCIES "\n" MAPNIK_DEPENDENCIES)
|
|
||||||
configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/mapnikConfig.cmake.in
|
# generate all find_dependency and pkg_config calls
|
||||||
|
set(mapnik_find_deps)
|
||||||
|
foreach(dep IN LISTS mapnik_deps)
|
||||||
|
set(ver_comment "# ${dep} used with version ${mapnik_${dep}_version}")
|
||||||
|
set(mapnik_find_deps "${mapnik_find_deps}\n${ver_comment}\n")
|
||||||
|
if(mapnik_${dep}_find_args)
|
||||||
|
list(REMOVE_DUPLICATES mapnik_${dep}_find_args)
|
||||||
|
list(JOIN mapnik_${dep}_find_args " " m_args_joined)
|
||||||
|
set(mapnik_find_deps "${mapnik_find_deps}find_dependency(${dep} ${m_args_joined})")
|
||||||
|
else()
|
||||||
|
list(JOIN mapnik_${dep}_pkg_args " " m_args_joined)
|
||||||
|
set(mapnik_find_deps "${mapnik_find_deps}pkg_check_modules(${dep} ${m_args_joined})")
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
configure_package_config_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/mapnikConfig.cmake.in"
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/mapnikConfig.cmake"
|
"${CMAKE_CURRENT_BINARY_DIR}/mapnikConfig.cmake"
|
||||||
INSTALL_DESTINATION ${MAPNIK_CMAKE_DIR}
|
INSTALL_DESTINATION ${MAPNIK_CMAKE_DIR}
|
||||||
PATH_VARS MAPNIK_INCLUDE_DIR PLUGINS_INSTALL_DIR FONTS_INSTALL_DIR MAPNIK_DEPENDENCIES MAPNIK_UTILITIES
|
PATH_VARS MAPNIK_INCLUDE_DIR PLUGINS_INSTALL_DIR FONTS_INSTALL_DIR mapnik_find_deps MAPNIK_UTILITIES
|
||||||
NO_CHECK_REQUIRED_COMPONENTS_MACRO
|
NO_CHECK_REQUIRED_COMPONENTS_MACRO
|
||||||
)
|
)
|
||||||
|
|
||||||
install(
|
install(
|
||||||
FILES
|
FILES
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/mapnikConfig.cmake"
|
"${CMAKE_CURRENT_BINARY_DIR}/mapnikConfig.cmake"
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/mapnikConfigVersion.cmake"
|
"${CMAKE_CURRENT_BINARY_DIR}/mapnikConfigVersion.cmake"
|
||||||
DESTINATION ${MAPNIK_CMAKE_DIR}
|
DESTINATION ${MAPNIK_CMAKE_DIR}
|
||||||
)
|
)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
# install our modules, so that the expected target names are found.
|
|
||||||
install(
|
mapnik_export_cmake_config()
|
||||||
FILES
|
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/FindCairo.cmake"
|
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/FindWebP.cmake"
|
|
||||||
DESTINATION ${MAPNIK_CMAKE_DIR}/Modules
|
|
||||||
)
|
|
||||||
|
|
||||||
install(EXPORT MapnikTargets
|
install(EXPORT MapnikTargets
|
||||||
DESTINATION ${MAPNIK_CMAKE_DIR}
|
DESTINATION ${MAPNIK_CMAKE_DIR}
|
||||||
|
@ -36,21 +48,21 @@ install(EXPORT MapnikTargets
|
||||||
NAMESPACE mapnik::
|
NAMESPACE mapnik::
|
||||||
)
|
)
|
||||||
|
|
||||||
|
### install plugin cmake config files ###
|
||||||
# Create configuration dependend files for the plugin install dirs.
|
# Create configuration dependend files for the plugin install dirs.
|
||||||
# some package managers are using different paths per configuration.
|
# some package managers are using different paths per configuration.
|
||||||
string(TOLOWER "${CMAKE_BUILD_TYPE}" _build_type)
|
string(TOLOWER "${CMAKE_BUILD_TYPE}" _build_type)
|
||||||
string(TOUPPER "${CMAKE_BUILD_TYPE}" _build_type_l)
|
string(TOUPPER "${CMAKE_BUILD_TYPE}" _build_type_l)
|
||||||
set(_mapnik_plugin_file_name "mapnikPlugins-${_build_type}")
|
set(m_mapnik_plugin_file_name mapnikPlugins-${_build_type})
|
||||||
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${_mapnik_plugin_file_name}.cmake.in "set(MAPNIK_PLUGINS_DIR_${_build_type_l} \"@PACKAGE_PLUGINS_INSTALL_DIR@\" CACHE STRING \"\")\n")
|
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/${m_mapnik_plugin_file_name}.cmake.in" "set(MAPNIK_PLUGINS_DIR_${_build_type_l} \"@PACKAGE_PLUGINS_INSTALL_DIR@\" CACHE STRING \"\")\n")
|
||||||
include(CMakePackageConfigHelpers)
|
include(CMakePackageConfigHelpers)
|
||||||
configure_package_config_file(
|
configure_package_config_file(
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/${_mapnik_plugin_file_name}.cmake.in
|
"${CMAKE_CURRENT_BINARY_DIR}/${m_mapnik_plugin_file_name}.cmake.in"
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/${_mapnik_plugin_file_name}.cmake
|
"${CMAKE_CURRENT_BINARY_DIR}/${m_mapnik_plugin_file_name}.cmake"
|
||||||
PATH_VARS PLUGINS_INSTALL_DIR
|
PATH_VARS PLUGINS_INSTALL_DIR
|
||||||
INSTALL_DESTINATION ${MAPNIK_CMAKE_DIR}
|
INSTALL_DESTINATION ${MAPNIK_CMAKE_DIR}
|
||||||
)
|
)
|
||||||
install(
|
install(
|
||||||
FILES ${CMAKE_CURRENT_BINARY_DIR}/${_mapnik_plugin_file_name}.cmake
|
FILES "${CMAKE_CURRENT_BINARY_DIR}/${m_mapnik_plugin_file_name}.cmake"
|
||||||
DESTINATION ${MAPNIK_CMAKE_DIR}
|
DESTINATION ${MAPNIK_CMAKE_DIR}
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,28 +1,50 @@
|
||||||
macro(mapnik_print_version)
|
function(mapnik_set_dep_version dep var)
|
||||||
string(TOUPPER ${ARGV0} TLNUP)
|
string(TOUPPER ${dep} m_package_name_upc)
|
||||||
set(TLN ${ARGV0})
|
set(m_package_name ${dep})
|
||||||
if(${TLN}_VERSION_STRING)
|
if(${m_package_name}_VERSION_STRING)
|
||||||
message(STATUS "Using ${ARGV0} version: ${${TLN}_VERSION_STRING}")
|
set(${var} ${${m_package_name}_VERSION_STRING} PARENT_SCOPE)
|
||||||
elseif(${TLN}_VERSION)
|
elseif(${m_package_name}_VERSION)
|
||||||
message(STATUS "Using ${ARGV0} version: ${${TLN}_VERSION}")
|
set(${var} ${${m_package_name}_VERSION} PARENT_SCOPE)
|
||||||
elseif(${TLNUP}_VERSION_STRING)
|
elseif(${m_package_name_upc}_VERSION_STRING)
|
||||||
message(STATUS "Using ${ARGV0} version: ${${TLNUP}_VERSION_STRING}")
|
set(${var} ${${m_package_name_upc}_VERSION_STRING} PARENT_SCOPE)
|
||||||
elseif(${TLNUP}_VERSION)
|
elseif(${m_package_name_upc}_VERSION)
|
||||||
message(STATUS "Using ${ARGV0} version: ${${TLNUP}_VERSION}")
|
set(${var} ${${m_package_name_upc}_VERSION} PARENT_SCOPE)
|
||||||
|
endif()
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
function(mapnik_print_package_info dep)
|
||||||
|
message(STATUS "Using ${dep} version: ${mapnik_${dep}_version}")
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
macro(mapnik_find_package dep)
|
||||||
|
find_package(${dep} ${ARGN})
|
||||||
|
if(${dep}_FOUND)
|
||||||
|
list(APPEND mapnik_deps ${dep})
|
||||||
|
|
||||||
|
if(mapnik_${dep}_find_args)
|
||||||
|
list(APPEND mapnik_${dep}_find_args ${ARGN})
|
||||||
else()
|
else()
|
||||||
message(STATUS "Using ${ARGV0}")
|
set(mapnik_${dep}_find_args ${ARGN})
|
||||||
|
endif()
|
||||||
|
mapnik_set_dep_version(${dep} mapnik_${dep}_version)
|
||||||
|
|
||||||
|
mapnik_print_package_info(${dep})
|
||||||
|
else()
|
||||||
|
message(STATUS "not found: ${dep}")
|
||||||
endif()
|
endif()
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
macro(mapnik_find_package)
|
macro(mapnik_pkg_check_modules dep)
|
||||||
find_package(${ARGN})
|
pkg_check_modules(${dep} ${ARGN})
|
||||||
if(${ARGV0}_FOUND)
|
if(${dep}_FOUND)
|
||||||
set(MAPNIK_TMP_DEP ${ARGN})
|
list(APPEND mapnik_deps ${dep})
|
||||||
list(JOIN MAPNIK_TMP_DEP " " MAPNIK_TMP_DEP)
|
|
||||||
list(APPEND MAPNIK_DEPENDENCIES "find_dependency(${MAPNIK_TMP_DEP})")
|
set(mapnik_${dep}_pkg_args ${ARGN})
|
||||||
mapnik_print_version(${ARGV0})
|
mapnik_set_dep_version(${dep} mapnik_${dep}_version)
|
||||||
|
|
||||||
|
mapnik_print_package_info(${dep})
|
||||||
else()
|
else()
|
||||||
message(STATUS "not found: ${ARGV0}")
|
message(STATUS "not found: ${dep}")
|
||||||
endif()
|
endif()
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,9 @@ endfunction()
|
||||||
# Install plugins
|
# Install plugins
|
||||||
#
|
#
|
||||||
function(mapnik_install_plugin _target)
|
function(mapnik_install_plugin _target)
|
||||||
|
if(NOT BUILD_SHARED_PLUGINS)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
install(TARGETS ${_target}
|
install(TARGETS ${_target}
|
||||||
RUNTIME DESTINATION ${PLUGINS_INSTALL_DIR}
|
RUNTIME DESTINATION ${PLUGINS_INSTALL_DIR}
|
||||||
COMPONENT MapnikPluginRuntime
|
COMPONENT MapnikPluginRuntime
|
||||||
|
|
|
@ -8,7 +8,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_LIST_DIR}/Modules/")
|
||||||
include(CMakeFindDependencyMacro)
|
include(CMakeFindDependencyMacro)
|
||||||
|
|
||||||
find_dependency(Threads REQUIRED)
|
find_dependency(Threads REQUIRED)
|
||||||
@MAPNIK_DEPENDENCIES@
|
@mapnik_find_deps@
|
||||||
|
|
||||||
include("${CMAKE_CURRENT_LIST_DIR}/mapnikTargets.cmake")
|
include("${CMAKE_CURRENT_LIST_DIR}/mapnikTargets.cmake")
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
add_executable(mapnik-demo rundemo.cpp)
|
add_executable(mapnik-demo rundemo.cpp)
|
||||||
set_target_properties(mapnik-demo PROPERTIES
|
target_link_libraries(mapnik-demo PRIVATE
|
||||||
LIBRARY_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
|
mapnik::agg
|
||||||
RUNTIME_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
|
mapnik::mapnik
|
||||||
ARCHIVE_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}/lib"
|
ICU::data ICU::i18n ICU::uc # needed for the static build (TODO: why isn't this correctly propagated from mapnik::mapnik?)
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(mapnik-demo PRIVATE mapnik::agg mapnik::mapnik)
|
|
||||||
|
|
|
@ -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";
|
||||||
|
|
|
@ -40,15 +40,13 @@ set_target_properties(mapnik-viewer PROPERTIES
|
||||||
AUTORCC ON
|
AUTORCC ON
|
||||||
AUTOUIC ON
|
AUTOUIC ON
|
||||||
AUTOMOC ON
|
AUTOMOC ON
|
||||||
LIBRARY_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
|
|
||||||
RUNTIME_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
|
|
||||||
ARCHIVE_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}/lib"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(mapnik-viewer PRIVATE
|
target_link_libraries(mapnik-viewer PRIVATE
|
||||||
Qt${QT_VERSION_MAJOR}::Widgets
|
Qt${QT_VERSION_MAJOR}::Widgets
|
||||||
mapnik::agg
|
mapnik::agg
|
||||||
mapnik::mapnik
|
mapnik::mapnik
|
||||||
|
ICU::data ICU::i18n ICU::uc # needed for the static build (TODO: why isn't this correctly propagated from mapnik::mapnik?)
|
||||||
)
|
)
|
||||||
|
|
||||||
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/viewer.ini
|
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/viewer.ini
|
||||||
|
|
|
@ -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)
|
||||||
|
|
|
@ -24,15 +24,23 @@
|
||||||
#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
|
||||||
|
# define MAPNIK_DECL
|
||||||
|
# define MAPNIK_EXP
|
||||||
|
#else
|
||||||
# define MAPNIK_EXP __declspec(dllexport)
|
# define MAPNIK_EXP __declspec(dllexport)
|
||||||
#define MAPNIK_IMP __declspec(dllimport)
|
# ifndef MAPNIK_DECL
|
||||||
# ifdef MAPNIK_EXPORTS
|
# ifdef MAPNIK_EXPORTS
|
||||||
|
/* We are building this library */
|
||||||
# define MAPNIK_DECL __declspec(dllexport)
|
# define MAPNIK_DECL __declspec(dllexport)
|
||||||
# else
|
# else
|
||||||
|
/* We are using this library */
|
||||||
# define MAPNIK_DECL __declspec(dllimport)
|
# define MAPNIK_DECL __declspec(dllimport)
|
||||||
# endif
|
# endif
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
# pragma warning( disable: 4251 )
|
# pragma warning( disable: 4251 )
|
||||||
# pragma warning( disable: 4275 )
|
# pragma warning( disable: 4275 )
|
||||||
# if (_MSC_VER >= 1400) // vc8
|
# if (_MSC_VER >= 1400) // vc8
|
||||||
|
@ -49,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
|
||||||
|
|
|
@ -48,11 +48,9 @@ namespace css_color_grammar {
|
||||||
|
|
||||||
using x3::attr;
|
using x3::attr;
|
||||||
using x3::double_;
|
using x3::double_;
|
||||||
using x3::hex;
|
|
||||||
using x3::lit;
|
using x3::lit;
|
||||||
using x3::no_case;
|
using x3::no_case;
|
||||||
using x3::no_skip;
|
using x3::no_skip;
|
||||||
using x3::omit;
|
|
||||||
using x3::symbols;
|
using x3::symbols;
|
||||||
using x3::uint_parser;
|
using x3::uint_parser;
|
||||||
|
|
||||||
|
@ -214,11 +212,11 @@ struct named_colors_ : x3::symbols<color>
|
||||||
;
|
;
|
||||||
// clang-format on
|
// clang-format on
|
||||||
}
|
}
|
||||||
} named_colors;
|
} const named_colors;
|
||||||
|
|
||||||
x3::uint_parser<std::uint8_t, 16, 2, 2> hex2;
|
const x3::uint_parser<std::uint8_t, 16, 2, 2> hex2;
|
||||||
x3::uint_parser<std::uint8_t, 16, 1, 1> hex1;
|
const x3::uint_parser<std::uint8_t, 16, 1, 1> hex1;
|
||||||
x3::uint_parser<std::uint16_t, 10, 1, 3> dec3;
|
const x3::uint_parser<std::uint16_t, 10, 1, 3> dec3;
|
||||||
|
|
||||||
// rules
|
// rules
|
||||||
x3::rule<class hex2_color, color> const hex2_color("hex2_color");
|
x3::rule<class hex2_color, color> const hex2_color("hex2_color");
|
||||||
|
@ -245,67 +243,67 @@ struct percent_converter
|
||||||
static std::uint8_t call(double val) { return safe_cast<std::uint8_t>(std::lround((255.0 * val) / 100.0)); }
|
static std::uint8_t call(double val) { return safe_cast<std::uint8_t>(std::lround((255.0 * val) / 100.0)); }
|
||||||
};
|
};
|
||||||
|
|
||||||
auto dec_red = [](auto& ctx) {
|
const auto dec_red = [](auto& ctx) {
|
||||||
_val(ctx).red_ = _attr(ctx);
|
_val(ctx).red_ = _attr(ctx);
|
||||||
};
|
};
|
||||||
|
|
||||||
auto dec_green = [](auto& ctx) {
|
const auto dec_green = [](auto& ctx) {
|
||||||
_val(ctx).green_ = _attr(ctx);
|
_val(ctx).green_ = _attr(ctx);
|
||||||
};
|
};
|
||||||
|
|
||||||
auto dec_blue = [](auto& ctx) {
|
const auto dec_blue = [](auto& ctx) {
|
||||||
_val(ctx).blue_ = _attr(ctx);
|
_val(ctx).blue_ = _attr(ctx);
|
||||||
};
|
};
|
||||||
|
|
||||||
auto opacity = [](auto& ctx) {
|
const auto opacity = [](auto& ctx) {
|
||||||
_val(ctx).alpha_ = uint8_t((255.0 * clip_opacity::call(_attr(ctx))) + 0.5);
|
_val(ctx).alpha_ = uint8_t((255.0 * clip_opacity::call(_attr(ctx))) + 0.5);
|
||||||
};
|
};
|
||||||
|
|
||||||
auto percent_red = [](auto& ctx) {
|
const auto percent_red = [](auto& ctx) {
|
||||||
_val(ctx).red_ = percent_converter::call(_attr(ctx));
|
_val(ctx).red_ = percent_converter::call(_attr(ctx));
|
||||||
};
|
};
|
||||||
|
|
||||||
auto percent_green = [](auto& ctx) {
|
const auto percent_green = [](auto& ctx) {
|
||||||
_val(ctx).green_ = percent_converter::call(_attr(ctx));
|
_val(ctx).green_ = percent_converter::call(_attr(ctx));
|
||||||
};
|
};
|
||||||
|
|
||||||
auto percent_blue = [](auto& ctx) {
|
const auto percent_blue = [](auto& ctx) {
|
||||||
_val(ctx).blue_ = percent_converter::call(_attr(ctx));
|
_val(ctx).blue_ = percent_converter::call(_attr(ctx));
|
||||||
};
|
};
|
||||||
|
|
||||||
auto hex1_red = [](auto& ctx) {
|
const auto hex1_red = [](auto& ctx) {
|
||||||
_val(ctx).red_ = _attr(ctx) | _attr(ctx) << 4;
|
_val(ctx).red_ = _attr(ctx) | _attr(ctx) << 4;
|
||||||
};
|
};
|
||||||
|
|
||||||
auto hex1_green = [](auto& ctx) {
|
const auto hex1_green = [](auto& ctx) {
|
||||||
_val(ctx).green_ = _attr(ctx) | _attr(ctx) << 4;
|
_val(ctx).green_ = _attr(ctx) | _attr(ctx) << 4;
|
||||||
};
|
};
|
||||||
|
|
||||||
auto hex1_blue = [](auto& ctx) {
|
const auto hex1_blue = [](auto& ctx) {
|
||||||
_val(ctx).blue_ = _attr(ctx) | _attr(ctx) << 4;
|
_val(ctx).blue_ = _attr(ctx) | _attr(ctx) << 4;
|
||||||
};
|
};
|
||||||
|
|
||||||
auto hex1_opacity = [](auto& ctx) {
|
const auto hex1_opacity = [](auto& ctx) {
|
||||||
_val(ctx).alpha_ = _attr(ctx) | _attr(ctx) << 4;
|
_val(ctx).alpha_ = _attr(ctx) | _attr(ctx) << 4;
|
||||||
};
|
};
|
||||||
|
|
||||||
auto hex2_red = [](auto& ctx) {
|
const auto hex2_red = [](auto& ctx) {
|
||||||
_val(ctx).red_ = _attr(ctx);
|
_val(ctx).red_ = _attr(ctx);
|
||||||
};
|
};
|
||||||
|
|
||||||
auto hex2_green = [](auto& ctx) {
|
const auto hex2_green = [](auto& ctx) {
|
||||||
_val(ctx).green_ = _attr(ctx);
|
_val(ctx).green_ = _attr(ctx);
|
||||||
};
|
};
|
||||||
|
|
||||||
auto hex2_blue = [](auto& ctx) {
|
const auto hex2_blue = [](auto& ctx) {
|
||||||
_val(ctx).blue_ = _attr(ctx);
|
_val(ctx).blue_ = _attr(ctx);
|
||||||
};
|
};
|
||||||
|
|
||||||
auto hex2_opacity = [](auto& ctx) {
|
const auto hex2_opacity = [](auto& ctx) {
|
||||||
_val(ctx).alpha_ = _attr(ctx);
|
_val(ctx).alpha_ = _attr(ctx);
|
||||||
};
|
};
|
||||||
|
|
||||||
auto hsl_to_rgba = [](auto& ctx) {
|
const auto hsl_to_rgba = [](auto& ctx) {
|
||||||
double h = std::get<0>(_attr(ctx));
|
double h = std::get<0>(_attr(ctx));
|
||||||
double s = std::get<1>(_attr(ctx));
|
double s = std::get<1>(_attr(ctx));
|
||||||
double l = std::get<2>(_attr(ctx));
|
double l = std::get<2>(_attr(ctx));
|
||||||
|
@ -325,10 +323,10 @@ auto hsl_to_rgba = [](auto& ctx) {
|
||||||
}
|
}
|
||||||
m1 = l * 2 - m2;
|
m1 = l * 2 - m2;
|
||||||
|
|
||||||
double r = hue_to_rgb(m1, m2, h + 1.0 / 3.0);
|
const double r = hue_to_rgb(m1, m2, h + 1.0 / 3.0);
|
||||||
double g = hue_to_rgb(m1, m2, h);
|
const double g = hue_to_rgb(m1, m2, h);
|
||||||
double b = hue_to_rgb(m1, m2, h - 1.0 / 3.0);
|
const double b = hue_to_rgb(m1, m2, h - 1.0 / 3.0);
|
||||||
uint8_t alpha = uint8_t((255.0 * clip_opacity::call(std::get<3>(_attr(ctx)))) + 0.5);
|
const uint8_t alpha = uint8_t((255.0 * clip_opacity::call(std::get<3>(_attr(ctx)))) + 0.5);
|
||||||
_val(ctx) = color(safe_cast<uint8_t>(std::lround(255.0 * r)),
|
_val(ctx) = color(safe_cast<uint8_t>(std::lround(255.0 * r)),
|
||||||
safe_cast<uint8_t>(std::lround(255.0 * g)),
|
safe_cast<uint8_t>(std::lround(255.0 * g)),
|
||||||
safe_cast<uint8_t>(std::lround(255.0 * b)),
|
safe_cast<uint8_t>(std::lround(255.0 * b)),
|
||||||
|
|
|
@ -150,32 +150,27 @@ namespace css_grammar {
|
||||||
|
|
||||||
using x3::alnum;
|
using x3::alnum;
|
||||||
using x3::alpha;
|
using x3::alpha;
|
||||||
using x3::attr;
|
|
||||||
using x3::char_;
|
using x3::char_;
|
||||||
using x3::lexeme;
|
using x3::lexeme;
|
||||||
using x3::lit;
|
using x3::lit;
|
||||||
using x3::no_case;
|
|
||||||
using x3::no_skip;
|
|
||||||
using x3::raw;
|
using x3::raw;
|
||||||
using x3::standard::space;
|
using x3::standard::space;
|
||||||
|
|
||||||
// import unicode string rule
|
// import unicode string rule
|
||||||
namespace {
|
const auto css_string = mapnik::json::grammar::unicode_string;
|
||||||
auto const& css_string = mapnik::json::grammar::unicode_string;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto assign_def = [](auto const& ctx) {
|
const auto assign_def = [](auto const& ctx) {
|
||||||
for (auto const& k : std::get<0>(_attr(ctx)))
|
for (auto const& k : std::get<0>(_attr(ctx)))
|
||||||
{
|
{
|
||||||
_val(ctx).emplace(k, std::get<1>(_attr(ctx)));
|
_val(ctx).emplace(k, std::get<1>(_attr(ctx)));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
auto assign_key = [](auto const& ctx) {
|
const auto assign_key = [](auto const& ctx) {
|
||||||
_val(ctx).first = std::move(_attr(ctx));
|
_val(ctx).first = std::move(_attr(ctx));
|
||||||
};
|
};
|
||||||
|
|
||||||
auto assign_value = [](auto const& ctx) {
|
const auto assign_value = [](auto const& ctx) {
|
||||||
_val(ctx).second = std::move(_attr(ctx));
|
_val(ctx).second = std::move(_attr(ctx));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -39,9 +39,9 @@ using standard::char_;
|
||||||
using x3::lexeme;
|
using x3::lexeme;
|
||||||
using x3::lit;
|
using x3::lit;
|
||||||
|
|
||||||
struct unesc_char_ : x3::symbols<char>
|
struct unesc_char_csv_ : x3::symbols<char>
|
||||||
{
|
{
|
||||||
unesc_char_()
|
unesc_char_csv_()
|
||||||
{
|
{
|
||||||
add("\\a", '\a') //
|
add("\\a", '\a') //
|
||||||
("\\b", '\b') //
|
("\\b", '\b') //
|
||||||
|
@ -56,7 +56,7 @@ struct unesc_char_ : x3::symbols<char>
|
||||||
("\"\"", '\"') // double quote
|
("\"\"", '\"') // double quote
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
} unesc_char;
|
} const unesc_char_csv;
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
struct literal : x3::parser<literal<T>>
|
struct literal : x3::parser<literal<T>>
|
||||||
|
@ -93,7 +93,7 @@ auto const column_def = quoted_text | *(char_ - separator);
|
||||||
auto const quoted_text_def = quote > text > quote // support unmatched quotes or not (??)
|
auto const quoted_text_def = quote > text > quote // support unmatched quotes or not (??)
|
||||||
;
|
;
|
||||||
|
|
||||||
auto const text_def = *(unesc_char | (char_ - quote));
|
auto const text_def = *(unesc_char_csv | (char_ - quote));
|
||||||
|
|
||||||
BOOST_SPIRIT_DEFINE(line, column, quoted_text, text);
|
BOOST_SPIRIT_DEFINE(line, column, quoted_text, text);
|
||||||
|
|
||||||
|
|
|
@ -113,25 +113,6 @@ class datasource_deleter
|
||||||
};
|
};
|
||||||
|
|
||||||
using datasource_ptr = std::shared_ptr<datasource>;
|
using datasource_ptr = std::shared_ptr<datasource>;
|
||||||
|
|
||||||
#ifdef MAPNIK_STATIC_PLUGINS
|
|
||||||
#define DATASOURCE_PLUGIN(classname)
|
|
||||||
#else
|
|
||||||
#define DATASOURCE_PLUGIN(classname) \
|
|
||||||
extern "C" MAPNIK_EXP const char* datasource_name() \
|
|
||||||
{ \
|
|
||||||
return classname::name(); \
|
|
||||||
} \
|
|
||||||
extern "C" MAPNIK_EXP datasource* create(parameters const& params) \
|
|
||||||
{ \
|
|
||||||
return new classname(params); \
|
|
||||||
} \
|
|
||||||
extern "C" MAPNIK_EXP void destroy(datasource* ds) \
|
|
||||||
{ \
|
|
||||||
delete ds; \
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
} // namespace mapnik
|
} // namespace mapnik
|
||||||
|
|
||||||
#endif // MAPNIK_DATASOURCE_HPP
|
#endif // MAPNIK_DATASOURCE_HPP
|
||||||
|
|
|
@ -47,7 +47,8 @@ class MAPNIK_DECL datasource_cache : public singleton<datasource_cache, CreateSt
|
||||||
friend class CreateStatic<datasource_cache>;
|
friend class CreateStatic<datasource_cache>;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::vector<std::string> plugin_names();
|
bool plugin_registered(const std::string& plugin_name) const;
|
||||||
|
std::vector<std::string> plugin_names() const;
|
||||||
std::string plugin_directories();
|
std::string plugin_directories();
|
||||||
bool register_datasources(std::string const& path, bool recurse = false);
|
bool register_datasources(std::string const& path, bool recurse = false);
|
||||||
bool register_datasource(std::string const& path);
|
bool register_datasource(std::string const& path);
|
||||||
|
@ -62,7 +63,7 @@ class MAPNIK_DECL datasource_cache : public singleton<datasource_cache, CreateSt
|
||||||
// but the instance also needs its own mutex to protect the
|
// but the instance also needs its own mutex to protect the
|
||||||
// plugins_ and plugin_directories_ members which are potentially
|
// plugins_ and plugin_directories_ members which are potentially
|
||||||
// modified recusrively by register_datasources(path, true);
|
// modified recusrively by register_datasources(path, true);
|
||||||
std::recursive_mutex instance_mutex_;
|
mutable std::recursive_mutex instance_mutex_;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern template class MAPNIK_DECL singleton<datasource_cache, CreateStatic>;
|
extern template class MAPNIK_DECL singleton<datasource_cache, CreateStatic>;
|
||||||
|
|
|
@ -51,23 +51,17 @@ namespace grammar {
|
||||||
namespace x3 = boost::spirit::x3;
|
namespace x3 = boost::spirit::x3;
|
||||||
namespace ascii = boost::spirit::x3::ascii;
|
namespace ascii = boost::spirit::x3::ascii;
|
||||||
using ascii::char_;
|
using ascii::char_;
|
||||||
using ascii::string;
|
|
||||||
using x3::_attr;
|
using x3::_attr;
|
||||||
using x3::_val;
|
using x3::_val;
|
||||||
using x3::alnum;
|
using x3::alnum;
|
||||||
using x3::alpha;
|
using x3::alpha;
|
||||||
using x3::bool_;
|
|
||||||
using x3::double_;
|
|
||||||
using x3::int_;
|
|
||||||
using x3::lexeme;
|
using x3::lexeme;
|
||||||
using x3::lit;
|
using x3::lit;
|
||||||
using x3::no_case;
|
using x3::no_case;
|
||||||
using x3::no_skip;
|
using x3::no_skip;
|
||||||
x3::uint_parser<char, 16, 2, 2> const hex2{};
|
x3::uint_parser<char, 16, 2, 2> const hex2{};
|
||||||
|
|
||||||
namespace {
|
const auto escaped_unicode = json::grammar::escaped_unicode;
|
||||||
auto const& escaped_unicode = json::grammar::escaped_unicode;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename Context>
|
template<typename Context>
|
||||||
inline mapnik::transcoder const& extract_transcoder(Context const& ctx)
|
inline mapnik::transcoder const& extract_transcoder(Context const& ctx)
|
||||||
|
@ -75,19 +69,19 @@ inline mapnik::transcoder const& extract_transcoder(Context const& ctx)
|
||||||
return x3::get<transcoder_tag>(ctx);
|
return x3::get<transcoder_tag>(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto append = [](auto const& ctx) {
|
const auto append = [](auto const& ctx) {
|
||||||
_val(ctx) += _attr(ctx);
|
_val(ctx) += _attr(ctx);
|
||||||
};
|
};
|
||||||
|
|
||||||
auto do_assign = [](auto const& ctx) {
|
const auto do_assign = [](auto const& ctx) {
|
||||||
_val(ctx) = std::move(_attr(ctx));
|
_val(ctx) = std::move(_attr(ctx));
|
||||||
};
|
};
|
||||||
|
|
||||||
auto do_negate = [](auto const& ctx) {
|
const auto do_negate = [](auto const& ctx) {
|
||||||
_val(ctx) = std::move(unary_node<mapnik::tags::negate>(_attr(ctx)));
|
_val(ctx) = std::move(unary_node<mapnik::tags::negate>(_attr(ctx)));
|
||||||
};
|
};
|
||||||
|
|
||||||
auto do_attribute = [](auto const& ctx) {
|
const auto do_attribute = [](auto const& ctx) {
|
||||||
auto const& attr = _attr(ctx);
|
auto const& attr = _attr(ctx);
|
||||||
if (attr == "mapnik::geometry_type")
|
if (attr == "mapnik::geometry_type")
|
||||||
{
|
{
|
||||||
|
@ -99,84 +93,84 @@ auto do_attribute = [](auto const& ctx) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
auto do_global_attribute = [](auto const& ctx) {
|
const auto do_global_attribute = [](auto const& ctx) {
|
||||||
_val(ctx) = std::move(global_attribute(_attr(ctx)));
|
_val(ctx) = std::move(global_attribute(_attr(ctx)));
|
||||||
};
|
};
|
||||||
|
|
||||||
auto do_add = [](auto const& ctx) {
|
const auto do_add = [](auto const& ctx) {
|
||||||
_val(ctx) = std::move(mapnik::binary_node<mapnik::tags::plus>(std::move(_val(ctx)), std::move(_attr(ctx))));
|
_val(ctx) = std::move(mapnik::binary_node<mapnik::tags::plus>(std::move(_val(ctx)), std::move(_attr(ctx))));
|
||||||
};
|
};
|
||||||
|
|
||||||
auto do_subt = [](auto const& ctx) {
|
const auto do_subt = [](auto const& ctx) {
|
||||||
_val(ctx) = std::move(mapnik::binary_node<mapnik::tags::minus>(std::move(_val(ctx)), std::move(_attr(ctx))));
|
_val(ctx) = std::move(mapnik::binary_node<mapnik::tags::minus>(std::move(_val(ctx)), std::move(_attr(ctx))));
|
||||||
};
|
};
|
||||||
|
|
||||||
auto do_mult = [](auto const& ctx) {
|
const auto do_mult = [](auto const& ctx) {
|
||||||
_val(ctx) = std::move(mapnik::binary_node<mapnik::tags::mult>(std::move(_val(ctx)), std::move(_attr(ctx))));
|
_val(ctx) = std::move(mapnik::binary_node<mapnik::tags::mult>(std::move(_val(ctx)), std::move(_attr(ctx))));
|
||||||
};
|
};
|
||||||
|
|
||||||
auto do_div = [](auto const& ctx) {
|
const auto do_div = [](auto const& ctx) {
|
||||||
_val(ctx) = std::move(mapnik::binary_node<mapnik::tags::div>(std::move(_val(ctx)), std::move(_attr(ctx))));
|
_val(ctx) = std::move(mapnik::binary_node<mapnik::tags::div>(std::move(_val(ctx)), std::move(_attr(ctx))));
|
||||||
};
|
};
|
||||||
|
|
||||||
auto do_mod = [](auto const& ctx) {
|
const auto do_mod = [](auto const& ctx) {
|
||||||
_val(ctx) = std::move(mapnik::binary_node<mapnik::tags::mod>(std::move(_val(ctx)), std::move(_attr(ctx))));
|
_val(ctx) = std::move(mapnik::binary_node<mapnik::tags::mod>(std::move(_val(ctx)), std::move(_attr(ctx))));
|
||||||
};
|
};
|
||||||
|
|
||||||
auto do_unicode = [](auto const& ctx) {
|
const auto do_unicode = [](auto const& ctx) {
|
||||||
auto const& tr = extract_transcoder(ctx);
|
auto const& tr = extract_transcoder(ctx);
|
||||||
_val(ctx) = std::move(tr.transcode(_attr(ctx).c_str()));
|
_val(ctx) = std::move(tr.transcode(_attr(ctx).c_str()));
|
||||||
};
|
};
|
||||||
|
|
||||||
auto do_null = [](auto const& ctx) {
|
const auto do_null = [](auto const& ctx) {
|
||||||
_val(ctx) = std::move(mapnik::value_null());
|
_val(ctx) = std::move(mapnik::value_null());
|
||||||
};
|
};
|
||||||
|
|
||||||
auto do_not = [](auto const& ctx) {
|
const auto do_not = [](auto const& ctx) {
|
||||||
mapnik::unary_node<mapnik::tags::logical_not> node(_attr(ctx));
|
mapnik::unary_node<mapnik::tags::logical_not> node(_attr(ctx));
|
||||||
_val(ctx) = std::move(node);
|
_val(ctx) = std::move(node);
|
||||||
};
|
};
|
||||||
|
|
||||||
auto do_and = [](auto const& ctx) {
|
const auto do_and = [](auto const& ctx) {
|
||||||
_val(ctx) = std::move(mapnik::binary_node<mapnik::tags::logical_and>(std::move(_val(ctx)), std::move(_attr(ctx))));
|
_val(ctx) = std::move(mapnik::binary_node<mapnik::tags::logical_and>(std::move(_val(ctx)), std::move(_attr(ctx))));
|
||||||
};
|
};
|
||||||
|
|
||||||
auto do_or = [](auto const& ctx) {
|
const auto do_or = [](auto const& ctx) {
|
||||||
_val(ctx) = std::move(mapnik::binary_node<mapnik::tags::logical_or>(std::move(_val(ctx)), std::move(_attr(ctx))));
|
_val(ctx) = std::move(mapnik::binary_node<mapnik::tags::logical_or>(std::move(_val(ctx)), std::move(_attr(ctx))));
|
||||||
};
|
};
|
||||||
|
|
||||||
auto do_equal = [](auto const& ctx) {
|
const auto do_equal = [](auto const& ctx) {
|
||||||
_val(ctx) = std::move(mapnik::binary_node<mapnik::tags::equal_to>(std::move(_val(ctx)), std::move(_attr(ctx))));
|
_val(ctx) = std::move(mapnik::binary_node<mapnik::tags::equal_to>(std::move(_val(ctx)), std::move(_attr(ctx))));
|
||||||
};
|
};
|
||||||
|
|
||||||
auto do_not_equal = [](auto const& ctx) {
|
const auto do_not_equal = [](auto const& ctx) {
|
||||||
_val(ctx) = std::move(mapnik::binary_node<mapnik::tags::not_equal_to>(std::move(_val(ctx)), std::move(_attr(ctx))));
|
_val(ctx) = std::move(mapnik::binary_node<mapnik::tags::not_equal_to>(std::move(_val(ctx)), std::move(_attr(ctx))));
|
||||||
};
|
};
|
||||||
|
|
||||||
auto do_less = [](auto const& ctx) {
|
const auto do_less = [](auto const& ctx) {
|
||||||
_val(ctx) = std::move(mapnik::binary_node<mapnik::tags::less>(std::move(_val(ctx)), std::move(_attr(ctx))));
|
_val(ctx) = std::move(mapnik::binary_node<mapnik::tags::less>(std::move(_val(ctx)), std::move(_attr(ctx))));
|
||||||
};
|
};
|
||||||
|
|
||||||
auto do_less_equal = [](auto const& ctx) {
|
const auto do_less_equal = [](auto const& ctx) {
|
||||||
_val(ctx) = std::move(mapnik::binary_node<mapnik::tags::less_equal>(std::move(_val(ctx)), std::move(_attr(ctx))));
|
_val(ctx) = std::move(mapnik::binary_node<mapnik::tags::less_equal>(std::move(_val(ctx)), std::move(_attr(ctx))));
|
||||||
};
|
};
|
||||||
|
|
||||||
auto do_greater = [](auto const& ctx) {
|
const auto do_greater = [](auto const& ctx) {
|
||||||
_val(ctx) = std::move(mapnik::binary_node<mapnik::tags::greater>(std::move(_val(ctx)), std::move(_attr(ctx))));
|
_val(ctx) = std::move(mapnik::binary_node<mapnik::tags::greater>(std::move(_val(ctx)), std::move(_attr(ctx))));
|
||||||
};
|
};
|
||||||
|
|
||||||
auto do_greater_equal = [](auto const& ctx) {
|
const auto do_greater_equal = [](auto const& ctx) {
|
||||||
_val(ctx) =
|
_val(ctx) =
|
||||||
std::move(mapnik::binary_node<mapnik::tags::greater_equal>(std::move(_val(ctx)), std::move(_attr(ctx))));
|
std::move(mapnik::binary_node<mapnik::tags::greater_equal>(std::move(_val(ctx)), std::move(_attr(ctx))));
|
||||||
};
|
};
|
||||||
|
|
||||||
// regex
|
// regex
|
||||||
auto do_regex_match = [](auto const& ctx) {
|
const auto do_regex_match = [](auto const& ctx) {
|
||||||
auto const& tr = extract_transcoder(ctx);
|
auto const& tr = extract_transcoder(ctx);
|
||||||
_val(ctx) = std::move(mapnik::regex_match_node(tr, std::move(_val(ctx)), std::move(_attr(ctx))));
|
_val(ctx) = std::move(mapnik::regex_match_node(tr, std::move(_val(ctx)), std::move(_attr(ctx))));
|
||||||
};
|
};
|
||||||
|
|
||||||
auto do_regex_replace = [](auto const& ctx) {
|
const auto do_regex_replace = [](auto const& ctx) {
|
||||||
auto const& tr = extract_transcoder(ctx);
|
auto const& tr = extract_transcoder(ctx);
|
||||||
auto const& pair = _attr(ctx);
|
auto const& pair = _attr(ctx);
|
||||||
auto const& pattern = std::get<0>(pair);
|
auto const& pattern = std::get<0>(pair);
|
||||||
|
@ -197,7 +191,7 @@ struct boolean_ : x3::symbols<mapnik::value_bool>
|
||||||
("false", false) //
|
("false", false) //
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
} boolean;
|
} const boolean;
|
||||||
|
|
||||||
struct floating_point_constants : x3::symbols<mapnik::value_double>
|
struct floating_point_constants : x3::symbols<mapnik::value_double>
|
||||||
{
|
{
|
||||||
|
@ -208,7 +202,7 @@ struct floating_point_constants : x3::symbols<mapnik::value_double>
|
||||||
("rad_to_deg", 57.295779513082320876798154814105) //
|
("rad_to_deg", 57.295779513082320876798154814105) //
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
} float_const;
|
} const float_const;
|
||||||
|
|
||||||
// unary functions
|
// unary functions
|
||||||
struct unary_function_types_ : x3::symbols<unary_function_impl>
|
struct unary_function_types_ : x3::symbols<unary_function_impl>
|
||||||
|
@ -225,7 +219,7 @@ struct unary_function_types_ : x3::symbols<unary_function_impl>
|
||||||
("length", length_impl()) //
|
("length", length_impl()) //
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
} unary_func_types;
|
} const unary_func_types;
|
||||||
|
|
||||||
// binary functions
|
// binary functions
|
||||||
|
|
||||||
|
@ -238,7 +232,7 @@ struct binary_function_types_ : x3::symbols<binary_function_impl>
|
||||||
("pow", binary_function_impl(pow_impl)) //
|
("pow", binary_function_impl(pow_impl)) //
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
} binary_func_types;
|
} const binary_func_types;
|
||||||
|
|
||||||
// geometry types
|
// geometry types
|
||||||
struct geometry_types_ : x3::symbols<mapnik::value_integer>
|
struct geometry_types_ : x3::symbols<mapnik::value_integer>
|
||||||
|
@ -251,7 +245,7 @@ struct geometry_types_ : x3::symbols<mapnik::value_integer>
|
||||||
("collection", 4) //
|
("collection", 4) //
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
} geometry_type;
|
} const geometry_type;
|
||||||
|
|
||||||
struct unesc_chars_ : x3::symbols<char>
|
struct unesc_chars_ : x3::symbols<char>
|
||||||
{
|
{
|
||||||
|
@ -269,7 +263,7 @@ struct unesc_chars_ : x3::symbols<char>
|
||||||
("\\\"", '\"') //
|
("\\\"", '\"') //
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
} unesc_char;
|
} const unesc_char;
|
||||||
|
|
||||||
// rules
|
// rules
|
||||||
x3::rule<class logical_expression, mapnik::expr_node> const logical_expression("logical expression");
|
x3::rule<class logical_expression, mapnik::expr_node> const logical_expression("logical expression");
|
||||||
|
|
|
@ -57,41 +57,35 @@ namespace x3 = boost::spirit::x3;
|
||||||
|
|
||||||
namespace image_filter {
|
namespace image_filter {
|
||||||
|
|
||||||
using x3::attr;
|
|
||||||
using x3::char_;
|
|
||||||
using x3::double_;
|
using x3::double_;
|
||||||
using x3::hex;
|
|
||||||
using x3::lit;
|
using x3::lit;
|
||||||
using x3::no_case;
|
|
||||||
using x3::no_skip;
|
|
||||||
using x3::omit;
|
|
||||||
using x3::symbols;
|
using x3::symbols;
|
||||||
using x3::uint_parser;
|
using x3::uint_parser;
|
||||||
|
|
||||||
auto push_back = [](auto& ctx) {
|
const auto push_back = [](auto& ctx) {
|
||||||
_val(ctx).push_back(_attr(ctx));
|
_val(ctx).push_back(_attr(ctx));
|
||||||
};
|
};
|
||||||
|
|
||||||
auto set_rx_ry = [](auto& ctx) {
|
const auto set_rx_ry = [](auto& ctx) {
|
||||||
_val(ctx).rx = _val(ctx).ry = _attr(ctx);
|
_val(ctx).rx = _val(ctx).ry = _attr(ctx);
|
||||||
};
|
};
|
||||||
|
|
||||||
auto set_ry = [](auto& ctx) {
|
const auto set_ry = [](auto& ctx) {
|
||||||
_val(ctx).ry = _attr(ctx);
|
_val(ctx).ry = _attr(ctx);
|
||||||
};
|
};
|
||||||
|
|
||||||
auto offset_value = [](auto& ctx) {
|
const auto offset_value = [](auto& ctx) {
|
||||||
_val(ctx) = _attr(ctx);
|
_val(ctx) = _attr(ctx);
|
||||||
};
|
};
|
||||||
|
|
||||||
auto percent = [](auto& ctx) {
|
const auto percent = [](auto& ctx) {
|
||||||
double val = std::abs(_val(ctx) / 100.0);
|
double val = std::abs(_val(ctx) / 100.0);
|
||||||
if (val > 1.0)
|
if (val > 1.0)
|
||||||
val = 1.0;
|
val = 1.0;
|
||||||
_val(ctx) = val;
|
_val(ctx) = val;
|
||||||
};
|
};
|
||||||
|
|
||||||
x3::uint_parser<unsigned, 10, 1, 3> radius;
|
const x3::uint_parser<unsigned, 10, 1, 3> radius;
|
||||||
|
|
||||||
// Import the expression rule
|
// Import the expression rule
|
||||||
namespace {
|
namespace {
|
||||||
|
|
|
@ -154,14 +154,14 @@ struct geometry_type_ : x3::symbols<mapnik::geometry::geometry_types>
|
||||||
("\"GeometryCollection\"", mapnik::geometry::geometry_types::GeometryCollection) //
|
("\"GeometryCollection\"", mapnik::geometry::geometry_types::GeometryCollection) //
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
} geometry_type_symbols;
|
} const geometry_type_symbols;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
auto assign_name = [](auto const& ctx) {
|
const auto assign_name = [](auto const& ctx) {
|
||||||
std::get<0>(_val(ctx)) = std::move(_attr(ctx));
|
std::get<0>(_val(ctx)) = std::move(_attr(ctx));
|
||||||
};
|
};
|
||||||
auto assign_value = [](auto const& ctx) {
|
const auto assign_value = [](auto const& ctx) {
|
||||||
std::get<1>(_val(ctx)) = std::move(_attr(ctx));
|
std::get<1>(_val(ctx)) = std::move(_attr(ctx));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -207,7 +207,7 @@ auto const assign_collection = [](auto const& ctx) {
|
||||||
std::get<2>(_val(ctx)) = std::move(_attr(ctx));
|
std::get<2>(_val(ctx)) = std::move(_attr(ctx));
|
||||||
};
|
};
|
||||||
|
|
||||||
auto assign_property = [](auto const& ctx) {
|
const auto assign_property = [](auto const& ctx) {
|
||||||
mapnik::feature_impl& feature = x3::get<grammar::feature_tag>(ctx);
|
mapnik::feature_impl& feature = x3::get<grammar::feature_tag>(ctx);
|
||||||
mapnik::transcoder const& tr = x3::get<grammar::transcoder_tag>(ctx);
|
mapnik::transcoder const& tr = x3::get<grammar::transcoder_tag>(ctx);
|
||||||
feature.put_new(std::get<0>(_attr(ctx)),
|
feature.put_new(std::get<0>(_attr(ctx)),
|
||||||
|
|
|
@ -35,39 +35,36 @@ namespace x3 = boost::spirit::x3;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
auto make_null = [](auto const& ctx) {
|
const auto make_null = [](auto const& ctx) {
|
||||||
_val(ctx) = mapnik::value_null{};
|
_val(ctx) = mapnik::value_null{};
|
||||||
};
|
};
|
||||||
|
|
||||||
auto make_true = [](auto const& ctx) {
|
const auto make_true = [](auto const& ctx) {
|
||||||
_val(ctx) = true;
|
_val(ctx) = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
auto make_false = [](auto const& ctx) {
|
const auto make_false = [](auto const& ctx) {
|
||||||
_val(ctx) = false;
|
_val(ctx) = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
auto assign = [](auto const& ctx) {
|
const auto assign = [](auto const& ctx) {
|
||||||
_val(ctx) = std::move(_attr(ctx));
|
_val(ctx) = std::move(_attr(ctx));
|
||||||
};
|
};
|
||||||
|
|
||||||
auto assign_key = [](auto const& ctx) {
|
const auto assign_key = [](auto const& ctx) {
|
||||||
std::get<0>(_val(ctx)) = std::move(_attr(ctx));
|
std::get<0>(_val(ctx)) = std::move(_attr(ctx));
|
||||||
};
|
};
|
||||||
|
|
||||||
auto assign_value = [](auto const& ctx) {
|
const auto assign_value = [](auto const& ctx) {
|
||||||
std::get<1>(_val(ctx)) = std::move(_attr(ctx));
|
std::get<1>(_val(ctx)) = std::move(_attr(ctx));
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
using x3::lit;
|
using x3::lit;
|
||||||
using x3::string;
|
|
||||||
|
|
||||||
// import unicode string rule
|
// import unicode string rule
|
||||||
namespace {
|
const auto json_string = mapnik::json::grammar::unicode_string;
|
||||||
auto const& json_string = mapnik::json::grammar::unicode_string;
|
|
||||||
}
|
|
||||||
|
|
||||||
// rules
|
// rules
|
||||||
x3::rule<class json_object_tag, json_object> const object("JSON Object");
|
x3::rule<class json_object_tag, json_object> const object("JSON Object");
|
||||||
|
|
|
@ -35,30 +35,30 @@ namespace grammar {
|
||||||
|
|
||||||
namespace x3 = boost::spirit::x3;
|
namespace x3 = boost::spirit::x3;
|
||||||
|
|
||||||
auto make_null = [](auto const& ctx) {
|
const auto make_null = [](auto const& ctx) {
|
||||||
_val(ctx) = mapnik::value_null{};
|
_val(ctx) = mapnik::value_null{};
|
||||||
};
|
};
|
||||||
|
|
||||||
auto make_true = [](auto const& ctx) {
|
const auto make_true = [](auto const& ctx) {
|
||||||
_val(ctx) = true;
|
_val(ctx) = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
auto make_false = [](auto const& ctx) {
|
const auto make_false = [](auto const& ctx) {
|
||||||
_val(ctx) = false;
|
_val(ctx) = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
auto assign = [](auto const& ctx) {
|
const auto assign = [](auto const& ctx) {
|
||||||
_val(ctx) = std::move(_attr(ctx));
|
_val(ctx) = std::move(_attr(ctx));
|
||||||
};
|
};
|
||||||
|
|
||||||
auto assign_key = [](auto const& ctx) {
|
const auto assign_key = [](auto const& ctx) {
|
||||||
std::string const& name = _attr(ctx);
|
std::string const& name = _attr(ctx);
|
||||||
keys_map& keys = x3::get<keys_tag>(ctx);
|
keys_map& keys = x3::get<keys_tag>(ctx);
|
||||||
auto result = keys.insert(keys_map::value_type(name, keys.size() + 1));
|
auto result = keys.insert(keys_map::value_type(name, keys.size() + 1));
|
||||||
std::get<0>(_val(ctx)) = result.first->right;
|
std::get<0>(_val(ctx)) = result.first->right;
|
||||||
};
|
};
|
||||||
|
|
||||||
auto assign_value = [](auto const& ctx) {
|
const auto assign_value = [](auto const& ctx) {
|
||||||
std::get<1>(_val(ctx)) = std::move(_attr(ctx));
|
std::get<1>(_val(ctx)) = std::move(_attr(ctx));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ struct geometry_type_ : x3::symbols<mapnik::geometry::geometry_types>
|
||||||
("\"GeometryCollection\"", mapnik::geometry::geometry_types::GeometryCollection) //
|
("\"GeometryCollection\"", mapnik::geometry::geometry_types::GeometryCollection) //
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
} geometry_type_sym;
|
} const geometry_type_sym;
|
||||||
|
|
||||||
// rules
|
// rules
|
||||||
x3::rule<class json_object_tag, geojson_object> const object("JSON Object");
|
x3::rule<class json_object_tag, geojson_object> const object("JSON Object");
|
||||||
|
@ -95,13 +95,9 @@ auto const geojson_double = x3::real_parser<value_double, x3::strict_real_polici
|
||||||
auto const geojson_integer = x3::int_parser<value_integer, 10, 1, -1>();
|
auto const geojson_integer = x3::int_parser<value_integer, 10, 1, -1>();
|
||||||
|
|
||||||
// import unicode string rule
|
// import unicode string rule
|
||||||
namespace {
|
const auto geojson_string = unicode_string;
|
||||||
auto const& geojson_string = unicode_string;
|
|
||||||
}
|
|
||||||
// import positions rule
|
// import positions rule
|
||||||
namespace {
|
const auto positions_rule = positions;
|
||||||
auto const& positions_rule = positions;
|
|
||||||
}
|
|
||||||
|
|
||||||
// GeoJSON types
|
// GeoJSON types
|
||||||
// clang-format off
|
// clang-format off
|
||||||
|
|
|
@ -33,14 +33,11 @@ namespace grammar {
|
||||||
namespace x3 = boost::spirit::x3;
|
namespace x3 = boost::spirit::x3;
|
||||||
using x3::double_;
|
using x3::double_;
|
||||||
using x3::lit;
|
using x3::lit;
|
||||||
using x3::no_case;
|
|
||||||
using x3::omit;
|
using x3::omit;
|
||||||
|
|
||||||
namespace {
|
const auto assign_helper = [](auto const& ctx) {
|
||||||
auto assign_helper = [](auto const& ctx) {
|
|
||||||
_val(ctx) = std::move(_attr(ctx));
|
_val(ctx) = std::move(_attr(ctx));
|
||||||
};
|
};
|
||||||
} // namespace
|
|
||||||
|
|
||||||
// rules
|
// rules
|
||||||
x3::rule<class point_class, point> const point("Position");
|
x3::rule<class point_class, point> const point("Position");
|
||||||
|
|
|
@ -169,7 +169,7 @@ struct create_multi_polygon
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
auto create_geometry = [](auto const& ctx) {
|
const auto create_geometry = [](auto const& ctx) {
|
||||||
auto const geom_type = std::get<0>(_attr(ctx));
|
auto const geom_type = std::get<0>(_attr(ctx));
|
||||||
auto const& coord = std::get<1>(_attr(ctx));
|
auto const& coord = std::get<1>(_attr(ctx));
|
||||||
auto const& arcs = std::get<2>(_attr(ctx));
|
auto const& arcs = std::get<2>(_attr(ctx));
|
||||||
|
@ -199,27 +199,27 @@ auto create_geometry = [](auto const& ctx) {
|
||||||
_val(ctx) = std::move(geom);
|
_val(ctx) = std::move(geom);
|
||||||
};
|
};
|
||||||
|
|
||||||
auto assign_bbox = [](auto const& ctx) {
|
const auto assign_bbox = [](auto const& ctx) {
|
||||||
_val(ctx).bbox = std::move(_attr(ctx));
|
_val(ctx).bbox = std::move(_attr(ctx));
|
||||||
};
|
};
|
||||||
|
|
||||||
auto assign_transform = [](auto const& ctx) {
|
const auto assign_transform = [](auto const& ctx) {
|
||||||
_val(ctx).tr = std::move(_attr(ctx));
|
_val(ctx).tr = std::move(_attr(ctx));
|
||||||
};
|
};
|
||||||
|
|
||||||
auto assign_arcs = [](auto const& ctx) {
|
const auto assign_arcs = [](auto const& ctx) {
|
||||||
_val(ctx).arcs = std::move(_attr(ctx));
|
_val(ctx).arcs = std::move(_attr(ctx));
|
||||||
};
|
};
|
||||||
|
|
||||||
auto assign_objects = [](auto const& ctx) {
|
const auto assign_objects = [](auto const& ctx) {
|
||||||
_val(ctx).geometries = std::move(_attr(ctx));
|
_val(ctx).geometries = std::move(_attr(ctx));
|
||||||
};
|
};
|
||||||
|
|
||||||
auto push_geometry = [](auto const& ctx) {
|
const auto push_geometry = [](auto const& ctx) {
|
||||||
_val(ctx).push_back(std::move(_attr(ctx)));
|
_val(ctx).push_back(std::move(_attr(ctx)));
|
||||||
};
|
};
|
||||||
|
|
||||||
auto push_collection = [](auto const& ctx) {
|
const auto push_collection = [](auto const& ctx) {
|
||||||
auto& dest = _val(ctx);
|
auto& dest = _val(ctx);
|
||||||
auto& src = _attr(ctx);
|
auto& src = _attr(ctx);
|
||||||
if (dest.empty())
|
if (dest.empty())
|
||||||
|
@ -231,27 +231,27 @@ auto push_collection = [](auto const& ctx) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
auto assign_geometry_type = [](auto const& ctx) {
|
const auto assign_geometry_type = [](auto const& ctx) {
|
||||||
std::get<0>(_val(ctx)) = _attr(ctx);
|
std::get<0>(_val(ctx)) = _attr(ctx);
|
||||||
};
|
};
|
||||||
|
|
||||||
auto assign_coordinates = [](auto const& ctx) {
|
const auto assign_coordinates = [](auto const& ctx) {
|
||||||
std::get<1>(_val(ctx)) = std::move(_attr(ctx));
|
std::get<1>(_val(ctx)) = std::move(_attr(ctx));
|
||||||
};
|
};
|
||||||
|
|
||||||
auto assign_rings = [](auto const& ctx) {
|
const auto assign_rings = [](auto const& ctx) {
|
||||||
std::get<2>(_val(ctx)) = std::move(_attr(ctx));
|
std::get<2>(_val(ctx)) = std::move(_attr(ctx));
|
||||||
};
|
};
|
||||||
|
|
||||||
auto assign_properties = [](auto const& ctx) {
|
const auto assign_properties = [](auto const& ctx) {
|
||||||
std::get<3>(_val(ctx)) = std::move(_attr(ctx));
|
std::get<3>(_val(ctx)) = std::move(_attr(ctx));
|
||||||
};
|
};
|
||||||
|
|
||||||
auto assign_prop_name = [](auto const& ctx) {
|
const auto assign_prop_name = [](auto const& ctx) {
|
||||||
std::get<0>(_val(ctx)) = std::move(_attr(ctx));
|
std::get<0>(_val(ctx)) = std::move(_attr(ctx));
|
||||||
};
|
};
|
||||||
|
|
||||||
auto assign_prop_value = [](auto const& ctx) {
|
const auto assign_prop_value = [](auto const& ctx) {
|
||||||
std::get<1>(_val(ctx)) = std::move(_attr(ctx));
|
std::get<1>(_val(ctx)) = std::move(_attr(ctx));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -262,12 +262,10 @@ using x3::int_;
|
||||||
using x3::lit;
|
using x3::lit;
|
||||||
using x3::omit;
|
using x3::omit;
|
||||||
|
|
||||||
namespace {
|
|
||||||
// import unicode string rule
|
// import unicode string rule
|
||||||
auto const& json_string = json::grammar::unicode_string;
|
const auto json_string = json::grammar::unicode_string;
|
||||||
// json value
|
// json value
|
||||||
auto const& json_value = json::grammar::value;
|
const auto json_value = json::grammar::value;
|
||||||
} // namespace
|
|
||||||
|
|
||||||
using coordinates_type = util::variant<topojson::coordinate, std::vector<topojson::coordinate>>;
|
using coordinates_type = util::variant<topojson::coordinate, std::vector<topojson::coordinate>>;
|
||||||
using arcs_type = util::variant<std::vector<index_type>,
|
using arcs_type = util::variant<std::vector<index_type>,
|
||||||
|
@ -287,7 +285,7 @@ struct topojson_geometry_type_ : x3::symbols<int>
|
||||||
("\"MultiPolygon\"", 6) //
|
("\"MultiPolygon\"", 6) //
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
} topojson_geometry_type;
|
} const topojson_geometry_type;
|
||||||
|
|
||||||
// rules
|
// rules
|
||||||
x3::rule<class transform_tag, mapnik::topojson::transform> const transform = "Transform";
|
x3::rule<class transform_tag, mapnik::topojson::transform> const transform = "Transform";
|
||||||
|
|
|
@ -35,7 +35,7 @@ namespace x3 = boost::spirit::x3;
|
||||||
|
|
||||||
using uchar = std::uint32_t; // a unicode code point
|
using uchar = std::uint32_t; // a unicode code point
|
||||||
|
|
||||||
auto append = [](auto const& ctx) {
|
const auto append = [](auto const& ctx) {
|
||||||
_val(ctx) += _attr(ctx);
|
_val(ctx) += _attr(ctx);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -50,15 +50,15 @@ static inline void push_utf8_impl(std::string& str, uchar code_point)
|
||||||
}
|
}
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
|
||||||
auto push_char = [](auto const& ctx) {
|
const auto push_char = [](auto const& ctx) {
|
||||||
_val(ctx).push_back(_attr(ctx));
|
_val(ctx).push_back(_attr(ctx));
|
||||||
};
|
};
|
||||||
|
|
||||||
auto push_utf8 = [](auto const& ctx) {
|
const auto push_utf8 = [](auto const& ctx) {
|
||||||
detail::push_utf8_impl(_val(ctx), _attr(ctx));
|
detail::push_utf8_impl(_val(ctx), _attr(ctx));
|
||||||
};
|
};
|
||||||
|
|
||||||
auto push_utf16 = [](auto const& ctx) {
|
const auto push_utf16 = [](auto const& ctx) {
|
||||||
using iterator_type = std::vector<std::uint16_t>::const_iterator;
|
using iterator_type = std::vector<std::uint16_t>::const_iterator;
|
||||||
auto const& utf16 = _attr(ctx);
|
auto const& utf16 = _attr(ctx);
|
||||||
try
|
try
|
||||||
|
@ -76,7 +76,7 @@ auto push_utf16 = [](auto const& ctx) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
auto push_esc = [](auto const& ctx) {
|
const auto push_esc = [](auto const& ctx) {
|
||||||
std::string& utf8 = _val(ctx);
|
std::string& utf8 = _val(ctx);
|
||||||
char c = _attr(ctx);
|
char c = _attr(ctx);
|
||||||
switch (c)
|
switch (c)
|
||||||
|
|
9
include/mapnik/mapnik.hpp
Normal file
9
include/mapnik/mapnik.hpp
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
#ifndef MAPNIK_MAPNIK_HPP
|
||||||
|
#define MAPNIK_MAPNIK_HPP
|
||||||
|
#include "config.hpp"
|
||||||
|
|
||||||
|
namespace mapnik {
|
||||||
|
MAPNIK_DECL void setup();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -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;
|
||||||
|
|
|
@ -32,10 +32,10 @@ namespace grammar {
|
||||||
namespace x3 = boost::spirit::x3;
|
namespace x3 = boost::spirit::x3;
|
||||||
using x3::lexeme;
|
using x3::lexeme;
|
||||||
using x3::standard_wide::char_;
|
using x3::standard_wide::char_;
|
||||||
auto create_string = [](auto& ctx) {
|
const auto create_string = [](auto& ctx) {
|
||||||
_val(ctx).push_back(_attr(ctx));
|
_val(ctx).push_back(_attr(ctx));
|
||||||
};
|
};
|
||||||
auto create_attribute = [](auto& ctx) {
|
const auto create_attribute = [](auto& ctx) {
|
||||||
_val(ctx).push_back(mapnik::attribute(_attr(ctx)));
|
_val(ctx).push_back(mapnik::attribute(_attr(ctx)));
|
||||||
};
|
};
|
||||||
// rules
|
// rules
|
||||||
|
|
|
@ -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 {
|
||||||
|
|
||||||
|
@ -45,13 +45,10 @@ class PluginInfo : util::noncopyable
|
||||||
bool valid() const;
|
bool valid() const;
|
||||||
std::string get_error() const;
|
std::string get_error() const;
|
||||||
void* get_symbol(std::string const& sym_name) const;
|
void* get_symbol(std::string const& sym_name) const;
|
||||||
static void init();
|
|
||||||
static void exit();
|
|
||||||
|
|
||||||
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
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
#define MAPNIK_WEBP_IO_HPP
|
#define MAPNIK_WEBP_IO_HPP
|
||||||
|
|
||||||
// mapnik
|
// mapnik
|
||||||
|
#include <mapnik/config.hpp>
|
||||||
#include <mapnik/image.hpp>
|
#include <mapnik/image.hpp>
|
||||||
#include <mapnik/util/conversions.hpp>
|
#include <mapnik/util/conversions.hpp>
|
||||||
|
|
||||||
|
@ -50,45 +51,7 @@ int webp_stream_write(const uint8_t* data, size_t data_size, const WebPPicture*
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string webp_encoding_error(WebPEncodingError error)
|
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T2>
|
template<typename T2>
|
||||||
inline int import_image(T2 const& im_in, WebPPicture& pic, bool alpha)
|
inline int import_image(T2 const& im_in, WebPPicture& pic, bool alpha)
|
||||||
|
|
|
@ -47,17 +47,16 @@ namespace mapnik {
|
||||||
namespace grammar {
|
namespace grammar {
|
||||||
|
|
||||||
namespace x3 = boost::spirit::x3;
|
namespace x3 = boost::spirit::x3;
|
||||||
namespace ascii = boost::spirit::x3::ascii;
|
|
||||||
using x3::double_;
|
using x3::double_;
|
||||||
using x3::lit;
|
using x3::lit;
|
||||||
using x3::no_case;
|
using x3::no_case;
|
||||||
|
|
||||||
// functors
|
// functors
|
||||||
auto make_empty = [](auto const& ctx) {
|
const auto make_empty = [](auto const& ctx) {
|
||||||
_val(ctx) = geometry::geometry_empty();
|
_val(ctx) = geometry::geometry_empty();
|
||||||
};
|
};
|
||||||
|
|
||||||
auto add_ring = [](auto const& ctx) {
|
const auto add_ring = [](auto const& ctx) {
|
||||||
auto& ring = reinterpret_cast<geometry::linear_ring<double>&>(_attr(ctx));
|
auto& ring = reinterpret_cast<geometry::linear_ring<double>&>(_attr(ctx));
|
||||||
_val(ctx).push_back(std::move(ring));
|
_val(ctx).push_back(std::move(ring));
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,28 @@
|
||||||
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_fpic ON)
|
||||||
|
set(_plugin_linkage MODULE)
|
||||||
|
set(_plugin_visibility PRIVATE)
|
||||||
|
if(NOT BUILD_SHARED_PLUGINS)
|
||||||
|
set(_plugin_linkage INTERFACE)
|
||||||
|
set(_plugin_visibility INTERFACE)
|
||||||
|
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}"
|
||||||
|
)
|
||||||
|
mapnik_install_plugin(${plugin_target})
|
||||||
|
endmacro()
|
||||||
|
|
||||||
|
|
||||||
|
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
|
||||||
set(m_build_plugins "")
|
set(m_build_plugins "")
|
||||||
|
@ -51,7 +74,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.
|
# 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(BUILD_SHARED_PLUGINS AND WIN32)
|
||||||
list(LENGTH m_build_plugins m_number_plugins)
|
list(LENGTH m_build_plugins m_number_plugins)
|
||||||
if(m_number_plugins GREATER 0)
|
if(m_number_plugins GREATER 0)
|
||||||
string(CONFIGURE
|
string(CONFIGURE
|
||||||
|
|
12
plugins/input/base/CMakeLists.txt
Normal file
12
plugins/input/base/CMakeLists.txt
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
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)
|
||||||
|
install(DIRECTORY include/ DESTINATION "${MAPNIK_INCLUDE_DIR}")
|
54
plugins/input/base/include/mapnik/datasource_plugin.hpp
Normal file
54
plugins/input/base/include/mapnik/datasource_plugin.hpp
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
#ifndef DATASOURCE_PLUGIN_HPP
|
||||||
|
#define DATASOURCE_PLUGIN_HPP
|
||||||
|
#include <string>
|
||||||
|
#include <mapnik/config.hpp>
|
||||||
|
#include <mapnik/datasource.hpp>
|
||||||
|
|
||||||
|
namespace mapnik {
|
||||||
|
class MAPNIK_DECL datasource_plugin
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
datasource_plugin() = default;
|
||||||
|
virtual ~datasource_plugin() = default;
|
||||||
|
virtual void after_load() const = 0;
|
||||||
|
virtual void before_unload() const = 0;
|
||||||
|
virtual const char* name() const = 0;
|
||||||
|
virtual datasource_ptr create(parameters const& params) const = 0;
|
||||||
|
};
|
||||||
|
} // namespace mapnik
|
||||||
|
|
||||||
|
#define DATASOURCE_PLUGIN_DEF(classname, pluginname) \
|
||||||
|
class classname : public mapnik::datasource_plugin \
|
||||||
|
{ \
|
||||||
|
public: \
|
||||||
|
static constexpr const char* kName = #pluginname; \
|
||||||
|
void after_load() const override; \
|
||||||
|
void before_unload() const override; \
|
||||||
|
const char* name() const override; \
|
||||||
|
mapnik::datasource_ptr create(mapnik::parameters const& params) const override; \
|
||||||
|
};
|
||||||
|
|
||||||
|
#define DATASOURCE_PLUGIN_IMPL(classname, pluginclassname) \
|
||||||
|
const char* 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_AFTER_LOAD(classname) \
|
||||||
|
void classname::after_load() const {}
|
||||||
|
#define DATASOURCE_PLUGIN_EMPTY_BEFORE_UNLOAD(classname) \
|
||||||
|
void classname::before_unload() 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
|
|
@ -1,21 +1,15 @@
|
||||||
add_library(input-csv MODULE
|
add_plugin_target(input-csv "csv")
|
||||||
|
|
||||||
|
target_sources(input-csv ${_plugin_visibility}
|
||||||
csv_datasource.cpp
|
csv_datasource.cpp
|
||||||
csv_featureset.cpp
|
csv_featureset.cpp
|
||||||
csv_index_featureset.cpp
|
csv_index_featureset.cpp
|
||||||
csv_inline_featureset.cpp
|
csv_inline_featureset.cpp
|
||||||
csv_utils.cpp
|
csv_utils.cpp
|
||||||
)
|
)
|
||||||
target_link_libraries(input-csv PRIVATE
|
target_link_libraries(input-csv ${_plugin_visibility}
|
||||||
mapnik::mapnik
|
mapnik::mapnik
|
||||||
mapnik::wkt
|
mapnik::wkt
|
||||||
mapnik::json
|
mapnik::json
|
||||||
|
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)
|
|
||||||
|
|
|
@ -65,7 +65,10 @@ MAPNIK_DISABLE_WARNING_POP
|
||||||
using mapnik::datasource;
|
using mapnik::datasource;
|
||||||
using mapnik::parameters;
|
using mapnik::parameters;
|
||||||
|
|
||||||
DATASOURCE_PLUGIN(csv_datasource)
|
DATASOURCE_PLUGIN_IMPL(csv_datasource_plugin, csv_datasource);
|
||||||
|
DATASOURCE_PLUGIN_EXPORT(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)
|
||||||
|
|
|
@ -48,6 +48,8 @@ MAPNIK_DISABLE_WARNING_POP
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#include <mapnik/datasource_plugin.hpp>
|
||||||
|
|
||||||
template<std::size_t Max, std::size_t Min>
|
template<std::size_t Max, std::size_t Min>
|
||||||
struct csv_linear : boost::geometry::index::linear<Max, Min>
|
struct csv_linear : boost::geometry::index::linear<Max, Min>
|
||||||
{};
|
{};
|
||||||
|
@ -79,6 +81,8 @@ struct options_type<csv_linear<Max, Min>>
|
||||||
} // namespace geometry
|
} // namespace geometry
|
||||||
} // namespace boost
|
} // namespace boost
|
||||||
|
|
||||||
|
DATASOURCE_PLUGIN_DEF(csv_datasource_plugin, csv);
|
||||||
|
|
||||||
class csv_datasource : public mapnik::datasource,
|
class csv_datasource : public mapnik::datasource,
|
||||||
private csv_utils::csv_file_parser
|
private csv_utils::csv_file_parser
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,20 +1,13 @@
|
||||||
find_package(GDAL REQUIRED)
|
find_package(GDAL REQUIRED)
|
||||||
|
|
||||||
add_library(input-gdal MODULE
|
add_plugin_target(input-gdal "gdal")
|
||||||
|
target_sources(input-gdal ${_plugin_visibility}
|
||||||
gdal_datasource.cpp
|
gdal_datasource.cpp
|
||||||
gdal_featureset.cpp
|
gdal_featureset.cpp
|
||||||
)
|
)
|
||||||
target_include_directories(input-gdal PRIVATE ${GDAL_INCLUDE_DIRS})
|
target_include_directories(input-gdal ${_plugin_visibility} ${GDAL_INCLUDE_DIRS})
|
||||||
target_link_libraries(input-gdal PRIVATE
|
target_link_libraries(input-gdal ${_plugin_visibility}
|
||||||
mapnik::mapnik
|
mapnik::mapnik
|
||||||
|
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)
|
|
||||||
|
|
|
@ -37,8 +37,6 @@
|
||||||
using mapnik::datasource;
|
using mapnik::datasource;
|
||||||
using mapnik::parameters;
|
using mapnik::parameters;
|
||||||
|
|
||||||
DATASOURCE_PLUGIN(gdal_datasource)
|
|
||||||
|
|
||||||
using mapnik::box2d;
|
using mapnik::box2d;
|
||||||
using mapnik::coord2d;
|
using mapnik::coord2d;
|
||||||
using mapnik::datasource_exception;
|
using mapnik::datasource_exception;
|
||||||
|
@ -46,12 +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_EXPORT(gdal_datasource_plugin);
|
||||||
extern "C" MAPNIK_EXP void on_plugin_load()
|
void gdal_datasource_plugin::after_load() const
|
||||||
{
|
{
|
||||||
// initialize gdal formats
|
GDALAllRegister();
|
||||||
std::call_once(once_flag, []() { GDALAllRegister(); });
|
}
|
||||||
|
|
||||||
|
void gdal_datasource_plugin::before_unload() const
|
||||||
|
{
|
||||||
|
GDALDestroyDriverManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
gdal_datasource::gdal_datasource(parameters const& params)
|
gdal_datasource::gdal_datasource(parameters const& params)
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
#include <mapnik/geometry/box2d.hpp>
|
#include <mapnik/geometry/box2d.hpp>
|
||||||
#include <mapnik/coord.hpp>
|
#include <mapnik/coord.hpp>
|
||||||
#include <mapnik/feature_layer_desc.hpp>
|
#include <mapnik/feature_layer_desc.hpp>
|
||||||
|
#include <mapnik/datasource_plugin.hpp>
|
||||||
// boost
|
// boost
|
||||||
#include <boost/optional.hpp>
|
#include <boost/optional.hpp>
|
||||||
|
|
||||||
|
@ -42,6 +42,8 @@
|
||||||
// gdal
|
// gdal
|
||||||
#include <gdal_priv.h>
|
#include <gdal_priv.h>
|
||||||
|
|
||||||
|
DATASOURCE_PLUGIN_DEF(gdal_datasource_plugin, gdal);
|
||||||
|
|
||||||
class gdal_datasource : public mapnik::datasource
|
class gdal_datasource : public mapnik::datasource
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -1,14 +1,10 @@
|
||||||
add_library(input-geobuf MODULE
|
add_plugin_target(input-geobuf "geobuf")
|
||||||
|
|
||||||
|
target_sources(input-geobuf ${_plugin_visibility}
|
||||||
geobuf_datasource.cpp
|
geobuf_datasource.cpp
|
||||||
geobuf_featureset.cpp
|
geobuf_featureset.cpp
|
||||||
)
|
)
|
||||||
target_link_libraries(input-geobuf PRIVATE mapnik::mapnik)
|
target_link_libraries(input-geobuf ${_plugin_visibility}
|
||||||
set_target_properties(input-geobuf PROPERTIES
|
mapnik::mapnik
|
||||||
OUTPUT_NAME "geobuf"
|
mapnik::datasource-base
|
||||||
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)
|
|
||||||
|
|
|
@ -48,7 +48,10 @@
|
||||||
using mapnik::datasource;
|
using mapnik::datasource;
|
||||||
using mapnik::parameters;
|
using mapnik::parameters;
|
||||||
|
|
||||||
DATASOURCE_PLUGIN(geobuf_datasource)
|
DATASOURCE_PLUGIN_IMPL(geobuf_datasource_plugin, geobuf_datasource);
|
||||||
|
DATASOURCE_PLUGIN_EXPORT(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
|
||||||
{
|
{
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
#include <mapnik/coord.hpp>
|
#include <mapnik/coord.hpp>
|
||||||
#include <mapnik/feature_layer_desc.hpp>
|
#include <mapnik/feature_layer_desc.hpp>
|
||||||
#include <mapnik/unicode.hpp>
|
#include <mapnik/unicode.hpp>
|
||||||
|
#include <mapnik/datasource_plugin.hpp>
|
||||||
// boost
|
// boost
|
||||||
#include <boost/optional.hpp>
|
#include <boost/optional.hpp>
|
||||||
#include <mapnik/warning.hpp>
|
#include <mapnik/warning.hpp>
|
||||||
|
@ -84,6 +85,7 @@ struct options_type<geobuf_linear<Max, Min>>
|
||||||
} // namespace geometry
|
} // namespace geometry
|
||||||
} // namespace boost
|
} // namespace boost
|
||||||
|
|
||||||
|
DATASOURCE_PLUGIN_DEF(geobuf_datasource_plugin, geobuf);
|
||||||
class geobuf_datasource : public mapnik::datasource
|
class geobuf_datasource : public mapnik::datasource
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -1,19 +1,12 @@
|
||||||
add_library(input-geojson MODULE
|
add_plugin_target(input-geojson "geojson")
|
||||||
|
target_sources(input-geojson ${_plugin_visibility}
|
||||||
geojson_datasource.cpp
|
geojson_datasource.cpp
|
||||||
geojson_featureset.cpp
|
geojson_featureset.cpp
|
||||||
geojson_index_featureset.cpp
|
geojson_index_featureset.cpp
|
||||||
geojson_memory_index_featureset.cpp
|
geojson_memory_index_featureset.cpp
|
||||||
)
|
)
|
||||||
target_link_libraries(input-geojson PRIVATE
|
target_link_libraries(input-geojson ${_plugin_visibility}
|
||||||
mapnik::mapnik
|
mapnik::mapnik
|
||||||
mapnik::json
|
mapnik::json
|
||||||
|
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)
|
|
||||||
|
|
|
@ -67,7 +67,10 @@ MAPNIK_DISABLE_WARNING_POP
|
||||||
using mapnik::datasource;
|
using mapnik::datasource;
|
||||||
using mapnik::parameters;
|
using mapnik::parameters;
|
||||||
|
|
||||||
DATASOURCE_PLUGIN(geojson_datasource)
|
DATASOURCE_PLUGIN_IMPL(geojson_datasource_plugin, geojson_datasource);
|
||||||
|
DATASOURCE_PLUGIN_EXPORT(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
|
||||||
{
|
{
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
#include <mapnik/coord.hpp>
|
#include <mapnik/coord.hpp>
|
||||||
#include <mapnik/feature_layer_desc.hpp>
|
#include <mapnik/feature_layer_desc.hpp>
|
||||||
#include <mapnik/unicode.hpp>
|
#include <mapnik/unicode.hpp>
|
||||||
|
#include <mapnik/datasource_plugin.hpp>
|
||||||
|
|
||||||
#include <mapnik/warning.hpp>
|
#include <mapnik/warning.hpp>
|
||||||
MAPNIK_DISABLE_WARNING_PUSH
|
MAPNIK_DISABLE_WARNING_PUSH
|
||||||
|
@ -82,6 +83,8 @@ struct options_type<geojson_linear<Max, Min>>
|
||||||
} // namespace geometry
|
} // namespace geometry
|
||||||
} // namespace boost
|
} // namespace boost
|
||||||
|
|
||||||
|
DATASOURCE_PLUGIN_DEF(geojson_datasource_plugin, geojson);
|
||||||
|
|
||||||
class geojson_datasource : public mapnik::datasource
|
class geojson_datasource : public mapnik::datasource
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -1,22 +1,15 @@
|
||||||
find_package(GDAL REQUIRED)
|
find_package(GDAL REQUIRED)
|
||||||
|
|
||||||
add_library(input-ogr MODULE
|
add_plugin_target(input-ogr "ogr")
|
||||||
|
target_sources(input-ogr ${_plugin_visibility}
|
||||||
ogr_converter.cpp
|
ogr_converter.cpp
|
||||||
ogr_datasource.cpp
|
ogr_datasource.cpp
|
||||||
ogr_featureset.cpp
|
ogr_featureset.cpp
|
||||||
ogr_index_featureset.cpp
|
ogr_index_featureset.cpp
|
||||||
)
|
)
|
||||||
target_include_directories(input-ogr PRIVATE ${GDAL_INCLUDE_DIRS})
|
target_include_directories(input-ogr ${_plugin_visibility} ${GDAL_INCLUDE_DIRS})
|
||||||
target_link_libraries(input-ogr PRIVATE
|
target_link_libraries(input-ogr ${_plugin_visibility}
|
||||||
mapnik::mapnik
|
mapnik::mapnik
|
||||||
|
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)
|
|
||||||
|
|
|
@ -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;
|
||||||
|
@ -63,11 +62,21 @@ using mapnik::query;
|
||||||
|
|
||||||
static std::once_flag once_flag;
|
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::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)
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
#include <mapnik/geometry/box2d.hpp>
|
#include <mapnik/geometry/box2d.hpp>
|
||||||
#include <mapnik/coord.hpp>
|
#include <mapnik/coord.hpp>
|
||||||
#include <mapnik/feature_layer_desc.hpp>
|
#include <mapnik/feature_layer_desc.hpp>
|
||||||
|
#include <mapnik/datasource_plugin.hpp>
|
||||||
|
|
||||||
// boost
|
// boost
|
||||||
#include <boost/optional.hpp>
|
#include <boost/optional.hpp>
|
||||||
|
@ -47,6 +48,8 @@ MAPNIK_DISABLE_WARNING_PUSH
|
||||||
MAPNIK_DISABLE_WARNING_POP
|
MAPNIK_DISABLE_WARNING_POP
|
||||||
#include "ogr_layer_ptr.hpp"
|
#include "ogr_layer_ptr.hpp"
|
||||||
|
|
||||||
|
DATASOURCE_PLUGIN_DEF(ogr_datasource_plugin, ogr);
|
||||||
|
|
||||||
class ogr_datasource : public mapnik::datasource
|
class ogr_datasource : public mapnik::datasource
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -1,20 +1,13 @@
|
||||||
find_package(PostgreSQL REQUIRED)
|
mapnik_find_package(PostgreSQL REQUIRED)
|
||||||
|
|
||||||
add_library(input-pgraster MODULE
|
add_plugin_target(input-pgraster "pgraster")
|
||||||
|
target_sources(input-pgraster ${_plugin_visibility}
|
||||||
pgraster_datasource.cpp
|
pgraster_datasource.cpp
|
||||||
pgraster_featureset.cpp
|
pgraster_featureset.cpp
|
||||||
pgraster_wkb_reader.cpp
|
pgraster_wkb_reader.cpp
|
||||||
)
|
)
|
||||||
target_link_libraries(input-pgraster PRIVATE
|
target_link_libraries(input-pgraster ${_plugin_visibility}
|
||||||
mapnik::mapnik
|
mapnik::mapnik
|
||||||
|
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)
|
|
||||||
|
|
|
@ -51,7 +51,10 @@ MAPNIK_DISABLE_WARNING_POP
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
DATASOURCE_PLUGIN(pgraster_datasource)
|
DATASOURCE_PLUGIN_IMPL(pgraster_datasource_plugin, pgraster_datasource);
|
||||||
|
DATASOURCE_PLUGIN_EXPORT(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";
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
#include <mapnik/feature_layer_desc.hpp>
|
#include <mapnik/feature_layer_desc.hpp>
|
||||||
#include <mapnik/unicode.hpp>
|
#include <mapnik/unicode.hpp>
|
||||||
#include <mapnik/value/types.hpp>
|
#include <mapnik/value/types.hpp>
|
||||||
|
#include <mapnik/datasource_plugin.hpp>
|
||||||
|
|
||||||
// boost
|
// boost
|
||||||
#include <boost/optional.hpp>
|
#include <boost/optional.hpp>
|
||||||
|
@ -73,6 +74,7 @@ struct pgraster_overview
|
||||||
float scale; // max absolute scale between x and y
|
float scale; // max absolute scale between x and y
|
||||||
};
|
};
|
||||||
|
|
||||||
|
DATASOURCE_PLUGIN_DEF(pgraster_datasource_plugin, pgraster);
|
||||||
class pgraster_datasource : public datasource
|
class pgraster_datasource : public datasource
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -1,19 +1,12 @@
|
||||||
find_package(PostgreSQL REQUIRED)
|
mapnik_find_package(PostgreSQL REQUIRED)
|
||||||
|
|
||||||
add_library(input-postgis MODULE
|
add_plugin_target(input-postgis "postgis")
|
||||||
|
target_sources(input-postgis ${_plugin_visibility}
|
||||||
postgis_datasource.cpp
|
postgis_datasource.cpp
|
||||||
postgis_featureset.cpp
|
postgis_featureset.cpp
|
||||||
)
|
)
|
||||||
target_link_libraries(input-postgis PRIVATE
|
target_link_libraries(input-postgis ${_plugin_visibility}
|
||||||
mapnik::mapnik
|
mapnik::mapnik
|
||||||
|
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)
|
|
||||||
|
|
|
@ -48,7 +48,10 @@ MAPNIK_DISABLE_WARNING_POP
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
DATASOURCE_PLUGIN(postgis_datasource)
|
DATASOURCE_PLUGIN_IMPL(postgis_datasource_plugin, postgis_datasource);
|
||||||
|
DATASOURCE_PLUGIN_EXPORT(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";
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
#include <mapnik/unicode.hpp>
|
#include <mapnik/unicode.hpp>
|
||||||
#include <mapnik/value/types.hpp>
|
#include <mapnik/value/types.hpp>
|
||||||
#include <mapnik/attribute.hpp>
|
#include <mapnik/attribute.hpp>
|
||||||
|
#include <mapnik/datasource_plugin.hpp>
|
||||||
|
|
||||||
// boost
|
// boost
|
||||||
#include <boost/optional.hpp>
|
#include <boost/optional.hpp>
|
||||||
|
@ -62,6 +63,7 @@ using mapnik::transcoder;
|
||||||
|
|
||||||
using CnxPool_ptr = std::shared_ptr<ConnectionManager::PoolType>;
|
using CnxPool_ptr = std::shared_ptr<ConnectionManager::PoolType>;
|
||||||
|
|
||||||
|
DATASOURCE_PLUGIN_DEF(postgis_datasource_plugin, postgis);
|
||||||
class postgis_datasource : public datasource
|
class postgis_datasource : public datasource
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -1,15 +1,10 @@
|
||||||
add_library(input-raster MODULE
|
add_plugin_target(input-raster "raster")
|
||||||
|
target_sources(input-raster ${_plugin_visibility}
|
||||||
raster_datasource.cpp
|
raster_datasource.cpp
|
||||||
raster_featureset.cpp
|
raster_featureset.cpp
|
||||||
raster_info.cpp
|
raster_info.cpp
|
||||||
)
|
)
|
||||||
target_link_libraries(input-raster PRIVATE mapnik::mapnik)
|
target_link_libraries(input-raster ${_plugin_visibility}
|
||||||
set_target_properties(input-raster PROPERTIES
|
mapnik::mapnik
|
||||||
OUTPUT_NAME "raster"
|
mapnik::datasource-base
|
||||||
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)
|
|
||||||
|
|
|
@ -43,7 +43,10 @@ using mapnik::layer_descriptor;
|
||||||
using mapnik::parameters;
|
using mapnik::parameters;
|
||||||
using mapnik::query;
|
using mapnik::query;
|
||||||
|
|
||||||
DATASOURCE_PLUGIN(raster_datasource)
|
DATASOURCE_PLUGIN_IMPL(raster_datasource_plugin, raster_datasource);
|
||||||
|
DATASOURCE_PLUGIN_EXPORT(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)
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
#include <mapnik/geometry/box2d.hpp>
|
#include <mapnik/geometry/box2d.hpp>
|
||||||
#include <mapnik/coord.hpp>
|
#include <mapnik/coord.hpp>
|
||||||
#include <mapnik/feature_layer_desc.hpp>
|
#include <mapnik/feature_layer_desc.hpp>
|
||||||
|
#include <mapnik/datasource_plugin.hpp>
|
||||||
|
|
||||||
// boost
|
// boost
|
||||||
#include <boost/optional.hpp>
|
#include <boost/optional.hpp>
|
||||||
|
@ -40,6 +41,8 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
DATASOURCE_PLUGIN_DEF(raster_datasource_plugin, raster);
|
||||||
|
|
||||||
class raster_datasource : public mapnik::datasource
|
class raster_datasource : public mapnik::datasource
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
add_library(input-shape MODULE
|
add_plugin_target(input-shape "shape")
|
||||||
|
target_sources(input-shape ${_plugin_visibility}
|
||||||
dbfile.cpp
|
dbfile.cpp
|
||||||
dbf_test.cpp
|
dbf_test.cpp
|
||||||
shape_datasource.cpp
|
shape_datasource.cpp
|
||||||
|
@ -6,13 +7,7 @@ add_library(input-shape MODULE
|
||||||
shape_index_featureset.cpp
|
shape_index_featureset.cpp
|
||||||
shape_io.cpp shape_utils.cpp
|
shape_io.cpp shape_utils.cpp
|
||||||
)
|
)
|
||||||
target_link_libraries(input-shape PRIVATE mapnik::mapnik)
|
target_link_libraries(input-shape ${_plugin_visibility}
|
||||||
set_target_properties(input-shape PROPERTIES
|
mapnik::mapnik
|
||||||
OUTPUT_NAME "shape"
|
mapnik::datasource-base
|
||||||
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)
|
|
||||||
|
|
|
@ -47,7 +47,10 @@ MAPNIK_DISABLE_WARNING_POP
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
DATASOURCE_PLUGIN(shape_datasource)
|
DATASOURCE_PLUGIN_IMPL(shape_datasource_plugin, shape_datasource);
|
||||||
|
DATASOURCE_PLUGIN_EXPORT(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;
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
#include <mapnik/coord.hpp>
|
#include <mapnik/coord.hpp>
|
||||||
#include <mapnik/feature_layer_desc.hpp>
|
#include <mapnik/feature_layer_desc.hpp>
|
||||||
#include <mapnik/value/types.hpp>
|
#include <mapnik/value/types.hpp>
|
||||||
|
#include <mapnik/datasource_plugin.hpp>
|
||||||
|
|
||||||
// boost
|
// boost
|
||||||
#include <boost/optional.hpp>
|
#include <boost/optional.hpp>
|
||||||
|
@ -50,6 +51,8 @@ using mapnik::layer_descriptor;
|
||||||
using mapnik::parameters;
|
using mapnik::parameters;
|
||||||
using mapnik::query;
|
using mapnik::query;
|
||||||
|
|
||||||
|
DATASOURCE_PLUGIN_DEF(shape_datasource_plugin, shape);
|
||||||
|
|
||||||
class shape_datasource : public datasource
|
class shape_datasource : public datasource
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -1,20 +1,12 @@
|
||||||
find_package(SQLite3 REQUIRED)
|
find_package(SQLite3 REQUIRED)
|
||||||
|
|
||||||
add_library(input-sqlite MODULE
|
add_plugin_target(input-sqlite "sqlite")
|
||||||
|
target_sources(input-sqlite ${_plugin_visibility}
|
||||||
sqlite_datasource.cpp
|
sqlite_datasource.cpp
|
||||||
sqlite_featureset.cpp
|
sqlite_featureset.cpp
|
||||||
)
|
)
|
||||||
add_library(mapnik::plugin::input::sqlite ALIAS input-sqlite)
|
target_link_libraries(input-sqlite ${_plugin_visibility}
|
||||||
target_link_libraries(input-sqlite PRIVATE
|
|
||||||
mapnik::mapnik
|
mapnik::mapnik
|
||||||
|
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)
|
|
||||||
|
|
|
@ -50,7 +50,10 @@ using mapnik::layer_descriptor;
|
||||||
using mapnik::parameters;
|
using mapnik::parameters;
|
||||||
using mapnik::query;
|
using mapnik::query;
|
||||||
|
|
||||||
DATASOURCE_PLUGIN(sqlite_datasource)
|
DATASOURCE_PLUGIN_IMPL(sqlite_datasource_plugin, sqlite_datasource);
|
||||||
|
DATASOURCE_PLUGIN_EXPORT(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)
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
#include <mapnik/feature_layer_desc.hpp>
|
#include <mapnik/feature_layer_desc.hpp>
|
||||||
#include <mapnik/wkb.hpp>
|
#include <mapnik/wkb.hpp>
|
||||||
#include <mapnik/value/types.hpp>
|
#include <mapnik/value/types.hpp>
|
||||||
|
#include <mapnik/datasource_plugin.hpp>
|
||||||
|
|
||||||
// boost
|
// boost
|
||||||
#include <boost/optional.hpp>
|
#include <boost/optional.hpp>
|
||||||
|
@ -45,6 +46,8 @@
|
||||||
// sqlite
|
// sqlite
|
||||||
#include "sqlite_connection.hpp"
|
#include "sqlite_connection.hpp"
|
||||||
|
|
||||||
|
DATASOURCE_PLUGIN_DEF(sqlite_datasource_plugin, sqlite);
|
||||||
|
|
||||||
class sqlite_datasource : public mapnik::datasource
|
class sqlite_datasource : public mapnik::datasource
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -1,18 +1,10 @@
|
||||||
add_library(input-topojson MODULE
|
add_plugin_target(input-topojson "topojson")
|
||||||
|
target_sources(input-topojson ${_plugin_visibility}
|
||||||
topojson_datasource.cpp
|
topojson_datasource.cpp
|
||||||
topojson_featureset.cpp
|
topojson_featureset.cpp
|
||||||
)
|
)
|
||||||
add_library(mapnik::plugin::input::topojson ALIAS input-topojson)
|
target_link_libraries(input-topojson ${_plugin_visibility}
|
||||||
target_link_libraries(input-topojson PRIVATE
|
|
||||||
mapnik::mapnik
|
mapnik::mapnik
|
||||||
mapnik::json
|
mapnik::json
|
||||||
|
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)
|
|
||||||
|
|
|
@ -42,7 +42,10 @@
|
||||||
using mapnik::datasource;
|
using mapnik::datasource;
|
||||||
using mapnik::parameters;
|
using mapnik::parameters;
|
||||||
|
|
||||||
DATASOURCE_PLUGIN(topojson_datasource)
|
DATASOURCE_PLUGIN_IMPL(topojson_datasource_plugin, topojson_datasource);
|
||||||
|
DATASOURCE_PLUGIN_EXPORT(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
|
||||||
{
|
{
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
#include <mapnik/feature_layer_desc.hpp>
|
#include <mapnik/feature_layer_desc.hpp>
|
||||||
#include <mapnik/unicode.hpp>
|
#include <mapnik/unicode.hpp>
|
||||||
#include <mapnik/json/topology.hpp>
|
#include <mapnik/json/topology.hpp>
|
||||||
|
#include <mapnik/datasource_plugin.hpp>
|
||||||
|
|
||||||
#include <mapnik/warning.hpp>
|
#include <mapnik/warning.hpp>
|
||||||
MAPNIK_DISABLE_WARNING_PUSH
|
MAPNIK_DISABLE_WARNING_PUSH
|
||||||
|
@ -52,6 +53,8 @@ MAPNIK_DISABLE_WARNING_POP
|
||||||
#include <deque>
|
#include <deque>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
DATASOURCE_PLUGIN_DEF(topojson_datasource_plugin, topojson);
|
||||||
|
|
||||||
class topojson_datasource : public mapnik::datasource
|
class topojson_datasource : public mapnik::datasource
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -1,27 +1,55 @@
|
||||||
add_subdirectory(json)
|
add_subdirectory(json)
|
||||||
add_subdirectory(wkt)
|
add_subdirectory(wkt)
|
||||||
|
|
||||||
add_library(mapnik "")
|
|
||||||
add_library(mapnik::mapnik ALIAS mapnik)
|
|
||||||
|
|
||||||
if(BUILD_SHARED_LIBS)
|
if(BUILD_SHARED_LIBS)
|
||||||
|
# private as this should only be visibile when building, to dllexport/dllimport correctly
|
||||||
target_compile_definitions(mapnik PRIVATE MAPNIK_EXPORTS)
|
target_compile_definitions(mapnik PRIVATE MAPNIK_EXPORTS)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_link_libraries(mapnik PUBLIC mapnik::core)
|
target_link_libraries(mapnik PUBLIC mapnik::core mapnik::datasource-base)
|
||||||
target_link_libraries(mapnik PRIVATE mapnik::agg)
|
target_link_libraries(mapnik PRIVATE
|
||||||
|
mapnik::agg
|
||||||
|
# expr: if(BUILD_SHARED_PLUGINS == OFF && <target> is build) then add link target
|
||||||
|
$<$<AND:$<NOT:$<BOOL:${BUILD_SHARED_PLUGINS}>>,$<TARGET_EXISTS:input-csv>>:input-csv>
|
||||||
|
$<$<AND:$<NOT:$<BOOL:${BUILD_SHARED_PLUGINS}>>,$<TARGET_EXISTS:input-gdal>>:input-gdal>
|
||||||
|
$<$<AND:$<NOT:$<BOOL:${BUILD_SHARED_PLUGINS}>>,$<TARGET_EXISTS:input-geobuf>>:input-geobuf>
|
||||||
|
$<$<AND:$<NOT:$<BOOL:${BUILD_SHARED_PLUGINS}>>,$<TARGET_EXISTS:input-geojson>>:input-geojson>
|
||||||
|
$<$<AND:$<NOT:$<BOOL:${BUILD_SHARED_PLUGINS}>>,$<TARGET_EXISTS:input-ogr>>:input-ogr>
|
||||||
|
$<$<AND:$<NOT:$<BOOL:${BUILD_SHARED_PLUGINS}>>,$<TARGET_EXISTS:input-pgraster>>:input-pgraster>
|
||||||
|
$<$<AND:$<NOT:$<BOOL:${BUILD_SHARED_PLUGINS}>>,$<TARGET_EXISTS:input-postgis>>:input-postgis>
|
||||||
|
$<$<AND:$<NOT:$<BOOL:${BUILD_SHARED_PLUGINS}>>,$<TARGET_EXISTS:input-raster>>:input-raster>
|
||||||
|
$<$<AND:$<NOT:$<BOOL:${BUILD_SHARED_PLUGINS}>>,$<TARGET_EXISTS:input-shape>>:input-shape>
|
||||||
|
$<$<AND:$<NOT:$<BOOL:${BUILD_SHARED_PLUGINS}>>,$<TARGET_EXISTS:input-sqlite>>:input-sqlite>
|
||||||
|
$<$<AND:$<NOT:$<BOOL:${BUILD_SHARED_PLUGINS}>>,$<TARGET_EXISTS:input-topojson>>:input-topojson>
|
||||||
|
)
|
||||||
|
target_compile_definitions(mapnik PRIVATE
|
||||||
|
# expr: if(BUILD_SHARED_PLUGINS == OFF && <target> is build) then add build definition
|
||||||
|
$<$<AND:$<NOT:$<BOOL:${BUILD_SHARED_PLUGINS}>>,$<TARGET_EXISTS:input-csv>>:MAPNIK_STATIC_PLUGIN_CSV>
|
||||||
|
$<$<AND:$<NOT:$<BOOL:${BUILD_SHARED_PLUGINS}>>,$<TARGET_EXISTS:input-gdal>>:MAPNIK_STATIC_PLUGIN_GDAL>
|
||||||
|
$<$<AND:$<NOT:$<BOOL:${BUILD_SHARED_PLUGINS}>>,$<TARGET_EXISTS:input-geobuf>>:MAPNIK_STATIC_PLUGIN_GEOBUF>
|
||||||
|
$<$<AND:$<NOT:$<BOOL:${BUILD_SHARED_PLUGINS}>>,$<TARGET_EXISTS:input-geojson>>:MAPNIK_STATIC_PLUGIN_GEOJSON>
|
||||||
|
$<$<AND:$<NOT:$<BOOL:${BUILD_SHARED_PLUGINS}>>,$<TARGET_EXISTS:input-ogr>>:MAPNIK_STATIC_PLUGIN_OGR>
|
||||||
|
$<$<AND:$<NOT:$<BOOL:${BUILD_SHARED_PLUGINS}>>,$<TARGET_EXISTS:input-pgraster>>:MAPNIK_STATIC_PLUGIN_PGRASTER>
|
||||||
|
$<$<AND:$<NOT:$<BOOL:${BUILD_SHARED_PLUGINS}>>,$<TARGET_EXISTS:input-postgis>>:MAPNIK_STATIC_PLUGIN_POSTGIS>
|
||||||
|
$<$<AND:$<NOT:$<BOOL:${BUILD_SHARED_PLUGINS}>>,$<TARGET_EXISTS:input-raster>>:MAPNIK_STATIC_PLUGIN_RASTER>
|
||||||
|
$<$<AND:$<NOT:$<BOOL:${BUILD_SHARED_PLUGINS}>>,$<TARGET_EXISTS:input-shape>>:MAPNIK_STATIC_PLUGIN_SHAPE>
|
||||||
|
$<$<AND:$<NOT:$<BOOL:${BUILD_SHARED_PLUGINS}>>,$<TARGET_EXISTS:input-sqlite>>:MAPNIK_STATIC_PLUGIN_SQLITE>
|
||||||
|
$<$<AND:$<NOT:$<BOOL:${BUILD_SHARED_PLUGINS}>>,$<TARGET_EXISTS:input-topojson>>:MAPNIK_STATIC_PLUGIN_TOPOJSON>
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
|
if(NOT BUILD_SHARED_PLUGINS)
|
||||||
|
target_include_directories(mapnik PRIVATE "${PROJECT_SOURCE_DIR}/plugins")
|
||||||
|
endif()
|
||||||
|
|
||||||
set_target_properties(mapnik PROPERTIES
|
set_target_properties(mapnik PROPERTIES
|
||||||
DEBUG_POSTFIX "${MAPNIK_DEBUG_POSTFIX}"
|
POSITION_INDEPENDENT_CODE ON
|
||||||
OUTPUT_NAME "mapnik"
|
OUTPUT_NAME "mapnik"
|
||||||
PREFIX "lib"
|
PREFIX "lib"
|
||||||
IMPORT_PREFIX "lib" # for the archive on dll platforms
|
IMPORT_PREFIX "lib" # for the archive on dll platforms
|
||||||
VERSION ${MAPNIK_VERSION}
|
VERSION ${MAPNIK_VERSION}
|
||||||
# see https://github.com/mapnik/mapnik/pull/4248#issuecomment-925596509 => ABI compability only with the full version
|
# see https://github.com/mapnik/mapnik/pull/4248#issuecomment-925596509 => ABI compability only with the full version
|
||||||
SOVERSION ${MAPNIK_VERSION}
|
SOVERSION ${MAPNIK_VERSION}
|
||||||
LIBRARY_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
|
|
||||||
RUNTIME_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
|
|
||||||
ARCHIVE_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}/lib"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
|
@ -74,6 +102,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
|
||||||
|
@ -258,7 +287,10 @@ if(USE_TIFF)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(USE_WEBP)
|
if(USE_WEBP)
|
||||||
target_sources(mapnik PRIVATE webp_reader.cpp)
|
target_sources(mapnik PRIVATE
|
||||||
|
webp_reader.cpp
|
||||||
|
webp_io.cpp
|
||||||
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(USE_GRID_RENDERER)
|
if(USE_GRID_RENDERER)
|
||||||
|
|
|
@ -87,6 +87,7 @@ if '-DHAVE_TIFF' in env['CPPDEFINES']:
|
||||||
if '-DHAVE_WEBP' in env['CPPDEFINES']:
|
if '-DHAVE_WEBP' in env['CPPDEFINES']:
|
||||||
lib_env['LIBS'].append('webp')
|
lib_env['LIBS'].append('webp')
|
||||||
enabled_imaging_libraries.append('webp_reader.cpp')
|
enabled_imaging_libraries.append('webp_reader.cpp')
|
||||||
|
enabled_imaging_libraries.append('webp_io.cpp')
|
||||||
|
|
||||||
if env['XMLPARSER'] == 'libxml2' and env['HAS_LIBXML2']:
|
if env['XMLPARSER'] == 'libxml2' and env['HAS_LIBXML2']:
|
||||||
lib_env['LIBS'].append('xml2')
|
lib_env['LIBS'].append('xml2')
|
||||||
|
@ -152,6 +153,7 @@ else: # unix, non-macos
|
||||||
|
|
||||||
source = Split(
|
source = Split(
|
||||||
"""
|
"""
|
||||||
|
mapnik.cpp
|
||||||
expression_grammar_x3.cpp
|
expression_grammar_x3.cpp
|
||||||
fs.cpp
|
fs.cpp
|
||||||
request.cpp
|
request.cpp
|
||||||
|
|
19
src/create_image_reader.hpp
Normal file
19
src/create_image_reader.hpp
Normal 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
|
|
@ -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>
|
||||||
|
@ -53,15 +54,8 @@ bool is_input_plugin(std::string const& filename)
|
||||||
return boost::algorithm::ends_with(filename, std::string(".input"));
|
return boost::algorithm::ends_with(filename, std::string(".input"));
|
||||||
}
|
}
|
||||||
|
|
||||||
datasource_cache::datasource_cache()
|
datasource_cache::datasource_cache() {}
|
||||||
{
|
datasource_cache::~datasource_cache() {}
|
||||||
PluginInfo::init();
|
|
||||||
}
|
|
||||||
|
|
||||||
datasource_cache::~datasource_cache()
|
|
||||||
{
|
|
||||||
PluginInfo::exit();
|
|
||||||
}
|
|
||||||
|
|
||||||
datasource_ptr datasource_cache::create(parameters const& params)
|
datasource_ptr datasource_cache::create(parameters const& params)
|
||||||
{
|
{
|
||||||
|
@ -71,11 +65,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 +106,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()
|
||||||
|
@ -134,7 +124,29 @@ std::string datasource_cache::plugin_directories()
|
||||||
return boost::algorithm::join(plugin_directories_, ", ");
|
return boost::algorithm::join(plugin_directories_, ", ");
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> datasource_cache::plugin_names()
|
bool datasource_cache::plugin_registered(const std::string& plugin_name) const
|
||||||
|
{
|
||||||
|
#ifdef MAPNIK_STATIC_PLUGINS
|
||||||
|
const auto static_names = get_static_datasource_names();
|
||||||
|
const auto static_it = std::find(static_names.begin(), static_names.end(), plugin_name);
|
||||||
|
if (static_it != static_names.end())
|
||||||
|
return true;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef MAPNIK_THREADSAFE
|
||||||
|
std::lock_guard<std::recursive_mutex> lock(instance_mutex_);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
std::map<std::string, std::shared_ptr<PluginInfo>>::const_iterator itr;
|
||||||
|
for (itr = plugins_.begin(); itr != plugins_.end(); ++itr)
|
||||||
|
{
|
||||||
|
if (itr->second->name() == plugin_name)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> datasource_cache::plugin_names() const
|
||||||
{
|
{
|
||||||
std::vector<std::string> names;
|
std::vector<std::string> names;
|
||||||
|
|
||||||
|
|
|
@ -26,9 +26,7 @@
|
||||||
|
|
||||||
#ifdef MAPNIK_STATIC_PLUGINS
|
#ifdef MAPNIK_STATIC_PLUGINS
|
||||||
#include <mapnik/params.hpp>
|
#include <mapnik/params.hpp>
|
||||||
|
#include <mapnik/datasource_plugin.hpp>
|
||||||
// boost
|
|
||||||
#include <boost/assign/list_of.hpp>
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// stl
|
// stl
|
||||||
|
@ -43,6 +41,9 @@
|
||||||
#if defined(MAPNIK_STATIC_PLUGIN_GDAL)
|
#if defined(MAPNIK_STATIC_PLUGIN_GDAL)
|
||||||
#include "input/gdal/gdal_datasource.hpp"
|
#include "input/gdal/gdal_datasource.hpp"
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(MAPNIK_STATIC_PLUGIN_GEOBUF)
|
||||||
|
#include "input/geobuf/geobuf_datasource.hpp"
|
||||||
|
#endif
|
||||||
#if defined(MAPNIK_STATIC_PLUGIN_GEOJSON)
|
#if defined(MAPNIK_STATIC_PLUGIN_GEOJSON)
|
||||||
#include "input/geojson/geojson_datasource.hpp"
|
#include "input/geojson/geojson_datasource.hpp"
|
||||||
#endif
|
#endif
|
||||||
|
@ -58,6 +59,9 @@
|
||||||
#if defined(MAPNIK_STATIC_PLUGIN_OGR)
|
#if defined(MAPNIK_STATIC_PLUGIN_OGR)
|
||||||
#include "input/ogr/ogr_datasource.hpp"
|
#include "input/ogr/ogr_datasource.hpp"
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(MAPNIK_STATIC_PLUGIN_PGRASTER)
|
||||||
|
#include "input/pgraster/pgraster_datasource.hpp"
|
||||||
|
#endif
|
||||||
#if defined(MAPNIK_STATIC_PLUGIN_OSM)
|
#if defined(MAPNIK_STATIC_PLUGIN_OSM)
|
||||||
#include "input/osm/osm_datasource.hpp"
|
#include "input/osm/osm_datasource.hpp"
|
||||||
#endif
|
#endif
|
||||||
|
@ -76,11 +80,21 @@
|
||||||
#if defined(MAPNIK_STATIC_PLUGIN_SQLITE)
|
#if defined(MAPNIK_STATIC_PLUGIN_SQLITE)
|
||||||
#include "input/sqlite/sqlite_datasource.hpp"
|
#include "input/sqlite/sqlite_datasource.hpp"
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(MAPNIK_STATIC_PLUGIN_TOPOJSON)
|
||||||
|
#include "input/topojson/topojson_datasource.hpp"
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define REGISTER_STATIC_DATASOURCE_PLUGIN(classname) \
|
||||||
|
{ \
|
||||||
|
auto plugin = std::make_shared<classname>(); \
|
||||||
|
plugin->after_load(); \
|
||||||
|
ds_map.emplace(std::string{classname::kName}, std::move(plugin)); \
|
||||||
|
}
|
||||||
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)
|
||||||
{
|
{
|
||||||
|
@ -88,56 +102,65 @@ 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, 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{};
|
||||||
|
|
||||||
|
void init_datasource_cache_static()
|
||||||
|
{
|
||||||
#if defined(MAPNIK_STATIC_PLUGIN_CSV)
|
#if defined(MAPNIK_STATIC_PLUGIN_CSV)
|
||||||
(std::string("csv"), &ds_generator<csv_datasource>)
|
REGISTER_STATIC_DATASOURCE_PLUGIN(csv_datasource_plugin);
|
||||||
#endif
|
#endif
|
||||||
#if defined(MAPNIK_STATIC_PLUGIN_GDAL)
|
#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
|
#endif
|
||||||
#if defined(MAPNIK_STATIC_PLUGIN_GEOJSON)
|
#if defined(MAPNIK_STATIC_PLUGIN_GEOJSON)
|
||||||
(std::string("geojson"), &ds_generator<geojson_datasource>)
|
REGISTER_STATIC_DATASOURCE_PLUGIN(geojson_datasource_plugin);
|
||||||
#endif
|
#endif
|
||||||
#if defined(MAPNIK_STATIC_PLUGIN_OCCI)
|
#if defined(MAPNIK_STATIC_PLUGIN_OCCI)
|
||||||
(std::string("occi"), &ds_generator<occi_datasource>)
|
REGISTER_STATIC_DATASOURCE_PLUGIN(occi_datasource_plugin);
|
||||||
#endif
|
#endif
|
||||||
#if defined(MAPNIK_STATIC_PLUGIN_OGR)
|
#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
|
#endif
|
||||||
#if defined(MAPNIK_STATIC_PLUGIN_OSM)
|
#if defined(MAPNIK_STATIC_PLUGIN_OSM)
|
||||||
(std::string("osm"), &ds_generator<osm_datasource>)
|
REGISTER_STATIC_DATASOURCE_PLUGIN(osm_datasource_plugin);
|
||||||
#endif
|
#endif
|
||||||
#if defined(MAPNIK_STATIC_PLUGIN_POSTGIS)
|
#if defined(MAPNIK_STATIC_PLUGIN_POSTGIS)
|
||||||
(std::string("postgis"), &ds_generator<postgis_datasource>)
|
REGISTER_STATIC_DATASOURCE_PLUGIN(postgis_datasource_plugin);
|
||||||
#endif
|
#endif
|
||||||
#if defined(MAPNIK_STATIC_PLUGIN_RASTER)
|
#if defined(MAPNIK_STATIC_PLUGIN_RASTER)
|
||||||
(std::string("raster"), &ds_generator<raster_datasource>)
|
REGISTER_STATIC_DATASOURCE_PLUGIN(raster_datasource_plugin);
|
||||||
#endif
|
#endif
|
||||||
#if defined(MAPNIK_STATIC_PLUGIN_RASTERLITE)
|
#if defined(MAPNIK_STATIC_PLUGIN_RASTERLITE)
|
||||||
(std::string("rasterlite"), &ds_generator<rasterlite_datasource>)
|
REGISTER_STATIC_DATASOURCE_PLUGIN(rasterlite_datasource_plugin);
|
||||||
#endif
|
#endif
|
||||||
#if defined(MAPNIK_STATIC_PLUGIN_SHAPE)
|
#if defined(MAPNIK_STATIC_PLUGIN_SHAPE)
|
||||||
(std::string("shape"), &ds_generator<shape_datasource>)
|
REGISTER_STATIC_DATASOURCE_PLUGIN(shape_datasource_plugin);
|
||||||
#endif
|
#endif
|
||||||
#if defined(MAPNIK_STATIC_PLUGIN_SQLITE)
|
#if defined(MAPNIK_STATIC_PLUGIN_SQLITE)
|
||||||
(std::string("sqlite"), &ds_generator<sqlite_datasource>)
|
REGISTER_STATIC_DATASOURCE_PLUGIN(sqlite_datasource_plugin);
|
||||||
#endif
|
#endif
|
||||||
;
|
#if defined(MAPNIK_STATIC_PLUGIN_TOPOJSON)
|
||||||
|
REGISTER_STATIC_DATASOURCE_PLUGIN(topojson_datasource_plugin);
|
||||||
#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;
|
|
||||||
boost::optional<std::string> type = params.get<std::string>("type");
|
boost::optional<std::string> type = params.get<std::string>("type");
|
||||||
datasource_map::iterator it = ds_map.find(*type);
|
datasource_map::iterator it = ds_map.find(*type);
|
||||||
if (it != ds_map.end())
|
if (it != ds_map.end())
|
||||||
{
|
{
|
||||||
ds = it->second(params);
|
return it->second->create(params);
|
||||||
}
|
}
|
||||||
return ds;
|
return datasource_ptr{};
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
datasource_ptr create_static_datasource(parameters const& /*params*/)
|
datasource_ptr create_static_datasource(parameters const& /*params*/)
|
||||||
|
|
|
@ -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>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
add_library(json STATIC
|
target_sources(json PRIVATE
|
||||||
extract_bounding_boxes_x3.cpp
|
extract_bounding_boxes_x3.cpp
|
||||||
feature_from_geojson.cpp
|
feature_from_geojson.cpp
|
||||||
feature_grammar_x3.cpp
|
feature_grammar_x3.cpp
|
||||||
|
@ -13,7 +13,6 @@ add_library(json STATIC
|
||||||
topojson_grammar_x3.cpp
|
topojson_grammar_x3.cpp
|
||||||
unicode_string_grammar_x3.cpp
|
unicode_string_grammar_x3.cpp
|
||||||
)
|
)
|
||||||
add_library(mapnik::json ALIAS json)
|
|
||||||
|
|
||||||
target_include_directories(json PRIVATE
|
target_include_directories(json PRIVATE
|
||||||
${JPEG_INCLUDE_DIR}
|
${JPEG_INCLUDE_DIR}
|
||||||
|
@ -26,16 +25,12 @@ target_link_libraries(json PRIVATE mapnik::core ${ICUU_LIB})
|
||||||
|
|
||||||
set_target_properties(json PROPERTIES
|
set_target_properties(json PROPERTIES
|
||||||
POSITION_INDEPENDENT_CODE ON
|
POSITION_INDEPENDENT_CODE ON
|
||||||
DEBUG_POSTFIX "${MAPNIK_DEBUG_POSTFIX}"
|
|
||||||
OUTPUT_NAME "mapnikjson"
|
OUTPUT_NAME "mapnikjson"
|
||||||
PREFIX "lib"
|
PREFIX "lib"
|
||||||
IMPORT_PREFIX "lib"
|
IMPORT_PREFIX "lib"
|
||||||
VERSION ${MAPNIK_VERSION}
|
VERSION ${MAPNIK_VERSION}
|
||||||
# see mapnik target for explanation
|
# see mapnik target for explanation
|
||||||
SOVERSION ${MAPNIK_VERSION}
|
SOVERSION ${MAPNIK_VERSION}
|
||||||
LIBRARY_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
|
|
||||||
RUNTIME_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
|
|
||||||
ARCHIVE_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}/lib"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
mapnik_install(json)
|
mapnik_install(json)
|
||||||
|
|
53
src/mapnik.cpp
Normal file
53
src/mapnik.cpp
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
#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
|
||||||
|
|
||||||
|
// only on other systems then windows and in shared builds
|
||||||
|
#if !defined(MAPNIK_DISABLE_AUTOSETUP) && MAPNIK_STATIC_PLUGINS == 0 && !defined(_WIN32)
|
||||||
|
namespace {
|
||||||
|
class AutoSetup final
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
AutoSetup() { mapnik::setup(); };
|
||||||
|
};
|
||||||
|
AutoSetup auto_setup{};
|
||||||
|
} // namespace
|
||||||
|
#endif
|
|
@ -35,10 +35,14 @@
|
||||||
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 +71,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)
|
||||||
|
|
119
src/plugin.cpp
119
src/plugin.cpp
|
@ -23,6 +23,8 @@
|
||||||
#include <mapnik/plugin.hpp>
|
#include <mapnik/plugin.hpp>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
|
#include <mapnik/datasource_plugin.hpp>
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#define NOMINMAX
|
#define NOMINMAX
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
@ -45,56 +47,15 @@ namespace mapnik {
|
||||||
|
|
||||||
struct _mapnik_lib_t
|
struct _mapnik_lib_t
|
||||||
{
|
{
|
||||||
|
std::string name;
|
||||||
|
std::string error_str;
|
||||||
handle dl;
|
handle dl;
|
||||||
};
|
_mapnik_lib_t()
|
||||||
|
: name{"unknown"}
|
||||||
PluginInfo::PluginInfo(std::string const& filename, std::string const& library_name)
|
, error_str{""}
|
||||||
: filename_(filename)
|
, dl{nullptr}
|
||||||
, name_()
|
{}
|
||||||
, module_(new mapnik_lib_t)
|
~_mapnik_lib_t()
|
||||||
{
|
|
||||||
#ifdef _WIN32
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#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
|
||||||
/*
|
/*
|
||||||
|
@ -108,16 +69,54 @@ 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 = nullptr;
|
||||||
#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>()}
|
||||||
|
{
|
||||||
|
assert(module_ != nullptr);
|
||||||
|
#if defined(_WIN32)
|
||||||
|
module_->dl = LoadLibraryA(filename.c_str());
|
||||||
|
#elif defined(MAPNIK_HAS_DLCFN)
|
||||||
|
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_->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();
|
||||||
|
module_->error_str = "";
|
||||||
|
plugin->after_load();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const auto errcode = dlerror();
|
||||||
|
#ifdef _WIN32
|
||||||
|
module_->error_str = std::system_category().message(errcode);
|
||||||
|
#else
|
||||||
|
module_->error_str = errcode ? errcode : "";
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#endif // defined(MAPNIK_HAS_DLCFN) || defined(_WIN32)
|
||||||
|
}
|
||||||
|
|
||||||
|
PluginInfo::~PluginInfo() {}
|
||||||
|
|
||||||
void* PluginInfo::get_symbol(std::string const& sym_name) const
|
void* PluginInfo::get_symbol(std::string const& sym_name) const
|
||||||
{
|
{
|
||||||
|
@ -130,13 +129,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_->dl && !module_->name.empty())
|
||||||
return true;
|
return true;
|
||||||
#endif
|
#endif
|
||||||
return false;
|
return false;
|
||||||
|
@ -144,17 +143,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 + "'. Error: " + module_->error_str;
|
||||||
}
|
|
||||||
|
|
||||||
void PluginInfo::init()
|
|
||||||
{
|
|
||||||
// do any initialization needed
|
|
||||||
}
|
|
||||||
|
|
||||||
void PluginInfo::exit()
|
|
||||||
{
|
|
||||||
// do any shutdown needed
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace mapnik
|
} // namespace mapnik
|
||||||
|
|
|
@ -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)
|
||||||
{
|
{
|
||||||
|
|
|
@ -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
|
||||||
|
|
44
src/webp_io.cpp
Normal file
44
src/webp_io.cpp
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
#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;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace mapnik
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue