Merge branch 'master' of https://github.com/mapnik/mapnik into feature/cmake-static
This commit is contained in:
commit
8a1f2579e9
819 changed files with 37753 additions and 37964 deletions
94
.clang-format
Normal file
94
.clang-format
Normal file
|
@ -0,0 +1,94 @@
|
|||
Language: Cpp
|
||||
AccessModifierOffset: -2
|
||||
AlignAfterOpenBracket: Align
|
||||
AlignArrayOfStructures: None
|
||||
AlignConsecutiveAssignments: None
|
||||
AlignConsecutiveDeclarations: None
|
||||
AlignConsecutiveMacros: Consecutive
|
||||
AlignEscapedNewlines: Right
|
||||
AlignOperands: Align
|
||||
AlignTrailingComments: true
|
||||
AllowAllArgumentsOnNextLine: false
|
||||
AllowAllParametersOfDeclarationOnNextLine: false
|
||||
AllowShortBlocksOnASingleLine: Empty
|
||||
AllowShortCaseLabelsOnASingleLine: false
|
||||
AllowShortEnumsOnASingleLine: true
|
||||
AllowShortFunctionsOnASingleLine: Inline
|
||||
AllowShortIfStatementsOnASingleLine: Never
|
||||
AllowShortLambdasOnASingleLine: Inline
|
||||
# AlwaysBreakAfterReturnType:
|
||||
AlwaysBreakBeforeMultilineStrings: false
|
||||
AlwaysBreakTemplateDeclarations: Yes
|
||||
BinPackArguments: false
|
||||
BitFieldColonSpacing: After
|
||||
BreakBeforeBraces: Custom
|
||||
BraceWrapping:
|
||||
AfterCaseLabel: false
|
||||
AfterClass: true
|
||||
AfterControlStatement: Always
|
||||
AfterEnum: false # see AllowShortEnumsOnASingleLine
|
||||
AfterFunction: true # see AllowShortFunctionsOnASingleLine
|
||||
AfterNamespace: false
|
||||
AfterStruct: true
|
||||
AfterExternBlock: true
|
||||
BeforeCatch: false
|
||||
BeforeElse: true
|
||||
BeforeLambdaBody: false
|
||||
BeforeWhile: false
|
||||
SplitEmptyFunction: false
|
||||
SplitEmptyRecord: false
|
||||
SplitEmptyNamespace: false
|
||||
BreakBeforeBinaryOperators: None
|
||||
BreakBeforeConceptDeclarations: false
|
||||
BreakBeforeTernaryOperators: true
|
||||
BreakConstructorInitializers: BeforeComma
|
||||
BreakInheritanceList: AfterComma
|
||||
BreakStringLiterals: true
|
||||
ColumnLimit: 120
|
||||
CompactNamespaces: false
|
||||
ContinuationIndentWidth: 2
|
||||
Cpp11BracedListStyle: true
|
||||
DeriveLineEnding: true
|
||||
EmptyLineAfterAccessModifier: Leave
|
||||
EmptyLineBeforeAccessModifier: LogicalBlock
|
||||
FixNamespaceComments: true
|
||||
IncludeBlocks: Preserve
|
||||
IndentCaseBlocks: false
|
||||
IndentCaseLabels: true
|
||||
IndentExternBlock: NoIndent
|
||||
IndentPPDirectives: None
|
||||
IndentRequires: true
|
||||
IndentWidth: 4
|
||||
IndentWrappedFunctionNames: true
|
||||
KeepEmptyLinesAtTheStartOfBlocks: false
|
||||
LambdaBodyIndentation: Signature
|
||||
MaxEmptyLinesToKeep: 1
|
||||
NamespaceIndentation: None
|
||||
# PackConstructorInitializers: CurrentLine # only clang-format > 14
|
||||
PointerAlignment: Left
|
||||
#QualifierAlignment: Left # only clang-format > 14
|
||||
ReferenceAlignment: Left
|
||||
ReflowComments: true
|
||||
SortIncludes: Never
|
||||
SpaceAfterLogicalNot: false
|
||||
SpaceAfterTemplateKeyword: false
|
||||
SpaceBeforeInheritanceColon: true
|
||||
Standard: c++14
|
||||
BinPackParameters: false
|
||||
BreakBeforeInheritanceComma: false
|
||||
IncludeCategories:
|
||||
# Headers in <> without extension.
|
||||
- Regex: '<([A-Za-z0-9\Q/-_\E])+>'
|
||||
Priority: 1
|
||||
# Headers in <> from specific external libraries.
|
||||
- Regex: '<(boost)\/'
|
||||
Priority: 2
|
||||
# Headers in <> from specific external libraries.
|
||||
- Regex: '<(mapnik)\/'
|
||||
Priority: 3
|
||||
# Headers in <> with extension.
|
||||
- Regex: '<([A-Za-z0-9.\Q/-_\E])+>'
|
||||
Priority: 4
|
||||
# Headers in "" with extension.
|
||||
- Regex: '"([A-Za-z0-9.\Q/-_\E])+"'
|
||||
Priority: 5
|
76
.github/workflows/build_test.yml
vendored
Normal file
76
.github/workflows/build_test.yml
vendored
Normal 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 }}
|
125
.github/workflows/macos.yml
vendored
Normal file
125
.github/workflows/macos.yml
vendored
Normal file
|
@ -0,0 +1,125 @@
|
|||
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/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"
|
||||
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"
|
||||
shell: "bash"
|
||||
run: >
|
||||
${{ env.mono }} `./vcpkg/vcpkg fetch nuget | tail -n 1`
|
||||
setapikey "${{ secrets.NUGET_REGISTRY_PAT }}" -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
|
141
.github/workflows/ubuntu.yml
vendored
Normal file
141
.github/workflows/ubuntu.yml
vendored
Normal file
|
@ -0,0 +1,141 @@
|
|||
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/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"
|
||||
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"
|
||||
shell: "bash"
|
||||
run: >
|
||||
${{ env.mono }} `./vcpkg/vcpkg fetch nuget | tail -n 1`
|
||||
setapikey "${{ secrets.NUGET_REGISTRY_PAT }}" -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
|
114
.github/workflows/windows.yml
vendored
Normal file
114
.github/workflows/windows.yml
vendored
Normal file
|
@ -0,0 +1,114 @@
|
|||
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"
|
||||
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"
|
||||
shell: "bash"
|
||||
run: >
|
||||
`./vcpkg/vcpkg fetch nuget | tail -n 1`
|
||||
setapikey "${{ secrets.NUGET_REGISTRY_PAT }}" -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
|
|
@ -173,6 +173,60 @@
|
|||
"windows-default",
|
||||
"release-build"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "ci-options",
|
||||
"hidden": true,
|
||||
"cacheVariables": {
|
||||
"BUILD_TESTING": "ON",
|
||||
"BUILD_DEMO_VIEWER": "OFF"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "windows-ci",
|
||||
"description": "used by the ci pipeline",
|
||||
"inherits": [
|
||||
"windows-release",
|
||||
"ci-options"
|
||||
],
|
||||
"cacheVariables": {
|
||||
"INSTALL_DEPENDENCIES": "ON",
|
||||
"ADDITIONAL_LIBARIES_PATHS": "${sourceDir}/build/${presetName}/vcpkg_installed/x64-windows/bin"
|
||||
},
|
||||
"environment": {
|
||||
"PROJ_LIB": "${sourceDir}/build/${presetName}/vcpkg_installed/x64-windows/share/proj4"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "linux-ci",
|
||||
"description": "used by the ci pipeline",
|
||||
"inherits": [
|
||||
"release-with-debug-build",
|
||||
"use-gcc",
|
||||
"ci-options"
|
||||
],
|
||||
"cacheVariables": {
|
||||
"CMAKE_CXX_FLAGS": "--coverage"
|
||||
},
|
||||
"environment": {
|
||||
"PROJ_LIB": "${sourceDir}/build/${presetName}/vcpkg_installed/x64-linux/share/proj4"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "macos-ci",
|
||||
"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/${presetName}/vcpkg_installed/x64-osx/share/proj4"
|
||||
}
|
||||
}
|
||||
],
|
||||
"buildPresets": [
|
||||
|
@ -199,6 +253,18 @@
|
|||
{
|
||||
"name": "linux-gcc-release",
|
||||
"configurePreset": "linux-gcc-release"
|
||||
},
|
||||
{
|
||||
"name": "windows-ci",
|
||||
"configurePreset": "windows-ci"
|
||||
},
|
||||
{
|
||||
"name": "linux-ci",
|
||||
"configurePreset": "linux-ci"
|
||||
},
|
||||
{
|
||||
"name": "macos-ci",
|
||||
"configurePreset": "macos-ci"
|
||||
}
|
||||
],
|
||||
"testPresets": [
|
||||
|
@ -212,6 +278,27 @@
|
|||
"noTestsAction": "error",
|
||||
"stopOnFailure": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "windows-ci",
|
||||
"configurePreset": "windows-ci",
|
||||
"inherits": [
|
||||
"test-default"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "linux-ci",
|
||||
"configurePreset": "linux-ci",
|
||||
"inherits": [
|
||||
"test-default"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "macos-ci",
|
||||
"configurePreset": "macos-ci",
|
||||
"inherits": [
|
||||
"test-default"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -34,24 +34,16 @@ protected:
|
|||
mapnik::parameters params_;
|
||||
std::size_t threads_;
|
||||
std::size_t iterations_;
|
||||
|
||||
public:
|
||||
test_case(mapnik::parameters const& params)
|
||||
: params_(params),
|
||||
threads_(mapnik::safe_cast<std::size_t>(*params.get<mapnik::value_integer>("threads", 0))),
|
||||
iterations_(mapnik::safe_cast<std::size_t>(*params.get<mapnik::value_integer>("iterations", 0)))
|
||||
: params_(params)
|
||||
, threads_(mapnik::safe_cast<std::size_t>(*params.get<mapnik::value_integer>("threads", 0)))
|
||||
, iterations_(mapnik::safe_cast<std::size_t>(*params.get<mapnik::value_integer>("iterations", 0)))
|
||||
{}
|
||||
std::size_t threads() const
|
||||
{
|
||||
return threads_;
|
||||
}
|
||||
std::size_t iterations() const
|
||||
{
|
||||
return iterations_;
|
||||
}
|
||||
mapnik::parameters const& params() const
|
||||
{
|
||||
return params_;
|
||||
}
|
||||
std::size_t threads() const { return threads_; }
|
||||
std::size_t iterations() const { return iterations_; }
|
||||
mapnik::parameters const& params() const { return params_; }
|
||||
virtual bool validate() const = 0;
|
||||
virtual bool operator()() const = 0;
|
||||
};
|
||||
|
@ -61,19 +53,23 @@ public:
|
|||
// or negated index of an ill-formed option argument
|
||||
inline int parse_args(int argc, char** argv, mapnik::parameters& params)
|
||||
{
|
||||
for (int i = 1; i < argc; ++i) {
|
||||
for (int i = 1; i < argc; ++i)
|
||||
{
|
||||
const char* opt = argv[i];
|
||||
if (opt[0] != '-') {
|
||||
if (opt[0] != '-')
|
||||
{
|
||||
// non-option argument, return its index
|
||||
return i;
|
||||
}
|
||||
if (opt[1] != '-') {
|
||||
if (opt[1] != '-')
|
||||
{
|
||||
// we only accept --long-options, but instead of throwing,
|
||||
// just issue a warning and let the caller decide what to do
|
||||
std::clog << argv[0] << ": invalid option '" << opt << "'\n";
|
||||
return -i; // negative means ill-formed option #i
|
||||
}
|
||||
if (opt[2] == '\0') {
|
||||
if (opt[2] == '\0')
|
||||
{
|
||||
// option-list terminator '--'
|
||||
return i + 1;
|
||||
}
|
||||
|
@ -81,15 +77,18 @@ inline int parse_args(int argc, char** argv, mapnik::parameters & params)
|
|||
// take option name without the leading '--'
|
||||
std::string key(opt + 2);
|
||||
size_t eq = key.find('=');
|
||||
if (eq != std::string::npos) {
|
||||
if (eq != std::string::npos)
|
||||
{
|
||||
// one-argument form '--foo=bar'
|
||||
params[key.substr(0, eq)] = key.substr(eq + 1);
|
||||
}
|
||||
else if (i + 1 < argc) {
|
||||
else if (i + 1 < argc)
|
||||
{
|
||||
// two-argument form '--foo' 'bar'
|
||||
params[key] = std::string(argv[++i]);
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
// missing second argument
|
||||
std::clog << argv[0] << ": missing option '" << opt << "' value\n";
|
||||
return -i; // negative means ill-formed option #i
|
||||
|
@ -100,7 +99,8 @@ inline int parse_args(int argc, char** argv, mapnik::parameters & params)
|
|||
|
||||
inline void handle_common_args(mapnik::parameters const& params)
|
||||
{
|
||||
if (auto severity = params.get<std::string>("log")) {
|
||||
if (auto severity = params.get<std::string>("log"))
|
||||
{
|
||||
if (*severity == "debug")
|
||||
mapnik::logger::set_severity(mapnik::logger::debug);
|
||||
else if (*severity == "warn")
|
||||
|
@ -110,8 +110,7 @@ inline void handle_common_args(mapnik::parameters const& params)
|
|||
else if (*severity == "none")
|
||||
mapnik::logger::set_severity(mapnik::logger::none);
|
||||
else
|
||||
std::clog << "ignoring option --log='" << *severity
|
||||
<< "' (allowed values are: debug, warn, error, none)\n";
|
||||
std::clog << "ignoring option --log='" << *severity << "' (allowed values are: debug, warn, error, none)\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -133,14 +132,13 @@ inline int handle_args(int argc, char** argv, mapnik::parameters & params)
|
|||
auto result = run(test_runner, name); \
|
||||
testing::run_cleanup(); \
|
||||
return result; \
|
||||
} \
|
||||
catch (std::exception const& ex) \
|
||||
} catch (std::exception const& ex) \
|
||||
{ \
|
||||
std::clog << ex.what() << "\n"; \
|
||||
testing::run_cleanup(); \
|
||||
return -1; \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
struct big_number_fmt
|
||||
{
|
||||
|
@ -149,7 +147,9 @@ struct big_number_fmt
|
|||
const char* u;
|
||||
|
||||
big_number_fmt(int width, double value, int base = 1000)
|
||||
: w(width), v(value), u("")
|
||||
: w(width)
|
||||
, v(value)
|
||||
, u("")
|
||||
{
|
||||
static const char* suffixes = "\0\0k\0M\0G\0T\0P\0E\0Z\0Y\0\0";
|
||||
u = suffixes;
|
||||
|
@ -196,8 +196,7 @@ int run(T const& test_runner, std::string const& name)
|
|||
std::mutex mtx_ready;
|
||||
std::unique_lock<std::mutex> lock_ready(mtx_ready);
|
||||
|
||||
auto stub = [&](T const& test_copy)
|
||||
{
|
||||
auto stub = [&](T const& test_copy) {
|
||||
// workers will wait on this mutex until the main thread
|
||||
// constructs all of them and starts measuring time
|
||||
std::unique_lock<std::mutex> my_lock(mtx_ready);
|
||||
|
@ -228,7 +227,8 @@ int run(T const& test_runner, std::string const& name)
|
|||
else
|
||||
{
|
||||
start = std::chrono::high_resolution_clock::now();
|
||||
do {
|
||||
do
|
||||
{
|
||||
test_runner();
|
||||
elapsed = std::chrono::high_resolution_clock::now() - start;
|
||||
total_iters += num_iters;
|
||||
|
@ -243,21 +243,27 @@ int run(T const& test_runner, std::string const& name)
|
|||
|
||||
std::clog << std::left << std::setw(43) << name;
|
||||
std::clog << std::resetiosflags(std::ios::adjustfield);
|
||||
if (num_threads > 0) {
|
||||
std::clog << ' ' << std::setw(3) << num_threads
|
||||
<< " worker" << (num_threads > 1 ? "s" : " ");
|
||||
if (num_threads > 0)
|
||||
{
|
||||
std::clog << ' ' << std::setw(3) << num_threads << " worker" << (num_threads > 1 ? "s" : " ");
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
std::clog << " main thread";
|
||||
}
|
||||
std::snprintf(msg, sizeof(msg),
|
||||
std::snprintf(msg,
|
||||
sizeof(msg),
|
||||
" %*.0f%s iters %6.0f milliseconds %*.0f%s i/t/s\n",
|
||||
itersf.w, itersf.v, itersf.u, dur_total,
|
||||
ips.w, ips.v, ips.u);
|
||||
itersf.w,
|
||||
itersf.v,
|
||||
itersf.u,
|
||||
dur_total,
|
||||
ips.w,
|
||||
ips.v,
|
||||
ips.u);
|
||||
std::clog << msg;
|
||||
return 0;
|
||||
}
|
||||
catch (std::exception const& ex)
|
||||
} catch (std::exception const& ex)
|
||||
{
|
||||
std::clog << "test runner did not complete: " << ex.what() << "\n";
|
||||
return 4;
|
||||
|
@ -272,10 +278,7 @@ struct sequencer
|
|||
benchmark::handle_args(argc, argv, params_);
|
||||
}
|
||||
|
||||
int done() const
|
||||
{
|
||||
return exit_code_;
|
||||
}
|
||||
int done() const { return exit_code_; }
|
||||
|
||||
template<typename Test, typename... Args>
|
||||
sequencer& run(std::string const& name, Args&&... args)
|
||||
|
@ -292,6 +295,6 @@ protected:
|
|||
int exit_code_;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace benchmark
|
||||
|
||||
#endif // MAPNIK_BENCH_FRAMEWORK_HPP
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
#include <mapnik/image_util.hpp>
|
||||
#include <mapnik/image_reader.hpp>
|
||||
|
||||
|
||||
namespace benchmark {
|
||||
|
||||
bool compare_images(std::string const& src_fn, std::string const& dest_fn)
|
||||
|
@ -31,6 +30,6 @@ namespace benchmark {
|
|||
return compare(dest, src, 0, true) == 0;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace benchmark
|
||||
|
||||
#endif // MAPNIK_COMPARE_IMAGES_HPP
|
||||
|
|
|
@ -9,7 +9,10 @@ struct bench_func : benchmark::test_case
|
|||
T const value_;
|
||||
|
||||
bench_func(mapnik::parameters const& params, T (*func)(T), T value)
|
||||
: test_case(params), func_(func), value_(value) {}
|
||||
: test_case(params)
|
||||
, func_(func)
|
||||
, value_(value)
|
||||
{}
|
||||
|
||||
bool validate() const { return true; }
|
||||
|
||||
|
@ -23,8 +26,7 @@ struct bench_func : benchmark::test_case
|
|||
}
|
||||
};
|
||||
|
||||
#define BENCH_FUNC1(func, value) \
|
||||
run<bench_func<double>>(#func "(" #value ")", func, value)
|
||||
#define BENCH_FUNC1(func, value) run<bench_func<double>>(#func "(" #value ")", func, value)
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
|
|
|
@ -14,15 +14,19 @@
|
|||
|
||||
#define FULL_ZERO_CHECK
|
||||
|
||||
inline void ensure_zero(uint8_t * data, uint32_t size) {
|
||||
inline void ensure_zero(uint8_t* data, uint32_t size)
|
||||
{
|
||||
#ifdef FULL_ZERO_CHECK
|
||||
for (std::size_t i=0;i<size;++i) {
|
||||
if (data[i] != 0) {
|
||||
for (std::size_t i = 0; i < size; ++i)
|
||||
{
|
||||
if (data[i] != 0)
|
||||
{
|
||||
throw std::runtime_error("found non zero value");
|
||||
}
|
||||
}
|
||||
#else
|
||||
if (data[0] != 0) {
|
||||
if (data[0] != 0)
|
||||
{
|
||||
throw std::runtime_error("found non zero value");
|
||||
}
|
||||
#endif
|
||||
|
@ -34,16 +38,15 @@ public:
|
|||
uint32_t size_;
|
||||
std::vector<uint8_t> array_;
|
||||
test1(mapnik::parameters const& params)
|
||||
: test_case(params),
|
||||
size_(*params.get<mapnik::value_integer>("size",256*256)),
|
||||
array_(size_,0) { }
|
||||
bool validate() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
: test_case(params)
|
||||
, size_(*params.get<mapnik::value_integer>("size", 256 * 256))
|
||||
, array_(size_, 0)
|
||||
{}
|
||||
bool validate() const { return true; }
|
||||
bool operator()() const
|
||||
{
|
||||
for (std::size_t i=0;i<iterations_;++i) {
|
||||
for (std::size_t i = 0; i < iterations_; ++i)
|
||||
{
|
||||
// NOTE: sizeof(uint8_t) == 1
|
||||
uint8_t* data = (uint8_t*)malloc(sizeof(uint8_t) * size_);
|
||||
memcpy(data, &array_[0], size_);
|
||||
|
@ -60,16 +63,15 @@ public:
|
|||
uint32_t size_;
|
||||
std::vector<uint8_t> array_;
|
||||
test1b(mapnik::parameters const& params)
|
||||
: test_case(params),
|
||||
size_(*params.get<mapnik::value_integer>("size",256*256)),
|
||||
array_(size_,0) { }
|
||||
bool validate() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
: test_case(params)
|
||||
, size_(*params.get<mapnik::value_integer>("size", 256 * 256))
|
||||
, array_(size_, 0)
|
||||
{}
|
||||
bool validate() const { return true; }
|
||||
bool operator()() const
|
||||
{
|
||||
for (std::size_t i=0;i<iterations_;++i) {
|
||||
for (std::size_t i = 0; i < iterations_; ++i)
|
||||
{
|
||||
// NOTE: sizeof(uint8_t) == 1
|
||||
uint8_t* data = (uint8_t*)malloc(sizeof(uint8_t) * size_);
|
||||
memset(data, 0, sizeof(uint8_t) * size_);
|
||||
|
@ -86,16 +88,15 @@ public:
|
|||
uint32_t size_;
|
||||
std::vector<uint8_t> array_;
|
||||
test1c(mapnik::parameters const& params)
|
||||
: test_case(params),
|
||||
size_(*params.get<mapnik::value_integer>("size",256*256)),
|
||||
array_(size_,0) { }
|
||||
bool validate() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
: test_case(params)
|
||||
, size_(*params.get<mapnik::value_integer>("size", 256 * 256))
|
||||
, array_(size_, 0)
|
||||
{}
|
||||
bool validate() const { return true; }
|
||||
bool operator()() const
|
||||
{
|
||||
for (std::size_t i=0;i<iterations_;++i) {
|
||||
for (std::size_t i = 0; i < iterations_; ++i)
|
||||
{
|
||||
uint8_t* data = static_cast<uint8_t*>(::operator new(sizeof(uint8_t) * size_));
|
||||
std::fill(data, data + size_, 0);
|
||||
ensure_zero(data, size_);
|
||||
|
@ -105,23 +106,21 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
class test2 : public benchmark::test_case
|
||||
{
|
||||
public:
|
||||
uint32_t size_;
|
||||
std::vector<uint8_t> array_;
|
||||
test2(mapnik::parameters const& params)
|
||||
: test_case(params),
|
||||
size_(*params.get<mapnik::value_integer>("size",256*256)),
|
||||
array_(size_,0) { }
|
||||
bool validate() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
: test_case(params)
|
||||
, size_(*params.get<mapnik::value_integer>("size", 256 * 256))
|
||||
, array_(size_, 0)
|
||||
{}
|
||||
bool validate() const { return true; }
|
||||
bool operator()() const
|
||||
{
|
||||
for (std::size_t i=0;i<iterations_;++i) {
|
||||
for (std::size_t i = 0; i < iterations_; ++i)
|
||||
{
|
||||
uint8_t* data = static_cast<uint8_t*>(::operator new(sizeof(uint8_t) * size_));
|
||||
memcpy(data, &array_[0], size_);
|
||||
ensure_zero(data, size_);
|
||||
|
@ -137,16 +136,15 @@ public:
|
|||
uint32_t size_;
|
||||
std::vector<uint8_t> array_;
|
||||
test3(mapnik::parameters const& params)
|
||||
: test_case(params),
|
||||
size_(*params.get<mapnik::value_integer>("size",256*256)),
|
||||
array_(size_,0) { }
|
||||
bool validate() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
: test_case(params)
|
||||
, size_(*params.get<mapnik::value_integer>("size", 256 * 256))
|
||||
, array_(size_, 0)
|
||||
{}
|
||||
bool validate() const { return true; }
|
||||
bool operator()() const
|
||||
{
|
||||
for (std::size_t i=0;i<iterations_;++i) {
|
||||
for (std::size_t i = 0; i < iterations_; ++i)
|
||||
{
|
||||
std::vector<uint8_t> data(size_);
|
||||
ensure_zero(&data[0], data.size());
|
||||
}
|
||||
|
@ -154,23 +152,21 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
class test3b : public benchmark::test_case
|
||||
{
|
||||
public:
|
||||
uint32_t size_;
|
||||
std::vector<uint8_t> array_;
|
||||
test3b(mapnik::parameters const& params)
|
||||
: test_case(params),
|
||||
size_(*params.get<mapnik::value_integer>("size",256*256)),
|
||||
array_(size_,0) { }
|
||||
bool validate() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
: test_case(params)
|
||||
, size_(*params.get<mapnik::value_integer>("size", 256 * 256))
|
||||
, array_(size_, 0)
|
||||
{}
|
||||
bool validate() const { return true; }
|
||||
bool operator()() const
|
||||
{
|
||||
for (std::size_t i=0;i<iterations_;++i) {
|
||||
for (std::size_t i = 0; i < iterations_; ++i)
|
||||
{
|
||||
std::vector<uint8_t> data(0);
|
||||
data.resize(size_, 0);
|
||||
ensure_zero(&data[0], data.size());
|
||||
|
@ -179,23 +175,21 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
class test3c : public benchmark::test_case
|
||||
{
|
||||
public:
|
||||
uint32_t size_;
|
||||
std::vector<uint8_t> array_;
|
||||
test3c(mapnik::parameters const& params)
|
||||
: test_case(params),
|
||||
size_(*params.get<mapnik::value_integer>("size",256*256)),
|
||||
array_(size_,0) { }
|
||||
bool validate() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
: test_case(params)
|
||||
, size_(*params.get<mapnik::value_integer>("size", 256 * 256))
|
||||
, array_(size_, 0)
|
||||
{}
|
||||
bool validate() const { return true; }
|
||||
bool operator()() const
|
||||
{
|
||||
for (std::size_t i=0;i<iterations_;++i) {
|
||||
for (std::size_t i = 0; i < iterations_; ++i)
|
||||
{
|
||||
std::vector<uint8_t> data(0);
|
||||
data.assign(size_, 0);
|
||||
ensure_zero(&data[0], data.size());
|
||||
|
@ -210,19 +204,20 @@ public:
|
|||
uint32_t size_;
|
||||
std::vector<uint8_t> array_;
|
||||
test3d(mapnik::parameters const& params)
|
||||
: test_case(params),
|
||||
size_(*params.get<mapnik::value_integer>("size",256*256)),
|
||||
array_(size_,0) { }
|
||||
bool validate() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
: test_case(params)
|
||||
, size_(*params.get<mapnik::value_integer>("size", 256 * 256))
|
||||
, array_(size_, 0)
|
||||
{}
|
||||
bool validate() const { return true; }
|
||||
bool operator()() const
|
||||
{
|
||||
for (std::size_t i=0;i<iterations_;++i) {
|
||||
for (std::size_t i = 0; i < iterations_; ++i)
|
||||
{
|
||||
std::deque<uint8_t> data(size_);
|
||||
for (std::size_t i=0;i<size_;++i) {
|
||||
if (data[i] != 0) {
|
||||
for (std::size_t i = 0; i < size_; ++i)
|
||||
{
|
||||
if (data[i] != 0)
|
||||
{
|
||||
throw std::runtime_error("found non zero value");
|
||||
}
|
||||
}
|
||||
|
@ -237,16 +232,15 @@ public:
|
|||
uint32_t size_;
|
||||
std::vector<uint8_t> array_;
|
||||
test4(mapnik::parameters const& params)
|
||||
: test_case(params),
|
||||
size_(*params.get<mapnik::value_integer>("size",256*256)),
|
||||
array_(size_,0) { }
|
||||
bool validate() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
: test_case(params)
|
||||
, size_(*params.get<mapnik::value_integer>("size", 256 * 256))
|
||||
, array_(size_, 0)
|
||||
{}
|
||||
bool validate() const { return true; }
|
||||
bool operator()() const
|
||||
{
|
||||
for (std::size_t i=0;i<iterations_;++i) {
|
||||
for (std::size_t i = 0; i < iterations_; ++i)
|
||||
{
|
||||
uint8_t* data = (uint8_t*)calloc(size_, sizeof(uint8_t));
|
||||
ensure_zero(data, size_);
|
||||
free(data);
|
||||
|
@ -261,16 +255,15 @@ public:
|
|||
uint32_t size_;
|
||||
std::vector<uint8_t> array_;
|
||||
test5(mapnik::parameters const& params)
|
||||
: test_case(params),
|
||||
size_(*params.get<mapnik::value_integer>("size",256*256)),
|
||||
array_(size_,0) { }
|
||||
bool validate() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
: test_case(params)
|
||||
, size_(*params.get<mapnik::value_integer>("size", 256 * 256))
|
||||
, array_(size_, 0)
|
||||
{}
|
||||
bool validate() const { return true; }
|
||||
bool operator()() const
|
||||
{
|
||||
for (std::size_t i=0;i<iterations_;++i) {
|
||||
for (std::size_t i = 0; i < iterations_; ++i)
|
||||
{
|
||||
std::string data(array_.begin(), array_.end());
|
||||
ensure_zero((uint8_t*)&data[0], size_);
|
||||
}
|
||||
|
@ -284,16 +277,15 @@ public:
|
|||
uint32_t size_;
|
||||
std::vector<char> array_;
|
||||
test5b(mapnik::parameters const& params)
|
||||
: test_case(params),
|
||||
size_(*params.get<mapnik::value_integer>("size",256*256)),
|
||||
array_(size_,0) { }
|
||||
bool validate() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
: test_case(params)
|
||||
, size_(*params.get<mapnik::value_integer>("size", 256 * 256))
|
||||
, array_(size_, 0)
|
||||
{}
|
||||
bool validate() const { return true; }
|
||||
bool operator()() const
|
||||
{
|
||||
for (std::size_t i=0;i<iterations_;++i) {
|
||||
for (std::size_t i = 0; i < iterations_; ++i)
|
||||
{
|
||||
std::string data(&array_[0], array_.size());
|
||||
ensure_zero((uint8_t*)&data[0], size_);
|
||||
}
|
||||
|
@ -312,16 +304,15 @@ public:
|
|||
uint32_t size_;
|
||||
std::vector<uint8_t> array_;
|
||||
test6(mapnik::parameters const& params)
|
||||
: test_case(params),
|
||||
size_(*params.get<mapnik::value_integer>("size",256*256)),
|
||||
array_(size_,0) { }
|
||||
bool validate() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
: test_case(params)
|
||||
, size_(*params.get<mapnik::value_integer>("size", 256 * 256))
|
||||
, array_(size_, 0)
|
||||
{}
|
||||
bool validate() const { return true; }
|
||||
bool operator()() const
|
||||
{
|
||||
for (std::size_t i=0;i<iterations_;++i) {
|
||||
for (std::size_t i = 0; i < iterations_; ++i)
|
||||
{
|
||||
std::valarray<uint8_t> data(static_cast<uint8_t>(0), static_cast<size_t>(size_));
|
||||
ensure_zero(&data[0], size_);
|
||||
}
|
||||
|
@ -339,16 +330,15 @@ public:
|
|||
uint32_t size_;
|
||||
std::vector<uint8_t> array_;
|
||||
test7(mapnik::parameters const& params)
|
||||
: test_case(params),
|
||||
size_(*params.get<mapnik::value_integer>("size",256*256)),
|
||||
array_(size_,0) { }
|
||||
bool validate() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
: test_case(params)
|
||||
, size_(*params.get<mapnik::value_integer>("size", 256 * 256))
|
||||
, array_(size_, 0)
|
||||
{}
|
||||
bool validate() const { return true; }
|
||||
bool operator()() const
|
||||
{
|
||||
for (std::size_t i=0;i<iterations_;++i) {
|
||||
for (std::size_t i = 0; i < iterations_; ++i)
|
||||
{
|
||||
boost::container::static_vector<uint8_t, 256 * 256> data(size_, 0);
|
||||
ensure_zero(&data[0], size_);
|
||||
}
|
||||
|
|
|
@ -7,10 +7,12 @@
|
|||
class test : public benchmark::test_case
|
||||
{
|
||||
std::string expr_;
|
||||
|
||||
public:
|
||||
test(mapnik::parameters const& params)
|
||||
: test_case(params),
|
||||
expr_("((([mapnik::geometry_type]=2) and ([oneway]=1)) and ([class]='path'))") {}
|
||||
: test_case(params)
|
||||
, expr_("((([mapnik::geometry_type]=2) and ([oneway]=1)) and ([class]='path'))")
|
||||
{}
|
||||
bool validate() const
|
||||
{
|
||||
mapnik::expression_ptr expr = mapnik::parse_expression(expr_);
|
||||
|
@ -24,14 +26,14 @@ public:
|
|||
}
|
||||
bool operator()() const
|
||||
{
|
||||
for (std::size_t i=0;i<iterations_;++i) {
|
||||
for (std::size_t i = 0; i < iterations_; ++i)
|
||||
{
|
||||
mapnik::expression_ptr expr = mapnik::parse_expression(expr_);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
mapnik::parameters params;
|
||||
|
|
|
@ -6,7 +6,8 @@ class test : public benchmark::test_case
|
|||
{
|
||||
public:
|
||||
test(mapnik::parameters const& params)
|
||||
: test_case(params) {}
|
||||
: test_case(params)
|
||||
{}
|
||||
bool validate() const
|
||||
{
|
||||
std::size_t count = 0;
|
||||
|
@ -22,7 +23,8 @@ public:
|
|||
font_cache,
|
||||
mapnik::freetype_engine::get_mapping(),
|
||||
mapnik::freetype_engine::get_cache());
|
||||
if (f) ++count;
|
||||
if (f)
|
||||
++count;
|
||||
}
|
||||
return count == expected_count;
|
||||
}
|
||||
|
@ -43,9 +45,11 @@ public:
|
|||
font_cache,
|
||||
mapnik::freetype_engine::get_mapping(),
|
||||
mapnik::freetype_engine::get_cache());
|
||||
if (f) ++count;
|
||||
if (f)
|
||||
++count;
|
||||
}
|
||||
if (count != expected_count) {
|
||||
if (count != expected_count)
|
||||
{
|
||||
std::clog << "warning: face creation not working as expected\n";
|
||||
}
|
||||
}
|
||||
|
@ -58,7 +62,8 @@ int main(int argc, char** argv)
|
|||
mapnik::parameters params;
|
||||
benchmark::handle_args(argc, argv, params);
|
||||
bool success = mapnik::freetype_engine::register_fonts("./fonts", true);
|
||||
if (!success) {
|
||||
if (!success)
|
||||
{
|
||||
std::clog << "warning, did not register any new fonts!\n";
|
||||
return -1;
|
||||
}
|
||||
|
@ -66,4 +71,3 @@ int main(int argc, char** argv)
|
|||
test test_runner(params);
|
||||
return run(test_runner, (boost::format("font_engine: creating %ld faces") % (face_count)).str());
|
||||
}
|
||||
|
||||
|
|
|
@ -7,11 +7,9 @@ class test : public benchmark::test_case
|
|||
{
|
||||
public:
|
||||
test(mapnik::parameters const& params)
|
||||
: test_case(params) {}
|
||||
bool validate() const
|
||||
{
|
||||
return mapnik::freetype_engine::register_fonts("./fonts", true);
|
||||
}
|
||||
: test_case(params)
|
||||
{}
|
||||
bool validate() const { return mapnik::freetype_engine::register_fonts("./fonts", true); }
|
||||
bool operator()() const
|
||||
{
|
||||
unsigned long count = 0;
|
||||
|
|
|
@ -1,15 +1,13 @@
|
|||
#include "bench_framework.hpp"
|
||||
#include "../plugins/input/csv/csv_getline.hpp"
|
||||
|
||||
|
||||
|
||||
class test : public benchmark::test_case
|
||||
{
|
||||
public:
|
||||
std::string line_data_;
|
||||
test(mapnik::parameters const& params)
|
||||
: test_case(params),
|
||||
line_data_("this is one line\nand this is a second line\nand a third line")
|
||||
: test_case(params)
|
||||
, line_data_("this is one line\nand this is a second line\nand a third line")
|
||||
{
|
||||
boost::optional<std::string> line_data = params.get<std::string>("line");
|
||||
if (line_data)
|
||||
|
@ -32,7 +30,8 @@ public:
|
|||
}
|
||||
else
|
||||
{
|
||||
std::clog << "Error: the parsed line (" << csv_line << ") should be a subset of the original line (" << line_data_ << ") (ensure you pass a line with a \\n)\n";
|
||||
std::clog << "Error: the parsed line (" << csv_line << ") should be a subset of the original line ("
|
||||
<< line_data_ << ") (ensure you pass a line with a \\n)\n";
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -50,14 +49,13 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
class test2 : public benchmark::test_case
|
||||
{
|
||||
public:
|
||||
std::string line_data_;
|
||||
test2(mapnik::parameters const& params)
|
||||
: test_case(params),
|
||||
line_data_("this is one line\nand this is a second line\nand a third line")
|
||||
: test_case(params)
|
||||
, line_data_("this is one line\nand this is a second line\nand a third line")
|
||||
{
|
||||
boost::optional<std::string> line_data = params.get<std::string>("line");
|
||||
if (line_data)
|
||||
|
@ -81,7 +79,8 @@ public:
|
|||
}
|
||||
else
|
||||
{
|
||||
std::clog << "Error: the parsed line (" << csv_line << ") should be a subset of the original line (" << line_data_ << ") (ensure you pass a line with a \\n)\n";
|
||||
std::clog << "Error: the parsed line (" << csv_line << ") should be a subset of the original line ("
|
||||
<< line_data_ << ") (ensure you pass a line with a \\n)\n";
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -115,8 +114,7 @@ int main(int argc, char** argv)
|
|||
test2 test_runner2(params);
|
||||
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";
|
||||
return -1;
|
||||
|
|
|
@ -4,11 +4,11 @@
|
|||
class test : public benchmark::test_case
|
||||
{
|
||||
std::vector<std::string> images_;
|
||||
|
||||
public:
|
||||
test(mapnik::parameters const& params)
|
||||
: test_case(params),
|
||||
images_{
|
||||
"./test/data/images/dummy.jpg",
|
||||
: test_case(params)
|
||||
, images_{"./test/data/images/dummy.jpg",
|
||||
"./test/data/images/dummy.jpeg",
|
||||
"./test/data/images/dummy.png",
|
||||
"./test/data/images/dummy.tif",
|
||||
|
@ -19,16 +19,14 @@ public:
|
|||
"./test/data/svg/place-of-worship-24.svg",
|
||||
"./test/data/svg/point_sm.svg",
|
||||
"./test/data/svg/point.svg",
|
||||
"./test/data/svg/airfield-12.svg"
|
||||
} {}
|
||||
bool validate() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
"./test/data/svg/airfield-12.svg"}
|
||||
{}
|
||||
bool validate() const { return true; }
|
||||
bool operator()() const
|
||||
{
|
||||
unsigned count = 0;
|
||||
for (std::size_t i=0;i<iterations_;++i) {
|
||||
for (std::size_t i = 0; i < iterations_; ++i)
|
||||
{
|
||||
for (auto filename : images_)
|
||||
{
|
||||
auto marker = mapnik::marker_cache::instance().find(filename, true);
|
||||
|
|
|
@ -16,12 +16,10 @@ class test : public benchmark::test_case
|
|||
{
|
||||
public:
|
||||
test(mapnik::parameters const& params)
|
||||
: test_case(params) {}
|
||||
: test_case(params)
|
||||
{}
|
||||
|
||||
bool validate() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool validate() const { return true; }
|
||||
bool operator()() const
|
||||
{
|
||||
mapnik::Map m(256, 256, "epsg:3857");
|
||||
|
|
|
@ -9,23 +9,25 @@ class test_static : public benchmark::test_case
|
|||
{
|
||||
double step_;
|
||||
std::uint8_t start_;
|
||||
|
||||
public:
|
||||
test_static(mapnik::parameters const& params)
|
||||
: test_case(params),
|
||||
step_(STEP_NUM),
|
||||
start_(START_NUM) {}
|
||||
bool validate() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
: test_case(params)
|
||||
, step_(STEP_NUM)
|
||||
, start_(START_NUM)
|
||||
{}
|
||||
bool validate() const { return true; }
|
||||
bool operator()() const
|
||||
{
|
||||
double value_ = 0.0;
|
||||
std::uint8_t x;
|
||||
for (std::size_t i=0;i<iterations_;++i) {
|
||||
for (std::size_t i = 0; i < iterations_; ++i)
|
||||
{
|
||||
double c = static_cast<double>(start_) * value_;
|
||||
if (c >= 256.0) c = 255.0;
|
||||
if (c < 0.0) c = 0.0;
|
||||
if (c >= 256.0)
|
||||
c = 255.0;
|
||||
if (c < 0.0)
|
||||
c = 0.0;
|
||||
x = static_cast<std::uint8_t>(c);
|
||||
value_ += step_;
|
||||
}
|
||||
|
@ -33,35 +35,34 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
using boost::numeric::positive_overflow;
|
||||
using boost::numeric::negative_overflow;
|
||||
using boost::numeric::positive_overflow;
|
||||
|
||||
class test_numeric : public benchmark::test_case
|
||||
{
|
||||
double step_;
|
||||
std::uint8_t start_;
|
||||
|
||||
public:
|
||||
test_numeric(mapnik::parameters const& params)
|
||||
: test_case(params),
|
||||
step_(STEP_NUM),
|
||||
start_(START_NUM) {}
|
||||
bool validate() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
: test_case(params)
|
||||
, step_(STEP_NUM)
|
||||
, start_(START_NUM)
|
||||
{}
|
||||
bool validate() const { return true; }
|
||||
bool operator()() const
|
||||
{
|
||||
double value_ = 0.0;
|
||||
std::uint8_t x;
|
||||
for (std::size_t i=0;i<iterations_;++i) {
|
||||
try {
|
||||
for (std::size_t i = 0; i < iterations_; ++i)
|
||||
{
|
||||
try
|
||||
{
|
||||
x = boost::numeric_cast<std::uint8_t>(start_ * value_);
|
||||
}
|
||||
catch(negative_overflow&)
|
||||
} catch (negative_overflow&)
|
||||
{
|
||||
x = std::numeric_limits<std::uint8_t>::min();
|
||||
}
|
||||
catch(positive_overflow&)
|
||||
} catch (positive_overflow&)
|
||||
{
|
||||
x = std::numeric_limits<std::uint8_t>::max();
|
||||
}
|
||||
|
@ -73,8 +74,5 @@ public:
|
|||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
return benchmark::sequencer(argc, argv)
|
||||
.run<test_static>("static_cast")
|
||||
.run<test_numeric>("numeric_cast")
|
||||
.done();
|
||||
return benchmark::sequencer(argc, argv).run<test_static>("static_cast").run<test_numeric>("numeric_cast").done();
|
||||
}
|
||||
|
|
|
@ -14,31 +14,36 @@ struct fake_path
|
|||
cont_type::iterator itr_;
|
||||
|
||||
fake_path(std::initializer_list<double> l)
|
||||
: fake_path(l.begin(), l.size()) {
|
||||
}
|
||||
: fake_path(l.begin(), l.size())
|
||||
{}
|
||||
|
||||
fake_path(std::vector<double> const& v)
|
||||
: fake_path(v.begin(), v.size()) {
|
||||
}
|
||||
: fake_path(v.begin(), v.size())
|
||||
{}
|
||||
|
||||
template<typename Itr>
|
||||
fake_path(Itr itr, size_t sz) {
|
||||
fake_path(Itr itr, size_t sz)
|
||||
{
|
||||
size_t num_coords = sz >> 1;
|
||||
vertices_.reserve(num_coords);
|
||||
|
||||
for (size_t i = 0; i < num_coords; ++i) {
|
||||
for (size_t i = 0; i < num_coords; ++i)
|
||||
{
|
||||
double x = *itr++;
|
||||
double y = *itr++;
|
||||
unsigned cmd = (i == 0) ? mapnik::SEG_MOVETO : mapnik::SEG_LINETO;
|
||||
vertices_.push_back(std::make_tuple(x, y, cmd));
|
||||
if (i == num_coords - 1) cmd = mapnik::SEG_END;
|
||||
if (i == num_coords - 1)
|
||||
cmd = mapnik::SEG_END;
|
||||
vertices_.push_back(std::make_tuple(x, y, cmd));
|
||||
}
|
||||
itr_ = vertices_.begin();
|
||||
}
|
||||
|
||||
unsigned vertex(double *x, double *y) {
|
||||
if (itr_ == vertices_.end()) {
|
||||
unsigned vertex(double* x, double* y)
|
||||
{
|
||||
if (itr_ == vertices_.end())
|
||||
{
|
||||
return mapnik::SEG_END;
|
||||
}
|
||||
*x = std::get<0>(*itr_);
|
||||
|
@ -48,20 +53,16 @@ struct fake_path
|
|||
return cmd;
|
||||
}
|
||||
|
||||
void rewind(unsigned) {
|
||||
itr_ = vertices_.begin();
|
||||
}
|
||||
void rewind(unsigned) { itr_ = vertices_.begin(); }
|
||||
};
|
||||
|
||||
class test_offset : public benchmark::test_case
|
||||
{
|
||||
public:
|
||||
test_offset(mapnik::parameters const& params)
|
||||
: test_case(params) {}
|
||||
bool validate() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
: test_case(params)
|
||||
{}
|
||||
bool validate() const { return true; }
|
||||
bool operator()() const
|
||||
{
|
||||
std::vector<double> path;
|
||||
|
@ -74,7 +75,8 @@ public:
|
|||
path.push_back(0);
|
||||
}
|
||||
fake_path fpath(path);
|
||||
for (std::size_t i=0;i<iterations_;++i) {
|
||||
for (std::size_t i = 0; i < iterations_; ++i)
|
||||
{
|
||||
mapnik::offset_converter<fake_path> off_path(fpath);
|
||||
off_path.set_offset(10);
|
||||
unsigned cmd;
|
||||
|
@ -88,7 +90,6 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
mapnik::parameters params;
|
||||
|
|
|
@ -4,18 +4,18 @@
|
|||
class test : public benchmark::test_case
|
||||
{
|
||||
mapnik::image_rgba8 im_;
|
||||
|
||||
public:
|
||||
test(mapnik::parameters const& params)
|
||||
: test_case(params),
|
||||
im_(256,256) {}
|
||||
bool validate() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
: test_case(params)
|
||||
, im_(256, 256)
|
||||
{}
|
||||
bool validate() const { return true; }
|
||||
bool operator()() const
|
||||
{
|
||||
std::string out;
|
||||
for (std::size_t i=0;i<iterations_;++i) {
|
||||
for (std::size_t i = 0; i < iterations_; ++i)
|
||||
{
|
||||
out.clear();
|
||||
out = mapnik::save_to_string(im_, "png8:m=h:z=1");
|
||||
}
|
||||
|
|
|
@ -4,9 +4,11 @@
|
|||
class test : public benchmark::test_case
|
||||
{
|
||||
std::shared_ptr<mapnik::image_rgba8> im_;
|
||||
|
||||
public:
|
||||
test(mapnik::parameters const& params)
|
||||
: test_case(params) {
|
||||
: test_case(params)
|
||||
{
|
||||
std::string filename("./benchmark/data/multicolor.png");
|
||||
std::unique_ptr<mapnik::image_reader> reader(mapnik::get_image_reader(filename, "png"));
|
||||
if (!reader.get())
|
||||
|
@ -26,7 +28,8 @@ public:
|
|||
bool operator()() const
|
||||
{
|
||||
std::string out;
|
||||
for (std::size_t i=0;i<iterations_;++i) {
|
||||
for (std::size_t i = 0; i < iterations_; ++i)
|
||||
{
|
||||
out.clear();
|
||||
out = mapnik::save_to_string(*im_, "png8:m=h:z=1");
|
||||
}
|
||||
|
|
|
@ -39,7 +39,8 @@ void render(mapnik::geometry::multi_polygon<double> const& geom,
|
|||
mapnik::box2d<double> const& extent,
|
||||
std::string const& name)
|
||||
{
|
||||
using path_type = mapnik::transform_path_adapter<mapnik::view_transform,mapnik::geometry::polygon_vertex_adapter<double>>;
|
||||
using path_type =
|
||||
mapnik::transform_path_adapter<mapnik::view_transform, mapnik::geometry::polygon_vertex_adapter<double>>;
|
||||
using ren_base = agg::renderer_base<agg::pixfmt_rgba32_plain>;
|
||||
using renderer = agg::renderer_scanline_aa_solid<ren_base>;
|
||||
mapnik::image_rgba8 im(256, 256);
|
||||
|
@ -70,15 +71,15 @@ class test1 : public benchmark::test_case
|
|||
std::string wkt_in_;
|
||||
mapnik::box2d<double> extent_;
|
||||
std::string expected_;
|
||||
|
||||
public:
|
||||
using conv_clip = agg::conv_clip_polygon<mapnik::geometry::polygon_vertex_adapter<double>>;
|
||||
test1(mapnik::parameters const& params,
|
||||
std::string const& wkt_in,
|
||||
mapnik::box2d<double> const& extent)
|
||||
: test_case(params),
|
||||
wkt_in_(wkt_in),
|
||||
extent_(extent),
|
||||
expected_("./benchmark/data/polygon_clipping_agg") {}
|
||||
test1(mapnik::parameters const& params, std::string const& wkt_in, mapnik::box2d<double> const& extent)
|
||||
: test_case(params)
|
||||
, wkt_in_(wkt_in)
|
||||
, extent_(extent)
|
||||
, expected_("./benchmark/data/polygon_clipping_agg")
|
||||
{}
|
||||
bool validate() const
|
||||
{
|
||||
mapnik::geometry::geometry<double> geom;
|
||||
|
@ -99,14 +100,8 @@ public:
|
|||
mapnik::geometry::polygon<double> const& poly = mapnik::util::get<mapnik::geometry::polygon<double>>(geom);
|
||||
mapnik::geometry::polygon_vertex_adapter<double> va(poly);
|
||||
|
||||
|
||||
conv_clip clipped(va);
|
||||
clipped.clip_box(
|
||||
extent_.minx(),
|
||||
extent_.miny(),
|
||||
extent_.maxx(),
|
||||
extent_.maxy());
|
||||
|
||||
clipped.clip_box(extent_.minx(), extent_.miny(), extent_.maxx(), extent_.maxy());
|
||||
|
||||
clipped.rewind(0);
|
||||
mapnik::geometry::polygon<double> poly2;
|
||||
|
@ -118,7 +113,8 @@ public:
|
|||
{
|
||||
if (cmd == mapnik::SEG_MOVETO)
|
||||
{
|
||||
x0 = x; y0 = y;
|
||||
x0 = x;
|
||||
y0 = y;
|
||||
}
|
||||
|
||||
if (cmd == mapnik::SEG_CLOSE)
|
||||
|
@ -135,7 +131,8 @@ public:
|
|||
{
|
||||
if (cmd == mapnik::SEG_MOVETO)
|
||||
{
|
||||
x0 = x; y0 = y;
|
||||
x0 = x;
|
||||
y0 = y;
|
||||
}
|
||||
else if (cmd == mapnik::SEG_CLOSE)
|
||||
{
|
||||
|
@ -184,23 +181,22 @@ public:
|
|||
mapnik::geometry::polygon<double> const& poly = mapnik::util::get<mapnik::geometry::polygon<double>>(geom);
|
||||
mapnik::geometry::polygon_vertex_adapter<double> va(poly);
|
||||
conv_clip clipped(va);
|
||||
clipped.clip_box(
|
||||
extent_.minx(),
|
||||
extent_.miny(),
|
||||
extent_.maxx(),
|
||||
extent_.maxy());
|
||||
clipped.clip_box(extent_.minx(), extent_.miny(), extent_.maxx(), extent_.maxy());
|
||||
unsigned cmd;
|
||||
double x, y;
|
||||
// NOTE: this rewind is critical otherwise
|
||||
// agg_conv_adapter_vpgen will give garbage
|
||||
// values for the first vertex
|
||||
clipped.rewind(0);
|
||||
while ((cmd = clipped.vertex(&x, &y)) != mapnik::SEG_END) {
|
||||
while ((cmd = clipped.vertex(&x, &y)) != mapnik::SEG_END)
|
||||
{
|
||||
count++;
|
||||
}
|
||||
unsigned expected_count = 30;
|
||||
if (count != expected_count) {
|
||||
std::clog << "test1: clipping failed: processed " << count << " verticies but expected " << expected_count << "\n";
|
||||
if (count != expected_count)
|
||||
{
|
||||
std::clog << "test1: clipping failed: processed " << count << " verticies but expected "
|
||||
<< expected_count << "\n";
|
||||
valid = false;
|
||||
}
|
||||
}
|
||||
|
@ -208,20 +204,19 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
class test3 : public benchmark::test_case
|
||||
{
|
||||
std::string wkt_in_;
|
||||
mapnik::box2d<double> extent_;
|
||||
std::string expected_;
|
||||
|
||||
public:
|
||||
test3(mapnik::parameters const& params,
|
||||
std::string const& wkt_in,
|
||||
mapnik::box2d<double> const& extent)
|
||||
: test_case(params),
|
||||
wkt_in_(wkt_in),
|
||||
extent_(extent),
|
||||
expected_("./benchmark/data/polygon_clipping_boost") {}
|
||||
test3(mapnik::parameters const& params, std::string const& wkt_in, mapnik::box2d<double> const& extent)
|
||||
: test_case(params)
|
||||
, wkt_in_(wkt_in)
|
||||
, extent_(extent)
|
||||
, expected_("./benchmark/data/polygon_clipping_boost")
|
||||
{}
|
||||
bool validate() const
|
||||
{
|
||||
mapnik::geometry::geometry<double> geom;
|
||||
|
@ -308,12 +303,15 @@ public:
|
|||
mapnik::geometry::polygon_vertex_adapter<double> va(_geom);
|
||||
unsigned cmd;
|
||||
double x, y;
|
||||
while ((cmd = va.vertex(&x, &y)) != mapnik::SEG_END) {
|
||||
while ((cmd = va.vertex(&x, &y)) != mapnik::SEG_END)
|
||||
{
|
||||
++count;
|
||||
}
|
||||
unsigned expected_count = 29;
|
||||
if (count != expected_count) {
|
||||
std::clog << "test3: clipping failed: processed " << count << " verticies but expected " << expected_count << "\n";
|
||||
if (count != expected_count)
|
||||
{
|
||||
std::clog << "test3: clipping failed: processed " << count << " verticies but expected "
|
||||
<< expected_count << "\n";
|
||||
valid = false;
|
||||
}
|
||||
}
|
||||
|
@ -500,8 +498,8 @@ public:
|
|||
}
|
||||
unsigned expected_count = 29;
|
||||
if (count != expected_count) {
|
||||
std::clog << "test3: clipping failed: processed " << count << " verticies but expected " << expected_count << "\n";
|
||||
valid = false;
|
||||
std::clog << "test3: clipping failed: processed " << count << " verticies but expected " <<
|
||||
expected_count << "\n"; valid = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -516,10 +514,13 @@ int main(int argc, char** argv)
|
|||
benchmark::handle_args(argc, argv, params);
|
||||
|
||||
// polygon/rect clipping
|
||||
// IN : POLYGON ((155 203, 233 454, 315 340, 421 446, 463 324, 559 466, 665 253, 528 178, 394 229, 329 138, 212 134, 183 228, 200 264, 155 203),(313 190, 440 256, 470 248, 510 305, 533 237, 613 263, 553 397, 455 262, 405 378, 343 287, 249 334, 229 191, 313 190))
|
||||
// RECT : POLYGON ((181 106, 181 470, 631 470, 631 106, 181 106))
|
||||
// OUT (expected)
|
||||
// POLYGON ((181 286.6666666666667, 233 454, 315 340, 421 446, 463 324, 559 466, 631 321.3207547169811, 631 234.38686131386862, 528 178, 394 229, 329 138, 212 134, 183 228, 200 264, 181 238.24444444444444, 181 286.6666666666667),(313 190, 440 256, 470 248, 510 305, 533 237, 613 263, 553 397, 455 262, 405 378, 343 287, 249 334, 229 191, 313 190))
|
||||
// IN : POLYGON ((155 203, 233 454, 315 340, 421 446, 463 324, 559 466, 665 253, 528 178, 394 229, 329 138, 212 134,
|
||||
// 183 228, 200 264, 155 203),(313 190, 440 256, 470 248, 510 305, 533 237, 613 263, 553 397, 455 262, 405 378, 343
|
||||
// 287, 249 334, 229 191, 313 190)) RECT : POLYGON ((181 106, 181 470, 631 470, 631 106, 181 106)) OUT (expected)
|
||||
// POLYGON ((181 286.6666666666667, 233 454, 315 340, 421 446, 463 324, 559 466, 631 321.3207547169811, 631
|
||||
// 234.38686131386862, 528 178, 394 229, 329 138, 212 134, 183 228, 200 264, 181 238.24444444444444, 181
|
||||
// 286.6666666666667),(313 190, 440 256, 470 248, 510 305, 533 237, 613 263, 553 397, 455 262, 405 378, 343 287, 249
|
||||
// 334, 229 191, 313 190))
|
||||
#if 0
|
||||
mapnik::box2d<double> clipping_box(181,106,631,470);
|
||||
std::string filename_("./benchmark/data/polygon.wkt");
|
||||
|
|
|
@ -8,13 +8,12 @@ class test : public benchmark::test_case
|
|||
{
|
||||
std::string xml_;
|
||||
mapnik::box2d<double> extent_;
|
||||
|
||||
public:
|
||||
test(mapnik::parameters const& params,
|
||||
std::string const& xml,
|
||||
mapnik::box2d<double> const& extent)
|
||||
: test_case(params),
|
||||
xml_(xml),
|
||||
extent_(extent)
|
||||
test(mapnik::parameters const& params, std::string const& xml, mapnik::box2d<double> const& extent)
|
||||
: test_case(params)
|
||||
, xml_(xml)
|
||||
, extent_(extent)
|
||||
{}
|
||||
bool validate() const
|
||||
{
|
||||
|
@ -42,7 +41,6 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
mapnik::parameters params;
|
||||
|
|
|
@ -10,6 +10,7 @@ class test : public benchmark::test_case
|
|||
mapnik::box2d<double> from_;
|
||||
mapnik::box2d<double> to_;
|
||||
bool defer_proj_init_;
|
||||
|
||||
public:
|
||||
test(mapnik::parameters const& params,
|
||||
std::string const& src,
|
||||
|
@ -17,24 +18,23 @@ public:
|
|||
mapnik::box2d<double> const& from,
|
||||
mapnik::box2d<double> const& to,
|
||||
bool defer_proj)
|
||||
: test_case(params),
|
||||
src_(src),
|
||||
dest_(dest),
|
||||
from_(from),
|
||||
to_(to),
|
||||
defer_proj_init_(defer_proj) {}
|
||||
: test_case(params)
|
||||
, src_(src)
|
||||
, dest_(dest)
|
||||
, from_(from)
|
||||
, to_(to)
|
||||
, defer_proj_init_(defer_proj)
|
||||
{}
|
||||
bool validate() const
|
||||
{
|
||||
mapnik::projection src(src_, defer_proj_init_);
|
||||
mapnik::projection dest(dest_, defer_proj_init_);
|
||||
mapnik::proj_transform tr(src, dest);
|
||||
mapnik::box2d<double> bbox = from_;
|
||||
if (!tr.forward(bbox)) return false;
|
||||
return ((std::fabs(bbox.minx() - to_.minx()) < .5) &&
|
||||
(std::fabs(bbox.maxx() - to_.maxx()) < .5) &&
|
||||
(std::fabs(bbox.miny() - to_.miny()) < .5) &&
|
||||
(std::fabs(bbox.maxy() - to_.maxy()) < .5)
|
||||
);
|
||||
if (!tr.forward(bbox))
|
||||
return false;
|
||||
return ((std::fabs(bbox.minx() - to_.minx()) < .5) && (std::fabs(bbox.maxx() - to_.maxx()) < .5) &&
|
||||
(std::fabs(bbox.miny() - to_.miny()) < .5) && (std::fabs(bbox.maxy() - to_.maxy()) < .5));
|
||||
}
|
||||
bool operator()() const
|
||||
{
|
||||
|
@ -48,7 +48,8 @@ public:
|
|||
for (int k = -85; k < 85; k = k + 5)
|
||||
{
|
||||
mapnik::box2d<double> box(j, k, j, k);
|
||||
if (!tr.forward(box)) throw std::runtime_error("could not transform coords");
|
||||
if (!tr.forward(box))
|
||||
throw std::runtime_error("could not transform coords");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -64,7 +65,8 @@ int main(int argc, char** argv)
|
|||
std::string from_str("epsg:4326");
|
||||
std::string to_str("epsg:3857");
|
||||
std::string from_str2("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs");
|
||||
std::string to_str2("+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over");
|
||||
std::string to_str2("+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m "
|
||||
"+nadgrids=@null +wktext +no_defs +over");
|
||||
return benchmark::sequencer(argc, argv)
|
||||
.run<test>("lonlat->merc epsg (internal)", from_str, to_str, from, to, true)
|
||||
.run<test>("lonlat->merc literal (libproj)", from_str2, to_str2, from, to, true)
|
||||
|
|
|
@ -8,12 +8,10 @@ class test : public benchmark::test_case
|
|||
{
|
||||
public:
|
||||
test(mapnik::parameters const& params)
|
||||
: test_case(params) {}
|
||||
: test_case(params)
|
||||
{}
|
||||
|
||||
bool validate() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool validate() const { return true; }
|
||||
|
||||
bool operator()() const
|
||||
{
|
||||
|
|
|
@ -15,15 +15,16 @@ class test : public benchmark::test_case
|
|||
mapnik::value_integer height_;
|
||||
double scale_factor_;
|
||||
std::string preview_;
|
||||
|
||||
public:
|
||||
test(mapnik::parameters const& params)
|
||||
: test_case(params),
|
||||
xml_(),
|
||||
extent_(),
|
||||
width_(*params.get<mapnik::value_integer>("width",256)),
|
||||
height_(*params.get<mapnik::value_integer>("height",256)),
|
||||
scale_factor_(*params.get<mapnik::value_double>("scale_factor",1.0)),
|
||||
preview_(*params.get<std::string>("preview",""))
|
||||
: test_case(params)
|
||||
, xml_()
|
||||
, extent_()
|
||||
, width_(*params.get<mapnik::value_integer>("width", 256))
|
||||
, height_(*params.get<mapnik::value_integer>("height", 256))
|
||||
, scale_factor_(*params.get<mapnik::value_double>("scale_factor", 1.0))
|
||||
, preview_(*params.get<std::string>("preview", ""))
|
||||
{
|
||||
boost::optional<std::string> map = params.get<std::string>("map");
|
||||
if (!map)
|
||||
|
@ -43,21 +44,24 @@ public:
|
|||
{
|
||||
throw std::runtime_error("please provide a --extent=<minx,miny,maxx,maxy> arg");
|
||||
}*/
|
||||
|
||||
}
|
||||
bool validate() const
|
||||
{
|
||||
mapnik::Map m(width_, height_);
|
||||
mapnik::load_map(m, xml_, true);
|
||||
if (extent_.valid()) {
|
||||
if (extent_.valid())
|
||||
{
|
||||
m.zoom_to_box(extent_);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
m.zoom_all();
|
||||
}
|
||||
mapnik::image_rgba8 im(m.width(), m.height());
|
||||
mapnik::agg_renderer<mapnik::image_rgba8> ren(m, im, scale_factor_);
|
||||
ren.apply();
|
||||
if (!preview_.empty()) {
|
||||
if (!preview_.empty())
|
||||
{
|
||||
std::clog << "preview available at " << preview_ << "\n";
|
||||
mapnik::save_to_file(im, preview_);
|
||||
}
|
||||
|
@ -65,14 +69,18 @@ public:
|
|||
}
|
||||
bool operator()() const
|
||||
{
|
||||
if (!preview_.empty()) {
|
||||
if (!preview_.empty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
mapnik::Map m(width_, height_);
|
||||
mapnik::load_map(m, xml_);
|
||||
if (extent_.valid()) {
|
||||
if (extent_.valid())
|
||||
{
|
||||
m.zoom_to_box(extent_);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
m.zoom_all();
|
||||
}
|
||||
for (unsigned i = 0; i < iterations_; ++i)
|
||||
|
@ -85,7 +93,6 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
int return_value = 0;
|
||||
|
@ -105,8 +112,7 @@ int main(int argc, char** argv)
|
|||
test test_runner(params);
|
||||
return_value = run(test_runner, *name);
|
||||
}
|
||||
}
|
||||
catch (std::exception const& ex)
|
||||
} catch (std::exception const& ex)
|
||||
{
|
||||
std::clog << ex.what() << "\n";
|
||||
return -1;
|
||||
|
|
|
@ -12,7 +12,8 @@
|
|||
#include <mapnik/datasource_cache.hpp>
|
||||
#include <stdexcept>
|
||||
|
||||
template <typename Renderer> void process_layers(Renderer & ren,
|
||||
template<typename Renderer>
|
||||
void process_layers(Renderer& ren,
|
||||
mapnik::request const& m_req,
|
||||
mapnik::projection const& map_proj,
|
||||
std::vector<mapnik::layer> const& layers,
|
||||
|
@ -50,17 +51,18 @@ class test : public benchmark::test_case
|
|||
double scale_factor_;
|
||||
std::string preview_;
|
||||
mutable mapnik::image_rgba8 im_;
|
||||
|
||||
public:
|
||||
test(mapnik::parameters const& params)
|
||||
: test_case(params),
|
||||
xml_(),
|
||||
extent_(),
|
||||
width_(*params.get<mapnik::value_integer>("width",256)),
|
||||
height_(*params.get<mapnik::value_integer>("height",256)),
|
||||
m_(new mapnik::Map(width_,height_)),
|
||||
scale_factor_(*params.get<mapnik::value_double>("scale_factor",2.0)),
|
||||
preview_(*params.get<std::string>("preview","")),
|
||||
im_(m_->width(),m_->height())
|
||||
: test_case(params)
|
||||
, xml_()
|
||||
, extent_()
|
||||
, width_(*params.get<mapnik::value_integer>("width", 256))
|
||||
, height_(*params.get<mapnik::value_integer>("height", 256))
|
||||
, m_(new mapnik::Map(width_, height_))
|
||||
, scale_factor_(*params.get<mapnik::value_double>("scale_factor", 2.0))
|
||||
, preview_(*params.get<std::string>("preview", ""))
|
||||
, im_(m_->width(), m_->height())
|
||||
{
|
||||
boost::optional<std::string> map = params.get<std::string>("map");
|
||||
if (!map)
|
||||
|
@ -98,7 +100,8 @@ public:
|
|||
std::vector<mapnik::layer> const& layers = m_->layers();
|
||||
process_layers(ren, m_req, map_proj, layers, scale_denom);
|
||||
ren.end_map_processing(*m_);
|
||||
if (!preview_.empty()) {
|
||||
if (!preview_.empty())
|
||||
{
|
||||
std::clog << "preview available at " << preview_ << "\n";
|
||||
mapnik::save_to_file(im_, preview_);
|
||||
}
|
||||
|
@ -107,7 +110,8 @@ public:
|
|||
|
||||
bool operator()() const
|
||||
{
|
||||
if (!preview_.empty()) {
|
||||
if (!preview_.empty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
for (unsigned i = 0; i < iterations_; ++i)
|
||||
|
@ -133,16 +137,17 @@ public:
|
|||
const unsigned int* row_to = dest.get_row(y);
|
||||
for (unsigned int x = 0; x < width_; ++x)
|
||||
{
|
||||
if (row_from[x] != row_to[x]) diff = true;
|
||||
if (row_from[x] != row_to[x])
|
||||
diff = true;
|
||||
}
|
||||
}
|
||||
if (diff) throw std::runtime_error("images differ");
|
||||
if (diff)
|
||||
throw std::runtime_error("images differ");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
int return_value = 0;
|
||||
|
@ -162,8 +167,7 @@ int main(int argc, char** argv)
|
|||
test test_runner(params);
|
||||
return_value = run(test_runner, *name);
|
||||
}
|
||||
}
|
||||
catch (std::exception const& ex)
|
||||
} catch (std::exception const& ex)
|
||||
{
|
||||
std::clog << ex.what() << "\n";
|
||||
return -1;
|
||||
|
|
|
@ -4,21 +4,25 @@
|
|||
class test : public benchmark::test_case
|
||||
{
|
||||
std::string value_;
|
||||
|
||||
public:
|
||||
test(mapnik::parameters const& params)
|
||||
: test_case(params),
|
||||
value_("true") {}
|
||||
: test_case(params)
|
||||
, value_("true")
|
||||
{}
|
||||
bool validate() const
|
||||
{
|
||||
bool result = false;
|
||||
mapnik::util::string2bool(value_.data(), value_.data() + value_.size(), result);
|
||||
if (!result) return result;
|
||||
if (!result)
|
||||
return result;
|
||||
mapnik::util::string2bool(value_, result);
|
||||
return (result == true);
|
||||
}
|
||||
bool operator()() const
|
||||
{
|
||||
for (std::size_t i=0;i<iterations_;++i) {
|
||||
for (std::size_t i = 0; i < iterations_; ++i)
|
||||
{
|
||||
bool result = false;
|
||||
mapnik::util::string2bool(value_, result);
|
||||
mapnik::util::string2bool(value_.data(), value_.data() + value_.size(), result);
|
||||
|
|
|
@ -4,23 +4,30 @@
|
|||
class test : public benchmark::test_case
|
||||
{
|
||||
std::string value_;
|
||||
|
||||
public:
|
||||
test(mapnik::parameters const& params)
|
||||
: test_case(params),
|
||||
value_("1.23456789") {}
|
||||
: test_case(params)
|
||||
, value_("1.23456789")
|
||||
{}
|
||||
bool validate() const
|
||||
{
|
||||
double result = 0;
|
||||
if (!mapnik::util::string2double(value_.data(),value_.data()+value_.size(),result)) return false;
|
||||
if (result != 1.23456789) return false;
|
||||
if (!mapnik::util::string2double(value_.data(), value_.data() + value_.size(), result))
|
||||
return false;
|
||||
if (result != 1.23456789)
|
||||
return false;
|
||||
result = 0;
|
||||
if (!mapnik::util::string2double(value_,result)) return false;
|
||||
if (result != 1.23456789) return false;
|
||||
if (!mapnik::util::string2double(value_, result))
|
||||
return false;
|
||||
if (result != 1.23456789)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
bool operator()() const
|
||||
{
|
||||
for (std::size_t i=0;i<iterations_;++i) {
|
||||
for (std::size_t i = 0; i < iterations_; ++i)
|
||||
{
|
||||
double result = 0;
|
||||
mapnik::util::string2double(value_, result);
|
||||
mapnik::util::string2double(value_.data(), value_.data() + value_.size(), result);
|
||||
|
|
|
@ -4,23 +4,30 @@
|
|||
class test : public benchmark::test_case
|
||||
{
|
||||
std::string value_;
|
||||
|
||||
public:
|
||||
test(mapnik::parameters const& params)
|
||||
: test_case(params),
|
||||
value_("123456789") {}
|
||||
: test_case(params)
|
||||
, value_("123456789")
|
||||
{}
|
||||
bool validate() const
|
||||
{
|
||||
mapnik::value_integer result = 0;
|
||||
if (!mapnik::util::string2int(value_.data(),value_.data()+value_.size(),result)) return false;
|
||||
if (result != 123456789) return false;
|
||||
if (!mapnik::util::string2int(value_.data(), value_.data() + value_.size(), result))
|
||||
return false;
|
||||
if (result != 123456789)
|
||||
return false;
|
||||
result = 0;
|
||||
if (!mapnik::util::string2int(value_,result)) return false;
|
||||
if (result != 123456789) return false;
|
||||
if (!mapnik::util::string2int(value_, result))
|
||||
return false;
|
||||
if (result != 123456789)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
bool operator()() const
|
||||
{
|
||||
for (std::size_t i=0;i<iterations_;++i) {
|
||||
for (std::size_t i = 0; i < iterations_; ++i)
|
||||
{
|
||||
mapnik::value_integer result = 0;
|
||||
mapnik::util::string2int(value_, result);
|
||||
mapnik::util::string2int(value_.data(), value_.data() + value_.size(), result);
|
||||
|
|
|
@ -4,10 +4,12 @@
|
|||
class test : public benchmark::test_case
|
||||
{
|
||||
double value_;
|
||||
|
||||
public:
|
||||
test(mapnik::parameters const& params)
|
||||
: test_case(params),
|
||||
value_(-0.1234) {}
|
||||
: test_case(params)
|
||||
, value_(-0.1234)
|
||||
{}
|
||||
bool validate() const
|
||||
{
|
||||
std::string s;
|
||||
|
@ -17,7 +19,8 @@ public:
|
|||
bool operator()() const
|
||||
{
|
||||
std::string out;
|
||||
for (std::size_t i=0;i<iterations_;++i) {
|
||||
for (std::size_t i = 0; i < iterations_; ++i)
|
||||
{
|
||||
out.clear();
|
||||
mapnik::util::to_string(out, value_);
|
||||
}
|
||||
|
|
|
@ -4,10 +4,12 @@
|
|||
class test : public benchmark::test_case
|
||||
{
|
||||
double value_;
|
||||
|
||||
public:
|
||||
test(mapnik::parameters const& params)
|
||||
: test_case(params),
|
||||
value_(-0.1234) {}
|
||||
: test_case(params)
|
||||
, value_(-0.1234)
|
||||
{}
|
||||
bool validate() const
|
||||
{
|
||||
std::ostringstream s;
|
||||
|
@ -17,7 +19,8 @@ public:
|
|||
bool operator()() const
|
||||
{
|
||||
std::string out;
|
||||
for (std::size_t i=0;i<iterations_;++i) {
|
||||
for (std::size_t i = 0; i < iterations_; ++i)
|
||||
{
|
||||
std::ostringstream s;
|
||||
s << value_;
|
||||
out = s.str();
|
||||
|
|
|
@ -13,26 +13,28 @@ using mapnik::util::from_u8string;
|
|||
class test : public benchmark::test_case
|
||||
{
|
||||
std::string utf8_;
|
||||
|
||||
public:
|
||||
test(mapnik::parameters const& params)
|
||||
: test_case(params),
|
||||
utf8_(from_u8string(u8"שלום")) {}
|
||||
: test_case(params)
|
||||
, utf8_(from_u8string(u8"שלום"))
|
||||
{}
|
||||
bool validate() const
|
||||
{
|
||||
std::wstring_convert<std::codecvt_utf8<char32_t>, char32_t> utf32conv;
|
||||
std::u32string utf32 = utf32conv.from_bytes(utf8_);
|
||||
if (utf32.size() != 4) return false;
|
||||
if (utf32[0] != 0x5e9 &&
|
||||
utf32[1] != 0x5dc &&
|
||||
utf32[2] != 0x5d5 &&
|
||||
utf32[3] != 0x5dd) return false;
|
||||
if (utf32.size() != 4)
|
||||
return false;
|
||||
if (utf32[0] != 0x5e9 && utf32[1] != 0x5dc && utf32[2] != 0x5d5 && utf32[3] != 0x5dd)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
bool operator()() const
|
||||
{
|
||||
std::u32string utf32;
|
||||
std::wstring_convert<std::codecvt_utf8<char32_t>, char32_t> utf32conv;
|
||||
for (std::size_t i=0;i<iterations_;++i) {
|
||||
for (std::size_t i = 0; i < iterations_; ++i)
|
||||
{
|
||||
utf32 = utf32conv.from_bytes(utf8_);
|
||||
}
|
||||
return true;
|
||||
|
@ -44,24 +46,26 @@ public:
|
|||
class test2 : public benchmark::test_case
|
||||
{
|
||||
std::string utf8_;
|
||||
|
||||
public:
|
||||
test2(mapnik::parameters const& params)
|
||||
: test_case(params),
|
||||
utf8_(from_u8string(u8"שלום")) {}
|
||||
: test_case(params)
|
||||
, utf8_(from_u8string(u8"שלום"))
|
||||
{}
|
||||
bool validate() const
|
||||
{
|
||||
std::u32string utf32 = boost::locale::conv::utf_to_utf<char32_t>(utf8_);
|
||||
if (utf32.size() != 4) return false;
|
||||
if (utf32[0] != 0x5e9 &&
|
||||
utf32[1] != 0x5dc &&
|
||||
utf32[2] != 0x5d5 &&
|
||||
utf32[3] != 0x5dd) return false;
|
||||
if (utf32.size() != 4)
|
||||
return false;
|
||||
if (utf32[0] != 0x5e9 && utf32[1] != 0x5dc && utf32[2] != 0x5d5 && utf32[3] != 0x5dd)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
bool operator()() const
|
||||
{
|
||||
std::u32string utf32;
|
||||
for (std::size_t i=0;i<iterations_;++i) {
|
||||
for (std::size_t i = 0; i < iterations_; ++i)
|
||||
{
|
||||
utf32 = boost::locale::conv::utf_to_utf<char32_t>(utf8_);
|
||||
}
|
||||
return true;
|
||||
|
@ -71,27 +75,29 @@ public:
|
|||
class test3 : public benchmark::test_case
|
||||
{
|
||||
std::string utf8_;
|
||||
|
||||
public:
|
||||
test3(mapnik::parameters const& params)
|
||||
: test_case(params),
|
||||
utf8_(from_u8string(u8"שלום")) {}
|
||||
: test_case(params)
|
||||
, utf8_(from_u8string(u8"שלום"))
|
||||
{}
|
||||
bool validate() const
|
||||
{
|
||||
mapnik::transcoder tr_("utf-8");
|
||||
mapnik::value_unicode_string utf32 = tr_.transcode(utf8_.data(), utf8_.size());
|
||||
// std::u32string utf32 = boost::locale::conv::utf_to_utf<char32_t>(utf8_);
|
||||
if (utf32.length() != 4) return false;
|
||||
if (utf32[0] != 0x5e9 &&
|
||||
utf32[1] != 0x5dc &&
|
||||
utf32[2] != 0x5d5 &&
|
||||
utf32[3] != 0x5dd) return false;
|
||||
if (utf32.length() != 4)
|
||||
return false;
|
||||
if (utf32[0] != 0x5e9 && utf32[1] != 0x5dc && utf32[2] != 0x5d5 && utf32[3] != 0x5dd)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
bool operator()() const
|
||||
{
|
||||
mapnik::transcoder tr_("utf-8");
|
||||
mapnik::value_unicode_string utf32;
|
||||
for (std::size_t i=0;i<iterations_;++i) {
|
||||
for (std::size_t i = 0; i < iterations_; ++i)
|
||||
{
|
||||
utf32 = tr_.transcode(utf8_.data(), utf8_.size());
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -4,14 +4,10 @@ class test : public benchmark::test_case
|
|||
{
|
||||
public:
|
||||
test(mapnik::parameters const& params)
|
||||
: test_case(params) {}
|
||||
bool validate() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
void operator()() const
|
||||
{
|
||||
}
|
||||
: test_case(params)
|
||||
{}
|
||||
bool validate() const { return true; }
|
||||
void operator()() const {}
|
||||
};
|
||||
|
||||
BENCHMARK(test, "test name")
|
||||
|
|
16
cmake/clang-format.cmake
Normal file
16
cmake/clang-format.cmake
Normal file
|
@ -0,0 +1,16 @@
|
|||
function(format_dir dir)
|
||||
file(GLOB_RECURSE sources
|
||||
"${dir}/*.cpp"
|
||||
"${dir}/*.hpp"
|
||||
)
|
||||
execute_process(COMMAND clang-format -style=file -i ${sources})
|
||||
endfunction()
|
||||
|
||||
|
||||
format_dir(benchmark)
|
||||
format_dir(demo)
|
||||
format_dir(include)
|
||||
format_dir(plugins)
|
||||
format_dir(src)
|
||||
format_dir(test)
|
||||
format_dir(utils)
|
|
@ -45,14 +45,16 @@
|
|||
|
||||
#include <iostream>
|
||||
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
using namespace mapnik;
|
||||
const std::string srs_lcc="+proj=lcc +ellps=GRS80 +lat_0=49 +lon_0=-95 +lat+1=49 +lat_2=77 +datum=NAD83 +units=m +no_defs";
|
||||
const std::string srs_merc="+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over";
|
||||
const std::string srs_lcc =
|
||||
"+proj=lcc +ellps=GRS80 +lat_0=49 +lon_0=-95 +lat+1=49 +lat_2=77 +datum=NAD83 +units=m +no_defs";
|
||||
const std::string srs_merc = "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 "
|
||||
"+units=m +nadgrids=@null +wktext +no_defs +over";
|
||||
|
||||
try {
|
||||
try
|
||||
{
|
||||
std::cout << " running demo ... \n";
|
||||
datasource_cache::instance().register_datasources("plugins/input/");
|
||||
freetype_engine::register_font("fonts/dejavu-fonts-ttf-2.37/ttf/DejaVuSans.ttf");
|
||||
|
@ -215,7 +217,8 @@ int main ( int, char** )
|
|||
placement_finder->defaults.format_defaults.fill = color(0, 0, 0);
|
||||
placement_finder->defaults.format_defaults.halo_fill = color(255, 255, 200);
|
||||
placement_finder->defaults.format_defaults.halo_radius = 1.0;
|
||||
placement_finder->defaults.set_format_tree(std::make_shared<mapnik::formatting::text_node>(parse_expression("[GEONAME]")));
|
||||
placement_finder->defaults.set_format_tree(
|
||||
std::make_shared<mapnik::formatting::text_node>(parse_expression("[GEONAME]")));
|
||||
put<text_placements_ptr>(text_sym, keys::text_placements_, placement_finder);
|
||||
r.append(std::move(text_sym));
|
||||
}
|
||||
|
@ -342,8 +345,7 @@ int main ( int, char** )
|
|||
but instead let's build up a surface for more flexibility
|
||||
*/
|
||||
|
||||
cairo_surface_ptr image_surface(
|
||||
cairo_image_surface_create(CAIRO_FORMAT_ARGB32,m.width(),m.height()),
|
||||
cairo_surface_ptr image_surface(cairo_image_surface_create(CAIRO_FORMAT_ARGB32, m.width(), m.height()),
|
||||
cairo_surface_closer());
|
||||
double scale_factor = 1.0;
|
||||
cairo_ptr image_context(create_context(image_surface));
|
||||
|
@ -353,7 +355,8 @@ int main ( int, char** )
|
|||
cairo_surface_write_to_png(&*image_surface, "cairo-demo.png");
|
||||
// but we can also benefit from quantization by converting
|
||||
// to a mapnik image object and then saving that
|
||||
mapnik::image_rgba8 im_data(cairo_image_surface_get_width(&*image_surface), cairo_image_surface_get_height(&*image_surface));
|
||||
mapnik::image_rgba8 im_data(cairo_image_surface_get_width(&*image_surface),
|
||||
cairo_image_surface_get_height(&*image_surface));
|
||||
cairo_image_to_rgba8(im_data, image_surface);
|
||||
save_to_file(im_data, "cairo-demo256.png", "png8");
|
||||
cairo_surface_finish(&*image_surface);
|
||||
|
@ -367,13 +370,11 @@ int main ( int, char** )
|
|||
#endif
|
||||
// save map definition (data + style)
|
||||
save_map(m, "map.xml");
|
||||
}
|
||||
catch ( std::exception const& ex )
|
||||
} catch (std::exception const& ex)
|
||||
{
|
||||
std::cerr << "### std::exception: " << ex.what() << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
catch ( ... )
|
||||
} catch (...)
|
||||
{
|
||||
std::cerr << "### Unknown exception." << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
|
|
|
@ -17,10 +17,8 @@
|
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
|
||||
#include "about_dialog.hpp"
|
||||
|
||||
|
||||
about_dialog::about_dialog(QWidget* parent)
|
||||
: QDialog(parent)
|
||||
{
|
||||
|
|
|
@ -17,8 +17,6 @@
|
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#if !defined ABOUT_DIALOG_HPP
|
||||
#define ABOUT_DIALOG_HPP
|
||||
|
||||
|
@ -30,9 +28,9 @@ class about_dialog : public QDialog
|
|||
Q_OBJECT
|
||||
public:
|
||||
about_dialog(QWidget* parent = 0);
|
||||
|
||||
private:
|
||||
Ui::Dialog ui;
|
||||
};
|
||||
|
||||
|
||||
#endif // ABOUT_DIALOG_HPP
|
||||
|
|
|
@ -17,10 +17,8 @@
|
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
|
||||
#include "info_dialog.hpp"
|
||||
|
||||
|
||||
info_dialog::info_dialog(QVector<QPair<QString, QString>> const& info, QWidget* parent)
|
||||
: QDialog(parent)
|
||||
{
|
||||
|
|
|
@ -17,8 +17,6 @@
|
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef INFO_DIALOG_HPP
|
||||
#define INFO_DIALOG_HPP
|
||||
|
||||
|
@ -30,9 +28,9 @@ class info_dialog : public QDialog
|
|||
Q_OBJECT
|
||||
public:
|
||||
info_dialog(QVector<QPair<QString, QString>> const& info, QWidget* parent = 0);
|
||||
|
||||
private:
|
||||
Ui::InfoDialog ui;
|
||||
};
|
||||
|
||||
|
||||
#endif // INFO_DIALOG_HPP
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
|
||||
#include "layer_info_dialog.hpp"
|
||||
|
||||
// mapnik
|
||||
|
@ -26,7 +25,6 @@
|
|||
#include <mapnik/params_impl.hpp>
|
||||
#include <mapnik/layer.hpp>
|
||||
|
||||
|
||||
layer_info_dialog::layer_info_dialog(mapnik::layer& lay, QWidget* parent)
|
||||
: QDialog(parent)
|
||||
{
|
||||
|
|
|
@ -17,16 +17,13 @@
|
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef LAYER_INFO_DIALOG_HPP
|
||||
#define LAYER_INFO_DIALOG_HPP
|
||||
|
||||
#include "ui_layer_info.h"
|
||||
#include <QDialog>
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
namespace mapnik {
|
||||
class layer;
|
||||
}
|
||||
|
||||
|
@ -36,9 +33,9 @@ class layer_info_dialog : public QDialog
|
|||
public:
|
||||
layer_info_dialog(mapnik::layer& l, QWidget* parent = 0);
|
||||
Ui::LayerInfoDialog& getUI();
|
||||
|
||||
private:
|
||||
Ui::LayerInfoDialog ui;
|
||||
};
|
||||
|
||||
|
||||
#endif // LAYER_INFO_DIALOG_HPP
|
||||
|
|
|
@ -17,17 +17,14 @@
|
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
|
||||
#include <QtGui>
|
||||
#include "layerdelegate.hpp"
|
||||
|
||||
LayerDelegate::LayerDelegate(QObject* parent)
|
||||
: QAbstractItemDelegate(parent)
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void LayerDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
|
||||
const QModelIndex &index) const
|
||||
void LayerDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const
|
||||
{
|
||||
painter->setRenderHint(QPainter::Antialiasing);
|
||||
painter->setPen(QPen(QColor(255, 0, 0), 1));
|
||||
|
@ -37,18 +34,15 @@ void LayerDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
|
|||
else
|
||||
painter->setBrush(QBrush(QColor(255, 0, 0, 64)));
|
||||
|
||||
|
||||
painter->drawRoundedRect(option.rect, 4, 4);
|
||||
|
||||
if (option.state & QStyle::State_Selected)
|
||||
painter->setBrush(option.palette.highlightedText());
|
||||
else
|
||||
painter->setBrush(QBrush(QColor(255, 120, 0, 127)));
|
||||
|
||||
}
|
||||
|
||||
QSize LayerDelegate::sizeHint(const QStyleOptionViewItem & /* option */,
|
||||
const QModelIndex & /* index */) const
|
||||
QSize LayerDelegate::sizeHint(const QStyleOptionViewItem& /* option */, const QModelIndex& /* index */) const
|
||||
{
|
||||
return QSize(120, 24);
|
||||
}
|
||||
|
|
|
@ -35,10 +35,8 @@ class LayerDelegate : public QAbstractItemDelegate
|
|||
|
||||
public:
|
||||
LayerDelegate(QObject* parent = 0);
|
||||
void paint(QPainter *painter, const QStyleOptionViewItem &option,
|
||||
const QModelIndex &index) const;
|
||||
QSize sizeHint(const QStyleOptionViewItem &option,
|
||||
const QModelIndex &index ) const;
|
||||
void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const;
|
||||
QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const;
|
||||
};
|
||||
|
||||
#endif // LAYER_DELEGATE_HPP
|
||||
|
|
|
@ -17,8 +17,6 @@
|
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "layerlistmodel.hpp"
|
||||
#include <QIcon>
|
||||
#include <QBrush>
|
||||
|
@ -27,12 +25,14 @@
|
|||
using mapnik::Map;
|
||||
|
||||
LayerListModel::LayerListModel(std::shared_ptr<Map> map, QObject* parent)
|
||||
: QAbstractListModel(parent),
|
||||
map_(map) {}
|
||||
: QAbstractListModel(parent)
|
||||
, map_(map)
|
||||
{}
|
||||
|
||||
int LayerListModel::rowCount(QModelIndex const&) const
|
||||
{
|
||||
if (map_) return map_->layers().size();
|
||||
if (map_)
|
||||
return map_->layers().size();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -76,8 +76,7 @@ QVariant LayerListModel::data(QModelIndex const& index, int role) const
|
|||
}
|
||||
}
|
||||
|
||||
QVariant LayerListModel::headerData(int section, Qt::Orientation orientation,
|
||||
int role) const
|
||||
QVariant LayerListModel::headerData(int section, Qt::Orientation orientation, int role) const
|
||||
{
|
||||
if (role != Qt::DisplayRole)
|
||||
return QVariant();
|
||||
|
@ -88,10 +87,10 @@ QVariant LayerListModel::headerData(int section, Qt::Orientation orientation,
|
|||
return QString("TODO Row %1").arg(section);
|
||||
}
|
||||
|
||||
bool LayerListModel::setData(const QModelIndex &index,
|
||||
const QVariant &value, int role)
|
||||
bool LayerListModel::setData(const QModelIndex& index, const QVariant& value, int role)
|
||||
{
|
||||
if (!map_) return false;
|
||||
if (!map_)
|
||||
return false;
|
||||
|
||||
if (index.isValid() && role == Qt::CheckStateRole)
|
||||
{
|
||||
|
|
|
@ -17,8 +17,6 @@
|
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef LAYER_LIST_MODEL_HPP
|
||||
#define LAYER_LIST_MODEL_HPP
|
||||
|
||||
|
@ -37,10 +35,8 @@ class LayerListModel : public QAbstractListModel
|
|||
LayerListModel(std::shared_ptr<mapnik::Map> map, QObject* parent = 0);
|
||||
int rowCount(const QModelIndex& parent = QModelIndex()) const;
|
||||
QVariant data(const QModelIndex& index, int role) const;
|
||||
QVariant headerData(int section, Qt::Orientation orientation,
|
||||
int role = Qt::DisplayRole) const;
|
||||
bool setData(const QModelIndex &index, const QVariant &value,
|
||||
int role = Qt::EditRole);
|
||||
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
|
||||
bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole);
|
||||
Qt::ItemFlags flags(QModelIndex const& index) const;
|
||||
boost::optional<mapnik::layer&> map_layer(int i);
|
||||
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
|
||||
#include "layerwidget.hpp"
|
||||
#include <qabstractitemdelegate.h>
|
||||
#include <qapplication.h>
|
||||
|
@ -33,17 +32,15 @@
|
|||
#include "layer_info_dialog.hpp"
|
||||
|
||||
LayerTab::LayerTab(QWidget* parent)
|
||||
: QListView(parent) {}
|
||||
|
||||
: QListView(parent)
|
||||
{}
|
||||
|
||||
void LayerTab::paintEvent(QPaintEvent* e)
|
||||
{
|
||||
QListView::paintEvent(e);
|
||||
}
|
||||
|
||||
void LayerTab::dataChanged(const QModelIndex &topLeft,
|
||||
const QModelIndex &bottomRight,
|
||||
const QVector<int> &roles)
|
||||
void LayerTab::dataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight, const QVector<int>& roles)
|
||||
{
|
||||
emit update_mapwidget();
|
||||
QListView::dataChanged(topLeft, bottomRight, roles);
|
||||
|
@ -66,7 +63,6 @@ void LayerTab::layerInfo()
|
|||
if (indexes.size() > 0)
|
||||
{
|
||||
qDebug("id = %d", indexes[0].row());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -86,10 +82,7 @@ void LayerTab::layerInfo2(QModelIndex const& index)
|
|||
}
|
||||
}
|
||||
|
||||
StyleTab::StyleTab(QWidget*)
|
||||
{
|
||||
|
||||
}
|
||||
StyleTab::StyleTab(QWidget*) {}
|
||||
|
||||
void StyleTab::contextMenuEvent(QContextMenuEvent* event)
|
||||
{
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef LAYERWIDGET_HPP
|
||||
#define LAYERWIDGET_HPP
|
||||
|
||||
|
@ -47,6 +46,7 @@ class StyleTab : public QTreeView
|
|||
Q_OBJECT
|
||||
public:
|
||||
StyleTab(QWidget* parent = 0);
|
||||
|
||||
protected:
|
||||
void contextMenuEvent(QContextMenuEvent* event);
|
||||
};
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
|
||||
// qt
|
||||
#include <QApplication>
|
||||
#include <QStringList>
|
||||
|
@ -41,8 +40,7 @@ int main( int argc, char **argv )
|
|||
QSettings settings("viewer.ini", QSettings::IniFormat);
|
||||
|
||||
// register input plug-ins
|
||||
QString plugins_dir = settings.value("mapnik/plugins_dir",
|
||||
QVariant("/usr/local/lib/mapnik/input/")).toString();
|
||||
QString plugins_dir = settings.value("mapnik/plugins_dir", QVariant("/usr/local/lib/mapnik/input/")).toString();
|
||||
datasource_cache::instance().register_datasources(plugins_dir.toStdString());
|
||||
// register fonts
|
||||
int count = settings.beginReadArray("mapnik/fonts");
|
||||
|
@ -57,7 +55,8 @@ int main( int argc, char **argv )
|
|||
QApplication app(argc, argv);
|
||||
MainWindow window;
|
||||
window.show();
|
||||
if (argc > 1) window.open(argv[1]);
|
||||
if (argc > 1)
|
||||
window.open(argv[1]);
|
||||
if (argc >= 3)
|
||||
{
|
||||
QStringList list = QString(argv[2]).split(",");
|
||||
|
@ -68,23 +67,25 @@ int main( int argc, char **argv )
|
|||
double y0 = list[1].toDouble(&ok);
|
||||
double x1 = list[2].toDouble(&ok);
|
||||
double y1 = list[3].toDouble(&ok);
|
||||
if (ok) window.set_default_extent(x0,y0,x1,y1);
|
||||
if (ok)
|
||||
window.set_default_extent(x0, y0, x1, y1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::shared_ptr<mapnik::Map> map = window.get_map();
|
||||
if (map) map->zoom_all();
|
||||
if (map)
|
||||
map->zoom_all();
|
||||
}
|
||||
if (argc == 4)
|
||||
{
|
||||
bool ok;
|
||||
double scaling_factor = QString(argv[3]).toDouble(&ok);
|
||||
if (ok) window.set_scaling_factor(scaling_factor);
|
||||
if (ok)
|
||||
window.set_scaling_factor(scaling_factor);
|
||||
}
|
||||
return app.exec();
|
||||
}
|
||||
catch (std::exception const& ex)
|
||||
} catch (std::exception const& ex)
|
||||
{
|
||||
std::cerr << "Could not start viewer: '" << ex.what() << "'\n";
|
||||
return 1;
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
|
||||
// stl
|
||||
#include <iostream>
|
||||
|
||||
|
@ -58,8 +57,8 @@
|
|||
#include <boost/algorithm/string.hpp>
|
||||
|
||||
MainWindow::MainWindow()
|
||||
: filename_(),
|
||||
default_extent_(-20037508.3428,-20037508.3428,20037508.3428,20037508.3428)
|
||||
: filename_()
|
||||
, default_extent_(-20037508.3428, -20037508.3428, 20037508.3428, 20037508.3428)
|
||||
{
|
||||
mapWidget_ = new MapWidget(this);
|
||||
QSplitter* splitter = new QSplitter(this);
|
||||
|
@ -107,19 +106,18 @@ MainWindow::MainWindow()
|
|||
// slider
|
||||
connect(slider_, SIGNAL(valueChanged(int)), mapWidget_, SLOT(zoomToLevel(int)));
|
||||
// renderer selector
|
||||
connect(renderer_selector_,SIGNAL(currentIndexChanged(QString const&)),
|
||||
mapWidget_, SLOT(updateRenderer(QString const&)));
|
||||
connect(renderer_selector_,
|
||||
SIGNAL(currentIndexChanged(QString const&)),
|
||||
mapWidget_,
|
||||
SLOT(updateRenderer(QString const&)));
|
||||
|
||||
// scale factor
|
||||
connect(scale_factor_,SIGNAL(valueChanged(double)),
|
||||
mapWidget_, SLOT(updateScaleFactor(double)));
|
||||
connect(scale_factor_, SIGNAL(valueChanged(double)), mapWidget_, SLOT(updateScaleFactor(double)));
|
||||
//
|
||||
connect(layerTab_, SIGNAL(update_mapwidget()), mapWidget_, SLOT(updateMap()));
|
||||
connect(layerTab_,SIGNAL(layerSelected(int)),
|
||||
mapWidget_,SLOT(layerSelected(int)));
|
||||
connect(layerTab_, SIGNAL(layerSelected(int)), mapWidget_, SLOT(layerSelected(int)));
|
||||
}
|
||||
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
delete mapWidget_;
|
||||
|
@ -141,8 +139,7 @@ void MainWindow::open(QString const& path)
|
|||
{
|
||||
if (path.isNull())
|
||||
{
|
||||
filename_ = QFileDialog::getOpenFileName(this,tr("Open Mapnik file"),
|
||||
currentPath,"*.xml");
|
||||
filename_ = QFileDialog::getOpenFileName(this, tr("Open Mapnik file"), currentPath, "*.xml");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -151,18 +148,15 @@ void MainWindow::open(QString const& path)
|
|||
|
||||
if (!filename_.isEmpty())
|
||||
{
|
||||
|
||||
load_map_file(filename_);
|
||||
setWindowTitle(tr("%1 - Mapnik Viewer").arg(filename_));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::reload()
|
||||
{
|
||||
if (!filename_.isEmpty())
|
||||
{
|
||||
|
||||
mapnik::box2d<double> bbox = mapWidget_->getMap()->get_current_extent();
|
||||
load_map_file(filename_);
|
||||
mapWidget_->zoomToBox(bbox);
|
||||
|
@ -173,10 +167,10 @@ void MainWindow::reload()
|
|||
void MainWindow::save()
|
||||
{
|
||||
QString initialPath = QDir::currentPath() + "/untitled.xml";
|
||||
QString filename = QFileDialog::getSaveFileName(this, tr("Save"),
|
||||
QString filename = QFileDialog::getSaveFileName(this,
|
||||
tr("Save"),
|
||||
initialPath,
|
||||
tr("%1 Files (*.xml)")
|
||||
.arg(QString("Mapnik definition")));
|
||||
tr("%1 Files (*.xml)").arg(QString("Mapnik definition")));
|
||||
if (!filename.isEmpty())
|
||||
{
|
||||
std::cout << "saving " << filename.toStdString() << std::endl;
|
||||
|
@ -195,12 +189,10 @@ void MainWindow::load_map_file(QString const& filename)
|
|||
{
|
||||
mapnik::auto_cpu_timer t(std::clog, "loading map took: ");
|
||||
mapnik::load_map(*map, filename.toStdString());
|
||||
}
|
||||
catch (std::exception const& ex)
|
||||
} catch (std::exception const& ex)
|
||||
{
|
||||
std::cout << ex.what() << "\n";
|
||||
}
|
||||
catch (...)
|
||||
} catch (...)
|
||||
{
|
||||
std::cerr << "Exception caught in load_map\n";
|
||||
}
|
||||
|
@ -256,11 +248,11 @@ void MainWindow::export_as()
|
|||
QByteArray fileFormat = action->data().toByteArray();
|
||||
QString initialPath = QDir::currentPath() + "/map." + fileFormat;
|
||||
|
||||
QString fileName = QFileDialog::getSaveFileName(this, tr("Export As"),
|
||||
QString fileName = QFileDialog::getSaveFileName(
|
||||
this,
|
||||
tr("Export As"),
|
||||
initialPath,
|
||||
tr("%1 Files (*.%2);;All Files (*)")
|
||||
.arg(QString(fileFormat.toUpper()))
|
||||
.arg(QString(fileFormat)));
|
||||
tr("%1 Files (*.%2);;All Files (*)").arg(QString(fileFormat.toUpper())).arg(QString(fileFormat)));
|
||||
if (!fileName.isEmpty())
|
||||
{
|
||||
QPixmap const& pix = mapWidget_->pixmap();
|
||||
|
@ -270,7 +262,6 @@ void MainWindow::export_as()
|
|||
|
||||
void MainWindow::print()
|
||||
{
|
||||
|
||||
// Q_ASSERT(mapWidget_->pixmap());
|
||||
// QPrintDialog dialog(&printer, this);
|
||||
// if (dialog.exec()) {
|
||||
|
@ -411,8 +402,6 @@ void MainWindow::createToolBars()
|
|||
fileToolBar->addAction(aboutAct);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void MainWindow::set_default_extent(double x0, double y0, double x1, double y1)
|
||||
{
|
||||
try
|
||||
|
@ -427,8 +416,8 @@ void MainWindow::set_default_extent(double x0,double y0, double x1, double y1)
|
|||
mapWidget_->zoomToBox(default_extent_);
|
||||
std::cout << "SET DEFAULT EXT:" << default_extent_ << std::endl;
|
||||
}
|
||||
}
|
||||
catch (...) {}
|
||||
} catch (...)
|
||||
{}
|
||||
}
|
||||
|
||||
void MainWindow::set_scaling_factor(double scaling_factor)
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef MAINWINDOW_HPP
|
||||
#define MAINWINDOW_HPP
|
||||
|
||||
|
@ -46,8 +45,10 @@ class MainWindow : public QMainWindow
|
|||
virtual ~MainWindow();
|
||||
void set_default_extent(double x0, double y0, double x1, double y1);
|
||||
void set_scaling_factor(double scaling_factor);
|
||||
|
||||
public:
|
||||
std::shared_ptr<mapnik::Map> get_map();
|
||||
|
||||
protected:
|
||||
void closeEvent(QCloseEvent* event);
|
||||
public slots:
|
||||
|
@ -65,6 +66,7 @@ public slots:
|
|||
void pan_right();
|
||||
void pan_up();
|
||||
void pan_down();
|
||||
|
||||
private:
|
||||
void createActions();
|
||||
void createMenus();
|
||||
|
@ -112,5 +114,4 @@ private:
|
|||
mapnik::box2d<double> default_extent_;
|
||||
};
|
||||
|
||||
|
||||
#endif // MAINWINDOW_HPP
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
|
||||
#include <QtGui>
|
||||
|
||||
#include <boost/bind.hpp>
|
||||
|
@ -41,54 +40,38 @@
|
|||
#include "mapwidget.hpp"
|
||||
#include "info_dialog.hpp"
|
||||
|
||||
using mapnik::image_rgba8;
|
||||
using mapnik::Map;
|
||||
using mapnik::layer;
|
||||
using mapnik::box2d;
|
||||
using mapnik::coord2d;
|
||||
using mapnik::feature_kv_iterator;
|
||||
using mapnik::feature_ptr;
|
||||
using mapnik::view_transform;
|
||||
using mapnik::image_rgba8;
|
||||
using mapnik::layer;
|
||||
using mapnik::Map;
|
||||
using mapnik::projection;
|
||||
using mapnik::scale_denominator;
|
||||
using mapnik::feature_kv_iterator;
|
||||
using mapnik::view_transform;
|
||||
|
||||
double scales [] = {279541132.014,
|
||||
139770566.007,
|
||||
69885283.0036,
|
||||
34942641.5018,
|
||||
17471320.7509,
|
||||
8735660.37545,
|
||||
4367830.18772,
|
||||
2183915.09386,
|
||||
1091957.54693,
|
||||
545978.773466,
|
||||
272989.386733,
|
||||
136494.693366,
|
||||
68247.3466832,
|
||||
34123.6733416,
|
||||
17061.8366708,
|
||||
8530.9183354,
|
||||
4265.4591677,
|
||||
2132.72958385,
|
||||
1066.36479192,
|
||||
533.182395962};
|
||||
double scales[] = {279541132.014, 139770566.007, 69885283.0036, 34942641.5018, 17471320.7509,
|
||||
8735660.37545, 4367830.18772, 2183915.09386, 1091957.54693, 545978.773466,
|
||||
272989.386733, 136494.693366, 68247.3466832, 34123.6733416, 17061.8366708,
|
||||
8530.9183354, 4265.4591677, 2132.72958385, 1066.36479192, 533.182395962};
|
||||
|
||||
MapWidget::MapWidget(QWidget* parent)
|
||||
: QWidget(parent),
|
||||
map_(),
|
||||
selected_(1),
|
||||
extent_(),
|
||||
cur_tool_(ZoomToBox),
|
||||
start_x_(0),
|
||||
start_y_(0),
|
||||
end_x_(0),
|
||||
end_y_(0),
|
||||
drag_(false),
|
||||
first_(true),
|
||||
pen_(QColor(0,0,255,96)),
|
||||
selectedLayer_(-1),
|
||||
scaling_factor_(1.0),
|
||||
cur_renderer_(AGG)
|
||||
: QWidget(parent)
|
||||
, map_()
|
||||
, selected_(1)
|
||||
, extent_()
|
||||
, cur_tool_(ZoomToBox)
|
||||
, start_x_(0)
|
||||
, start_y_(0)
|
||||
, end_x_(0)
|
||||
, end_y_(0)
|
||||
, drag_(false)
|
||||
, first_(true)
|
||||
, pen_(QColor(0, 0, 255, 96))
|
||||
, selectedLayer_(-1)
|
||||
, scaling_factor_(1.0)
|
||||
, cur_renderer_(AGG)
|
||||
{
|
||||
pen_.setWidth(3);
|
||||
pen_.setCapStyle(Qt::RoundCap);
|
||||
|
@ -162,10 +145,12 @@ void MapWidget::mousePressEvent(QMouseEvent* e)
|
|||
|
||||
for (unsigned index = 0; index < map_->layer_count(); ++index)
|
||||
{
|
||||
if (int(index) != selectedLayer_) continue;
|
||||
if (int(index) != selectedLayer_)
|
||||
continue;
|
||||
|
||||
layer& layer = map_->layers()[index];
|
||||
if (!layer.visible(scale_denom)) continue;
|
||||
if (!layer.visible(scale_denom))
|
||||
continue;
|
||||
std::string name = layer.name();
|
||||
double x = e->x();
|
||||
double y = e->y();
|
||||
|
@ -231,10 +216,9 @@ void MapWidget::mousePressEvent(QMouseEvent* e)
|
|||
}
|
||||
|
||||
// remove annotation layer
|
||||
map_->layers().erase(remove_if(map_->layers().begin(),
|
||||
map_->layers().end(),
|
||||
bind(&layer::name,_1) == "*annotations*")
|
||||
, map_->layers().end());
|
||||
map_->layers().erase(
|
||||
remove_if(map_->layers().begin(), map_->layers().end(), bind(&layer::name, _1) == "*annotations*"),
|
||||
map_->layers().end());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -334,7 +318,8 @@ void MapWidget::wheelEvent(QWheelEvent* e)
|
|||
void MapWidget::keyPressEvent(QKeyEvent* e)
|
||||
{
|
||||
std::cout << "key pressed:" << e->key() << "\n";
|
||||
switch (e->key()) {
|
||||
switch (e->key())
|
||||
{
|
||||
case Qt::Key_Minus:
|
||||
zoomOut();
|
||||
break;
|
||||
|
@ -387,8 +372,6 @@ void MapWidget::keyPressEvent(QKeyEvent *e)
|
|||
default:
|
||||
QWidget::keyPressEvent(e);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void MapWidget::zoomToBox(mapnik::box2d<double> const& bbox)
|
||||
|
@ -472,7 +455,6 @@ void MapWidget::panRight()
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void MapWidget::zoomToLevel(int level)
|
||||
{
|
||||
if (map_ && level >= 0 && level < 19)
|
||||
|
@ -531,20 +513,17 @@ void render_agg(mapnik::Map const& map, double scaling_factor, QPixmap & pix)
|
|||
catch (std::exception const& ex)
|
||||
{
|
||||
std::cerr << "exception: " << ex.what() << std::endl;
|
||||
}
|
||||
catch (...)
|
||||
} catch (...)
|
||||
{
|
||||
std::cerr << "Unknown exception caught!\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void render_grid(mapnik::Map const& map, double scaling_factor, QPixmap& pix)
|
||||
{
|
||||
std::cerr << "Not supported" << std::endl;
|
||||
}
|
||||
|
||||
|
||||
void render_cairo(mapnik::Map const& map, double scaling_factor, QPixmap& pix)
|
||||
{
|
||||
// FIXME
|
||||
|
@ -567,9 +546,12 @@ void render_cairo(mapnik::Map const& map, double scaling_factor, QPixmap & pix)
|
|||
|
||||
void MapWidget::updateRenderer(QString const& txt)
|
||||
{
|
||||
if (txt == "AGG") cur_renderer_ = AGG;
|
||||
else if (txt == "Cairo") cur_renderer_ = Cairo;
|
||||
else if (txt == "Grid") cur_renderer_ = Grid;
|
||||
if (txt == "AGG")
|
||||
cur_renderer_ = AGG;
|
||||
else if (txt == "Cairo")
|
||||
cur_renderer_ = Cairo;
|
||||
else if (txt == "Grid")
|
||||
cur_renderer_ = Grid;
|
||||
std::cerr << "Update renderer called" << std::endl;
|
||||
updateMap();
|
||||
}
|
||||
|
@ -620,8 +602,7 @@ void MapWidget::updateMap()
|
|||
update();
|
||||
// emit signal to interested widgets
|
||||
emit mapViewChanged();
|
||||
}
|
||||
catch (...)
|
||||
} catch (...)
|
||||
{
|
||||
std::cerr << "Unknown exception caught!\n";
|
||||
}
|
||||
|
@ -638,7 +619,6 @@ void MapWidget::setMap(std::shared_ptr<Map> map)
|
|||
map_ = map;
|
||||
}
|
||||
|
||||
|
||||
void MapWidget::layerSelected(int index)
|
||||
{
|
||||
selectedLayer_ = index;
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef MAP_WIDGET_HPP
|
||||
#define MAP_WIDGET_HPP
|
||||
|
||||
|
@ -30,7 +29,6 @@
|
|||
#include <string>
|
||||
#include <memory>
|
||||
|
||||
|
||||
#ifndef Q_MOC_RUN
|
||||
#include <mapnik/map.hpp>
|
||||
#endif
|
||||
|
@ -40,19 +38,13 @@ class MapWidget : public QWidget
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum eTool
|
||||
{
|
||||
enum eTool {
|
||||
ZoomToBox = 1,
|
||||
Pan,
|
||||
Info,
|
||||
};
|
||||
|
||||
enum eRenderer
|
||||
{
|
||||
AGG,
|
||||
Cairo,
|
||||
Grid
|
||||
};
|
||||
enum eRenderer { AGG, Cairo, Grid };
|
||||
|
||||
private:
|
||||
std::shared_ptr<mapnik::Map> map_;
|
||||
|
@ -70,6 +62,7 @@ private:
|
|||
int selectedLayer_;
|
||||
double scaling_factor_;
|
||||
eRenderer cur_renderer_;
|
||||
|
||||
public:
|
||||
MapWidget(QWidget* parent = 0);
|
||||
void setTool(eTool tool);
|
||||
|
@ -93,6 +86,7 @@ public slots:
|
|||
void updateScaleFactor(double scale_factor);
|
||||
signals:
|
||||
void mapViewChanged();
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent* ev);
|
||||
void resizeEvent(QResizeEvent* ev);
|
||||
|
@ -101,10 +95,7 @@ protected:
|
|||
void mouseReleaseEvent(QMouseEvent* e);
|
||||
void wheelEvent(QWheelEvent* e);
|
||||
void keyPressEvent(QKeyEvent* e);
|
||||
void export_to_file(unsigned width,
|
||||
unsigned height,
|
||||
std::string const& filename,
|
||||
std::string const& type);
|
||||
void export_to_file(unsigned width, unsigned height, std::string const& filename, std::string const& type);
|
||||
};
|
||||
|
||||
#endif // MAP_WIDGET_HPP
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
|
||||
#include "styles_model.hpp"
|
||||
#include <mapnik/config.hpp>
|
||||
#include <mapnik/util/variant.hpp>
|
||||
|
@ -48,19 +47,14 @@ class node : private mapnik::util::noncopyable
|
|||
struct wrap : public node_base
|
||||
{
|
||||
wrap(T const& obj)
|
||||
: obj_(obj) {}
|
||||
: obj_(obj)
|
||||
{}
|
||||
|
||||
~wrap() {}
|
||||
|
||||
QString name () const
|
||||
{
|
||||
return obj_.name();
|
||||
}
|
||||
QString name() const { return obj_.name(); }
|
||||
|
||||
QIcon icon() const
|
||||
{
|
||||
return obj_.icon();
|
||||
}
|
||||
QIcon icon() const { return obj_.icon(); }
|
||||
|
||||
T obj_;
|
||||
};
|
||||
|
@ -68,34 +62,19 @@ class node : private mapnik::util::noncopyable
|
|||
public:
|
||||
template<typename T>
|
||||
node(T const& obj, node* parent = 0)
|
||||
: impl_(new wrap<T>(obj)),
|
||||
parent_(parent)
|
||||
: impl_(new wrap<T>(obj))
|
||||
, parent_(parent)
|
||||
{}
|
||||
|
||||
QString name() const
|
||||
{
|
||||
return impl_->name();
|
||||
}
|
||||
QString name() const { return impl_->name(); }
|
||||
|
||||
QIcon icon() const
|
||||
{
|
||||
return impl_->icon();
|
||||
}
|
||||
QIcon icon() const { return impl_->icon(); }
|
||||
|
||||
unsigned num_children() const
|
||||
{
|
||||
return children_.count();
|
||||
}
|
||||
unsigned num_children() const { return children_.count(); }
|
||||
|
||||
node * child(unsigned row) const
|
||||
{
|
||||
return children_.value(row);
|
||||
}
|
||||
node* child(unsigned row) const { return children_.value(row); }
|
||||
|
||||
node * parent() const
|
||||
{
|
||||
return parent_;
|
||||
}
|
||||
node* parent() const { return parent_; }
|
||||
|
||||
node* add_child(node* child)
|
||||
{
|
||||
|
@ -110,10 +89,7 @@ public:
|
|||
return 0;
|
||||
}
|
||||
|
||||
~node()
|
||||
{
|
||||
qDeleteAll(children_);
|
||||
}
|
||||
~node() { qDeleteAll(children_); }
|
||||
|
||||
private:
|
||||
const std::unique_ptr<node_base> impl_;
|
||||
|
@ -121,7 +97,6 @@ private:
|
|||
node* parent_;
|
||||
};
|
||||
|
||||
|
||||
struct symbolizer_info
|
||||
{
|
||||
QString operator()(mapnik::point_symbolizer const& sym) const
|
||||
|
@ -239,7 +214,8 @@ class symbolizer_node
|
|||
{
|
||||
public:
|
||||
symbolizer_node(mapnik::symbolizer const& sym)
|
||||
: sym_(sym) {}
|
||||
: sym_(sym)
|
||||
{}
|
||||
~symbolizer_node() {}
|
||||
|
||||
QString name() const
|
||||
|
@ -259,8 +235,9 @@ class rule_node
|
|||
{
|
||||
public:
|
||||
rule_node(QString name, mapnik::rule const& r)
|
||||
: name_(name),
|
||||
rule_(r) {}
|
||||
: name_(name)
|
||||
, rule_(r)
|
||||
{}
|
||||
~rule_node() {}
|
||||
QString name() const
|
||||
{
|
||||
|
@ -268,10 +245,7 @@ public:
|
|||
return QString(mapnik::to_expression_string(*filter).c_str());
|
||||
}
|
||||
|
||||
QIcon icon() const
|
||||
{
|
||||
return QIcon(":/images/filter.png");
|
||||
}
|
||||
QIcon icon() const { return QIcon(":/images/filter.png"); }
|
||||
|
||||
private:
|
||||
QString name_;
|
||||
|
@ -282,20 +256,15 @@ class style_node
|
|||
{
|
||||
public:
|
||||
style_node(QString name, mapnik::feature_type_style const& style)
|
||||
: name_(name),
|
||||
style_(style) {}
|
||||
: name_(name)
|
||||
, style_(style)
|
||||
{}
|
||||
|
||||
~style_node() {}
|
||||
|
||||
QString name() const
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
QString name() const { return name_; }
|
||||
|
||||
QIcon icon() const
|
||||
{
|
||||
return QIcon(":/images/style.png");
|
||||
}
|
||||
QIcon icon() const { return QIcon(":/images/style.png"); }
|
||||
|
||||
private:
|
||||
QString name_;
|
||||
|
@ -306,26 +275,21 @@ class map_node
|
|||
{
|
||||
public:
|
||||
explicit map_node(std::shared_ptr<mapnik::Map> map)
|
||||
: map_(map) {}
|
||||
: map_(map)
|
||||
{}
|
||||
~map_node() {}
|
||||
|
||||
QString name() const
|
||||
{
|
||||
return QString("Map");
|
||||
}
|
||||
QString name() const { return QString("Map"); }
|
||||
|
||||
QIcon icon() const
|
||||
{
|
||||
return QIcon(":/images/map.png");
|
||||
}
|
||||
QIcon icon() const { return QIcon(":/images/map.png"); }
|
||||
|
||||
private:
|
||||
std::shared_ptr<mapnik::Map> map_;
|
||||
};
|
||||
|
||||
StyleModel::StyleModel(std::shared_ptr<mapnik::Map> map, QObject* parent)
|
||||
: QAbstractItemModel(parent),
|
||||
root_(new node(map_node(map)))
|
||||
: QAbstractItemModel(parent)
|
||||
, root_(new node(map_node(map)))
|
||||
{
|
||||
using style_type = std::map<std::string, mapnik::feature_type_style>;
|
||||
style_type const& styles = map->styles();
|
||||
|
@ -382,7 +346,8 @@ int StyleModel::rowCount(QModelIndex const& parent) const
|
|||
{
|
||||
// qDebug("rowCount");
|
||||
node* parent_node;
|
||||
if (parent.column() > 0) return 0;
|
||||
if (parent.column() > 0)
|
||||
return 0;
|
||||
if (!parent.isValid())
|
||||
parent_node = root_.get();
|
||||
else
|
||||
|
@ -405,7 +370,6 @@ QVariant StyleModel::data(const QModelIndex & index, int role) const
|
|||
{
|
||||
if (role == Qt::DisplayRole)
|
||||
{
|
||||
|
||||
return QVariant(cur_node->name());
|
||||
}
|
||||
else if (role == Qt::DecorationRole)
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef STYLE_MODEL_HPP
|
||||
#define STYLE_MODEL_HPP
|
||||
|
||||
|
@ -27,8 +26,6 @@
|
|||
#include <mapnik/map.hpp>
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
class node;
|
||||
class StyleModel : public QAbstractItemModel
|
||||
{
|
||||
|
@ -42,6 +39,7 @@ class StyleModel : public QAbstractItemModel
|
|||
int rowCount(QModelIndex const& parent = QModelIndex()) const;
|
||||
int columnCount(QModelIndex const& parent = QModelIndex()) const;
|
||||
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
|
||||
|
||||
private:
|
||||
// std::shared_ptr<mapnik::Map> map_;
|
||||
const std::unique_ptr<node> root_;
|
||||
|
|
|
@ -9,8 +9,7 @@ MAPNIK_DISABLE_WARNING_PUSH
|
|||
#include "agg_conv_smooth_poly1.h"
|
||||
MAPNIK_DISABLE_WARNING_POP
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
namespace mapnik {
|
||||
|
||||
struct vcgen_smooth_calucate_adaptive
|
||||
{
|
||||
|
@ -57,12 +56,8 @@ struct vcgen_smooth_calucate_adaptive
|
|||
}
|
||||
}
|
||||
|
||||
return {
|
||||
{v1.x + s1 * smooth_value * (v2.x - xm1),
|
||||
v1.y + s1 * smooth_value * (v2.y - ym1)},
|
||||
{v2.x + s2 * smooth_value * (v1.x - xm2),
|
||||
v2.y + s2 * smooth_value * (v1.y - ym2)}
|
||||
};
|
||||
return {{v1.x + s1 * smooth_value * (v2.x - xm1), v1.y + s1 * smooth_value * (v2.y - ym1)},
|
||||
{v2.x + s2 * smooth_value * (v1.x - xm2), v2.y + s2 * smooth_value * (v1.y - ym2)}};
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -95,45 +90,34 @@ class smooth_converter
|
|||
}
|
||||
|
||||
public:
|
||||
smooth_converter(Geometry & geom) :
|
||||
geom_(geom),
|
||||
impl_(std::move(init_impl(SMOOTH_ALGORITHM_BASIC, geom)))
|
||||
smooth_converter(Geometry& geom)
|
||||
: geom_(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_); }
|
||||
|
||||
void smooth_value(double v)
|
||||
{
|
||||
return util::apply_visitor([=](auto & impl) {
|
||||
impl.smooth_value(v);
|
||||
}, impl_);
|
||||
return util::apply_visitor([=](auto& impl) { impl.smooth_value(v); }, impl_);
|
||||
}
|
||||
|
||||
void rewind(unsigned path_id)
|
||||
{
|
||||
return util::apply_visitor([=](auto & impl) {
|
||||
return impl.rewind(path_id);
|
||||
}, impl_);
|
||||
return util::apply_visitor([=](auto& impl) { return impl.rewind(path_id); }, impl_);
|
||||
}
|
||||
|
||||
unsigned vertex(double* x, double* y)
|
||||
{
|
||||
return util::apply_visitor([=](auto & impl) {
|
||||
return impl.vertex(x, y);
|
||||
}, impl_);
|
||||
return util::apply_visitor([=](auto& impl) { return impl.vertex(x, y); }, impl_);
|
||||
}
|
||||
|
||||
unsigned type() const
|
||||
{
|
||||
return util::apply_visitor([](auto const& impl) {
|
||||
return impl.type();
|
||||
}, impl_);
|
||||
return util::apply_visitor([](auto const& impl) { return impl.type(); }, impl_);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_ADAPTIVE_SMOOTH_HPP
|
||||
|
|
|
@ -78,41 +78,40 @@ struct agg_polygon_pattern : agg_pattern_base
|
|||
using pixfmt_type = agg::pixfmt_custom_blend_rgba<blender_type, agg::rendering_buffer>;
|
||||
using wrap_x_type = agg::wrap_mode_repeat;
|
||||
using wrap_y_type = agg::wrap_mode_repeat;
|
||||
using img_source_type = agg::image_accessor_wrap<agg::pixfmt_rgba32_pre,
|
||||
wrap_x_type,
|
||||
wrap_y_type>;
|
||||
using img_source_type = agg::image_accessor_wrap<agg::pixfmt_rgba32_pre, wrap_x_type, wrap_y_type>;
|
||||
using span_gen_type = agg::span_pattern_rgba<img_source_type>;
|
||||
using renderer_base = agg::renderer_base<pixfmt_type>;
|
||||
using renderer_type = agg::renderer_scanline_aa_alpha<renderer_base,
|
||||
agg::span_allocator<agg::rgba8>,
|
||||
span_gen_type>;
|
||||
using renderer_type =
|
||||
agg::renderer_scanline_aa_alpha<renderer_base, agg::span_allocator<agg::rgba8>, span_gen_type>;
|
||||
|
||||
agg_polygon_pattern(image_rgba8 const& pattern_img,
|
||||
renderer_common const& common,
|
||||
symbolizer_base const& sym,
|
||||
mapnik::feature_impl const& feature,
|
||||
proj_transform const& prj_trans)
|
||||
: agg_pattern_base{pattern_img, common, sym, feature, prj_trans},
|
||||
clip_(get<value_bool, keys::clip>(sym_, feature_, common_.vars_)),
|
||||
clip_box_(clipping_extent(common)),
|
||||
tr_(geom_transform()),
|
||||
converter_(clip_box_, sym, common.t_, prj_trans, tr_,
|
||||
feature, common.vars_, common.scale_factor_)
|
||||
: agg_pattern_base{pattern_img, common, sym, feature, prj_trans}
|
||||
, clip_(get<value_bool, keys::clip>(sym_, feature_, common_.vars_))
|
||||
, clip_box_(clipping_extent(common))
|
||||
, tr_(geom_transform())
|
||||
, converter_(clip_box_, sym, common.t_, prj_trans, tr_, feature, common.vars_, common.scale_factor_)
|
||||
{
|
||||
value_double simplify_tolerance = get<value_double, keys::simplify_tolerance>(sym_, feature_, common_.vars_);
|
||||
value_double smooth = get<value_double, keys::smooth>(sym_, feature_, common_.vars_);
|
||||
|
||||
if (simplify_tolerance > 0.0) converter_.template set<simplify_tag>();
|
||||
if (simplify_tolerance > 0.0)
|
||||
converter_.template set<simplify_tag>();
|
||||
converter_.template set<affine_transform_tag>();
|
||||
if (smooth > 0.0) converter_.template set<smooth_tag>();
|
||||
if (smooth > 0.0)
|
||||
converter_.template set<smooth_tag>();
|
||||
}
|
||||
|
||||
void render(renderer_base& ren_base, rasterizer& ras)
|
||||
{
|
||||
coord<double, 2> offset(pattern_offset(sym_, feature_, prj_trans_, common_,
|
||||
pattern_img_.width(), pattern_img_.height()));
|
||||
coord<double, 2> offset(
|
||||
pattern_offset(sym_, feature_, prj_trans_, common_, pattern_img_.width(), pattern_img_.height()));
|
||||
agg::rendering_buffer pattern_rbuf((agg::int8u*)pattern_img_.bytes(),
|
||||
pattern_img_.width(), pattern_img_.height(),
|
||||
pattern_img_.width(),
|
||||
pattern_img_.height(),
|
||||
pattern_img_.width() * 4);
|
||||
agg::pixfmt_rgba32_pre pixf_pattern(pattern_rbuf);
|
||||
img_source_type img_src(pixf_pattern);
|
||||
|
@ -122,8 +121,7 @@ struct agg_polygon_pattern : agg_pattern_base
|
|||
value_double opacity = get<double, keys::opacity>(sym_, feature_, common_.vars_);
|
||||
renderer_type rp(ren_base, sa, sg, unsigned(opacity * 255));
|
||||
|
||||
using apply_vertex_converter_type = detail::apply_vertex_converter<
|
||||
VertexConverter, rasterizer>;
|
||||
using apply_vertex_converter_type = detail::apply_vertex_converter<VertexConverter, rasterizer>;
|
||||
using vertex_processor_type = geometry::vertex_processor<apply_vertex_converter_type>;
|
||||
apply_vertex_converter_type apply(converter_, ras);
|
||||
mapnik::util::apply_visitor(vertex_processor_type(apply), feature_.get_geometry());
|
||||
|
@ -139,5 +137,4 @@ struct agg_polygon_pattern : agg_pattern_base
|
|||
|
||||
} // namespace mapnik
|
||||
|
||||
|
||||
#endif // MAPNIK_RENDER_POLYGON_PATTERN_HPP
|
||||
|
|
|
@ -59,6 +59,6 @@ void set_gamma_method(T & ras_ptr, double gamma, gamma_method_enum method)
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_AGG_HELPERS_HPP
|
||||
|
|
|
@ -33,24 +33,18 @@ MAPNIK_DISABLE_WARNING_PUSH
|
|||
#include "agg_color_rgba.h"
|
||||
MAPNIK_DISABLE_WARNING_POP
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
namespace mapnik {
|
||||
|
||||
class pattern_source : private util::noncopyable
|
||||
{
|
||||
public:
|
||||
pattern_source(image_rgba8 const& pattern, double opacity = 1.0)
|
||||
: pattern_(pattern),
|
||||
opacity_(opacity) {}
|
||||
: pattern_(pattern)
|
||||
, opacity_(opacity)
|
||||
{}
|
||||
|
||||
unsigned int width() const
|
||||
{
|
||||
return pattern_.width();
|
||||
}
|
||||
unsigned int height() const
|
||||
{
|
||||
return pattern_.height();
|
||||
}
|
||||
unsigned int width() const { return pattern_.width(); }
|
||||
unsigned int height() const { return pattern_.height(); }
|
||||
agg::rgba8 pixel(int x, int y) const
|
||||
{
|
||||
unsigned c = pattern_(x, y);
|
||||
|
@ -59,10 +53,11 @@ public:
|
|||
static_cast<unsigned>(((c >> 16) & 0xff) * opacity_),
|
||||
static_cast<unsigned>(((c >> 24) & 0xff) * opacity_));
|
||||
}
|
||||
|
||||
private:
|
||||
image_rgba8 const& pattern_;
|
||||
double opacity_;
|
||||
};
|
||||
}
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_AGG_PATTERN_SOURCE_HPP
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
// mapnik
|
||||
#include <mapnik/util/noncopyable.hpp>
|
||||
|
||||
|
||||
#include <mapnik/warning.hpp>
|
||||
MAPNIK_DISABLE_WARNING_PUSH
|
||||
#include <mapnik/warning_ignore_agg.hpp>
|
||||
|
@ -35,8 +34,10 @@ MAPNIK_DISABLE_WARNING_POP
|
|||
|
||||
namespace mapnik {
|
||||
|
||||
struct rasterizer : agg::rasterizer_scanline_aa<agg::rasterizer_sl_clip_int_sat>, util::noncopyable {};
|
||||
struct rasterizer : agg::rasterizer_scanline_aa<agg::rasterizer_sl_clip_int_sat>,
|
||||
util::noncopyable
|
||||
{};
|
||||
|
||||
}
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_AGG_RASTERIZER_HPP
|
||||
|
|
|
@ -53,9 +53,13 @@ MAPNIK_DISABLE_WARNING_POP
|
|||
namespace mapnik {
|
||||
|
||||
template<typename SvgRenderer, typename RasterizerType, typename RendererBaseType>
|
||||
void render_vector_marker(SvgRenderer & svg_renderer, RasterizerType & ras, RendererBaseType & renb,
|
||||
box2d<double> const& bbox, agg::trans_affine const& tr,
|
||||
double opacity, bool snap_to_pixels)
|
||||
void render_vector_marker(SvgRenderer& svg_renderer,
|
||||
RasterizerType& ras,
|
||||
RendererBaseType& renb,
|
||||
box2d<double> const& bbox,
|
||||
agg::trans_affine const& tr,
|
||||
double opacity,
|
||||
bool snap_to_pixels)
|
||||
{
|
||||
agg::scanline_u8 sl;
|
||||
if (snap_to_pixels)
|
||||
|
@ -73,9 +77,13 @@ void render_vector_marker(SvgRenderer & svg_renderer, RasterizerType & ras, Rend
|
|||
}
|
||||
|
||||
template<typename RendererType, typename RasterizerType>
|
||||
void render_raster_marker(RendererType renb, RasterizerType & ras, image_rgba8 const& src,
|
||||
agg::trans_affine const& tr, double opacity,
|
||||
float scale_factor, bool snap_to_pixels)
|
||||
void render_raster_marker(RendererType renb,
|
||||
RasterizerType& ras,
|
||||
image_rgba8 const& src,
|
||||
agg::trans_affine const& tr,
|
||||
double opacity,
|
||||
float scale_factor,
|
||||
bool snap_to_pixels)
|
||||
{
|
||||
using color_type = agg::rgba8;
|
||||
using const_rendering_buffer = util::rendering_buffer<image_rgba8>;
|
||||
|
@ -84,11 +92,9 @@ void render_raster_marker(RendererType renb, RasterizerType & ras, image_rgba8 c
|
|||
agg::scanline_u8 sl;
|
||||
double width = src.width();
|
||||
double height = src.height();
|
||||
if (std::fabs(1.0 - scale_factor) < 0.001
|
||||
&& (std::fabs(1.0 - tr.sx) < agg::affine_epsilon)
|
||||
&& (std::fabs(0.0 - tr.shy) < agg::affine_epsilon)
|
||||
&& (std::fabs(0.0 - tr.shx) < agg::affine_epsilon)
|
||||
&& (std::fabs(1.0 - tr.sy) < agg::affine_epsilon))
|
||||
if (std::fabs(1.0 - scale_factor) < 0.001 && (std::fabs(1.0 - tr.sx) < agg::affine_epsilon) &&
|
||||
(std::fabs(0.0 - tr.shy) < agg::affine_epsilon) && (std::fabs(0.0 - tr.shx) < agg::affine_epsilon) &&
|
||||
(std::fabs(1.0 - tr.sy) < agg::affine_epsilon))
|
||||
{
|
||||
const_rendering_buffer src_buffer(src);
|
||||
pixfmt_pre pixf_mask(src_buffer);
|
||||
|
@ -102,11 +108,7 @@ void render_raster_marker(RendererType renb, RasterizerType & ras, image_rgba8 c
|
|||
}
|
||||
else
|
||||
{
|
||||
renb.blend_from(pixf_mask,
|
||||
0,
|
||||
static_cast<int>(tr.tx),
|
||||
static_cast<int>(tr.ty),
|
||||
unsigned(255*opacity));
|
||||
renb.blend_from(pixf_mask, 0, static_cast<int>(tr.tx), static_cast<int>(tr.ty), unsigned(255 * opacity));
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -115,15 +117,18 @@ void render_raster_marker(RendererType renb, RasterizerType & ras, image_rgba8 c
|
|||
using interpolator_type = agg::span_interpolator_linear<>;
|
||||
// using span_gen_type = agg::span_image_filter_rgba_2x2<img_accessor_type,interpolator_type>;
|
||||
using span_gen_type = agg::span_image_resample_rgba_affine<img_accessor_type>;
|
||||
using renderer_type = agg::renderer_scanline_aa_alpha<RendererType,
|
||||
agg::span_allocator<color_type>,
|
||||
span_gen_type>;
|
||||
using renderer_type =
|
||||
agg::renderer_scanline_aa_alpha<RendererType, agg::span_allocator<color_type>, span_gen_type>;
|
||||
|
||||
double p[8];
|
||||
p[0] = 0; p[1] = 0;
|
||||
p[2] = width; p[3] = 0;
|
||||
p[4] = width; p[5] = height;
|
||||
p[6] = 0; p[7] = height;
|
||||
p[0] = 0;
|
||||
p[1] = 0;
|
||||
p[2] = width;
|
||||
p[3] = 0;
|
||||
p[4] = width;
|
||||
p[5] = height;
|
||||
p[6] = 0;
|
||||
p[7] = height;
|
||||
tr.transform(&p[0], &p[1]);
|
||||
tr.transform(&p[2], &p[3]);
|
||||
tr.transform(&p[4], &p[5]);
|
||||
|
@ -151,6 +156,6 @@ void render_raster_marker(RendererType renb, RasterizerType & ras, image_rgba8 c
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_AGG_RENDER_MARKER_HPP
|
||||
|
|
|
@ -41,7 +41,9 @@
|
|||
#include <stack>
|
||||
|
||||
// fwd declaration to avoid dependence on agg headers
|
||||
namespace agg { struct trans_affine; }
|
||||
namespace agg {
|
||||
struct trans_affine;
|
||||
}
|
||||
|
||||
// fwd declarations to speed up compile
|
||||
namespace mapnik {
|
||||
|
@ -55,8 +57,9 @@ namespace mapnik {
|
|||
class proj_transform;
|
||||
struct rasterizer;
|
||||
struct rgba8_t;
|
||||
template<typename T> class image;
|
||||
}
|
||||
template<typename T>
|
||||
class image;
|
||||
} // namespace mapnik
|
||||
|
||||
namespace mapnik {
|
||||
|
||||
|
@ -65,12 +68,11 @@ class buffer_stack
|
|||
{
|
||||
public:
|
||||
buffer_stack(std::size_t width, std::size_t height)
|
||||
: width_(width),
|
||||
height_(height),
|
||||
buffers_(),
|
||||
position_(buffers_.begin())
|
||||
{
|
||||
}
|
||||
: width_(width)
|
||||
, height_(height)
|
||||
, buffers_()
|
||||
, position_(buffers_.begin())
|
||||
{}
|
||||
|
||||
T& push()
|
||||
{
|
||||
|
@ -86,10 +88,7 @@ public:
|
|||
}
|
||||
return *position_;
|
||||
}
|
||||
bool in_range() const
|
||||
{
|
||||
return (position_ != buffers_.end());
|
||||
}
|
||||
bool in_range() const { return (position_ != buffers_.end()); }
|
||||
|
||||
void pop()
|
||||
{
|
||||
|
@ -98,10 +97,7 @@ public:
|
|||
++position_;
|
||||
}
|
||||
|
||||
T & top() const
|
||||
{
|
||||
return *position_;
|
||||
}
|
||||
T& top() const { return *position_; }
|
||||
|
||||
private:
|
||||
const std::size_t width_;
|
||||
|
@ -114,18 +110,31 @@ template <typename T0, typename T1=label_collision_detector4>
|
|||
class MAPNIK_DECL agg_renderer : public feature_style_processor<agg_renderer<T0>>,
|
||||
private util::noncopyable
|
||||
{
|
||||
|
||||
public:
|
||||
using buffer_type = T0;
|
||||
using processor_impl_type = agg_renderer<T0>;
|
||||
using detector_type = T1;
|
||||
// create with default, empty placement detector
|
||||
agg_renderer(Map const& m, buffer_type & pixmap, double scale_factor=1.0, unsigned offset_x=0, unsigned offset_y=0);
|
||||
agg_renderer(Map const& m,
|
||||
buffer_type& pixmap,
|
||||
double scale_factor = 1.0,
|
||||
unsigned offset_x = 0,
|
||||
unsigned offset_y = 0);
|
||||
// create with external placement detector, possibly non-empty
|
||||
agg_renderer(Map const &m, buffer_type & pixmap, std::shared_ptr<detector_type> detector,
|
||||
double scale_factor=1.0, unsigned offset_x=0, unsigned offset_y=0);
|
||||
agg_renderer(Map const& m,
|
||||
buffer_type& pixmap,
|
||||
std::shared_ptr<detector_type> detector,
|
||||
double scale_factor = 1.0,
|
||||
unsigned offset_x = 0,
|
||||
unsigned offset_y = 0);
|
||||
// pass in mapnik::request object to provide the mutable things per render
|
||||
agg_renderer(Map const& m, request const& req, attributes const& vars, buffer_type & pixmap, double scale_factor=1.0, unsigned offset_x=0, unsigned offset_y=0);
|
||||
agg_renderer(Map const& m,
|
||||
request const& req,
|
||||
attributes const& vars,
|
||||
buffer_type& pixmap,
|
||||
double scale_factor = 1.0,
|
||||
unsigned offset_x = 0,
|
||||
unsigned offset_y = 0);
|
||||
~agg_renderer();
|
||||
void start_map_processing(Map const& map);
|
||||
void end_map_processing(Map const& map);
|
||||
|
@ -135,52 +144,27 @@ public:
|
|||
void start_style_processing(feature_type_style const& st);
|
||||
void end_style_processing(feature_type_style const& st);
|
||||
|
||||
void render_marker(pixel_position const& pos, marker const& marker, agg::trans_affine const& tr,
|
||||
double opacity, composite_mode_e comp_op);
|
||||
void render_marker(pixel_position const& pos,
|
||||
marker const& marker,
|
||||
agg::trans_affine const& tr,
|
||||
double opacity,
|
||||
composite_mode_e comp_op);
|
||||
|
||||
void process(point_symbolizer const& sym,
|
||||
mapnik::feature_impl & feature,
|
||||
proj_transform const& prj_trans);
|
||||
void process(line_symbolizer const& sym,
|
||||
mapnik::feature_impl & feature,
|
||||
proj_transform const& prj_trans);
|
||||
void process(line_pattern_symbolizer const& sym,
|
||||
mapnik::feature_impl & feature,
|
||||
proj_transform const& prj_trans);
|
||||
void process(polygon_symbolizer const& sym,
|
||||
mapnik::feature_impl & feature,
|
||||
proj_transform const& prj_trans);
|
||||
void process(polygon_pattern_symbolizer const& sym,
|
||||
mapnik::feature_impl & feature,
|
||||
proj_transform const& prj_trans);
|
||||
void process(raster_symbolizer const& sym,
|
||||
mapnik::feature_impl & feature,
|
||||
proj_transform const& prj_trans);
|
||||
void process(shield_symbolizer const& sym,
|
||||
mapnik::feature_impl & feature,
|
||||
proj_transform const& prj_trans);
|
||||
void process(text_symbolizer const& sym,
|
||||
mapnik::feature_impl & feature,
|
||||
proj_transform const& prj_trans);
|
||||
void process(building_symbolizer const& sym,
|
||||
mapnik::feature_impl & feature,
|
||||
proj_transform const& prj_trans);
|
||||
void process(markers_symbolizer const& sym,
|
||||
mapnik::feature_impl & feature,
|
||||
proj_transform const& prj_trans);
|
||||
void process(group_symbolizer const& sym,
|
||||
mapnik::feature_impl & feature,
|
||||
proj_transform const& prj_trans);
|
||||
void process(debug_symbolizer const& sym,
|
||||
feature_impl & feature,
|
||||
proj_transform const& prj_trans);
|
||||
void process(dot_symbolizer const& sym,
|
||||
mapnik::feature_impl & feature,
|
||||
proj_transform const& prj_trans);
|
||||
void process(point_symbolizer const& sym, mapnik::feature_impl& feature, proj_transform const& prj_trans);
|
||||
void process(line_symbolizer const& sym, mapnik::feature_impl& feature, proj_transform const& prj_trans);
|
||||
void process(line_pattern_symbolizer const& sym, mapnik::feature_impl& feature, proj_transform const& prj_trans);
|
||||
void process(polygon_symbolizer const& sym, mapnik::feature_impl& feature, proj_transform const& prj_trans);
|
||||
void process(polygon_pattern_symbolizer const& sym, mapnik::feature_impl& feature, proj_transform const& prj_trans);
|
||||
void process(raster_symbolizer const& sym, mapnik::feature_impl& feature, proj_transform const& prj_trans);
|
||||
void process(shield_symbolizer const& sym, mapnik::feature_impl& feature, proj_transform const& prj_trans);
|
||||
void process(text_symbolizer const& sym, mapnik::feature_impl& feature, proj_transform const& prj_trans);
|
||||
void process(building_symbolizer const& sym, mapnik::feature_impl& feature, proj_transform const& prj_trans);
|
||||
void process(markers_symbolizer const& sym, mapnik::feature_impl& feature, proj_transform const& prj_trans);
|
||||
void process(group_symbolizer const& sym, mapnik::feature_impl& feature, proj_transform const& prj_trans);
|
||||
void process(debug_symbolizer const& sym, feature_impl& feature, proj_transform const& prj_trans);
|
||||
void process(dot_symbolizer const& sym, mapnik::feature_impl& feature, proj_transform const& prj_trans);
|
||||
|
||||
inline bool process(rule::symbolizers const&,
|
||||
mapnik::feature_impl&,
|
||||
proj_transform const& )
|
||||
inline bool process(rule::symbolizers const&, mapnik::feature_impl&, proj_transform const&)
|
||||
{
|
||||
// agg renderer doesn't support processing of multiple symbolizers.
|
||||
return false;
|
||||
|
@ -189,26 +173,16 @@ public:
|
|||
void painted(bool painted);
|
||||
bool painted();
|
||||
|
||||
inline eAttributeCollectionPolicy attribute_collection_policy() const
|
||||
{
|
||||
return DEFAULT;
|
||||
}
|
||||
inline eAttributeCollectionPolicy attribute_collection_policy() const { return DEFAULT; }
|
||||
|
||||
inline double scale_factor() const
|
||||
{
|
||||
return common_.scale_factor_;
|
||||
}
|
||||
inline double scale_factor() const { return common_.scale_factor_; }
|
||||
|
||||
inline attributes const& variables() const { return common_.vars_; }
|
||||
|
||||
inline attributes const& variables() const
|
||||
{
|
||||
return common_.vars_;
|
||||
}
|
||||
protected:
|
||||
template<typename R>
|
||||
void debug_draw_box(R& buf, box2d<double> const& extent,
|
||||
double x, double y, double angle = 0.0);
|
||||
void debug_draw_box(box2d<double> const& extent,
|
||||
double x, double y, double angle = 0.0);
|
||||
void debug_draw_box(R& buf, box2d<double> const& extent, double x, double y, double angle = 0.0);
|
||||
void debug_draw_box(box2d<double> const& extent, double x, double y, double angle = 0.0);
|
||||
void draw_geo_extent(box2d<double> const& extent, mapnik::color const& color);
|
||||
|
||||
private:
|
||||
|
|
|
@ -37,7 +37,8 @@ struct attribute
|
|||
{
|
||||
std::string name_;
|
||||
explicit attribute(std::string const& _name)
|
||||
: name_(_name) {}
|
||||
: name_(_name)
|
||||
{}
|
||||
|
||||
template<typename V, typename F>
|
||||
V const& value(F const& f) const
|
||||
|
@ -61,7 +62,8 @@ struct global_attribute
|
|||
{
|
||||
std::string name;
|
||||
explicit global_attribute(std::string const& name_)
|
||||
: name(name_) {}
|
||||
: name(name_)
|
||||
{}
|
||||
|
||||
template<typename V, typename C>
|
||||
V const& operator()(C const& ctx)
|
||||
|
@ -72,6 +74,6 @@ struct global_attribute
|
|||
|
||||
using attributes = std::unordered_map<std::string, value>;
|
||||
|
||||
}
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_ATTRIBUTE_HPP
|
||||
|
|
|
@ -55,12 +55,10 @@ template <typename Container>
|
|||
struct expression_attributes
|
||||
{
|
||||
explicit expression_attributes(Container& names)
|
||||
: names_(names) {}
|
||||
: names_(names)
|
||||
{}
|
||||
|
||||
void operator() (attribute const& attr) const
|
||||
{
|
||||
names_.emplace(attr.name());
|
||||
}
|
||||
void operator()(attribute const& attr) const { names_.emplace(attr.name()); }
|
||||
|
||||
template<typename Tag>
|
||||
void operator()(binary_node<Tag> const& x) const
|
||||
|
@ -75,18 +73,13 @@ struct expression_attributes
|
|||
util::apply_visitor(*this, x.expr);
|
||||
}
|
||||
|
||||
void operator() (regex_match_node const& x) const
|
||||
{
|
||||
util::apply_visitor(*this, x.expr);
|
||||
}
|
||||
void operator()(regex_match_node const& x) const { util::apply_visitor(*this, x.expr); }
|
||||
|
||||
void operator() (regex_replace_node const& x) const
|
||||
{
|
||||
util::apply_visitor(*this, x.expr);
|
||||
}
|
||||
void operator()(regex_replace_node const& x) const { util::apply_visitor(*this, x.expr); }
|
||||
|
||||
template<typename T>
|
||||
void operator() (T const&) const {}
|
||||
void operator()(T const&) const
|
||||
{}
|
||||
|
||||
private:
|
||||
Container& names_;
|
||||
|
@ -97,11 +90,12 @@ class group_attribute_collector : public util::noncopyable
|
|||
private:
|
||||
std::set<std::string>& names_;
|
||||
bool expand_index_columns_;
|
||||
|
||||
public:
|
||||
group_attribute_collector(std::set<std::string>& names,
|
||||
bool expand_index_columns)
|
||||
: names_(names),
|
||||
expand_index_columns_(expand_index_columns) {}
|
||||
group_attribute_collector(std::set<std::string>& names, bool expand_index_columns)
|
||||
: names_(names)
|
||||
, expand_index_columns_(expand_index_columns)
|
||||
{}
|
||||
|
||||
void operator()(group_symbolizer const& sym);
|
||||
};
|
||||
|
@ -110,8 +104,9 @@ template <typename Container>
|
|||
struct extract_attribute_names
|
||||
{
|
||||
explicit extract_attribute_names(Container& names)
|
||||
: names_(names),
|
||||
f_attr_(names) {}
|
||||
: names_(names)
|
||||
, f_attr_(names)
|
||||
{}
|
||||
|
||||
void operator()(mapnik::expression_ptr const& expr) const
|
||||
{
|
||||
|
@ -138,7 +133,8 @@ struct extract_attribute_names
|
|||
expr->add_expressions(expressions);
|
||||
for (it = expressions.begin(); it != expressions.end(); ++it)
|
||||
{
|
||||
if (*it) util::apply_visitor(f_attr_, **it);
|
||||
if (*it)
|
||||
util::apply_visitor(f_attr_, **it);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -152,7 +148,8 @@ struct extract_attribute_names
|
|||
}
|
||||
|
||||
template<typename T>
|
||||
void operator() (T const&) const {}
|
||||
void operator()(T const&) const
|
||||
{}
|
||||
|
||||
private:
|
||||
Container& names_;
|
||||
|
@ -161,11 +158,11 @@ private:
|
|||
|
||||
struct symbolizer_attributes
|
||||
{
|
||||
symbolizer_attributes(std::set<std::string>& names,
|
||||
double & filter_factor)
|
||||
: filter_factor_(filter_factor),
|
||||
f_attrs_(names),
|
||||
g_attrs_(names, true) {}
|
||||
symbolizer_attributes(std::set<std::string>& names, double& filter_factor)
|
||||
: filter_factor_(filter_factor)
|
||||
, f_attrs_(names)
|
||||
, g_attrs_(names, true)
|
||||
{}
|
||||
|
||||
template<typename T>
|
||||
void operator()(T const& sym)
|
||||
|
@ -197,10 +194,7 @@ struct symbolizer_attributes
|
|||
}
|
||||
}
|
||||
|
||||
void operator () (group_symbolizer const& sym)
|
||||
{
|
||||
g_attrs_(sym);
|
||||
}
|
||||
void operator()(group_symbolizer const& sym) { g_attrs_(sym); }
|
||||
|
||||
private:
|
||||
double& filter_factor_;
|
||||
|
@ -208,19 +202,20 @@ private:
|
|||
group_attribute_collector g_attrs_;
|
||||
};
|
||||
|
||||
|
||||
class attribute_collector : public util::noncopyable
|
||||
{
|
||||
private:
|
||||
std::set<std::string>& names_;
|
||||
double filter_factor_;
|
||||
expression_attributes<std::set<std::string>> f_attr;
|
||||
|
||||
public:
|
||||
|
||||
attribute_collector(std::set<std::string>& names)
|
||||
: names_(names),
|
||||
filter_factor_(1.0),
|
||||
f_attr(names) {}
|
||||
: names_(names)
|
||||
, filter_factor_(1.0)
|
||||
, f_attr(names)
|
||||
{}
|
||||
template<typename RuleType>
|
||||
void operator()(RuleType const& r)
|
||||
{
|
||||
|
@ -235,13 +230,9 @@ public:
|
|||
util::apply_visitor(f_attr, *expr);
|
||||
}
|
||||
|
||||
double get_filter_factor() const
|
||||
{
|
||||
return filter_factor_;
|
||||
}
|
||||
double get_filter_factor() const { return filter_factor_; }
|
||||
};
|
||||
|
||||
|
||||
inline void group_attribute_collector::operator()(group_symbolizer const& sym)
|
||||
{
|
||||
// find all column names referenced in the group symbolizer
|
||||
|
|
|
@ -27,35 +27,30 @@
|
|||
|
||||
namespace mapnik {
|
||||
|
||||
enum eAttributeType {
|
||||
Integer=1,
|
||||
Float =2,
|
||||
Double =3,
|
||||
String =4,
|
||||
Boolean =5,
|
||||
Geometry=6,
|
||||
Object=7
|
||||
};
|
||||
enum eAttributeType { Integer = 1, Float = 2, Double = 3, String = 4, Boolean = 5, Geometry = 6, Object = 7 };
|
||||
|
||||
class attribute_descriptor
|
||||
{
|
||||
public:
|
||||
attribute_descriptor(std::string const& name,unsigned type,
|
||||
attribute_descriptor(std::string const& name,
|
||||
unsigned type,
|
||||
bool primary_key = false,
|
||||
int size = -1,
|
||||
int precision = -1)
|
||||
: name_(name),
|
||||
type_(type),
|
||||
size_(size),
|
||||
precision_(precision),
|
||||
primary_key_(primary_key) {}
|
||||
: name_(name)
|
||||
, type_(type)
|
||||
, size_(size)
|
||||
, precision_(precision)
|
||||
, primary_key_(primary_key)
|
||||
{}
|
||||
|
||||
attribute_descriptor(attribute_descriptor const& other)
|
||||
: name_(other.name_),
|
||||
type_(other.type_),
|
||||
size_(other.size_),
|
||||
precision_(other.precision_),
|
||||
primary_key_(other.primary_key_) {}
|
||||
: name_(other.name_)
|
||||
, type_(other.type_)
|
||||
, size_(other.size_)
|
||||
, precision_(other.precision_)
|
||||
, primary_key_(other.primary_key_)
|
||||
{}
|
||||
|
||||
attribute_descriptor& operator=(attribute_descriptor rhs)
|
||||
{
|
||||
|
@ -68,30 +63,15 @@ public:
|
|||
return *this;
|
||||
}
|
||||
|
||||
std::string const& get_name() const
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
std::string const& get_name() const { return name_; }
|
||||
|
||||
unsigned int get_type() const
|
||||
{
|
||||
return type_;
|
||||
}
|
||||
unsigned int get_type() const { return type_; }
|
||||
|
||||
bool is_primary_key() const
|
||||
{
|
||||
return primary_key_;
|
||||
}
|
||||
bool is_primary_key() const { return primary_key_; }
|
||||
|
||||
int get_size() const
|
||||
{
|
||||
return size_;
|
||||
}
|
||||
int get_size() const { return size_; }
|
||||
|
||||
int get_precision() const
|
||||
{
|
||||
return precision_;
|
||||
}
|
||||
int get_precision() const { return precision_; }
|
||||
|
||||
private:
|
||||
std::string name_;
|
||||
|
@ -101,6 +81,6 @@ private:
|
|||
bool primary_key_;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_ATTRIBUTE_DESCRIPTOR_HPP
|
||||
|
|
|
@ -30,23 +30,22 @@
|
|||
#include <iosfwd>
|
||||
#include <string>
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
namespace mapnik {
|
||||
|
||||
class MAPNIK_DECL boolean_type
|
||||
{
|
||||
public:
|
||||
boolean_type()
|
||||
: b_(false) {}
|
||||
: b_(false)
|
||||
{}
|
||||
boolean_type(bool b)
|
||||
: b_(b) {}
|
||||
: b_(b)
|
||||
{}
|
||||
boolean_type(boolean_type const& b)
|
||||
: b_(b.b_) {}
|
||||
: b_(b.b_)
|
||||
{}
|
||||
|
||||
operator bool() const
|
||||
{
|
||||
return b_;
|
||||
}
|
||||
operator bool() const { return b_; }
|
||||
|
||||
boolean_type& operator=(boolean_type const& other)
|
||||
{
|
||||
|
@ -62,27 +61,26 @@ private:
|
|||
|
||||
// Special stream input operator for boolean_type values
|
||||
template<typename charT, typename traits>
|
||||
std::basic_istream<charT, traits> &
|
||||
operator >> ( std::basic_istream<charT, traits> & s, boolean_type & b )
|
||||
std::basic_istream<charT, traits>& operator>>(std::basic_istream<charT, traits>& s, boolean_type& b)
|
||||
{
|
||||
if (s)
|
||||
{
|
||||
std::string word;
|
||||
s >> word;
|
||||
bool result;
|
||||
if (util::string2bool(word,result)) b = result;
|
||||
if (util::string2bool(word, result))
|
||||
b = result;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
template<typename charT, typename traits>
|
||||
std::basic_ostream<charT, traits> &
|
||||
operator << ( std::basic_ostream<charT, traits> & s, boolean_type const& b )
|
||||
std::basic_ostream<charT, traits>& operator<<(std::basic_ostream<charT, traits>& s, boolean_type const& b)
|
||||
{
|
||||
s << (b ? "true" : "false");
|
||||
return s;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_BOOLEAN_HPP
|
||||
|
|
|
@ -23,17 +23,21 @@
|
|||
#ifndef MAPNIK_BOOST_SPIRIT_INSTANTIATE_HPP
|
||||
#define MAPNIK_BOOST_SPIRIT_INSTANTIATE_HPP
|
||||
|
||||
namespace boost { namespace spirit { namespace x3
|
||||
{
|
||||
namespace boost {
|
||||
namespace spirit {
|
||||
namespace x3 {
|
||||
// helper macro
|
||||
#define BOOST_SPIRIT_INSTANTIATE_UNUSED(rule_type, Iterator, Context) \
|
||||
template bool parse_rule<Iterator, Context, boost::spirit::x3::unused_type const>( \
|
||||
rule_type rule_ \
|
||||
, Iterator& first, Iterator const& last \
|
||||
, Context const& context, boost::spirit::x3::unused_type const& ); \
|
||||
rule_type rule_, \
|
||||
Iterator & first, \
|
||||
Iterator const& last, \
|
||||
Context const& context, \
|
||||
boost::spirit::x3::unused_type const&); \
|
||||
/***/
|
||||
|
||||
}}}
|
||||
|
||||
} // namespace x3
|
||||
} // namespace spirit
|
||||
} // namespace boost
|
||||
|
||||
#endif // MAPNIK_BOOST_SPIRIT_INSTANTIATE_HPP
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
*
|
||||
*****************************************************************************/
|
||||
|
||||
|
||||
#ifndef MAPNIK_CAIRO_CONTEXT_HPP
|
||||
#define MAPNIK_CAIRO_CONTEXT_HPP
|
||||
|
||||
|
@ -57,7 +56,8 @@ MAPNIK_DISABLE_WARNING_POP
|
|||
|
||||
namespace mapnik {
|
||||
|
||||
template <typename T> class box2d;
|
||||
template<typename T>
|
||||
class box2d;
|
||||
|
||||
using ErrorStatus = cairo_status_t;
|
||||
|
||||
|
@ -86,12 +86,15 @@ public:
|
|||
cairo_face(std::shared_ptr<font_library> const& library, face_ptr const& face);
|
||||
~cairo_face();
|
||||
cairo_font_face_t* face() const;
|
||||
|
||||
private:
|
||||
class handle
|
||||
{
|
||||
public:
|
||||
handle(std::shared_ptr<font_library> const& library, face_ptr const& face)
|
||||
: library_(library), face_(face) {}
|
||||
: library_(library)
|
||||
, face_(face)
|
||||
{}
|
||||
|
||||
private:
|
||||
std::shared_ptr<font_library> library_;
|
||||
|
@ -127,7 +130,8 @@ struct cairo_closer
|
|||
{
|
||||
void operator()(cairo_t* obj)
|
||||
{
|
||||
if (obj) cairo_destroy(obj);
|
||||
if (obj)
|
||||
cairo_destroy(obj);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -135,7 +139,8 @@ struct cairo_surface_closer
|
|||
{
|
||||
void operator()(cairo_surface_t* surface)
|
||||
{
|
||||
if (surface) cairo_surface_destroy(surface);
|
||||
if (surface)
|
||||
cairo_surface_destroy(surface);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -157,15 +162,12 @@ public:
|
|||
const unsigned int* in_end = in_ptr + pixels;
|
||||
unsigned int* out_ptr;
|
||||
|
||||
surface_ = cairo_surface_ptr(
|
||||
cairo_image_surface_create(
|
||||
CAIRO_FORMAT_ARGB32,
|
||||
surface_ = cairo_surface_ptr(cairo_image_surface_create(CAIRO_FORMAT_ARGB32,
|
||||
static_cast<int>(data.width()),
|
||||
static_cast<int>(data.height())),
|
||||
cairo_surface_closer());
|
||||
|
||||
out_ptr = reinterpret_cast<unsigned int *>(
|
||||
cairo_image_surface_get_data(surface_.get()));
|
||||
out_ptr = reinterpret_cast<unsigned int*>(cairo_image_surface_get_data(surface_.get()));
|
||||
|
||||
while (in_ptr < in_end)
|
||||
{
|
||||
|
@ -186,21 +188,18 @@ public:
|
|||
pattern_ = cairo_pattern_create_for_surface(surface_.get());
|
||||
}
|
||||
|
||||
cairo_pattern(cairo_surface_ptr const& surface) :
|
||||
surface_(surface),
|
||||
pattern_(cairo_pattern_create_for_surface(surface_.get()))
|
||||
{
|
||||
}
|
||||
cairo_pattern(cairo_surface_ptr const& surface)
|
||||
: surface_(surface)
|
||||
, pattern_(cairo_pattern_create_for_surface(surface_.get()))
|
||||
{}
|
||||
|
||||
~cairo_pattern()
|
||||
{
|
||||
if (pattern_) cairo_pattern_destroy(pattern_);
|
||||
if (pattern_)
|
||||
cairo_pattern_destroy(pattern_);
|
||||
}
|
||||
|
||||
void set_matrix(cairo_matrix_t const& matrix)
|
||||
{
|
||||
cairo_pattern_set_matrix(pattern_, &matrix);
|
||||
}
|
||||
void set_matrix(cairo_matrix_t const& matrix) { cairo_pattern_set_matrix(pattern_, &matrix); }
|
||||
|
||||
void set_origin(double x, double y)
|
||||
{
|
||||
|
@ -211,27 +210,17 @@ public:
|
|||
cairo_pattern_set_matrix(pattern_, &matrix);
|
||||
}
|
||||
|
||||
void set_extend(cairo_extend_t extend)
|
||||
{
|
||||
cairo_pattern_set_extend(pattern_, extend);
|
||||
}
|
||||
void set_extend(cairo_extend_t extend) { cairo_pattern_set_extend(pattern_, extend); }
|
||||
|
||||
void set_filter(cairo_filter_t filter)
|
||||
{
|
||||
cairo_pattern_set_filter(pattern_, filter);
|
||||
}
|
||||
void set_filter(cairo_filter_t filter) { cairo_pattern_set_filter(pattern_, filter); }
|
||||
|
||||
cairo_pattern_t * pattern() const
|
||||
{
|
||||
return pattern_;
|
||||
}
|
||||
cairo_pattern_t* pattern() const { return pattern_; }
|
||||
|
||||
private:
|
||||
cairo_surface_ptr surface_;
|
||||
cairo_pattern_t* pattern_;
|
||||
};
|
||||
|
||||
|
||||
class cairo_gradient : private util::noncopyable
|
||||
{
|
||||
public:
|
||||
|
@ -275,21 +264,13 @@ public:
|
|||
cairo_pattern_destroy(pattern_);
|
||||
}
|
||||
|
||||
cairo_pattern_t* gradient() const { return pattern_; }
|
||||
|
||||
cairo_pattern_t * gradient() const
|
||||
{
|
||||
return pattern_;
|
||||
}
|
||||
|
||||
gradient_unit_e units() const
|
||||
{
|
||||
return units_;
|
||||
}
|
||||
gradient_unit_e units() const { return units_; }
|
||||
|
||||
private:
|
||||
cairo_pattern_t* pattern_;
|
||||
gradient_unit_e units_;
|
||||
|
||||
};
|
||||
|
||||
class cairo_context : private util::noncopyable
|
||||
|
@ -297,10 +278,7 @@ class cairo_context : private util::noncopyable
|
|||
public:
|
||||
cairo_context(cairo_ptr const& cairo);
|
||||
|
||||
inline ErrorStatus get_status() const
|
||||
{
|
||||
return cairo_status(cairo_.get());
|
||||
}
|
||||
inline ErrorStatus get_status() const { return cairo_status(cairo_.get()); }
|
||||
|
||||
void clip();
|
||||
void show_page();
|
||||
|
@ -434,10 +412,11 @@ template <typename Context>
|
|||
struct line_pattern_rasterizer
|
||||
{
|
||||
line_pattern_rasterizer(Context& context, cairo_pattern& pattern, unsigned width, unsigned height)
|
||||
: context_(context),
|
||||
pattern_(pattern),
|
||||
width_(width),
|
||||
height_(height) {}
|
||||
: context_(context)
|
||||
, pattern_(pattern)
|
||||
, width_(width)
|
||||
, height_(height)
|
||||
{}
|
||||
|
||||
template<typename T>
|
||||
void add_path(T& path, unsigned start_index = 0)
|
||||
|
@ -485,7 +464,6 @@ struct line_pattern_rasterizer
|
|||
unsigned height_;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_CAIRO_CONTEXT_HPP
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
*
|
||||
*****************************************************************************/
|
||||
|
||||
|
||||
#ifndef MAPNIK_CAIRO_IMAGE_UTIL_HPP
|
||||
#define MAPNIK_CAIRO_IMAGE_UTIL_HPP
|
||||
|
||||
|
@ -33,8 +32,7 @@
|
|||
|
||||
namespace mapnik {
|
||||
|
||||
static inline void cairo_image_to_rgba8(mapnik::image_rgba8 & data,
|
||||
cairo_surface_ptr const& surface)
|
||||
static inline void cairo_image_to_rgba8(mapnik::image_rgba8& data, cairo_surface_ptr const& surface)
|
||||
{
|
||||
if (cairo_image_surface_get_format(&*surface) != CAIRO_FORMAT_ARGB32)
|
||||
{
|
||||
|
@ -62,10 +60,15 @@ static inline void cairo_image_to_rgba8(mapnik::image_rgba8 & data,
|
|||
unsigned int g = (in >> 8) & 0xff;
|
||||
unsigned int b = (in >> 0) & 0xff;
|
||||
|
||||
#define DE_ALPHA(x) do { \
|
||||
if (a == 0) x = 0; \
|
||||
else x = x * 255 / a; \
|
||||
if (x > 255) x = 255; \
|
||||
#define DE_ALPHA(x) \
|
||||
do \
|
||||
{ \
|
||||
if (a == 0) \
|
||||
x = 0; \
|
||||
else \
|
||||
x = x * 255 / a; \
|
||||
if (x > 255) \
|
||||
x = 255; \
|
||||
} while (0)
|
||||
|
||||
DE_ALPHA(r);
|
||||
|
@ -78,7 +81,6 @@ static inline void cairo_image_to_rgba8(mapnik::image_rgba8 & data,
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_CAIRO_IMAGE_UTIL_HPP
|
||||
|
|
|
@ -32,12 +32,14 @@ namespace mapnik {
|
|||
|
||||
class cairo_context;
|
||||
|
||||
void render_vector_marker(cairo_context & context, svg_path_adapter & svg_path,
|
||||
void render_vector_marker(cairo_context& context,
|
||||
svg_path_adapter& svg_path,
|
||||
svg_attribute_type const& attributes,
|
||||
box2d<double> const& bbox, agg::trans_affine const& tr,
|
||||
box2d<double> const& bbox,
|
||||
agg::trans_affine const& tr,
|
||||
double opacity);
|
||||
|
||||
}
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_CAIRO_RENDER_VECTOR_HPP
|
||||
|
||||
|
|
|
@ -58,10 +58,7 @@ struct cairo_save_restore
|
|||
{
|
||||
context_.save();
|
||||
}
|
||||
~cairo_save_restore()
|
||||
{
|
||||
context_.restore();
|
||||
}
|
||||
~cairo_save_restore() { context_.restore(); }
|
||||
cairo_context& context_;
|
||||
};
|
||||
|
||||
|
@ -71,11 +68,7 @@ class MAPNIK_DECL cairo_renderer : public feature_style_processor<cairo_renderer
|
|||
{
|
||||
public:
|
||||
using processor_impl_type = cairo_renderer<T>;
|
||||
cairo_renderer(Map const& m,
|
||||
T const& obj,
|
||||
double scale_factor=1.0,
|
||||
unsigned offset_x=0,
|
||||
unsigned offset_y=0);
|
||||
cairo_renderer(Map const& m, T const& obj, double scale_factor = 1.0, unsigned offset_x = 0, unsigned offset_y = 0);
|
||||
cairo_renderer(Map const& m,
|
||||
request const& req,
|
||||
attributes const& vars,
|
||||
|
@ -97,80 +90,44 @@ public:
|
|||
void end_layer_processing(layer const& lay);
|
||||
void start_style_processing(feature_type_style const& st);
|
||||
void end_style_processing(feature_type_style const& st);
|
||||
void process(point_symbolizer const& sym,
|
||||
mapnik::feature_impl & feature,
|
||||
proj_transform const& prj_trans);
|
||||
void process(line_symbolizer const& sym,
|
||||
mapnik::feature_impl & feature,
|
||||
proj_transform const& prj_trans);
|
||||
void process(line_pattern_symbolizer const& sym,
|
||||
mapnik::feature_impl & feature,
|
||||
proj_transform const& prj_trans);
|
||||
void process(polygon_symbolizer const& sym,
|
||||
mapnik::feature_impl & feature,
|
||||
proj_transform const& prj_trans);
|
||||
void process(polygon_pattern_symbolizer const& sym,
|
||||
mapnik::feature_impl & feature,
|
||||
proj_transform const& prj_trans);
|
||||
void process(raster_symbolizer const& sym,
|
||||
mapnik::feature_impl & feature,
|
||||
proj_transform const& prj_trans);
|
||||
void process(shield_symbolizer const& sym,
|
||||
mapnik::feature_impl & feature,
|
||||
proj_transform const& prj_trans);
|
||||
void process(text_symbolizer const& sym,
|
||||
mapnik::feature_impl & feature,
|
||||
proj_transform const& prj_trans);
|
||||
void process(building_symbolizer const& sym,
|
||||
mapnik::feature_impl & feature,
|
||||
proj_transform const& prj_trans);
|
||||
void process(markers_symbolizer const& sym,
|
||||
mapnik::feature_impl & feature,
|
||||
proj_transform const& prj_trans);
|
||||
void process(group_symbolizer const& sym,
|
||||
mapnik::feature_impl & feature,
|
||||
proj_transform const& prj_trans);
|
||||
void process(debug_symbolizer const& sym,
|
||||
mapnik::feature_impl & feature,
|
||||
proj_transform const& prj_trans);
|
||||
inline bool process(rule::symbolizers const& /*syms*/,
|
||||
mapnik::feature_impl & /*feature*/,
|
||||
proj_transform const& /*prj_trans*/)
|
||||
void process(point_symbolizer const& sym, mapnik::feature_impl& feature, proj_transform const& prj_trans);
|
||||
void process(line_symbolizer const& sym, mapnik::feature_impl& feature, proj_transform const& prj_trans);
|
||||
void process(line_pattern_symbolizer const& sym, mapnik::feature_impl& feature, proj_transform const& prj_trans);
|
||||
void process(polygon_symbolizer const& sym, mapnik::feature_impl& feature, proj_transform const& prj_trans);
|
||||
void process(polygon_pattern_symbolizer const& sym, mapnik::feature_impl& feature, proj_transform const& prj_trans);
|
||||
void process(raster_symbolizer const& sym, mapnik::feature_impl& feature, proj_transform const& prj_trans);
|
||||
void process(shield_symbolizer const& sym, mapnik::feature_impl& feature, proj_transform const& prj_trans);
|
||||
void process(text_symbolizer const& sym, mapnik::feature_impl& feature, proj_transform const& prj_trans);
|
||||
void process(building_symbolizer const& sym, mapnik::feature_impl& feature, proj_transform const& prj_trans);
|
||||
void process(markers_symbolizer const& sym, mapnik::feature_impl& feature, proj_transform const& prj_trans);
|
||||
void process(group_symbolizer const& sym, mapnik::feature_impl& feature, proj_transform const& prj_trans);
|
||||
void process(debug_symbolizer const& sym, mapnik::feature_impl& feature, proj_transform const& prj_trans);
|
||||
inline bool
|
||||
process(rule::symbolizers const& /*syms*/, mapnik::feature_impl& /*feature*/, proj_transform const& /*prj_trans*/)
|
||||
{
|
||||
// cairo renderer doesn't support processing of multiple symbolizers.
|
||||
return false;
|
||||
}
|
||||
|
||||
bool painted()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool painted() { return true; }
|
||||
|
||||
void painted(bool /*painted*/)
|
||||
{
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
inline eAttributeCollectionPolicy attribute_collection_policy() const
|
||||
{
|
||||
return DEFAULT;
|
||||
}
|
||||
inline eAttributeCollectionPolicy attribute_collection_policy() const { return DEFAULT; }
|
||||
|
||||
inline double scale_factor() const
|
||||
{
|
||||
return common_.scale_factor_;
|
||||
}
|
||||
inline double scale_factor() const { return common_.scale_factor_; }
|
||||
|
||||
inline attributes const& variables() const
|
||||
{
|
||||
return common_.vars_;
|
||||
}
|
||||
inline attributes const& variables() const { return common_.vars_; }
|
||||
|
||||
void render_marker(pixel_position const& pos,
|
||||
marker const& marker,
|
||||
agg::trans_affine const& mtx,
|
||||
double opacity = 1.0,
|
||||
bool recenter = true);
|
||||
|
||||
protected:
|
||||
Map const& m_;
|
||||
cairo_context context_;
|
||||
|
@ -178,12 +135,11 @@ protected:
|
|||
cairo_face_manager face_manager_;
|
||||
bool style_level_compositing_;
|
||||
void setup(Map const& m);
|
||||
|
||||
};
|
||||
|
||||
extern template class MAPNIK_DECL cairo_renderer<cairo_ptr>;
|
||||
|
||||
}
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_CAIRO_RENDERER_HPP
|
||||
|
||||
|
|
|
@ -36,10 +36,9 @@ namespace mapnik {
|
|||
|
||||
struct cairo_renderer_process_visitor_p
|
||||
{
|
||||
cairo_renderer_process_visitor_p(agg::trans_affine const& image_tr,
|
||||
double opacity)
|
||||
: image_tr_(image_tr),
|
||||
opacity_(opacity)
|
||||
cairo_renderer_process_visitor_p(agg::trans_affine const& image_tr, double opacity)
|
||||
: image_tr_(image_tr)
|
||||
, opacity_(opacity)
|
||||
{}
|
||||
|
||||
cairo_surface_ptr operator()(marker_svg const& marker) const
|
||||
|
@ -50,9 +49,7 @@ struct cairo_renderer_process_visitor_p
|
|||
double width = std::max(1.0, std::round(bbox.width()));
|
||||
double height = std::max(1.0, std::round(bbox.height()));
|
||||
cairo_rectangle_t extent{0, 0, width, height};
|
||||
cairo_surface_ptr surface(
|
||||
cairo_recording_surface_create(
|
||||
CAIRO_CONTENT_COLOR_ALPHA, &extent),
|
||||
cairo_surface_ptr surface(cairo_recording_surface_create(CAIRO_CONTENT_COLOR_ALPHA, &extent),
|
||||
cairo_surface_closer());
|
||||
|
||||
cairo_ptr cairo = create_context(surface);
|
||||
|
@ -60,12 +57,10 @@ struct cairo_renderer_process_visitor_p
|
|||
|
||||
svg_storage_type& svg = *marker.get_data();
|
||||
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);
|
||||
|
||||
render_vector_marker(context, svg_path, svg_attributes,
|
||||
bbox, tr, opacity_);
|
||||
render_vector_marker(context, svg_path, svg_attributes, bbox, tr, opacity_);
|
||||
|
||||
return surface;
|
||||
}
|
||||
|
@ -76,9 +71,7 @@ struct cairo_renderer_process_visitor_p
|
|||
agg::trans_affine tr(transform(bbox));
|
||||
|
||||
cairo_rectangle_t extent{0, 0, bbox.width(), bbox.height()};
|
||||
cairo_surface_ptr surface(
|
||||
cairo_recording_surface_create(
|
||||
CAIRO_CONTENT_COLOR_ALPHA, &extent),
|
||||
cairo_surface_ptr surface(cairo_recording_surface_create(CAIRO_CONTENT_COLOR_ALPHA, &extent),
|
||||
cairo_surface_closer());
|
||||
|
||||
cairo_ptr cairo = create_context(surface);
|
||||
|
@ -91,9 +84,7 @@ struct cairo_renderer_process_visitor_p
|
|||
|
||||
cairo_surface_ptr operator()(marker_null const&) const
|
||||
{
|
||||
cairo_surface_ptr surface(
|
||||
cairo_recording_surface_create(
|
||||
CAIRO_CONTENT_COLOR_ALPHA, nullptr),
|
||||
cairo_surface_ptr surface(cairo_recording_surface_create(CAIRO_CONTENT_COLOR_ALPHA, nullptr),
|
||||
cairo_surface_closer());
|
||||
cairo_ptr cairo = create_context(surface);
|
||||
cairo_context context(cairo);
|
||||
|
@ -105,9 +96,7 @@ private:
|
|||
{
|
||||
bbox *= image_tr_;
|
||||
coord<double, 2> c = bbox.center();
|
||||
agg::trans_affine mtx = agg::trans_affine_translation(
|
||||
0.5 * bbox.width() - c.x,
|
||||
0.5 * bbox.height() - c.y);
|
||||
agg::trans_affine mtx = agg::trans_affine_translation(0.5 * bbox.width() - c.x, 0.5 * bbox.height() - c.y);
|
||||
return image_tr_ * mtx;
|
||||
}
|
||||
|
||||
|
@ -143,19 +132,20 @@ struct cairo_polygon_pattern : cairo_pattern_base
|
|||
symbolizer_base const& sym,
|
||||
mapnik::feature_impl const& feature,
|
||||
proj_transform const& prj_trans)
|
||||
: cairo_pattern_base{marker, common, sym, feature, prj_trans},
|
||||
clip_(get<value_bool, keys::clip>(sym_, feature_, common_.vars_)),
|
||||
clip_box_(clipping_extent(common)),
|
||||
tr_(geom_transform()),
|
||||
converter_(clip_box_, sym, common.t_, prj_trans, tr_,
|
||||
feature, common.vars_, common.scale_factor_)
|
||||
: cairo_pattern_base{marker, common, sym, feature, prj_trans}
|
||||
, clip_(get<value_bool, keys::clip>(sym_, feature_, common_.vars_))
|
||||
, clip_box_(clipping_extent(common))
|
||||
, tr_(geom_transform())
|
||||
, converter_(clip_box_, sym, common.t_, prj_trans, tr_, feature, common.vars_, common.scale_factor_)
|
||||
{
|
||||
value_double simplify_tolerance = get<value_double, keys::simplify_tolerance>(sym, feature, common_.vars_);
|
||||
value_double smooth = get<value_double, keys::smooth>(sym, feature, common_.vars_);
|
||||
|
||||
converter_.template set<affine_transform_tag>();
|
||||
if (simplify_tolerance > 0.0) converter_.template set<simplify_tag>();
|
||||
if (smooth > 0.0) converter_.template set<smooth_tag>();
|
||||
if (simplify_tolerance > 0.0)
|
||||
converter_.template set<simplify_tag>();
|
||||
if (smooth > 0.0)
|
||||
converter_.template set<smooth_tag>();
|
||||
}
|
||||
|
||||
void render(cairo_fill_rule_t fill_rule, cairo_context& context)
|
||||
|
@ -181,8 +171,12 @@ struct cairo_polygon_pattern : cairo_pattern_base
|
|||
cairo_rectangle_t pattern_surface_extent;
|
||||
if (cairo_recording_surface_get_extents(surface.get(), &pattern_surface_extent))
|
||||
{
|
||||
offset = pattern_offset(sym_, feature_, prj_trans_, common_,
|
||||
pattern_surface_extent.width, pattern_surface_extent.height);
|
||||
offset = pattern_offset(sym_,
|
||||
feature_,
|
||||
prj_trans_,
|
||||
common_,
|
||||
pattern_surface_extent.width,
|
||||
pattern_surface_extent.height);
|
||||
}
|
||||
|
||||
cairo_pattern pattern(surface);
|
||||
|
@ -207,5 +201,4 @@ struct cairo_polygon_pattern : cairo_pattern_base
|
|||
|
||||
} // namespace mapnik
|
||||
|
||||
|
||||
#endif // MAPNIK_CAIRO_RENDER_POLYGON_PATTERN_HPP
|
||||
|
|
|
@ -44,6 +44,6 @@ MAPNIK_DECL void save_to_cairo_file(mapnik::Map const& map,
|
|||
double scale_denominator = 0.0);
|
||||
#endif
|
||||
|
||||
} // end ns
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_CAIRO_IO_HPP
|
||||
|
|
|
@ -50,44 +50,50 @@ public:
|
|||
|
||||
// default ctor
|
||||
color()
|
||||
: red_(0xff),
|
||||
green_(0xff),
|
||||
blue_(0xff),
|
||||
alpha_(0xff),
|
||||
premultiplied_(false)
|
||||
: red_(0xff)
|
||||
, green_(0xff)
|
||||
, blue_(0xff)
|
||||
, alpha_(0xff)
|
||||
, premultiplied_(false)
|
||||
{}
|
||||
|
||||
color(std::uint8_t _red, std::uint8_t _green, std::uint8_t _blue, std::uint8_t _alpha = 0xff, bool premultiplied = false)
|
||||
: red_(_red),
|
||||
green_(_green),
|
||||
blue_(_blue),
|
||||
alpha_(_alpha),
|
||||
premultiplied_(premultiplied)
|
||||
color(std::uint8_t _red,
|
||||
std::uint8_t _green,
|
||||
std::uint8_t _blue,
|
||||
std::uint8_t _alpha = 0xff,
|
||||
bool premultiplied = false)
|
||||
: red_(_red)
|
||||
, green_(_green)
|
||||
, blue_(_blue)
|
||||
, alpha_(_alpha)
|
||||
, premultiplied_(premultiplied)
|
||||
{}
|
||||
|
||||
color(std::uint32_t _rgba, bool premultiplied = false)
|
||||
: red_(_rgba & 0xff),
|
||||
green_((_rgba >> 8) & 0xff),
|
||||
blue_((_rgba >> 16) & 0xff),
|
||||
alpha_((_rgba >> 24) & 0xff),
|
||||
premultiplied_(premultiplied) {}
|
||||
: red_(_rgba & 0xff)
|
||||
, green_((_rgba >> 8) & 0xff)
|
||||
, blue_((_rgba >> 16) & 0xff)
|
||||
, alpha_((_rgba >> 24) & 0xff)
|
||||
, premultiplied_(premultiplied)
|
||||
{}
|
||||
|
||||
// copy ctor
|
||||
color(const color& rhs)
|
||||
: red_(rhs.red_),
|
||||
green_(rhs.green_),
|
||||
blue_(rhs.blue_),
|
||||
alpha_(rhs.alpha_),
|
||||
premultiplied_(rhs.premultiplied_)
|
||||
: red_(rhs.red_)
|
||||
, green_(rhs.green_)
|
||||
, blue_(rhs.blue_)
|
||||
, alpha_(rhs.alpha_)
|
||||
, premultiplied_(rhs.premultiplied_)
|
||||
{}
|
||||
|
||||
// move ctor
|
||||
color(color&& rhs)
|
||||
: red_(std::move(rhs.red_)),
|
||||
green_(std::move(rhs.green_)),
|
||||
blue_(std::move(rhs.blue_)),
|
||||
alpha_(std::move(rhs.alpha_)),
|
||||
premultiplied_(std::move(rhs.premultiplied_)) {}
|
||||
: red_(std::move(rhs.red_))
|
||||
, green_(std::move(rhs.green_))
|
||||
, blue_(std::move(rhs.blue_))
|
||||
, alpha_(std::move(rhs.alpha_))
|
||||
, premultiplied_(std::move(rhs.premultiplied_))
|
||||
{}
|
||||
|
||||
color(std::string const& str, bool premultiplied = false);
|
||||
|
||||
|
@ -104,64 +110,32 @@ public:
|
|||
|
||||
inline bool operator==(color const& rhs) const
|
||||
{
|
||||
return (red_== rhs.red_) &&
|
||||
(green_ == rhs.green_) &&
|
||||
(blue_ == rhs.blue_) &&
|
||||
(alpha_ == rhs.alpha_) &&
|
||||
return (red_ == rhs.red_) && (green_ == rhs.green_) && (blue_ == rhs.blue_) && (alpha_ == rhs.alpha_) &&
|
||||
(premultiplied_ == rhs.premultiplied_);
|
||||
}
|
||||
|
||||
inline std::uint8_t red() const
|
||||
{
|
||||
return red_;
|
||||
}
|
||||
inline std::uint8_t red() const { return red_; }
|
||||
|
||||
inline std::uint8_t green() const
|
||||
{
|
||||
return green_;
|
||||
}
|
||||
inline std::uint8_t green() const { return green_; }
|
||||
|
||||
inline std::uint8_t blue() const
|
||||
{
|
||||
return blue_;
|
||||
}
|
||||
inline std::uint8_t blue() const { return blue_; }
|
||||
|
||||
inline std::uint8_t alpha() const
|
||||
{
|
||||
return alpha_;
|
||||
}
|
||||
inline std::uint8_t alpha() const { return alpha_; }
|
||||
|
||||
inline void set_red(std::uint8_t _red)
|
||||
{
|
||||
red_ = _red;
|
||||
}
|
||||
inline void set_red(std::uint8_t _red) { red_ = _red; }
|
||||
|
||||
inline void set_green(std::uint8_t _green)
|
||||
{
|
||||
green_ = _green;
|
||||
}
|
||||
inline void set_green(std::uint8_t _green) { green_ = _green; }
|
||||
|
||||
inline void set_blue(std::uint8_t _blue)
|
||||
{
|
||||
blue_ = _blue;
|
||||
}
|
||||
inline void set_alpha(std::uint8_t _alpha)
|
||||
{
|
||||
alpha_ = _alpha;
|
||||
}
|
||||
inline bool get_premultiplied() const
|
||||
{
|
||||
return premultiplied_;
|
||||
}
|
||||
inline void set_premultiplied(bool val)
|
||||
{
|
||||
premultiplied_ = val;
|
||||
}
|
||||
inline void set_blue(std::uint8_t _blue) { blue_ = _blue; }
|
||||
inline void set_alpha(std::uint8_t _alpha) { alpha_ = _alpha; }
|
||||
inline bool get_premultiplied() const { return premultiplied_; }
|
||||
inline void set_premultiplied(bool val) { premultiplied_ = val; }
|
||||
|
||||
inline unsigned rgba() const
|
||||
{
|
||||
return static_cast<unsigned>((alpha_ << 24) | (blue_ << 16) | (green_ << 8) | (red_));
|
||||
}
|
||||
|
||||
private:
|
||||
void swap(color& rhs)
|
||||
{
|
||||
|
@ -174,8 +148,7 @@ private:
|
|||
};
|
||||
|
||||
template<typename charT, typename traits>
|
||||
std::basic_ostream<charT, traits> &
|
||||
operator << ( std::basic_ostream<charT, traits> & s, mapnik::color const& c )
|
||||
std::basic_ostream<charT, traits>& operator<<(std::basic_ostream<charT, traits>& s, mapnik::color const& c)
|
||||
{
|
||||
s << c.to_string();
|
||||
return s;
|
||||
|
@ -187,6 +160,6 @@ inline std::size_t hash_value(color const& c)
|
|||
return c.rgba();
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_COLOR_HPP
|
||||
|
|
|
@ -47,6 +47,14 @@
|
|||
#pragma warning(disable: 4996) //_CRT_SECURE_NO_DEPRECATE
|
||||
#endif
|
||||
#else
|
||||
#define MAPNIK_DECL __declspec(dllimport)
|
||||
#endif
|
||||
#pragma warning(disable: 4251)
|
||||
#pragma warning(disable: 4275)
|
||||
#if (_MSC_VER >= 1400) // vc8
|
||||
#pragma warning(disable: 4996) //_CRT_SECURE_NO_DEPRECATE
|
||||
#endif
|
||||
#else
|
||||
#if __GNUC__ >= 4
|
||||
#define MAPNIK_EXP __attribute__((visibility("default")))
|
||||
#define MAPNIK_DECL __attribute__((visibility("default")))
|
||||
|
|
|
@ -36,16 +36,14 @@ class config_error : public std::exception
|
|||
{
|
||||
public:
|
||||
config_error(std::string const& what);
|
||||
config_error(std::string const& what,
|
||||
xml_node const& node);
|
||||
config_error(std::string const& what,
|
||||
unsigned line_number,
|
||||
std::string const& filename);
|
||||
config_error(std::string const& what, xml_node const& node);
|
||||
config_error(std::string const& what, unsigned line_number, std::string const& filename);
|
||||
virtual ~config_error() {}
|
||||
virtual const char* what() const noexcept;
|
||||
void append_context(std::string const& ctx) const;
|
||||
void append_context(std::string const& ctx, xml_node const& node) const;
|
||||
void append_context(xml_node const& node) const;
|
||||
|
||||
protected:
|
||||
mutable std::string what_;
|
||||
mutable unsigned line_number_;
|
||||
|
@ -54,6 +52,6 @@ protected:
|
|||
mutable std::string msg_;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_CONFIG_ERROR_HPP
|
||||
|
|
|
@ -31,41 +31,53 @@ MAPNIK_DISABLE_WARNING_POP
|
|||
|
||||
namespace mapnik {
|
||||
template<typename T, int dim>
|
||||
struct coord {
|
||||
struct coord
|
||||
{
|
||||
using type = T;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct coord<T, 2>
|
||||
: boost::addable<coord<T,2>,
|
||||
boost::addable2<coord<T,2>,T,
|
||||
boost::subtractable<coord<T,2>,
|
||||
boost::subtractable2<coord<T,2>,T,
|
||||
boost::dividable2<coord<T,2>, T,
|
||||
boost::multipliable2<coord<T,2>, T > > > > > >
|
||||
: boost::addable<
|
||||
coord<T, 2>,
|
||||
boost::addable2<
|
||||
coord<T, 2>,
|
||||
T,
|
||||
boost::subtractable<
|
||||
coord<T, 2>,
|
||||
boost::
|
||||
subtractable2<coord<T, 2>, T, boost::dividable2<coord<T, 2>, T, boost::multipliable2<coord<T, 2>, T>>>>>>
|
||||
|
||||
{
|
||||
using type = T;
|
||||
T x;
|
||||
T y;
|
||||
|
||||
public:
|
||||
coord()
|
||||
: x(),y() {}
|
||||
: x()
|
||||
, y()
|
||||
{}
|
||||
coord(T x_, T y_)
|
||||
: x(x_),y(y_) {}
|
||||
: x(x_)
|
||||
, y(y_)
|
||||
{}
|
||||
|
||||
coord(coord<T, 2> const& rhs)
|
||||
: x(rhs.x),
|
||||
y(rhs.y) {}
|
||||
: x(rhs.x)
|
||||
, y(rhs.y)
|
||||
{}
|
||||
|
||||
template<typename T2>
|
||||
coord(coord<T2, 2> const& rhs)
|
||||
: x(type(rhs.x)),
|
||||
y(type(rhs.y)) {}
|
||||
: x(type(rhs.x))
|
||||
, y(type(rhs.y))
|
||||
{}
|
||||
|
||||
coord(coord<T, 2>&& rhs) noexcept
|
||||
: x(std::move(rhs.x)),
|
||||
y(std::move(rhs.y)) {}
|
||||
: x(std::move(rhs.x))
|
||||
, y(std::move(rhs.y))
|
||||
{}
|
||||
|
||||
coord<T, 2>& operator=(coord<T, 2> rhs)
|
||||
{
|
||||
|
@ -127,6 +139,7 @@ public:
|
|||
y /= t;
|
||||
return *this;
|
||||
}
|
||||
|
||||
private:
|
||||
void swap(coord<T, 2>& rhs)
|
||||
{
|
||||
|
@ -142,22 +155,31 @@ struct coord<T,3>
|
|||
T x;
|
||||
T y;
|
||||
T z;
|
||||
|
||||
public:
|
||||
coord()
|
||||
: x(),y(),z() {}
|
||||
: x()
|
||||
, y()
|
||||
, z()
|
||||
{}
|
||||
coord(T x_, T y_, T z_)
|
||||
: x(x_),y(y_),z(z_) {}
|
||||
: x(x_)
|
||||
, y(y_)
|
||||
, z(z_)
|
||||
{}
|
||||
|
||||
template<typename T2>
|
||||
coord(coord<T2, 3> const& rhs)
|
||||
: x(type(rhs.x)),
|
||||
y(type(rhs.y)),
|
||||
z(type(rhs.z)) {}
|
||||
: x(type(rhs.x))
|
||||
, y(type(rhs.y))
|
||||
, z(type(rhs.z))
|
||||
{}
|
||||
|
||||
coord(coord<T, 3>&& rhs) noexcept
|
||||
: x(std::move(rhs.x)),
|
||||
y(std::move(rhs.y)),
|
||||
z(std::move(rhs.z)) {}
|
||||
: x(std::move(rhs.x))
|
||||
, y(std::move(rhs.y))
|
||||
, z(std::move(rhs.z))
|
||||
{}
|
||||
|
||||
coord<T, 3> operator=(coord<T, 3> rhs)
|
||||
{
|
||||
|
@ -172,6 +194,7 @@ public:
|
|||
swap(tmp);
|
||||
return *this;
|
||||
}
|
||||
|
||||
private:
|
||||
void swap(coord<T, 3>& rhs)
|
||||
{
|
||||
|
@ -185,6 +208,6 @@ using coord2d = coord<double,2>;
|
|||
using coord2f = coord<float, 2>;
|
||||
using coord2i = coord<int, 2>;
|
||||
|
||||
}
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_COORD_HPP
|
||||
|
|
|
@ -31,13 +31,11 @@ MAPNIK_DISABLE_WARNING_PUSH
|
|||
#include <boost/spirit/home/x3.hpp>
|
||||
MAPNIK_DISABLE_WARNING_POP
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
namespace mapnik {
|
||||
|
||||
namespace x3 = boost::spirit::x3;
|
||||
|
||||
namespace css_color_grammar
|
||||
{
|
||||
namespace css_color_grammar {
|
||||
|
||||
struct css_color_class;
|
||||
using css_color_grammar_type = x3::rule<css_color_class, mapnik::color>;
|
||||
|
@ -46,6 +44,7 @@ css_color_grammar_type const css_color = "css_color";
|
|||
|
||||
BOOST_SPIRIT_DECLARE(css_color_grammar_type);
|
||||
|
||||
}}
|
||||
} // namespace css_color_grammar
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_CSS_COLOR_GRAMMAR_X3_HPP
|
||||
|
|
|
@ -37,13 +37,8 @@ MAPNIK_DISABLE_WARNING_PUSH
|
|||
#include <boost/fusion/adapted/std_tuple.hpp>
|
||||
MAPNIK_DISABLE_WARNING_POP
|
||||
|
||||
BOOST_FUSION_ADAPT_STRUCT (
|
||||
mapnik::color,
|
||||
(std::uint8_t, red_)
|
||||
(std::uint8_t, green_)
|
||||
(std::uint8_t, blue_)
|
||||
(std::uint8_t, alpha_)
|
||||
)
|
||||
BOOST_FUSION_ADAPT_STRUCT(mapnik::color,
|
||||
(std::uint8_t, red_)(std::uint8_t, green_)(std::uint8_t, blue_)(std::uint8_t, alpha_))
|
||||
|
||||
namespace mapnik {
|
||||
|
||||
|
@ -51,20 +46,21 @@ namespace x3 = boost::spirit::x3;
|
|||
|
||||
namespace css_color_grammar {
|
||||
|
||||
using x3::lit;
|
||||
using x3::uint_parser;
|
||||
using x3::hex;
|
||||
using x3::symbols;
|
||||
using x3::omit;
|
||||
using x3::attr;
|
||||
using x3::double_;
|
||||
using x3::hex;
|
||||
using x3::lit;
|
||||
using x3::no_case;
|
||||
using x3::no_skip;
|
||||
using x3::omit;
|
||||
using x3::symbols;
|
||||
using x3::uint_parser;
|
||||
|
||||
struct named_colors_ : x3::symbols<color>
|
||||
{
|
||||
named_colors_()
|
||||
{
|
||||
// clang-format off
|
||||
add
|
||||
("aliceblue", color(240, 248, 255))
|
||||
("antiquewhite", color(250, 235, 215))
|
||||
|
@ -216,6 +212,7 @@ struct named_colors_ : x3::symbols<color>
|
|||
("yellowgreen", color(154, 205, 50))
|
||||
("transparent", color(0, 0, 0, 0))
|
||||
;
|
||||
// clang-format on
|
||||
}
|
||||
} named_colors;
|
||||
|
||||
|
@ -235,97 +232,80 @@ struct clip_opacity
|
|||
{
|
||||
static double call(double val)
|
||||
{
|
||||
if (val > 1.0) return 1.0;
|
||||
if (val < 0.0) return 0.0;
|
||||
if (val > 1.0)
|
||||
return 1.0;
|
||||
if (val < 0.0)
|
||||
return 0.0;
|
||||
return val;
|
||||
}
|
||||
};
|
||||
|
||||
struct percent_converter
|
||||
{
|
||||
static std::uint8_t call(double val)
|
||||
{
|
||||
return safe_cast<std::uint8_t>(std::lround((255.0 * val)/100.0));
|
||||
}
|
||||
static std::uint8_t call(double val) { return safe_cast<std::uint8_t>(std::lround((255.0 * val) / 100.0)); }
|
||||
};
|
||||
|
||||
auto dec_red = [](auto& ctx)
|
||||
{
|
||||
auto dec_red = [](auto& ctx) {
|
||||
_val(ctx).red_ = _attr(ctx);
|
||||
};
|
||||
|
||||
auto dec_green = [](auto& ctx)
|
||||
{
|
||||
auto dec_green = [](auto& ctx) {
|
||||
_val(ctx).green_ = _attr(ctx);
|
||||
};
|
||||
|
||||
auto dec_blue = [](auto& ctx)
|
||||
{
|
||||
auto dec_blue = [](auto& ctx) {
|
||||
_val(ctx).blue_ = _attr(ctx);
|
||||
};
|
||||
|
||||
auto opacity = [](auto& ctx)
|
||||
{
|
||||
auto opacity = [](auto& ctx) {
|
||||
_val(ctx).alpha_ = uint8_t((255.0 * clip_opacity::call(_attr(ctx))) + 0.5);
|
||||
};
|
||||
|
||||
auto percent_red = [] (auto & ctx)
|
||||
{
|
||||
auto percent_red = [](auto& ctx) {
|
||||
_val(ctx).red_ = percent_converter::call(_attr(ctx));
|
||||
};
|
||||
|
||||
auto percent_green = [] (auto & ctx)
|
||||
{
|
||||
auto percent_green = [](auto& ctx) {
|
||||
_val(ctx).green_ = percent_converter::call(_attr(ctx));
|
||||
};
|
||||
|
||||
auto percent_blue = [] (auto & ctx)
|
||||
{
|
||||
auto percent_blue = [](auto& ctx) {
|
||||
_val(ctx).blue_ = percent_converter::call(_attr(ctx));
|
||||
};
|
||||
|
||||
auto hex1_red = [](auto& ctx)
|
||||
{
|
||||
auto hex1_red = [](auto& ctx) {
|
||||
_val(ctx).red_ = _attr(ctx) | _attr(ctx) << 4;
|
||||
};
|
||||
|
||||
auto hex1_green = [](auto& ctx)
|
||||
{
|
||||
auto hex1_green = [](auto& ctx) {
|
||||
_val(ctx).green_ = _attr(ctx) | _attr(ctx) << 4;
|
||||
};
|
||||
|
||||
auto hex1_blue = [](auto& ctx)
|
||||
{
|
||||
auto hex1_blue = [](auto& ctx) {
|
||||
_val(ctx).blue_ = _attr(ctx) | _attr(ctx) << 4;
|
||||
};
|
||||
|
||||
auto hex1_opacity = [](auto& ctx)
|
||||
{
|
||||
auto hex1_opacity = [](auto& ctx) {
|
||||
_val(ctx).alpha_ = _attr(ctx) | _attr(ctx) << 4;
|
||||
};
|
||||
|
||||
auto hex2_red = [](auto& ctx)
|
||||
{
|
||||
auto hex2_red = [](auto& ctx) {
|
||||
_val(ctx).red_ = _attr(ctx);
|
||||
};
|
||||
|
||||
auto hex2_green = [](auto& ctx)
|
||||
{
|
||||
auto hex2_green = [](auto& ctx) {
|
||||
_val(ctx).green_ = _attr(ctx);
|
||||
};
|
||||
|
||||
auto hex2_blue = [](auto& ctx)
|
||||
{
|
||||
auto hex2_blue = [](auto& ctx) {
|
||||
_val(ctx).blue_ = _attr(ctx);
|
||||
};
|
||||
|
||||
auto hex2_opacity = [](auto& ctx)
|
||||
{
|
||||
auto hex2_opacity = [](auto& ctx) {
|
||||
_val(ctx).alpha_ = _attr(ctx);
|
||||
};
|
||||
|
||||
auto hsl_to_rgba = [] (auto& ctx)
|
||||
{
|
||||
auto hsl_to_rgba = [](auto& ctx) {
|
||||
double h = std::get<0>(_attr(ctx));
|
||||
double s = std::get<1>(_attr(ctx));
|
||||
double l = std::get<2>(_attr(ctx));
|
||||
|
@ -354,7 +334,7 @@ auto hsl_to_rgba = [] (auto& ctx)
|
|||
safe_cast<uint8_t>(std::lround(255.0 * b)),
|
||||
alpha);
|
||||
};
|
||||
|
||||
// clang-format off
|
||||
auto const hex2_color_def = no_skip[lit('#')
|
||||
>> hex2[hex2_red]
|
||||
>> hex2[hex2_green]
|
||||
|
@ -429,21 +409,13 @@ auto const css_color_def =
|
|||
|
|
||||
hsla_color
|
||||
;
|
||||
|
||||
// clang-format on
|
||||
MAPNIK_DISABLE_WARNING_PUSH
|
||||
#include <mapnik/warning_ignore.hpp>
|
||||
BOOST_SPIRIT_DEFINE(
|
||||
css_color,
|
||||
hex2_color,
|
||||
hex1_color,
|
||||
rgb_color,
|
||||
rgba_color,
|
||||
rgb_color_percent,
|
||||
rgba_color_percent
|
||||
);
|
||||
BOOST_SPIRIT_DEFINE(css_color, hex2_color, hex1_color, rgb_color, rgba_color, rgb_color_percent, rgba_color_percent);
|
||||
MAPNIK_DISABLE_WARNING_POP
|
||||
|
||||
} // ns
|
||||
} //ns mapnik
|
||||
} // namespace css_color_grammar
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_CSS_COLOR_GRAMMAR_X3_DEF_HPP
|
||||
|
|
|
@ -31,8 +31,7 @@ MAPNIK_DISABLE_WARNING_PUSH
|
|||
#include <boost/spirit/home/x3.hpp>
|
||||
MAPNIK_DISABLE_WARNING_POP
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
namespace mapnik {
|
||||
using property_value_type = boost::iterator_range<char const*>;
|
||||
using css_key_value = std::pair<std::string, property_value_type>;
|
||||
using definition_type = std::vector<css_key_value>;
|
||||
|
@ -40,8 +39,7 @@ using css_data = std::unordered_multimap<std::string, definition_type>;
|
|||
|
||||
namespace x3 = boost::spirit::x3;
|
||||
|
||||
namespace css_grammar
|
||||
{
|
||||
namespace css_grammar {
|
||||
|
||||
class css_tag;
|
||||
class ident_tag;
|
||||
|
@ -58,17 +56,14 @@ css_grammar_type const css_grammar{"css"};
|
|||
css_skipper_type const css_skipper{"css skipper"};
|
||||
css_classes_type const css_classes{"css classes"};
|
||||
|
||||
BOOST_SPIRIT_DECLARE(ident_grammar_type,
|
||||
css_classes_type,
|
||||
css_grammar_type,
|
||||
css_skipper_type);
|
||||
BOOST_SPIRIT_DECLARE(ident_grammar_type, css_classes_type, css_grammar_type, css_skipper_type);
|
||||
|
||||
}
|
||||
} // namespace css_grammar
|
||||
|
||||
css_grammar::ident_grammar_type const ident_grammar();
|
||||
css_grammar::css_classes_type const classes();
|
||||
css_grammar::css_grammar_type const grammar();
|
||||
css_grammar::css_skipper_type const skipper();
|
||||
}
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_CSS_GRAMMAR_X3_HPP
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
*
|
||||
*****************************************************************************/
|
||||
|
||||
|
||||
#ifndef MAPNIK_CSS_GRAMMAR_X3_DEF_HPP
|
||||
#define MAPNIK_CSS_GRAMMAR_X3_DEF_HPP
|
||||
|
||||
|
@ -33,9 +32,10 @@ MAPNIK_DISABLE_WARNING_PUSH
|
|||
#include <boost/fusion/adapted/std_pair.hpp>
|
||||
MAPNIK_DISABLE_WARNING_POP
|
||||
|
||||
|
||||
/*
|
||||
The grammar below is LL(1) (but note that most UA's should not use it directly, since it doesn't express the parsing conventions, only the CSS1 syntax). The format of the productions is optimized for human consumption and some shorthand notation beyond yacc [15] is used:
|
||||
The grammar below is LL(1) (but note that most UA's should not use it directly, since it doesn't express the parsing
|
||||
conventions, only the CSS1 syntax). The format of the productions is optimized for human consumption and some shorthand
|
||||
notation beyond yacc [15] is used:
|
||||
|
||||
* : 0 or more
|
||||
+ : 1 or more
|
||||
|
@ -148,34 +148,36 @@ namespace x3 = boost::spirit::x3;
|
|||
|
||||
namespace css_grammar {
|
||||
|
||||
using x3::lit;
|
||||
using x3::alnum;
|
||||
using x3::alpha;
|
||||
using x3::attr;
|
||||
using x3::char_;
|
||||
using x3::lexeme;
|
||||
using x3::lit;
|
||||
using x3::no_case;
|
||||
using x3::no_skip;
|
||||
using x3::lexeme;
|
||||
using x3::alpha;
|
||||
using x3::alnum;
|
||||
using x3::char_;
|
||||
using x3::raw;
|
||||
using x3::standard::space;
|
||||
|
||||
// import unicode string rule
|
||||
namespace { auto const& css_string = mapnik::json::grammar::unicode_string; }
|
||||
namespace {
|
||||
auto const& css_string = mapnik::json::grammar::unicode_string;
|
||||
}
|
||||
|
||||
auto assign_def = [] (auto const& ctx)
|
||||
{
|
||||
auto assign_def = [](auto const& ctx) {
|
||||
for (auto const& k : std::get<0>(_attr(ctx)))
|
||||
{
|
||||
_val(ctx).emplace(k, std::get<1>(_attr(ctx)));
|
||||
}
|
||||
};
|
||||
|
||||
auto assign_key = [] (auto const& ctx)
|
||||
{
|
||||
auto assign_key = [](auto const& ctx) {
|
||||
_val(ctx).first = std::move(_attr(ctx));
|
||||
};
|
||||
|
||||
auto assign_value = [] (auto const& ctx) {_val(ctx).second = std::move(_attr(ctx));};
|
||||
auto assign_value = [](auto const& ctx) {
|
||||
_val(ctx).second = std::move(_attr(ctx));
|
||||
};
|
||||
|
||||
// rules
|
||||
x3::rule<class simple_selector_tag, std::string> const simple_selector{"Simple selector"};
|
||||
|
@ -185,9 +187,9 @@ x3::rule<class key_value_tag, css_key_value> const key_value {"CSS Key/Value"};
|
|||
x3::rule<class definition_tag, std::pair<std::vector<std::string>, definition_type>> const definition{"CSS Definition"};
|
||||
|
||||
auto const ident_def = alpha >> *(alnum | char_('-'));
|
||||
auto const simple_selector_def = lexeme[ident >> -((char_('.') | char_('#') | char_(':')) >> ident)]
|
||||
| lexeme[char_('#') >> ident >> -((char_('.') | char_(':')) >> ident)]
|
||||
| lexeme[char_('.') >> ident >> -(char_(':') >> ident)];
|
||||
auto const simple_selector_def = lexeme[ident >> -((char_('.') | char_('#') | char_(':')) >> ident)] |
|
||||
lexeme[char_('#') >> ident >> -((char_('.') | char_(':')) >> ident)] |
|
||||
lexeme[char_('.') >> ident >> -(char_(':') >> ident)];
|
||||
|
||||
auto const selector_def = simple_selector % lit(',');
|
||||
auto const value_def = raw[lexeme[+~char_(";}")]];
|
||||
|
@ -202,8 +204,7 @@ auto const css_classes_def = +lexeme[ident];
|
|||
#include <mapnik/warning.hpp>
|
||||
MAPNIK_DISABLE_WARNING_PUSH
|
||||
#include <mapnik/warning_ignore.hpp>
|
||||
BOOST_SPIRIT_DEFINE(
|
||||
ident,
|
||||
BOOST_SPIRIT_DEFINE(ident,
|
||||
css_classes,
|
||||
simple_selector,
|
||||
selector,
|
||||
|
@ -211,12 +212,11 @@ BOOST_SPIRIT_DEFINE(
|
|||
key_value,
|
||||
definition,
|
||||
css_grammar,
|
||||
css_skipper
|
||||
);
|
||||
css_skipper);
|
||||
|
||||
MAPNIK_DISABLE_WARNING_POP
|
||||
|
||||
} //css_grammar
|
||||
} //mapnik
|
||||
} // namespace css_grammar
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_CSS_GRAMMAR_X3_DEF_HPP
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
*
|
||||
*****************************************************************************/
|
||||
|
||||
|
||||
#ifndef MAPNIK_CSS_UNIT_VALUE_HPP
|
||||
#define MAPNIK_CSS_UNIT_VALUE_HPP
|
||||
|
||||
|
@ -36,7 +35,7 @@ struct css_unit_value : x3::symbols<double>
|
|||
constexpr static double DPI = 96;
|
||||
css_unit_value()
|
||||
{
|
||||
add
|
||||
add //
|
||||
("px", 1.0) // pixels
|
||||
("pt", DPI / 72.0) // points
|
||||
("pc", DPI / 6.0) // picas
|
||||
|
@ -53,14 +52,14 @@ struct css_absolute_size : x3::symbols<double>
|
|||
constexpr static double EM = 10.0; // 1em == 10px
|
||||
css_absolute_size()
|
||||
{
|
||||
add
|
||||
("xx-small", 0.6 * EM)
|
||||
("x-small", 0.75 * EM)
|
||||
("small", 0.88 * EM)
|
||||
("medium", 1.0 * EM)
|
||||
("large", 1.2 * EM)
|
||||
("x-large", 1.5 * EM)
|
||||
("xx-large", 2.0 * EM)
|
||||
add //
|
||||
("xx-small", 0.6 * EM) //
|
||||
("x-small", 0.75 * EM) //
|
||||
("small", 0.88 * EM) //
|
||||
("medium", 1.0 * EM) //
|
||||
("large", 1.2 * EM) //
|
||||
("x-large", 1.5 * EM) //
|
||||
("xx-large", 2.0 * EM) //
|
||||
;
|
||||
}
|
||||
};
|
||||
|
@ -69,13 +68,12 @@ struct css_relative_size : x3::symbols<double>
|
|||
{
|
||||
css_relative_size()
|
||||
{
|
||||
add
|
||||
("larger", 1.2)
|
||||
("smaller", 0.8)
|
||||
;
|
||||
add //
|
||||
("larger", 1.2) //
|
||||
("smaller", 0.8);
|
||||
}
|
||||
};
|
||||
|
||||
} //mapnik
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_CSS_GRAMMAR_X3_DEF_HPP
|
||||
|
|
|
@ -36,8 +36,7 @@ struct csv_white_space_skipper : x3::parser<csv_white_space_skipper>
|
|||
static bool const has_attribute = false;
|
||||
|
||||
template<typename Iterator, typename Context, typename Attribute>
|
||||
bool parse(Iterator& first, Iterator const& last,
|
||||
Context const& context, x3::unused_type, Attribute& ) const
|
||||
bool parse(Iterator& first, Iterator const& last, Context const& context, x3::unused_type, Attribute&) const
|
||||
{
|
||||
x3::skip_over(first, last, context);
|
||||
if (first != last && *first == ' ')
|
||||
|
@ -64,6 +63,7 @@ csv_line_grammar_type const line = "csv-line";
|
|||
|
||||
BOOST_SPIRIT_DECLARE(csv_line_grammar_type);
|
||||
|
||||
}}
|
||||
} // namespace grammar
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_CSV_GRAMMAR_X3_HPP
|
||||
|
|
|
@ -29,30 +29,30 @@ MAPNIK_DISABLE_WARNING_PUSH
|
|||
#include <mapnik/csv/csv_grammar_x3.hpp>
|
||||
MAPNIK_DISABLE_WARNING_POP
|
||||
|
||||
|
||||
namespace mapnik { namespace grammar {
|
||||
namespace mapnik {
|
||||
namespace grammar {
|
||||
|
||||
namespace x3 = boost::spirit::x3;
|
||||
namespace standard = boost::spirit::x3::standard;
|
||||
|
||||
using x3::lit;
|
||||
using x3::lexeme;
|
||||
using standard::char_;
|
||||
using x3::lexeme;
|
||||
using x3::lit;
|
||||
|
||||
struct unesc_char_ : x3::symbols<char>
|
||||
{
|
||||
unesc_char_()
|
||||
{
|
||||
add("\\a", '\a')
|
||||
("\\b", '\b')
|
||||
("\\f", '\f')
|
||||
("\\n", '\n')
|
||||
("\\r", '\r')
|
||||
("\\t", '\t')
|
||||
("\\v", '\v')
|
||||
("\\\\",'\\')
|
||||
("\\\'", '\'')
|
||||
("\\\"", '\"')
|
||||
add("\\a", '\a') //
|
||||
("\\b", '\b') //
|
||||
("\\f", '\f') //
|
||||
("\\n", '\n') //
|
||||
("\\r", '\r') //
|
||||
("\\t", '\t') //
|
||||
("\\v", '\v') //
|
||||
("\\\\", '\\') //
|
||||
("\\\'", '\'') //
|
||||
("\\\"", '\"') //
|
||||
("\"\"", '\"') // double quote
|
||||
;
|
||||
}
|
||||
|
@ -66,8 +66,7 @@ struct literal : x3::parser<literal<T>>
|
|||
static bool const has_attribute = false;
|
||||
|
||||
template<typename Iterator, typename Context, typename Attribute>
|
||||
bool parse(Iterator& first, Iterator const& last,
|
||||
Context const& context, x3::unused_type, Attribute& ) const
|
||||
bool parse(Iterator& first, Iterator const& last, Context const& context, x3::unused_type, Attribute&) const
|
||||
{
|
||||
x3::skip_over(first, last, context);
|
||||
if (first != last && *first == x3::get<context_tag>(context))
|
||||
|
@ -87,27 +86,18 @@ x3::rule<class csv_column, csv_value> const column("csv-column");
|
|||
x3::rule<class csv_text, csv_value> const text("csv-text");
|
||||
x3::rule<class csc_quoted_text, csv_value> const quoted_text("csv-quoted-text");
|
||||
|
||||
auto const line_def = -lit('\r') > -lit('\n') > lexeme[column] % separator
|
||||
;
|
||||
auto const line_def = -lit('\r') > -lit('\n') > lexeme[column] % separator;
|
||||
|
||||
auto const column_def = quoted_text | *(char_ - separator)
|
||||
;
|
||||
auto const column_def = quoted_text | *(char_ - separator);
|
||||
|
||||
auto const quoted_text_def = quote > text > quote // support unmatched quotes or not (??)
|
||||
;
|
||||
|
||||
auto const text_def = *(unesc_char | (char_ - quote))
|
||||
;
|
||||
auto const text_def = *(unesc_char | (char_ - quote));
|
||||
|
||||
BOOST_SPIRIT_DEFINE (
|
||||
line,
|
||||
column,
|
||||
quoted_text,
|
||||
text
|
||||
);
|
||||
BOOST_SPIRIT_DEFINE(line, column, quoted_text, text);
|
||||
|
||||
} // grammar
|
||||
} // namespace grammar
|
||||
} // namespace mapnik
|
||||
|
||||
|
||||
#endif // MAPNIK_CSV_GRAMMAR_X3_DEF_HPP
|
||||
|
|
|
@ -32,6 +32,6 @@ using csv_value = std::string;
|
|||
using csv_line = std::vector<csv_value>;
|
||||
using csv_data = std::vector<csv_line>;
|
||||
|
||||
}
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_CSV_TYPES_HPP
|
||||
|
|
|
@ -1,43 +0,0 @@
|
|||
/*****************************************************************************
|
||||
*
|
||||
* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2021 Artem Pavlenko
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef MAPNIK_CXX11_SUPPORT_HPP
|
||||
#define MAPNIK_CXX11_SUPPORT_HPP
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
namespace mapnik {
|
||||
namespace detail {
|
||||
|
||||
template <bool B, typename T, typename F>
|
||||
using conditional_t = typename std::conditional<B, T, F>::type;
|
||||
|
||||
template <typename T>
|
||||
using decay_t = typename std::decay<T>::type;
|
||||
|
||||
template <bool B, typename T = void>
|
||||
using enable_if_t = typename std::enable_if<B, T>::type;
|
||||
|
||||
} // namespace detail
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_CXX11_SUPPORT_HPP
|
|
@ -50,10 +50,8 @@ public:
|
|||
|
||||
~datasource_exception() {}
|
||||
|
||||
virtual const char* what() const noexcept
|
||||
{
|
||||
return message_.c_str();
|
||||
}
|
||||
virtual const char* what() const noexcept { return message_.c_str(); }
|
||||
|
||||
private:
|
||||
std::string message_;
|
||||
};
|
||||
|
@ -61,13 +59,11 @@ private:
|
|||
class MAPNIK_DECL datasource : private util::noncopyable
|
||||
{
|
||||
public:
|
||||
enum datasource_t : std::uint8_t {
|
||||
Vector,
|
||||
Raster
|
||||
};
|
||||
enum datasource_t : std::uint8_t { Vector, Raster };
|
||||
|
||||
datasource(parameters const& _params)
|
||||
: params_(_params) {}
|
||||
: params_(_params)
|
||||
{}
|
||||
|
||||
/*!
|
||||
* @brief Get the configuration parameters of the data source.
|
||||
|
@ -76,25 +72,13 @@ public:
|
|||
*
|
||||
* @return The configuration parameters of the data source.
|
||||
*/
|
||||
parameters const& params() const
|
||||
{
|
||||
return params_;
|
||||
}
|
||||
parameters const& params() const { return params_; }
|
||||
|
||||
parameters & params()
|
||||
{
|
||||
return params_;
|
||||
}
|
||||
parameters& params() { return params_; }
|
||||
|
||||
bool operator==(datasource const& rhs) const
|
||||
{
|
||||
return params_ == rhs.params();
|
||||
}
|
||||
bool operator==(datasource const& rhs) const { return params_ == rhs.params(); }
|
||||
|
||||
bool operator!=(datasource const& rhs) const
|
||||
{
|
||||
return !(*this == rhs);
|
||||
}
|
||||
bool operator!=(datasource const& rhs) const { return !(*this == rhs); }
|
||||
|
||||
/*!
|
||||
* @brief Get the type of the datasource
|
||||
|
@ -113,6 +97,7 @@ public:
|
|||
virtual box2d<double> envelope() const = 0;
|
||||
virtual layer_descriptor get_descriptor() const = 0;
|
||||
virtual ~datasource() {}
|
||||
|
||||
protected:
|
||||
parameters params_;
|
||||
};
|
||||
|
@ -124,32 +109,10 @@ using destroy_ds = void (*) (datasource *);
|
|||
class datasource_deleter
|
||||
{
|
||||
public:
|
||||
void operator() (datasource* ds)
|
||||
{
|
||||
delete ds;
|
||||
}
|
||||
void operator()(datasource* ds) { delete ds; }
|
||||
};
|
||||
|
||||
using datasource_ptr = std::shared_ptr<datasource>;
|
||||
|
||||
#ifdef MAPNIK_STATIC_PLUGINS
|
||||
#define DATASOURCE_PLUGIN(classname)
|
||||
#else
|
||||
#define DATASOURCE_PLUGIN(classname) \
|
||||
extern "C" MAPNIK_DECL const char * datasource_name() \
|
||||
{ \
|
||||
return classname::name(); \
|
||||
} \
|
||||
extern "C" MAPNIK_DECL datasource* create(parameters const& params) \
|
||||
{ \
|
||||
return new classname(params); \
|
||||
} \
|
||||
extern "C" MAPNIK_DECL void destroy(datasource *ds) \
|
||||
{ \
|
||||
delete ds; \
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_DATASOURCE_HPP
|
||||
|
|
|
@ -41,17 +41,18 @@ class datasource;
|
|||
class parameters;
|
||||
class PluginInfo;
|
||||
|
||||
class MAPNIK_DECL datasource_cache
|
||||
: public singleton<datasource_cache, CreateStatic>,
|
||||
class MAPNIK_DECL datasource_cache : public singleton<datasource_cache, CreateStatic>,
|
||||
private util::noncopyable
|
||||
{
|
||||
friend class CreateStatic<datasource_cache>;
|
||||
|
||||
public:
|
||||
std::vector<std::string> plugin_names();
|
||||
std::string plugin_directories();
|
||||
bool register_datasources(std::string const& path, bool recurse = false);
|
||||
bool register_datasource(std::string const& path);
|
||||
std::shared_ptr<datasource> create(parameters const& params);
|
||||
|
||||
private:
|
||||
datasource_cache();
|
||||
~datasource_cache();
|
||||
|
@ -66,6 +67,6 @@ private:
|
|||
|
||||
extern template class MAPNIK_DECL singleton<datasource_cache, CreateStatic>;
|
||||
|
||||
}
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_DATASOURCE_CACHE_HPP
|
||||
|
|
|
@ -27,15 +27,8 @@
|
|||
|
||||
namespace mapnik {
|
||||
|
||||
enum datasource_geometry_t : std::uint8_t {
|
||||
Unknown = 0,
|
||||
Point = 1,
|
||||
LineString = 2,
|
||||
Polygon = 3,
|
||||
Collection = 4
|
||||
};
|
||||
enum datasource_geometry_t : std::uint8_t { Unknown = 0, Point = 1, LineString = 2, Polygon = 3, Collection = 4 };
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif // MAPNIK_DATASOURCE_GEOMETRY_TYPE_HPP
|
||||
|
|
|
@ -42,35 +42,21 @@
|
|||
|
||||
namespace mapnik {
|
||||
|
||||
|
||||
// Global logger class that holds the configuration of severity, format
|
||||
// and file/console redirection.
|
||||
|
||||
class MAPNIK_DECL logger :
|
||||
public singleton<logger,CreateStatic>,
|
||||
class MAPNIK_DECL logger : public singleton<logger, CreateStatic>,
|
||||
private util::noncopyable
|
||||
{
|
||||
public:
|
||||
enum severity_type
|
||||
{
|
||||
debug = 0,
|
||||
warn = 1,
|
||||
error = 2,
|
||||
none = 3
|
||||
};
|
||||
enum severity_type { debug = 0, warn = 1, error = 2, none = 3 };
|
||||
|
||||
using severity_map = std::unordered_map<std::string, severity_type>;
|
||||
|
||||
// global security level
|
||||
static severity_type get_severity()
|
||||
{
|
||||
return severity_level_;
|
||||
}
|
||||
static severity_type get_severity() { return severity_level_; }
|
||||
|
||||
static void set_severity(severity_type severity_level)
|
||||
{
|
||||
severity_level_ = severity_level;
|
||||
}
|
||||
static void set_severity(severity_type severity_level) { severity_level_ = severity_level; }
|
||||
|
||||
// per object security levels
|
||||
static severity_type get_object_severity(std::string const& object_name)
|
||||
|
@ -89,8 +75,7 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
static void set_object_severity(std::string const& object_name,
|
||||
severity_type const& security_level)
|
||||
static void set_object_severity(std::string const& object_name, severity_type const& security_level)
|
||||
{
|
||||
if (!object_name.empty())
|
||||
{
|
||||
|
@ -111,10 +96,7 @@ public:
|
|||
}
|
||||
|
||||
// format
|
||||
static std::string const& get_format()
|
||||
{
|
||||
return format_;
|
||||
}
|
||||
static std::string const& get_format() { return format_; }
|
||||
|
||||
static void set_format(std::string const& format)
|
||||
{
|
||||
|
@ -151,7 +133,6 @@ private:
|
|||
#endif
|
||||
};
|
||||
|
||||
|
||||
namespace detail {
|
||||
|
||||
// Default sink, it regulates access to clog
|
||||
|
@ -198,9 +179,7 @@ public:
|
|||
}
|
||||
}
|
||||
#else
|
||||
base_log(const char* /*object_name*/)
|
||||
{
|
||||
}
|
||||
base_log(const char* /*object_name*/) {}
|
||||
#endif
|
||||
|
||||
~base_log()
|
||||
|
@ -217,32 +196,25 @@ public:
|
|||
#ifdef MAPNIK_LOG
|
||||
base_log& operator<<(T const& x)
|
||||
{
|
||||
|
||||
streambuf_ << x;
|
||||
return *this;
|
||||
}
|
||||
#else
|
||||
base_log& operator<<(T const& /*x*/)
|
||||
{
|
||||
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
private:
|
||||
#ifdef MAPNIK_LOG
|
||||
inline bool check_severity()
|
||||
{
|
||||
return Severity >= logger::get_object_severity(object_name_);
|
||||
}
|
||||
inline bool check_severity() { return Severity >= logger::get_object_severity(object_name_); }
|
||||
|
||||
typename output_policy::stream_buffer streambuf_;
|
||||
std::string object_name_;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
|
||||
// Base log class that always log, regardless of MAPNIK_LOG.
|
||||
// This is used for error reporting that should always log something
|
||||
|
||||
|
@ -282,49 +254,56 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
inline bool check_severity()
|
||||
{
|
||||
return Severity >= logger::get_object_severity(object_name_);
|
||||
}
|
||||
inline bool check_severity() { return Severity >= logger::get_object_severity(object_name_); }
|
||||
|
||||
typename output_policy::stream_buffer streambuf_;
|
||||
std::string object_name_;
|
||||
};
|
||||
|
||||
|
||||
using base_log_debug = base_log<clog_sink, logger::debug>;
|
||||
using base_log_warn = base_log<clog_sink, logger::warn>;
|
||||
using base_log_error = base_log_always<clog_sink, logger::error>;
|
||||
|
||||
} // namespace detail
|
||||
|
||||
|
||||
// real interfaces
|
||||
class MAPNIK_DECL warn : public detail::base_log_warn
|
||||
{
|
||||
public:
|
||||
warn() : detail::base_log_warn() {}
|
||||
warn(const char* object_name) : detail::base_log_warn(object_name) {}
|
||||
warn()
|
||||
: detail::base_log_warn()
|
||||
{}
|
||||
warn(const char* object_name)
|
||||
: detail::base_log_warn(object_name)
|
||||
{}
|
||||
};
|
||||
|
||||
class MAPNIK_DECL debug : public detail::base_log_debug
|
||||
{
|
||||
public:
|
||||
debug() : detail::base_log_debug() {}
|
||||
debug(const char* object_name) : detail::base_log_debug(object_name) {}
|
||||
debug()
|
||||
: detail::base_log_debug()
|
||||
{}
|
||||
debug(const char* object_name)
|
||||
: detail::base_log_debug(object_name)
|
||||
{}
|
||||
};
|
||||
|
||||
class MAPNIK_DECL error : public detail::base_log_error
|
||||
{
|
||||
public:
|
||||
error() : detail::base_log_error() {}
|
||||
error(const char* object_name) : detail::base_log_error(object_name) {}
|
||||
error()
|
||||
: detail::base_log_error()
|
||||
{}
|
||||
error(const char* object_name)
|
||||
: detail::base_log_error(object_name)
|
||||
{}
|
||||
};
|
||||
|
||||
// logging helpers
|
||||
#define MAPNIK_LOG_DEBUG(s) mapnik::debug(#s)
|
||||
#define MAPNIK_LOG_WARN(s) mapnik::warn(#s)
|
||||
#define MAPNIK_LOG_ERROR(s) mapnik::error(#s)
|
||||
}
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_DEBUG_HPP
|
||||
|
|
|
@ -39,25 +39,21 @@ namespace mapnik {
|
|||
class illegal_enum_value : public std::exception
|
||||
{
|
||||
public:
|
||||
illegal_enum_value():
|
||||
what_() {}
|
||||
illegal_enum_value()
|
||||
: what_()
|
||||
{}
|
||||
|
||||
illegal_enum_value( std::string const& _what ) :
|
||||
what_( _what )
|
||||
{
|
||||
}
|
||||
illegal_enum_value(std::string const& _what)
|
||||
: what_(_what)
|
||||
{}
|
||||
virtual ~illegal_enum_value() {}
|
||||
|
||||
virtual const char * what() const noexcept
|
||||
{
|
||||
return what_.c_str();
|
||||
}
|
||||
virtual const char* what() const noexcept { return what_.c_str(); }
|
||||
|
||||
protected:
|
||||
std::string what_;
|
||||
};
|
||||
|
||||
|
||||
/** Slim wrapper for enumerations. It creates a new type from a native enum and
|
||||
* a char pointer array. It almost exactly behaves like a native enumeration
|
||||
* type. It supports string conversion through stream operators. This is useful
|
||||
|
@ -138,41 +134,33 @@ protected:
|
|||
*/
|
||||
|
||||
template<typename ENUM, int THE_MAX>
|
||||
class MAPNIK_DECL enumeration {
|
||||
class MAPNIK_DECL enumeration
|
||||
{
|
||||
public:
|
||||
using native_type = ENUM;
|
||||
|
||||
enumeration()
|
||||
: value_() {}
|
||||
: value_()
|
||||
{}
|
||||
|
||||
enumeration(ENUM v)
|
||||
: value_(v) {}
|
||||
: value_(v)
|
||||
{}
|
||||
|
||||
enumeration(enumeration const& other)
|
||||
: value_(other.value_) {}
|
||||
: value_(other.value_)
|
||||
{}
|
||||
|
||||
/** Assignment operator for native enum values. */
|
||||
void operator=(ENUM v)
|
||||
{
|
||||
value_ = v;
|
||||
}
|
||||
void operator=(ENUM v) { value_ = v; }
|
||||
|
||||
/** Assignment operator. */
|
||||
void operator=(enumeration const& other)
|
||||
{
|
||||
value_ = other.value_;
|
||||
}
|
||||
void operator=(enumeration const& other) { value_ = other.value_; }
|
||||
|
||||
/** Conversion operator for native enum values. */
|
||||
operator ENUM() const
|
||||
{
|
||||
return value_;
|
||||
}
|
||||
operator ENUM() const { return value_; }
|
||||
|
||||
enum Max
|
||||
{
|
||||
MAX = THE_MAX
|
||||
};
|
||||
enum Max { MAX = THE_MAX };
|
||||
|
||||
/** Converts @p str to an enum.
|
||||
* @throw illegal_enum_value @p str is not a legal identifier.
|
||||
|
@ -190,7 +178,6 @@ public:
|
|||
}
|
||||
for (unsigned i = 0; i < THE_MAX; ++i)
|
||||
{
|
||||
|
||||
MAPNIK_DISABLE_WARNING_PUSH
|
||||
MAPNIK_DISABLE_WARNING_UNKNOWN_PRAGMAS
|
||||
MAPNIK_DISABLE_WARNING_PRAGMAS
|
||||
|
@ -201,7 +188,10 @@ MAPNIK_DISABLE_WARNING_POP
|
|||
value_ = static_cast<ENUM>(i);
|
||||
if (deprecated)
|
||||
{
|
||||
MAPNIK_LOG_ERROR(enumerations) << "enumeration value (" << str << ") using \"_\" is deprecated and will be removed in Mapnik 4.x, use '" << str_copy << "' instead";
|
||||
MAPNIK_LOG_ERROR(enumerations)
|
||||
<< "enumeration value (" << str
|
||||
<< ") using \"_\" is deprecated and will be removed in Mapnik 4.x, use '" << str_copy
|
||||
<< "' instead";
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -210,8 +200,7 @@ MAPNIK_DISABLE_WARNING_PUSH
|
|||
MAPNIK_DISABLE_WARNING_UNKNOWN_PRAGMAS
|
||||
MAPNIK_DISABLE_WARNING_PRAGMAS
|
||||
MAPNIK_DISABLE_LONG_LONG
|
||||
throw illegal_enum_value(std::string("Illegal enumeration value '") +
|
||||
str + "' for enum " + our_name_);
|
||||
throw illegal_enum_value(std::string("Illegal enumeration value '") + str + "' for enum " + our_name_);
|
||||
MAPNIK_DISABLE_WARNING_POP
|
||||
}
|
||||
|
||||
|
@ -227,10 +216,7 @@ MAPNIK_DISABLE_WARNING_POP
|
|||
}
|
||||
|
||||
/** Static helper function to iterate over valid identifiers. */
|
||||
static const char * get_string(unsigned i)
|
||||
{
|
||||
return our_strings_[i];
|
||||
}
|
||||
static const char* get_string(unsigned i) { return our_strings_[i]; }
|
||||
|
||||
/** Performs some simple checks and quits the application if
|
||||
* any error is detected. Tries to print helpful error messages.
|
||||
|
@ -241,16 +227,14 @@ MAPNIK_DISABLE_WARNING_POP
|
|||
{
|
||||
if (our_strings_[i] == 0)
|
||||
{
|
||||
std::cerr << "### FATAL: Not enough strings for enum "
|
||||
<< our_name_ << " defined in file '" << filename
|
||||
std::cerr << "### FATAL: Not enough strings for enum " << our_name_ << " defined in file '" << filename
|
||||
<< "' at line " << line_no;
|
||||
}
|
||||
}
|
||||
if (std::string("") != our_strings_[THE_MAX])
|
||||
{
|
||||
std::cerr << "### FATAL: The string array for enum " << our_name_
|
||||
<< " defined in file '" << filename << "' at line " << line_no
|
||||
<< " has too many items or is not terminated with an "
|
||||
std::cerr << "### FATAL: The string array for enum " << our_name_ << " defined in file '" << filename
|
||||
<< "' at line " << line_no << " has too many items or is not terminated with an "
|
||||
<< "empty string";
|
||||
}
|
||||
return true;
|
||||
|
@ -267,13 +251,12 @@ private:
|
|||
* @relates mapnik::enumeration
|
||||
*/
|
||||
template<class ENUM, int THE_MAX>
|
||||
std::ostream &
|
||||
operator<<(std::ostream & os, const mapnik::enumeration<ENUM, THE_MAX> & e)
|
||||
std::ostream& operator<<(std::ostream& os, const mapnik::enumeration<ENUM, THE_MAX>& e)
|
||||
{
|
||||
return os << e.as_string();
|
||||
}
|
||||
|
||||
} // end of namespace
|
||||
} // namespace mapnik
|
||||
|
||||
/** Helper macro.
|
||||
* @relates mapnik::enumeration
|
||||
|
@ -285,9 +268,12 @@ operator<<(std::ostream & os, const mapnik::enumeration<ENUM, THE_MAX> & e)
|
|||
#else
|
||||
#define DEFINE_ENUM(name, e) \
|
||||
using name = enumeration<e, e##_MAX>; \
|
||||
template <> MAPNIK_DECL const char ** name ::our_strings_; \
|
||||
template <> MAPNIK_DECL std::string name ::our_name_; \
|
||||
template <> MAPNIK_DECL bool name ::our_verified_flag_;
|
||||
template<> \
|
||||
MAPNIK_DECL const char** name ::our_strings_; \
|
||||
template<> \
|
||||
MAPNIK_DECL std::string name ::our_name_; \
|
||||
template<> \
|
||||
MAPNIK_DECL bool name ::our_verified_flag_;
|
||||
#endif
|
||||
|
||||
/** Helper macro. Runs the verify_mapnik_enum() method during static initialization.
|
||||
|
@ -295,8 +281,11 @@ operator<<(std::ostream & os, const mapnik::enumeration<ENUM, THE_MAX> & e)
|
|||
*/
|
||||
|
||||
#define IMPLEMENT_ENUM(name, strings) \
|
||||
template <> MAPNIK_DECL const char ** name ::our_strings_ = strings; \
|
||||
template <> MAPNIK_DECL std::string name ::our_name_ = #name; \
|
||||
template <> MAPNIK_DECL bool name ::our_verified_flag_( name ::verify_mapnik_enum(__FILE__, __LINE__));
|
||||
template<> \
|
||||
MAPNIK_DECL const char** name ::our_strings_ = strings; \
|
||||
template<> \
|
||||
MAPNIK_DECL std::string name ::our_name_ = #name; \
|
||||
template<> \
|
||||
MAPNIK_DECL bool name ::our_verified_flag_(name ::verify_mapnik_enum(__FILE__, __LINE__));
|
||||
|
||||
#endif // MAPNIK_ENUMERATION_HPP
|
||||
|
|
|
@ -44,7 +44,8 @@ struct evaluate_expression
|
|||
using value_type = T;
|
||||
|
||||
explicit evaluate_expression(Attributes const& attrs)
|
||||
: attrs_(attrs) {}
|
||||
: attrs_(attrs)
|
||||
{}
|
||||
|
||||
value_type operator()(attribute const&) const
|
||||
{
|
||||
|
@ -68,22 +69,19 @@ struct evaluate_expression
|
|||
|
||||
value_type operator()(binary_node<tags::logical_and> const& x) const
|
||||
{
|
||||
return (util::apply_visitor(*this, x.left).to_bool())
|
||||
&& (util::apply_visitor(*this, x.right).to_bool());
|
||||
return (util::apply_visitor(*this, x.left).to_bool()) && (util::apply_visitor(*this, x.right).to_bool());
|
||||
}
|
||||
|
||||
value_type operator()(binary_node<tags::logical_or> const& x) const
|
||||
{
|
||||
return (util::apply_visitor(*this,x.left).to_bool())
|
||||
|| (util::apply_visitor(*this,x.right).to_bool());
|
||||
return (util::apply_visitor(*this, x.left).to_bool()) || (util::apply_visitor(*this, x.right).to_bool());
|
||||
}
|
||||
|
||||
template<typename Tag>
|
||||
value_type operator()(binary_node<Tag> const& x) const
|
||||
{
|
||||
typename make_op<Tag>::type operation;
|
||||
return operation(util::apply_visitor(*this, x.left),
|
||||
util::apply_visitor(*this, x.right));
|
||||
return operation(util::apply_visitor(*this, x.left), util::apply_visitor(*this, x.right));
|
||||
}
|
||||
|
||||
template<typename Tag>
|
||||
|
@ -156,22 +154,19 @@ struct evaluate_expression<T, boost::none_t>
|
|||
|
||||
value_type operator()(binary_node<tags::logical_and> const& x) const
|
||||
{
|
||||
return (util::apply_visitor(*this, x.left).to_bool())
|
||||
&& (util::apply_visitor(*this, x.right).to_bool());
|
||||
return (util::apply_visitor(*this, x.left).to_bool()) && (util::apply_visitor(*this, x.right).to_bool());
|
||||
}
|
||||
|
||||
value_type operator()(binary_node<tags::logical_or> const& x) const
|
||||
{
|
||||
return (util::apply_visitor(*this,x.left).to_bool())
|
||||
|| (util::apply_visitor(*this,x.right).to_bool());
|
||||
return (util::apply_visitor(*this, x.left).to_bool()) || (util::apply_visitor(*this, x.right).to_bool());
|
||||
}
|
||||
|
||||
template<typename Tag>
|
||||
value_type operator()(binary_node<Tag> const& x) const
|
||||
{
|
||||
typename make_op<Tag>::type operation;
|
||||
return operation(util::apply_visitor(*this, x.left),
|
||||
util::apply_visitor(*this, x.right));
|
||||
return operation(util::apply_visitor(*this, x.left), util::apply_visitor(*this, x.right));
|
||||
}
|
||||
|
||||
template<typename Tag>
|
||||
|
@ -221,33 +216,39 @@ struct evaluate_expression<T, boost::none_t>
|
|||
struct assign_value
|
||||
{
|
||||
template<typename Attributes>
|
||||
static void apply(symbolizer_base::value_type & val, expression_ptr const& expr, Attributes const& attrs, property_types target )
|
||||
static void apply(symbolizer_base::value_type& val,
|
||||
expression_ptr const& expr,
|
||||
Attributes const& attrs,
|
||||
property_types target)
|
||||
{
|
||||
|
||||
switch (target)
|
||||
{
|
||||
case property_types::target_color:
|
||||
{
|
||||
case property_types::target_color: {
|
||||
// evaluate expression as a string then parse as css color
|
||||
std::string str = util::apply_visitor(mapnik::evaluate_expression<mapnik::value,
|
||||
Attributes>(attrs),*expr).to_string();
|
||||
try { val = parse_color(str); }
|
||||
catch (...) { val = color(0,0,0);}
|
||||
std::string str =
|
||||
util::apply_visitor(mapnik::evaluate_expression<mapnik::value, Attributes>(attrs), *expr).to_string();
|
||||
try
|
||||
{
|
||||
val = parse_color(str);
|
||||
} catch (...)
|
||||
{
|
||||
val = color(0, 0, 0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case property_types::target_double:
|
||||
{
|
||||
val = util::apply_visitor(mapnik::evaluate_expression<mapnik::value, Attributes>(attrs),*expr).to_double();
|
||||
case property_types::target_double: {
|
||||
val =
|
||||
util::apply_visitor(mapnik::evaluate_expression<mapnik::value, Attributes>(attrs), *expr).to_double();
|
||||
break;
|
||||
}
|
||||
case property_types::target_integer:
|
||||
{
|
||||
val = util::apply_visitor(mapnik::evaluate_expression<mapnik::value, Attributes>(attrs),*expr).to_int();
|
||||
case property_types::target_integer: {
|
||||
val =
|
||||
util::apply_visitor(mapnik::evaluate_expression<mapnik::value, Attributes>(attrs), *expr).to_int();
|
||||
break;
|
||||
}
|
||||
case property_types::target_bool:
|
||||
{
|
||||
val = util::apply_visitor(mapnik::evaluate_expression<mapnik::value, Attributes>(attrs),*expr).to_bool();
|
||||
case property_types::target_bool: {
|
||||
val =
|
||||
util::apply_visitor(mapnik::evaluate_expression<mapnik::value, Attributes>(attrs), *expr).to_bool();
|
||||
break;
|
||||
}
|
||||
default: // no-op
|
||||
|
@ -256,16 +257,16 @@ struct assign_value
|
|||
}
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace
|
||||
|
||||
template<typename T>
|
||||
std::tuple<T, bool> pre_evaluate_expression(expression_ptr const& expr)
|
||||
{
|
||||
try
|
||||
{
|
||||
return std::make_tuple(util::apply_visitor(mapnik::evaluate_expression<T, boost::none_t>(boost::none),*expr), true);
|
||||
}
|
||||
catch (...)
|
||||
return std::make_tuple(util::apply_visitor(mapnik::evaluate_expression<T, boost::none_t>(boost::none), *expr),
|
||||
true);
|
||||
} catch (...)
|
||||
{
|
||||
return std::make_tuple(T(), false);
|
||||
}
|
||||
|
@ -277,8 +278,9 @@ struct evaluate_global_attributes : util::noncopyable
|
|||
struct evaluator
|
||||
{
|
||||
evaluator(symbolizer_base::cont_type::value_type& prop, Attributes const& attrs)
|
||||
: prop_(prop),
|
||||
attrs_(attrs) {}
|
||||
: prop_(prop)
|
||||
, attrs_(attrs)
|
||||
{}
|
||||
|
||||
void operator()(expression_ptr const& expr) const
|
||||
{
|
||||
|
@ -299,7 +301,8 @@ struct evaluate_global_attributes : util::noncopyable
|
|||
struct extract_symbolizer
|
||||
{
|
||||
extract_symbolizer(Attributes const& attrs)
|
||||
: attrs_(attrs) {}
|
||||
: attrs_(attrs)
|
||||
{}
|
||||
|
||||
template<typename Symbolizer>
|
||||
void operator()(Symbolizer& sym) const
|
||||
|
@ -328,6 +331,6 @@ struct evaluate_global_attributes : util::noncopyable
|
|||
}
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_EVALUATE_GLOBAL_ATTRIBUTES_HPP
|
||||
|
|
|
@ -34,14 +34,13 @@
|
|||
#include <string>
|
||||
#include <set>
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
namespace mapnik {
|
||||
|
||||
// fwd declare to reduce compile time
|
||||
using expression_ptr = std::shared_ptr<expr_node>;
|
||||
using expression_set = std::set<expression_ptr>;
|
||||
|
||||
MAPNIK_DECL expression_ptr parse_expression(std::string const& wkt);
|
||||
}
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_EXPRESSION_HPP
|
||||
|
|
|
@ -31,8 +31,7 @@
|
|||
#include <mapnik/util/variant.hpp>
|
||||
#include <mapnik/feature.hpp>
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
namespace mapnik {
|
||||
|
||||
template<typename T0, typename T1, typename T2>
|
||||
struct evaluate
|
||||
|
@ -42,38 +41,21 @@ struct evaluate
|
|||
using variable_type = T2;
|
||||
using result_type = T1; // we need this because automatic result_type deduction fails
|
||||
explicit evaluate(feature_type const& f, variable_type const& v)
|
||||
: feature_(f),
|
||||
vars_(v) {}
|
||||
: feature_(f)
|
||||
, vars_(v)
|
||||
{}
|
||||
|
||||
value_type operator() (value_integer val) const
|
||||
{
|
||||
return val;
|
||||
}
|
||||
value_type operator()(value_integer val) const { return val; }
|
||||
|
||||
value_type operator() (value_double val) const
|
||||
{
|
||||
return val;
|
||||
}
|
||||
value_type operator()(value_double val) const { return val; }
|
||||
|
||||
value_type operator() (value_bool val) const
|
||||
{
|
||||
return val;
|
||||
}
|
||||
value_type operator()(value_bool val) const { return val; }
|
||||
|
||||
value_type operator() (value_null val) const
|
||||
{
|
||||
return val;
|
||||
}
|
||||
value_type operator()(value_null val) const { return val; }
|
||||
|
||||
value_type operator() (value_unicode_string const& str) const
|
||||
{
|
||||
return str;
|
||||
}
|
||||
value_type operator()(value_unicode_string const& str) const { return str; }
|
||||
|
||||
value_type operator() (attribute const& attr) const
|
||||
{
|
||||
return attr.value<value_type,feature_type>(feature_);
|
||||
}
|
||||
value_type operator()(attribute const& attr) const { return attr.value<value_type, feature_type>(feature_); }
|
||||
|
||||
value_type operator()(global_attribute const& attr) const
|
||||
{
|
||||
|
@ -92,22 +74,19 @@ struct evaluate
|
|||
|
||||
value_type operator()(binary_node<tags::logical_and> const& x) const
|
||||
{
|
||||
return (util::apply_visitor(*this, x.left).to_bool())
|
||||
&& (util::apply_visitor(*this, x.right).to_bool());
|
||||
return (util::apply_visitor(*this, x.left).to_bool()) && (util::apply_visitor(*this, x.right).to_bool());
|
||||
}
|
||||
|
||||
value_type operator()(binary_node<tags::logical_or> const& x) const
|
||||
{
|
||||
return (util::apply_visitor(*this, x.left).to_bool())
|
||||
|| (util::apply_visitor(*this, x.right).to_bool());
|
||||
return (util::apply_visitor(*this, x.left).to_bool()) || (util::apply_visitor(*this, x.right).to_bool());
|
||||
}
|
||||
|
||||
template<typename Tag>
|
||||
value_type operator()(binary_node<Tag> const& x) const
|
||||
{
|
||||
typename make_op<Tag>::type operation;
|
||||
return operation(util::apply_visitor(*this, x.left),
|
||||
util::apply_visitor(*this, x.right));
|
||||
return operation(util::apply_visitor(*this, x.left), util::apply_visitor(*this, x.right));
|
||||
}
|
||||
|
||||
template<typename Tag>
|
||||
|
@ -151,6 +130,6 @@ struct evaluate
|
|||
variable_type const& vars_;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_EXPRESSION_EVALUATOR_HPP
|
||||
|
|
|
@ -31,7 +31,8 @@ MAPNIK_DISABLE_WARNING_PUSH
|
|||
#include <boost/spirit/home/x3.hpp>
|
||||
MAPNIK_DISABLE_WARNING_POP
|
||||
|
||||
namespace mapnik { namespace grammar {
|
||||
namespace mapnik {
|
||||
namespace grammar {
|
||||
|
||||
#if BOOST_VERSION >= 106700
|
||||
using transcoder_type = mapnik::transcoder;
|
||||
|
@ -39,7 +40,6 @@ using transcoder_type = mapnik::transcoder;
|
|||
using transcoder_type = std::reference_wrapper<mapnik::transcoder const>;
|
||||
#endif
|
||||
|
||||
|
||||
namespace x3 = boost::spirit::x3;
|
||||
struct transcoder_tag;
|
||||
struct expression_class; // top-most ID
|
||||
|
@ -49,6 +49,7 @@ expression_grammar_type const expression("expression");
|
|||
|
||||
BOOST_SPIRIT_DECLARE(expression_grammar_type);
|
||||
|
||||
}}
|
||||
} // namespace grammar
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_EXPRESSIONS_GRAMMAR_X3_HPP
|
||||
|
|
|
@ -26,16 +26,16 @@
|
|||
#include <mapnik/expression_grammar_x3.hpp>
|
||||
#include <string>
|
||||
|
||||
namespace mapnik { namespace grammar {
|
||||
namespace mapnik {
|
||||
namespace grammar {
|
||||
|
||||
namespace x3 = boost::spirit::x3;
|
||||
using iterator_type = std::string::const_iterator;
|
||||
using phrase_context_type = x3::phrase_parse_context<x3::ascii::space_type>::type;
|
||||
// define combined context
|
||||
using context_type = x3::context<transcoder_tag,
|
||||
transcoder_type const,
|
||||
phrase_context_type>;
|
||||
using context_type = x3::context<transcoder_tag, transcoder_type const, phrase_context_type>;
|
||||
|
||||
}}
|
||||
} // namespace grammar
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_EXPRESSIONS_GRAMMAR_X3_CONFIG_HPP
|
||||
|
|
|
@ -24,47 +24,45 @@
|
|||
#define MAPNIK_EXPRESSIONS_GRAMMAR_X3_DEF_HPP
|
||||
|
||||
#include <mapnik/expression_grammar_x3.hpp>
|
||||
#include <mapnik/json/unicode_string_grammar_x3_def.hpp>
|
||||
#include <mapnik/expression_node.hpp>
|
||||
#include <mapnik/function_call.hpp>
|
||||
#include <mapnik/json/unicode_string_grammar_x3_def.hpp>
|
||||
#include <mapnik/unicode.hpp>
|
||||
|
||||
#include <mapnik/warning.hpp>
|
||||
MAPNIK_DISABLE_WARNING_PUSH
|
||||
#include <mapnik/warning_ignore.hpp>
|
||||
#include <boost/spirit/home/x3.hpp>
|
||||
#include <boost/spirit/home/x3/support/ast/variant.hpp>
|
||||
#include <boost/fusion/include/adapt_struct.hpp>
|
||||
#include <boost/fusion/include/std_pair.hpp>
|
||||
#include <boost/spirit/home/x3.hpp>
|
||||
#include <boost/spirit/home/x3/support/ast/variant.hpp>
|
||||
#include <mapnik/warning_ignore.hpp>
|
||||
MAPNIK_DISABLE_WARNING_POP
|
||||
|
||||
BOOST_FUSION_ADAPT_STRUCT(mapnik::unary_function_call,
|
||||
(mapnik::unary_function_impl, fun)
|
||||
(mapnik::unary_function_call::argument_type, arg))
|
||||
(mapnik::unary_function_impl, fun)(mapnik::unary_function_call::argument_type, arg))
|
||||
|
||||
BOOST_FUSION_ADAPT_STRUCT(mapnik::binary_function_call,
|
||||
(mapnik::binary_function_impl, fun)
|
||||
(mapnik::binary_function_call::argument_type, arg1)
|
||||
(mapnik::binary_function_call::argument_type, arg2))
|
||||
(mapnik::binary_function_impl, fun)(mapnik::binary_function_call::argument_type,
|
||||
arg1)(mapnik::binary_function_call::argument_type, arg2))
|
||||
|
||||
|
||||
namespace mapnik { namespace grammar {
|
||||
namespace mapnik {
|
||||
namespace grammar {
|
||||
|
||||
namespace x3 = boost::spirit::x3;
|
||||
namespace ascii = boost::spirit::x3::ascii;
|
||||
using ascii::char_;
|
||||
using ascii::string;
|
||||
using x3::lit;
|
||||
using x3::double_;
|
||||
using x3::int_;
|
||||
using x3::bool_;
|
||||
using x3::_attr;
|
||||
using x3::_val;
|
||||
using x3::no_skip;
|
||||
using x3::lexeme;
|
||||
using x3::no_case;
|
||||
using x3::alpha;
|
||||
using x3::alnum;
|
||||
using x3::alpha;
|
||||
using x3::bool_;
|
||||
using x3::double_;
|
||||
using x3::int_;
|
||||
using x3::lexeme;
|
||||
using x3::lit;
|
||||
using x3::no_case;
|
||||
using x3::no_skip;
|
||||
x3::uint_parser<char, 16, 2, 2> const hex2{};
|
||||
|
||||
namespace {
|
||||
|
@ -77,23 +75,19 @@ namespace mapnik { namespace grammar {
|
|||
return x3::get<transcoder_tag>(ctx);
|
||||
}
|
||||
|
||||
auto append = [](auto const& ctx)
|
||||
{
|
||||
auto append = [](auto const& ctx) {
|
||||
_val(ctx) += _attr(ctx);
|
||||
};
|
||||
|
||||
auto do_assign = [] (auto const& ctx)
|
||||
{
|
||||
auto do_assign = [](auto const& ctx) {
|
||||
_val(ctx) = std::move(_attr(ctx));
|
||||
};
|
||||
|
||||
auto do_negate = [] (auto const& ctx)
|
||||
{
|
||||
auto do_negate = [](auto const& ctx) {
|
||||
_val(ctx) = std::move(unary_node<mapnik::tags::negate>(_attr(ctx)));
|
||||
};
|
||||
|
||||
auto do_attribute = [] (auto const& ctx)
|
||||
{
|
||||
auto do_attribute = [](auto const& ctx) {
|
||||
auto const& attr = _attr(ctx);
|
||||
if (attr == "mapnik::geometry_type")
|
||||
{
|
||||
|
@ -105,102 +99,84 @@ namespace mapnik { namespace grammar {
|
|||
}
|
||||
};
|
||||
|
||||
auto do_global_attribute = [] (auto const& ctx)
|
||||
{
|
||||
auto do_global_attribute = [](auto const& ctx) {
|
||||
_val(ctx) = std::move(global_attribute(_attr(ctx)));
|
||||
};
|
||||
|
||||
auto do_add = [] (auto const& ctx)
|
||||
{
|
||||
auto do_add = [](auto const& ctx) {
|
||||
_val(ctx) = std::move(mapnik::binary_node<mapnik::tags::plus>(std::move(_val(ctx)), std::move(_attr(ctx))));
|
||||
};
|
||||
|
||||
auto do_subt = [] (auto const& ctx)
|
||||
{
|
||||
auto do_subt = [](auto const& ctx) {
|
||||
_val(ctx) = std::move(mapnik::binary_node<mapnik::tags::minus>(std::move(_val(ctx)), std::move(_attr(ctx))));
|
||||
};
|
||||
|
||||
auto do_mult = [] (auto const& ctx)
|
||||
{
|
||||
auto do_mult = [](auto const& ctx) {
|
||||
_val(ctx) = std::move(mapnik::binary_node<mapnik::tags::mult>(std::move(_val(ctx)), std::move(_attr(ctx))));
|
||||
};
|
||||
|
||||
auto do_div = [] (auto const& ctx)
|
||||
{
|
||||
auto do_div = [](auto const& ctx) {
|
||||
_val(ctx) = std::move(mapnik::binary_node<mapnik::tags::div>(std::move(_val(ctx)), std::move(_attr(ctx))));
|
||||
};
|
||||
|
||||
auto do_mod = [] (auto const& ctx)
|
||||
{
|
||||
auto do_mod = [](auto const& ctx) {
|
||||
_val(ctx) = std::move(mapnik::binary_node<mapnik::tags::mod>(std::move(_val(ctx)), std::move(_attr(ctx))));
|
||||
};
|
||||
|
||||
auto do_unicode = [] (auto const& ctx)
|
||||
{
|
||||
auto do_unicode = [](auto const& ctx) {
|
||||
auto const& tr = extract_transcoder(ctx);
|
||||
_val(ctx) = std::move(tr.transcode(_attr(ctx).c_str()));
|
||||
};
|
||||
|
||||
auto do_null = [] (auto const& ctx)
|
||||
{
|
||||
auto do_null = [](auto const& ctx) {
|
||||
_val(ctx) = std::move(mapnik::value_null());
|
||||
};
|
||||
|
||||
auto do_not = [] (auto const& ctx)
|
||||
{
|
||||
auto do_not = [](auto const& ctx) {
|
||||
mapnik::unary_node<mapnik::tags::logical_not> node(_attr(ctx));
|
||||
_val(ctx) = std::move(node);
|
||||
};
|
||||
|
||||
auto do_and = [] (auto const& ctx)
|
||||
{
|
||||
auto do_and = [](auto const& ctx) {
|
||||
_val(ctx) = std::move(mapnik::binary_node<mapnik::tags::logical_and>(std::move(_val(ctx)), std::move(_attr(ctx))));
|
||||
};
|
||||
|
||||
auto do_or = [] (auto const& ctx)
|
||||
{
|
||||
auto do_or = [](auto const& ctx) {
|
||||
_val(ctx) = std::move(mapnik::binary_node<mapnik::tags::logical_or>(std::move(_val(ctx)), std::move(_attr(ctx))));
|
||||
};
|
||||
|
||||
auto do_equal = [] (auto const& ctx)
|
||||
{
|
||||
auto do_equal = [](auto const& ctx) {
|
||||
_val(ctx) = std::move(mapnik::binary_node<mapnik::tags::equal_to>(std::move(_val(ctx)), std::move(_attr(ctx))));
|
||||
};
|
||||
|
||||
auto do_not_equal = [] (auto const& ctx)
|
||||
{
|
||||
auto do_not_equal = [](auto const& ctx) {
|
||||
_val(ctx) = std::move(mapnik::binary_node<mapnik::tags::not_equal_to>(std::move(_val(ctx)), std::move(_attr(ctx))));
|
||||
};
|
||||
|
||||
auto do_less = [] (auto const& ctx)
|
||||
{
|
||||
auto do_less = [](auto const& ctx) {
|
||||
_val(ctx) = std::move(mapnik::binary_node<mapnik::tags::less>(std::move(_val(ctx)), std::move(_attr(ctx))));
|
||||
};
|
||||
|
||||
auto do_less_equal = [] (auto const& ctx)
|
||||
{
|
||||
auto do_less_equal = [](auto const& ctx) {
|
||||
_val(ctx) = std::move(mapnik::binary_node<mapnik::tags::less_equal>(std::move(_val(ctx)), std::move(_attr(ctx))));
|
||||
};
|
||||
|
||||
auto do_greater = [] (auto const& ctx)
|
||||
{
|
||||
auto do_greater = [](auto const& ctx) {
|
||||
_val(ctx) = std::move(mapnik::binary_node<mapnik::tags::greater>(std::move(_val(ctx)), std::move(_attr(ctx))));
|
||||
};
|
||||
|
||||
auto do_greater_equal = [] (auto const& ctx)
|
||||
{
|
||||
_val(ctx) = std::move(mapnik::binary_node<mapnik::tags::greater_equal>(std::move(_val(ctx)), std::move(_attr(ctx))));
|
||||
auto do_greater_equal = [](auto const& ctx) {
|
||||
_val(ctx) =
|
||||
std::move(mapnik::binary_node<mapnik::tags::greater_equal>(std::move(_val(ctx)), std::move(_attr(ctx))));
|
||||
};
|
||||
|
||||
// regex
|
||||
auto do_regex_match = [] (auto const& ctx)
|
||||
{
|
||||
auto do_regex_match = [](auto const& ctx) {
|
||||
auto const& tr = extract_transcoder(ctx);
|
||||
_val(ctx) = std::move(mapnik::regex_match_node(tr, std::move(_val(ctx)), std::move(_attr(ctx))));
|
||||
};
|
||||
|
||||
auto do_regex_replace = [] (auto const& ctx)
|
||||
{
|
||||
auto do_regex_replace = [](auto const& ctx) {
|
||||
auto const& tr = extract_transcoder(ctx);
|
||||
auto const& pair = _attr(ctx);
|
||||
auto const& pattern = std::get<0>(pair);
|
||||
|
@ -217,9 +193,8 @@ namespace mapnik { namespace grammar {
|
|||
{
|
||||
boolean_()
|
||||
{
|
||||
add
|
||||
("true", true)
|
||||
("false", false)
|
||||
add("true", true) //
|
||||
("false", false) //
|
||||
;
|
||||
}
|
||||
} boolean;
|
||||
|
@ -228,10 +203,9 @@ namespace mapnik { namespace grammar {
|
|||
{
|
||||
floating_point_constants()
|
||||
{
|
||||
add
|
||||
("pi", 3.1415926535897932384626433832795)
|
||||
("deg_to_rad",0.017453292519943295769236907684886)
|
||||
("rad_to_deg",57.295779513082320876798154814105)
|
||||
add("pi", 3.1415926535897932384626433832795) //
|
||||
("deg_to_rad", 0.017453292519943295769236907684886) //
|
||||
("rad_to_deg", 57.295779513082320876798154814105) //
|
||||
;
|
||||
}
|
||||
} float_const;
|
||||
|
@ -241,30 +215,27 @@ namespace mapnik { namespace grammar {
|
|||
{
|
||||
unary_function_types_()
|
||||
{
|
||||
add
|
||||
("sin", sin_impl())
|
||||
("cos", cos_impl())
|
||||
("tan", tan_impl())
|
||||
("atan", atan_impl())
|
||||
("exp", exp_impl())
|
||||
("log", log_impl())
|
||||
("abs", abs_impl())
|
||||
("length",length_impl())
|
||||
add("sin", sin_impl()) //
|
||||
("cos", cos_impl()) //
|
||||
("tan", tan_impl()) //
|
||||
("atan", atan_impl()) //
|
||||
("exp", exp_impl()) //
|
||||
("log", log_impl()) //
|
||||
("abs", abs_impl()) //
|
||||
("length", length_impl()) //
|
||||
;
|
||||
}
|
||||
} unary_func_types;
|
||||
|
||||
|
||||
// binary functions
|
||||
|
||||
struct binary_function_types_ : x3::symbols<binary_function_impl>
|
||||
{
|
||||
binary_function_types_()
|
||||
{
|
||||
add
|
||||
("min", binary_function_impl(min_impl))
|
||||
("max", binary_function_impl(max_impl))
|
||||
("pow", binary_function_impl(pow_impl))
|
||||
add("min", binary_function_impl(min_impl)) //
|
||||
("max", binary_function_impl(max_impl)) //
|
||||
("pow", binary_function_impl(pow_impl)) //
|
||||
;
|
||||
}
|
||||
} binary_func_types;
|
||||
|
@ -274,11 +245,10 @@ namespace mapnik { namespace grammar {
|
|||
{
|
||||
geometry_types_()
|
||||
{
|
||||
add
|
||||
("point", 1)
|
||||
("linestring", 2)
|
||||
("polygon",3)
|
||||
("collection",4)
|
||||
add("point", 1) //
|
||||
("linestring", 2) //
|
||||
("polygon", 3) //
|
||||
("collection", 4) //
|
||||
;
|
||||
}
|
||||
} geometry_type;
|
||||
|
@ -287,17 +257,16 @@ namespace mapnik { namespace grammar {
|
|||
{
|
||||
unesc_chars_()
|
||||
{
|
||||
add
|
||||
("\\a", '\a')
|
||||
("\\b", '\b')
|
||||
("\\f", '\f')
|
||||
("\\n", '\n')
|
||||
("\\r", '\r')
|
||||
("\\t", '\t')
|
||||
("\\v", '\v')
|
||||
("\\\\", '\\')
|
||||
("\\\'", '\'')
|
||||
("\\\"", '\"')
|
||||
add("\\a", '\a') //
|
||||
("\\b", '\b') //
|
||||
("\\f", '\f') //
|
||||
("\\n", '\n') //
|
||||
("\\r", '\r') //
|
||||
("\\t", '\t') //
|
||||
("\\v", '\v') //
|
||||
("\\\\", '\\') //
|
||||
("\\\'", '\'') //
|
||||
("\\\"", '\"') //
|
||||
;
|
||||
}
|
||||
} unesc_char;
|
||||
|
@ -309,14 +278,18 @@ namespace mapnik { namespace grammar {
|
|||
x3::rule<class equality_expression, mapnik::expr_node> const equality_expression("equality expression");
|
||||
x3::rule<class relational_expression, mapnik::expr_node> const relational_expression("relational expression");
|
||||
x3::rule<class additive_expression, mapnik::expr_node> const additive_expression("additive expression");
|
||||
x3::rule<class multiplicative_expression, mapnik::expr_node> const multiplicative_expression("multiplicative expression");
|
||||
x3::rule<class unary_func_expression, mapnik::unary_function_call> const unary_func_expression("unary function expression");
|
||||
x3::rule<class binary_func_expression, mapnik::binary_function_call> const binary_func_expression("binary function expression");
|
||||
x3::rule<class multiplicative_expression, mapnik::expr_node> const
|
||||
multiplicative_expression("multiplicative expression");
|
||||
x3::rule<class unary_func_expression, mapnik::unary_function_call> const
|
||||
unary_func_expression("unary function expression");
|
||||
x3::rule<class binary_func_expression, mapnik::binary_function_call> const
|
||||
binary_func_expression("binary function expression");
|
||||
x3::rule<class unary_expression, mapnik::expr_node> const unary_expression("unary expression");
|
||||
x3::rule<class primary_expression, mapnik::expr_node> const primary_expression("primary expression");
|
||||
x3::rule<class regex_match_expression, std::string> const regex_match_expression("regex match expression");
|
||||
x3::rule<class regex_replace_expression, std::pair<std::string,std::string> > const regex_replace_expression("regex replace expression");
|
||||
|
||||
x3::rule<class regex_replace_expression, std::pair<std::string, std::string>> const
|
||||
regex_replace_expression("regex replace expression");
|
||||
// clang-format off
|
||||
// strings
|
||||
auto const single_quoted_string = x3::rule<class single_quoted_string, std::string> {} = lit('\'')
|
||||
>> no_skip[*(unesc_char[append]
|
||||
|
@ -431,9 +404,8 @@ namespace mapnik { namespace grammar {
|
|||
unquoted_ustring[do_unicode]
|
||||
// ^ https://github.com/mapnik/mapnik/pull/3389
|
||||
;
|
||||
|
||||
BOOST_SPIRIT_DEFINE (
|
||||
expression,
|
||||
// clang-format on
|
||||
BOOST_SPIRIT_DEFINE(expression,
|
||||
logical_expression,
|
||||
not_expression,
|
||||
conditional_expression,
|
||||
|
@ -446,9 +418,9 @@ namespace mapnik { namespace grammar {
|
|||
unary_func_expression,
|
||||
binary_func_expression,
|
||||
unary_expression,
|
||||
primary_expression
|
||||
);
|
||||
primary_expression);
|
||||
|
||||
}}
|
||||
} // namespace grammar
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_EXPRESSIONS_GRAMMAR_X3_DEF_HPP
|
||||
|
|
|
@ -34,41 +34,100 @@
|
|||
// stl
|
||||
#include <memory>
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
namespace mapnik {
|
||||
|
||||
using value_type = mapnik::value;
|
||||
|
||||
template <typename Tag> struct make_op;
|
||||
template <> struct make_op<mapnik::tags::negate> { using type = std::negate<value_type>;};
|
||||
template <> struct make_op<mapnik::tags::plus> { using type = std::plus<value_type>;};
|
||||
template <> struct make_op<mapnik::tags::minus> { using type = std::minus<value_type>;};
|
||||
template <> struct make_op<mapnik::tags::mult> { using type = std::multiplies<value_type>;};
|
||||
template <> struct make_op<mapnik::tags::div> { using type = std::divides<value_type>;};
|
||||
template <> struct make_op<mapnik::tags::mod> { using type = std::modulus<value_type>;};
|
||||
template <> struct make_op<mapnik::tags::less> { using type = std::less<value_type>;};
|
||||
template <> struct make_op<mapnik::tags::less_equal> { using type = std::less_equal<value_type>;};
|
||||
template <> struct make_op<mapnik::tags::greater> { using type = std::greater<value_type>;};
|
||||
template <> struct make_op<mapnik::tags::greater_equal> { using type = std::greater_equal<value_type>;};
|
||||
template <> struct make_op<mapnik::tags::equal_to> { using type = std::equal_to<value_type>;};
|
||||
template <> struct make_op<mapnik::tags::not_equal_to> { using type = std::not_equal_to<value_type>;};
|
||||
template <> struct make_op<mapnik::tags::logical_not> { using type = std::logical_not<value_type>;};
|
||||
template <> struct make_op<mapnik::tags::logical_and> { using type = std::logical_and<value_type>;};
|
||||
template <> struct make_op<mapnik::tags::logical_or> { using type = std::logical_or<value_type>;};
|
||||
template<typename Tag>
|
||||
struct make_op;
|
||||
template<>
|
||||
struct make_op<mapnik::tags::negate>
|
||||
{
|
||||
using type = std::negate<value_type>;
|
||||
};
|
||||
template<>
|
||||
struct make_op<mapnik::tags::plus>
|
||||
{
|
||||
using type = std::plus<value_type>;
|
||||
};
|
||||
template<>
|
||||
struct make_op<mapnik::tags::minus>
|
||||
{
|
||||
using type = std::minus<value_type>;
|
||||
};
|
||||
template<>
|
||||
struct make_op<mapnik::tags::mult>
|
||||
{
|
||||
using type = std::multiplies<value_type>;
|
||||
};
|
||||
template<>
|
||||
struct make_op<mapnik::tags::div>
|
||||
{
|
||||
using type = std::divides<value_type>;
|
||||
};
|
||||
template<>
|
||||
struct make_op<mapnik::tags::mod>
|
||||
{
|
||||
using type = std::modulus<value_type>;
|
||||
};
|
||||
template<>
|
||||
struct make_op<mapnik::tags::less>
|
||||
{
|
||||
using type = std::less<value_type>;
|
||||
};
|
||||
template<>
|
||||
struct make_op<mapnik::tags::less_equal>
|
||||
{
|
||||
using type = std::less_equal<value_type>;
|
||||
};
|
||||
template<>
|
||||
struct make_op<mapnik::tags::greater>
|
||||
{
|
||||
using type = std::greater<value_type>;
|
||||
};
|
||||
template<>
|
||||
struct make_op<mapnik::tags::greater_equal>
|
||||
{
|
||||
using type = std::greater_equal<value_type>;
|
||||
};
|
||||
template<>
|
||||
struct make_op<mapnik::tags::equal_to>
|
||||
{
|
||||
using type = std::equal_to<value_type>;
|
||||
};
|
||||
template<>
|
||||
struct make_op<mapnik::tags::not_equal_to>
|
||||
{
|
||||
using type = std::not_equal_to<value_type>;
|
||||
};
|
||||
template<>
|
||||
struct make_op<mapnik::tags::logical_not>
|
||||
{
|
||||
using type = std::logical_not<value_type>;
|
||||
};
|
||||
template<>
|
||||
struct make_op<mapnik::tags::logical_and>
|
||||
{
|
||||
using type = std::logical_and<value_type>;
|
||||
};
|
||||
template<>
|
||||
struct make_op<mapnik::tags::logical_or>
|
||||
{
|
||||
using type = std::logical_or<value_type>;
|
||||
};
|
||||
|
||||
template<typename Tag>
|
||||
struct unary_node
|
||||
{
|
||||
unary_node(expr_node&& a)
|
||||
: expr(std::move(a)) {}
|
||||
: expr(std::move(a))
|
||||
{}
|
||||
|
||||
unary_node(expr_node const& a)
|
||||
: expr(a) {}
|
||||
: expr(a)
|
||||
{}
|
||||
|
||||
static const char* type()
|
||||
{
|
||||
return Tag::str();
|
||||
}
|
||||
static const char* type() { return Tag::str(); }
|
||||
|
||||
expr_node expr;
|
||||
};
|
||||
|
@ -77,17 +136,16 @@ template <typename Tag>
|
|||
struct binary_node
|
||||
{
|
||||
binary_node(expr_node&& a, expr_node&& b)
|
||||
: left(std::move(a)),
|
||||
right(std::move(b)) {}
|
||||
: left(std::move(a))
|
||||
, right(std::move(b))
|
||||
{}
|
||||
|
||||
binary_node(expr_node const& a, expr_node const& b)
|
||||
: left(a),
|
||||
right(b) {}
|
||||
: left(a)
|
||||
, right(b)
|
||||
{}
|
||||
|
||||
static const char* type()
|
||||
{
|
||||
return Tag::str();
|
||||
}
|
||||
static const char* type() { return Tag::str(); }
|
||||
expr_node left, right;
|
||||
};
|
||||
|
||||
|
@ -96,7 +154,9 @@ struct unary_function_call
|
|||
using argument_type = expr_node;
|
||||
unary_function_call() = default;
|
||||
unary_function_call(unary_function_impl _fun, argument_type const& _arg)
|
||||
: fun(_fun), arg(_arg) {}
|
||||
: fun(_fun)
|
||||
, arg(_arg)
|
||||
{}
|
||||
|
||||
unary_function_impl fun;
|
||||
argument_type arg;
|
||||
|
@ -107,7 +167,10 @@ struct binary_function_call
|
|||
using argument_type = expr_node;
|
||||
binary_function_call() = default;
|
||||
binary_function_call(binary_function_impl _fun, argument_type const& _arg1, argument_type const& _arg2)
|
||||
: fun(_fun), arg1(_arg1), arg2(_arg2) {}
|
||||
: fun(_fun)
|
||||
, arg1(_arg1)
|
||||
, arg2(_arg2)
|
||||
{}
|
||||
binary_function_impl fun;
|
||||
argument_type arg1;
|
||||
argument_type arg2;
|
||||
|
@ -137,7 +200,6 @@ struct MAPNIK_DECL regex_replace_node
|
|||
std::shared_ptr<_regex_replace_impl> impl_;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_EXPRESSION_NODE_HPP
|
||||
|
|
|
@ -28,136 +28,90 @@
|
|||
#include <mapnik/value/types.hpp>
|
||||
#include <mapnik/util/variant.hpp>
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
namespace mapnik {
|
||||
|
||||
namespace tags {
|
||||
struct negate
|
||||
{
|
||||
static const char* str()
|
||||
{
|
||||
return "-";
|
||||
}
|
||||
static const char* str() { return "-"; }
|
||||
};
|
||||
|
||||
struct plus
|
||||
{
|
||||
static const char* str()
|
||||
{
|
||||
return "+";
|
||||
}
|
||||
static const char* str() { return "+"; }
|
||||
};
|
||||
|
||||
struct minus
|
||||
{
|
||||
static const char* str()
|
||||
{
|
||||
return "-";
|
||||
}
|
||||
static const char* str() { return "-"; }
|
||||
};
|
||||
|
||||
struct mult
|
||||
{
|
||||
static const char* str()
|
||||
{
|
||||
return "*";
|
||||
}
|
||||
static const char* str() { return "*"; }
|
||||
};
|
||||
|
||||
struct div
|
||||
{
|
||||
static const char* str()
|
||||
{
|
||||
return "/";
|
||||
}
|
||||
static const char* str() { return "/"; }
|
||||
};
|
||||
|
||||
|
||||
struct mod
|
||||
{
|
||||
static const char* str()
|
||||
{
|
||||
return "%";
|
||||
}
|
||||
static const char* str() { return "%"; }
|
||||
};
|
||||
|
||||
struct less
|
||||
{
|
||||
static const char* str()
|
||||
{
|
||||
return "<";
|
||||
}
|
||||
static const char* str() { return "<"; }
|
||||
};
|
||||
|
||||
struct less_equal
|
||||
{
|
||||
static const char* str()
|
||||
{
|
||||
return "<=";
|
||||
}
|
||||
static const char* str() { return "<="; }
|
||||
};
|
||||
|
||||
struct greater
|
||||
{
|
||||
static const char* str()
|
||||
{
|
||||
return ">";
|
||||
}
|
||||
static const char* str() { return ">"; }
|
||||
};
|
||||
|
||||
struct greater_equal
|
||||
{
|
||||
static const char* str()
|
||||
{
|
||||
return ">=";
|
||||
}
|
||||
static const char* str() { return ">="; }
|
||||
};
|
||||
|
||||
struct equal_to
|
||||
{
|
||||
static const char* str()
|
||||
{
|
||||
return "=";
|
||||
}
|
||||
static const char* str() { return "="; }
|
||||
};
|
||||
|
||||
struct not_equal_to
|
||||
{
|
||||
static const char* str()
|
||||
{
|
||||
return "!=";
|
||||
}
|
||||
static const char* str() { return "!="; }
|
||||
};
|
||||
|
||||
struct logical_not
|
||||
{
|
||||
static const char* str()
|
||||
{
|
||||
return "not ";
|
||||
}
|
||||
static const char* str() { return "not "; }
|
||||
};
|
||||
|
||||
struct logical_and
|
||||
{
|
||||
static const char* str()
|
||||
{
|
||||
return " and ";
|
||||
}
|
||||
static const char* str() { return " and "; }
|
||||
};
|
||||
|
||||
struct logical_or
|
||||
{
|
||||
static const char* str()
|
||||
{
|
||||
return " or ";
|
||||
}
|
||||
static const char* str() { return " or "; }
|
||||
};
|
||||
|
||||
} // end operation tags
|
||||
} // namespace tags
|
||||
|
||||
|
||||
template <typename Tag> struct binary_node;
|
||||
template <typename Tag> struct unary_node;
|
||||
template<typename Tag>
|
||||
struct binary_node;
|
||||
template<typename Tag>
|
||||
struct unary_node;
|
||||
struct regex_match_node;
|
||||
struct regex_replace_node;
|
||||
struct attribute;
|
||||
|
@ -166,8 +120,7 @@ struct geometry_type_attribute;
|
|||
struct unary_function_call;
|
||||
struct binary_function_call;
|
||||
|
||||
using expr_node = util::variant<
|
||||
value_null,
|
||||
using expr_node = util::variant<value_null,
|
||||
value_bool,
|
||||
value_integer,
|
||||
value_double,
|
||||
|
@ -193,10 +146,8 @@ util::recursive_wrapper<binary_node<mapnik::tags::logical_or> >,
|
|||
util::recursive_wrapper<regex_match_node>,
|
||||
util::recursive_wrapper<regex_replace_node>,
|
||||
util::recursive_wrapper<unary_function_call>,
|
||||
util::recursive_wrapper<binary_function_call>
|
||||
>;
|
||||
|
||||
}
|
||||
util::recursive_wrapper<binary_function_call>>;
|
||||
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_EXPRESSION_NODE_HPP
|
||||
|
|
|
@ -35,8 +35,7 @@
|
|||
#include <string>
|
||||
#include <stdexcept>
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
namespace mapnik {
|
||||
MAPNIK_DECL std::string to_expression_string(expr_node const& node);
|
||||
|
||||
/*
|
||||
|
@ -63,6 +62,6 @@ std::string to_expression_string(std::shared_ptr<T> const& expr_node_ptr)
|
|||
// compile error intended here; comment on the next line shows in clang output
|
||||
return expr_node_ptr; // to_expression_string() called with pointer argument
|
||||
}
|
||||
}
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_EXPRESSION_STRING_HPP
|
||||
|
|
|
@ -38,11 +38,9 @@ MAPNIK_DISABLE_WARNING_POP
|
|||
// stl
|
||||
#include <cmath>
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
namespace mapnik {
|
||||
|
||||
namespace detail
|
||||
{
|
||||
namespace detail {
|
||||
|
||||
namespace msm = boost::msm;
|
||||
namespace mpl = boost::mpl;
|
||||
|
@ -55,26 +53,37 @@ T extend(T const & v1, T const & v2, double length)
|
|||
double dy = v2.y - v1.y;
|
||||
double l12 = std::sqrt(dx * dx + dy * dy);
|
||||
double coef = 1.0 + length / l12;
|
||||
return vertex2d(v1.x + dx * coef,
|
||||
v1.y + dy * coef, v2.cmd);
|
||||
return vertex2d(v1.x + dx * coef, v1.y + dy * coef, v2.cmd);
|
||||
}
|
||||
|
||||
namespace events
|
||||
{
|
||||
namespace events {
|
||||
struct vertex_event
|
||||
{
|
||||
vertex_event(vertex2d const & vertex) : vertex(vertex) { }
|
||||
vertex_event(vertex2d const& vertex)
|
||||
: vertex(vertex)
|
||||
{}
|
||||
vertex2d const& vertex;
|
||||
};
|
||||
|
||||
struct move_to : vertex_event { using vertex_event::vertex_event; };
|
||||
struct line_to : vertex_event { using vertex_event::vertex_event; };
|
||||
struct close : vertex_event { using vertex_event::vertex_event; };
|
||||
struct end : vertex_event { using vertex_event::vertex_event; };
|
||||
}
|
||||
|
||||
namespace actions
|
||||
struct move_to : vertex_event
|
||||
{
|
||||
using vertex_event::vertex_event;
|
||||
};
|
||||
struct line_to : vertex_event
|
||||
{
|
||||
using vertex_event::vertex_event;
|
||||
};
|
||||
struct close : vertex_event
|
||||
{
|
||||
using vertex_event::vertex_event;
|
||||
};
|
||||
struct end : vertex_event
|
||||
{
|
||||
using vertex_event::vertex_event;
|
||||
};
|
||||
} // namespace events
|
||||
|
||||
namespace actions {
|
||||
struct store
|
||||
{
|
||||
template<class FSM, class EVT, class SourceState, class TargetState>
|
||||
|
@ -126,20 +135,25 @@ namespace actions
|
|||
m.v1 = e.vertex;
|
||||
}
|
||||
};
|
||||
}
|
||||
} // namespace actions
|
||||
|
||||
struct extender_def : public msm::front::state_machine_def<extender_def>
|
||||
{
|
||||
using no_exception_thrown = int;
|
||||
using no_message_queue = int;
|
||||
|
||||
struct initial : public msm::front::state<> { };
|
||||
struct vertex_one : public msm::front::state<> { };
|
||||
struct vertex_two : public msm::front::state<> { };
|
||||
struct end : public msm::front::state<> { };
|
||||
struct initial : public msm::front::state<>
|
||||
{};
|
||||
struct vertex_one : public msm::front::state<>
|
||||
{};
|
||||
struct vertex_two : public msm::front::state<>
|
||||
{};
|
||||
struct end : public msm::front::state<>
|
||||
{};
|
||||
|
||||
using initial_state = initial;
|
||||
|
||||
// clang-format off
|
||||
struct transition_table : mpl::vector<
|
||||
// Start Event Next Action Guard
|
||||
// +------------+-----------------+------------+--------------------+------+
|
||||
|
@ -157,11 +171,11 @@ struct extender_def : public msm::front::state_machine_def<extender_def>
|
|||
Row < vertex_two , events::end , end , actions::output_end >,
|
||||
Row < end , events::end , end , actions::output >
|
||||
> {};
|
||||
// clang-format on
|
||||
|
||||
extender_def(double extend_length)
|
||||
: extend_length(extend_length)
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
boost::optional<vertex2d> output;
|
||||
vertex2d v1, v2;
|
||||
|
@ -170,7 +184,7 @@ struct extender_def : public msm::front::state_machine_def<extender_def>
|
|||
|
||||
using extender = msm::back::state_machine<extender_def>;
|
||||
|
||||
}
|
||||
} // namespace detail
|
||||
|
||||
template<typename Geometry>
|
||||
struct extend_converter
|
||||
|
@ -180,13 +194,11 @@ struct extend_converter
|
|||
{}
|
||||
|
||||
extend_converter(Geometry& geom, double extend)
|
||||
: geom_(geom), extender_(extend)
|
||||
: geom_(geom)
|
||||
, extender_(extend)
|
||||
{}
|
||||
|
||||
void set_extend(double extend)
|
||||
{
|
||||
extender_.extend_length = extend;
|
||||
}
|
||||
void set_extend(double extend) { extender_.extend_length = extend; }
|
||||
|
||||
unsigned vertex(double* x, double* y)
|
||||
{
|
||||
|
@ -229,6 +241,6 @@ private:
|
|||
detail::extender extender_;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_EXTEND_CONVERTER_HPP
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue