Compare commits

..

No commits in common. "master" and "mathisloge-feature/cmake-static" have entirely different histories.

2415 changed files with 33635 additions and 49993 deletions

View file

@ -30,8 +30,8 @@ BraceWrapping:
AfterFunction: true # see AllowShortFunctionsOnASingleLine AfterFunction: true # see AllowShortFunctionsOnASingleLine
AfterNamespace: false AfterNamespace: false
AfterStruct: true AfterStruct: true
AfterExternBlock: false AfterExternBlock: true
BeforeCatch: true BeforeCatch: false
BeforeElse: true BeforeElse: true
BeforeLambdaBody: false BeforeLambdaBody: false
BeforeWhile: false BeforeWhile: false

View file

@ -1,85 +0,0 @@
name: Run tests with coverage
description: Runs all mapnik tests with coverage
inputs:
cmake-preset:
description: The used CMake preset
required: true
runs:
using: composite
steps:
- name: Set PROJ_LIB
shell: bash
run: |
cmake --preset ${{ inputs.cmake-preset }} -N -L | grep -o "PROJ_LIB=.*" >> ${GITHUB_ENV}
- name: Set TEST_WRAPPER (Windows)
if: runner.os == 'Windows'
shell: bash
run: |-
echo "TEST_WRAPPER=OpenCppCoverage \
--cover_children \
--export_type binary \
--modules '*.input' \
--modules '*libmapnik*' \
--modules 'mapnik*.exe' \
--quiet \
--sources '${{ github.workspace }}' \
--" >> ${GITHUB_ENV}
- name: Test
shell: bash
env:
UPDATE: 1
run: |
${TEST_WRAPPER:-} ctest --preset ${{ inputs.cmake-preset }}
- name: Test visuals
continue-on-error: true
working-directory: build/out
shell: bash
run: |
${TEST_WRAPPER:-} ./mapnik-test-visual -j ${CTEST_PARALLEL_LEVEL} --output-dir visual-test-result
- name: Pack visual test results
working-directory: build/out
shell: bash
run: |
tar -vzcf visual-test-results.tar.gz visual-test-result
- name: Upload visual test results
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.cmake-preset }}-visual-tests-${{ github.sha }}
path: build/out/visual-test-results.tar.gz
- name: Run Benchmarks (Linux & macOS)
working-directory: build/out
if: runner.os != 'Windows'
shell: bash
run: |
./run_benchmarks
- name: Collect coverage (Linux & macOS)
working-directory: build
if: runner.os != 'Windows'
shell: bash
run: |
if [ "${RUNNER_OS}" == "macOS" ]; then
LCOV_EXTRA_OPTIONS="--ignore-errors count,gcov,inconsistent,range,unused --keep-going"
fi
lcov ${LCOV_EXTRA_OPTIONS:-} --directory . --capture --output-file coverage.info
lcov ${LCOV_EXTRA_OPTIONS:-} --remove coverage.info '/usr/*' '*/vcpkg_installed/*' '/.cache/*' '*/test/*' --output-file coverage.info
lcov ${LCOV_EXTRA_OPTIONS:-} --list coverage.info
- name: Upload coverage to Codecov (Linux & macOS)
if: runner.os != 'Windows'
uses: codecov/codecov-action@v4
with:
files: build/coverage.info
- name: Upload coverage to Codecov (Windows)
if: runner.os == 'Windows'
uses: codecov/codecov-action@v4
with:
files: ctest.cov,build/out/mapnik-test-visual.cov

View file

@ -1,136 +0,0 @@
name: Build and Test
on:
push:
branches:
- "*"
pull_request:
branches-ignore:
- "no-ci-*"
env:
VCPKG_BINARY_SOURCES: clear;x-gha,readwrite
VCPKG_RELEASE: 2024.06.15
jobs:
checkSource:
name: Check Source Code
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.10"
- uses: pre-commit/action@v3.0.1
buildAndTest:
name: >-
Build & Test
(${{ matrix.os }})
(C++ ${{ matrix.cxx-standard }})
${{ startsWith(matrix.os, 'macos-') && (matrix.os == 'macos-14' && '(ARM64)' || '(AMD64)') || '' }}
needs: checkSource
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- macos-14
- ubuntu-22.04
- windows-2022
cxx-standard:
- 17
steps:
- name: Checkout Mapnik
uses: actions/checkout@v4
with:
submodules: recursive
- name: Checkout vcpkg
uses: actions/checkout@v4
with:
path: vcpkg
ref: ${{ env.VCPKG_RELEASE }}
repository: microsoft/vcpkg
- name: Export GitHub Actions cache environment variables
uses: actions/github-script@v7
with:
script: |
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
- name: Install required system packages
shell: bash
run: |
if [ "${RUNNER_OS}" == "Linux" ]; then
sudo apt-get update
sudo apt-get -y install \
autoconf \
autoconf-archive \
automake \
gperf \
lcov \
libxxf86vm-dev \
ninja-build \
postgresql-client
elif [ "${RUNNER_OS}" == "macOS" ]; then
brew install \
autoconf \
autoconf-archive \
automake \
lcov \
libtool \
ninja \
vcpkg
elif [ "${RUNNER_OS}" == "Windows" ]; then
choco install \
ninja \
OpenCppCoverage
echo "C:\Program Files\OpenCppCoverage" >> ${GITHUB_PATH}
fi
- name: Enable Developer Command Prompt (Windows)
uses: ilammy/msvc-dev-cmd@v1
if: runner.os == 'Windows'
- name: Set CMAKE_BUILD_PARALLEL_LEVEL, CTEST_PARALLEL_LEVEL & PRESET
shell: bash
run: |
PRESET=$(echo "${RUNNER_OS}" | perl -ne "print lc")-ci
if [ "${RUNNER_OS}" == "Linux" ]; then
echo "CMAKE_BUILD_PARALLEL_LEVEL=$(nproc)" >> ${GITHUB_ENV}
echo "CTEST_PARALLEL_LEVEL=$(nproc)" >> ${GITHUB_ENV}
elif [ "${RUNNER_OS}" == "macOS" ]; then
echo "CMAKE_BUILD_PARALLEL_LEVEL=$(sysctl -n hw.logicalcpu)" >> ${GITHUB_ENV}
echo "CTEST_PARALLEL_LEVEL=$(sysctl -n hw.logicalcpu)" >> ${GITHUB_ENV}
PRESET=${PRESET}-${{ matrix.os == 'macos-14' && 'arm64' || 'x64' }}
elif [ "${RUNNER_OS}" == "Windows" ]; then
echo "CMAKE_BUILD_PARALLEL_LEVEL=$(pwsh -Command '(Get-CimInstance -ClassName Win32_ComputerSystem).NumberOfLogicalProcessors')" >> ${GITHUB_ENV}
echo "CTEST_PARALLEL_LEVEL=$(pwsh -Command '(Get-CimInstance -ClassName Win32_ComputerSystem).NumberOfLogicalProcessors')" >> ${GITHUB_ENV}
fi
echo "PRESET=${PRESET}" >> ${GITHUB_ENV}
- name: Configure CMake
shell: bash
run: |
cmake \
-DBUILD_SHARED_LIBS:BOOL=ON \
-DCMAKE_CXX_STANDARD:STRING=${{ matrix.cxx-standard }} \
-DUSE_MEMORY_MAPPED_FILE:BOOL=ON \
-LA \
--preset ${PRESET}
- name: Build
shell: bash
run: |
cmake \
--build \
--preset ${PRESET}
- name: Run Tests
uses: ./.github/actions/run_tests
with:
cmake-preset: ${{ env.PRESET }}

76
.github/workflows/build_test.yml vendored Normal file
View file

@ -0,0 +1,76 @@
name: Build and Test
on:
push:
branches-ignore:
- "no-ci-*"
pull_request:
branches:
- "**"
jobs:
windows:
name: Windows memory mapped
uses: mapnik/mapnik/.github/workflows/windows.yml@master
with:
VCPKG_SHA: 2e34a79a814551424d9b1a981b3b110e0a8fbdfd
NUGET_REGISTRY: https://nuget.pkg.github.com/mapnik/index.json
NUGET_USERNAME: mapnik
USE_MEMORY_MAPPED_FILE: 'ON'
secrets:
NUGET_REGISTRY_PAT: ${{ secrets.VCPKG_CACHE_PAT }}
windows-mmf-off:
name: Windows file based
uses: mapnik/mapnik/.github/workflows/windows.yml@master
with:
VCPKG_SHA: 2e34a79a814551424d9b1a981b3b110e0a8fbdfd
NUGET_REGISTRY: https://nuget.pkg.github.com/mapnik/index.json
NUGET_USERNAME: mapnik
USE_MEMORY_MAPPED_FILE: 'OFF'
secrets:
NUGET_REGISTRY_PAT: ${{ secrets.VCPKG_CACHE_PAT }}
ubuntu:
name: Linux memory mapped
uses: mapnik/mapnik/.github/workflows/ubuntu.yml@master
with:
VCPKG_SHA: 2e34a79a814551424d9b1a981b3b110e0a8fbdfd
NUGET_REGISTRY: https://nuget.pkg.github.com/mapnik/index.json
NUGET_USERNAME: mapnik
USE_MEMORY_MAPPED_FILE: 'ON'
secrets:
NUGET_REGISTRY_PAT: ${{ secrets.VCPKG_CACHE_PAT }}
ubuntu-mmf-off:
name: Linux file based
uses: mapnik/mapnik/.github/workflows/ubuntu.yml@master
with:
VCPKG_SHA: 2e34a79a814551424d9b1a981b3b110e0a8fbdfd
NUGET_REGISTRY: https://nuget.pkg.github.com/mapnik/index.json
NUGET_USERNAME: mapnik
USE_MEMORY_MAPPED_FILE: 'OFF'
secrets:
NUGET_REGISTRY_PAT: ${{ secrets.VCPKG_CACHE_PAT }}
macos:
name: MacOS memory mapped
uses: mapnik/mapnik/.github/workflows/macos.yml@master
with:
VCPKG_SHA: 2e34a79a814551424d9b1a981b3b110e0a8fbdfd
NUGET_REGISTRY: https://nuget.pkg.github.com/mapnik/index.json
NUGET_USERNAME: mapnik
USE_MEMORY_MAPPED_FILE: 'ON'
secrets:
NUGET_REGISTRY_PAT: ${{ secrets.VCPKG_CACHE_PAT }}
macos-mmf-off:
name: MacOS file based
uses: mapnik/mapnik/.github/workflows/macos.yml@master
with:
VCPKG_SHA: 2e34a79a814551424d9b1a981b3b110e0a8fbdfd
NUGET_REGISTRY: https://nuget.pkg.github.com/mapnik/index.json
NUGET_USERNAME: mapnik
USE_MEMORY_MAPPED_FILE: 'OFF'
secrets:
NUGET_REGISTRY_PAT: ${{ secrets.VCPKG_CACHE_PAT }}

146
.github/workflows/macos.yml vendored Normal file
View file

@ -0,0 +1,146 @@
name: MacOS
on:
workflow_call:
inputs:
VCPKG_SHA:
required: true
type: string
NUGET_REGISTRY:
required: true
type: string
NUGET_USERNAME:
required: true
type: string
USE_MEMORY_MAPPED_FILE:
required: true
type: string
secrets:
NUGET_REGISTRY_PAT:
required: true
env:
VCPKG_BINARY_SOURCES: "clear;nuget,GitHub,readwrite"
VCPKG_NUGET_REPOSITORY: https://github.com/mapnik/vcpkg-cache.git
UPDATE: 1
preset: macos-ci
mono: mono
jobs:
build:
runs-on: macos-latest
steps:
- name: Install required system packages
run: |
brew install automake ninja lcov
- name: checkout mapnik
uses: actions/checkout@v2
with:
submodules: "recursive"
- name: checkout vcpkg
uses: actions/checkout@v2
with:
repository: "microsoft/vcpkg"
ref: ${{ inputs.VCPKG_SHA }}
path: vcpkg
- name: "Setup vcpkg"
shell: bash
run: ./vcpkg/bootstrap-vcpkg.sh
- name: "Setup NuGet Credentials"
if: ${{ !(github.event_name == 'pull_request' || github.repository != 'mapnik/mapnik') }}
shell: "bash"
run: >
${{ env.mono }} `./vcpkg/vcpkg fetch nuget | tail -n 1`
sources add
-source "${{ inputs.NUGET_REGISTRY }}"
-storepasswordincleartext
-name "GitHub"
-username "${{ inputs.NUGET_USERNAME }}"
-password "${{ secrets.NUGET_REGISTRY_PAT }}"
- name: "Setup NuGet apikey"
if: ${{ !(github.event_name == 'pull_request' || github.repository != 'mapnik/mapnik') }}
shell: "bash"
run: >
${{ env.mono }} `./vcpkg/vcpkg fetch nuget | tail -n 1`
setapikey "${{ secrets.NUGET_REGISTRY_PAT }}" -Source "${{ inputs.NUGET_REGISTRY }}"
- name: "Setup NuGet Credentials READONLY"
if: ${{ github.event_name == 'pull_request' || github.repository != 'mapnik/mapnik' }}
shell: "bash"
run: >
${{ env.mono }} `./vcpkg/vcpkg fetch nuget | tail -n 1`
sources add
-source "${{ inputs.NUGET_REGISTRY }}"
-storepasswordincleartext
-name "GitHub"
-username "${{ github.actor }}"
-password "${{ secrets.GITHUB_TOKEN }}"
- name: "Setup NuGet apikey READONLY"
if: ${{ github.event_name == 'pull_request' || github.repository != 'mapnik/mapnik' }}
shell: "bash"
run: >
${{ env.mono }} `./vcpkg/vcpkg fetch nuget | tail -n 1`
setapikey "${{ secrets.GITHUB_TOKEN }}" -Source "${{ inputs.NUGET_REGISTRY }}"
- name: Configure CMake
run: cmake -DCMAKE_TOOLCHAIN_FILE=./vcpkg/scripts/buildsystems/vcpkg.cmake -DUSE_MEMORY_MAPPED_FILE=${{ inputs.USE_MEMORY_MAPPED_FILE }} --preset=${{ env.preset }}
- name: Build
run: cmake --build --preset ${{ env.preset }}
- name: Test
run: ctest --preset ${{ env.preset }}
- name: Test visuals
continue-on-error: true
working-directory: build/${{ env.preset }}/out
env:
PROJ_LIB: ${{ github.workspace }}/build/${{ env.preset }}/vcpkg_installed/x64-osx/share/proj4
run: ./mapnik-test-visual -j $(sysctl -n hw.logicalcpu) --output-dir ./visual-test-result
- name: Pack visual test results
working-directory: build/${{ env.preset }}/out
run: tar cfvz visual-test-results.tar.gz ./visual-test-result
- name: Run Benchmark
working-directory: build/${{ env.preset }}/out
env:
PROJ_LIB: ${{ github.workspace }}/build/${{ env.preset }}/vcpkg_installed/x64-osx/share/proj4
run: ./run_benchmarks
- name: Coverage
working-directory: build/${{ env.preset }}
run: |
lcov --directory . --capture --output-file coverage.info
lcov --remove coverage.info '/usr/*' '*/vcpkg_installed/*' '/.cache/*' '*/test/*' --output-file coverage.info
lcov --list coverage.info
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2
with:
files: build/${{ env.preset }}/coverage.info
- name: Package
if: failure()
run: cmake --build --preset ${{ env.preset }} --target package
- name: Upload mapnik build artifact
uses: actions/upload-artifact@v2
if: failure()
with:
name: ${{ env.preset }}-mmio-${{ inputs.USE_MEMORY_MAPPED_FILE }}
path: build/${{ env.preset }}/mapnik-*.tar.gz
retention-days: 2
- name: Upload visual test results
uses: actions/upload-artifact@v2
with:
name: ${{ env.preset }}-visual-tests-mmio-${{ inputs.USE_MEMORY_MAPPED_FILE }}
path: build/${{ env.preset }}/out/visual-test-results.tar.gz
retention-days: 2

View file

@ -1,55 +0,0 @@
name: Release Linux
on:
push:
branches:
- "*"
pull_request:
branches-ignore:
- "no-ci-*"
env:
PRESET: linux-ci-release
jobs:
build:
runs-on: "ubuntu-22.04"
steps:
- name: checkout mapnik
uses: actions/checkout@v4
with:
submodules: "recursive"
- name: "Install required system packages"
shell: bash
run: |
sudo apt update
sudo apt install -y ninja-build\
libicu-dev \
libfreetype6-dev \
libharfbuzz-dev \
libxml2-dev \
libjpeg-dev \
libtiff-dev \
libwebp-dev \
libcairo2-dev \
libproj-dev \
libgdal-dev \
libboost-filesystem-dev \
libboost-program-options-dev \
libboost-regex-dev
- name: Configure CMake
run: cmake -LA --preset ${{ env.PRESET }}
- name: Build
run: cmake --build --preset ${{ env.PRESET }}
- name: Package
run: cmake --build --preset ${{ env.PRESET }} --target package
- name: Upload mapnik debian package
uses: actions/upload-artifact@v4
with:
name: ${{ env.PRESET }}-deb
path: build/mapnik-*.deb

162
.github/workflows/ubuntu.yml vendored Normal file
View file

@ -0,0 +1,162 @@
name: Ubuntu
on:
workflow_call:
inputs:
VCPKG_SHA:
required: true
type: string
NUGET_REGISTRY:
required: true
type: string
NUGET_USERNAME:
required: true
type: string
USE_MEMORY_MAPPED_FILE:
required: true
type: string
secrets:
NUGET_REGISTRY_PAT:
required: true
env:
VCPKG_BINARY_SOURCES: "clear;nuget,GitHub,readwrite"
VCPKG_NUGET_REPOSITORY: https://github.com/mapnik/vcpkg-cache.git
UPDATE: 1
preset: linux-ci
mono: mono
jobs:
build:
runs-on: ubuntu-latest
services:
postgres:
image: postgis/postgis
env:
POSTGRES_PASSWORD: password
POSTGRES_DB: mapnik-tmp-postgis-test-db
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Install required system packages
shell: "bash"
run: |
sudo apt-get install -y gperf libxxf86vm-dev ninja-build postgresql-client lcov
- name: checkout mapnik
uses: actions/checkout@v2
with:
submodules: "recursive"
- name: checkout vcpkg
uses: actions/checkout@v2
with:
repository: "microsoft/vcpkg"
ref: ${{ inputs.VCPKG_SHA }}
path: vcpkg
- name: "Setup vcpkg"
shell: bash
run: ./vcpkg/bootstrap-vcpkg.sh
- name: "Setup NuGet Credentials"
if: ${{ !(github.event_name == 'pull_request' || github.repository != 'mapnik/mapnik') }}
shell: "bash"
run: >
${{ env.mono }} `./vcpkg/vcpkg fetch nuget | tail -n 1`
sources add
-source "${{ inputs.NUGET_REGISTRY }}"
-storepasswordincleartext
-name "GitHub"
-username "${{ inputs.NUGET_USERNAME }}"
-password "${{ secrets.NUGET_REGISTRY_PAT }}"
- name: "Setup NuGet apikey"
if: ${{ !(github.event_name == 'pull_request' || github.repository != 'mapnik/mapnik') }}
shell: "bash"
run: >
${{ env.mono }} `./vcpkg/vcpkg fetch nuget | tail -n 1`
setapikey "${{ secrets.NUGET_REGISTRY_PAT }}" -Source "${{ inputs.NUGET_REGISTRY }}"
- name: "Setup NuGet Credentials READONLY"
if: ${{ github.event_name == 'pull_request' || github.repository != 'mapnik/mapnik' }}
shell: "bash"
run: >
${{ env.mono }} `./vcpkg/vcpkg fetch nuget | tail -n 1`
sources add
-source "${{ inputs.NUGET_REGISTRY }}"
-storepasswordincleartext
-name "GitHub"
-username "${{ github.actor }}"
-password "${{ secrets.GITHUB_TOKEN }}"
- name: "Setup NuGet apikey READONLY"
if: ${{ github.event_name == 'pull_request' || github.repository != 'mapnik/mapnik' }}
shell: "bash"
run: >
${{ env.mono }} `./vcpkg/vcpkg fetch nuget | tail -n 1`
setapikey "${{ secrets.GITHUB_TOKEN }}" -Source "${{ inputs.NUGET_REGISTRY }}"
- name: Configure CMake
run: cmake -DCMAKE_TOOLCHAIN_FILE=./vcpkg/scripts/buildsystems/vcpkg.cmake -DUSE_MEMORY_MAPPED_FILE=${{ inputs.USE_MEMORY_MAPPED_FILE }} --preset=${{ env.preset }}
- name: Build
run: cmake --build --preset ${{ env.preset }}
- name: Test
run: ctest --preset ${{ env.preset }}
- name: Test visuals
continue-on-error: true
working-directory: build/${{ env.preset }}/out
env:
PROJ_LIB: ${{ github.workspace }}/build/${{ env.preset }}/vcpkg_installed/x64-linux/share/proj4
run: ./mapnik-test-visual -j $(nproc) --output-dir ./visual-test-result
- name: Pack visual test results
working-directory: build/${{ env.preset }}/out
run: tar cfvz visual-test-results.tar.gz ./visual-test-result
- name: Run Benchmarks
working-directory: build/${{ env.preset }}/out
env:
PROJ_LIB: ${{ github.workspace }}/build/${{ env.preset }}/vcpkg_installed/x64-linux/share/proj4
run: ./run_benchmarks
- name: Coverage
working-directory: build/${{ env.preset }}
run: |
lcov --directory . --capture --output-file coverage.info
lcov --remove coverage.info '/usr/*' '*/vcpkg_installed/*' '/.cache/*' '*/test/*' --output-file coverage.info
lcov --list coverage.info
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2
with:
files: build/${{ env.preset }}/coverage.info
- name: Package
if: failure()
run: cmake --build --preset ${{ env.preset }} --target package
- name: Upload mapnik build artifact
uses: actions/upload-artifact@v2
if: failure()
with:
name: ${{ env.preset }}-artifact-mmio-${{ inputs.USE_MEMORY_MAPPED_FILE }}
path: build/${{ env.preset }}/mapnik-*.tar.gz
retention-days: 2
- name: Upload visual test results
uses: actions/upload-artifact@v2
with:
name: ${{ env.preset }}-visual-tests-mmio-${{ inputs.USE_MEMORY_MAPPED_FILE }}
path: build/${{ env.preset }}/out/visual-test-results.tar.gz
retention-days: 2

135
.github/workflows/windows.yml vendored Normal file
View file

@ -0,0 +1,135 @@
name: Windows
on:
workflow_call:
inputs:
VCPKG_SHA:
required: true
type: string
NUGET_REGISTRY:
required: true
type: string
NUGET_USERNAME:
required: true
type: string
USE_MEMORY_MAPPED_FILE:
required: true
type: string
secrets:
NUGET_REGISTRY_PAT:
required: true
env:
VCPKG_BINARY_SOURCES: "clear;nuget,GitHub,readwrite"
VCPKG_NUGET_REPOSITORY: https://github.com/mapnik/vcpkg-cache.git
UPDATE: 1
preset: windows-ci
jobs:
build:
runs-on: windows-latest
steps:
- name: Install required system packages
run: |
choco install ninja OpenCppCoverage
echo "C:\Program Files\OpenCppCoverage" >> $env:GITHUB_PATH
- uses: ilammy/msvc-dev-cmd@v1
- name: checkout mapnik
uses: actions/checkout@v2
with:
submodules: "recursive"
- name: checkout vcpkg
uses: actions/checkout@v2
with:
repository: "microsoft/vcpkg"
ref: ${{ inputs.VCPKG_SHA }}
path: vcpkg
- name: "Setup vcpkg"
run: ./vcpkg/bootstrap-vcpkg.bat
- name: "Setup NuGet Credentials"
if: ${{ !(github.event_name == 'pull_request' || github.repository != 'mapnik/mapnik') }}
shell: "bash"
run: >
`./vcpkg/vcpkg fetch nuget | tail -n 1`
sources add
-source "${{ inputs.NUGET_REGISTRY }}"
-storepasswordincleartext
-name "GitHub"
-username "${{ inputs.NUGET_USERNAME }}"
-password "${{ secrets.NUGET_REGISTRY_PAT }}"
- name: "Setup NuGet apikey"
if: ${{ !(github.event_name == 'pull_request' || github.repository != 'mapnik/mapnik') }}
shell: "bash"
run: >
`./vcpkg/vcpkg fetch nuget | tail -n 1`
setapikey "${{ secrets.NUGET_REGISTRY_PAT }}" -Source "${{ inputs.NUGET_REGISTRY }}"
- name: "Setup NuGet Credentials READONLY"
if: ${{ github.event_name == 'pull_request' || github.repository != 'mapnik/mapnik' }}
shell: "bash"
run: >
`./vcpkg/vcpkg fetch nuget | tail -n 1`
sources add
-source "${{ inputs.NUGET_REGISTRY }}"
-storepasswordincleartext
-name "GitHub"
-username "${{ github.actor }}"
-password "${{ secrets.GITHUB_TOKEN }}"
- name: "Setup NuGet apikey READONLY"
if: ${{ github.event_name == 'pull_request' || github.repository != 'mapnik/mapnik' }}
shell: "bash"
run: >
`./vcpkg/vcpkg fetch nuget | tail -n 1`
setapikey "${{ secrets.GITHUB_TOKEN }}" -Source "${{ inputs.NUGET_REGISTRY }}"
- name: Configure CMake
run: cmake -DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake -DUSE_MEMORY_MAPPED_FILE=${{ inputs.USE_MEMORY_MAPPED_FILE }} --preset ${{env.preset}}
- name: Build
run: cmake --build --preset ${{env.preset}}
- name: Test
run: OpenCppCoverage --modules *libmapnik* --modules mapnik*.exe --modules *.input --sources ${{ github.workspace }} --export_type binary --cover_children -- ctest --preset ${{env.preset}}
- name: Test visuals
shell: pwsh
continue-on-error: true
working-directory: build/${{ env.preset }}/out
env:
PROJ_LIB: ${{ github.workspace }}/build/${{ env.preset }}/vcpkg_installed/x64-windows/share/proj4
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: Pack visual test results
working-directory: build/${{ env.preset }}/out
run: tar cfvz visual-test-results.tar.gz ./visual-test-result
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2
with:
files: build/${{ env.preset }}/out/mapnik-test-visual.cov
- name: Package
if: failure()
run: cmake --build --preset ${{env.preset}} --target package
- uses: actions/upload-artifact@v2
if: failure()
with:
name: ${{ env.preset }}-artifact-mmio-${{ inputs.USE_MEMORY_MAPPED_FILE }}
path: build/*-ci/mapnik-*.tar.gz
retention-days: 2
- name: Upload visual test results
uses: actions/upload-artifact@v2
with:
name: ${{ env.preset }}-visual-tests-mmio-${{ inputs.USE_MEMORY_MAPPED_FILE }}
path: build/${{ env.preset }}/out/visual-test-results.tar.gz
retention-days: 2

1
.gitignore vendored
View file

@ -1,6 +1,5 @@
.DS_Store .DS_Store
.vscode .vscode
.cache
*.gcov *.gcov
*.gcda *.gcda
*.gcno *.gcno

View file

@ -1,16 +0,0 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: trailing-whitespace
files: ^.*\.cmake|CMakeLists\.txt$
- id: end-of-file-fixer
files: ^.*\.cmake|CMakeLists\.txt$
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v18.1.3
hooks:
- id: clang-format
types_or: [c++, c]

98
.travis.yml Normal file
View file

@ -0,0 +1,98 @@
language: cpp
git:
depth: 10
submodules: false
env:
global:
- CCACHE_TEMPDIR=/tmp/.ccache-temp
- CCACHE_COMPRESS=1
- PREFIX=/tmp/mapnik
- PYTHON=python3
cache:
directories:
- $HOME/.ccache
dist: xenial
matrix:
include:
- os: linux
name: Linux clang
env: >-
CXX="ccache clang++ -Qunused-arguments"
CC="clang"
addons:
postgresql: "9.5"
apt:
sources: [ 'ubuntu-toolchain-r-test' ]
packages: [ 'xutils-dev', 'libstdc++-6-dev', 'postgresql-9.5-postgis-2.4' ]
- os: linux
name: Linux clang + coverage
env: >-
CXX="ccache clang++ -Qunused-arguments"
CC="clang"
COVERAGE=true
QUIET=true
before_install:
- export LLVM_COV="llvm-cov"
addons:
postgresql: "9.5"
apt:
sources: [ 'ubuntu-toolchain-r-test' ]
packages: [ 'xutils-dev', 'libstdc++-6-dev','postgresql-9.5-postgis-2.4' ]
- os: osx
name: OSX clang
#https://docs.travis-ci.com/user/reference/osx#macos-version
osx_image: xcode12.2
env: >-
CXX="ccache clang++ -Qunused-arguments"
before_install:
install:
- source scripts/travis-common.sh
# workaround travis rvm bug
# http://superuser.com/questions/1044130/why-am-i-having-how-can-i-fix-this-error-shell-session-update-command-not-f
- on 'osx' rvm get head || true
- export PATH=${PREFIX}/bin:$(pwd)/mason_packages/.link/bin:${PATH}
- export COVERAGE=${COVERAGE:-false}
- export BENCH=${BENCH:-false}
- on 'osx' export DATA_PATH=$(brew --prefix)/var/postgres
- on 'osx' rm -rf ${DATA_PATH}
- on 'osx' initdb ${DATA_PATH} -E utf8
- on 'osx' pg_ctl -w start -l postgres.log --pgdata ${DATA_PATH};
- on 'osx' cat postgres.log;
- on 'osx' createuser -s postgres
- psql -c 'create database template_postgis;' -U postgres
- psql -c 'create extension postgis;' -d template_postgis -U postgres
- enabled ${COVERAGE} curl -S -f https://codecov.io/bash -o codecov
- enabled ${COVERAGE} chmod +x codecov
before_script:
- export JOBS=${JOBS:-4}
- export HEAVY_JOBS=${HEAVY_JOBS:-2}
- export SCONSFLAGS='--debug=time'
- source bootstrap.sh
- ccache --version
- ccache -p || true
- ccache --show-stats || true
- commit_message_parse
script:
- git_submodule_update --init deps/
- on 'osx' brew unlink $(brew list --formula)
- on 'osx' brew link git postgresql postgis
- configure BENCHMARK=${BENCH} ENABLE_GLIBC_WORKAROUND=${ENABLE_GLIBC_WORKAROUND:-false} QUIET=${QUIET:-false}
#- cat config.log => comment out to reduce log size limit on travis-ci
# we limit the `make` to 40 min
# to ensure that slow builds still upload their
# ccache results and therefore should be faster
# (and might work) for the next build
- DEADLINE=$(( $(date +%s) + 40 * 60 ))
- scripts/travis-command-wrapper.py -s "date" -i 120 --deadline="$DEADLINE" make
- test_ok && git_submodule_update --init --depth=50 test/
- test_ok && make test
- test_ok && enabled ${COVERAGE} coverage
- test_ok && enabled ${BENCH} make bench
- ./scripts/check_glibcxx.sh

View file

@ -6,44 +6,17 @@ Developers: Please commit along with changes.
For a complete change history, see the git log. For a complete change history, see the git log.
## Mapnik 4.0.3
Released October 30th, 2024 ## UNRELEASED
(Packaged from [05389e3c7](https://github.com/mapnik/mapnik/commit/05389e3c7))
- Remove 'final' specifier from invalid_featureset implementation
(issues with dynamic_cast<> when building using Apple clang version 16.0.0 on darwin-arm64)
- Rename invalid_featureset to empty_featureset
- Upgrade to SCons v4.8.1
- Fix unit tests e.g #endif statement (via @bgardner-noggin)
## Mapnik 4.0.2
Released August 21st, 2024
- CMake build - set `SOVERSION` to `${MAPNIK_MAJOR_VERSION}.${MAPNIK_MINOR_VERSION}`
- Upgraded SCons build system to v4.8.0
## Mapnik 4.0.1
- Use CMAKE_INSTALL_LIBDIR for libdir in pkg-config files
- Support gcc 14
- Improved accuracy of bounding box re-projections. Automatic spliting at (0, 0) and merging results.
- Fixes missing features when using WGS 84 / Arctic Polar Stereographic (`epsg:4326 <-> epsg:3995`)
- Added `area_of_use` method to `mapnik::projection`
## Mapnik 4.0.0
#### Notice #### Notice
- Mapnik now requires C++17 compliant compiler (`-std=c++17`) - 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 #### 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)) - 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)) - mapnik now has a global `mapnik::setup()` method which have to be called before any other functions of mapnik. Defined in `mapnik.hpp` ([#4291](https://github.com/mapnik/mapnik/pull/4291))
#### Core #### Core
@ -60,7 +33,6 @@ Released August 21st, 2024
- 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)) - 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))
#### Plugins #### Plugins

View file

@ -5,18 +5,17 @@ cmake_minimum_required(VERSION 3.15)
include(cmake/GetVersion.cmake) include(cmake/GetVersion.cmake)
get_mapnik_version() get_mapnik_version()
project(mapnik project(mapnik
VERSION ${MAPNIK_MAJOR_VERSION}.${MAPNIK_MINOR_VERSION}.${MAPNIK_PATCH_VERSION} VERSION ${MAPNIK_MAJOR_VERSION}.${MAPNIK_MINOR_VERSION}.${MAPNIK_PATCH_VERSION}
HOMEPAGE_URL "https://mapnik.org/" HOMEPAGE_URL "https://mapnik.org/"
DESCRIPTION "Mapnik is an open source toolkit for developing mapping applications" DESCRIPTION "Mapnik is an open source toolkit for developing mapping applications"
LANGUAGES CXX LANGUAGES CXX
) )
message(STATUS "mapnik version: ${PROJECT_VERSION}") 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)
@ -28,9 +27,9 @@ 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_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) if(WIN32 AND BUILD_SHARED_PLUGINS AND NOT BUILD_SHARED_LIBS)
message(FATAL_ERROR "static libmapnik and dynamic plugins won't work correctly") message(FATAL_ERROR "static libmapnik and dynamic plugins won't work correctly")
endif() endif()
@ -49,7 +48,6 @@ mapnik_option(USE_PROJ "adds proj support" ON)
mapnik_option(USE_GRID_RENDERER "adds grid renderer" ON) mapnik_option(USE_GRID_RENDERER "adds grid renderer" ON)
mapnik_option(USE_SVG_RENDERER "adds svg renderer" ON) mapnik_option(USE_SVG_RENDERER "adds svg renderer" ON)
mapnik_option(USE_BIGINT "uses 64 bit instead of 32" ON) mapnik_option(USE_BIGINT "uses 64 bit instead of 32" ON)
mapnik_option(USE_BOOST_FILESYSTEM "use boost::filesytem even if `std::filesystem` is available (since c++17)" OFF)
mapnik_option(USE_MEMORY_MAPPED_FILE "uses file cache" ON) mapnik_option(USE_MEMORY_MAPPED_FILE "uses file cache" ON)
mapnik_option(USE_MULTITHREADED "enables the multithreaded features (threadsafe)" ON) mapnik_option(USE_MULTITHREADED "enables the multithreaded features (threadsafe)" ON)
mapnik_option(USE_NO_ATEXIT "disable atexit" OFF) mapnik_option(USE_NO_ATEXIT "disable atexit" OFF)
@ -63,8 +61,6 @@ mapnik_option(USE_LOG "enables logging output. See log severity level." OFF)
set(USE_LOG_SEVERITY "1" CACHE STRING "sets the logging severity (only applies when USE_LOG is ON") set(USE_LOG_SEVERITY "1" CACHE STRING "sets the logging severity (only applies when USE_LOG is ON")
mapnik_option(USE_STATS "Enable statistics reporting" OFF) mapnik_option(USE_STATS "Enable statistics reporting" OFF)
mapnik_option(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)
@ -96,6 +92,18 @@ 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")
@ -113,39 +121,16 @@ endif()
set(PLUGINS_INSTALL_DIR ${DEFAULT_PLUGINS_INSTALL_DIR} CACHE STRING "installs the plugins in the specified directory") set(PLUGINS_INSTALL_DIR ${DEFAULT_PLUGINS_INSTALL_DIR} CACHE STRING "installs the plugins in the specified directory")
message(STATUS "Installing plugins to ${PLUGINS_INSTALL_DIR}") message(STATUS "Installing plugins to ${PLUGINS_INSTALL_DIR}")
set(FONTS_INSTALL_DIR ${MAPNIK_LIB_DIR}/mapnik/fonts CACHE STRING "installs the fonts in the specified directory") set(FONTS_INSTALL_DIR ${MAPNIK_BIN_DIR}/fonts CACHE STRING "installs the fonts in the specified directory")
message(STATUS "Installing fonts to ${FONTS_INSTALL_DIR}") message(STATUS "Installing fonts to ${FONTS_INSTALL_DIR}")
set(MAPNIK_COMPILE_DEFS "") 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 17 CACHE STRING "Sets the c++ standard. c++17 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.
if(CMAKE_CXX_STANDARD VERSION_LESS 17)
list(APPEND MAPNIK_COMPILE_DEFS BOOST_SPIRIT_X3_HIDE_CXX17_WARNING)
endif()
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)
@ -154,18 +139,11 @@ else()
endif() endif()
mapnik_find_package(PkgConfig REQUIRED) find_package(PkgConfig)
mapnik_find_threads() mapnik_find_threads()
mapnik_find_package(ICU REQUIRED COMPONENTS uc i18n data) mapnik_find_package(ICU REQUIRED COMPONENTS uc i18n data)
mapnik_find_package(Boost ${BOOST_MIN_VERSION} REQUIRED COMPONENTS regex) mapnik_find_package(Boost ${BOOST_MIN_VERSION} REQUIRED COMPONENTS filesystem system regex)
if(CMAKE_CXX_STANDARD VERSION_LESS 17)
set(USE_BOOST_FILESYSTEM ON CACHE BOOL "Use boost::filesystem" FORCE)
endif()
if(USE_BOOST_FILESYSTEM)
mapnik_find_package(Boost ${BOOST_MIN_VERSION} REQUIRED COMPONENTS filesystem system)
endif()
list(APPEND MAPNIK_COMPILE_DEFS BOOST_REGEX_HAS_ICU) list(APPEND MAPNIK_COMPILE_DEFS BOOST_REGEX_HAS_ICU)
if(USE_BOOST_REGEX_ICU_WORKAROUND) if(USE_BOOST_REGEX_ICU_WORKAROUND)
message(STATUS "using boost regex workaround") message(STATUS "using boost regex workaround")
@ -186,11 +164,11 @@ if(harfbuzz_FOUND)
message(STATUS "Found harfbuzz native cmake") message(STATUS "Found harfbuzz native cmake")
list(APPEND MAPNIK_OPTIONAL_LIBS harfbuzz::harfbuzz) list(APPEND MAPNIK_OPTIONAL_LIBS harfbuzz::harfbuzz)
else() else()
# Use pkg-config when harfbuzz is not found. # Use pkg-config when harfbuzz is not found.
# 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...")
mapnik_pkg_check_modules(harfbuzz REQUIRED IMPORTED_TARGET harfbuzz>=${HARFBUZZ_MIN_VERSION}) 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()
@ -201,13 +179,13 @@ if(USE_EXTERNAL_MAPBOX_GEOMETRY)
find_path(MAPBOX_GEOMETRY_INCLUDE_DIRS "mapbox/geometry.hpp" REQUIRED) find_path(MAPBOX_GEOMETRY_INCLUDE_DIRS "mapbox/geometry.hpp" REQUIRED)
endif() endif()
else() else()
set(MAPBOX_GEOMETRY_INCLUDE_DIRS set(MAPBOX_GEOMETRY_INCLUDE_DIRS
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/deps/mapbox/geometry/include> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/deps/mapbox/geometry/include>
$<INSTALL_INTERFACE:include> $<INSTALL_INTERFACE:include>
) )
endif() endif()
if(NOT MAPBOX_GEOMETRY_INCLUDE_DIRS) if(NOT MAPBOX_GEOMETRY_INCLUDE_DIRS)
message(FATAL_ERROR "Set -DMAPBOX_GEOMETRY_INCLUDE_DIRS to the mapbox/geometry.hpp include dir") message(FATAL_ERROR "Set -DMAPBOX_GEOMETRY_INCLUDE_DIRS to the mapbox/geometry.hpp include dir")
endif() endif()
if(USE_EXTERNAL_MAPBOX_POLYLABEL) if(USE_EXTERNAL_MAPBOX_POLYLABEL)
@ -216,13 +194,13 @@ if(USE_EXTERNAL_MAPBOX_POLYLABEL)
find_path(MAPBOX_POLYLABEL_INCLUDE_DIRS "mapbox/polylabel.hpp") find_path(MAPBOX_POLYLABEL_INCLUDE_DIRS "mapbox/polylabel.hpp")
endif() endif()
else() else()
set(MAPBOX_POLYLABEL_INCLUDE_DIRS set(MAPBOX_POLYLABEL_INCLUDE_DIRS
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/deps/mapbox/polylabel/include> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/deps/mapbox/polylabel/include>
$<INSTALL_INTERFACE:include> $<INSTALL_INTERFACE:include>
) )
endif() endif()
if(NOT MAPBOX_POLYLABEL_INCLUDE_DIRS) if(NOT MAPBOX_POLYLABEL_INCLUDE_DIRS)
message(FATAL_ERROR "Set MAPBOX_POLYLABEL_INCLUDE_DIRS to the mapbox/geometry include dir") message(FATAL_ERROR "Set MAPBOX_POLYLABEL_INCLUDE_DIRS to the mapbox/geometry include dir")
endif() endif()
if(USE_EXTERNAL_MAPBOX_PROTOZERO) if(USE_EXTERNAL_MAPBOX_PROTOZERO)
@ -231,13 +209,13 @@ if(USE_EXTERNAL_MAPBOX_PROTOZERO)
find_path(MAPBOX_PROTOZERO_INCLUDE_DIRS "protozero/pbf_message.hpp") find_path(MAPBOX_PROTOZERO_INCLUDE_DIRS "protozero/pbf_message.hpp")
endif() endif()
else() else()
set(MAPBOX_PROTOZERO_INCLUDE_DIRS set(MAPBOX_PROTOZERO_INCLUDE_DIRS
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/deps/mapbox/protozero/include> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/deps/mapbox/protozero/include>
$<INSTALL_INTERFACE:include> $<INSTALL_INTERFACE:include>
) )
endif() endif()
if(NOT MAPBOX_PROTOZERO_INCLUDE_DIRS) if(NOT MAPBOX_PROTOZERO_INCLUDE_DIRS)
message(FATAL_ERROR "Set MAPBOX_PROTOZERO_INCLUDE_DIRS to the mapbox/protozero include dir") message(FATAL_ERROR "Set MAPBOX_PROTOZERO_INCLUDE_DIRS to the mapbox/protozero include dir")
endif() endif()
if(USE_EXTERNAL_MAPBOX_VARIANT) if(USE_EXTERNAL_MAPBOX_VARIANT)
@ -246,13 +224,13 @@ if(USE_EXTERNAL_MAPBOX_VARIANT)
find_path(MAPBOX_VARIANT_INCLUDE_DIRS "mapbox/variant.hpp") find_path(MAPBOX_VARIANT_INCLUDE_DIRS "mapbox/variant.hpp")
endif() endif()
else() else()
set(MAPBOX_VARIANT_INCLUDE_DIRS set(MAPBOX_VARIANT_INCLUDE_DIRS
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/deps/mapbox/variant/include> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/deps/mapbox/variant/include>
$<INSTALL_INTERFACE:include> $<INSTALL_INTERFACE:include>
) )
endif() endif()
if(NOT MAPBOX_VARIANT_INCLUDE_DIRS) if(NOT MAPBOX_VARIANT_INCLUDE_DIRS)
message(FATAL_ERROR "Set MAPBOX_VARIANT_INCLUDE_DIRS to the mapbox/variant include dir") message(FATAL_ERROR "Set MAPBOX_VARIANT_INCLUDE_DIRS to the mapbox/variant include dir")
endif() endif()
# (used by MapnikInstall.cmake. properties are needed since "set(...)" will be out of scope # (used by MapnikInstall.cmake. properties are needed since "set(...)" will be out of scope
@ -264,15 +242,10 @@ if(USE_GLIBC_WORKAROUND)
list(APPEND MAPNIK_COMPILE_DEFS MAPNIK_ENABLE_GLIBC_WORKAROUND) list(APPEND MAPNIK_COMPILE_DEFS MAPNIK_ENABLE_GLIBC_WORKAROUND)
endif() endif()
if(USE_BIGINT) if(USE_BIGINT)
list(APPEND MAPNIK_COMPILE_DEFS BIGINT) list(APPEND MAPNIK_COMPILE_DEFS BIGINT)
endif() endif()
if(USE_BOOST_FILESYSTEM)
list(APPEND MAPNIK_COMPILE_DEFS USE_BOOST_FILESYSTEM)
list(APPEND MAPNIK_OPTIONAL_LIBS Boost::filesystem)
endif()
if(USE_MEMORY_MAPPED_FILE) if(USE_MEMORY_MAPPED_FILE)
list(APPEND MAPNIK_COMPILE_DEFS MAPNIK_MEMORY_MAPPED_FILE) list(APPEND MAPNIK_COMPILE_DEFS MAPNIK_MEMORY_MAPPED_FILE)
endif() endif()
@ -322,15 +295,20 @@ if(USE_TIFF)
endif() endif()
if(USE_WEBP) if(USE_WEBP)
mapnik_pkg_check_modules(WebP REQUIRED IMPORTED_TARGET libwebp) mapnik_find_package(WebP REQUIRED)
list(APPEND MAPNIK_COMPILE_DEFS HAVE_WEBP) list(APPEND MAPNIK_COMPILE_DEFS HAVE_WEBP)
list(APPEND MAPNIK_OPTIONAL_LIBS PkgConfig::WebP) list(APPEND MAPNIK_OPTIONAL_LIBS WebP::WebP)
endif() endif()
if(USE_CAIRO) if(USE_CAIRO)
mapnik_pkg_check_modules(Cairo REQUIRED IMPORTED_TARGET cairo) if(WIN32)
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)
@ -339,7 +317,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...")
mapnik_pkg_check_modules(PROJ REQUIRED IMPORTED_TARGET proj>=${PROJ_MIN_VERSION}) 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}")
@ -365,7 +343,7 @@ if(USE_SVG_RENDERER)
list(APPEND MAPNIK_COMPILE_DEFS SVG_RENDERER) list(APPEND MAPNIK_COMPILE_DEFS SVG_RENDERER)
endif() endif()
if(NOT WIN32) if(NOT WIN32)
message(STATUS "Compiling with -DMAPNIK_HAS_DLCFN") message(STATUS "Compiling with -DMAPNIK_HAS_DLCFN")
list(APPEND MAPNIK_COMPILE_DEFS MAPNIK_HAS_DLCFN) list(APPEND MAPNIK_COMPILE_DEFS MAPNIK_HAS_DLCFN)
list(APPEND MAPNIK_OPTIONAL_LIBS ${CMAKE_DL_LIBS}) list(APPEND MAPNIK_OPTIONAL_LIBS ${CMAKE_DL_LIBS})
@ -379,10 +357,6 @@ if(NOT BUILD_SHARED_LIBS)
list(APPEND MAPNIK_COMPILE_DEFS MAPNIK_STATIC_DEFINE) list(APPEND MAPNIK_COMPILE_DEFS MAPNIK_STATIC_DEFINE)
endif() 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( add_compile_options(
@ -393,8 +367,8 @@ add_compile_options(
add_library(core INTERFACE) add_library(core INTERFACE)
add_library(mapnik::core ALIAS core) add_library(mapnik::core ALIAS core)
target_include_directories(core INTERFACE target_include_directories(core INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${MAPBOX_GEOMETRY_INCLUDE_DIRS}> $<BUILD_INTERFACE:${MAPBOX_GEOMETRY_INCLUDE_DIRS}>
$<BUILD_INTERFACE:${MAPBOX_POLYLABEL_INCLUDE_DIRS}> $<BUILD_INTERFACE:${MAPBOX_POLYLABEL_INCLUDE_DIRS}>
$<BUILD_INTERFACE:${MAPBOX_VARIANT_INCLUDE_DIRS}> $<BUILD_INTERFACE:${MAPBOX_VARIANT_INCLUDE_DIRS}>
@ -403,17 +377,17 @@ target_include_directories(core INTERFACE
$<INSTALL_INTERFACE:include> $<INSTALL_INTERFACE:include>
${MAPNIK_OPTIONAL_LIBS_INCLUDE} ${MAPNIK_OPTIONAL_LIBS_INCLUDE}
) )
target_link_libraries(core INTERFACE target_link_libraries(core INTERFACE
Threads::Threads Threads::Threads
ICU::uc ICU::uc
ICU::data ICU::data
ICU::i18n ICU::i18n
Boost::headers Boost::headers
Boost::regex Boost::regex
Boost::filesystem
Freetype::Freetype Freetype::Freetype
${MAPNIK_OPTIONAL_LIBS} ${MAPNIK_OPTIONAL_LIBS}
) )
target_compile_definitions(core INTERFACE ${MAPNIK_COMPILE_DEFS}) target_compile_definitions(core INTERFACE ${MAPNIK_COMPILE_DEFS})
mapnik_install(core) mapnik_install(core)
@ -448,11 +422,10 @@ feature_summary(FILENAME "${CMAKE_CURRENT_BINARY_DIR}/packages.log" WHAT PACKAGE
include(MapnikExport) include(MapnikExport)
include(MapnikExportPkgConfig) include(MapnikExportPkgConfig)
install(DIRECTORY include/mapnik/ DESTINATION "${MAPNIK_INCLUDE_DIR}/mapnik") install(DIRECTORY include/ DESTINATION "${MAPNIK_INCLUDE_DIR}")
install(DIRECTORY deps/agg/include/ DESTINATION "${MAPNIK_INCLUDE_DIR}/mapnik/agg") 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") install(DIRECTORY fonts/ DESTINATION "${FONTS_INSTALL_DIR}" FILES_MATCHING PATTERN "*.py" EXCLUDE PATTERN "*")
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}")

View file

@ -1,8 +1,8 @@
{ {
"version": 6, "version": 2,
"cmakeMinimumRequired": { "cmakeMinimumRequired": {
"major": 3, "major": 3,
"minor": 25, "minor": 20,
"patch": 0 "patch": 0
}, },
"configurePresets": [ "configurePresets": [
@ -17,7 +17,7 @@
{ {
"name": "default-build-dir", "name": "default-build-dir",
"hidden": true, "hidden": true,
"binaryDir": "${sourceDir}/build" "binaryDir": "${sourceDir}/build/${presetName}"
}, },
{ {
"name": "debug-build", "name": "debug-build",
@ -179,10 +179,8 @@
"hidden": true, "hidden": true,
"cacheVariables": { "cacheVariables": {
"BUILD_TESTING": "ON", "BUILD_TESTING": "ON",
"BUILD_DEMO_VIEWER": "OFF", "BUILD_DEMO_VIEWER": "OFF"
"DISABLE_MAPNIK_AUTOSETUP": "ON" }
},
"toolchainFile": "vcpkg/scripts/buildsystems/vcpkg.cmake"
}, },
{ {
"name": "windows-ci", "name": "windows-ci",
@ -193,10 +191,10 @@
], ],
"cacheVariables": { "cacheVariables": {
"INSTALL_DEPENDENCIES": "ON", "INSTALL_DEPENDENCIES": "ON",
"ADDITIONAL_LIBARIES_PATHS": "${sourceDir}/build/vcpkg_installed/x64-windows/bin" "ADDITIONAL_LIBARIES_PATHS": "${sourceDir}/build/${presetName}/vcpkg_installed/x64-windows/bin"
}, },
"environment": { "environment": {
"PROJ_LIB": "${sourceDir}/build/vcpkg_installed/x64-windows/share/proj" "PROJ_LIB": "${sourceDir}/build/${presetName}/vcpkg_installed/x64-windows/share/proj4"
} }
}, },
{ {
@ -211,24 +209,11 @@
"CMAKE_CXX_FLAGS": "--coverage" "CMAKE_CXX_FLAGS": "--coverage"
}, },
"environment": { "environment": {
"PROJ_LIB": "${sourceDir}/build/vcpkg_installed/x64-linux/share/proj" "PROJ_LIB": "${sourceDir}/build/${presetName}/vcpkg_installed/x64-linux/share/proj4"
} }
}, },
{ {
"name": "linux-ci-release", "name": "macos-ci",
"description": "used by the ci pipeline for releasing",
"inherits": [
"release-build",
"linux-gcc-release"
],
"cacheVariables": {
"BUILD_TESTING": "OFF",
"BUILD_DEMO_VIEWER": "OFF",
"USE_MEMORY_MAPPED_FILE": "ON"
}
},
{
"name": "macos-ci-arm64",
"description": "used by the ci pipeline", "description": "used by the ci pipeline",
"inherits": [ "inherits": [
"use-ninja", "use-ninja",
@ -240,23 +225,7 @@
"CMAKE_CXX_FLAGS": "-fprofile-arcs -ftest-coverage" "CMAKE_CXX_FLAGS": "-fprofile-arcs -ftest-coverage"
}, },
"environment": { "environment": {
"PROJ_LIB": "${sourceDir}/build/vcpkg_installed/arm64-osx/share/proj" "PROJ_LIB": "${sourceDir}/build/${presetName}/vcpkg_installed/x64-osx/share/proj4"
}
},
{
"name": "macos-ci-x64",
"description": "used by the ci pipeline",
"inherits": [
"use-ninja",
"release-with-debug-build",
"default-build-dir",
"ci-options"
],
"cacheVariables": {
"CMAKE_CXX_FLAGS": "-fprofile-arcs -ftest-coverage"
},
"environment": {
"PROJ_LIB": "${sourceDir}/build/vcpkg_installed/x64-osx/share/proj"
} }
} }
], ],
@ -294,16 +263,8 @@
"configurePreset": "linux-ci" "configurePreset": "linux-ci"
}, },
{ {
"name": "linux-ci-release", "name": "macos-ci",
"configurePreset": "linux-ci-release" "configurePreset": "macos-ci"
},
{
"name": "macos-ci-arm64",
"configurePreset": "macos-ci-arm64"
},
{
"name": "macos-ci-x64",
"configurePreset": "macos-ci-x64"
} }
], ],
"testPresets": [ "testPresets": [
@ -333,15 +294,8 @@
] ]
}, },
{ {
"name": "macos-ci-arm64", "name": "macos-ci",
"configurePreset": "macos-ci-arm64", "configurePreset": "macos-ci",
"inherits": [
"test-default"
]
},
{
"name": "macos-ci-x64",
"configurePreset": "macos-ci-x64",
"inherits": [ "inherits": [
"test-default" "test-default"
] ]

View file

@ -42,8 +42,8 @@ To use a Python interpreter that is not named `python` for your build, do
something like the following instead: something like the following instead:
```bash ```bash
$ PYTHON=python3 ./configure $ PYTHON=python2 ./configure
$ make PYTHON=python3 $ make PYTHON=python2
``` ```
NOTE: the above will not work on windows, rather see https://github.com/mapnik/mapnik/wiki/WindowsInstallation NOTE: the above will not work on windows, rather see https://github.com/mapnik/mapnik/wiki/WindowsInstallation
@ -71,15 +71,15 @@ For troubleshooting help see https://github.com/mapnik/mapnik/wiki/InstallationT
Build system dependencies are: Build system dependencies are:
* C++ compiler supporting `-std=c++17` (like >= g++ 9 or >= clang++ 5) * C++ compiler supporting `-std=c++14` (like >= g++ 4.8 or >= clang++ 3.4)
* \>= 2 GB RAM (> 5 GB for g++) * >= 2 GB RAM (> 5 GB for g++)
* Python 3 * Python 2.4-2.7
* Scons (a copy is bundled) or CMake >= 3.15 see [docs/cmake-usage.md](./docs/cmake-usage.md) * Scons (a copy is bundled) or CMake >= 3.15 see [docs/cmake-usage.md](./docs/cmake-usage.md)
Mapnik Core depends on: Mapnik Core depends on:
* Boost * Boost
- \>= 1.73 is required - >= 1.73 is required
- These libraries are used: - These libraries are used:
- filesystem - filesystem
- system - system

View file

@ -1,6 +1,6 @@
# This file is part of Mapnik (c++ mapping toolkit) # This file is part of Mapnik (c++ mapping toolkit)
# #
# Copyright (C) 2024 Artem Pavlenko # Copyright (C) 2021 Artem Pavlenko
# #
# Mapnik is free software; you can redistribute it and/or # Mapnik is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public # modify it under the terms of the GNU Lesser General Public
@ -22,7 +22,7 @@ import re
import platform import platform
from glob import glob from glob import glob
from copy import copy from copy import copy
from subprocess import run, Popen, PIPE from subprocess import Popen, PIPE
from SCons.SConf import SetCacheMode from SCons.SConf import SetCacheMode
import pickle import pickle
@ -43,7 +43,7 @@ ICU_LIBS_DEFAULT='/usr/'
DEFAULT_CC = "cc" DEFAULT_CC = "cc"
DEFAULT_CXX = "c++" DEFAULT_CXX = "c++"
DEFAULT_CXX_STD = "17" DEFAULT_CXX_STD = "14"
DEFAULT_CXX_CXXFLAGS = " -DU_USING_ICU_NAMESPACE=0" DEFAULT_CXX_CXXFLAGS = " -DU_USING_ICU_NAMESPACE=0"
DEFAULT_CXX_LINKFLAGS = "" DEFAULT_CXX_LINKFLAGS = ""
if sys.platform == 'darwin': if sys.platform == 'darwin':
@ -410,8 +410,8 @@ opts.AddVariables(
PathVariable('WEBP_INCLUDES', 'Search path for libwebp include files', '/usr/include', PathVariable.PathAccept), PathVariable('WEBP_INCLUDES', 'Search path for libwebp include files', '/usr/include', PathVariable.PathAccept),
PathVariable('WEBP_LIBS','Search path for libwebp library files','/usr/' + LIBDIR_SCHEMA_DEFAULT, PathVariable.PathAccept), PathVariable('WEBP_LIBS','Search path for libwebp library files','/usr/' + LIBDIR_SCHEMA_DEFAULT, PathVariable.PathAccept),
BoolVariable('PROJ', 'Build Mapnik with proj support to enable transformations between many different projections', 'True'), BoolVariable('PROJ', 'Build Mapnik with proj support to enable transformations between many different projections', 'True'),
PathVariable('PROJ_INCLUDES', 'Search path for libproj include files', '/usr/include', PathVariable.PathAccept), PathVariable('PROJ_INCLUDES', 'Search path for PROJ.4 include files', '/usr/include', PathVariable.PathAccept),
PathVariable('PROJ_LIBS', 'Search path for libproj library files', '/usr/' + LIBDIR_SCHEMA_DEFAULT, PathVariable.PathAccept), PathVariable('PROJ_LIBS', 'Search path for PROJ.4 library files', '/usr/' + LIBDIR_SCHEMA_DEFAULT, PathVariable.PathAccept),
('PG_INCLUDES', 'Search path for libpq (postgres client) include files', ''), ('PG_INCLUDES', 'Search path for libpq (postgres client) include files', ''),
('PG_LIBS', 'Search path for libpq (postgres client) library files', ''), ('PG_LIBS', 'Search path for libpq (postgres client) library files', ''),
('FREETYPE_INCLUDES', 'Search path for Freetype include files', ''), ('FREETYPE_INCLUDES', 'Search path for Freetype include files', ''),
@ -467,9 +467,8 @@ opts.AddVariables(
BoolVariable('MAPNIK_RENDER', 'Compile and install a utility to render a map to an image', 'True'), BoolVariable('MAPNIK_RENDER', 'Compile and install a utility to render a map to an image', 'True'),
BoolVariable('COLOR_PRINT', 'Print build status information in color', 'True'), BoolVariable('COLOR_PRINT', 'Print build status information in color', 'True'),
BoolVariable('BIGINT', 'Compile support for 64-bit integers in mapnik::value', 'True'), BoolVariable('BIGINT', 'Compile support for 64-bit integers in mapnik::value', 'True'),
BoolVariable('USE_BOOST_FILESYSTEM','Use boost::filesytem even if `std::filesystem` is available (since c++17)', 'False'),
BoolVariable('QUIET', 'Reduce build verbosity', 'False'), BoolVariable('QUIET', 'Reduce build verbosity', 'False'),
) )
# variables to pickle after successful configure step # variables to pickle after successful configure step
# these include all scons core variables as well as custom # these include all scons core variables as well as custom
@ -536,7 +535,6 @@ pickle_store = [# Scons internal variables
'SQLITE_LINKFLAGS', 'SQLITE_LINKFLAGS',
'BOOST_LIB_VERSION_FROM_HEADER', 'BOOST_LIB_VERSION_FROM_HEADER',
'BIGINT', 'BIGINT',
'USE_BOOST_FILESYSTEM',
'HOST', 'HOST',
'QUERIED_GDAL_DATA', 'QUERIED_GDAL_DATA',
'QUERIED_ICU_DATA', 'QUERIED_ICU_DATA',
@ -949,17 +947,54 @@ int main()
return ret return ret
def CheckProjData(context, silent=False): def CheckProjData(context, silent=False):
if not silent: if not silent:
context.Message('Checking for PROJ_LIB directory...') context.Message('Checking for PROJ_LIB directory...')
result = run(['pkg-config', 'proj', '--variable=datadir'], stdout=PIPE) ret, out = context.TryRun("""
value = result.stdout.decode('utf-8').strip()
#include <proj.h>
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <fstream>
std::vector<std::string> split_searchpath(std::string const& paths)
{
std::vector<std::string> output;
std::stringstream ss(paths);
std::string path;
for( std::string path;std::getline(ss, path, ':');)
{
output.push_back(path);
}
return output;
}
int main()
{
PJ_INFO info = proj_info();
std::string result = info.searchpath;
for (auto path : split_searchpath(result))
{
std::ifstream file(path + "/proj.db");
if (file)
{
std::cout << path;
return 0;
}
}
return -1;
}
""", '.cpp')
value = out.strip()
if silent: if silent:
context.did_show_result=1 context.did_show_result=1
if os.path.exists(value): if ret:
context.Result('`pkg-config proj --variable=datadir` returned:\n%s ' % value) context.Result('proj_info.searchpath returned %s' % value)
else: else:
value = None
context.Result('Failed to detect (mapnik-config will have null value)') context.Result('Failed to detect (mapnik-config will have null value)')
return value return value
@ -1545,25 +1580,11 @@ if not preconfigured:
env['SKIPPED_DEPS'].append('png') env['SKIPPED_DEPS'].append('png')
if env['WEBP']: if env['WEBP']:
if env.get('WEBP_LIBS') or env.get('WEBP_INCLUDES'): OPTIONAL_LIBSHEADERS.append(['webp', 'webp/decode.h', False,'C','-DHAVE_WEBP'])
OPTIONAL_LIBSHEADERS.append(['webp', 'webp/decode.h', False,'C','-DHAVE_WEBP']) inc_path = env['%s_INCLUDES' % 'WEBP']
inc_path = env['WEBP_INCLUDES'] lib_path = env['%s_LIBS' % 'WEBP']
lib_path = env['WEBP_LIBS'] env.AppendUnique(CPPPATH = fix_path(inc_path))
env.AppendUnique(CPPPATH = fix_path(inc_path)) env.AppendUnique(LIBPATH = fix_path(lib_path))
env.AppendUnique(LIBPATH = fix_path(lib_path))
else:
cmd = 'pkg-config libwebp --libs --cflags'
if env['RUNTIME_LINK'] == 'static':
cmd += ' --static'
temp_env = Environment(ENV=os.environ)
try:
temp_env.ParseConfig(cmd)
for lib in temp_env['LIBS']:
env.AppendUnique(LIBPATH = fix_path(lib))
for inc in temp_env['CPPPATH']:
env.AppendUnique(CPPPATH = fix_path(inc))
except OSError as e:
pass
else: else:
env['SKIPPED_DEPS'].append('webp') env['SKIPPED_DEPS'].append('webp')
@ -1610,12 +1631,6 @@ if not preconfigured:
if env['BIGINT']: if env['BIGINT']:
env.Append(CPPDEFINES = '-DBIGINT') env.Append(CPPDEFINES = '-DBIGINT')
if int(env['CXX_STD']) < 17:
env['USE_BOOST_FILESYSTEM'] = True
if env['USE_BOOST_FILESYSTEM']:
env.Append(CPPDEFINES = '-DUSE_BOOST_FILESYSTEM')
if env['THREADING'] == 'multi': if env['THREADING'] == 'multi':
thread_flag = thread_suffix thread_flag = thread_suffix
else: else:
@ -1635,13 +1650,12 @@ if not preconfigured:
# The other required boost headers. # The other required boost headers.
BOOST_LIBSHEADERS = [ BOOST_LIBSHEADERS = [
['system', 'boost/system/system_error.hpp', True],
['filesystem', 'boost/filesystem/operations.hpp', True],
['regex', 'boost/regex.hpp', True], ['regex', 'boost/regex.hpp', True],
['program_options', 'boost/program_options.hpp', False] ['program_options', 'boost/program_options.hpp', False]
] ]
if env['USE_BOOST_FILESYSTEM']:
BOOST_LIBSHEADERS.append(['system', 'boost/system/system_error.hpp', True])
BOOST_LIBSHEADERS.append(['filesystem', 'boost/filesystem/operations.hpp', True])
# if requested, sort LIBPATH and CPPPATH before running CheckLibWithHeader tests # if requested, sort LIBPATH and CPPPATH before running CheckLibWithHeader tests
if env['PRIORITIZE_LINKING']: if env['PRIORITIZE_LINKING']:
conf.prioritize_paths(silent=True) conf.prioritize_paths(silent=True)
@ -1865,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')

39
appveyor.yml Normal file
View file

@ -0,0 +1,39 @@
environment:
msvs_toolset: 14
FASTBUILD: 1
matrix:
- platform: x64
configuration: Release
os: Visual Studio 2015
#shallow_clone: true
# limit clone to latest 5 commits
clone_depth: 5
services:
- postgresql94 #if changing this, also change PATH below
install:
- SET PGUSER=postgres
- SET PGPASSWORD=Password12!
- SET PATH=C:\Program Files\PostgreSQL\9.4\bin\;%PATH%
build_script:
- scripts\build-appveyor.bat
after_build:
- 7z a visual-test-results.zip C:\tmp\mapnik-visual-images\visual-test-results
artifacts:
- path: mapnik-gyp\msbuild-summary.txt
name: msbuild-summary.txt
- path: mapnik-gyp\msbuild-errors.txt
name: msbuild-errors.txt
- path: mapnik-gyp\msbuild-warnings.txt
name: msbuild-warnings.txt
- path: visual-test-results.zip
name: visual-test-results.zip
test: off
deploy: off

View file

@ -1,6 +1,6 @@
project(mapnik-benchmark) project(mapnik-benchmark)
set(BENCHMARK_SRCS set(BENCHMARK_SRCS
src/normalize_angle.cpp src/normalize_angle.cpp
src/test_array_allocation.cpp src/test_array_allocation.cpp
src/test_expression_parse.cpp src/test_expression_parse.cpp
@ -31,12 +31,11 @@ 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 target_link_libraries(${TARGET_NAME} PRIVATE mapnik::agg mapnik::mapnik)
mapnik::agg set_target_properties(${TARGET_NAME} PROPERTIES
mapnik::mapnik LIBRARY_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
ICU::data ICU::i18n ICU::uc # needed for the static build (TODO: why isn't this correctly propagated from mapnik::mapnik?) RUNTIME_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
) ARCHIVE_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}/lib"
set_target_properties(${TARGET_NAME} PROPERTIES
OUTPUT_NAME "${BENCHNAME}" OUTPUT_NAME "${BENCHNAME}"
) )
endfunction() endfunction()
@ -46,7 +45,7 @@ foreach(benchmark ${BENCHMARK_SRCS})
endforeach() endforeach()
file(COPY data DESTINATION "${MAPNIK_OUTPUT_DIR}/benchmark") file(COPY data DESTINATION "${MAPNIK_OUTPUT_DIR}/benchmark")
file(COPY run_benchmarks file(COPY run_benchmarks
DESTINATION "${MAPNIK_OUTPUT_DIR}" DESTINATION "${MAPNIK_OUTPUT_DIR}"
FILE_PERMISSIONS OWNER_READ OWNER_EXECUTE OWNER_WRITE GROUP_WRITE GROUP_READ GROUP_EXECUTE WORLD_READ FILE_PERMISSIONS OWNER_READ OWNER_EXECUTE OWNER_WRITE GROUP_WRITE GROUP_READ GROUP_EXECUTE WORLD_READ
) )

View file

@ -15,6 +15,8 @@
#include <cstdio> // snprintf #include <cstdio> // snprintf
#include <iomanip> #include <iomanip>
#include <iostream> #include <iostream>
#include <set>
#include <sstream>
#include <thread> #include <thread>
#include <mutex> #include <mutex>
#include <vector> #include <vector>
@ -132,8 +134,7 @@ inline int handle_args(int argc, char** argv, mapnik::parameters& params)
auto result = run(test_runner, name); \ auto result = run(test_runner, name); \
testing::run_cleanup(); \ testing::run_cleanup(); \
return result; \ return result; \
} \ } catch (std::exception const& ex) \
catch (std::exception const& ex) \
{ \ { \
std::clog << ex.what() << "\n"; \ std::clog << ex.what() << "\n"; \
testing::run_cleanup(); \ testing::run_cleanup(); \
@ -264,8 +265,7 @@ int run(T const& test_runner, std::string const& name)
ips.u); ips.u);
std::clog << msg; std::clog << msg;
return 0; return 0;
} } catch (std::exception const& ex)
catch (std::exception const& ex)
{ {
std::clog << "test runner did not complete: " << ex.what() << "\n"; std::clog << "test runner did not complete: " << ex.what() << "\n";
return 4; return 4;

View file

@ -1,6 +1,7 @@
#include "bench_framework.hpp" #include "bench_framework.hpp"
#include <mapnik/font_engine_freetype.hpp> #include <mapnik/font_engine_freetype.hpp>
#include <boost/format.hpp> #include <boost/format.hpp>
#include <boost/foreach.hpp>
class test : public benchmark::test_case class test : public benchmark::test_case
{ {

View file

@ -9,7 +9,7 @@ class test : public benchmark::test_case
: test_case(params) : test_case(params)
, line_data_("this is one line\nand this is a second line\nand a third line") , line_data_("this is one line\nand this is a second line\nand a third line")
{ {
auto line_data = params.get<std::string>("line"); boost::optional<std::string> line_data = params.get<std::string>("line");
if (line_data) if (line_data)
{ {
line_data_ = *line_data; line_data_ = *line_data;
@ -57,7 +57,7 @@ class test2 : public benchmark::test_case
: test_case(params) : test_case(params)
, line_data_("this is one line\nand this is a second line\nand a third line") , line_data_("this is one line\nand this is a second line\nand a third line")
{ {
auto line_data = params.get<std::string>("line"); boost::optional<std::string> line_data = params.get<std::string>("line");
if (line_data) if (line_data)
{ {
line_data_ = *line_data; line_data_ = *line_data;
@ -115,8 +115,7 @@ int main(int argc, char** argv)
test2 test_runner2(params); test2 test_runner2(params);
return_value = return_value | run(test_runner2, "csv_utils::getline_csv"); return_value = return_value | run(test_runner2, "csv_utils::getline_csv");
} }
} } catch (std::exception const& ex)
catch (std::exception const& ex)
{ {
std::clog << ex.what() << "\n"; std::clog << ex.what() << "\n";
return -1; return -1;

View file

@ -59,12 +59,10 @@ class test_numeric : public benchmark::test_case
try try
{ {
x = boost::numeric_cast<std::uint8_t>(start_ * value_); x = boost::numeric_cast<std::uint8_t>(start_ * value_);
} } catch (negative_overflow&)
catch (negative_overflow&)
{ {
x = std::numeric_limits<std::uint8_t>::min(); x = std::numeric_limits<std::uint8_t>::min();
} } catch (positive_overflow&)
catch (positive_overflow&)
{ {
x = std::numeric_limits<std::uint8_t>::max(); x = std::numeric_limits<std::uint8_t>::max();
} }

View file

@ -1,6 +1,5 @@
#include "bench_framework.hpp" #include "bench_framework.hpp"
#include "compare_images.hpp" #include "compare_images.hpp"
#include <memory>
class test : public benchmark::test_case class test : public benchmark::test_case
{ {

View file

@ -26,14 +26,14 @@ class test : public benchmark::test_case
, scale_factor_(*params.get<mapnik::value_double>("scale_factor", 1.0)) , scale_factor_(*params.get<mapnik::value_double>("scale_factor", 1.0))
, preview_(*params.get<std::string>("preview", "")) , preview_(*params.get<std::string>("preview", ""))
{ {
const auto map = params.get<std::string>("map"); boost::optional<std::string> map = params.get<std::string>("map");
if (!map) if (!map)
{ {
throw std::runtime_error("please provide a --map <path to xml> arg"); throw std::runtime_error("please provide a --map <path to xml> arg");
} }
xml_ = *map; xml_ = *map;
const auto ext = params.get<std::string>("extent"); boost::optional<std::string> ext = params.get<std::string>("extent");
if (ext && !ext->empty()) if (ext && !ext->empty())
{ {
if (!extent_.from_string(*ext)) if (!extent_.from_string(*ext))
@ -101,7 +101,7 @@ int main(int argc, char** argv)
{ {
mapnik::parameters params; mapnik::parameters params;
benchmark::handle_args(argc, argv, params); benchmark::handle_args(argc, argv, params);
const auto name = params.get<std::string>("name"); boost::optional<std::string> name = params.get<std::string>("name");
if (!name) if (!name)
{ {
std::clog << "please provide a name for this test\n"; std::clog << "please provide a name for this test\n";
@ -113,8 +113,7 @@ int main(int argc, char** argv)
test test_runner(params); test test_runner(params);
return_value = run(test_runner, *name); return_value = run(test_runner, *name);
} }
} } catch (std::exception const& ex)
catch (std::exception const& ex)
{ {
std::clog << ex.what() << "\n"; std::clog << ex.what() << "\n";
return -1; return -1;

View file

@ -64,14 +64,14 @@ class test : public benchmark::test_case
, preview_(*params.get<std::string>("preview", "")) , preview_(*params.get<std::string>("preview", ""))
, im_(m_->width(), m_->height()) , im_(m_->width(), m_->height())
{ {
const auto map = params.get<std::string>("map"); boost::optional<std::string> map = params.get<std::string>("map");
if (!map) if (!map)
{ {
throw std::runtime_error("please provide a --map=<path to xml> arg"); throw std::runtime_error("please provide a --map=<path to xml> arg");
} }
xml_ = *map; xml_ = *map;
auto ext = params.get<std::string>("extent"); boost::optional<std::string> ext = params.get<std::string>("extent");
mapnik::load_map(*m_, xml_, true); mapnik::load_map(*m_, xml_, true);
if (ext && !ext->empty()) if (ext && !ext->empty())
{ {
@ -156,7 +156,7 @@ int main(int argc, char** argv)
{ {
mapnik::parameters params; mapnik::parameters params;
benchmark::handle_args(argc, argv, params); benchmark::handle_args(argc, argv, params);
const auto name = params.get<std::string>("name"); boost::optional<std::string> name = params.get<std::string>("name");
if (!name) if (!name)
{ {
std::clog << "please provide a name for this test\n"; std::clog << "please provide a name for this test\n";
@ -168,8 +168,7 @@ int main(int argc, char** argv)
test test_runner(params); test test_runner(params);
return_value = run(test_runner, *name); return_value = run(test_runner, *name);
} }
} } catch (std::exception const& ex)
catch (std::exception const& ex)
{ {
std::clog << ex.what() << "\n"; std::clog << ex.what() << "\n";
return -1; return -1;

173
bootstrap.sh Executable file
View file

@ -0,0 +1,173 @@
#!/usr/bin/env bash
: '
todo
- docs for base setup: sudo apt-get -y install zlib1g-dev make git
- shrink icu data
'
MASON_VERSION="485514d8"
function setup_mason() {
if [[ ! -d ./.mason ]]; then
git clone https://github.com/mapbox/mason.git .mason || return
elif ! git -C .mason rev-parse -q --verify "$MASON_VERSION" >/dev/null; then
git -C .mason fetch --all || true # non-fatal
fi
git -C .mason checkout --detach "$MASON_VERSION" -- || return
case ":$PATH:" in
*":$PWD/.mason:"*) : already there ;;
*) export PATH="$PWD/.mason:$PATH" ;;
esac
export CXX=${CXX:-clang++}
export CC=${CC:-clang}
}
function install() {
MASON_PLATFORM_ID=$(mason env MASON_PLATFORM_ID)
if [[ ! -d ./mason_packages/${MASON_PLATFORM_ID}/${1}/${2} ]]; then
mason install $1 $2
if [[ ${3:-false} != false ]]; then
LA_FILE=$(mason prefix $1 $2)/lib/$3.la
if [[ -f ${LA_FILE} ]]; then
perl -i -p -e 's:\Q$ENV{HOME}/build/mapbox/mason\E:$ENV{PWD}:g' ${LA_FILE}
else
echo "$LA_FILE not found"
fi
fi
fi
# the rm here is to workaround https://github.com/mapbox/mason/issues/230
rm -f ./mason_packages/.link/mason.ini
mason link $1 $2
}
ICU_VERSION="58.1"
BOOST_VERSION="1.75.0"
function install_mason_deps() {
install ccache 3.3.1
install zlib 1.2.8
install jpeg_turbo 1.5.2 libjpeg
install libpng 1.6.32 libpng
install libtiff 4.0.8 libtiff
install libpq 9.6.5
install sqlite 3.34.0 libsqlite3
install icu ${ICU_VERSION}
install proj 7.2.1 libproj
install pixman 0.34.0 libpixman-1
install cairo 1.14.8 libcairo
install webp 0.6.0 libwebp
install libgdal 2.2.3 libgdal
install boost ${BOOST_VERSION}
install boost_libsystem ${BOOST_VERSION}
install boost_libfilesystem ${BOOST_VERSION}
install boost_libprogram_options ${BOOST_VERSION}
install boost_libregex_icu58 ${BOOST_VERSION}
# technically boost thread and python are not a core dep, but installing
# here by default helps make python-mapnik builds easier
install boost_libthread ${BOOST_VERSION}
install boost_libpython ${BOOST_VERSION}
install freetype 2.7.1 libfreetype
install harfbuzz 1.4.4-ft libharfbuzz
}
MASON_LINKED_ABS=$(pwd)/mason_packages/.link
MASON_LINKED_REL=./mason_packages/.link
export C_INCLUDE_PATH="${MASON_LINKED_ABS}/include"
export CPLUS_INCLUDE_PATH="${MASON_LINKED_ABS}/include"
export LIBRARY_PATH="${MASON_LINKED_ABS}/lib"
function make_config() {
echo "
CXX = '$CXX'
CC = '$CC'
CUSTOM_CXXFLAGS = '-D_GLIBCXX_USE_CXX11_ABI=0'
RUNTIME_LINK = 'static'
INPUT_PLUGINS = 'all'
PATH = '${MASON_LINKED_REL}/bin'
PKG_CONFIG_PATH = '${MASON_LINKED_REL}/lib/pkgconfig'
PATH_REMOVE = '/usr:/usr/local'
PATH_REPLACE = '$HOME/build/mapbox/mason/mason_packages:./mason_packages'
BOOST_INCLUDES = '${MASON_LINKED_REL}/include'
BOOST_LIBS = '${MASON_LINKED_REL}/lib'
ICU_INCLUDES = '${MASON_LINKED_REL}/include'
ICU_LIBS = '${MASON_LINKED_REL}/lib'
HB_INCLUDES = '${MASON_LINKED_REL}/include'
HB_LIBS = '${MASON_LINKED_REL}/lib'
PNG_INCLUDES = '${MASON_LINKED_REL}/include/libpng16'
PNG_LIBS = '${MASON_LINKED_REL}/lib'
JPEG_INCLUDES = '${MASON_LINKED_REL}/include'
JPEG_LIBS = '${MASON_LINKED_REL}/lib'
TIFF_INCLUDES = '${MASON_LINKED_REL}/include'
TIFF_LIBS = '${MASON_LINKED_REL}/lib'
WEBP_INCLUDES = '${MASON_LINKED_REL}/include'
WEBP_LIBS = '${MASON_LINKED_REL}/lib'
PROJ_INCLUDES = '${MASON_LINKED_REL}/include'
PROJ_LIBS = '${MASON_LINKED_REL}/lib'
PG_INCLUDES = '${MASON_LINKED_REL}/include'
PG_LIBS = '${MASON_LINKED_REL}/lib'
FREETYPE_INCLUDES = '${MASON_LINKED_REL}/include/freetype2'
FREETYPE_LIBS = '${MASON_LINKED_REL}/lib'
SVG_RENDERER = True
CAIRO_INCLUDES = '${MASON_LINKED_REL}/include'
CAIRO_LIBS = '${MASON_LINKED_REL}/lib'
SQLITE_INCLUDES = '${MASON_LINKED_REL}/include'
SQLITE_LIBS = '${MASON_LINKED_REL}/lib'
BENCHMARK = True
CPP_TESTS = True
PGSQL2SQLITE = True
XMLPARSER = 'ptree'
SVG2PNG = True
"
}
# NOTE: the `mapnik-settings.env` is used by test/run (which is run by `make test`)
function setup_runtime_settings() {
echo "export PROJ_LIB=${MASON_LINKED_ABS}/share/proj" > mapnik-settings.env
echo "export ICU_DATA=${MASON_LINKED_ABS}/share/icu/${ICU_VERSION}" >> mapnik-settings.env
echo "export GDAL_DATA=${MASON_LINKED_ABS}/share/gdal" >> mapnik-settings.env
}
# turn arguments of the form NAME=VALUE into exported variables;
# any other arguments are reported and cause error return status
function export_variables() {
local arg= ret=0
for arg
do
if [[ "$arg" =~ ^[[:alpha:]][_[:alnum:]]*= ]]
then
export "$arg"
else
printf >&2 "bootstrap.sh: invalid argument: %s\n" "$arg"
ret=1
fi
done
return $ret
}
function main() {
export_variables "$@" || return
# setup_mason must not run in subshell, because it sets default
# values of CC, CXX and adds mason to PATH, which we want to keep
# when sourced
setup_mason || return
(
# this is wrapped in subshell to allow sourcing this script
# without having the terminal closed on error
set -eu
set -o pipefail
install_mason_deps
make_config > ./config.py
setup_runtime_settings
printf "\n\e[1;32m%s\e[m\n" "bootstrap successful, now run:"
echo ""
echo " ./configure && make"
echo ""
)
}
main "$@"

98
cmake/FindCairo.cmake Normal file
View file

@ -0,0 +1,98 @@
# 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 ()

97
cmake/FindWebP.cmake Normal file
View file

@ -0,0 +1,97 @@
# 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 ()

View file

@ -1,46 +1,34 @@
include(CMakePackageConfigHelpers) include(CMakePackageConfigHelpers)
### exports mapnik cmake config files (mapnikConfigVersion and mapnikConfig) # export mapnik configuration
function(mapnik_export_cmake_config) write_basic_package_version_file(
# export mapnik configuration "${CMAKE_CURRENT_BINARY_DIR}/mapnikConfigVersion.cmake"
write_basic_package_version_file( VERSION ${MAPNIK_VERSION}
"${CMAKE_CURRENT_BINARY_DIR}/mapnikConfigVersion.cmake" COMPATIBILITY ExactVersion
VERSION ${MAPNIK_VERSION} )
COMPATIBILITY ExactVersion get_property(MAPNIK_UTILITIES GLOBAL PROPERTY MAPNIK_UTILITIES)
) list(JOIN MAPNIK_DEPENDENCIES "\n" MAPNIK_DEPENDENCIES)
get_property(MAPNIK_UTILITIES GLOBAL PROPERTY MAPNIK_UTILITIES) configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/mapnikConfig.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/mapnikConfig.cmake"
INSTALL_DESTINATION ${MAPNIK_CMAKE_DIR}
PATH_VARS MAPNIK_INCLUDE_DIR PLUGINS_INSTALL_DIR FONTS_INSTALL_DIR MAPNIK_DEPENDENCIES MAPNIK_UTILITIES
NO_CHECK_REQUIRED_COMPONENTS_MACRO
)
# generate all find_dependency and pkg_config calls install(
set(mapnik_find_deps) FILES
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} "${CMAKE_CURRENT_BINARY_DIR}/mapnikConfigVersion.cmake"
PATH_VARS MAPNIK_INCLUDE_DIR PLUGINS_INSTALL_DIR FONTS_INSTALL_DIR mapnik_find_deps MAPNIK_UTILITIES DESTINATION ${MAPNIK_CMAKE_DIR}
NO_CHECK_REQUIRED_COMPONENTS_MACRO )
)
install(
FILES
"${CMAKE_CURRENT_BINARY_DIR}/mapnikConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/mapnikConfigVersion.cmake"
DESTINATION ${MAPNIK_CMAKE_DIR}
)
endfunction()
# install our modules, so that the expected target names are found.
mapnik_export_cmake_config() install(
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}
@ -48,21 +36,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(m_mapnik_plugin_file_name mapnikPlugins-${_build_type}) set(_mapnik_plugin_file_name "mapnikPlugins-${_build_type}")
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") 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")
include(CMakePackageConfigHelpers) include(CMakePackageConfigHelpers)
configure_package_config_file( configure_package_config_file(
"${CMAKE_CURRENT_BINARY_DIR}/${m_mapnik_plugin_file_name}.cmake.in" ${CMAKE_CURRENT_BINARY_DIR}/${_mapnik_plugin_file_name}.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/${m_mapnik_plugin_file_name}.cmake" ${CMAKE_CURRENT_BINARY_DIR}/${_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}/${m_mapnik_plugin_file_name}.cmake" FILES ${CMAKE_CURRENT_BINARY_DIR}/${_mapnik_plugin_file_name}.cmake
DESTINATION ${MAPNIK_CMAKE_DIR} DESTINATION ${MAPNIK_CMAKE_DIR}
) )

View file

@ -3,13 +3,13 @@ function(create_pkg_config_file _target _lib_name _description)
prefix=@CMAKE_INSTALL_PREFIX@ prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=${prefix} exec_prefix=${prefix}
includedir=${prefix}/include includedir=${prefix}/include
libdir=${exec_prefix}/@MAPNIK_LIB_DIR@ libdir=${exec_prefix}/lib
Name: @_lib_name@ Name: @_lib_name@
Description: @_description@ Description: @_description@
Version: @MAPNIK_VERSION@ Version: @MAPNIK_VERSION@
Libs: -L"${libdir}" -l$<TARGET_FILE_BASE_NAME:@_target@>$<TARGET_PROPERTY:@_target@,$<CONFIG>_POSTFIX> Libs: -L"${libdir}" -l$<TARGET_FILE_BASE_NAME:@_target@>$<TARGET_PROPERTY:@_target@,$<CONFIG>_POSTFIX>
Cflags: -I"${includedir}" -I"${includedir}/mapnik" ]] Cflags: -I"${includedir}" ]]
_contents @ONLY) _contents @ONLY)
file(GENERATE file(GENERATE
@ -26,11 +26,11 @@ endfunction()
function(create_pkg_config_file_mapnik _lib_name _description) function(create_pkg_config_file_mapnik _lib_name _description)
get_target_property(m_compile_defs core INTERFACE_COMPILE_DEFINITIONS) get_target_property(m_compile_defs core INTERFACE_COMPILE_DEFINITIONS)
string(JOIN " -D" m_str_compile_defs ${m_compile_defs}) string(JOIN " -D" m_str_compile_defs ${m_compile_defs})
if(m_str_compile_defs) if(m_str_compile_defs)
set(m_str_compile_defs "-D${m_str_compile_defs}") set(m_str_compile_defs "-D${m_str_compile_defs}")
endif() endif()
set(m_requires set(m_requires
libmapnikwkt libmapnikwkt
libmapnikjson libmapnikjson
icu-uc icu-uc
@ -64,16 +64,14 @@ function(create_pkg_config_file_mapnik _lib_name _description)
prefix=@CMAKE_INSTALL_PREFIX@ prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=${prefix} exec_prefix=${prefix}
includedir=${prefix}/include includedir=${prefix}/include
libdir=${exec_prefix}/@MAPNIK_LIB_DIR@ libdir=${exec_prefix}/lib
fonts_dir=${prefix}/@FONTS_INSTALL_DIR@
plugins_dir=${prefix}/@PLUGINS_INSTALL_DIR@
Name: @_lib_name@ Name: @_lib_name@
Description: @_description@ Description: @_description@
Version: @MAPNIK_VERSION@ Version: @MAPNIK_VERSION@
Requires: @m_requires@ Requires: @m_requires@
Libs: -L"${libdir}" -l$<TARGET_FILE_BASE_NAME:mapnik>$<TARGET_PROPERTY:mapnik,$<CONFIG>_POSTFIX> Libs: -L"${libdir}" -l$<TARGET_FILE_BASE_NAME:mapnik>$<TARGET_PROPERTY:mapnik,$<CONFIG>_POSTFIX>
Cflags: -I"${includedir}" -I"${includedir}/mapnik" -I"${includedir}/mapnik/agg" @m_str_compile_defs@]] Cflags: -I"${includedir}" @m_str_compile_defs@]]
_contents @ONLY) _contents @ONLY)
file(GENERATE file(GENERATE
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_lib_name}-$<CONFIG>.pc OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_lib_name}-$<CONFIG>.pc

View file

@ -1,50 +1,28 @@
function(mapnik_set_dep_version dep var) macro(mapnik_print_version)
string(TOUPPER ${dep} m_package_name_upc) string(TOUPPER ${ARGV0} TLNUP)
set(m_package_name ${dep}) set(TLN ${ARGV0})
if(${m_package_name}_VERSION_STRING) if(${TLN}_VERSION_STRING)
set(${var} ${${m_package_name}_VERSION_STRING} PARENT_SCOPE) message(STATUS "Using ${ARGV0} version: ${${TLN}_VERSION_STRING}")
elseif(${m_package_name}_VERSION) elseif(${TLN}_VERSION)
set(${var} ${${m_package_name}_VERSION} PARENT_SCOPE) message(STATUS "Using ${ARGV0} version: ${${TLN}_VERSION}")
elseif(${m_package_name_upc}_VERSION_STRING) elseif(${TLNUP}_VERSION_STRING)
set(${var} ${${m_package_name_upc}_VERSION_STRING} PARENT_SCOPE) message(STATUS "Using ${ARGV0} version: ${${TLNUP}_VERSION_STRING}")
elseif(${m_package_name_upc}_VERSION) elseif(${TLNUP}_VERSION)
set(${var} ${${m_package_name_upc}_VERSION} PARENT_SCOPE) message(STATUS "Using ${ARGV0} version: ${${TLNUP}_VERSION}")
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()
set(mapnik_${dep}_find_args ${ARGN})
endif()
mapnik_set_dep_version(${dep} mapnik_${dep}_version)
mapnik_print_package_info(${dep})
else() else()
message(STATUS "not found: ${dep}") message(STATUS "Using ${ARGV0}")
endif() endif()
endmacro() endmacro()
macro(mapnik_pkg_check_modules dep) macro(mapnik_find_package)
pkg_check_modules(${dep} ${ARGN}) find_package(${ARGN})
if(${dep}_FOUND) if(${ARGV0}_FOUND)
list(APPEND mapnik_deps ${dep}) set(MAPNIK_TMP_DEP ${ARGN})
list(JOIN MAPNIK_TMP_DEP " " MAPNIK_TMP_DEP)
set(mapnik_${dep}_pkg_args ${ARGN}) list(APPEND MAPNIK_DEPENDENCIES "find_dependency(${MAPNIK_TMP_DEP})")
mapnik_set_dep_version(${dep} mapnik_${dep}_version) mapnik_print_version(${ARGV0})
mapnik_print_package_info(${dep})
else() else()
message(STATUS "not found: ${dep}") message(STATUS "not found: ${ARGV0}")
endif() endif()
endmacro() endmacro()

View file

@ -90,7 +90,7 @@ function(mapnik_install_targets)
message(STATUS \"internal_executables: ${_internal_executables}\") message(STATUS \"internal_executables: ${_internal_executables}\")
message(STATUS \"internal_libraries: ${_internal_libraries}\") message(STATUS \"internal_libraries: ${_internal_libraries}\")
message(STATUS \"ADDITIONAL_LIBARIES_PATHS: ${ADDITIONAL_LIBARIES_PATHS}\") message(STATUS \"ADDITIONAL_LIBARIES_PATHS: ${ADDITIONAL_LIBARIES_PATHS}\")
include(BundleUtilities) include(BundleUtilities)
fixup_bundle(\"${_internal_executables}\" \"${_internal_libraries}\" \"${ADDITIONAL_LIBARIES_PATHS}\") fixup_bundle(\"${_internal_executables}\" \"${_internal_libraries}\" \"${ADDITIONAL_LIBARIES_PATHS}\")
" COMPONENT MapnikRuntime) " COMPONENT MapnikRuntime)

View file

@ -1,5 +1,5 @@
function(format_dir dir) function(format_dir dir)
file(GLOB_RECURSE sources file(GLOB_RECURSE sources
"${dir}/*.cpp" "${dir}/*.cpp"
"${dir}/*.hpp" "${dir}/*.hpp"
) )

View file

@ -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_find_deps@ @MAPNIK_DEPENDENCIES@
include("${CMAKE_CURRENT_LIST_DIR}/mapnikTargets.cmake") include("${CMAKE_CURRENT_LIST_DIR}/mapnikTargets.cmake")
@ -32,14 +32,14 @@ function(mapnik_find_plugin_dir PLUGIN_DIR)
string(TOUPPER "${CMAKE_BUILD_TYPE}" _build_type_l) string(TOUPPER "${CMAKE_BUILD_TYPE}" _build_type_l)
set(_plugin_dir "${MAPNIK_PLUGINS_DIR_${_build_type_l}}") set(_plugin_dir "${MAPNIK_PLUGINS_DIR_${_build_type_l}}")
# only release has more then one configuration # only release has more then one configuration
if(NOT _plugin_dir) if(NOT _plugin_dir)
set(_all_rel_cfgs RELEASE RELWITHDEBINFO MINSIZEREL) set(_all_rel_cfgs RELEASE RELWITHDEBINFO MINSIZEREL)
list(FIND _all_rel_cfgs ${_build_type_l} _is_rel_cfg) list(FIND _all_rel_cfgs ${_build_type_l} _is_rel_cfg)
# check if the current configuration is a known release configuration # check if the current configuration is a known release configuration
if(${_is_rel_cfg} GREATER_EQUAL 0) if(${_is_rel_cfg} GREATER_EQUAL 0)
foreach(_rel_cfg IN LISTS _all_rel_cfgs) foreach(_rel_cfg IN LISTS _all_rel_cfgs)
set(_plugin_dir "${MAPNIK_PLUGINS_DIR_${_rel_cfg}}") set(_plugin_dir "${MAPNIK_PLUGINS_DIR_${_rel_cfg}}")
if(_plugin_dir) if(_plugin_dir)
break() break()
endif() endif()
endforeach() endforeach()
@ -49,4 +49,4 @@ function(mapnik_find_plugin_dir PLUGIN_DIR)
message(WARNING "Could not find a plugin install dir for configuration ${_build_type_l}") message(WARNING "Could not find a plugin install dir for configuration ${_build_type_l}")
endif() endif()
set(${PLUGIN_DIR} ${_plugin_dir} PARENT_SCOPE) set(${PLUGIN_DIR} ${_plugin_dir} PARENT_SCOPE)
endfunction() endfunction()

View file

@ -1,10 +1,9 @@
include(InstallRequiredSystemLibraries) include(InstallRequiredSystemLibraries)
set(CPACK_PACKAGE_NAME "mapnik") set(CPACK_PACKAGE_NAME "mapnik")
set(CPACK_PACKAGE_CONTACT "ubuntu-mathis@outlook.com")
set(CPACK_PACKAGE_HOMEPAGE_URL "https://mapnik.org") set(CPACK_PACKAGE_HOMEPAGE_URL "https://mapnik.org")
set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/COPYING") set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/COPYING")
set(CPACK_SOURCE_GENERATOR "TGZ") set(CPACK_SOURCE_GENERATOR "TGZ")
set(CPACK_GENERATOR "DEB;TGZ") set(CPACK_GENERATOR "TGZ")
set(CPACK_SOURCE_IGNORE_FILES set(CPACK_SOURCE_IGNORE_FILES
\\.git/ \\.git/
build/ build/

18
configure vendored
View file

@ -1,32 +1,18 @@
#! /usr/bin/env bash #! /bin/sh
set -eu set -eu
: ${PYTHON:=python} : ${PYTHON:=python}
# Only some shells (Bash and Z shell) support arrays. Therefore,
# the following code provides an alternative for users calling the script
# with shells other than Bash or Z shell (e.g. Debian users using Dash).
THE_SHELL=$(basename $SHELL)
if [ "$THE_SHELL" != "bash" ] && [ "$THE_SHELL" != "zsh" ]; then
if [ -f mapnik-settings.env ]; then
echo "WARNING: Reading from mapnik-settings.env is supported with Bash or Z shell only."
fi
$PYTHON scons/scons.py --implicit-deps-changed configure "$@"
exit 0
fi
# mapnik-settings.env is an optional file to store # mapnik-settings.env is an optional file to store
# environment variables that should be used before # environment variables that should be used before
# running tests like PROJ_LIB, GDAL_DATA, and ICU_DATA # running tests like PROJ_LIB, GDAL_DATA, and ICU_DATA
# These do not normally need to be set except when # These do not normally need to be set except when
# building against binary versions of dependencies like # building against binary versions of dependencies like
# done via bootstrap.sh # done via bootstrap.sh
if [ -f mapnik-settings.env ]; then if [ -f mapnik-settings.env ]; then
echo "Inheriting from mapnik-settings.env" echo "Inheriting from mapnik-settings.env"
. ./mapnik-settings.env . ./mapnik-settings.env
VARS=( $(cat mapnik-settings.env) )
fi fi
$PYTHON scons/scons.py --implicit-deps-changed configure ${VARS[*]:-} "$@" $PYTHON scons/scons.py --implicit-deps-changed configure "$@"

View file

@ -1,6 +1,8 @@
add_executable(mapnik-demo rundemo.cpp) add_executable(mapnik-demo rundemo.cpp)
target_link_libraries(mapnik-demo PRIVATE set_target_properties(mapnik-demo PROPERTIES
mapnik::agg LIBRARY_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
mapnik::mapnik RUNTIME_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
ICU::data ICU::i18n ICU::uc # needed for the static build (TODO: why isn't this correctly propagated from mapnik::mapnik?) ARCHIVE_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}/lib"
) )
target_link_libraries(mapnik-demo PRIVATE mapnik::agg mapnik::mapnik)

View file

@ -2,7 +2,7 @@
* *
* This file is part of Mapnik (c++ mapping toolkit) * This file is part of Mapnik (c++ mapping toolkit)
* *
* Copyright (C) 2024 Artem Pavlenko * Copyright (C) 2021 Artem Pavlenko
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -132,8 +132,8 @@ int main(int, char**)
line_symbolizer line_sym; line_symbolizer line_sym;
put(line_sym, keys::stroke, color(171, 158, 137)); put(line_sym, keys::stroke, color(171, 158, 137));
put(line_sym, keys::stroke_width, 2.0); put(line_sym, keys::stroke_width, 2.0);
put(line_sym, keys::stroke_linecap, line_cap_enum::ROUND_CAP); put(line_sym, keys::stroke_linecap, ROUND_CAP);
put(line_sym, keys::stroke_linejoin, line_join_enum::ROUND_JOIN); put(line_sym, keys::stroke_linejoin, ROUND_JOIN);
r.append(std::move(line_sym)); r.append(std::move(line_sym));
} }
roads34_style.add_rule(std::move(r)); roads34_style.add_rule(std::move(r));
@ -149,8 +149,8 @@ int main(int, char**)
line_symbolizer line_sym; line_symbolizer line_sym;
put(line_sym, keys::stroke, color(171, 158, 137)); put(line_sym, keys::stroke, color(171, 158, 137));
put(line_sym, keys::stroke_width, 4.0); put(line_sym, keys::stroke_width, 4.0);
put(line_sym, keys::stroke_linecap, line_cap_enum::ROUND_CAP); put(line_sym, keys::stroke_linecap, ROUND_CAP);
put(line_sym, keys::stroke_linejoin, line_join_enum::ROUND_JOIN); put(line_sym, keys::stroke_linejoin, ROUND_JOIN);
r.append(std::move(line_sym)); r.append(std::move(line_sym));
} }
roads2_style_1.add_rule(std::move(r)); roads2_style_1.add_rule(std::move(r));
@ -165,8 +165,8 @@ int main(int, char**)
line_symbolizer line_sym; line_symbolizer line_sym;
put(line_sym, keys::stroke, color(255, 250, 115)); put(line_sym, keys::stroke, color(255, 250, 115));
put(line_sym, keys::stroke_width, 2.0); put(line_sym, keys::stroke_width, 2.0);
put(line_sym, keys::stroke_linecap, line_cap_enum::ROUND_CAP); put(line_sym, keys::stroke_linecap, ROUND_CAP);
put(line_sym, keys::stroke_linejoin, line_join_enum::ROUND_JOIN); put(line_sym, keys::stroke_linejoin, ROUND_JOIN);
r.append(std::move(line_sym)); r.append(std::move(line_sym));
} }
roads2_style_2.add_rule(std::move(r)); roads2_style_2.add_rule(std::move(r));
@ -182,8 +182,8 @@ int main(int, char**)
line_symbolizer line_sym; line_symbolizer line_sym;
put(line_sym, keys::stroke, color(188, 149, 28)); put(line_sym, keys::stroke, color(188, 149, 28));
put(line_sym, keys::stroke_width, 7.0); put(line_sym, keys::stroke_width, 7.0);
put(line_sym, keys::stroke_linecap, line_cap_enum::ROUND_CAP); put(line_sym, keys::stroke_linecap, ROUND_CAP);
put(line_sym, keys::stroke_linejoin, line_join_enum::ROUND_JOIN); put(line_sym, keys::stroke_linejoin, ROUND_JOIN);
r.append(std::move(line_sym)); r.append(std::move(line_sym));
} }
roads1_style_1.add_rule(std::move(r)); roads1_style_1.add_rule(std::move(r));
@ -198,8 +198,8 @@ int main(int, char**)
line_symbolizer line_sym; line_symbolizer line_sym;
put(line_sym, keys::stroke, color(242, 191, 36)); put(line_sym, keys::stroke, color(242, 191, 36));
put(line_sym, keys::stroke_width, 5.0); put(line_sym, keys::stroke_width, 5.0);
put(line_sym, keys::stroke_linecap, line_cap_enum::ROUND_CAP); put(line_sym, keys::stroke_linecap, ROUND_CAP);
put(line_sym, keys::stroke_linejoin, line_join_enum::ROUND_JOIN); put(line_sym, keys::stroke_linejoin, ROUND_JOIN);
r.append(std::move(line_sym)); r.append(std::move(line_sym));
} }
roads1_style_2.add_rule(std::move(r)); roads1_style_2.add_rule(std::move(r));
@ -371,13 +371,11 @@ int main(int, char**)
#endif #endif
// save map definition (data + style) // save map definition (data + style)
save_map(m, "map.xml"); save_map(m, "map.xml");
} } catch (std::exception const& ex)
catch (std::exception const& ex)
{ {
std::cerr << "### std::exception: " << ex.what() << std::endl; std::cerr << "### std::exception: " << ex.what() << std::endl;
return EXIT_FAILURE; return EXIT_FAILURE;
} } catch (...)
catch (...)
{ {
std::cerr << "### Unknown exception." << std::endl; std::cerr << "### Unknown exception." << std::endl;
return EXIT_FAILURE; return EXIT_FAILURE;

View file

@ -14,7 +14,7 @@ set(PROJECT_SOURCES
styles_model.cpp styles_model.cpp
forms/about.ui forms/about.ui
forms/info.ui forms/info.ui
forms/layer_info.ui forms/layer_info.ui
mapnik_viewer.qrc mapnik_viewer.qrc
) )
@ -37,23 +37,24 @@ endif()
set_target_properties(mapnik-viewer PROPERTIES set_target_properties(mapnik-viewer PROPERTIES
AUTOUIC_SEARCH_PATHS forms AUTOUIC_SEARCH_PATHS forms
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
"[mapnik] "[mapnik]
plugins_dir=${PLUGINS_INSTALL_DIR} plugins_dir=${PLUGINS_INSTALL_DIR}
fonts/1/dir=${FONTS_INSTALL_DIR} fonts/1/dir=${FONTS_INSTALL_DIR}"
fonts/size=1"
) )
if(QT_VERSION_MAJOR EQUAL 6) if(QT_VERSION_MAJOR EQUAL 6)

View file

@ -1,6 +1,6 @@
/* This file is part of Mapnik (c++ mapping toolkit) /* This file is part of Mapnik (c++ mapping toolkit)
* *
* Copyright (C) 2024 Artem Pavlenko * Copyright (C) 2021 Artem Pavlenko
* *
* Mapnik is free software; you can redistribute it and/or * Mapnik is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License

View file

@ -1,6 +1,6 @@
/* This file is part of Mapnik (c++ mapping toolkit) /* This file is part of Mapnik (c++ mapping toolkit)
* *
* Copyright (C) 2024 Artem Pavlenko * Copyright (C) 2021 Artem Pavlenko
* *
* Mapnik is free software; you can redistribute it and/or * Mapnik is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License

View file

@ -1,6 +1,6 @@
/* This file is part of Mapnik (c++ mapping toolkit) /* This file is part of Mapnik (c++ mapping toolkit)
* *
* Copyright (C) 2024 Artem Pavlenko * Copyright (C) 2021 Artem Pavlenko
* *
* Mapnik is free software; you can redistribute it and/or * Mapnik is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License

View file

@ -1,6 +1,6 @@
/* This file is part of Mapnik (c++ mapping toolkit) /* This file is part of Mapnik (c++ mapping toolkit)
* *
* Copyright (C) 2024 Artem Pavlenko * Copyright (C) 2021 Artem Pavlenko
* *
* Mapnik is free software; you can redistribute it and/or * Mapnik is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License

View file

@ -1,6 +1,6 @@
/* This file is part of Mapnik (c++ mapping toolkit) /* This file is part of Mapnik (c++ mapping toolkit)
* *
* Copyright (C) 2024 Artem Pavlenko * Copyright (C) 2021 Artem Pavlenko
* *
* Mapnik is free software; you can redistribute it and/or * Mapnik is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -51,7 +51,7 @@ layer_info_dialog::layer_info_dialog(mapnik::layer& lay, QWidget* parent)
int index = 0; int index = 0;
for (pos = ps.begin(); pos != ps.end(); ++pos) for (pos = ps.begin(); pos != ps.end(); ++pos)
{ {
std::optional<std::string> result; boost::optional<std::string> result;
mapnik::util::apply_visitor(mapnik::value_extractor_visitor<std::string>(result), pos->second); mapnik::util::apply_visitor(mapnik::value_extractor_visitor<std::string>(result), pos->second);
if (result) if (result)
{ {

View file

@ -1,6 +1,6 @@
/* This file is part of Mapnik (c++ mapping toolkit) /* This file is part of Mapnik (c++ mapping toolkit)
* *
* Copyright (C) 2024 Artem Pavlenko * Copyright (C) 2021 Artem Pavlenko
* *
* Mapnik is free software; you can redistribute it and/or * Mapnik is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License

View file

@ -1,6 +1,6 @@
/* This file is part of Mapnik (c++ mapping toolkit) /* This file is part of Mapnik (c++ mapping toolkit)
* *
* Copyright (C) 2024 Artem Pavlenko * Copyright (C) 2021 Artem Pavlenko
* *
* Mapnik is free software; you can redistribute it and/or * Mapnik is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License

View file

@ -1,6 +1,6 @@
/* This file is part of Mapnik (c++ mapping toolkit) /* This file is part of Mapnik (c++ mapping toolkit)
* *
* Copyright (C) 2024 Artem Pavlenko * Copyright (C) 2021 Artem Pavlenko
* *
* Mapnik is free software; you can redistribute it and/or * Mapnik is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License

View file

@ -1,6 +1,6 @@
/* This file is part of Mapnik (c++ mapping toolkit) /* This file is part of Mapnik (c++ mapping toolkit)
* *
* Copyright (C) 2024 Artem Pavlenko * Copyright (C) 2021 Artem Pavlenko
* *
* Mapnik is free software; you can redistribute it and/or * Mapnik is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License

View file

@ -1,6 +1,6 @@
/* This file is part of Mapnik (c++ mapping toolkit) /* This file is part of Mapnik (c++ mapping toolkit)
* *
* Copyright (C) 2024 Artem Pavlenko * Copyright (C) 2021 Artem Pavlenko
* *
* Mapnik is free software; you can redistribute it and/or * Mapnik is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License

View file

@ -1,6 +1,6 @@
/* This file is part of Mapnik (c++ mapping toolkit) /* This file is part of Mapnik (c++ mapping toolkit)
* *
* Copyright (C) 2024 Artem Pavlenko * Copyright (C) 2021 Artem Pavlenko
* *
* Mapnik is free software; you can redistribute it and/or * Mapnik is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License

View file

@ -1,6 +1,6 @@
/* This file is part of Mapnik (c++ mapping toolkit) /* This file is part of Mapnik (c++ mapping toolkit)
* *
* Copyright (C) 2024 Artem Pavlenko * Copyright (C) 2021 Artem Pavlenko
* *
* Mapnik is free software; you can redistribute it and/or * Mapnik is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License

View file

@ -1,6 +1,6 @@
/* This file is part of Mapnik (c++ mapping toolkit) /* This file is part of Mapnik (c++ mapping toolkit)
* *
* Copyright (C) 2024 Artem Pavlenko * Copyright (C) 2021 Artem Pavlenko
* *
* Mapnik is free software; you can redistribute it and/or * Mapnik is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -87,8 +87,7 @@ int main(int argc, char** argv)
window.set_scaling_factor(scaling_factor); window.set_scaling_factor(scaling_factor);
} }
return app.exec(); return app.exec();
} } catch (std::exception const& ex)
catch (std::exception const& ex)
{ {
std::cerr << "Could not start viewer: '" << ex.what() << "'\n"; std::cerr << "Could not start viewer: '" << ex.what() << "'\n";
return 1; return 1;

View file

@ -1,6 +1,6 @@
/* This file is part of Mapnik (c++ mapping toolkit) /* This file is part of Mapnik (c++ mapping toolkit)
* *
* Copyright (C) 2024 Artem Pavlenko * Copyright (C) 2021 Artem Pavlenko
* *
* Mapnik is free software; you can redistribute it and/or * Mapnik is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -38,7 +38,7 @@
// mapnik // mapnik
#ifndef Q_MOC_RUN // QT moc chokes on BOOST_JOIN #ifndef Q_MOC_RUN // QT moc chokes on BOOST_JOIN
// #include <mapnik/config_error.hpp> //#include <mapnik/config_error.hpp>
#include <mapnik/load_map.hpp> #include <mapnik/load_map.hpp>
#include <mapnik/save_map.hpp> #include <mapnik/save_map.hpp>
#include <mapnik/projection.hpp> #include <mapnik/projection.hpp>
@ -106,7 +106,10 @@ MainWindow::MainWindow()
// slider // slider
connect(slider_, SIGNAL(valueChanged(int)), mapWidget_, SLOT(zoomToLevel(int))); connect(slider_, SIGNAL(valueChanged(int)), mapWidget_, SLOT(zoomToLevel(int)));
// renderer selector // renderer selector
connect(renderer_selector_, SIGNAL(currentIndexChanged(int)), mapWidget_, SLOT(updateRenderer(int))); connect(renderer_selector_,
SIGNAL(currentIndexChanged(QString const&)),
mapWidget_,
SLOT(updateRenderer(QString const&)));
// scale factor // scale factor
connect(scale_factor_, SIGNAL(valueChanged(double)), mapWidget_, SLOT(updateScaleFactor(double))); connect(scale_factor_, SIGNAL(valueChanged(double)), mapWidget_, SLOT(updateScaleFactor(double)));
@ -186,12 +189,10 @@ void MainWindow::load_map_file(QString const& filename)
{ {
mapnik::auto_cpu_timer t(std::clog, "loading map took: "); mapnik::auto_cpu_timer t(std::clog, "loading map took: ");
mapnik::load_map(*map, filename.toStdString()); mapnik::load_map(*map, filename.toStdString());
} } catch (std::exception const& ex)
catch (std::exception const& ex)
{ {
std::cout << ex.what() << "\n"; std::cout << ex.what() << "\n";
} } catch (...)
catch (...)
{ {
std::cerr << "Exception caught in load_map\n"; std::cerr << "Exception caught in load_map\n";
} }
@ -387,7 +388,7 @@ void MainWindow::createToolBars()
scale_factor_ = new QDoubleSpinBox(fileToolBar); scale_factor_ = new QDoubleSpinBox(fileToolBar);
scale_factor_->setMinimum(0.1); scale_factor_->setMinimum(0.1);
scale_factor_->setMaximum(10.0); scale_factor_->setMaximum(5.0);
scale_factor_->setSingleStep(0.1); scale_factor_->setSingleStep(0.1);
scale_factor_->setValue(1.0); scale_factor_->setValue(1.0);
@ -415,8 +416,7 @@ void MainWindow::set_default_extent(double x0, double y0, double x1, double y1)
mapWidget_->zoomToBox(default_extent_); mapWidget_->zoomToBox(default_extent_);
std::cout << "SET DEFAULT EXT:" << default_extent_ << std::endl; std::cout << "SET DEFAULT EXT:" << default_extent_ << std::endl;
} }
} } catch (...)
catch (...)
{} {}
} }

View file

@ -1,6 +1,6 @@
/* This file is part of Mapnik (c++ mapping toolkit) /* This file is part of Mapnik (c++ mapping toolkit)
* *
* Copyright (C) 2024 Artem Pavlenko * Copyright (C) 2021 Artem Pavlenko
* *
* Mapnik is free software; you can redistribute it and/or * Mapnik is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License

View file

@ -1,6 +1,6 @@
/* This file is part of Mapnik (c++ mapping toolkit) /* This file is part of Mapnik (c++ mapping toolkit)
* *
* Copyright (C) 2024 Artem Pavlenko * Copyright (C) 2021 Artem Pavlenko
* *
* Mapnik is free software; you can redistribute it and/or * Mapnik is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -513,8 +513,7 @@ void render_agg(mapnik::Map const& map, double scaling_factor, QPixmap& pix)
catch (std::exception const& ex) catch (std::exception const& ex)
{ {
std::cerr << "exception: " << ex.what() << std::endl; std::cerr << "exception: " << ex.what() << std::endl;
} } catch (...)
catch (...)
{ {
std::cerr << "Unknown exception caught!\n"; std::cerr << "Unknown exception caught!\n";
} }
@ -545,15 +544,15 @@ void render_cairo(mapnik::Map const& map, double scaling_factor, QPixmap& pix)
#endif #endif
} }
void MapWidget::updateRenderer(int index) void MapWidget::updateRenderer(QString const& txt)
{ {
std::cerr << "updateRenderer:" << index << std::endl; if (txt == "AGG")
if (index == 0)
cur_renderer_ = AGG; cur_renderer_ = AGG;
else if (index == 1) else if (txt == "Cairo")
cur_renderer_ = Cairo; cur_renderer_ = Cairo;
else if (index == 2) else if (txt == "Grid")
cur_renderer_ = Grid; cur_renderer_ = Grid;
std::cerr << "Update renderer called" << std::endl;
updateMap(); updateMap();
} }
@ -603,8 +602,7 @@ void MapWidget::updateMap()
update(); update();
// emit signal to interested widgets // emit signal to interested widgets
emit mapViewChanged(); emit mapViewChanged();
} } catch (...)
catch (...)
{ {
std::cerr << "Unknown exception caught!\n"; std::cerr << "Unknown exception caught!\n";
} }

View file

@ -1,6 +1,6 @@
/* This file is part of Mapnik (c++ mapping toolkit) /* This file is part of Mapnik (c++ mapping toolkit)
* *
* Copyright (C) 2024 Artem Pavlenko * Copyright (C) 2021 Artem Pavlenko
* *
* Mapnik is free software; you can redistribute it and/or * Mapnik is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -82,7 +82,7 @@ class MapWidget : public QWidget
void zoomToLevel(int level); void zoomToLevel(int level);
void updateMap(); void updateMap();
void layerSelected(int); void layerSelected(int);
void updateRenderer(int); void updateRenderer(QString const& txt);
void updateScaleFactor(double scale_factor); void updateScaleFactor(double scale_factor);
signals: signals:
void mapViewChanged(); void mapViewChanged();

View file

@ -1,6 +1,6 @@
/* This file is part of Mapnik (c++ mapping toolkit) /* This file is part of Mapnik (c++ mapping toolkit)
* *
* Copyright (C) 2024 Artem Pavlenko * Copyright (C) 2021 Artem Pavlenko
* *
* Mapnik is free software; you can redistribute it and/or * Mapnik is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License

View file

@ -1,6 +1,6 @@
/* This file is part of Mapnik (c++ mapping toolkit) /* This file is part of Mapnik (c++ mapping toolkit)
* *
* Copyright (C) 2024 Artem Pavlenko * Copyright (C) 2021 Artem Pavlenko
* *
* Mapnik is free software; you can redistribute it and/or * Mapnik is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License

View file

@ -1 +0,0 @@
DisableFormat: true

View file

@ -3,8 +3,8 @@ project(agg)
add_library(agg INTERFACE) add_library(agg INTERFACE)
add_library(mapnik::agg ALIAS agg) add_library(mapnik::agg ALIAS agg)
target_include_directories(agg INTERFACE target_include_directories(agg INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include> $<INSTALL_INTERFACE:include>
) )
target_link_libraries(agg INTERFACE mapnik::core) target_link_libraries(agg INTERFACE mapnik::core)

View file

@ -365,7 +365,7 @@ namespace agg
inline bool is_close(unsigned c) inline bool is_close(unsigned c)
{ {
return (c & ~(path_flags_cw | path_flags_ccw)) == return (c & ~(path_flags_cw | path_flags_ccw)) ==
(path_cmd_end_poly | static_cast<path_commands_e>(path_flags_close)); (path_cmd_end_poly | path_flags_close);
} }
//------------------------------------------------------------is_next_poly //------------------------------------------------------------is_next_poly

View file

@ -436,8 +436,7 @@ struct gray16
static value_type luminance(const rgba& c) static value_type luminance(const rgba& c)
{ {
// Calculate grayscale value as per ITU-R BT.709. // Calculate grayscale value as per ITU-R BT.709.
return value_type(uround((0.2126 * c.r + 0.7152 * c.g + 0.0722 * c.b) return value_type(uround((0.2126 * c.r + 0.7152 * c.g + 0.0722 * c.b) * base_mask));
* static_cast<double>(base_mask)));
} }
static value_type luminance(const rgba16& c) static value_type luminance(const rgba16& c)
@ -538,13 +537,13 @@ struct gray16
//-------------------------------------------------------------------- //--------------------------------------------------------------------
static AGG_INLINE double to_double(value_type a) static AGG_INLINE double to_double(value_type a)
{ {
return static_cast<double>(a) / static_cast<double>(base_mask); return double(a) / base_mask;
} }
//-------------------------------------------------------------------- //--------------------------------------------------------------------
static AGG_INLINE value_type from_double(double a) static AGG_INLINE value_type from_double(double a)
{ {
return value_type(uround(a * static_cast<double>(base_mask))); return value_type(uround(a * base_mask));
} }
//-------------------------------------------------------------------- //--------------------------------------------------------------------
@ -699,7 +698,7 @@ struct gray16
self_type gradient(self_type c, double k) const self_type gradient(self_type c, double k) const
{ {
self_type ret; self_type ret;
calc_type ik = uround(k * static_cast<double>(base_scale)); calc_type ik = uround(k * base_scale);
ret.v = lerp(v, c.v, ik); ret.v = lerp(v, c.v, ik);
ret.a = lerp(a, c.a, ik); ret.a = lerp(a, c.a, ik);
return ret; return ret;
@ -950,7 +949,7 @@ struct gray32
//-------------------------------------------------------------------- //--------------------------------------------------------------------
static AGG_INLINE value_type mult_cover(value_type a, cover_type b) static AGG_INLINE value_type mult_cover(value_type a, cover_type b)
{ {
return value_type(a * b / static_cast<double>(cover_mask)); return value_type(a * b / cover_mask);
} }
//-------------------------------------------------------------------- //--------------------------------------------------------------------

View file

@ -281,10 +281,10 @@ struct rgba8T
static void convert(rgba8T<linear>& dst, const rgba& src) static void convert(rgba8T<linear>& dst, const rgba& src)
{ {
dst.r = value_type(uround(src.r * static_cast<double>(base_mask))); dst.r = value_type(uround(src.r * base_mask));
dst.g = value_type(uround(src.g * static_cast<double>(base_mask))); dst.g = value_type(uround(src.g * base_mask));
dst.b = value_type(uround(src.b * static_cast<double>(base_mask))); dst.b = value_type(uround(src.b * base_mask));
dst.a = value_type(uround(src.a * static_cast<double>(base_mask))); dst.a = value_type(uround(src.a * base_mask));
} }
static void convert(rgba8T<sRGB>& dst, const rgba& src) static void convert(rgba8T<sRGB>& dst, const rgba& src)
@ -761,13 +761,13 @@ struct rgba16
//-------------------------------------------------------------------- //--------------------------------------------------------------------
static AGG_INLINE double to_double(value_type a) static AGG_INLINE double to_double(value_type a)
{ {
return static_cast<double>(a) / static_cast<double>(base_mask); return double(a) / base_mask;
} }
//-------------------------------------------------------------------- //--------------------------------------------------------------------
static AGG_INLINE value_type from_double(double a) static AGG_INLINE value_type from_double(double a)
{ {
return value_type(uround(a * static_cast<double>(base_mask))); return value_type(uround(a * base_mask));
} }
//-------------------------------------------------------------------- //--------------------------------------------------------------------
@ -955,7 +955,7 @@ struct rgba16
AGG_INLINE self_type gradient(const self_type& c, double k) const AGG_INLINE self_type gradient(const self_type& c, double k) const
{ {
self_type ret; self_type ret;
calc_type ik = uround(k * static_cast<double>(base_mask)); calc_type ik = uround(k * base_mask);
ret.r = lerp(r, c.r, ik); ret.r = lerp(r, c.r, ik);
ret.g = lerp(g, c.g, ik); ret.g = lerp(g, c.g, ik);
ret.b = lerp(b, c.b, ik); ret.b = lerp(b, c.b, ik);
@ -1194,7 +1194,7 @@ struct rgba32
//-------------------------------------------------------------------- //--------------------------------------------------------------------
static AGG_INLINE value_type mult_cover(value_type a, cover_type b) static AGG_INLINE value_type mult_cover(value_type a, cover_type b)
{ {
return value_type(a * b / static_cast<float>(cover_mask)); return value_type(a * b / cover_mask);
} }
//-------------------------------------------------------------------- //--------------------------------------------------------------------

View file

@ -2,8 +2,8 @@
// Anti-Grain Geometry - Version 2.4 // Anti-Grain Geometry - Version 2.4
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
// //
// Permission to copy, use, modify, sell and distribute this software // Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies. // is granted provided this copyright notice appears in all copies.
// This software is provided "as is" without express or implied // This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose. // warranty, and with no claim as to its suitability for any purpose.
// //
@ -37,7 +37,7 @@ namespace agg
private: private:
conv_adaptor_vpgen(const conv_adaptor_vpgen<VertexSource, VPGen>&); conv_adaptor_vpgen(const conv_adaptor_vpgen<VertexSource, VPGen>&);
const conv_adaptor_vpgen<VertexSource, VPGen>& const conv_adaptor_vpgen<VertexSource, VPGen>&
operator = (const conv_adaptor_vpgen<VertexSource, VPGen>&); operator = (const conv_adaptor_vpgen<VertexSource, VPGen>&);
VertexSource* m_source; VertexSource* m_source;
@ -52,8 +52,8 @@ namespace agg
//------------------------------------------------------------------------ //------------------------------------------------------------------------
template<class VertexSource, class VPGen> template<class VertexSource, class VPGen>
void conv_adaptor_vpgen<VertexSource, VPGen>::rewind(unsigned path_id) void conv_adaptor_vpgen<VertexSource, VPGen>::rewind(unsigned path_id)
{ {
m_source->rewind(path_id); m_source->rewind(path_id);
m_vpgen.reset(); m_vpgen.reset();
m_start_x = 0; m_start_x = 0;
@ -84,7 +84,7 @@ namespace agg
if(m_vertices < 0) if(m_vertices < 0)
{ {
if(m_vertices < -1) if(m_vertices < -1)
{ {
m_vertices = 0; m_vertices = 0;
return path_cmd_stop; return path_cmd_stop;
@ -98,13 +98,12 @@ namespace agg
cmd = m_source->vertex(&tx, &ty); cmd = m_source->vertex(&tx, &ty);
if(is_vertex(cmd)) if(is_vertex(cmd))
{ {
if(is_move_to(cmd)) if(is_move_to(cmd))
{ {
if(m_vpgen.auto_close() && m_vertices > 2) if(m_vpgen.auto_close() && m_vertices > 2)
{ {
m_vpgen.line_to(m_start_x, m_start_y); m_vpgen.line_to(m_start_x, m_start_y);
m_poly_flags = path_cmd_end_poly m_poly_flags = path_cmd_end_poly | path_flags_close;
| static_cast<path_commands_e>(path_flags_close);
m_start_x = tx; m_start_x = tx;
m_start_y = ty; m_start_y = ty;
m_vertices = -1; m_vertices = -1;
@ -115,7 +114,7 @@ namespace agg
m_start_y = ty; m_start_y = ty;
m_vertices = 1; m_vertices = 1;
} }
else else
{ {
m_vpgen.line_to(tx, ty); m_vpgen.line_to(tx, ty);
++m_vertices; ++m_vertices;
@ -142,8 +141,7 @@ namespace agg
if(m_vpgen.auto_close() && m_vertices > 2) if(m_vpgen.auto_close() && m_vertices > 2)
{ {
m_vpgen.line_to(m_start_x, m_start_y); m_vpgen.line_to(m_start_x, m_start_y);
m_poly_flags = path_cmd_end_poly m_poly_flags = path_cmd_end_poly | path_flags_close;
| static_cast<path_commands_e>(path_flags_close);
m_vertices = -2; m_vertices = -2;
continue; continue;
} }
@ -159,3 +157,4 @@ namespace agg
#endif #endif

View file

@ -2,8 +2,8 @@
// Anti-Grain Geometry - Version 2.4 // Anti-Grain Geometry - Version 2.4
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
// //
// Permission to copy, use, modify, sell and distribute this software // Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies. // is granted provided this copyright notice appears in all copies.
// This software is provided "as is" without express or implied // This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose. // warranty, and with no claim as to its suitability for any purpose.
// //
@ -22,25 +22,24 @@
#include "agg_array.h" #include "agg_array.h"
#include "agg_math.h" #include "agg_math.h"
#include <cstdint>
namespace agg namespace agg
{ {
// See Implementation agg_image_filters.cpp // See Implementation agg_image_filters.cpp
enum image_filter_scale_e enum image_filter_scale_e
{ {
image_filter_shift = 14, //----image_filter_shift image_filter_shift = 14, //----image_filter_shift
image_filter_scale = 1 << image_filter_shift, //----image_filter_scale image_filter_scale = 1 << image_filter_shift, //----image_filter_scale
image_filter_mask = image_filter_scale - 1 //----image_filter_mask image_filter_mask = image_filter_scale - 1 //----image_filter_mask
}; };
enum image_subpixel_scale_e enum image_subpixel_scale_e
{ {
image_subpixel_shift = 8, //----image_subpixel_shift image_subpixel_shift = 8, //----image_subpixel_shift
image_subpixel_scale = 1 << image_subpixel_shift, //----image_subpixel_scale image_subpixel_scale = 1 << image_subpixel_shift, //----image_subpixel_scale
image_subpixel_mask = image_subpixel_scale - 1 //----image_subpixel_mask image_subpixel_mask = image_subpixel_scale - 1 //----image_subpixel_mask
}; };
@ -59,13 +58,12 @@ namespace agg
{ {
double x = double(i) / double(image_subpixel_scale); double x = double(i) / double(image_subpixel_scale);
double y = filter.calc_weight(x); double y = filter.calc_weight(x);
m_weight_array[pivot + i] = m_weight_array[pivot + i] =
m_weight_array[pivot - i] = m_weight_array[pivot - i] = (int16)iround(y * image_filter_scale);
static_cast<std::int16_t>(iround(y * static_cast<double>(image_filter_scale)));
} }
unsigned end = (diameter() << image_subpixel_shift) - 1; unsigned end = (diameter() << image_subpixel_shift) - 1;
m_weight_array[0] = m_weight_array[end]; m_weight_array[0] = m_weight_array[end];
if(normalization) if(normalization)
{ {
normalize(); normalize();
} }
@ -73,7 +71,7 @@ namespace agg
image_filter_lut() : m_radius(0), m_diameter(0), m_start(0) {} image_filter_lut() : m_radius(0), m_diameter(0), m_start(0) {}
template<class FilterF> image_filter_lut(const FilterF& filter, template<class FilterF> image_filter_lut(const FilterF& filter,
bool normalization=true) bool normalization=true)
{ {
calculate(filter, normalization); calculate(filter, normalization);
@ -82,7 +80,7 @@ namespace agg
double radius() const { return m_radius; } double radius() const { return m_radius; }
unsigned diameter() const { return m_diameter; } unsigned diameter() const { return m_diameter; }
int start() const { return m_start; } int start() const { return m_start; }
std::int16_t const* weight_array() const { return &m_weight_array[0]; } const int16* weight_array() const { return &m_weight_array[0]; }
void normalize(); void normalize();
private: private:
@ -93,7 +91,7 @@ namespace agg
double m_radius; double m_radius;
unsigned m_diameter; unsigned m_diameter;
int m_start; int m_start;
pod_array<std::int16_t> m_weight_array; pod_array<int16> m_weight_array;
}; };
@ -152,7 +150,7 @@ namespace agg
return (2.0 * x - 3.0) * x * x + 1.0; return (2.0 * x - 3.0) * x * x + 1.0;
} }
}; };
//------------------------------------------------image_filter_quadric //------------------------------------------------image_filter_quadric
struct image_filter_quadric struct image_filter_quadric
{ {
@ -179,7 +177,7 @@ namespace agg
static double calc_weight(double x) static double calc_weight(double x)
{ {
return return
(1.0/6.0) * (1.0/6.0) *
(pow3(x + 2) - 4 * pow3(x + 1) + 6 * pow3(x) - 4 * pow3(x - 1)); (pow3(x + 2) - 4 * pow3(x + 1) + 6 * pow3(x) - 4 * pow3(x - 1));
} }
}; };
@ -213,7 +211,7 @@ namespace agg
sum = 1.; sum = 1.;
y = x * x / 4.; y = x * x / 4.;
t = y; t = y;
for(i = 2; t > epsilon; i++) for(i = 2; t > epsilon; i++)
{ {
sum += t; sum += t;
@ -300,7 +298,7 @@ namespace agg
struct image_filter_gaussian struct image_filter_gaussian
{ {
static double radius() { return 2.0; } static double radius() { return 2.0; }
static double calc_weight(double x) static double calc_weight(double x)
{ {
return exp(-2.0 * x * x) * sqrt(2.0 / pi); return exp(-2.0 * x * x) * sqrt(2.0 / pi);
} }
@ -310,7 +308,7 @@ namespace agg
//------------------------------------------------image_filter_bessel //------------------------------------------------image_filter_bessel
struct image_filter_bessel struct image_filter_bessel
{ {
static double radius() { return 3.2383; } static double radius() { return 3.2383; }
static double calc_weight(double x) static double calc_weight(double x)
{ {
return (x == 0.0) ? pi / 4.0 : besj(pi * x, 1) / (2.0 * x); return (x == 0.0) ? pi / 4.0 : besj(pi * x, 1) / (2.0 * x);

View file

@ -44,13 +44,13 @@ namespace agg
//------------------------------------------------------------------line_mr //------------------------------------------------------------------line_mr
AGG_INLINE int line_mr(int x) AGG_INLINE int line_mr(int x)
{ {
return x >> (line_subpixel_shift - static_cast<line_subpixel_scale_e>(line_mr_subpixel_shift)); return x >> (line_subpixel_shift - line_mr_subpixel_shift);
} }
//-------------------------------------------------------------------line_hr //-------------------------------------------------------------------line_hr
AGG_INLINE int line_hr(int x) AGG_INLINE int line_hr(int x)
{ {
return x << (line_subpixel_shift - static_cast<line_subpixel_scale_e>(line_mr_subpixel_shift)); return x << (line_subpixel_shift - line_mr_subpixel_shift);
} }
//---------------------------------------------------------------line_dbl_hr //---------------------------------------------------------------line_dbl_hr
@ -64,7 +64,7 @@ namespace agg
{ {
AGG_INLINE static int conv(double x) AGG_INLINE static int conv(double x)
{ {
return iround(x * static_cast<double>(line_subpixel_scale)); return iround(x * line_subpixel_scale);
} }
}; };
@ -73,7 +73,7 @@ namespace agg
{ {
AGG_INLINE static int conv(double x) AGG_INLINE static int conv(double x)
{ {
return saturation<line_max_coord>::iround(x * static_cast<double>(line_subpixel_scale)); return saturation<line_max_coord>::iround(x * line_subpixel_scale);
} }
}; };

View file

@ -2,8 +2,8 @@
// Anti-Grain Geometry - Version 2.4 // Anti-Grain Geometry - Version 2.4
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
// //
// Permission to copy, use, modify, sell and distribute this software // Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies. // is granted provided this copyright notice appears in all copies.
// This software is provided "as is" without express or implied // This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose. // warranty, and with no claim as to its suitability for any purpose.
// //
@ -92,7 +92,7 @@ namespace agg
{ {
pod_allocator<T>::deallocate( pod_allocator<T>::deallocate(
*coord_blk, *coord_blk,
block_size * 2 + block_size * 2 +
block_size / (sizeof(T) / sizeof(unsigned char))); block_size / (sizeof(T) / sizeof(unsigned char)));
--coord_blk; --coord_blk;
} }
@ -137,7 +137,7 @@ namespace agg
//------------------------------------------------------------------------ //------------------------------------------------------------------------
template<class T, unsigned S, unsigned P> template<class T, unsigned S, unsigned P>
const vertex_block_storage<T,S,P>& const vertex_block_storage<T,S,P>&
vertex_block_storage<T,S,P>::operator = (const vertex_block_storage<T,S,P>& v) vertex_block_storage<T,S,P>::operator = (const vertex_block_storage<T,S,P>& v)
{ {
remove_all(); remove_all();
@ -160,7 +160,7 @@ namespace agg
//------------------------------------------------------------------------ //------------------------------------------------------------------------
template<class T, unsigned S, unsigned P> template<class T, unsigned S, unsigned P>
inline void vertex_block_storage<T,S,P>::add_vertex(double x, double y, inline void vertex_block_storage<T,S,P>::add_vertex(double x, double y,
unsigned cmd) unsigned cmd)
{ {
T* coord_ptr = 0; T* coord_ptr = 0;
@ -172,7 +172,7 @@ namespace agg
//------------------------------------------------------------------------ //------------------------------------------------------------------------
template<class T, unsigned S, unsigned P> template<class T, unsigned S, unsigned P>
inline void vertex_block_storage<T,S,P>::modify_vertex(unsigned idx, inline void vertex_block_storage<T,S,P>::modify_vertex(unsigned idx,
double x, double y) double x, double y)
{ {
T* pv = m_coord_blocks[idx >> block_shift] + ((idx & block_mask) << 1); T* pv = m_coord_blocks[idx >> block_shift] + ((idx & block_mask) << 1);
@ -182,8 +182,8 @@ namespace agg
//------------------------------------------------------------------------ //------------------------------------------------------------------------
template<class T, unsigned S, unsigned P> template<class T, unsigned S, unsigned P>
inline void vertex_block_storage<T,S,P>::modify_vertex(unsigned idx, inline void vertex_block_storage<T,S,P>::modify_vertex(unsigned idx,
double x, double y, double x, double y,
unsigned cmd) unsigned cmd)
{ {
unsigned block = idx >> block_shift; unsigned block = idx >> block_shift;
@ -196,7 +196,7 @@ namespace agg
//------------------------------------------------------------------------ //------------------------------------------------------------------------
template<class T, unsigned S, unsigned P> template<class T, unsigned S, unsigned P>
inline void vertex_block_storage<T,S,P>::modify_command(unsigned idx, inline void vertex_block_storage<T,S,P>::modify_command(unsigned idx,
unsigned cmd) unsigned cmd)
{ {
m_cmd_blocks[idx >> block_shift][idx & block_mask] = (int8u)cmd; m_cmd_blocks[idx >> block_shift][idx & block_mask] = (int8u)cmd;
@ -277,7 +277,7 @@ namespace agg
//------------------------------------------------------------------------ //------------------------------------------------------------------------
template<class T, unsigned S, unsigned P> template<class T, unsigned S, unsigned P>
inline unsigned vertex_block_storage<T,S,P>::vertex(unsigned idx, inline unsigned vertex_block_storage<T,S,P>::vertex(unsigned idx,
double* x, double* y) const double* x, double* y) const
{ {
unsigned nb = idx >> block_shift; unsigned nb = idx >> block_shift;
@ -298,22 +298,22 @@ namespace agg
template<class T, unsigned S, unsigned P> template<class T, unsigned S, unsigned P>
void vertex_block_storage<T,S,P>::allocate_block(unsigned nb) void vertex_block_storage<T,S,P>::allocate_block(unsigned nb)
{ {
if(nb >= m_max_blocks) if(nb >= m_max_blocks)
{ {
T** new_coords = T** new_coords =
pod_allocator<T*>::allocate((m_max_blocks + block_pool) * 2); pod_allocator<T*>::allocate((m_max_blocks + block_pool) * 2);
unsigned char** new_cmds = unsigned char** new_cmds =
(unsigned char**)(new_coords + m_max_blocks + block_pool); (unsigned char**)(new_coords + m_max_blocks + block_pool);
if(m_coord_blocks) if(m_coord_blocks)
{ {
memcpy(new_coords, memcpy(new_coords,
m_coord_blocks, m_coord_blocks,
m_max_blocks * sizeof(T*)); m_max_blocks * sizeof(T*));
memcpy(new_cmds, memcpy(new_cmds,
m_cmd_blocks, m_cmd_blocks,
m_max_blocks * sizeof(unsigned char*)); m_max_blocks * sizeof(unsigned char*));
pod_allocator<T*>::deallocate(m_coord_blocks, m_max_blocks * 2); pod_allocator<T*>::deallocate(m_coord_blocks, m_max_blocks * 2);
@ -322,11 +322,11 @@ namespace agg
m_cmd_blocks = new_cmds; m_cmd_blocks = new_cmds;
m_max_blocks += block_pool; m_max_blocks += block_pool;
} }
m_coord_blocks[nb] = m_coord_blocks[nb] =
pod_allocator<T>::allocate(block_size * 2 + pod_allocator<T>::allocate(block_size * 2 +
block_size / (sizeof(T) / sizeof(unsigned char))); block_size / (sizeof(T) / sizeof(unsigned char)));
m_cmd_blocks[nb] = m_cmd_blocks[nb] =
(unsigned char*)(m_coord_blocks[nb] + block_size * 2); (unsigned char*)(m_coord_blocks[nb] + block_size * 2);
m_total_blocks++; m_total_blocks++;
@ -354,8 +354,8 @@ namespace agg
public: public:
typedef T value_type; typedef T value_type;
poly_plain_adaptor() : poly_plain_adaptor() :
m_data(0), m_data(0),
m_ptr(0), m_ptr(0),
m_end(0), m_end(0),
m_closed(false), m_closed(false),
@ -363,7 +363,7 @@ namespace agg
{} {}
poly_plain_adaptor(const T* data, unsigned num_points, bool closed) : poly_plain_adaptor(const T* data, unsigned num_points, bool closed) :
m_data(data), m_data(data),
m_ptr(data), m_ptr(data),
m_end(data + num_points * 2), m_end(data + num_points * 2),
m_closed(closed), m_closed(closed),
@ -398,8 +398,7 @@ namespace agg
if(m_closed && !m_stop) if(m_closed && !m_stop)
{ {
m_stop = true; m_stop = true;
return path_cmd_end_poly return path_cmd_end_poly | path_flags_close;
| static_cast<agg::path_commands_e>(path_flags_close);
} }
return path_cmd_stop; return path_cmd_stop;
} }
@ -422,15 +421,15 @@ namespace agg
public: public:
typedef typename Container::value_type vertex_type; typedef typename Container::value_type vertex_type;
poly_container_adaptor() : poly_container_adaptor() :
m_container(0), m_container(0),
m_index(0), m_index(0),
m_closed(false), m_closed(false),
m_stop(false) m_stop(false)
{} {}
poly_container_adaptor(const Container& data, bool closed) : poly_container_adaptor(const Container& data, bool closed) :
m_container(&data), m_container(&data),
m_index(0), m_index(0),
m_closed(closed), m_closed(closed),
m_stop(false) m_stop(false)
@ -464,8 +463,7 @@ namespace agg
if(m_closed && !m_stop) if(m_closed && !m_stop)
{ {
m_stop = true; m_stop = true;
return path_cmd_end_poly return path_cmd_end_poly | path_flags_close;
| static_cast<agg::path_commands_e>(path_flags_close);
} }
return path_cmd_stop; return path_cmd_stop;
} }
@ -485,15 +483,15 @@ namespace agg
public: public:
typedef typename Container::value_type vertex_type; typedef typename Container::value_type vertex_type;
poly_container_reverse_adaptor() : poly_container_reverse_adaptor() :
m_container(0), m_container(0),
m_index(-1), m_index(-1),
m_closed(false), m_closed(false),
m_stop(false) m_stop(false)
{} {}
poly_container_reverse_adaptor(const Container& data, bool closed) : poly_container_reverse_adaptor(const Container& data, bool closed) :
m_container(&data), m_container(&data),
m_index(-1), m_index(-1),
m_closed(closed), m_closed(closed),
m_stop(false) m_stop(false)
@ -527,8 +525,7 @@ namespace agg
if(m_closed && !m_stop) if(m_closed && !m_stop)
{ {
m_stop = true; m_stop = true;
return path_cmd_end_poly return path_cmd_end_poly | path_flags_close;
| static_cast<agg::path_commands_e>(path_flags_close);
} }
return path_cmd_stop; return path_cmd_stop;
} }
@ -559,7 +556,7 @@ namespace agg
m_coord[2] = x2; m_coord[2] = x2;
m_coord[3] = y2; m_coord[3] = y2;
} }
void init(double x1, double y1, double x2, double y2) void init(double x1, double y1, double x2, double y2)
{ {
m_coord[0] = x1; m_coord[0] = x1;
@ -597,10 +594,10 @@ namespace agg
//---------------------------------------------------------------path_base //---------------------------------------------------------------path_base
// A container to store vertices with their flags. // A container to store vertices with their flags.
// A path consists of a number of contours separated with "move_to" // A path consists of a number of contours separated with "move_to"
// commands. The path storage can keep and maintain more than one // commands. The path storage can keep and maintain more than one
// path. // path.
// To navigate to the beginning of a particular path, use rewind(path_id); // To navigate to the beginning of a particular path, use rewind(path_id);
// Where path_id is what start_new_path() returns. So, when you call // Where path_id is what start_new_path() returns. So, when you call
// start_new_path() you need to store its return value somewhere else // start_new_path() you need to store its return value somewhere else
@ -647,28 +644,28 @@ namespace agg
bool sweep_flag, bool sweep_flag,
double dx, double dy); double dx, double dy);
void curve3(double x_ctrl, double y_ctrl, void curve3(double x_ctrl, double y_ctrl,
double x_to, double y_to); double x_to, double y_to);
void curve3_rel(double dx_ctrl, double dy_ctrl, void curve3_rel(double dx_ctrl, double dy_ctrl,
double dx_to, double dy_to); double dx_to, double dy_to);
void curve3(double x_to, double y_to); void curve3(double x_to, double y_to);
void curve3_rel(double dx_to, double dy_to); void curve3_rel(double dx_to, double dy_to);
void curve4(double x_ctrl1, double y_ctrl1, void curve4(double x_ctrl1, double y_ctrl1,
double x_ctrl2, double y_ctrl2, double x_ctrl2, double y_ctrl2,
double x_to, double y_to); double x_to, double y_to);
void curve4_rel(double dx_ctrl1, double dy_ctrl1, void curve4_rel(double dx_ctrl1, double dy_ctrl1,
double dx_ctrl2, double dy_ctrl2, double dx_ctrl2, double dy_ctrl2,
double dx_to, double dy_to); double dx_to, double dy_to);
void curve4(double x_ctrl2, double y_ctrl2, void curve4(double x_ctrl2, double y_ctrl2,
double x_to, double y_to); double x_to, double y_to);
void curve4_rel(double x_ctrl2, double y_ctrl2, void curve4_rel(double x_ctrl2, double y_ctrl2,
double x_to, double y_to); double x_to, double y_to);
@ -677,8 +674,8 @@ namespace agg
// Accessors // Accessors
//-------------------------------------------------------------------- //--------------------------------------------------------------------
const container_type& vertices() const { return m_vertices; } const container_type& vertices() const { return m_vertices; }
container_type& vertices() { return m_vertices; } container_type& vertices() { return m_vertices; }
unsigned total_vertices() const; unsigned total_vertices() const;
@ -702,9 +699,9 @@ namespace agg
void rewind(unsigned path_id); void rewind(unsigned path_id);
unsigned vertex(double* x, double* y); unsigned vertex(double* x, double* y);
// Arrange the orientation of a polygon, all polygons in a path, // Arrange the orientation of a polygon, all polygons in a path,
// or in all paths. After calling arrange_orientations() or // or in all paths. After calling arrange_orientations() or
// arrange_orientations_all_paths(), all the polygons will have // arrange_orientations_all_paths(), all the polygons will have
// the same orientation, i.e. path_flags_cw or path_flags_ccw // the same orientation, i.e. path_flags_cw or path_flags_ccw
//-------------------------------------------------------------------- //--------------------------------------------------------------------
unsigned arrange_polygon_orientation(unsigned start, path_flags_e orientation); unsigned arrange_polygon_orientation(unsigned start, path_flags_e orientation);
@ -712,7 +709,7 @@ namespace agg
void arrange_orientations_all_paths(path_flags_e orientation); void arrange_orientations_all_paths(path_flags_e orientation);
void invert_polygon(unsigned start); void invert_polygon(unsigned start);
// Flip all vertices horizontally or vertically, // Flip all vertices horizontally or vertically,
// between x1 and x2, or between y1 and y2 respectively // between x1 and x2, or between y1 and y2 respectively
//-------------------------------------------------------------------- //--------------------------------------------------------------------
void flip_x(double x1, double x2); void flip_x(double x1, double x2);
@ -720,7 +717,7 @@ namespace agg
// Concatenate path. The path is added as is. // Concatenate path. The path is added as is.
//-------------------------------------------------------------------- //--------------------------------------------------------------------
template<class VertexSource> template<class VertexSource>
void concat_path(VertexSource& vs, unsigned path_id = 0) void concat_path(VertexSource& vs, unsigned path_id = 0)
{ {
double x=0; double x=0;
@ -734,9 +731,9 @@ namespace agg
} }
//-------------------------------------------------------------------- //--------------------------------------------------------------------
// Join path. The path is joined with the existing one, that is, // Join path. The path is joined with the existing one, that is,
// it behaves as if the pen of a plotter was always down (drawing) // it behaves as if the pen of a plotter was always down (drawing)
template<class VertexSource> template<class VertexSource>
void join_path(VertexSource& vs, unsigned path_id = 0) void join_path(VertexSource& vs, unsigned path_id = 0)
{ {
double x=0.0, y=0.0; double x=0.0, y=0.0;
@ -772,16 +769,16 @@ namespace agg
} }
while(!is_stop(cmd = vs.vertex(&x, &y))) while(!is_stop(cmd = vs.vertex(&x, &y)))
{ {
m_vertices.add_vertex(x, y, is_move_to(cmd) ? m_vertices.add_vertex(x, y, is_move_to(cmd) ?
unsigned(path_cmd_line_to) : unsigned(path_cmd_line_to) :
cmd); cmd);
} }
} }
} }
// Concatenate polygon/polyline. // Concatenate polygon/polyline.
//-------------------------------------------------------------------- //--------------------------------------------------------------------
template<class T> void concat_poly(const T* data, template<class T> void concat_poly(const T* data,
unsigned num_points, unsigned num_points,
bool closed) bool closed)
{ {
@ -791,7 +788,7 @@ namespace agg
// Join polygon/polyline continuously. // Join polygon/polyline continuously.
//-------------------------------------------------------------------- //--------------------------------------------------------------------
template<class T> void join_poly(const T* data, template<class T> void join_poly(const T* data,
unsigned num_points, unsigned num_points,
bool closed) bool closed)
{ {
@ -849,7 +846,7 @@ namespace agg
}; };
//------------------------------------------------------------------------ //------------------------------------------------------------------------
template<class VC> template<class VC>
unsigned path_base<VC>::start_new_path() unsigned path_base<VC>::start_new_path()
{ {
if(!is_stop(m_vertices.last_command())) if(!is_stop(m_vertices.last_command()))
@ -861,7 +858,7 @@ namespace agg
//------------------------------------------------------------------------ //------------------------------------------------------------------------
template<class VC> template<class VC>
inline void path_base<VC>::rel_to_abs(double* x, double* y) const inline void path_base<VC>::rel_to_abs(double* x, double* y) const
{ {
if(m_vertices.total_vertices()) if(m_vertices.total_vertices())
@ -873,7 +870,7 @@ namespace agg
*x += x2; *x += x2;
*y += y2; *y += y2;
} }
else if (!is_stop(m_vertices.last_command()) && else if (!is_stop(m_vertices.last_command()) &&
is_vertex(m_vertices.prev_vertex(&x2, &y2))) is_vertex(m_vertices.prev_vertex(&x2, &y2)))
{ {
*x += x2; *x += x2;
@ -883,14 +880,14 @@ namespace agg
} }
//------------------------------------------------------------------------ //------------------------------------------------------------------------
template<class VC> template<class VC>
inline void path_base<VC>::move_to(double x, double y) inline void path_base<VC>::move_to(double x, double y)
{ {
m_vertices.add_vertex(x, y, path_cmd_move_to); m_vertices.add_vertex(x, y, path_cmd_move_to);
} }
//------------------------------------------------------------------------ //------------------------------------------------------------------------
template<class VC> template<class VC>
inline void path_base<VC>::move_rel(double dx, double dy) inline void path_base<VC>::move_rel(double dx, double dy)
{ {
rel_to_abs(&dx, &dy); rel_to_abs(&dx, &dy);
@ -898,14 +895,14 @@ namespace agg
} }
//------------------------------------------------------------------------ //------------------------------------------------------------------------
template<class VC> template<class VC>
inline void path_base<VC>::line_to(double x, double y) inline void path_base<VC>::line_to(double x, double y)
{ {
m_vertices.add_vertex(x, y, path_cmd_line_to); m_vertices.add_vertex(x, y, path_cmd_line_to);
} }
//------------------------------------------------------------------------ //------------------------------------------------------------------------
template<class VC> template<class VC>
inline void path_base<VC>::line_rel(double dx, double dy) inline void path_base<VC>::line_rel(double dx, double dy)
{ {
rel_to_abs(&dx, &dy); rel_to_abs(&dx, &dy);
@ -913,14 +910,14 @@ namespace agg
} }
//------------------------------------------------------------------------ //------------------------------------------------------------------------
template<class VC> template<class VC>
inline void path_base<VC>::hline_to(double x) inline void path_base<VC>::hline_to(double x)
{ {
m_vertices.add_vertex(x, last_y(), path_cmd_line_to); m_vertices.add_vertex(x, last_y(), path_cmd_line_to);
} }
//------------------------------------------------------------------------ //------------------------------------------------------------------------
template<class VC> template<class VC>
inline void path_base<VC>::hline_rel(double dx) inline void path_base<VC>::hline_rel(double dx)
{ {
double dy = 0; double dy = 0;
@ -929,14 +926,14 @@ namespace agg
} }
//------------------------------------------------------------------------ //------------------------------------------------------------------------
template<class VC> template<class VC>
inline void path_base<VC>::vline_to(double y) inline void path_base<VC>::vline_to(double y)
{ {
m_vertices.add_vertex(last_x(), y, path_cmd_line_to); m_vertices.add_vertex(last_x(), y, path_cmd_line_to);
} }
//------------------------------------------------------------------------ //------------------------------------------------------------------------
template<class VC> template<class VC>
inline void path_base<VC>::vline_rel(double dy) inline void path_base<VC>::vline_rel(double dy)
{ {
double dx = 0; double dx = 0;
@ -945,7 +942,7 @@ namespace agg
} }
//------------------------------------------------------------------------ //------------------------------------------------------------------------
template<class VC> template<class VC>
void path_base<VC>::arc_to(double rx, double ry, void path_base<VC>::arc_to(double rx, double ry,
double angle, double angle,
bool large_arc_flag, bool large_arc_flag,
@ -964,7 +961,7 @@ namespace agg
// Ensure radii are valid // Ensure radii are valid
//------------------------- //-------------------------
if(rx < epsilon || ry < epsilon) if(rx < epsilon || ry < epsilon)
{ {
line_to(x, y); line_to(x, y);
return; return;
@ -981,11 +978,10 @@ namespace agg
{ {
join_path(a); join_path(a);
} }
// We are adding an explicit line_to, even if we've already add the else
// bezier arc to the current path. This is to prevent subsequent smooth {
// bezier curves from accidentally assuming that the previous command line_to(x, y);
// was a bezier curve as well when calculating reflection points. }
line_to(x, y);
} }
else else
{ {
@ -994,7 +990,7 @@ namespace agg
} }
//------------------------------------------------------------------------ //------------------------------------------------------------------------
template<class VC> template<class VC>
void path_base<VC>::arc_rel(double rx, double ry, void path_base<VC>::arc_rel(double rx, double ry,
double angle, double angle,
bool large_arc_flag, bool large_arc_flag,
@ -1006,8 +1002,8 @@ namespace agg
} }
//------------------------------------------------------------------------ //------------------------------------------------------------------------
template<class VC> template<class VC>
void path_base<VC>::curve3(double x_ctrl, double y_ctrl, void path_base<VC>::curve3(double x_ctrl, double y_ctrl,
double x_to, double y_to) double x_to, double y_to)
{ {
m_vertices.add_vertex(x_ctrl, y_ctrl, path_cmd_curve3); m_vertices.add_vertex(x_ctrl, y_ctrl, path_cmd_curve3);
@ -1015,8 +1011,8 @@ namespace agg
} }
//------------------------------------------------------------------------ //------------------------------------------------------------------------
template<class VC> template<class VC>
void path_base<VC>::curve3_rel(double dx_ctrl, double dy_ctrl, void path_base<VC>::curve3_rel(double dx_ctrl, double dy_ctrl,
double dx_to, double dy_to) double dx_to, double dy_to)
{ {
rel_to_abs(&dx_ctrl, &dy_ctrl); rel_to_abs(&dx_ctrl, &dy_ctrl);
@ -1026,7 +1022,7 @@ namespace agg
} }
//------------------------------------------------------------------------ //------------------------------------------------------------------------
template<class VC> template<class VC>
void path_base<VC>::curve3(double x_to, double y_to) void path_base<VC>::curve3(double x_to, double y_to)
{ {
double x0; double x0;
@ -1034,7 +1030,7 @@ namespace agg
if(is_vertex(m_vertices.last_vertex(&x0, &y0))) if(is_vertex(m_vertices.last_vertex(&x0, &y0)))
{ {
double x_ctrl; double x_ctrl;
double y_ctrl; double y_ctrl;
unsigned cmd = m_vertices.prev_vertex(&x_ctrl, &y_ctrl); unsigned cmd = m_vertices.prev_vertex(&x_ctrl, &y_ctrl);
if(is_curve(cmd)) if(is_curve(cmd))
{ {
@ -1051,7 +1047,7 @@ namespace agg
} }
//------------------------------------------------------------------------ //------------------------------------------------------------------------
template<class VC> template<class VC>
void path_base<VC>::curve3_rel(double dx_to, double dy_to) void path_base<VC>::curve3_rel(double dx_to, double dy_to)
{ {
rel_to_abs(&dx_to, &dy_to); rel_to_abs(&dx_to, &dy_to);
@ -1059,9 +1055,9 @@ namespace agg
} }
//------------------------------------------------------------------------ //------------------------------------------------------------------------
template<class VC> template<class VC>
void path_base<VC>::curve4(double x_ctrl1, double y_ctrl1, void path_base<VC>::curve4(double x_ctrl1, double y_ctrl1,
double x_ctrl2, double y_ctrl2, double x_ctrl2, double y_ctrl2,
double x_to, double y_to) double x_to, double y_to)
{ {
m_vertices.add_vertex(x_ctrl1, y_ctrl1, path_cmd_curve4); m_vertices.add_vertex(x_ctrl1, y_ctrl1, path_cmd_curve4);
@ -1070,9 +1066,9 @@ namespace agg
} }
//------------------------------------------------------------------------ //------------------------------------------------------------------------
template<class VC> template<class VC>
void path_base<VC>::curve4_rel(double dx_ctrl1, double dy_ctrl1, void path_base<VC>::curve4_rel(double dx_ctrl1, double dy_ctrl1,
double dx_ctrl2, double dy_ctrl2, double dx_ctrl2, double dy_ctrl2,
double dx_to, double dy_to) double dx_to, double dy_to)
{ {
rel_to_abs(&dx_ctrl1, &dy_ctrl1); rel_to_abs(&dx_ctrl1, &dy_ctrl1);
@ -1084,8 +1080,8 @@ namespace agg
} }
//------------------------------------------------------------------------ //------------------------------------------------------------------------
template<class VC> template<class VC>
void path_base<VC>::curve4(double x_ctrl2, double y_ctrl2, void path_base<VC>::curve4(double x_ctrl2, double y_ctrl2,
double x_to, double y_to) double x_to, double y_to)
{ {
double x0; double x0;
@ -1093,7 +1089,7 @@ namespace agg
if(is_vertex(last_vertex(&x0, &y0))) if(is_vertex(last_vertex(&x0, &y0)))
{ {
double x_ctrl1; double x_ctrl1;
double y_ctrl1; double y_ctrl1;
unsigned cmd = prev_vertex(&x_ctrl1, &y_ctrl1); unsigned cmd = prev_vertex(&x_ctrl1, &y_ctrl1);
if(is_curve(cmd)) if(is_curve(cmd))
{ {
@ -1110,8 +1106,8 @@ namespace agg
} }
//------------------------------------------------------------------------ //------------------------------------------------------------------------
template<class VC> template<class VC>
void path_base<VC>::curve4_rel(double dx_ctrl2, double dy_ctrl2, void path_base<VC>::curve4_rel(double dx_ctrl2, double dy_ctrl2,
double dx_to, double dy_to) double dx_to, double dy_to)
{ {
rel_to_abs(&dx_ctrl2, &dy_ctrl2); rel_to_abs(&dx_ctrl2, &dy_ctrl2);
@ -1120,7 +1116,7 @@ namespace agg
} }
//------------------------------------------------------------------------ //------------------------------------------------------------------------
template<class VC> template<class VC>
inline void path_base<VC>::end_poly(unsigned flags) inline void path_base<VC>::end_poly(unsigned flags)
{ {
if(is_vertex(m_vertices.last_command())) if(is_vertex(m_vertices.last_command()))
@ -1130,91 +1126,91 @@ namespace agg
} }
//------------------------------------------------------------------------ //------------------------------------------------------------------------
template<class VC> template<class VC>
inline void path_base<VC>::close_polygon(unsigned flags) inline void path_base<VC>::close_polygon(unsigned flags)
{ {
end_poly(path_flags_close | flags); end_poly(path_flags_close | flags);
} }
//------------------------------------------------------------------------ //------------------------------------------------------------------------
template<class VC> template<class VC>
inline unsigned path_base<VC>::total_vertices() const inline unsigned path_base<VC>::total_vertices() const
{ {
return m_vertices.total_vertices(); return m_vertices.total_vertices();
} }
//------------------------------------------------------------------------ //------------------------------------------------------------------------
template<class VC> template<class VC>
inline unsigned path_base<VC>::last_vertex(double* x, double* y) const inline unsigned path_base<VC>::last_vertex(double* x, double* y) const
{ {
return m_vertices.last_vertex(x, y); return m_vertices.last_vertex(x, y);
} }
//------------------------------------------------------------------------ //------------------------------------------------------------------------
template<class VC> template<class VC>
inline unsigned path_base<VC>::prev_vertex(double* x, double* y) const inline unsigned path_base<VC>::prev_vertex(double* x, double* y) const
{ {
return m_vertices.prev_vertex(x, y); return m_vertices.prev_vertex(x, y);
} }
//------------------------------------------------------------------------ //------------------------------------------------------------------------
template<class VC> template<class VC>
inline double path_base<VC>::last_x() const inline double path_base<VC>::last_x() const
{ {
return m_vertices.last_x(); return m_vertices.last_x();
} }
//------------------------------------------------------------------------ //------------------------------------------------------------------------
template<class VC> template<class VC>
inline double path_base<VC>::last_y() const inline double path_base<VC>::last_y() const
{ {
return m_vertices.last_y(); return m_vertices.last_y();
} }
//------------------------------------------------------------------------ //------------------------------------------------------------------------
template<class VC> template<class VC>
inline unsigned path_base<VC>::vertex(unsigned idx, double* x, double* y) const inline unsigned path_base<VC>::vertex(unsigned idx, double* x, double* y) const
{ {
return m_vertices.vertex(idx, x, y); return m_vertices.vertex(idx, x, y);
} }
//------------------------------------------------------------------------ //------------------------------------------------------------------------
template<class VC> template<class VC>
inline unsigned path_base<VC>::command(unsigned idx) const inline unsigned path_base<VC>::command(unsigned idx) const
{ {
return m_vertices.command(idx); return m_vertices.command(idx);
} }
//------------------------------------------------------------------------ //------------------------------------------------------------------------
template<class VC> template<class VC>
void path_base<VC>::modify_vertex(unsigned idx, double x, double y) void path_base<VC>::modify_vertex(unsigned idx, double x, double y)
{ {
m_vertices.modify_vertex(idx, x, y); m_vertices.modify_vertex(idx, x, y);
} }
//------------------------------------------------------------------------ //------------------------------------------------------------------------
template<class VC> template<class VC>
void path_base<VC>::modify_vertex(unsigned idx, double x, double y, unsigned cmd) void path_base<VC>::modify_vertex(unsigned idx, double x, double y, unsigned cmd)
{ {
m_vertices.modify_vertex(idx, x, y, cmd); m_vertices.modify_vertex(idx, x, y, cmd);
} }
//------------------------------------------------------------------------ //------------------------------------------------------------------------
template<class VC> template<class VC>
void path_base<VC>::modify_command(unsigned idx, unsigned cmd) void path_base<VC>::modify_command(unsigned idx, unsigned cmd)
{ {
m_vertices.modify_command(idx, cmd); m_vertices.modify_command(idx, cmd);
} }
//------------------------------------------------------------------------ //------------------------------------------------------------------------
template<class VC> template<class VC>
inline void path_base<VC>::rewind(unsigned path_id) inline void path_base<VC>::rewind(unsigned path_id)
{ {
m_iterator = path_id; m_iterator = path_id;
} }
//------------------------------------------------------------------------ //------------------------------------------------------------------------
template<class VC> template<class VC>
inline unsigned path_base<VC>::vertex(double* x, double* y) inline unsigned path_base<VC>::vertex(double* x, double* y)
{ {
if(m_iterator >= m_vertices.total_vertices()) return path_cmd_stop; if(m_iterator >= m_vertices.total_vertices()) return path_cmd_stop;
@ -1222,7 +1218,7 @@ namespace agg
} }
//------------------------------------------------------------------------ //------------------------------------------------------------------------
template<class VC> template<class VC>
unsigned path_base<VC>::perceive_polygon_orientation(unsigned start, unsigned path_base<VC>::perceive_polygon_orientation(unsigned start,
unsigned end) unsigned end)
{ {
@ -1242,12 +1238,12 @@ namespace agg
} }
//------------------------------------------------------------------------ //------------------------------------------------------------------------
template<class VC> template<class VC>
void path_base<VC>::invert_polygon(unsigned start, unsigned end) void path_base<VC>::invert_polygon(unsigned start, unsigned end)
{ {
unsigned i; unsigned i;
unsigned tmp_cmd = m_vertices.command(start); unsigned tmp_cmd = m_vertices.command(start);
--end; // Make "end" inclusive --end; // Make "end" inclusive
// Shift all commands to one position // Shift all commands to one position
@ -1267,45 +1263,45 @@ namespace agg
} }
//------------------------------------------------------------------------ //------------------------------------------------------------------------
template<class VC> template<class VC>
void path_base<VC>::invert_polygon(unsigned start) void path_base<VC>::invert_polygon(unsigned start)
{ {
// Skip all non-vertices at the beginning // Skip all non-vertices at the beginning
while(start < m_vertices.total_vertices() && while(start < m_vertices.total_vertices() &&
!is_vertex(m_vertices.command(start))) ++start; !is_vertex(m_vertices.command(start))) ++start;
// Skip all insignificant move_to // Skip all insignificant move_to
while(start+1 < m_vertices.total_vertices() && while(start+1 < m_vertices.total_vertices() &&
is_move_to(m_vertices.command(start)) && is_move_to(m_vertices.command(start)) &&
is_move_to(m_vertices.command(start+1))) ++start; is_move_to(m_vertices.command(start+1))) ++start;
// Find the last vertex // Find the last vertex
unsigned end = start + 1; unsigned end = start + 1;
while(end < m_vertices.total_vertices() && while(end < m_vertices.total_vertices() &&
!is_next_poly(m_vertices.command(end))) ++end; !is_next_poly(m_vertices.command(end))) ++end;
invert_polygon(start, end); invert_polygon(start, end);
} }
//------------------------------------------------------------------------ //------------------------------------------------------------------------
template<class VC> template<class VC>
unsigned path_base<VC>::arrange_polygon_orientation(unsigned start, unsigned path_base<VC>::arrange_polygon_orientation(unsigned start,
path_flags_e orientation) path_flags_e orientation)
{ {
if(orientation == path_flags_none) return start; if(orientation == path_flags_none) return start;
// Skip all non-vertices at the beginning // Skip all non-vertices at the beginning
while(start < m_vertices.total_vertices() && while(start < m_vertices.total_vertices() &&
!is_vertex(m_vertices.command(start))) ++start; !is_vertex(m_vertices.command(start))) ++start;
// Skip all insignificant move_to // Skip all insignificant move_to
while(start+1 < m_vertices.total_vertices() && while(start+1 < m_vertices.total_vertices() &&
is_move_to(m_vertices.command(start)) && is_move_to(m_vertices.command(start)) &&
is_move_to(m_vertices.command(start+1))) ++start; is_move_to(m_vertices.command(start+1))) ++start;
// Find the last vertex // Find the last vertex
unsigned end = start + 1; unsigned end = start + 1;
while(end < m_vertices.total_vertices() && while(end < m_vertices.total_vertices() &&
!is_next_poly(m_vertices.command(end))) ++end; !is_next_poly(m_vertices.command(end))) ++end;
if(end - start > 2) if(end - start > 2)
@ -1315,7 +1311,7 @@ namespace agg
// Invert polygon, set orientation flag, and skip all end_poly // Invert polygon, set orientation flag, and skip all end_poly
invert_polygon(start, end); invert_polygon(start, end);
unsigned cmd; unsigned cmd;
while(end < m_vertices.total_vertices() && while(end < m_vertices.total_vertices() &&
is_end_poly(cmd = m_vertices.command(end))) is_end_poly(cmd = m_vertices.command(end)))
{ {
m_vertices.modify_command(end++, set_orientation(cmd, orientation)); m_vertices.modify_command(end++, set_orientation(cmd, orientation));
@ -1326,8 +1322,8 @@ namespace agg
} }
//------------------------------------------------------------------------ //------------------------------------------------------------------------
template<class VC> template<class VC>
unsigned path_base<VC>::arrange_orientations(unsigned start, unsigned path_base<VC>::arrange_orientations(unsigned start,
path_flags_e orientation) path_flags_e orientation)
{ {
if(orientation != path_flags_none) if(orientation != path_flags_none)
@ -1346,7 +1342,7 @@ namespace agg
} }
//------------------------------------------------------------------------ //------------------------------------------------------------------------
template<class VC> template<class VC>
void path_base<VC>::arrange_orientations_all_paths(path_flags_e orientation) void path_base<VC>::arrange_orientations_all_paths(path_flags_e orientation)
{ {
if(orientation != path_flags_none) if(orientation != path_flags_none)
@ -1360,7 +1356,7 @@ namespace agg
} }
//------------------------------------------------------------------------ //------------------------------------------------------------------------
template<class VC> template<class VC>
void path_base<VC>::flip_x(double x1, double x2) void path_base<VC>::flip_x(double x1, double x2)
{ {
unsigned i; unsigned i;
@ -1376,7 +1372,7 @@ namespace agg
} }
//------------------------------------------------------------------------ //------------------------------------------------------------------------
template<class VC> template<class VC>
void path_base<VC>::flip_y(double y1, double y2) void path_base<VC>::flip_y(double y1, double y2)
{ {
unsigned i; unsigned i;
@ -1392,7 +1388,7 @@ namespace agg
} }
//------------------------------------------------------------------------ //------------------------------------------------------------------------
template<class VC> template<class VC>
void path_base<VC>::translate(double dx, double dy, unsigned path_id) void path_base<VC>::translate(double dx, double dy, unsigned path_id)
{ {
unsigned num_ver = m_vertices.total_vertices(); unsigned num_ver = m_vertices.total_vertices();
@ -1411,7 +1407,7 @@ namespace agg
} }
//------------------------------------------------------------------------ //------------------------------------------------------------------------
template<class VC> template<class VC>
void path_base<VC>::translate_all_paths(double dx, double dy) void path_base<VC>::translate_all_paths(double dx, double dy)
{ {
unsigned idx; unsigned idx;
@ -1444,8 +1440,8 @@ namespace agg
void add_vertex(double x, double y, unsigned cmd) void add_vertex(double x, double y, unsigned cmd)
{ {
m_vertices.push_back(vertex_type(value_type(x), m_vertices.push_back(vertex_type(value_type(x),
value_type(y), value_type(y),
int8u(cmd))); int8u(cmd)));
} }
@ -1478,8 +1474,8 @@ namespace agg
unsigned last_command() const unsigned last_command() const
{ {
return m_vertices.size() ? return m_vertices.size() ?
m_vertices[m_vertices.size() - 1].cmd : m_vertices[m_vertices.size() - 1].cmd :
path_cmd_stop; path_cmd_stop;
} }
@ -1549,11 +1545,11 @@ namespace agg
// Example of declarations path_storage with std::vector as a container // Example of declarations path_storage with std::vector as a container
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
//#include <vector> //#include <vector>
//namespace agg //namespace agg
//{ //{
// typedef path_base<vertex_stl_storage<std::vector<vertex_d> > > path_storage; // typedef path_base<vertex_stl_storage<std::vector<vertex_d> > > path_storage;
//} //}
#endif #endif

View file

@ -2,8 +2,8 @@
// Anti-Grain Geometry - Version 2.4 // Anti-Grain Geometry - Version 2.4
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
// //
// Permission to copy, use, modify, sell and distribute this software // Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies. // is granted provided this copyright notice appears in all copies.
// This software is provided "as is" without express or implied // This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose. // warranty, and with no claim as to its suitability for any purpose.
// //
@ -35,7 +35,7 @@ namespace agg
}; };
//--------------------------------------------------------------blender_base //--------------------------------------------------------------blender_base
template<class ColorT, class Order = void> template<class ColorT, class Order = void>
struct blender_base struct blender_base
{ {
typedef ColorT color_type; typedef ColorT color_type;
@ -47,14 +47,14 @@ namespace agg
if (cover > cover_none) if (cover > cover_none)
{ {
rgba c( rgba c(
color_type::to_double(r), color_type::to_double(r),
color_type::to_double(g), color_type::to_double(g),
color_type::to_double(b), color_type::to_double(b),
color_type::to_double(a)); color_type::to_double(a));
if (cover < cover_full) if (cover < cover_full)
{ {
double x = static_cast<double>(cover) / static_cast<double>(cover_full); double x = double(cover) / cover_full;
c.r *= x; c.r *= x;
c.g *= x; c.g *= x;
c.b *= x; c.b *= x;
@ -69,10 +69,10 @@ namespace agg
static rgba get(const value_type* p, cover_type cover = cover_full) static rgba get(const value_type* p, cover_type cover = cover_full)
{ {
return get( return get(
p[order_type::R], p[order_type::R],
p[order_type::G], p[order_type::G],
p[order_type::B], p[order_type::B],
p[order_type::A], p[order_type::A],
cover); cover);
} }

View file

@ -24,7 +24,6 @@
#ifndef AGG_PIXFMT_RGBA_INCLUDED #ifndef AGG_PIXFMT_RGBA_INCLUDED
#define AGG_PIXFMT_RGBA_INCLUDED #define AGG_PIXFMT_RGBA_INCLUDED
#include <mapnik/config.hpp>
#include <cstring> #include <cstring>
#include <cmath> #include <cmath>
#include "agg_basics.h" #include "agg_basics.h"
@ -3167,10 +3166,6 @@ private:
extern template struct MAPNIK_DECL comp_op_rgba_hue<agg::rgba8, agg::order_rgba>;
extern template struct MAPNIK_DECL comp_op_rgba_saturation<agg::rgba8, agg::order_rgba>;
extern template struct MAPNIK_DECL comp_op_rgba_color<agg::rgba8, agg::order_rgba>;
extern template struct MAPNIK_DECL comp_op_rgba_value<agg::rgba8, agg::order_rgba>;
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
typedef blender_rgba<rgba8, order_rgba> blender_rgba32; //----blender_rgba32 typedef blender_rgba<rgba8, order_rgba> blender_rgba32; //----blender_rgba32

View file

@ -2,8 +2,8 @@
// Anti-Grain Geometry - Version 2.4 // Anti-Grain Geometry - Version 2.4
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
// //
// Permission to copy, use, modify, sell and distribute this software // Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies. // is granted provided this copyright notice appears in all copies.
// This software is provided "as is" without express or implied // This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose. // warranty, and with no claim as to its suitability for any purpose.
// //
@ -24,7 +24,7 @@ namespace agg
{ {
poly_max_coord = (1 << 30) - 1 //----poly_max_coord poly_max_coord = (1 << 30) - 1 //----poly_max_coord
}; };
//------------------------------------------------------------ras_conv_int //------------------------------------------------------------ras_conv_int
struct ras_conv_int struct ras_conv_int
{ {
@ -35,7 +35,7 @@ namespace agg
} }
static int xi(int v) { return v; } static int xi(int v) { return v; }
static int yi(int v) { return v; } static int yi(int v) { return v; }
static int upscale(double v) { return iround(v * static_cast<double>(poly_subpixel_scale)); } static int upscale(double v) { return iround(v * poly_subpixel_scale); }
static int downscale(int v) { return v; } static int downscale(int v) { return v; }
}; };
@ -49,9 +49,9 @@ namespace agg
} }
static int xi(int v) { return v; } static int xi(int v) { return v; }
static int yi(int v) { return v; } static int yi(int v) { return v; }
static int upscale(double v) static int upscale(double v)
{ {
return saturation<poly_max_coord>::iround(v * static_cast<double>(poly_subpixel_scale)); return saturation<poly_max_coord>::iround(v * poly_subpixel_scale);
} }
static int downscale(int v) { return v; } static int downscale(int v) { return v; }
}; };
@ -66,7 +66,7 @@ namespace agg
} }
static int xi(int v) { return v * 3; } static int xi(int v) { return v * 3; }
static int yi(int v) { return v; } static int yi(int v) { return v; }
static int upscale(double v) { return iround(v * static_cast<double>(poly_subpixel_scale)); } static int upscale(double v) { return iround(v * poly_subpixel_scale); }
static int downscale(int v) { return v; } static int downscale(int v) { return v; }
}; };
@ -78,10 +78,10 @@ namespace agg
{ {
return a * b / c; return a * b / c;
} }
static int xi(double v) { return iround(v * static_cast<double>(poly_subpixel_scale)); } static int xi(double v) { return iround(v * poly_subpixel_scale); }
static int yi(double v) { return iround(v * static_cast<double>(poly_subpixel_scale)); } static int yi(double v) { return iround(v * poly_subpixel_scale); }
static double upscale(double v) { return v; } static double upscale(double v) { return v; }
static double downscale(int v) { return v / static_cast<double>(poly_subpixel_scale); } static double downscale(int v) { return v / double(poly_subpixel_scale); }
}; };
//--------------------------------------------------------ras_conv_dbl_3x //--------------------------------------------------------ras_conv_dbl_3x
@ -92,10 +92,10 @@ namespace agg
{ {
return a * b / c; return a * b / c;
} }
static int xi(double v) { return iround(v * static_cast<double>(poly_subpixel_scale) * 3); } static int xi(double v) { return iround(v * poly_subpixel_scale * 3); }
static int yi(double v) { return iround(v * static_cast<double>(poly_subpixel_scale)); } static int yi(double v) { return iround(v * poly_subpixel_scale); }
static double upscale(double v) { return v; } static double upscale(double v) { return v; }
static double downscale(int v) { return v / static_cast<double>(poly_subpixel_scale); } static double downscale(int v) { return v / double(poly_subpixel_scale); }
}; };
@ -111,12 +111,12 @@ namespace agg
typedef rect_base<coord_type> rect_type; typedef rect_base<coord_type> rect_type;
//-------------------------------------------------------------------- //--------------------------------------------------------------------
rasterizer_sl_clip() : rasterizer_sl_clip() :
m_clip_box(0,0,0,0), m_clip_box(0,0,0,0),
m_x1(0), m_x1(0),
m_y1(0), m_y1(0),
m_f1(0), m_f1(0),
m_clipping(false) m_clipping(false)
{} {}
//-------------------------------------------------------------------- //--------------------------------------------------------------------
@ -145,8 +145,8 @@ namespace agg
//------------------------------------------------------------------------ //------------------------------------------------------------------------
template<class Rasterizer> template<class Rasterizer>
AGG_INLINE void line_clip_y(Rasterizer& ras, AGG_INLINE void line_clip_y(Rasterizer& ras,
coord_type x1, coord_type y1, coord_type x1, coord_type y1,
coord_type x2, coord_type y2, coord_type x2, coord_type y2,
unsigned f1, unsigned f2) const unsigned f1, unsigned f2) const
{ {
f1 &= 10; f1 &= 10;
@ -154,7 +154,7 @@ namespace agg
if((f1 | f2) == 0) if((f1 | f2) == 0)
{ {
// Fully visible // Fully visible
ras.line(Conv::xi(x1), Conv::yi(y1), Conv::xi(x2), Conv::yi(y2)); ras.line(Conv::xi(x1), Conv::yi(y1), Conv::xi(x2), Conv::yi(y2));
} }
else else
{ {
@ -192,8 +192,8 @@ namespace agg
tx2 = x1 + Conv::mul_div(m_clip_box.y2-y1, x2-x1, y2-y1); tx2 = x1 + Conv::mul_div(m_clip_box.y2-y1, x2-x1, y2-y1);
ty2 = m_clip_box.y2; ty2 = m_clip_box.y2;
} }
ras.line(Conv::xi(tx1), Conv::yi(ty1), ras.line(Conv::xi(tx1), Conv::yi(ty1),
Conv::xi(tx2), Conv::yi(ty2)); Conv::xi(tx2), Conv::yi(ty2));
} }
} }
@ -288,8 +288,8 @@ namespace agg
} }
else else
{ {
ras.line(Conv::xi(m_x1), Conv::yi(m_y1), ras.line(Conv::xi(m_x1), Conv::yi(m_y1),
Conv::xi(x2), Conv::yi(y2)); Conv::xi(x2), Conv::yi(y2));
} }
m_x1 = x2; m_x1 = x2;
m_y1 = y2; m_y1 = y2;
@ -321,10 +321,10 @@ namespace agg
void move_to(coord_type x1, coord_type y1) { m_x1 = x1; m_y1 = y1; } void move_to(coord_type x1, coord_type y1) { m_x1 = x1; m_y1 = y1; }
template<class Rasterizer> template<class Rasterizer>
void line_to(Rasterizer& ras, coord_type x2, coord_type y2) void line_to(Rasterizer& ras, coord_type x2, coord_type y2)
{ {
ras.line(m_x1, m_y1, x2, y2); ras.line(m_x1, m_y1, x2, y2);
m_x1 = x2; m_x1 = x2;
m_y1 = y2; m_y1 = y2;
} }

View file

@ -1305,7 +1305,7 @@ namespace agg
for(i = 0; i < aa_scale; i++) for(i = 0; i < aa_scale; i++)
{ {
m_gamma[i] = value_type( m_gamma[i] = value_type(
uround(gamma_function(static_cast<double>(i) / static_cast<double>(aa_mask)) * aa_mask)); uround(gamma_function(double(i) / aa_mask) * aa_mask));
} }
} }

View file

@ -66,9 +66,7 @@ void arrowhead::rewind(unsigned path_id)
m_cmd[3] = path_cmd_line_to; m_cmd[3] = path_cmd_line_to;
m_cmd[4] = path_cmd_line_to; m_cmd[4] = path_cmd_line_to;
m_cmd[5] = path_cmd_line_to; m_cmd[5] = path_cmd_line_to;
m_cmd[7] = path_cmd_end_poly m_cmd[7] = path_cmd_end_poly | path_flags_close | path_flags_ccw;
| static_cast<path_commands_e>(path_flags_close)
| static_cast<path_commands_e>(path_flags_ccw);
m_cmd[6] = path_cmd_stop; m_cmd[6] = path_cmd_stop;
return; return;
} }
@ -89,9 +87,7 @@ void arrowhead::rewind(unsigned path_id)
m_cmd[1] = path_cmd_line_to; m_cmd[1] = path_cmd_line_to;
m_cmd[2] = path_cmd_line_to; m_cmd[2] = path_cmd_line_to;
m_cmd[3] = path_cmd_line_to; m_cmd[3] = path_cmd_line_to;
m_cmd[4] = path_cmd_end_poly m_cmd[4] = path_cmd_end_poly | path_flags_close | path_flags_ccw;
| static_cast<path_commands_e>(path_flags_close)
| static_cast<path_commands_e>(path_flags_ccw);
m_cmd[5] = path_cmd_stop; m_cmd[5] = path_cmd_stop;
return; return;
} }

View file

@ -42,7 +42,7 @@ void line_profile_aa::width(double w)
//--------------------------------------------------------------------- //---------------------------------------------------------------------
line_profile_aa::value_type* line_profile_aa::profile(double w) line_profile_aa::value_type* line_profile_aa::profile(double w)
{ {
m_subpixel_width = uround(w * static_cast<double>(subpixel_scale)); m_subpixel_width = uround(w * subpixel_scale);
unsigned size = m_subpixel_width + subpixel_scale * 6; unsigned size = m_subpixel_width + subpixel_scale * 6;
if(size > m_profile.size()) if(size > m_profile.size())
{ {
@ -56,8 +56,8 @@ line_profile_aa::value_type* line_profile_aa::profile(double w)
void line_profile_aa::set(double center_width, double smoother_width) void line_profile_aa::set(double center_width, double smoother_width)
{ {
double base_val = 1.0; double base_val = 1.0;
if(center_width == 0.0) center_width = 1.0 / static_cast<double>(subpixel_scale); if(center_width == 0.0) center_width = 1.0 / subpixel_scale;
if(smoother_width == 0.0) smoother_width = 1.0 / static_cast<double>(subpixel_scale); if(smoother_width == 0.0) smoother_width = 1.0 / subpixel_scale;
double width = center_width + smoother_width; double width = center_width + smoother_width;
if(width < m_min_width) if(width < m_min_width)
@ -70,15 +70,15 @@ void line_profile_aa::set(double center_width, double smoother_width)
value_type* ch = profile(center_width + smoother_width); value_type* ch = profile(center_width + smoother_width);
unsigned subpixel_center_width = unsigned(center_width * static_cast<double>(subpixel_scale)); unsigned subpixel_center_width = unsigned(center_width * subpixel_scale);
unsigned subpixel_smoother_width = unsigned(smoother_width * static_cast<double>(subpixel_scale)); unsigned subpixel_smoother_width = unsigned(smoother_width * subpixel_scale);
value_type* ch_center = ch + subpixel_scale * 2; value_type* ch_center = ch + subpixel_scale*2;
value_type* ch_smoother = ch_center + subpixel_center_width; value_type* ch_smoother = ch_center + subpixel_center_width;
unsigned i; unsigned i;
unsigned val = m_gamma[unsigned(base_val * static_cast<double>(aa_mask))]; unsigned val = m_gamma[unsigned(base_val * aa_mask)];
ch = ch_center; ch = ch_center;
for(i = 0; i < subpixel_center_width; i++) for(i = 0; i < subpixel_center_width; i++)
{ {
@ -90,7 +90,7 @@ void line_profile_aa::set(double center_width, double smoother_width)
*ch_smoother++ = *ch_smoother++ =
m_gamma[unsigned((base_val - m_gamma[unsigned((base_val -
base_val * base_val *
(double(i) / subpixel_smoother_width)) * static_cast<double>(aa_mask))]; (double(i) / subpixel_smoother_width)) * aa_mask)];
} }
unsigned n_smoother = profile_size() - unsigned n_smoother = profile_size() -
@ -113,3 +113,4 @@ void line_profile_aa::set(double center_width, double smoother_width)
} }

View file

@ -152,9 +152,7 @@ unsigned rounded_rect::vertex(double* x, double* y)
else return path_cmd_line_to; else return path_cmd_line_to;
case 8: case 8:
cmd = path_cmd_end_poly cmd = path_cmd_end_poly | path_flags_close | path_flags_ccw;
| static_cast<path_commands_e>(path_flags_close)
| static_cast<path_commands_e>(path_flags_ccw);
m_status++; m_status++;
break; break;
} }
@ -163,3 +161,4 @@ unsigned rounded_rect::vertex(double* x, double* y)
} }

View file

@ -153,9 +153,7 @@ unsigned vcgen_contour::vertex(double* x, double* y)
case end_poly: case end_poly:
if(!m_closed) return path_cmd_stop; if(!m_closed) return path_cmd_stop;
m_status = stop; m_status = stop;
return path_cmd_end_poly return path_cmd_end_poly | path_flags_close | path_flags_ccw;
| static_cast<path_commands_e>(path_flags_close)
| static_cast<path_commands_e>(path_flags_ccw);
case stop: case stop:
return path_cmd_stop; return path_cmd_stop;

View file

@ -196,15 +196,11 @@ unsigned vcgen_stroke::vertex(double* x, double* y)
case end_poly1: case end_poly1:
m_status = m_prev_status; m_status = m_prev_status;
return path_cmd_end_poly return path_cmd_end_poly | path_flags_close | path_flags_ccw;
| static_cast<path_commands_e>(path_flags_close)
| static_cast<path_commands_e>(path_flags_ccw);
case end_poly2: case end_poly2:
m_status = m_prev_status; m_status = m_prev_status;
return path_cmd_end_poly return path_cmd_end_poly | path_flags_close | path_flags_cw;
| static_cast<path_commands_e>(path_flags_close)
| static_cast<path_commands_e>(path_flags_cw);
case stop: case stop:
cmd = path_cmd_stop; cmd = path_cmd_stop;

View file

@ -1 +0,0 @@
DisableFormat: true

View file

@ -1 +0,0 @@
DisableFormat: true

File diff suppressed because it is too large Load diff

View file

@ -43,9 +43,9 @@
#include <mapnik/sparsehash/internal/sparseconfig.h> #include <mapnik/sparsehash/internal/sparseconfig.h>
#include <assert.h> #include <assert.h>
#include <stdio.h> #include <stdio.h>
#include <stddef.h> // for size_t #include <stddef.h> // for size_t
#include <iosfwd> #include <iosfwd>
#include <stdexcept> // For length_error #include <stdexcept> // For length_error
_START_GOOGLE_NAMESPACE_ _START_GOOGLE_NAMESPACE_
@ -80,15 +80,15 @@ namespace sparsehash_internal {
// ----- low-level I/O for FILE* ---- // ----- low-level I/O for FILE* ----
template<typename Ignored> template<typename Ignored>
inline bool read_data_internal(Ignored*, FILE* fp, void* data, size_t length) inline bool read_data_internal(Ignored*, FILE* fp,
{ void* data, size_t length) {
return fread(data, length, 1, fp) == 1; return fread(data, length, 1, fp) == 1;
} }
template<typename Ignored> template<typename Ignored>
inline bool write_data_internal(Ignored*, FILE* fp, const void* data, size_t length) inline bool write_data_internal(Ignored*, FILE* fp,
{ const void* data, size_t length) {
return fwrite(data, length, 1, fp) == 1; return fwrite(data, length, 1, fp) == 1;
} }
// ----- low-level I/O for iostream ---- // ----- low-level I/O for iostream ----
@ -98,57 +98,55 @@ inline bool write_data_internal(Ignored*, FILE* fp, const void* data, size_t len
// it's only legal to delay the instantiation the way we want to if // it's only legal to delay the instantiation the way we want to if
// the istream/ostream is a template type. So we jump through hoops. // the istream/ostream is a template type. So we jump through hoops.
template<typename ISTREAM> template<typename ISTREAM>
inline bool read_data_internal_for_istream(ISTREAM* fp, void* data, size_t length) inline bool read_data_internal_for_istream(ISTREAM* fp,
{ void* data, size_t length) {
return fp->read(reinterpret_cast<char*>(data), length).good(); return fp->read(reinterpret_cast<char*>(data), length).good();
} }
template<typename Ignored> template<typename Ignored>
inline bool read_data_internal(Ignored*, std::istream* fp, void* data, size_t length) inline bool read_data_internal(Ignored*, std::istream* fp,
{ void* data, size_t length) {
return read_data_internal_for_istream(fp, data, length); return read_data_internal_for_istream(fp, data, length);
} }
template<typename OSTREAM> template<typename OSTREAM>
inline bool write_data_internal_for_ostream(OSTREAM* fp, const void* data, size_t length) inline bool write_data_internal_for_ostream(OSTREAM* fp,
{ const void* data, size_t length) {
return fp->write(reinterpret_cast<const char*>(data), length).good(); return fp->write(reinterpret_cast<const char*>(data), length).good();
} }
template<typename Ignored> template<typename Ignored>
inline bool write_data_internal(Ignored*, std::ostream* fp, const void* data, size_t length) inline bool write_data_internal(Ignored*, std::ostream* fp,
{ const void* data, size_t length) {
return write_data_internal_for_ostream(fp, data, length); return write_data_internal_for_ostream(fp, data, length);
} }
// ----- low-level I/O for custom streams ---- // ----- low-level I/O for custom streams ----
// The INPUT type needs to support a Read() method that takes a // The INPUT type needs to support a Read() method that takes a
// buffer and a length and returns the number of bytes read. // buffer and a length and returns the number of bytes read.
template<typename INPUT> template <typename INPUT>
inline bool read_data_internal(INPUT* fp, void*, void* data, size_t length) inline bool read_data_internal(INPUT* fp, void*,
{ void* data, size_t length) {
return static_cast<size_t>(fp->Read(data, length)) == length; return static_cast<size_t>(fp->Read(data, length)) == length;
} }
// The OUTPUT type needs to support a Write() operation that takes // The OUTPUT type needs to support a Write() operation that takes
// a buffer and a length and returns the number of bytes written. // a buffer and a length and returns the number of bytes written.
template<typename OUTPUT> template <typename OUTPUT>
inline bool write_data_internal(OUTPUT* fp, void*, const void* data, size_t length) inline bool write_data_internal(OUTPUT* fp, void*,
{ const void* data, size_t length) {
return static_cast<size_t>(fp->Write(data, length)) == length; return static_cast<size_t>(fp->Write(data, length)) == length;
} }
// ----- low-level I/O: the public API ---- // ----- low-level I/O: the public API ----
template<typename INPUT> template <typename INPUT>
inline bool read_data(INPUT* fp, void* data, size_t length) inline bool read_data(INPUT* fp, void* data, size_t length) {
{ return read_data_internal(fp, fp, data, length);
return read_data_internal(fp, fp, data, length);
} }
template<typename OUTPUT> template <typename OUTPUT>
inline bool write_data(OUTPUT* fp, const void* data, size_t length) inline bool write_data(OUTPUT* fp, const void* data, size_t length) {
{ return write_data_internal(fp, fp, data, length);
return write_data_internal(fp, fp, data, length);
} }
// Uses read_data() and write_data() to read/write an integer. // Uses read_data() and write_data() to read/write an integer.
@ -156,32 +154,26 @@ inline bool write_data(OUTPUT* fp, const void* data, size_t length)
// from sizeof(IntType), allowing us to save on a 32-bit system // from sizeof(IntType), allowing us to save on a 32-bit system
// and load on a 64-bit system). Excess bytes are taken to be 0. // and load on a 64-bit system). Excess bytes are taken to be 0.
// INPUT and OUTPUT must match legal inputs to read/write_data (above). // INPUT and OUTPUT must match legal inputs to read/write_data (above).
template<typename INPUT, typename IntType> template <typename INPUT, typename IntType>
bool read_bigendian_number(INPUT* fp, IntType* value, size_t length) bool read_bigendian_number(INPUT* fp, IntType* value, size_t length) {
{ *value = 0;
*value = 0; unsigned char byte;
unsigned char byte; for (size_t i = 0; i < length; ++i) {
for (size_t i = 0; i < length; ++i) if (!read_data(fp, &byte, sizeof(byte))) return false;
{ *value |= static_cast<IntType>(byte) << ((length - 1 - i) * 8);
if (!read_data(fp, &byte, sizeof(byte))) }
return false; return true;
*value |= static_cast<IntType>(byte) << ((length - 1 - i) * 8);
}
return true;
} }
template<typename OUTPUT, typename IntType> template <typename OUTPUT, typename IntType>
bool write_bigendian_number(OUTPUT* fp, IntType value, size_t length) bool write_bigendian_number(OUTPUT* fp, IntType value, size_t length) {
{ unsigned char byte;
unsigned char byte; for (size_t i = 0; i < length; ++i) {
for (size_t i = 0; i < length; ++i) byte = (sizeof(value) <= length-1 - i)
{ ? 0 : static_cast<unsigned char>((value >> ((length-1 - i) * 8)) & 255);
byte = if (!write_data(fp, &byte, sizeof(byte))) return false;
(sizeof(value) <= length - 1 - i) ? 0 : static_cast<unsigned char>((value >> ((length - 1 - i) * 8)) & 255); }
if (!write_data(fp, &byte, sizeof(byte))) return true;
return false;
}
return true;
} }
// If your keys and values are simple enough, you can pass this // If your keys and values are simple enough, you can pass this
@ -189,22 +181,19 @@ bool write_bigendian_number(OUTPUT* fp, IntType value, size_t length)
// value_type is a POD type that contains no pointers. Note, // value_type is a POD type that contains no pointers. Note,
// however, we don't try to normalize endianness. // however, we don't try to normalize endianness.
// This is the type used for NopointerSerializer. // This is the type used for NopointerSerializer.
template<typename value_type> template <typename value_type> struct pod_serializer {
struct pod_serializer template <typename INPUT>
{ bool operator()(INPUT* fp, value_type* value) const {
template<typename INPUT> return read_data(fp, value, sizeof(*value));
bool operator()(INPUT* fp, value_type* value) const }
{
return read_data(fp, value, sizeof(*value));
}
template<typename OUTPUT> template <typename OUTPUT>
bool operator()(OUTPUT* fp, const value_type& value) const bool operator()(OUTPUT* fp, const value_type& value) const {
{ return write_data(fp, &value, sizeof(value));
return write_data(fp, &value, sizeof(value)); }
}
}; };
// Settings contains parameters for growing and shrinking the table. // Settings contains parameters for growing and shrinking the table.
// It also packages zero-size functor (ie. hasher). // It also packages zero-size functor (ie. hasher).
// //
@ -217,136 +206,165 @@ struct pod_serializer
// for sure that the hash is the identity hash. If it's not, this // for sure that the hash is the identity hash. If it's not, this
// is needless work (and possibly, though not likely, harmful). // is needless work (and possibly, though not likely, harmful).
template<typename Key, typename HashFunc, typename SizeType, int HT_MIN_BUCKETS> template<typename Key, typename HashFunc,
class sh_hashtable_settings : public HashFunc typename SizeType, int HT_MIN_BUCKETS>
{ class sh_hashtable_settings : public HashFunc {
public: public:
typedef Key key_type; typedef Key key_type;
typedef HashFunc hasher; typedef HashFunc hasher;
typedef SizeType size_type; typedef SizeType size_type;
public: public:
sh_hashtable_settings(const hasher& hf, const float ht_occupancy_flt, const float ht_empty_flt) sh_hashtable_settings(const hasher& hf,
: hasher(hf) const float ht_occupancy_flt,
, enlarge_threshold_(0) const float ht_empty_flt)
, shrink_threshold_(0) : hasher(hf),
, consider_shrink_(false) enlarge_threshold_(0),
, use_empty_(false) shrink_threshold_(0),
, use_deleted_(false) consider_shrink_(false),
, num_ht_copies_(0) use_empty_(false),
{ use_deleted_(false),
set_enlarge_factor(ht_occupancy_flt); num_ht_copies_(0) {
set_shrink_factor(ht_empty_flt); set_enlarge_factor(ht_occupancy_flt);
set_shrink_factor(ht_empty_flt);
}
size_type hash(const key_type& v) const {
// We munge the hash value when we don't trust hasher::operator().
return hash_munger<Key>::MungedHash(hasher::operator()(v));
}
float enlarge_factor() const {
return enlarge_factor_;
}
void set_enlarge_factor(float f) {
enlarge_factor_ = f;
}
float shrink_factor() const {
return shrink_factor_;
}
void set_shrink_factor(float f) {
shrink_factor_ = f;
}
size_type enlarge_threshold() const {
return enlarge_threshold_;
}
void set_enlarge_threshold(size_type t) {
enlarge_threshold_ = t;
}
size_type shrink_threshold() const {
return shrink_threshold_;
}
void set_shrink_threshold(size_type t) {
shrink_threshold_ = t;
}
size_type enlarge_size(size_type x) const {
return static_cast<size_type>(x * enlarge_factor_);
}
size_type shrink_size(size_type x) const {
return static_cast<size_type>(x * shrink_factor_);
}
bool consider_shrink() const {
return consider_shrink_;
}
void set_consider_shrink(bool t) {
consider_shrink_ = t;
}
bool use_empty() const {
return use_empty_;
}
void set_use_empty(bool t) {
use_empty_ = t;
}
bool use_deleted() const {
return use_deleted_;
}
void set_use_deleted(bool t) {
use_deleted_ = t;
}
size_type num_ht_copies() const {
return static_cast<size_type>(num_ht_copies_);
}
void inc_num_ht_copies() {
++num_ht_copies_;
}
// Reset the enlarge and shrink thresholds
void reset_thresholds(size_type num_buckets) {
set_enlarge_threshold(enlarge_size(num_buckets));
set_shrink_threshold(shrink_size(num_buckets));
// whatever caused us to reset already considered
set_consider_shrink(false);
}
// Caller is resposible for calling reset_threshold right after
// set_resizing_parameters.
void set_resizing_parameters(float shrink, float grow) {
assert(shrink >= 0.0);
assert(grow <= 1.0);
if (shrink > grow/2.0f)
shrink = grow / 2.0f; // otherwise we thrash hashtable size
set_shrink_factor(shrink);
set_enlarge_factor(grow);
}
// This is the smallest size a hashtable can be without being too crowded
// If you like, you can give a min #buckets as well as a min #elts
size_type min_buckets(size_type num_elts, size_type min_buckets_wanted) {
float enlarge = enlarge_factor();
size_type sz = HT_MIN_BUCKETS; // min buckets allowed
while ( sz < min_buckets_wanted ||
num_elts >= static_cast<size_type>(sz * enlarge) ) {
// This just prevents overflowing size_type, since sz can exceed
// max_size() here.
if (static_cast<size_type>(sz * 2) < sz) {
throw std::length_error("resize overflow"); // protect against overflow
}
sz *= 2;
} }
return sz;
}
size_type hash(const key_type& v) const private:
{ template<class HashKey> class hash_munger {
// We munge the hash value when we don't trust hasher::operator(). public:
return hash_munger<Key>::MungedHash(hasher::operator()(v)); static size_t MungedHash(size_t hash) {
return hash;
} }
};
float enlarge_factor() const { return enlarge_factor_; } // This matches when the hashtable key is a pointer.
void set_enlarge_factor(float f) { enlarge_factor_ = f; } template<class HashKey> class hash_munger<HashKey*> {
float shrink_factor() const { return shrink_factor_; } public:
void set_shrink_factor(float f) { shrink_factor_ = f; } static size_t MungedHash(size_t hash) {
// TODO(csilvers): consider rotating instead:
size_type enlarge_threshold() const { return enlarge_threshold_; } // static const int shift = (sizeof(void *) == 4) ? 2 : 3;
void set_enlarge_threshold(size_type t) { enlarge_threshold_ = t; } // return (hash << (sizeof(hash) * 8) - shift)) | (hash >> shift);
size_type shrink_threshold() const { return shrink_threshold_; } // This matters if we ever change sparse/dense_hash_* to compare
void set_shrink_threshold(size_type t) { shrink_threshold_ = t; } // hashes before comparing actual values. It's speedy on x86.
return hash / sizeof(void*); // get rid of known-0 bits
size_type enlarge_size(size_type x) const { return static_cast<size_type>(x * enlarge_factor_); }
size_type shrink_size(size_type x) const { return static_cast<size_type>(x * shrink_factor_); }
bool consider_shrink() const { return consider_shrink_; }
void set_consider_shrink(bool t) { consider_shrink_ = t; }
bool use_empty() const { return use_empty_; }
void set_use_empty(bool t) { use_empty_ = t; }
bool use_deleted() const { return use_deleted_; }
void set_use_deleted(bool t) { use_deleted_ = t; }
size_type num_ht_copies() const { return static_cast<size_type>(num_ht_copies_); }
void inc_num_ht_copies() { ++num_ht_copies_; }
// Reset the enlarge and shrink thresholds
void reset_thresholds(size_type num_buckets)
{
set_enlarge_threshold(enlarge_size(num_buckets));
set_shrink_threshold(shrink_size(num_buckets));
// whatever caused us to reset already considered
set_consider_shrink(false);
} }
};
// Caller is resposible for calling reset_threshold right after size_type enlarge_threshold_; // table.size() * enlarge_factor
// set_resizing_parameters. size_type shrink_threshold_; // table.size() * shrink_factor
void set_resizing_parameters(float shrink, float grow) float enlarge_factor_; // how full before resize
{ float shrink_factor_; // how empty before resize
assert(shrink >= 0.0); // consider_shrink=true if we should try to shrink before next insert
assert(grow <= 1.0); bool consider_shrink_;
if (shrink > grow / 2.0f) bool use_empty_; // used only by densehashtable, not sparsehashtable
shrink = grow / 2.0f; // otherwise we thrash hashtable size bool use_deleted_; // false until delkey has been set
set_shrink_factor(shrink); // num_ht_copies is a counter incremented every Copy/Move
set_enlarge_factor(grow); unsigned int num_ht_copies_;
}
// This is the smallest size a hashtable can be without being too crowded
// If you like, you can give a min #buckets as well as a min #elts
size_type min_buckets(size_type num_elts, size_type min_buckets_wanted)
{
float enlarge = enlarge_factor();
size_type sz = HT_MIN_BUCKETS; // min buckets allowed
while (sz < min_buckets_wanted || num_elts >= static_cast<size_type>(sz * enlarge))
{
// This just prevents overflowing size_type, since sz can exceed
// max_size() here.
if (static_cast<size_type>(sz * 2) < sz)
{
throw std::length_error("resize overflow"); // protect against overflow
}
sz *= 2;
}
return sz;
}
private:
template<class HashKey>
class hash_munger
{
public:
static size_t MungedHash(size_t hash) { return hash; }
};
// This matches when the hashtable key is a pointer.
template<class HashKey>
class hash_munger<HashKey*>
{
public:
static size_t MungedHash(size_t hash)
{
// TODO(csilvers): consider rotating instead:
// static const int shift = (sizeof(void *) == 4) ? 2 : 3;
// return (hash << (sizeof(hash) * 8) - shift)) | (hash >> shift);
// This matters if we ever change sparse/dense_hash_* to compare
// hashes before comparing actual values. It's speedy on x86.
return hash / sizeof(void*); // get rid of known-0 bits
}
};
size_type enlarge_threshold_; // table.size() * enlarge_factor
size_type shrink_threshold_; // table.size() * shrink_factor
float enlarge_factor_; // how full before resize
float shrink_factor_; // how empty before resize
// consider_shrink=true if we should try to shrink before next insert
bool consider_shrink_;
bool use_empty_; // used only by densehashtable, not sparsehashtable
bool use_deleted_; // false until delkey has been set
// num_ht_copies is a counter incremented every Copy/Move
unsigned int num_ht_copies_;
}; };
} // namespace sparsehash_internal } // namespace sparsehash_internal
_END_GOOGLE_NAMESPACE_ _END_GOOGLE_NAMESPACE_
#endif // UTIL_GTL_HASHTABLE_COMMON_H_ #endif // UTIL_GTL_HASHTABLE_COMMON_H_

View file

@ -33,82 +33,87 @@
#define UTIL_GTL_LIBC_ALLOCATOR_WITH_REALLOC_H_ #define UTIL_GTL_LIBC_ALLOCATOR_WITH_REALLOC_H_
#include <mapnik/sparsehash/internal/sparseconfig.h> #include <mapnik/sparsehash/internal/sparseconfig.h>
#include <stdlib.h> // for malloc/realloc/free #include <stdlib.h> // for malloc/realloc/free
#include <stddef.h> // for ptrdiff_t #include <stddef.h> // for ptrdiff_t
#include <new> // for placement new #include <new> // for placement new
_START_GOOGLE_NAMESPACE_ _START_GOOGLE_NAMESPACE_
template<class T> template<class T>
class libc_allocator_with_realloc class libc_allocator_with_realloc {
{ public:
public: typedef T value_type;
typedef T value_type; typedef size_t size_type;
typedef size_t size_type; typedef ptrdiff_t difference_type;
typedef ptrdiff_t difference_type;
typedef T* pointer; typedef T* pointer;
typedef const T* const_pointer; typedef const T* const_pointer;
typedef T& reference; typedef T& reference;
typedef const T& const_reference; typedef const T& const_reference;
libc_allocator_with_realloc() {} libc_allocator_with_realloc() {}
libc_allocator_with_realloc(const libc_allocator_with_realloc&) {} libc_allocator_with_realloc(const libc_allocator_with_realloc&) {}
~libc_allocator_with_realloc() {} ~libc_allocator_with_realloc() {}
pointer address(reference r) const { return &r; } pointer address(reference r) const { return &r; }
const_pointer address(const_reference r) const { return &r; } const_pointer address(const_reference r) const { return &r; }
pointer allocate(size_type n, const_pointer = 0) { return static_cast<pointer>(malloc(n * sizeof(value_type))); } pointer allocate(size_type n, const_pointer = 0) {
void deallocate(pointer p, size_type) { free(p); } return static_cast<pointer>(malloc(n * sizeof(value_type)));
pointer reallocate(pointer p, size_type n) { return static_cast<pointer>(realloc(p, n * sizeof(value_type))); } }
void deallocate(pointer p, size_type) {
free(p);
}
pointer reallocate(pointer p, size_type n) {
return static_cast<pointer>(realloc(p, n * sizeof(value_type)));
}
size_type max_size() const { return static_cast<size_type>(-1) / sizeof(value_type); } size_type max_size() const {
return static_cast<size_type>(-1) / sizeof(value_type);
}
void construct(pointer p, const value_type& val) { new (p) value_type(val); } void construct(pointer p, const value_type& val) {
void destroy(pointer p) { p->~value_type(); } new(p) value_type(val);
}
void destroy(pointer p) { p->~value_type(); }
template<class U> template <class U>
libc_allocator_with_realloc(const libc_allocator_with_realloc<U>&) libc_allocator_with_realloc(const libc_allocator_with_realloc<U>&) {}
{}
template<class U> template<class U>
struct rebind struct rebind {
{ typedef libc_allocator_with_realloc<U> other;
typedef libc_allocator_with_realloc<U> other; };
};
}; };
// libc_allocator_with_realloc<void> specialization. // libc_allocator_with_realloc<void> specialization.
template<> template<>
class libc_allocator_with_realloc<void> class libc_allocator_with_realloc<void> {
{ public:
public: typedef void value_type;
typedef void value_type; typedef size_t size_type;
typedef size_t size_type; typedef ptrdiff_t difference_type;
typedef ptrdiff_t difference_type; typedef void* pointer;
typedef void* pointer; typedef const void* const_pointer;
typedef const void* const_pointer;
template<class U> template<class U>
struct rebind struct rebind {
{ typedef libc_allocator_with_realloc<U> other;
typedef libc_allocator_with_realloc<U> other; };
};
}; };
template<class T> template<class T>
inline bool operator==(const libc_allocator_with_realloc<T>&, const libc_allocator_with_realloc<T>&) inline bool operator==(const libc_allocator_with_realloc<T>&,
{ const libc_allocator_with_realloc<T>&) {
return true; return true;
} }
template<class T> template<class T>
inline bool operator!=(const libc_allocator_with_realloc<T>&, const libc_allocator_with_realloc<T>&) inline bool operator!=(const libc_allocator_with_realloc<T>&,
{ const libc_allocator_with_realloc<T>&) {
return false; return false;
} }
_END_GOOGLE_NAMESPACE_ _END_GOOGLE_NAMESPACE_
#endif // UTIL_GTL_LIBC_ALLOCATOR_WITH_REALLOC_H_ #endif // UTIL_GTL_LIBC_ALLOCATOR_WITH_REALLOC_H_

View file

@ -56,16 +56,14 @@ _START_GOOGLE_NAMESPACE_
// sizeof(big_) // sizeof(big_)
typedef char small_; typedef char small_;
struct big_ struct big_ {
{ char dummy[2];
char dummy[2];
}; };
// Identity metafunction. // Identity metafunction.
template<class T> template <class T>
struct identity_ struct identity_ {
{ typedef T type;
typedef T type;
}; };
// integral_constant, defined in tr1, is a wrapper for an integer // integral_constant, defined in tr1, is a wrapper for an integer
@ -74,64 +72,63 @@ struct identity_
// general integer_constant for compatibility with tr1. // general integer_constant for compatibility with tr1.
template<class T, T v> template<class T, T v>
struct integral_constant struct integral_constant {
{ static const T value = v;
static const T value = v; typedef T value_type;
typedef T value_type; typedef integral_constant<T, v> type;
typedef integral_constant<T, v> type;
}; };
template<class T, T v> template <class T, T v> const T integral_constant<T, v>::value;
const T integral_constant<T, v>::value;
// Abbreviations: true_type and false_type are structs that represent boolean // Abbreviations: true_type and false_type are structs that represent boolean
// true and false values. Also define the boost::mpl versions of those names, // true and false values. Also define the boost::mpl versions of those names,
// true_ and false_. // true_ and false_.
typedef integral_constant<bool, true> true_type; typedef integral_constant<bool, true> true_type;
typedef integral_constant<bool, false> false_type; typedef integral_constant<bool, false> false_type;
typedef true_type true_; typedef true_type true_;
typedef false_type false_; typedef false_type false_;
// if_ is a templatized conditional statement. // if_ is a templatized conditional statement.
// if_<cond, A, B> is a compile time evaluation of cond. // if_<cond, A, B> is a compile time evaluation of cond.
// if_<>::type contains A if cond is true, B otherwise. // if_<>::type contains A if cond is true, B otherwise.
template<bool cond, typename A, typename B> template<bool cond, typename A, typename B>
struct if_ struct if_{
{ typedef A type;
typedef A type;
}; };
template<typename A, typename B> template<typename A, typename B>
struct if_<false, A, B> struct if_<false, A, B> {
{ typedef B type;
typedef B type;
}; };
// type_equals_ is a template type comparator, similar to Loki IsSameType. // type_equals_ is a template type comparator, similar to Loki IsSameType.
// type_equals_<A, B>::value is true iff "A" is the same type as "B". // type_equals_<A, B>::value is true iff "A" is the same type as "B".
// //
// New code should prefer base::is_same, defined in base/type_traits.h. // New code should prefer base::is_same, defined in base/type_traits.h.
// It is functionally identical, but is_same is the standard spelling. // It is functionally identical, but is_same is the standard spelling.
template<typename A, typename B> template<typename A, typename B>
struct type_equals_ : public false_ struct type_equals_ : public false_ {
{}; };
template<typename A> template<typename A>
struct type_equals_<A, A> : public true_ struct type_equals_<A, A> : public true_ {
{}; };
// and_ is a template && operator. // and_ is a template && operator.
// and_<A, B>::value evaluates "A::value && B::value". // and_<A, B>::value evaluates "A::value && B::value".
template<typename A, typename B> template<typename A, typename B>
struct and_ : public integral_constant<bool, (A::value && B::value)> struct and_ : public integral_constant<bool, (A::value && B::value)> {
{}; };
// or_ is a template || operator. // or_ is a template || operator.
// or_<A, B>::value evaluates "A::value || B::value". // or_<A, B>::value evaluates "A::value || B::value".
template<typename A, typename B> template<typename A, typename B>
struct or_ : public integral_constant<bool, (A::value || B::value)> struct or_ : public integral_constant<bool, (A::value || B::value)> {
{}; };
_END_GOOGLE_NAMESPACE_ _END_GOOGLE_NAMESPACE_
#endif // BASE_TEMPLATE_UTIL_H_ #endif // BASE_TEMPLATE_UTIL_H_

View file

@ -58,188 +58,106 @@
#define BASE_TYPE_TRAITS_H_ #define BASE_TYPE_TRAITS_H_
#include <mapnik/sparsehash/internal/sparseconfig.h> #include <mapnik/sparsehash/internal/sparseconfig.h>
#include <utility> // For pair #include <utility> // For pair
#include <mapnik/sparsehash/template_util.h> // For true_type and false_type #include <mapnik/sparsehash/template_util.h> // For true_type and false_type
_START_GOOGLE_NAMESPACE_ _START_GOOGLE_NAMESPACE_
template<class T> template <class T> struct is_integral;
struct is_integral; template <class T> struct is_floating_point;
template<class T> template <class T> struct is_pointer;
struct is_floating_point;
template<class T>
struct is_pointer;
// MSVC can't compile this correctly, and neither can gcc 3.3.5 (at least) // MSVC can't compile this correctly, and neither can gcc 3.3.5 (at least)
#if !defined(_MSC_VER) && !(defined(__GNUC__) && __GNUC__ <= 3) #if !defined(_MSC_VER) && !(defined(__GNUC__) && __GNUC__ <= 3)
// is_enum uses is_convertible, which is not available on MSVC. // is_enum uses is_convertible, which is not available on MSVC.
template<class T> template <class T> struct is_enum;
struct is_enum;
#endif #endif
template<class T> template <class T> struct is_reference;
struct is_reference; template <class T> struct is_pod;
template<class T> template <class T> struct has_trivial_constructor;
struct is_pod; template <class T> struct has_trivial_copy;
template<class T> template <class T> struct has_trivial_assign;
struct has_trivial_constructor; template <class T> struct has_trivial_destructor;
template<class T> template <class T> struct remove_const;
struct has_trivial_copy; template <class T> struct remove_volatile;
template<class T> template <class T> struct remove_cv;
struct has_trivial_assign; template <class T> struct remove_reference;
template<class T> template <class T> struct add_reference;
struct has_trivial_destructor; template <class T> struct remove_pointer;
template<class T> template <class T, class U> struct is_same;
struct remove_const;
template<class T>
struct remove_volatile;
template<class T>
struct remove_cv;
template<class T>
struct remove_reference;
template<class T>
struct add_reference;
template<class T>
struct remove_pointer;
template<class T, class U>
struct is_same;
#if !defined(_MSC_VER) && !(defined(__GNUC__) && __GNUC__ <= 3) #if !defined(_MSC_VER) && !(defined(__GNUC__) && __GNUC__ <= 3)
template<class From, class To> template <class From, class To> struct is_convertible;
struct is_convertible;
#endif #endif
// is_integral is false except for the built-in integer types. A // is_integral is false except for the built-in integer types. A
// cv-qualified type is integral if and only if the underlying type is. // cv-qualified type is integral if and only if the underlying type is.
template<class T> template <class T> struct is_integral : false_type { };
struct is_integral : false_type template<> struct is_integral<bool> : true_type { };
{}; template<> struct is_integral<char> : true_type { };
template<> template<> struct is_integral<unsigned char> : true_type { };
struct is_integral<bool> : true_type template<> struct is_integral<signed char> : true_type { };
{};
template<>
struct is_integral<char> : true_type
{};
template<>
struct is_integral<unsigned char> : true_type
{};
template<>
struct is_integral<signed char> : true_type
{};
#if defined(_MSC_VER) #if defined(_MSC_VER)
// wchar_t is not by default a distinct type from unsigned short in // wchar_t is not by default a distinct type from unsigned short in
// Microsoft C. // Microsoft C.
// See http://msdn2.microsoft.com/en-us/library/dh8che7s(VS.80).aspx // See http://msdn2.microsoft.com/en-us/library/dh8che7s(VS.80).aspx
template<> template<> struct is_integral<__wchar_t> : true_type { };
struct is_integral<__wchar_t> : true_type
{};
#else #else
template<> template<> struct is_integral<wchar_t> : true_type { };
struct is_integral<wchar_t> : true_type
{};
#endif #endif
template<> template<> struct is_integral<short> : true_type { };
struct is_integral<short> : true_type template<> struct is_integral<unsigned short> : true_type { };
{}; template<> struct is_integral<int> : true_type { };
template<> template<> struct is_integral<unsigned int> : true_type { };
struct is_integral<unsigned short> : true_type template<> struct is_integral<long> : true_type { };
{}; template<> struct is_integral<unsigned long> : true_type { };
template<>
struct is_integral<int> : true_type
{};
template<>
struct is_integral<unsigned int> : true_type
{};
template<>
struct is_integral<long> : true_type
{};
template<>
struct is_integral<unsigned long> : true_type
{};
#ifdef HAVE_LONG_LONG #ifdef HAVE_LONG_LONG
template<> template<> struct is_integral<long long> : true_type { };
struct is_integral<long long> : true_type template<> struct is_integral<unsigned long long> : true_type { };
{};
template<>
struct is_integral<unsigned long long> : true_type
{};
#endif #endif
template<class T> template <class T> struct is_integral<const T> : is_integral<T> { };
struct is_integral<const T> : is_integral<T> template <class T> struct is_integral<volatile T> : is_integral<T> { };
{}; template <class T> struct is_integral<const volatile T> : is_integral<T> { };
template<class T>
struct is_integral<volatile T> : is_integral<T>
{};
template<class T>
struct is_integral<const volatile T> : is_integral<T>
{};
// is_floating_point is false except for the built-in floating-point types. // is_floating_point is false except for the built-in floating-point types.
// A cv-qualified type is integral if and only if the underlying type is. // A cv-qualified type is integral if and only if the underlying type is.
template<class T> template <class T> struct is_floating_point : false_type { };
struct is_floating_point : false_type template<> struct is_floating_point<float> : true_type { };
{}; template<> struct is_floating_point<double> : true_type { };
template<> template<> struct is_floating_point<long double> : true_type { };
struct is_floating_point<float> : true_type template <class T> struct is_floating_point<const T>
{}; : is_floating_point<T> { };
template<> template <class T> struct is_floating_point<volatile T>
struct is_floating_point<double> : true_type : is_floating_point<T> { };
{}; template <class T> struct is_floating_point<const volatile T>
template<> : is_floating_point<T> { };
struct is_floating_point<long double> : true_type
{};
template<class T>
struct is_floating_point<const T> : is_floating_point<T>
{};
template<class T>
struct is_floating_point<volatile T> : is_floating_point<T>
{};
template<class T>
struct is_floating_point<const volatile T> : is_floating_point<T>
{};
// is_pointer is false except for pointer types. A cv-qualified type (e.g. // is_pointer is false except for pointer types. A cv-qualified type (e.g.
// "int* const", as opposed to "int const*") is cv-qualified if and only if // "int* const", as opposed to "int const*") is cv-qualified if and only if
// the underlying type is. // the underlying type is.
template<class T> template <class T> struct is_pointer : false_type { };
struct is_pointer : false_type template <class T> struct is_pointer<T*> : true_type { };
{}; template <class T> struct is_pointer<const T> : is_pointer<T> { };
template<class T> template <class T> struct is_pointer<volatile T> : is_pointer<T> { };
struct is_pointer<T*> : true_type template <class T> struct is_pointer<const volatile T> : is_pointer<T> { };
{};
template<class T>
struct is_pointer<const T> : is_pointer<T>
{};
template<class T>
struct is_pointer<volatile T> : is_pointer<T>
{};
template<class T>
struct is_pointer<const volatile T> : is_pointer<T>
{};
#if !defined(_MSC_VER) && !(defined(__GNUC__) && __GNUC__ <= 3) #if !defined(_MSC_VER) && !(defined(__GNUC__) && __GNUC__ <= 3)
namespace internal { namespace internal {
template<class T> template <class T> struct is_class_or_union {
struct is_class_or_union template <class U> static small_ tester(void (U::*)());
{ template <class U> static big_ tester(...);
template<class U> static const bool value = sizeof(tester<T>(0)) == sizeof(small_);
static small_ tester(void (U::*)());
template<class U>
static big_ tester(...);
static const bool value = sizeof(tester<T>(0)) == sizeof(small_);
}; };
// is_convertible chokes if the first argument is an array. That's why // is_convertible chokes if the first argument is an array. That's why
// we use add_reference here. // we use add_reference here.
template<bool NotUnum, class T> template <bool NotUnum, class T> struct is_enum_impl
struct is_enum_impl : is_convertible<typename add_reference<T>::type, int> : is_convertible<typename add_reference<T>::type, int> { };
{};
template<class T> template <class T> struct is_enum_impl<true, T> : false_type { };
struct is_enum_impl<true, T> : false_type
{};
} // namespace internal } // namespace internal
// Specified by TR1 [4.5.1] primary type categories. // Specified by TR1 [4.5.1] primary type categories.
@ -256,212 +174,127 @@ struct is_enum_impl<true, T> : false_type
// Is-convertible-to-int check is done only if all other checks pass, // Is-convertible-to-int check is done only if all other checks pass,
// because it can't be used with some types (e.g. void or classes with // because it can't be used with some types (e.g. void or classes with
// inaccessible conversion operators). // inaccessible conversion operators).
template<class T> template <class T> struct is_enum
struct is_enum : internal::is_enum_impl<
: internal::is_enum_impl<is_same<T, void>::value || is_integral<T>::value || is_floating_point<T>::value || is_same<T, void>::value ||
is_reference<T>::value || internal::is_class_or_union<T>::value, is_integral<T>::value ||
T> is_floating_point<T>::value ||
{}; is_reference<T>::value ||
internal::is_class_or_union<T>::value,
T> { };
template<class T> template <class T> struct is_enum<const T> : is_enum<T> { };
struct is_enum<const T> : is_enum<T> template <class T> struct is_enum<volatile T> : is_enum<T> { };
{}; template <class T> struct is_enum<const volatile T> : is_enum<T> { };
template<class T>
struct is_enum<volatile T> : is_enum<T>
{};
template<class T>
struct is_enum<const volatile T> : is_enum<T>
{};
#endif #endif
// is_reference is false except for reference types. // is_reference is false except for reference types.
template<typename T> template<typename T> struct is_reference : false_type {};
struct is_reference : false_type template<typename T> struct is_reference<T&> : true_type {};
{};
template<typename T>
struct is_reference<T&> : true_type
{};
// We can't get is_pod right without compiler help, so fail conservatively. // We can't get is_pod right without compiler help, so fail conservatively.
// We will assume it's false except for arithmetic types, enumerations, // We will assume it's false except for arithmetic types, enumerations,
// pointers and cv-qualified versions thereof. Note that std::pair<T,U> // pointers and cv-qualified versions thereof. Note that std::pair<T,U>
// is not a POD even if T and U are PODs. // is not a POD even if T and U are PODs.
template<class T> template <class T> struct is_pod
struct is_pod : integral_constant<bool, : integral_constant<bool, (is_integral<T>::value ||
(is_integral<T>::value || is_floating_point<T>::value || is_floating_point<T>::value ||
#if !defined(_MSC_VER) && !(defined(__GNUC__) && __GNUC__ <= 3) #if !defined(_MSC_VER) && !(defined(__GNUC__) && __GNUC__ <= 3)
// is_enum is not available on MSVC. // is_enum is not available on MSVC.
is_enum<T>::value || is_enum<T>::value ||
#endif #endif
is_pointer<T>::value)> is_pointer<T>::value)> { };
{}; template <class T> struct is_pod<const T> : is_pod<T> { };
template<class T> template <class T> struct is_pod<volatile T> : is_pod<T> { };
struct is_pod<const T> : is_pod<T> template <class T> struct is_pod<const volatile T> : is_pod<T> { };
{};
template<class T>
struct is_pod<volatile T> : is_pod<T>
{};
template<class T>
struct is_pod<const volatile T> : is_pod<T>
{};
// We can't get has_trivial_constructor right without compiler help, so // We can't get has_trivial_constructor right without compiler help, so
// fail conservatively. We will assume it's false except for: (1) types // fail conservatively. We will assume it's false except for: (1) types
// for which is_pod is true. (2) std::pair of types with trivial // for which is_pod is true. (2) std::pair of types with trivial
// constructors. (3) array of a type with a trivial constructor. // constructors. (3) array of a type with a trivial constructor.
// (4) const versions thereof. // (4) const versions thereof.
template<class T> template <class T> struct has_trivial_constructor : is_pod<T> { };
struct has_trivial_constructor : is_pod<T> template <class T, class U> struct has_trivial_constructor<std::pair<T, U> >
{}; : integral_constant<bool,
template<class T, class U> (has_trivial_constructor<T>::value &&
struct has_trivial_constructor<std::pair<T, U>> has_trivial_constructor<U>::value)> { };
: integral_constant<bool, (has_trivial_constructor<T>::value && has_trivial_constructor<U>::value)> template <class A, int N> struct has_trivial_constructor<A[N]>
{}; : has_trivial_constructor<A> { };
template<class A, int N> template <class T> struct has_trivial_constructor<const T>
struct has_trivial_constructor<A[N]> : has_trivial_constructor<A> : has_trivial_constructor<T> { };
{};
template<class T>
struct has_trivial_constructor<const T> : has_trivial_constructor<T>
{};
// We can't get has_trivial_copy right without compiler help, so fail // We can't get has_trivial_copy right without compiler help, so fail
// conservatively. We will assume it's false except for: (1) types // conservatively. We will assume it's false except for: (1) types
// for which is_pod is true. (2) std::pair of types with trivial copy // for which is_pod is true. (2) std::pair of types with trivial copy
// constructors. (3) array of a type with a trivial copy constructor. // constructors. (3) array of a type with a trivial copy constructor.
// (4) const versions thereof. // (4) const versions thereof.
template<class T> template <class T> struct has_trivial_copy : is_pod<T> { };
struct has_trivial_copy : is_pod<T> template <class T, class U> struct has_trivial_copy<std::pair<T, U> >
{}; : integral_constant<bool,
template<class T, class U> (has_trivial_copy<T>::value &&
struct has_trivial_copy<std::pair<T, U>> has_trivial_copy<U>::value)> { };
: integral_constant<bool, (has_trivial_copy<T>::value && has_trivial_copy<U>::value)> template <class A, int N> struct has_trivial_copy<A[N]>
{}; : has_trivial_copy<A> { };
template<class A, int N> template <class T> struct has_trivial_copy<const T> : has_trivial_copy<T> { };
struct has_trivial_copy<A[N]> : has_trivial_copy<A>
{};
template<class T>
struct has_trivial_copy<const T> : has_trivial_copy<T>
{};
// We can't get has_trivial_assign right without compiler help, so fail // We can't get has_trivial_assign right without compiler help, so fail
// conservatively. We will assume it's false except for: (1) types // conservatively. We will assume it's false except for: (1) types
// for which is_pod is true. (2) std::pair of types with trivial copy // for which is_pod is true. (2) std::pair of types with trivial copy
// constructors. (3) array of a type with a trivial assign constructor. // constructors. (3) array of a type with a trivial assign constructor.
template<class T> template <class T> struct has_trivial_assign : is_pod<T> { };
struct has_trivial_assign : is_pod<T> template <class T, class U> struct has_trivial_assign<std::pair<T, U> >
{}; : integral_constant<bool,
template<class T, class U> (has_trivial_assign<T>::value &&
struct has_trivial_assign<std::pair<T, U>> has_trivial_assign<U>::value)> { };
: integral_constant<bool, (has_trivial_assign<T>::value && has_trivial_assign<U>::value)> template <class A, int N> struct has_trivial_assign<A[N]>
{}; : has_trivial_assign<A> { };
template<class A, int N>
struct has_trivial_assign<A[N]> : has_trivial_assign<A>
{};
// We can't get has_trivial_destructor right without compiler help, so // We can't get has_trivial_destructor right without compiler help, so
// fail conservatively. We will assume it's false except for: (1) types // fail conservatively. We will assume it's false except for: (1) types
// for which is_pod is true. (2) std::pair of types with trivial // for which is_pod is true. (2) std::pair of types with trivial
// destructors. (3) array of a type with a trivial destructor. // destructors. (3) array of a type with a trivial destructor.
// (4) const versions thereof. // (4) const versions thereof.
template<class T> template <class T> struct has_trivial_destructor : is_pod<T> { };
struct has_trivial_destructor : is_pod<T> template <class T, class U> struct has_trivial_destructor<std::pair<T, U> >
{}; : integral_constant<bool,
template<class T, class U> (has_trivial_destructor<T>::value &&
struct has_trivial_destructor<std::pair<T, U>> has_trivial_destructor<U>::value)> { };
: integral_constant<bool, (has_trivial_destructor<T>::value && has_trivial_destructor<U>::value)> template <class A, int N> struct has_trivial_destructor<A[N]>
{}; : has_trivial_destructor<A> { };
template<class A, int N> template <class T> struct has_trivial_destructor<const T>
struct has_trivial_destructor<A[N]> : has_trivial_destructor<A> : has_trivial_destructor<T> { };
{};
template<class T>
struct has_trivial_destructor<const T> : has_trivial_destructor<T>
{};
// Specified by TR1 [4.7.1] // Specified by TR1 [4.7.1]
template<typename T> template<typename T> struct remove_const { typedef T type; };
struct remove_const template<typename T> struct remove_const<T const> { typedef T type; };
{ template<typename T> struct remove_volatile { typedef T type; };
typedef T type; template<typename T> struct remove_volatile<T volatile> { typedef T type; };
}; template<typename T> struct remove_cv {
template<typename T> typedef typename remove_const<typename remove_volatile<T>::type>::type type;
struct remove_const<T const>
{
typedef T type;
};
template<typename T>
struct remove_volatile
{
typedef T type;
};
template<typename T>
struct remove_volatile<T volatile>
{
typedef T type;
};
template<typename T>
struct remove_cv
{
typedef typename remove_const<typename remove_volatile<T>::type>::type type;
}; };
// Specified by TR1 [4.7.2] Reference modifications. // Specified by TR1 [4.7.2] Reference modifications.
template<typename T> template<typename T> struct remove_reference { typedef T type; };
struct remove_reference template<typename T> struct remove_reference<T&> { typedef T type; };
{
typedef T type;
};
template<typename T>
struct remove_reference<T&>
{
typedef T type;
};
template<typename T> template <typename T> struct add_reference { typedef T& type; };
struct add_reference template <typename T> struct add_reference<T&> { typedef T& type; };
{
typedef T& type;
};
template<typename T>
struct add_reference<T&>
{
typedef T& type;
};
// Specified by TR1 [4.7.4] Pointer modifications. // Specified by TR1 [4.7.4] Pointer modifications.
template<typename T> template<typename T> struct remove_pointer { typedef T type; };
struct remove_pointer template<typename T> struct remove_pointer<T*> { typedef T type; };
{ template<typename T> struct remove_pointer<T* const> { typedef T type; };
typedef T type; template<typename T> struct remove_pointer<T* volatile> { typedef T type; };
}; template<typename T> struct remove_pointer<T* const volatile> {
template<typename T> typedef T type; };
struct remove_pointer<T*>
{
typedef T type;
};
template<typename T>
struct remove_pointer<T* const>
{
typedef T type;
};
template<typename T>
struct remove_pointer<T* volatile>
{
typedef T type;
};
template<typename T>
struct remove_pointer<T* const volatile>
{
typedef T type;
};
// Specified by TR1 [4.6] Relationships between types // Specified by TR1 [4.6] Relationships between types
template<typename T, typename U> template<typename T, typename U> struct is_same : public false_type { };
struct is_same : public false_type template<typename T> struct is_same<T, T> : public true_type { };
{};
template<typename T>
struct is_same<T, T> : public true_type
{};
// Specified by TR1 [4.6] Relationships between types // Specified by TR1 [4.6] Relationships between types
#if !defined(_MSC_VER) && !(defined(__GNUC__) && __GNUC__ <= 3) #if !defined(_MSC_VER) && !(defined(__GNUC__) && __GNUC__ <= 3)
@ -476,22 +309,22 @@ namespace internal {
// had called it with an argument of type From. See Alexandrescu's // had called it with an argument of type From. See Alexandrescu's
// _Modern C++ Design_ for more details on this sort of trick. // _Modern C++ Design_ for more details on this sort of trick.
template<typename From, typename To> template <typename From, typename To>
struct ConvertHelper struct ConvertHelper {
{ static small_ Test(To);
static small_ Test(To); static big_ Test(...);
static big_ Test(...); static From Create();
static From Create();
}; };
} // namespace internal } // namespace internal
// Inherits from true_type if From is convertible to To, false_type otherwise. // Inherits from true_type if From is convertible to To, false_type otherwise.
template<typename From, typename To> template <typename From, typename To>
struct is_convertible struct is_convertible
: integral_constant<bool, : integral_constant<bool,
sizeof(internal::ConvertHelper<From, To>::Test(internal::ConvertHelper<From, To>::Create())) == sizeof(internal::ConvertHelper<From, To>::Test(
sizeof(small_)> internal::ConvertHelper<From, To>::Create()))
{}; == sizeof(small_)> {
};
#endif #endif
_END_GOOGLE_NAMESPACE_ _END_GOOGLE_NAMESPACE_
@ -500,10 +333,10 @@ _END_GOOGLE_NAMESPACE_
// these types are PODs, for human use. They may be made more contentful // these types are PODs, for human use. They may be made more contentful
// later. The typedef is just to make it legal to put a semicolon after // later. The typedef is just to make it legal to put a semicolon after
// these macros. // these macros.
#define DECLARE_POD(TypeName) typedef int Dummy_Type_For_DECLARE_POD #define DECLARE_POD(TypeName) typedef int Dummy_Type_For_DECLARE_POD
#define DECLARE_NESTED_POD(TypeName) DECLARE_POD(TypeName) #define DECLARE_NESTED_POD(TypeName) DECLARE_POD(TypeName)
#define PROPAGATE_POD_FROM_TEMPLATE_ARGUMENT(TemplateName) \ #define PROPAGATE_POD_FROM_TEMPLATE_ARGUMENT(TemplateName) \
typedef int Dummy_Type_For_PROPAGATE_POD_FROM_TEMPLATE_ARGUMENT typedef int Dummy_Type_For_PROPAGATE_POD_FROM_TEMPLATE_ARGUMENT
#define ENFORCE_POD(TypeName) typedef int Dummy_Type_For_ENFORCE_POD #define ENFORCE_POD(TypeName) typedef int Dummy_Type_For_ENFORCE_POD
#endif // BASE_TYPE_TRAITS_H_ #endif // BASE_TYPE_TRAITS_H_

View file

@ -4,8 +4,6 @@
#include <mapnik/util/math.hpp> #include <mapnik/util/math.hpp>
#include <mapnik/warning.hpp> #include <mapnik/warning.hpp>
#include <mapnik/symbolizer_enumerations.hpp>
#include <mapnik/util/variant.hpp>
MAPNIK_DISABLE_WARNING_PUSH MAPNIK_DISABLE_WARNING_PUSH
#include <mapnik/warning_ignore_agg.hpp> #include <mapnik/warning_ignore_agg.hpp>
#include "agg_conv_smooth_poly1.h" #include "agg_conv_smooth_poly1.h"
@ -82,9 +80,9 @@ class smooth_converter
{ {
switch (algo) switch (algo)
{ {
case smooth_algorithm_enum::SMOOTH_ALGORITHM_ADAPTIVE: case SMOOTH_ALGORITHM_ADAPTIVE:
return adaptive_impl_type(geom); return adaptive_impl_type(geom);
case smooth_algorithm_enum::SMOOTH_ALGORITHM_BASIC: case SMOOTH_ALGORITHM_BASIC:
default: default:
break; break;
} }
@ -94,7 +92,7 @@ class smooth_converter
public: public:
smooth_converter(Geometry& geom) smooth_converter(Geometry& geom)
: geom_(geom) : geom_(geom)
, impl_(std::move(init_impl(smooth_algorithm_enum::SMOOTH_ALGORITHM_BASIC, geom))) , impl_(std::move(init_impl(SMOOTH_ALGORITHM_BASIC, geom)))
{} {}
void algorithm(smooth_algorithm_enum algo) { impl_ = init_impl(algo, geom_); } void algorithm(smooth_algorithm_enum algo) { impl_ = init_impl(algo, geom_); }

View file

@ -2,7 +2,7 @@
* *
* This file is part of Mapnik (c++ mapping toolkit) * This file is part of Mapnik (c++ mapping toolkit)
* *
* Copyright (C) 2024 Artem Pavlenko * Copyright (C) 2021 Artem Pavlenko
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public

View file

@ -2,7 +2,7 @@
* *
* This file is part of Mapnik (c++ mapping toolkit) * This file is part of Mapnik (c++ mapping toolkit)
* *
* Copyright (C) 2024 Artem Pavlenko * Copyright (C) 2021 Artem Pavlenko
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -39,19 +39,19 @@ void set_gamma_method(T& ras_ptr, double gamma, gamma_method_enum method)
{ {
switch (method) switch (method)
{ {
case gamma_method_enum::GAMMA_POWER: case GAMMA_POWER:
ras_ptr->gamma(agg::gamma_power(gamma)); ras_ptr->gamma(agg::gamma_power(gamma));
break; break;
case gamma_method_enum::GAMMA_LINEAR: case GAMMA_LINEAR:
ras_ptr->gamma(agg::gamma_linear(0.0, gamma)); ras_ptr->gamma(agg::gamma_linear(0.0, gamma));
break; break;
case gamma_method_enum::GAMMA_NONE: case GAMMA_NONE:
ras_ptr->gamma(agg::gamma_none()); ras_ptr->gamma(agg::gamma_none());
break; break;
case gamma_method_enum::GAMMA_THRESHOLD: case GAMMA_THRESHOLD:
ras_ptr->gamma(agg::gamma_threshold(gamma)); ras_ptr->gamma(agg::gamma_threshold(gamma));
break; break;
case gamma_method_enum::GAMMA_MULTIPLY: case GAMMA_MULTIPLY:
ras_ptr->gamma(agg::gamma_multiply(gamma)); ras_ptr->gamma(agg::gamma_multiply(gamma));
break; break;
default: default:

View file

@ -2,7 +2,7 @@
* *
* This file is part of Mapnik (c++ mapping toolkit) * This file is part of Mapnik (c++ mapping toolkit)
* *
* Copyright (C) 2024 Artem Pavlenko * Copyright (C) 2021 Artem Pavlenko
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public

View file

@ -2,7 +2,7 @@
* *
* This file is part of Mapnik (c++ mapping toolkit) * This file is part of Mapnik (c++ mapping toolkit)
* *
* Copyright (C) 2024 Artem Pavlenko * Copyright (C) 2021 Artem Pavlenko
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public

View file

@ -2,7 +2,7 @@
* *
* This file is part of Mapnik (c++ mapping toolkit) * This file is part of Mapnik (c++ mapping toolkit)
* *
* Copyright (C) 2024 Artem Pavlenko * Copyright (C) 2021 Artem Pavlenko
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public

View file

@ -2,7 +2,7 @@
* *
* This file is part of Mapnik (c++ mapping toolkit) * This file is part of Mapnik (c++ mapping toolkit)
* *
* Copyright (C) 2024 Artem Pavlenko * Copyright (C) 2021 Artem Pavlenko
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -92,7 +92,7 @@ class buffer_stack
void pop() void pop()
{ {
// ^ ensure iterator is not out-of-range // ^ ensure irator is not out-of-range
// prior calling this method // prior calling this method
++position_; ++position_;
} }

View file

@ -2,7 +2,7 @@
* *
* This file is part of Mapnik (c++ mapping toolkit) * This file is part of Mapnik (c++ mapping toolkit)
* *
* Copyright (C) 2024 Artem Pavlenko * Copyright (C) 2021 Artem Pavlenko
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public

View file

@ -2,7 +2,7 @@
* *
* This file is part of Mapnik (c++ mapping toolkit) * This file is part of Mapnik (c++ mapping toolkit)
* *
* Copyright (C) 2024 Artem Pavlenko * Copyright (C) 2021 Artem Pavlenko
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -175,14 +175,14 @@ struct symbolizer_attributes
void operator()(raster_symbolizer const& sym) void operator()(raster_symbolizer const& sym)
{ {
const auto filter_factor = get_optional<double>(sym, keys::filter_factor); boost::optional<double> filter_factor = get_optional<double>(sym, keys::filter_factor);
if (filter_factor) if (filter_factor)
{ {
filter_factor_ = *filter_factor; filter_factor_ = *filter_factor;
} }
else else
{ {
const auto scaling_method = get_optional<scaling_method_e>(sym, keys::scaling); boost::optional<scaling_method_e> scaling_method = get_optional<scaling_method_e>(sym, keys::scaling);
if (scaling_method && *scaling_method != SCALING_NEAR) if (scaling_method && *scaling_method != SCALING_NEAR)
{ {
filter_factor_ = 2; filter_factor_ = 2;

View file

@ -2,7 +2,7 @@
* *
* This file is part of Mapnik (c++ mapping toolkit) * This file is part of Mapnik (c++ mapping toolkit)
* *
* Copyright (C) 2024 Artem Pavlenko * Copyright (C) 2021 Artem Pavlenko
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public

View file

@ -2,7 +2,7 @@
* *
* This file is part of Mapnik (c++ mapping toolkit) * This file is part of Mapnik (c++ mapping toolkit)
* *
* Copyright (C) 2024 Artem Pavlenko * Copyright (C) 2021 Artem Pavlenko
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public

View file

@ -2,7 +2,7 @@
* *
* This file is part of Mapnik (c++ mapping toolkit) * This file is part of Mapnik (c++ mapping toolkit)
* *
* Copyright (C) 2024 Artem Pavlenko * Copyright (C) 2021 Artem Pavlenko
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public

View file

@ -2,7 +2,7 @@
* *
* This file is part of Mapnik (c++ mapping toolkit) * This file is part of Mapnik (c++ mapping toolkit)
* *
* Copyright (C) 2024 Artem Pavlenko * Copyright (C) 2021 Artem Pavlenko
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public

View file

@ -2,7 +2,7 @@
* *
* This file is part of Mapnik (c++ mapping toolkit) * This file is part of Mapnik (c++ mapping toolkit)
* *
* Copyright (C) 2024 Artem Pavlenko * Copyright (C) 2021 Artem Pavlenko
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public

View file

@ -2,7 +2,7 @@
* *
* This file is part of Mapnik (c++ mapping toolkit) * This file is part of Mapnik (c++ mapping toolkit)
* *
* Copyright (C) 2024 Artem Pavlenko * Copyright (C) 2021 Artem Pavlenko
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -34,7 +34,7 @@ class cairo_context;
void render_vector_marker(cairo_context& context, void render_vector_marker(cairo_context& context,
svg_path_adapter& svg_path, svg_path_adapter& svg_path,
svg::group const& group_attr, svg_attribute_type const& attributes,
box2d<double> const& bbox, box2d<double> const& bbox,
agg::trans_affine const& tr, agg::trans_affine const& tr,
double opacity); double opacity);

View file

@ -2,7 +2,7 @@
* *
* This file is part of Mapnik (c++ mapping toolkit) * This file is part of Mapnik (c++ mapping toolkit)
* *
* Copyright (C) 2024 Artem Pavlenko * Copyright (C) 2021 Artem Pavlenko
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public

View file

@ -2,7 +2,7 @@
* *
* This file is part of Mapnik (c++ mapping toolkit) * This file is part of Mapnik (c++ mapping toolkit)
* *
* Copyright (C) 2024 Artem Pavlenko * Copyright (C) 2021 Artem Pavlenko
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -56,11 +56,11 @@ struct cairo_renderer_process_visitor_p
cairo_context context(cairo); cairo_context context(cairo);
svg_storage_type& svg = *marker.get_data(); svg_storage_type& svg = *marker.get_data();
auto const& svg_group = svg.svg_group(); svg_attribute_type const& svg_attributes = svg.attributes();
svg::vertex_stl_adapter<svg::svg_path_storage> stl_storage(svg.source()); svg::vertex_stl_adapter<svg::svg_path_storage> stl_storage(svg.source());
svg::svg_path_adapter svg_path(stl_storage); svg::svg_path_adapter svg_path(stl_storage);
render_vector_marker(context, svg_path, svg_group, bbox, tr, opacity_); render_vector_marker(context, svg_path, svg_attributes, bbox, tr, opacity_);
return surface; return surface;
} }

Some files were not shown because too many files have changed in this diff Show more