diff --git a/.gitattributes b/.gitattributes index 3e84d7c70..78ca6001c 100644 --- a/.gitattributes +++ b/.gitattributes @@ -79,7 +79,7 @@ COPYING text svneol=native#text/plain INSTALL text svneol=native#text/plain Jamfile text svneol=native#text/plain Jamroot text svneol=native#text/plain -Jamfile.v2 text svneol=native#text/plain +Jamfile text svneol=native#text/plain Jamrules text svneol=native#text/plain Makefile* text svneol=native#text/plain README text svneol=native#text/plain diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml new file mode 100644 index 000000000..a4db3aa10 --- /dev/null +++ b/.github/workflows/documentation.yml @@ -0,0 +1,104 @@ +############################################################################## +# GitHub Actions Workflow for Boost.Geometry to build documentation +# +# Copyright (c) 2020 Mateusz Loskot +# +# Use, modification and distribution is subject to the Boost Software License, +# Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) +############################################################################## +name: documentation + +on: + push: + branches: + - develop + - master + pull_request: + paths: + - '.github/workflows/documentation.yml' + - 'doc/**' + - 'index.html' + - 'Jamfile*' + - 'meta/libraries.json' + +jobs: + build: + name: Build documentation + runs-on: ubuntu-latest + steps: + - name: Set up environment + id: setenv + run: | + if [[ "$GITHUB_REF" == *master ]]; then + echo "::set-env name=BOOST_BRANCH::master" + else + echo "::set-env name=BOOST_BRANCH::develop" + fi + echo "::set-env name=BOOST_SELF::$(basename $GITHUB_WORKSPACE)" + echo "::set-env name=BOOST_ROOT::$GITHUB_WORKSPACE/boost-root" + echo "::set-output name=boost_self::$(basename $GITHUB_WORKSPACE)" + echo "::set-output name=boost_root::$GITHUB_WORKSPACE/boost-root" + + - name: Clone boostorg/boost + run: | + git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git $BOOST_ROOT + cd $BOOST_ROOT + git submodule update -q --init libs/headers + git submodule update -q --init tools/boost_install + git submodule update -q --init tools/boostbook + git submodule update -q --init tools/boostdep + git submodule update -q --init tools/build + git submodule update -q --init tools/quickbook + mkdir -p libs/$BOOST_SELF + + - uses: actions/checkout@v2 + with: + path: ${{ steps.setenv.outputs.boost_root }}/libs/${{ steps.setenv.outputs.boost_self }} + + - name: Run tools/boostdep/depinst/depinst.py + run: | + cd $BOOST_ROOT + python tools/boostdep/depinst/depinst.py ../tools/quickbook + python tools/boostdep/depinst/depinst.py --include benchmark --include example --include examples --include tools $BOOST_SELF + + - name: Bootstrap boostorg/boost + run: | + gcc --version + cd $BOOST_ROOT + ./bootstrap.sh --with-toolset=gcc + ./b2 headers + test -f /usr/local/bin/b2 && rm -rf /usr/local/bin/b2 + test -f /usr/local/bin/bjam && rm -rf /usr/local/bin/bjam + sudo cp $BOOST_ROOT/b2 /usr/local/bin/ + ls -l /usr/local/bin/b2 + b2 -v + + - name: Install tools/quickbook + run: | + sudo apt-get -q -y --no-install-suggests --no-install-recommends install docbook-xml docbook-xsl doxygen xsltproc + echo "# $HOME/user-config.jam" > $HOME/user-config.jam + echo "using doxygen ;" >> $HOME/user-config.jam + echo -e "using boostbook\n : /usr/share/xml/docbook/stylesheet/nwalsh\n : /usr/share/xml/docbook/schema/dtd/4.2\n ;" >> $HOME/user-config.jam + echo "using xsltproc ;" >> $HOME/user-config.jam + test -f $HOME/user-config.jam && cat $HOME/user-config.jam + + - name: Install libs/geometry/doc/src/docutils/tools/doxygen_xml2qbk + run: | + cd $BOOST_ROOT + $BOOST_ROOT/b2 variant=release libs/geometry/doc/src/docutils/tools/doxygen_xml2qbk + test -f /usr/local/bin/doxygen_xml2qbk && rm -rf /usr/local/bin/doxygen_xml2qbk + sudo cp $BOOST_ROOT/dist/bin/doxygen_xml2qbk /usr/local/bin/ + ls -l /usr/local/bin/b2 + doxygen_xml2qbk --version + + - name: Build libs/geometry/doc/src/examples + run: | + cd $BOOST_ROOT + $BOOST_ROOT/b2 libs/geometry/doc/src/examples + + - name: Run libs/geometry/doc/make_qbk.py + run: | + cd $BOOST_ROOT + cd libs/geometry/doc + python ./make_qbk.py diff --git a/.github/workflows/minimal-clang.yml b/.github/workflows/minimal-clang.yml new file mode 100644 index 000000000..5033993a1 --- /dev/null +++ b/.github/workflows/minimal-clang.yml @@ -0,0 +1,122 @@ +############################################################################## +# GitHub Actions Workflow for Boost.Geometry to build minimal tests with Clang +# +# Copyright (c) 2020 Mateusz Loskot +# +# Use, modification and distribution is subject to the Boost Software License, +# Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) +############################################################################## +name: clang-test-minimal + +on: [push, pull_request] + +jobs: + build: + name: ${{ matrix.b2_toolset }} + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + b2_toolset: [ + clang-3.9, + clang-4.0, + clang-5.0, + clang-6.0, + clang-7, + clang-8, + clang-9, + clang-10 + ] + + include: + - b2_toolset: clang-3.9 + b2_cxxstd: 03,11 + version: "3.9" + - b2_toolset: clang-4.0 + b2_cxxstd: 03,11 + version: "4.0" + - b2_toolset: clang-5.0 + b2_cxxstd: 03,11,14 + version: "5.0" + - b2_toolset: clang-6.0 + b2_cxxstd: 03,11,14 + version: "6.0" + - b2_toolset: clang-7 + b2_cxxstd: 03,11,14,17 + version: "7" + - b2_toolset: clang-8 + b2_cxxstd: 03,11,14,17 + version: "8" + - b2_toolset: clang-9 + b2_cxxstd: 03,11,14,17,2a + version: "9" + - b2_toolset: clang-10 + b2_cxxstd: 03,11,14,17,2a + version: "10" + + steps: + - name: Set up environment + id: setenv + run: | + if [[ "$GITHUB_REF" == *master ]]; then + echo "::set-env name=BOOST_BRANCH::master" + else + echo "::set-env name=BOOST_BRANCH::develop" + fi + echo "::set-env name=BOOST_SELF::$(basename $GITHUB_WORKSPACE)" + echo "::set-env name=BOOST_ROOT::$GITHUB_WORKSPACE/boost-root" + echo "::set-output name=boost_self::$(basename $GITHUB_WORKSPACE)" + echo "::set-output name=boost_root::$GITHUB_WORKSPACE/boost-root" + + - name: Clone boostorg/boost + run: | + git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git $BOOST_ROOT + cd $BOOST_ROOT + git submodule update -q --init libs/headers + git submodule update -q --init tools/boost_install + git submodule update -q --init tools/boostdep + git submodule update -q --init tools/build + mkdir -p libs/$BOOST_SELF + + - uses: actions/checkout@v2 + with: + path: ${{ steps.setenv.outputs.boost_root }}/libs/${{ steps.setenv.outputs.boost_self }} + + - name: Run tools/boostdep/depinst/depinst.py + run: | + cd $BOOST_ROOT + python tools/boostdep/depinst/depinst.py --include benchmark --include example --include examples --include tools $BOOST_SELF + + - name: Install + run: | + sudo add-apt-repository "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-10 main" + sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test + sudo apt -q -y update + sudo apt -q -y install clang-${{ matrix.version }} g++-multilib + + - name: Bootstrap boostorg/boost + run: | + gcc --version + cd $BOOST_ROOT + ./bootstrap.sh --with-toolset=gcc + ./b2 headers + test -f /usr/local/bin/b2 && rm -rf /usr/local/bin/b2 + test -f /usr/local/bin/bjam && rm -rf /usr/local/bin/bjam + sudo cp $BOOST_ROOT/b2 /usr/local/bin/ + ls -l /usr/local/bin/b2 + b2 -v + + - name: Set up clang toolset in ~/user-config.jam + run: | + export CXX_NAME=clang++-${{ matrix.version }} + echo ${CXX_NAME} + echo "# $HOME/user-config.jam" > $HOME/user-config.jam + echo "using clang : : $(which clang++-${{ matrix.version }}) ;" > ${HOME}/user-config.jam + test -f $HOME/user-config.jam && cat $HOME/user-config.jam + + - name: Build libs/geometry/test//minimal + run: | + cd $BOOST_ROOT + $BOOST_ROOT/b2 toolset=clang cxxstd=${{ matrix.b2_cxxstd }} variant=debug,release address-model=32,64 libs/geometry/test//minimal diff --git a/.github/workflows/minimal-gcc.yml b/.github/workflows/minimal-gcc.yml new file mode 100644 index 000000000..bcf1654e3 --- /dev/null +++ b/.github/workflows/minimal-gcc.yml @@ -0,0 +1,112 @@ +############################################################################## +# GitHub Actions Workflow for Boost.Geometry to build minimal tests with GCC +# +# Copyright (c) 2020 Mateusz Loskot +# +# Use, modification and distribution is subject to the Boost Software License, +# Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) +############################################################################## +name: gcc-test-minimal + +on: [push, pull_request] + +jobs: + build: + name: ${{ matrix.b2_toolset }} + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + b2_toolset: [ + gcc-4.8, + gcc-4.9, + gcc-5, + gcc-6, + gcc-7, + gcc-8, + gcc-9 + ] + + include: + - b2_toolset: gcc-4.8 + b2_cxxstd: 03,11 + version: "4.8" + - b2_toolset: gcc-4.9 + b2_cxxstd: 03,11 + version: "4.9" + - b2_toolset: gcc-5 + b2_cxxstd: 03,11,14 + version: "5" + - b2_toolset: gcc-6 + b2_cxxstd: 03,11,14 + version: "6" + - b2_toolset: gcc-7 + b2_cxxstd: 03,11,14,17 + version: "7" + - b2_toolset: gcc-8 + b2_cxxstd: 03,11,14,17 + version: "8" + - b2_toolset: gcc-9 + b2_cxxstd: 03,11,14,17,2a + version: "9" + + steps: + - name: Set up environment + id: setenv + run: | + if [[ "$GITHUB_REF" == *master ]]; then + echo "::set-env name=BOOST_BRANCH::master" + else + echo "::set-env name=BOOST_BRANCH::develop" + fi + echo "::set-env name=BOOST_SELF::$(basename $GITHUB_WORKSPACE)" + echo "::set-env name=BOOST_ROOT::$GITHUB_WORKSPACE/boost-root" + echo "::set-output name=boost_self::$(basename $GITHUB_WORKSPACE)" + echo "::set-output name=boost_root::$GITHUB_WORKSPACE/boost-root" + + - name: Clone boostorg/boost + run: | + git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git $BOOST_ROOT + cd $BOOST_ROOT + git submodule update -q --init libs/headers + git submodule update -q --init tools/boost_install + git submodule update -q --init tools/boostdep + git submodule update -q --init tools/build + mkdir -p libs/$BOOST_SELF + + - uses: actions/checkout@v2 + with: + path: ${{ steps.setenv.outputs.boost_root }}/libs/${{ steps.setenv.outputs.boost_self }} + + - name: Run tools/boostdep/depinst/depinst.py + run: | + cd $BOOST_ROOT + python tools/boostdep/depinst/depinst.py --include benchmark --include example --include examples --include tools $BOOST_SELF + + - name: Install + run: | + # gcc-4.8 is not available in Bionic anymore + sudo add-apt-repository "deb http://dk.archive.ubuntu.com/ubuntu/ xenial main" + sudo add-apt-repository "deb http://dk.archive.ubuntu.com/ubuntu/ xenial universe" + sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test + sudo apt -q -y update + sudo apt -q -y install g++-${{ matrix.version }} g++-${{ matrix.version }}-multilib + + - name: Bootstrap boostorg/boost + run: | + gcc --version + cd $BOOST_ROOT + ./bootstrap.sh --with-toolset=gcc + ./b2 headers + test -f /usr/local/bin/b2 && rm -rf /usr/local/bin/b2 + test -f /usr/local/bin/bjam && rm -rf /usr/local/bin/bjam + sudo cp $BOOST_ROOT/b2 /usr/local/bin/ + ls -l /usr/local/bin/b2 + b2 -v + + - name: Build libs/geometry/test//minimal + run: | + cd $BOOST_ROOT + $BOOST_ROOT/b2 toolset=${{ matrix.b2_toolset }} cxxstd=${{ matrix.b2_cxxstd }} variant=debug,release address-model=32,64 libs/geometry/test//minimal diff --git a/.github/workflows/minimal-msvc.yml b/.github/workflows/minimal-msvc.yml new file mode 100644 index 000000000..f442d2721 --- /dev/null +++ b/.github/workflows/minimal-msvc.yml @@ -0,0 +1,80 @@ +############################################################################## +# GitHub Actions Workflow for Boost.Geometry to build minimal tests with MSVC +# +# Copyright (c) 2020 Mateusz Loskot +# +# Use, modification and distribution is subject to the Boost Software License, +# Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) +############################################################################## +name: msvc-test-minimal + +on: [push, pull_request] + +jobs: + build: + name: ${{ matrix.b2_toolset }} + runs-on: windows-latest + + strategy: + fail-fast: false + matrix: + # TODO: Waiting for msvc-14.0, msvc-14.1 + # https://github.com/actions/virtual-environments/issues/68#issuecomment-596817066 + b2_toolset: [ + msvc-14.2 + ] + + include: + - b2_toolset: msvc-14.2 + b2_cxxstd: 14,17,2a + + steps: + - name: Set up environment + id: setenv + shell: pwsh + run: | + if ("$GITHUB_REF" -contains "master") { + echo "::set-env name=BOOST_BRANCH::master" + } else { + echo "::set-env name=BOOST_BRANCH::develop" + } + echo "::set-env name=BOOST_SELF::$((Get-Item $env:GITHUB_WORKSPACE).BaseName)" + echo "::set-env name=BOOST_ROOT::$env:GITHUB_WORKSPACE\boost-root" + echo "::set-output name=boost_self::$((Get-Item $env:GITHUB_WORKSPACE).BaseName)" + echo "::set-output name=boost_root::$env:GITHUB_WORKSPACE\boost-root" + + - name: Clone boostorg/boost + shell: pwsh + run: | + git clone -b $env:BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git $env:BOOST_ROOT + cd $env:BOOST_ROOT + git submodule update -q --init libs/headers + git submodule update -q --init tools/boost_install + git submodule update -q --init tools/boostdep + git submodule update -q --init tools/build + New-Item -Path libs\$env:BOOST_SELF -ItemType Directory -ErrorAction SilentlyContinue + + - uses: actions/checkout@v2 + with: + path: ${{ steps.setenv.outputs.boost_root }}/libs/${{ steps.setenv.outputs.boost_self }} + + - name: Run tools/boostdep/depinst/depinst.py + shell: pwsh + run: | + cd $env:BOOST_ROOT + python tools/boostdep/depinst/depinst.py --include benchmark --include example --include examples --include tools $env:BOOST_SELF + + - name: Bootstrap boostorg/boost + shell: pwsh + run: | + cd $env:BOOST_ROOT + .\bootstrap.bat --with-toolset=msvc + .\b2 headers + .\b2 -v + + - name: Build libs/geometry/test//minimal + shell: pwsh + run: | + cd $env:BOOST_ROOT + .\b2 toolset=${{ matrix.b2_toolset }} cxxstd=${{ matrix.b2_cxxstd }} variant=debug,release address-model=32,64 libs/geometry/test//minimal diff --git a/Jamfile.v2 b/Jamfile similarity index 100% rename from Jamfile.v2 rename to Jamfile diff --git a/README.md b/README.md index 094a67283..f4af8ed1d 100644 --- a/README.md +++ b/README.md @@ -10,10 +10,10 @@ Boost.Geometry, part of collection of the [Boost C++ Libraries](http://github.co ### Test results -@ | Build | Coverage | Regression -------------|---------------|----------------|------------ -**master** | [![status](https://circleci.com/gh/boostorg/geometry/tree/master.svg?style=shield)](https://circleci.com/gh/boostorg/geometry/tree/master) | [![status](https://coveralls.io/repos/github/boostorg/geometry/badge.svg?branch=master)](https://coveralls.io/github/boostorg/geometry?branch=master) | [![geometry](https://img.shields.io/badge/-geometry-4480cc.png)](http://www.boost.org/development/tests/master/developer/geometry.html) [![index](https://img.shields.io/badge/-index-4480cc.png)](http://www.boost.org/development/tests/master/developer/geometry-index.html) -**develop** | [![status](https://circleci.com/gh/boostorg/geometry/tree/develop.svg?style=shield)](https://circleci.com/gh/boostorg/geometry/tree/develop) | [![status](https://coveralls.io/repos/github/boostorg/geometry/badge.svg?branch=develop)](https://coveralls.io/github/boostorg/geometry?branch=develop) | [![geometry](https://img.shields.io/badge/-geometry-4480cc.png)](http://www.boost.org/development/tests/develop/developer/geometry.html) [![index](https://img.shields.io/badge/-index-4480cc.png)](http://www.boost.org/development/tests/develop/developer/geometry-index.html) [![extensions](https://img.shields.io/badge/-extensions-4480cc.png)](http://www.boost.org/development/tests/develop/developer/geometry-extensions.html) + Branch | Build | Coverage | Regression | Documentation +------------|---------------|----------------|------------|-------------- +**develop** | [![status](https://circleci.com/gh/boostorg/geometry/tree/develop.svg?style=shield)](https://circleci.com/gh/boostorg/geometry/tree/develop)
[![status](https://github.com/boostorg/geometry/workflows/clang-test-minimal/badge.svg?branch=develop)](https://github.com/boostorg/geometry/actions?query=branch:develop+workflow:clang-test-minimal)
[![status](https://github.com/boostorg/geometry/workflows/gcc-test-minimal/badge.svg?branch=develop)](https://github.com/boostorg/geometry/actions?query=branch:develop+workflow:gcc-test-minimal)
[![status](https://github.com/boostorg/geometry/workflows/msvc-test-minimal/badge.svg?branch=develop)](https://github.com/boostorg/geometry/actions?query=branch:develop+workflow:msvc-test-minimal) | [![status](https://coveralls.io/repos/github/boostorg/geometry/badge.svg?branch=develop)](https://coveralls.io/github/boostorg/geometry?branch=develop) | [![geometry](https://img.shields.io/badge/-geometry-4480cc.png)](http://www.boost.org/development/tests/develop/developer/geometry.html) [![index](https://img.shields.io/badge/-index-4480cc.png)](http://www.boost.org/development/tests/develop/developer/geometry-index.html) [![extensions](https://img.shields.io/badge/-extensions-4480cc.png)](http://www.boost.org/development/tests/develop/developer/geometry-extensions.html) | [![](https://github.com/boostorg/geometry/workflows/documentation/badge.svg?branch=develop)](https://github.com/boostorg/geometry/actions?query=branch:develop+workflow:documentation) +**master** | [![status](https://circleci.com/gh/boostorg/geometry/tree/master.svg?style=shield)](https://circleci.com/gh/boostorg/geometry/tree/master)
[![status](https://github.com/boostorg/geometry/workflows/clang-test-minimal/badge.svg?branch=master)](https://github.com/boostorg/geometry/actions?query=branch:master+workflow:clang-test-minimal)
[![status](https://github.com/boostorg/geometry/workflows/gcc-test-minimal/badge.svg?branch=master)](https://github.com/boostorg/geometry/actions?query=branch:master+workflow:gcc-test-minimal)
[![status](https://github.com/boostorg/geometry/workflows/msvc-test-minimal/badge.svg?branch=master)](https://github.com/boostorg/geometry/actions?query=branch:master+workflow:msvc-test-minimal) | [![status](https://coveralls.io/repos/github/boostorg/geometry/badge.svg?branch=master)](https://coveralls.io/github/boostorg/geometry?branch=master) | [![geometry](https://img.shields.io/badge/-geometry-4480cc.png)](http://www.boost.org/development/tests/master/developer/geometry.html) [![index](https://img.shields.io/badge/-index-4480cc.png)](http://www.boost.org/development/tests/master/developer/geometry-index.html) | [![](https://github.com/boostorg/geometry/workflows/documentation/badge.svg?branch=master)](https://github.com/boostorg/geometry/actions?query=branch:master+workflow:documentation) ### Directories diff --git a/doc/Jamfile.v2 b/doc/Jamfile similarity index 98% rename from doc/Jamfile.v2 rename to doc/Jamfile index afffae910..91b1139a3 100644 --- a/doc/Jamfile.v2 +++ b/doc/Jamfile @@ -31,7 +31,7 @@ explicit make_qbk ; boostbook geometry : geometry.qbk - : Jamfile.v2 + : Jamfile quickref.xml # generated/point.qbk chunk.section.depth=4 diff --git a/doc/compiling.qbk b/doc/compiling.qbk index 1cde2c6a0..dbfd12de5 100644 --- a/doc/compiling.qbk +++ b/doc/compiling.qbk @@ -83,7 +83,7 @@ compilers: __boost_geometry__ uses __boost_bb__, a text-based system for developing and testing software, to configure, build and execute unit tests and example -programs. The build configuration is provided as a collection of `Jamfile.v2` +programs. The build configuration is provided as a collection of `Jamfile` files. For gcc, flag [^-Wno-long-long] can be used to surpress some warnings diff --git a/doc/doxy/Doxyfile b/doc/doxy/Doxyfile index 904da9377..ed8705596 100644 --- a/doc/doxy/Doxyfile +++ b/doc/doxy/Doxyfile @@ -314,9 +314,9 @@ EXPAND_ONLY_PREDEF = YES SEARCH_INCLUDES = YES INCLUDE_PATH = INCLUDE_FILE_PATTERNS = -PREDEFINED = BOOST_CONCEPT_REQUIRES(x)= \ - BOOST_CONCEPT_ASSERT(x) = \ - BOOST_STATIC_ASSERT(x) = \ +PREDEFINED = BOOST_CONCEPT_REQUIRES(x) \ + BOOST_CONCEPT_ASSERT(x) \ + BOOST_STATIC_ASSERT(x) \ DOXYGEN_SHOULD_SKIP_THIS \ DOXYGEN_NO_DISPATCH \ DOXYGEN_NO_IMPL \ diff --git a/doc/doxy/doxygen_output/.gitignore b/doc/doxy/doxygen_output/.gitignore new file mode 100644 index 000000000..a7c59cc10 --- /dev/null +++ b/doc/doxy/doxygen_output/.gitignore @@ -0,0 +1,2 @@ +html_by_doxygen/ +xml/ diff --git a/doc/generated/.gitignore b/doc/generated/.gitignore new file mode 100644 index 000000000..9b1294c70 --- /dev/null +++ b/doc/generated/.gitignore @@ -0,0 +1 @@ +*.qbk \ No newline at end of file diff --git a/doc/html/.gitignore b/doc/html/.gitignore new file mode 100644 index 000000000..37ae5c557 --- /dev/null +++ b/doc/html/.gitignore @@ -0,0 +1,2 @@ +geometry/ +geometry_HTML.manifest diff --git a/doc/html/img/algorithms/covered_by.png b/doc/html/img/algorithms/covered_by.png new file mode 100644 index 000000000..e43d1da4b Binary files /dev/null and b/doc/html/img/algorithms/covered_by.png differ diff --git a/doc/html/img/algorithms/crosses.png b/doc/html/img/algorithms/crosses.png new file mode 100644 index 000000000..e5b9716f9 Binary files /dev/null and b/doc/html/img/algorithms/crosses.png differ diff --git a/doc/html/img/algorithms/disjoint.png b/doc/html/img/algorithms/disjoint.png new file mode 100644 index 000000000..8cf6988ef Binary files /dev/null and b/doc/html/img/algorithms/disjoint.png differ diff --git a/doc/html/img/algorithms/overlaps.png b/doc/html/img/algorithms/overlaps.png new file mode 100644 index 000000000..bc43df08f Binary files /dev/null and b/doc/html/img/algorithms/overlaps.png differ diff --git a/doc/html/img/algorithms/touches_one_geometry.png b/doc/html/img/algorithms/touches_one_geometry.png new file mode 100644 index 000000000..18e384ffa Binary files /dev/null and b/doc/html/img/algorithms/touches_one_geometry.png differ diff --git a/doc/html/img/algorithms/touches_two_geometries.png b/doc/html/img/algorithms/touches_two_geometries.png new file mode 100644 index 000000000..49dae63e9 Binary files /dev/null and b/doc/html/img/algorithms/touches_two_geometries.png differ diff --git a/doc/imports.qbk b/doc/imports.qbk index a3e8f4e59..a184f1513 100644 --- a/doc/imports.qbk +++ b/doc/imports.qbk @@ -31,12 +31,15 @@ [import src/examples/algorithms/convert.cpp] [import src/examples/algorithms/convex_hull.cpp] [import src/examples/algorithms/correct.cpp] +[import src/examples/algorithms/covered_by.cpp] +[import src/examples/algorithms/crosses.cpp] [import src/examples/algorithms/densify.cpp] [import src/examples/algorithms/densify_strategy.cpp] [import src/examples/algorithms/discrete_frechet_distance.cpp] [import src/examples/algorithms/discrete_frechet_distance_strategy.cpp] [import src/examples/algorithms/discrete_hausdorff_distance.cpp] [import src/examples/algorithms/discrete_hausdorff_distance_strategy.cpp] +[import src/examples/algorithms/disjoint.cpp] [import src/examples/algorithms/distance.cpp] [import src/examples/algorithms/difference.cpp] [import src/examples/algorithms/envelope.cpp] @@ -66,18 +69,25 @@ [import src/examples/algorithms/num_interior_rings.cpp] [import src/examples/algorithms/num_points.cpp] [import src/examples/algorithms/num_segments.cpp] +[import src/examples/algorithms/overlaps.cpp] +[import src/examples/algorithms/perimeter.cpp] [import src/examples/algorithms/relate.cpp] [import src/examples/algorithms/relation.cpp] [import src/examples/algorithms/reverse.cpp] [import src/examples/algorithms/return_envelope.cpp] [import src/examples/algorithms/simplify.cpp] [import src/examples/algorithms/sym_difference.cpp] +[import src/examples/algorithms/touches_one_geometry.cpp] +[import src/examples/algorithms/touches_two_geometries.cpp] [import src/examples/algorithms/transform.cpp] [import src/examples/algorithms/transform_with_strategy.cpp] [import src/examples/algorithms/union.cpp] [import src/examples/algorithms/unique.cpp] [import src/examples/algorithms/within.cpp] +[import src/examples/arithmetic/cross_product.cpp] +[import src/examples/arithmetic/dot_product.cpp] + [import src/examples/core/coordinate_type.cpp] [import src/examples/core/coordinate_system.cpp] [import src/examples/core/coordinate_dimension.cpp] @@ -103,6 +113,7 @@ [import src/examples/geometries/multi_point.cpp] [import src/examples/geometries/multi_polygon.cpp] [import src/examples/geometries/point_xy.cpp] +[import src/examples/geometries/point_xyz.cpp] [import src/examples/geometries/point.cpp] [import src/examples/geometries/polygon.cpp] [import src/examples/geometries/ring.cpp] diff --git a/doc/index/.gitignore b/doc/index/.gitignore new file mode 100644 index 000000000..a7c59cc10 --- /dev/null +++ b/doc/index/.gitignore @@ -0,0 +1,2 @@ +html_by_doxygen/ +xml/ diff --git a/doc/index/Jamfile.v2 b/doc/index/Jamfile similarity index 96% rename from doc/index/Jamfile.v2 rename to doc/index/Jamfile index e6f507006..895180e16 100644 --- a/doc/index/Jamfile.v2 +++ b/doc/index/Jamfile @@ -15,7 +15,7 @@ boostbook geometry_index-doc : index.qbk : - Jamfile.v2 + Jamfile generated/rtree.qbk html diff --git a/doc/index/generated/.gitignore b/doc/index/generated/.gitignore new file mode 100644 index 000000000..9b1294c70 --- /dev/null +++ b/doc/index/generated/.gitignore @@ -0,0 +1 @@ +*.qbk \ No newline at end of file diff --git a/doc/index/src/examples/Jamfile.v2 b/doc/index/src/examples/Jamfile similarity index 100% rename from doc/index/src/examples/Jamfile.v2 rename to doc/index/src/examples/Jamfile diff --git a/doc/index/src/examples/rtree/Jamfile.v2 b/doc/index/src/examples/rtree/Jamfile similarity index 100% rename from doc/index/src/examples/rtree/Jamfile.v2 rename to doc/index/src/examples/rtree/Jamfile diff --git a/doc/make_qbk.py b/doc/make_qbk.py index 7c6864de8..8a5cb6100 100755 --- a/doc/make_qbk.py +++ b/doc/make_qbk.py @@ -106,6 +106,8 @@ algorithms = ["append", "assign", "make", "clear" , "relation", "reverse","simplify", "sym_difference", "touches" , "transform", "union", "unique", "within"] +arithmetic = ["cross_product"] + access_functions = ["get", "set", "exterior_ring", "interior_rings" , "num_points", "num_interior_rings", "num_geometries"] @@ -190,6 +192,7 @@ for i in views: model_to_quickbook2("d2_1_1point__xy", "point_xy") +model_to_quickbook2("d3_1_1point__xyz", "point_xyz") group_to_quickbook("arithmetic") group_to_quickbook("dsv") diff --git a/doc/quickref.xml b/doc/quickref.xml index 0d6de52ca..4c1cc130a 100644 --- a/doc/quickref.xml +++ b/doc/quickref.xml @@ -87,6 +87,7 @@ point point_xy + point_xyz multi_point diff --git a/doc/reference.qbk b/doc/reference.qbk index 40010d59f..aa0be56c0 100644 --- a/doc/reference.qbk +++ b/doc/reference.qbk @@ -312,6 +312,7 @@ [include generated/point.qbk] [include generated/point_xy.qbk] +[include generated/point_xyz.qbk] [include generated/linestring.qbk] [include generated/polygon.qbk] [include generated/multi_point.qbk] diff --git a/doc/reference/geometries/point_xy.qbk b/doc/reference/geometries/point_xy.qbk index ead56d36f..7167c5922 100644 --- a/doc/reference/geometries/point_xy.qbk +++ b/doc/reference/geometries/point_xy.qbk @@ -13,6 +13,3 @@ [heading Examples] [point_xy] [point_xy_output] - -[include reference/geometries/point_assign_warning.qbk] - diff --git a/doc/reference/geometries/point_xyz.qbk b/doc/reference/geometries/point_xyz.qbk new file mode 100644 index 000000000..870f5d53e --- /dev/null +++ b/doc/reference/geometries/point_xyz.qbk @@ -0,0 +1,13 @@ +[/============================================================================ + Boost.Geometry (aka GGL, Generic Geometry Library) + + Copyright (c) 2020 Digvijay Janartha, Hamirpur, India. + + Use, modification and distribution is subject to the Boost Software License, + Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +=============================================================================/] + +[heading Examples] +[point_xyz] +[point_xyz_output] diff --git a/doc/src/docutils/tools/doxygen_xml2qbk/Jamfile.v2 b/doc/src/docutils/tools/doxygen_xml2qbk/Jamfile similarity index 100% rename from doc/src/docutils/tools/doxygen_xml2qbk/Jamfile.v2 rename to doc/src/docutils/tools/doxygen_xml2qbk/Jamfile diff --git a/doc/src/docutils/tools/doxygen_xml2qbk/sample/Jamfile.v2 b/doc/src/docutils/tools/doxygen_xml2qbk/sample/Jamfile similarity index 96% rename from doc/src/docutils/tools/doxygen_xml2qbk/sample/Jamfile.v2 rename to doc/src/docutils/tools/doxygen_xml2qbk/sample/Jamfile index 2337a69b5..72c1b8f18 100644 --- a/doc/src/docutils/tools/doxygen_xml2qbk/sample/Jamfile.v2 +++ b/doc/src/docutils/tools/doxygen_xml2qbk/sample/Jamfile @@ -17,7 +17,7 @@ import quickbook ; boostbook fruit : fruit.qbk - : Jamfile.v2 + : Jamfile generated/apple.qbk generated/rose.qbk generated/grouped.qbk diff --git a/doc/src/docutils/tools/implementation_status/Jamfile.v2 b/doc/src/docutils/tools/implementation_status/Jamfile similarity index 100% rename from doc/src/docutils/tools/implementation_status/Jamfile.v2 rename to doc/src/docutils/tools/implementation_status/Jamfile diff --git a/doc/src/docutils/tools/implementation_status/tmp/Jamfile.v2 b/doc/src/docutils/tools/implementation_status/tmp/Jamfile similarity index 100% rename from doc/src/docutils/tools/implementation_status/tmp/Jamfile.v2 rename to doc/src/docutils/tools/implementation_status/tmp/Jamfile diff --git a/doc/src/docutils/tools/support_status/Jamfile.v2 b/doc/src/docutils/tools/support_status/Jamfile similarity index 100% rename from doc/src/docutils/tools/support_status/Jamfile.v2 rename to doc/src/docutils/tools/support_status/Jamfile diff --git a/doc/src/examples/Jamfile.v2 b/doc/src/examples/Jamfile similarity index 100% rename from doc/src/examples/Jamfile.v2 rename to doc/src/examples/Jamfile diff --git a/doc/src/examples/algorithms/Jamfile.v2 b/doc/src/examples/algorithms/Jamfile similarity index 100% rename from doc/src/examples/algorithms/Jamfile.v2 rename to doc/src/examples/algorithms/Jamfile diff --git a/doc/src/examples/algorithms/covered_by.cpp b/doc/src/examples/algorithms/covered_by.cpp new file mode 100644 index 000000000..72eee97ef --- /dev/null +++ b/doc/src/examples/algorithms/covered_by.cpp @@ -0,0 +1,70 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// QuickBook Example + +// Copyright (c) 2020 Digvijay Janartha, Hamirpur, India. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +//[covered_by +//` Checks if the first geometry is inside or on border the second geometry + +#include + +#include +#include +#include + +namespace bg = boost::geometry; /*< Convenient namespace alias >*/ + +int main() +{ + // Checks if the first geometry is inside or on border the second geometry. + bg::model::polygon > poly1; + bg::read_wkt("POLYGON((0 2,0 3,2 4,1 2,0 2))", poly1); + bg::model::polygon > poly2; + bg::read_wkt("POLYGON((0 4,3 4,2 2,0 1,0 4))", poly2); + bool check_covered = bg::covered_by(poly1, poly2); + if (check_covered) { + std::cout << "Covered: Yes" << std::endl; + } else { + std::cout << "Covered: No" << std::endl; + } + + bg::model::polygon > poly3; + bg::read_wkt("POLYGON((-1 -1,-3 -4,-7 -7,-4 -3,-1 -1))", poly3); + check_covered = bg::covered_by(poly1, poly3); + if (check_covered) { + std::cout << "Covered: Yes" << std::endl; + } else { + std::cout << "Covered: No" << std::endl; + } + + // This should return true since both polygons are same, so they are lying on each other. + check_covered = bg::covered_by(poly1, poly1); + if (check_covered) { + std::cout << "Covered: Yes" << std::endl; + } else { + std::cout << "Covered: No" << std::endl; + } + + return 0; +} + +//] + + +//[covered_by_output +/*` +Output: +[pre +Covered: Yes + +[$img/algorithms/covered_by.png] + +Covered: No +Covered: Yes +] +*/ +//] diff --git a/doc/src/examples/algorithms/crosses.cpp b/doc/src/examples/algorithms/crosses.cpp new file mode 100644 index 000000000..c30380d71 --- /dev/null +++ b/doc/src/examples/algorithms/crosses.cpp @@ -0,0 +1,62 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// QuickBook Example + +// Copyright (c) 2020 Digvijay Janartha, Hamirpur, India. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +//[crosses +//` Checks if two geometries crosses + +#include + +#include +#include +#include + +namespace bg = boost::geometry; /*< Convenient namespace alias >*/ + +int main() +{ + // Checks if the two geometries (here, a polygon and a linestring) crosses or not. + bg::model::polygon > poly; + bg::read_wkt("POLYGON((0 0,0 3,3 3,3 0,0 0))", poly); + bg::model::linestring > line1; + bg::read_wkt("LINESTRING(1 1,2 2,4 4)", line1); + bool check_crosses = bg::crosses(poly, line1); + if (check_crosses) { + std::cout << "Crosses: Yes" << std::endl; + } else { + std::cout << "Crosses: No" << std::endl; + } + + // Edge case: linestring just touches the polygon but doesn't crosses it. + bg::model::linestring > line2; + bg::read_wkt("LINESTRING(1 1,1 2,1 3)", line2); + check_crosses = bg::crosses(poly, line2); + if (check_crosses) { + std::cout << "Crosses: Yes" << std::endl; + } else { + std::cout << "Crosses: No" << std::endl; + } + + return 0; +} + +//] + + +//[crosses_output +/*` +Output: +[pre +Crosses: Yes +Crosses: No + +[$img/algorithms/crosses.png] + +] +*/ +//] diff --git a/doc/src/examples/algorithms/disjoint.cpp b/doc/src/examples/algorithms/disjoint.cpp new file mode 100644 index 000000000..6beffc27a --- /dev/null +++ b/doc/src/examples/algorithms/disjoint.cpp @@ -0,0 +1,61 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// QuickBook Example + +// Copyright (c) 2020 Digvijay Janartha, Hamirpur, India. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +//[disjoint +//` Checks if two geometries are disjoint + +#include + +#include +#include +#include + +namespace bg = boost::geometry; /*< Convenient namespace alias >*/ + +int main() +{ + // Checks if two geometries are disjoint, which means that two geometries have zero intersection. + bg::model::polygon > poly1; + bg::read_wkt("POLYGON((0 2,-2 0,-4 2,-2 4,0 2))", poly1); + bg::model::polygon > poly2; + bg::read_wkt("POLYGON((2 2,4 4,6 2,4 0,2 2))", poly2); + bool check_disjoint = bg::disjoint(poly1, poly2); + if (check_disjoint) { + std::cout << "Disjoint: Yes" << std::endl; + } else { + std::cout << "Disjoint: No" << std::endl; + } + + bg::model::polygon > poly3; + bg::read_wkt("POLYGON((0 2,2 4,4 2,2 0,0 2))", poly3); + check_disjoint = bg::disjoint(poly1, poly3); + if (check_disjoint) { + std::cout << "Disjoint: Yes" << std::endl; + } else { + std::cout << "Disjoint: No" << std::endl; + } + + return 0; +} + +//] + + +//[disjoint_output +/*` +Output: +[pre +Disjoint: Yes +Disjoint: No + +[$img/algorithms/disjoint.png] + +] +*/ +//] diff --git a/doc/src/examples/algorithms/overlaps.cpp b/doc/src/examples/algorithms/overlaps.cpp new file mode 100644 index 000000000..497d5e17e --- /dev/null +++ b/doc/src/examples/algorithms/overlaps.cpp @@ -0,0 +1,61 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// QuickBook Example + +// Copyright (c) 2020 Digvijay Janartha, Hamirpur, India. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +//[overlaps +//` Checks if two geometries overlap + +#include + +#include +#include +#include + +namespace bg = boost::geometry; /*< Convenient namespace alias >*/ + +int main() +{ + // Checks if the two geometries overlaps or not. + bg::model::polygon > poly1; + bg::read_wkt("POLYGON((0 0,0 4,4 4,4 0,0 0))", poly1); + bg::model::polygon > poly2; + bg::read_wkt("POLYGON((2 2,2 6,6 7,6 1,2 2))", poly2); + bool check_overlap = bg::overlaps(poly1, poly2); + if (check_overlap) { + std::cout << "Overlaps: Yes" << std::endl; + } else { + std::cout << "Overlaps: No" << std::endl; + } + + bg::model::polygon > poly3; + bg::read_wkt("POLYGON((-1 -1,-3 -4,-7 -7,-4 -3,-1 -1))", poly3); + check_overlap = bg::overlaps(poly1, poly3); + if (check_overlap) { + std::cout << "Overlaps: Yes" << std::endl; + } else { + std::cout << "Overlaps: No" << std::endl; + } + + return 0; +} + +//] + + +//[overlaps_output +/*` +Output: +[pre +Overlaps: Yes + +[$img/algorithms/overlaps.png] + +Overlaps: No +] +*/ +//] diff --git a/doc/src/examples/algorithms/perimeter.cpp b/doc/src/examples/algorithms/perimeter.cpp new file mode 100644 index 000000000..130d8fdee --- /dev/null +++ b/doc/src/examples/algorithms/perimeter.cpp @@ -0,0 +1,42 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// QuickBook Example + +// Copyright (c) 2020 Digvijay Janartha, Hamirpur, India. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +//[perimeter +//` Calculate the perimeter of a polygon + +#include + +#include +#include +#include + +namespace bg = boost::geometry; /*< Convenient namespace alias >*/ + +int main() +{ + // Calculate the perimeter of a cartesian polygon + bg::model::polygon > poly; + bg::read_wkt("POLYGON((0 0,3 4,5 -5,-2 -4, 0 0))", poly); + double perimeter = bg::perimeter(poly); + std::cout << "Perimeter: " << perimeter << std::endl; + + return 0; +} + +//] + + +//[perimeter_output +/*` +Output: +[pre +Perimeter: 25.7627 +] +*/ +//] diff --git a/doc/src/examples/algorithms/touches_one_geometry.cpp b/doc/src/examples/algorithms/touches_one_geometry.cpp new file mode 100644 index 000000000..2604f9bd7 --- /dev/null +++ b/doc/src/examples/algorithms/touches_one_geometry.cpp @@ -0,0 +1,59 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// QuickBook Example + +// Copyright (c) 2020 Digvijay Janartha, Hamirpur, India. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +//[touches_one_geometry +//` Checks if a geometry has at least one touching point (self-tangency) + +#include + +#include +#include +#include + +namespace bg = boost::geometry; /*< Convenient namespace alias >*/ + +int main() +{ + // Checks if the geometry has self-tangency. + bg::model::polygon > poly1; + bg::read_wkt("POLYGON((0 0,0 3,2 3,2 2,1 2,1 1,2 1,2 2,3 2,3 0,0 0))", poly1); + bool check_touches = bg::touches(poly1); + if (check_touches) { + std::cout << "Touches: Yes" << std::endl; + } else { + std::cout << "Touches: No" << std::endl; + } + + bg::model::polygon > poly2; + bg::read_wkt("POLYGON((0 0,0 4,4 4,4 0,2 3,0 0))", poly2); + check_touches = bg::touches(poly2); + if (check_touches) { + std::cout << "Touches: Yes" << std::endl; + } else { + std::cout << "Touches: No" << std::endl; + } + + return 0; +} + +//] + + +//[touches_one_geometry_output +/*` +Output: +[pre +Touches: Yes + +[$img/algorithms/touches_one_geometry.png] + +Touches: No +] +*/ +//] diff --git a/doc/src/examples/algorithms/touches_two_geometries.cpp b/doc/src/examples/algorithms/touches_two_geometries.cpp new file mode 100644 index 000000000..1edba94cc --- /dev/null +++ b/doc/src/examples/algorithms/touches_two_geometries.cpp @@ -0,0 +1,61 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// QuickBook Example + +// Copyright (c) 2020 Digvijay Janartha, Hamirpur, India. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +//[touches_two_geometries +//` Checks if two geometries have at least one touching point (tangent - non overlapping) + +#include + +#include +#include +#include + +namespace bg = boost::geometry; /*< Convenient namespace alias >*/ + +int main() +{ + // Checks if the two geometries touch + bg::model::polygon > poly1; + bg::read_wkt("POLYGON((0 0,0 4,4 4,4 0,0 0))", poly1); + bg::model::polygon > poly2; + bg::read_wkt("POLYGON((0 0,0 -4,-4 -4,-4 0,0 0))", poly2); + bool check_touches = bg::touches(poly1, poly2); + if (check_touches) { + std::cout << "Touches: Yes" << std::endl; + } else { + std::cout << "Touches: No" << std::endl; + } + + bg::model::polygon > poly3; + bg::read_wkt("POLYGON((1 1,0 -4,-4 -4,-4 0,1 1))", poly3); + check_touches = bg::touches(poly1, poly3); + if (check_touches) { + std::cout << "Touches: Yes" << std::endl; + } else { + std::cout << "Touches: No" << std::endl; + } + + return 0; +} + +//] + + +//[touches_two_geometries_output +/*` +Output: +[pre +Touches: Yes + +[$img/algorithms/touches_two_geometries.png] + +Touches: No +] +*/ +//] diff --git a/doc/src/examples/arithmetic/cross_product.cpp b/doc/src/examples/arithmetic/cross_product.cpp new file mode 100644 index 000000000..ca2906be1 --- /dev/null +++ b/doc/src/examples/arithmetic/cross_product.cpp @@ -0,0 +1,57 @@ +// Boost.Geometry +// QuickBook Example + +// Copyright (c) 2020, Aditya Mohan + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +//[cross_product +//` Calculate the cross product of two points + + +#include +#include +#include + +namespace bg = boost::geometry; /*< Convenient namespace alias >*/ + +int main() +{ + //Example 1 2D Vector + + bg::model::point p1(7.0, 2.0); + bg::model::point p2(4.0, 5.0); + + bg::model::point r1; + + r1 = bg::cross_product(p1,p2); + + std::cout << "Cross Product 1: "<< r1.get<0>() << std::endl; //Note that the second point (r1.get<1>) would be undefined in this case + + //Example 2 - 3D Vector + + bg::model::point p3(4.0, 6.0, 5.0); + bg::model::point p4(7.0, 2.0, 3.0); + + bg::model::point r2; + + r2 = bg::cross_product(p3,p4); + + std::cout << "Cross Product 2: ("<< r2.get<0>() <<","<< r2.get<1>() <<","<< r2.get<2>() << ")"<< std::endl; + + return 0; +} + +//] + +//[cross_product_output +/*` +Output: +[pre +Cross Product 1: 27 +Cross Product 2: (8,23,-34) +] +*/ +//] diff --git a/doc/src/examples/arithmetic/dot_product.cpp b/doc/src/examples/arithmetic/dot_product.cpp new file mode 100644 index 000000000..9440b5dfd --- /dev/null +++ b/doc/src/examples/arithmetic/dot_product.cpp @@ -0,0 +1,66 @@ +// Boost.Geometry +// QuickBook Example + +// Copyright (c) 2020, Aditya Mohan + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +//[dot_product +//` Calculate the dot product of two points + +#include + +#include +#include +#include + +namespace bg = boost::geometry; /*< Convenient namespace alias >*/ + +BOOST_GEOMETRY_REGISTER_BOOST_ARRAY_CS(cs::cartesian) + + +int main() +{ + double dp1,dp2,dp3,dp4; + bg::model::point point1(1.0, 2.0, 3.0); + bg::model::point point2(4.0, 5.0, 6.0); + + //Example 1 + dp1 = bg::dot_product(point1, point2); + + std::cout << "Dot Product 1: "<< dp1 << std::endl; + + bg::model::point point3(3.0, 2.0); + bg::model::point point4(4.0, 7.0); + + //Example 2 + dp2 = bg::dot_product(point3, point4); + + std::cout << "Dot Product 2: "<< dp2 << std::endl; + + boost::array a = {1, 2}; + boost::array b = {2, 3}; + + //Example 3 + dp3 = bg::dot_product(a, b); + + std::cout << "Dot Product 3: "<< dp3 << std::endl; + + return 0; + +} + +//] + +//[dot_product_output +/*` +Output: +[pre +Dot Product 1: 32 +Dot Product 2: 26 +Dot Product 3: 8 +] +*/ +//] diff --git a/doc/src/examples/core/Jamfile.v2 b/doc/src/examples/core/Jamfile similarity index 100% rename from doc/src/examples/core/Jamfile.v2 rename to doc/src/examples/core/Jamfile diff --git a/doc/src/examples/geometries/Jamfile.v2 b/doc/src/examples/geometries/Jamfile similarity index 96% rename from doc/src/examples/geometries/Jamfile.v2 rename to doc/src/examples/geometries/Jamfile index cd0e71e6d..99ee90cc3 100644 --- a/doc/src/examples/geometries/Jamfile.v2 +++ b/doc/src/examples/geometries/Jamfile @@ -17,6 +17,7 @@ exe box : box.cpp ; exe linestring : linestring.cpp ; exe point : point.cpp ; exe point_xy : point_xy.cpp ; +exe point_xyz : point_xyz.cpp ; exe polygon : polygon.cpp ; exe multi_linestring : multi_linestring.cpp ; exe multi_point : multi_point.cpp ; diff --git a/doc/src/examples/geometries/adapted/Jamfile.v2 b/doc/src/examples/geometries/adapted/Jamfile similarity index 100% rename from doc/src/examples/geometries/adapted/Jamfile.v2 rename to doc/src/examples/geometries/adapted/Jamfile diff --git a/doc/src/examples/geometries/adapted/boost_range/Jamfile.v2 b/doc/src/examples/geometries/adapted/boost_range/Jamfile similarity index 100% rename from doc/src/examples/geometries/adapted/boost_range/Jamfile.v2 rename to doc/src/examples/geometries/adapted/boost_range/Jamfile diff --git a/doc/src/examples/geometries/point_xyz.cpp b/doc/src/examples/geometries/point_xyz.cpp new file mode 100644 index 000000000..92f636ecc --- /dev/null +++ b/doc/src/examples/geometries/point_xyz.cpp @@ -0,0 +1,46 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// QuickBook Example + +// Copyright (c) 2020 Digvijay Janartha, Hamirpur, India. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +//[point_xyz +//` Declaration and use of the Boost.Geometry model::d3::point_xyz, modelling the Point Concept + +#include +#include +#include + +namespace bg = boost::geometry; + +int main() +{ + bg::model::d3::point_xyz point1; + bg::model::d3::point_xyz point2(3, 4, 5); /*< Construct, assigning coordinates. >*/ + + bg::set<0>(point1, 1.0); /*< Set a coordinate, generic. >*/ + point1.y(2.0); /*< Set a coordinate, class-specific ([*Note]: prefer `bg::set()`). >*/ + point1.z(4.0); + + double x = bg::get<0>(point1); /*< Get a coordinate, generic. >*/ + double y = point1.y(); /*< Get a coordinate, class-specific ([*Note]: prefer `bg::get()`). >*/ + double z = point1.z(); + + std::cout << x << ", " << y << ", " << z << std::endl; + return 0; +} + +//] + + +//[point_xyz_output +/*` +Output: +[pre +1, 2, 4 +] +*/ +//] diff --git a/doc/src/examples/geometries/register/Jamfile.v2 b/doc/src/examples/geometries/register/Jamfile similarity index 100% rename from doc/src/examples/geometries/register/Jamfile.v2 rename to doc/src/examples/geometries/register/Jamfile diff --git a/doc/src/examples/io/Jamfile.v2 b/doc/src/examples/io/Jamfile similarity index 100% rename from doc/src/examples/io/Jamfile.v2 rename to doc/src/examples/io/Jamfile diff --git a/doc/src/examples/strategies/Jamfile.v2 b/doc/src/examples/strategies/Jamfile similarity index 100% rename from doc/src/examples/strategies/Jamfile.v2 rename to doc/src/examples/strategies/Jamfile diff --git a/doc/src/examples/views/Jamfile.v2 b/doc/src/examples/views/Jamfile similarity index 100% rename from doc/src/examples/views/Jamfile.v2 rename to doc/src/examples/views/Jamfile diff --git a/example/Jamfile.v2 b/example/Jamfile similarity index 100% rename from example/Jamfile.v2 rename to example/Jamfile diff --git a/extensions/Jamfile.v2 b/extensions/Jamfile similarity index 100% rename from extensions/Jamfile.v2 rename to extensions/Jamfile diff --git a/extensions/example/Jamfile.v2 b/extensions/example/Jamfile similarity index 100% rename from extensions/example/Jamfile.v2 rename to extensions/example/Jamfile diff --git a/extensions/example/gis/Jamfile.v2 b/extensions/example/gis/Jamfile similarity index 100% rename from extensions/example/gis/Jamfile.v2 rename to extensions/example/gis/Jamfile diff --git a/extensions/example/gis/latlong/Jamfile.v2 b/extensions/example/gis/latlong/Jamfile similarity index 100% rename from extensions/example/gis/latlong/Jamfile.v2 rename to extensions/example/gis/latlong/Jamfile diff --git a/extensions/example/gis/projections/Jamfile.v2 b/extensions/example/gis/projections/Jamfile similarity index 100% rename from extensions/example/gis/projections/Jamfile.v2 rename to extensions/example/gis/projections/Jamfile diff --git a/extensions/test/Jamfile.v2 b/extensions/test/Jamfile similarity index 100% rename from extensions/test/Jamfile.v2 rename to extensions/test/Jamfile diff --git a/extensions/test/algorithms/Jamfile.v2 b/extensions/test/algorithms/Jamfile similarity index 100% rename from extensions/test/algorithms/Jamfile.v2 rename to extensions/test/algorithms/Jamfile diff --git a/extensions/test/gis/Jamfile.v2 b/extensions/test/gis/Jamfile similarity index 100% rename from extensions/test/gis/Jamfile.v2 rename to extensions/test/gis/Jamfile diff --git a/extensions/test/gis/io/Jamfile.v2 b/extensions/test/gis/io/Jamfile similarity index 100% rename from extensions/test/gis/io/Jamfile.v2 rename to extensions/test/gis/io/Jamfile diff --git a/extensions/test/gis/io/shapefile/Jamfile.v2 b/extensions/test/gis/io/shapefile/Jamfile similarity index 100% rename from extensions/test/gis/io/shapefile/Jamfile.v2 rename to extensions/test/gis/io/shapefile/Jamfile diff --git a/extensions/test/gis/io/wkb/Jamfile.v2 b/extensions/test/gis/io/wkb/Jamfile similarity index 100% rename from extensions/test/gis/io/wkb/Jamfile.v2 rename to extensions/test/gis/io/wkb/Jamfile diff --git a/extensions/test/gis/latlong/Jamfile.v2 b/extensions/test/gis/latlong/Jamfile similarity index 100% rename from extensions/test/gis/latlong/Jamfile.v2 rename to extensions/test/gis/latlong/Jamfile diff --git a/extensions/test/iterators/Jamfile.v2 b/extensions/test/iterators/Jamfile similarity index 100% rename from extensions/test/iterators/Jamfile.v2 rename to extensions/test/iterators/Jamfile diff --git a/extensions/test/nsphere/Jamfile.v2 b/extensions/test/nsphere/Jamfile similarity index 100% rename from extensions/test/nsphere/Jamfile.v2 rename to extensions/test/nsphere/Jamfile diff --git a/extensions/test/triangulation/Jamfile.v2 b/extensions/test/triangulation/Jamfile similarity index 100% rename from extensions/test/triangulation/Jamfile.v2 rename to extensions/test/triangulation/Jamfile diff --git a/include/boost/geometry/algorithms/crosses.hpp b/include/boost/geometry/algorithms/crosses.hpp index c9e3651ab..6dcbdbe9d 100644 --- a/include/boost/geometry/algorithms/crosses.hpp +++ b/include/boost/geometry/algorithms/crosses.hpp @@ -252,6 +252,11 @@ inline bool crosses(Geometry1 const& geometry1, \return \return_check2{crosses} \qbk{[include reference/algorithms/crosses.qbk]} +\qbk{ +[heading Examples] +[crosses] +[crosses_output] +} */ template inline bool crosses(Geometry1 const& geometry1, Geometry2 const& geometry2) diff --git a/include/boost/geometry/algorithms/detail/buffer/buffer_inserter.hpp b/include/boost/geometry/algorithms/detail/buffer/buffer_inserter.hpp index c921f4759..0352287ee 100644 --- a/include/boost/geometry/algorithms/detail/buffer/buffer_inserter.hpp +++ b/include/boost/geometry/algorithms/detail/buffer/buffer_inserter.hpp @@ -612,7 +612,7 @@ struct buffer_inserter collection, distance, side_strategy, join_strategy, end_strategy, point_strategy, robust_policy, strategy); - collection.finish_ring(code); + collection.finish_ring(code, ring, false, false); return code; } }; @@ -810,7 +810,7 @@ private: join_strategy, end_strategy, point_strategy, robust_policy, strategy); - collection.finish_ring(code, is_interior); + collection.finish_ring(code, *it, is_interior, false); } } @@ -874,7 +874,7 @@ public: join_strategy, end_strategy, point_strategy, robust_policy, strategy); - collection.finish_ring(code, false, + collection.finish_ring(code, exterior_ring(polygon), false, geometry::num_interior_rings(polygon) > 0u); } @@ -947,9 +947,10 @@ inline void buffer_inserter(GeometryInput const& geometry_input, OutputIterator < typename geometry::ring_type::type, IntersectionStrategy, + DistanceStrategy, RobustPolicy > collection_type; - collection_type collection(intersection_strategy, robust_policy); + collection_type collection(intersection_strategy, distance_strategy, robust_policy); collection_type const& const_collection = collection; bool const areal = boost::is_same @@ -972,11 +973,11 @@ inline void buffer_inserter(GeometryInput const& geometry_input, OutputIterator end_strategy, point_strategy, robust_policy, intersection_strategy.get_side_strategy()); - collection.get_turns(distance_strategy); + collection.get_turns(); collection.classify_turns(); if (BOOST_GEOMETRY_CONDITION(areal)) { - collection.check_remaining_points(distance_strategy); + collection.check_remaining_points(); } // Visit the piece collection. This does nothing (by default), but diff --git a/include/boost/geometry/algorithms/detail/buffer/buffer_policies.hpp b/include/boost/geometry/algorithms/detail/buffer/buffer_policies.hpp index a37eabbe2..d95aab250 100644 --- a/include/boost/geometry/algorithms/detail/buffer/buffer_policies.hpp +++ b/include/boost/geometry/algorithms/detail/buffer/buffer_policies.hpp @@ -162,17 +162,9 @@ struct buffer_turn_info std::size_t turn_index; // TODO: this might go if partition can operate on non-const input RobustPoint robust_point; -#if defined(BOOST_GEOMETRY_BUFFER_ENLARGED_CLUSTERS) - // Will (most probably) be removed later - RobustPoint mapped_robust_point; // alas... we still need to adapt our points, offsetting them 1 integer to be co-located with neighbours -#endif - inline RobustPoint const& get_robust_point() const { -#if defined(BOOST_GEOMETRY_BUFFER_ENLARGED_CLUSTERS) - return mapped_robust_point; -#endif return robust_point; } @@ -183,32 +175,21 @@ struct buffer_turn_info std::size_t count_within; bool within_original; - std::size_t count_on_original_boundary; signed_size_type count_in_original; // increased by +1 for in ext.ring, -1 for int.ring std::size_t count_on_offsetted; std::size_t count_on_helper; std::size_t count_within_near_offsetted; - bool remove_on_multi; - - // Obsolete: - std::size_t count_on_occupied; - std::size_t count_on_multi; - inline buffer_turn_info() : turn_index(0) , location(location_ok) , count_within(0) , within_original(false) - , count_on_original_boundary(0) , count_in_original(0) , count_on_offsetted(0) , count_on_helper(0) , count_within_near_offsetted(0) - , remove_on_multi(false) - , count_on_occupied(0) - , count_on_multi(0) {} }; diff --git a/include/boost/geometry/algorithms/detail/buffer/buffered_piece_collection.hpp b/include/boost/geometry/algorithms/detail/buffer/buffered_piece_collection.hpp index 470eb8d3c..2b8f8ccbd 100644 --- a/include/boost/geometry/algorithms/detail/buffer/buffered_piece_collection.hpp +++ b/include/boost/geometry/algorithms/detail/buffer/buffered_piece_collection.hpp @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -51,14 +52,13 @@ #include #include #include -#include #include #include #include +#include #include - namespace boost { namespace geometry { @@ -67,13 +67,6 @@ namespace boost { namespace geometry namespace detail { namespace buffer { -enum segment_relation_code -{ - segment_relation_on_left, - segment_relation_on_right, - segment_relation_within, - segment_relation_disjoint -}; /* * Terminology @@ -119,14 +112,15 @@ enum segment_relation_code */ -template +template +< + typename Ring, + typename IntersectionStrategy, + typename DistanceStrategy, + typename RobustPolicy +> struct buffered_piece_collection { - typedef buffered_piece_collection - < - Ring, IntersectionStrategy, RobustPolicy - > this_type; - typedef typename geometry::point_type::type point_type; typedef typename geometry::coordinate_type::type coordinate_type; typedef typename geometry::robust_point_type @@ -250,8 +244,6 @@ struct buffered_piece_collection robust_box_type robust_envelope; robust_box_type robust_offsetted_envelope; - std::vector robust_turns; // Used only in insert_rescaled_piece_turns - we might use a map instead - robust_point_type robust_center; robust_comparable_radius_type robust_min_comparable_radius; robust_comparable_radius_type robust_max_comparable_radius; @@ -277,17 +269,17 @@ struct buffered_piece_collection } }; - struct robust_original + struct original_ring { - typedef robust_ring_type original_robust_ring_type; typedef geometry::sections sections_type; - inline robust_original() + // Creates an empty instance + inline original_ring() : m_is_interior(false) - , m_has_interiors(true) + , m_has_interiors(false) {} - inline robust_original(robust_ring_type const& ring, + inline original_ring(robust_ring_type const& ring, bool is_interior, bool has_interiors, envelope_strategy_type const& envelope_strategy, expand_strategy_type const& expand_strategy) @@ -323,9 +315,11 @@ struct buffered_piece_collection bool m_deflate; bool m_has_deflated; - buffered_ring_collection > offsetted_rings; // indexed by multi_index - std::vector robust_originals; // robust representation of the original(s) - robust_ring_type current_robust_ring; + // Offsetted rings, and representations of original ring(s) + // both indexed by multi_index + buffered_ring_collection > offsetted_rings; + std::vector original_rings; + buffered_ring_collection traversed_rings; segment_identifier current_segment_id; @@ -344,6 +338,7 @@ struct buffered_piece_collection cluster_type m_clusters; IntersectionStrategy m_intersection_strategy; + DistanceStrategy m_distance_strategy; side_strategy_type m_side_strategy; area_strategy_type m_area_strategy; envelope_strategy_type m_envelope_strategy; @@ -353,20 +348,14 @@ struct buffered_piece_collection robust_area_strategy_type m_robust_area_strategy; RobustPolicy const& m_robust_policy; - struct redundant_turn - { - inline bool operator()(buffer_turn_info_type const& turn) const - { - return turn.remove_on_multi; - } - }; - buffered_piece_collection(IntersectionStrategy const& intersection_strategy, + DistanceStrategy const& distance_strategy, RobustPolicy const& robust_policy) : m_first_piece_index(-1) , m_deflate(false) , m_has_deflated(false) , m_intersection_strategy(intersection_strategy) + , m_distance_strategy(distance_strategy) , m_side_strategy(intersection_strategy.get_side_strategy()) , m_area_strategy(intersection_strategy .template get_area_strategy()) @@ -381,163 +370,6 @@ struct buffered_piece_collection {} -#if defined(BOOST_GEOMETRY_BUFFER_ENLARGED_CLUSTERS) - // Will (most probably) be removed later - template - inline void adapt_mapped_robust_point(OccupationMap const& map, - buffer_turn_info_type& turn, int distance) const - { - for (int x = -distance; x <= distance; x++) - { - for (int y = -distance; y <= distance; y++) - { - robust_point_type rp = turn.robust_point; - geometry::set<0>(rp, geometry::get<0>(rp) + x); - geometry::set<1>(rp, geometry::get<1>(rp) + y); - if (map.find(rp) != map.end()) - { - turn.mapped_robust_point = rp; - return; - } - } - } - } -#endif - - inline void get_occupation( -#if defined(BOOST_GEOMETRY_BUFFER_ENLARGED_CLUSTERS) - int distance = 0 -#endif - ) - { - typedef occupation_info > - buffer_occupation_info; - - typedef std::map - < - robust_point_type, - buffer_occupation_info, - geometry::less - > occupation_map_type; - - occupation_map_type occupation_map; - - // 1: Add all intersection points to occupation map - typedef typename boost::range_iterator::type - iterator_type; - - for (iterator_type it = boost::begin(m_turns); - it != boost::end(m_turns); - ++it) - { - if (it->location == location_ok) - { -#if defined(BOOST_GEOMETRY_BUFFER_ENLARGED_CLUSTERS) - if (distance > 0 && ! occupation_map.empty()) - { - adapt_mapped_robust_point(occupation_map, *it, distance); - } -#endif - occupation_map[it->get_robust_point()].count++; - } - } - - // Remove all points with one or more u/u points from the map - // (Alternatively, we could NOT do this here and change all u/u - // behaviour in overlay. Currently nothing is done: each polygon is - // just followed there. We could also always switch polygons there. For - // buffer behaviour, where 3 pieces might meet of which 2 (or more) form - // a u/u turn, this last option would have been better, probably). - for (iterator_type it = boost::begin(m_turns); - it != boost::end(m_turns); - ++it) - { - if (it->both(detail::overlay::operation_union)) - { - typename occupation_map_type::iterator mit = - occupation_map.find(it->get_robust_point()); - - if (mit != occupation_map.end()) - { - occupation_map.erase(mit); - } - } - } - - // 2: Remove all points from map which has only one - typename occupation_map_type::iterator it = occupation_map.begin(); - while (it != occupation_map.end()) - { - if (it->second.count <= 1) - { - typename occupation_map_type::iterator to_erase = it; - ++it; - occupation_map.erase(to_erase); - } - else - { - ++it; - } - } - - if (occupation_map.empty()) - { - return; - } - - // 3: Add vectors (incoming->intersection-point, - // intersection-point -> outgoing) - // for all (co-located) points still present in the map - - for (iterator_type tit = boost::begin(m_turns); - tit != boost::end(m_turns); - ++tit) - { - typename occupation_map_type::iterator mit = - occupation_map.find(tit->get_robust_point()); - - if (mit != occupation_map.end()) - { - buffer_occupation_info& info = mit->second; - for (int i = 0; i < 2; i++) - { - add_incoming_and_outgoing_angles(tit->get_robust_point(), *tit, - m_pieces, - i, tit->operations[i].seg_id, - info); - } - - tit->count_on_multi++; - } - } - -#if defined(BOOST_GEOMETRY_BUFFER_ENLARGED_CLUSTERS) - // X: Check rounding issues - if (distance == 0) - { - for (typename occupation_map_type::const_iterator it = occupation_map.begin(); - it != occupation_map.end(); ++it) - { - if (it->second.has_rounding_issues(it->first)) - { - if(distance == 0) - { - get_occupation(distance + 1); - return; - } - } - } - } -#endif - - // Get left turns from all clusters - for (typename occupation_map_type::iterator mit = occupation_map.begin(); - mit != occupation_map.end(); ++mit) - { - mit->second.get_left_turns(mit->first, m_turns, m_side_strategy); - } - } - inline void classify_turns() { for (typename boost::range_iterator::type it = @@ -646,8 +478,7 @@ struct buffered_piece_collection } } - template - inline void check_remaining_points(DistanceStrategy const& distance_strategy) + inline void check_remaining_points() { // Check if a turn is inside any of the originals @@ -671,11 +502,11 @@ struct buffered_piece_collection robust_box_type, include_turn_policy, detail::partition::include_all_policy - >::apply(m_turns, robust_originals, visitor, + >::apply(m_turns, original_rings, visitor, turn_get_box(), turn_in_original_ovelaps_box_type(), original_get_box(), original_ovelaps_box_type()); - bool const deflate = distance_strategy.negative(); + bool const deflate = m_distance_strategy.negative(); for (typename boost::range_iterator::type it = boost::begin(m_turns); it != boost::end(m_turns); ++it) @@ -703,100 +534,15 @@ struct buffered_piece_collection } } - inline bool assert_indices_in_robust_rings() const - { - geometry::equal_to comparator; - for (typename boost::range_iterator::type it = - boost::begin(m_turns); it != boost::end(m_turns); ++it) - { - for (int i = 0; i < 2; i++) - { - robust_point_type const &p1 - = m_pieces[it->operations[i].piece_index].robust_ring - [it->operations[i].index_in_robust_ring]; - robust_point_type const &p2 = it->robust_point; - if (! comparator(p1, p2)) - { - return false; - } - } - } - return true; - } - - inline void insert_rescaled_piece_turns() + inline void update_turn_administration() { // Add rescaled turn points to corresponding pieces - // (after this, each turn occurs twice) std::size_t index = 0; for (typename boost::range_iterator::type it = boost::begin(m_turns); it != boost::end(m_turns); ++it, ++index) { geometry::recalculate(it->robust_point, it->point, m_robust_policy); -#if defined(BOOST_GEOMETRY_BUFFER_ENLARGED_CLUSTERS) - it->mapped_robust_point = it->robust_point; -#endif - - robust_turn turn; it->turn_index = index; - turn.turn_index = index; - turn.point = it->robust_point; - for (int i = 0; i < 2; i++) - { - turn.operation_index = i; - turn.seg_id = it->operations[i].seg_id; - turn.fraction = it->operations[i].fraction; - - piece& pc = m_pieces[it->operations[i].piece_index]; - pc.robust_turns.push_back(turn); - - // Take into account for the box (intersection points should fall inside, - // but in theory they can be one off because of rounding - geometry::expand(pc.robust_envelope, it->robust_point); - geometry::expand(pc.robust_offsetted_envelope, it->robust_point); - } - } - - if (! use_side_of_intersection::type>::value) - { - // Insert all rescaled turn-points into these rings, to form a - // reliable integer-based ring. All turns can be compared (inside) to this - // rings to see if they are inside. - - for (typename boost::range_iterator::type - it = boost::begin(m_pieces); it != boost::end(m_pieces); ++it) - { - piece& pc = *it; - signed_size_type piece_segment_index = pc.first_seg_id.segment_index; - if (! pc.robust_turns.empty()) - { - if (pc.robust_turns.size() > 1u) - { - std::sort(pc.robust_turns.begin(), pc.robust_turns.end(), buffer_operation_less()); - } - // Walk through them, in reverse to insert at right index - signed_size_type index_offset = static_cast(pc.robust_turns.size()) - 1; - for (typename boost::range_reverse_iterator >::type - rit = boost::const_rbegin(pc.robust_turns); - rit != boost::const_rend(pc.robust_turns); - ++rit, --index_offset) - { - signed_size_type const index_in_vector = 1 + rit->seg_id.segment_index - piece_segment_index; - BOOST_GEOMETRY_ASSERT - ( - index_in_vector > 0 - && index_in_vector < pc.offsetted_count - ); - - pc.robust_ring.insert(boost::begin(pc.robust_ring) + index_in_vector, rit->point); - pc.offsetted_count++; - - m_turns[rit->turn_index].operations[rit->operation_index].index_in_robust_ring = index_in_vector + index_offset; - } - } - } - - BOOST_GEOMETRY_ASSERT(assert_indices_in_robust_rings()); } } @@ -916,17 +662,8 @@ struct buffered_piece_collection } } - template - inline void get_turns(DistanceStrategy const& distance_strategy) + inline void get_turns() { - for(typename boost::range_iterator::type it - = boost::begin(monotonic_sections); - it != boost::end(monotonic_sections); - ++it) - { - enlarge_box(it->bounding_box, 1); - } - { // Calculate the turns piece_turn_visitor @@ -948,6 +685,8 @@ struct buffered_piece_collection typename IntersectionStrategy::disjoint_box_box_strategy_type > overlaps_section_box_type; + detail::sectionalize::enlarge_sections(monotonic_sections, + m_envelope_strategy); geometry::partition < robust_box_type @@ -956,7 +695,7 @@ struct buffered_piece_collection overlaps_section_box_type()); } - insert_rescaled_piece_turns(); + update_turn_administration(); reverse_negative_robust_rings(); @@ -974,7 +713,7 @@ struct buffered_piece_collection point_in_geometry_strategy_type, side_strategy_type > visitor(m_turns, m_pieces, - distance_strategy, + m_distance_strategy, m_point_in_geometry_strategy, m_side_strategy); @@ -999,14 +738,14 @@ struct buffered_piece_collection inline void start_new_ring(bool deflate) { - signed_size_type const n = static_cast(offsetted_rings.size()); + std::size_t const n = offsetted_rings.size(); current_segment_id.source_index = 0; - current_segment_id.multi_index = n; + current_segment_id.multi_index = static_cast(n); current_segment_id.ring_index = -1; current_segment_id.segment_index = 0; offsetted_rings.resize(n + 1); - current_robust_ring.clear(); + original_rings.resize(n + 1); m_first_piece_index = static_cast(boost::size(m_pieces)); m_deflate = deflate; @@ -1025,32 +764,15 @@ struct buffered_piece_collection && m_pieces.back().first_seg_id.multi_index == current_segment_id.multi_index) { - m_pieces.erase(m_pieces.end() - 1); + m_pieces.pop_back(); } - while (! monotonic_sections.empty() - && monotonic_sections.back().ring_id.multi_index - == current_segment_id.multi_index) - { - monotonic_sections.erase(monotonic_sections.end() - 1); - } - - offsetted_rings.erase(offsetted_rings.end() - 1); - current_robust_ring.clear(); + offsetted_rings.pop_back(); + original_rings.pop_back(); m_first_piece_index = -1; } - inline void update_closing_point() - { - BOOST_GEOMETRY_ASSERT(! offsetted_rings.empty()); - buffered_ring& added = offsetted_rings.back(); - if (! boost::empty(added)) - { - range::back(added) = range::front(added); - } - } - inline void update_last_point(point_type const& p, buffered_ring& ring) { @@ -1079,43 +801,84 @@ struct buffered_piece_collection m_robust_policy); } - inline void finish_ring(strategy::buffer::result_code code, - bool is_interior = false, bool has_interiors = false) + inline bool finish_ring(strategy::buffer::result_code code) { if (code == strategy::buffer::result_error_numerical) { abort_ring(); - return; + return false; } if (m_first_piece_index == -1) + { + return false; + } + + // Casted version + std::size_t const first_piece_index + = static_cast(m_first_piece_index); + signed_size_type const last_piece_index + = static_cast(boost::size(m_pieces)) - 1; + + if (first_piece_index < boost::size(m_pieces)) + { + // If pieces were added, + // reassign left-of-first and right-of-last + geometry::range::at(m_pieces, first_piece_index).left_index + = last_piece_index; + geometry::range::back(m_pieces).right_index = m_first_piece_index; + } + + buffered_ring& added = offsetted_rings.back(); + if (! boost::empty(added)) + { + // Make sure the closing point is identical (they are calculated + // separately by different pieces) + range::back(added) = range::front(added); + } + + for (std::size_t i = first_piece_index; i < boost::size(m_pieces); i++) + { + sectionalize(m_pieces[i], added); + } + + m_first_piece_index = -1; + return true; + } + + template + inline void finish_ring(strategy::buffer::result_code code, + InputRing const& input_ring, + bool is_interior, bool has_interiors) + { + if (! finish_ring(code)) { return; } - if (m_first_piece_index < static_cast(boost::size(m_pieces))) + if (! input_ring.empty()) { - // If piece was added - // Reassign left-of-first and right-of-last - geometry::range::at(m_pieces, m_first_piece_index).left_index - = static_cast(boost::size(m_pieces)) - 1; - geometry::range::back(m_pieces).right_index = m_first_piece_index; - } - m_first_piece_index = -1; + // Assign the ring to the original_ring collection + // For rescaling, it is recalculated. Without rescaling, it + // is just assigning (note that this Ring type is the + // GeometryOut type, which might differ from the input ring type) + geometry::model::ring adapted_ring; - update_closing_point(); + typedef detail::normalized_view view_type; + view_type const view(input_ring); - if (! current_robust_ring.empty()) - { - BOOST_GEOMETRY_ASSERT - ( - geometry::equals(current_robust_ring.front(), - current_robust_ring.back()) - ); + for (typename boost::range_iterator::type it = + boost::begin(view); it != boost::end(view); ++it) + { + robust_point_type adapted_point; + geometry::recalculate(adapted_point, *it, m_robust_policy); + adapted_ring.push_back(adapted_point); + } - robust_originals.push_back( - robust_original(current_robust_ring, - is_interior, has_interiors, m_envelope_strategy, m_expand_strategy)); + original_rings.back() + = original_ring(adapted_ring, + is_interior, has_interiors, + m_envelope_strategy, m_expand_strategy); } } @@ -1174,7 +937,6 @@ struct buffered_piece_collection { // This indicates an error situation: an earlier piece was empty // It currently does not happen - // std::cout << "EMPTY " << pc.type << " " << pc.index << " " << pc.first_seg_id.multi_index << std::endl; pc.offsetted_count = 0; return; } @@ -1203,7 +965,7 @@ struct buffered_piece_collection } } - inline robust_point_type add_helper_point(piece& pc, const point_type& point) + inline void add_helper_point(piece& pc, const point_type& point) { #if defined(BOOST_GEOMETRY_BUFFER_USE_HELPER_POINTS) pc.helper_points.push_back(point); @@ -1212,17 +974,18 @@ struct buffered_piece_collection robust_point_type rob_point; geometry::recalculate(rob_point, point, m_robust_policy); pc.robust_ring.push_back(rob_point); - return rob_point; } - // TODO: this is shared with sectionalize, move to somewhere else (assign?) - template - inline void enlarge_box(Box& box, Value value) + template + static inline void enlarge_box(Box& box) { - geometry::set<0, 0>(box, geometry::get<0, 0>(box) - value); - geometry::set<0, 1>(box, geometry::get<0, 1>(box) - value); - geometry::set<1, 0>(box, geometry::get<1, 0>(box) + value); - geometry::set<1, 1>(box, geometry::get<1, 1>(box) + value); +#if defined(BOOST_GEOMETRY_USE_RESCALING) + // Enlarge the box by 1 pixel, or 1 unit + detail::buffer::buffer_box(box, 1, box); +#else + // Enlarge the box just a bit + detail::buffer::buffer_box(box, 0.001, box); +#endif } inline void calculate_robust_envelope(piece& pc) @@ -1240,16 +1003,13 @@ struct buffered_piece_collection geometry::expand(pc.robust_offsetted_envelope, pc.robust_ring[i]); } - // Take roundings into account, enlarge boxes with 1 integer - enlarge_box(pc.robust_envelope, 1); - enlarge_box(pc.robust_offsetted_envelope, 1); + // Take roundings into account, enlarge boxes + enlarge_box(pc.robust_envelope); + enlarge_box(pc.robust_offsetted_envelope); } - inline void sectionalize(piece& pc) + inline void sectionalize(piece const& pc, buffered_ring const& ring) { - - buffered_ring const& ring = offsetted_rings.back(); - typedef geometry::detail::sectionalize::sectionalize_part < point_type, @@ -1259,7 +1019,7 @@ struct buffered_piece_collection // Create a ring-identifier. The source-index is the piece index // The multi_index is as in this collection (the ring), but not used here // The ring_index is not used - ring_identifier ring_id(pc.index, pc.first_seg_id.multi_index, -1); + ring_identifier const ring_id(pc.index, pc.first_seg_id.multi_index, -1); sectionalizer::apply(monotonic_sections, boost::begin(ring) + pc.first_seg_id.segment_index, @@ -1272,7 +1032,6 @@ struct buffered_piece_collection { init_rescale_piece(pc, 0u); calculate_robust_envelope(pc); - sectionalize(pc); } inline void finish_piece(piece& pc, @@ -1287,12 +1046,9 @@ struct buffered_piece_collection } add_helper_point(pc, point1); - robust_point_type mid_point = add_helper_point(pc, point2); + add_helper_point(pc, point2); add_helper_point(pc, point3); calculate_robust_envelope(pc); - sectionalize(pc); - - current_robust_ring.push_back(mid_point); } inline void finish_piece(piece& pc, @@ -1303,24 +1059,10 @@ struct buffered_piece_collection { init_rescale_piece(pc, 4u); add_helper_point(pc, point1); - robust_point_type mid_point2 = add_helper_point(pc, point2); - robust_point_type mid_point1 = add_helper_point(pc, point3); + add_helper_point(pc, point2); + add_helper_point(pc, point3); add_helper_point(pc, point4); - sectionalize(pc); calculate_robust_envelope(pc); - - // Add mid-points in other order to current helper_ring - current_robust_ring.push_back(mid_point1); - current_robust_ring.push_back(mid_point2); - } - - inline void add_piece(strategy::buffer::piece_type type, point_type const& p, - point_type const& b1, point_type const& b2) - { - piece& pc = create_piece(type, false); - add_point(b1); - pc.last_segment_index = add_point(b2); - finish_piece(pc, b2, p, b1); } template @@ -1344,6 +1086,14 @@ struct buffered_piece_collection } } + inline void add_piece(strategy::buffer::piece_type type, point_type const& p, + point_type const& b1, point_type const& b2) + { + piece& pc = create_piece(type, false); + add_point(b1); + pc.last_segment_index = add_point(b2); + finish_piece(pc, b2, p, b1); + } template inline void add_piece(strategy::buffer::piece_type type, Range const& range, @@ -1358,17 +1108,6 @@ struct buffered_piece_collection finish_piece(pc); } - template - inline void add_side_piece(point_type const& p1, point_type const& p2, - Range const& range, bool first) - { - BOOST_GEOMETRY_ASSERT(boost::size(range) >= 2u); - - piece& pc = create_piece(strategy::buffer::buffered_segment, ! first); - add_range_to_piece(pc, range, first); - finish_piece(pc, range.back(), p2, p1, range.front()); - } - template inline void add_piece(strategy::buffer::piece_type type, point_type const& p, Range const& range) @@ -1386,6 +1125,17 @@ struct buffered_piece_collection } } + template + inline void add_side_piece(point_type const& p1, point_type const& p2, + Range const& range, bool first) + { + BOOST_GEOMETRY_ASSERT(boost::size(range) >= 2u); + + piece& pc = create_piece(strategy::buffer::buffered_segment, ! first); + add_range_to_piece(pc, range, first); + finish_piece(pc, range.back(), p2, p1, range.front()); + } + template inline void add_endcap(EndcapStrategy const& strategy, Range const& range, point_type const& end_point) @@ -1470,12 +1220,16 @@ struct buffered_piece_collection // any of the robust original rings // This can go quadratic if the input has many rings, and there // are many untouched deflated rings around - for (typename std::vector::const_iterator it - = robust_originals.begin(); - it != robust_originals.end(); + for (typename std::vector::const_iterator it + = original_rings.begin(); + it != original_rings.end(); ++it) { - robust_original const& original = *it; + original_ring const& original = *it; + if (original.m_ring.empty()) + { + continue; + } if (detail::disjoint::disjoint_point_box(any_point, original.m_box, d_pb_strategy_type())) @@ -1536,15 +1290,6 @@ struct buffered_piece_collection inline void block_turns() { - // To fix left-turn issues like #rt_u13 - // But currently it causes more other issues than it fixes -// m_turns.erase -// ( -// std::remove_if(boost::begin(m_turns), boost::end(m_turns), -// redundant_turn()), -// boost::end(m_turns) -// ); - for (typename boost::range_iterator::type it = boost::begin(m_turns); it != boost::end(m_turns); ++it) { diff --git a/include/boost/geometry/algorithms/detail/buffer/turn_in_original_visitor.hpp b/include/boost/geometry/algorithms/detail/buffer/turn_in_original_visitor.hpp index 6b7635ec4..7bdd21255 100644 --- a/include/boost/geometry/algorithms/detail/buffer/turn_in_original_visitor.hpp +++ b/include/boost/geometry/algorithms/detail/buffer/turn_in_original_visitor.hpp @@ -212,9 +212,13 @@ public: {} template - inline bool apply(Turn const& turn, Original const& original, bool first = true) + inline bool apply(Turn const& turn, Original const& original) { - boost::ignore_unused(first); + if (boost::empty(original.m_ring)) + { + // Skip empty rings + return true; + } if (turn.location != location_ok || turn.within_original) { diff --git a/include/boost/geometry/algorithms/detail/buffer/turn_in_piece_visitor.hpp b/include/boost/geometry/algorithms/detail/buffer/turn_in_piece_visitor.hpp index 73b3fdf5f..e8d1bb650 100644 --- a/include/boost/geometry/algorithms/detail/buffer/turn_in_piece_visitor.hpp +++ b/include/boost/geometry/algorithms/detail/buffer/turn_in_piece_visitor.hpp @@ -935,12 +935,8 @@ public: switch(analyse_code) { case analyse_disjoint : - return true; case analyse_on_offsetted : - mutable_turn.count_on_offsetted++; // value is not used anymore - return true; case analyse_on_original_boundary : - mutable_turn.count_on_original_boundary++; return true; case analyse_within : mutable_turn.count_within++; diff --git a/include/boost/geometry/algorithms/detail/covered_by/interface.hpp b/include/boost/geometry/algorithms/detail/covered_by/interface.hpp index bdc92db43..4749ed168 100644 --- a/include/boost/geometry/algorithms/detail/covered_by/interface.hpp +++ b/include/boost/geometry/algorithms/detail/covered_by/interface.hpp @@ -217,7 +217,11 @@ struct covered_by< \note The default strategy is used for covered_by detection \qbk{[include reference/algorithms/covered_by.qbk]} - +\qbk{ +[heading Examples] +[covered_by] +[covered_by_output] +} */ template inline bool covered_by(Geometry1 const& geometry1, Geometry2 const& geometry2) diff --git a/include/boost/geometry/algorithms/detail/disjoint/interface.hpp b/include/boost/geometry/algorithms/detail/disjoint/interface.hpp index 64898e35f..fc4aecbb0 100644 --- a/include/boost/geometry/algorithms/detail/disjoint/interface.hpp +++ b/include/boost/geometry/algorithms/detail/disjoint/interface.hpp @@ -228,6 +228,11 @@ inline bool disjoint(Geometry1 const& geometry1, \return \return_check2{are disjoint} \qbk{[include reference/algorithms/disjoint.qbk]} +\qbk{ +[heading Examples] +[disjoint] +[disjoint_output] +} */ template inline bool disjoint(Geometry1 const& geometry1, diff --git a/include/boost/geometry/algorithms/detail/get_left_turns.hpp b/include/boost/geometry/algorithms/detail/get_left_turns.hpp deleted file mode 100644 index 2e0275a9b..000000000 --- a/include/boost/geometry/algorithms/detail/get_left_turns.hpp +++ /dev/null @@ -1,315 +0,0 @@ -// Boost.Geometry (aka GGL, Generic Geometry Library) - -// Copyright (c) 2012-2014 Barend Gehrels, Amsterdam, the Netherlands. - -// This file was modified by Oracle on 2017, 2018. -// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates. - -// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle - -// Use, modification and distribution is subject to the Boost Software License, -// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_GET_LEFT_TURNS_HPP -#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_GET_LEFT_TURNS_HPP - -#include -#include - -#include - -#include -#include -#include -#include -#include -#include - -namespace boost { namespace geometry -{ - - -#ifndef DOXYGEN_NO_DETAIL -namespace detail -{ - -// TODO: move this to /util/ -template -inline std::pair ordered_pair(T const& first, T const& second) -{ - return first < second ? std::make_pair(first, second) : std::make_pair(second, first); -} - -namespace left_turns -{ - - - -template -inline int get_quadrant(Vector const& vector) -{ - // Return quadrant as layouted in the code below: - // 3 | 0 - // ----- - // 2 | 1 - return geometry::get<1>(vector) >= 0 - ? (geometry::get<0>(vector) < 0 ? 3 : 0) - : (geometry::get<0>(vector) < 0 ? 2 : 1) - ; -} - -template -inline int squared_length(Vector const& vector) -{ - return geometry::get<0>(vector) * geometry::get<0>(vector) - + geometry::get<1>(vector) * geometry::get<1>(vector) - ; -} - - -template -struct angle_less -{ - typedef Point vector_type; - - angle_less(Point const& origin, SideStrategy const& strategy) - : m_origin(origin) - , m_strategy(strategy) - {} - - template - inline bool operator()(Angle const& p, Angle const& q) const - { - // Vector origin -> p and origin -> q - vector_type pv = p.point; - vector_type qv = q.point; - geometry::subtract_point(pv, m_origin); - geometry::subtract_point(qv, m_origin); - - int const quadrant_p = get_quadrant(pv); - int const quadrant_q = get_quadrant(qv); - if (quadrant_p != quadrant_q) - { - return quadrant_p < quadrant_q; - } - // Same quadrant, check if p is located left of q - int const side = m_strategy.apply(m_origin, q.point, p.point); - if (side != 0) - { - return side == 1; - } - // Collinear, check if one is incoming, incoming angles come first - if (p.incoming != q.incoming) - { - return int(p.incoming) < int(q.incoming); - } - // Same quadrant/side/direction, return longest first - // TODO: maybe not necessary, decide this - int const length_p = squared_length(pv); - int const length_q = squared_length(qv); - if (length_p != length_q) - { - return squared_length(pv) > squared_length(qv); - } - // They are still the same. Just compare on seg_id - return p.seg_id < q.seg_id; - } - -private: - Point m_origin; - SideStrategy m_strategy; -}; - -template -struct angle_equal_to -{ - typedef Point vector_type; - - inline angle_equal_to(Point const& origin, SideStrategy const& strategy) - : m_origin(origin) - , m_strategy(strategy) - {} - - template - inline bool operator()(Angle const& p, Angle const& q) const - { - // Vector origin -> p and origin -> q - vector_type pv = p.point; - vector_type qv = q.point; - geometry::subtract_point(pv, m_origin); - geometry::subtract_point(qv, m_origin); - - if (get_quadrant(pv) != get_quadrant(qv)) - { - return false; - } - // Same quadrant, check if p/q are collinear - int const side = m_strategy.apply(m_origin, q.point, p.point); - return side == 0; - } - -private: - Point m_origin; - SideStrategy m_strategy; -}; - -template -inline void get_left_turns(AngleCollection const& sorted_angles, - Turns& turns) -{ - std::set good_incoming; - std::set good_outgoing; - - for (typename boost::range_iterator::type it = - sorted_angles.begin(); it != sorted_angles.end(); ++it) - { - if (!it->blocked) - { - if (it->incoming) - { - good_incoming.insert(it->turn_index); - } - else - { - good_outgoing.insert(it->turn_index); - } - } - } - - if (good_incoming.empty() || good_outgoing.empty()) - { - return; - } - - for (typename boost::range_iterator::type it = - sorted_angles.begin(); it != sorted_angles.end(); ++it) - { - if (good_incoming.count(it->turn_index) == 0 - || good_outgoing.count(it->turn_index) == 0) - { - turns[it->turn_index].remove_on_multi = true; - } - } -} - - -//! Returns the number of clusters -template -inline std::size_t assign_cluster_indices(AngleCollection& sorted, Point const& origin, - SideStrategy const& strategy) -{ - // Assign same cluster_index for all turns in same direction - BOOST_GEOMETRY_ASSERT(boost::size(sorted) >= 4u); - - angle_equal_to comparator(origin, strategy); - typename boost::range_iterator::type it = sorted.begin(); - - std::size_t cluster_index = 0; - it->cluster_index = cluster_index; - typename boost::range_iterator::type previous = it++; - for (; it != sorted.end(); ++it) - { - if (!comparator(*previous, *it)) - { - cluster_index++; - previous = it; - } - it->cluster_index = cluster_index; - } - return cluster_index + 1; -} - -template -inline void block_turns(AngleCollection& sorted, std::size_t cluster_size) -{ - BOOST_GEOMETRY_ASSERT(boost::size(sorted) >= 4u && cluster_size > 0); - - std::vector > directions; - for (std::size_t i = 0; i < cluster_size; i++) - { - directions.push_back(std::make_pair(false, false)); - } - - for (typename boost::range_iterator::type it = sorted.begin(); - it != sorted.end(); ++it) - { - if (it->incoming) - { - directions[it->cluster_index].first = true; - } - else - { - directions[it->cluster_index].second = true; - } - } - - for (typename boost::range_iterator::type it = sorted.begin(); - it != sorted.end(); ++it) - { - std::size_t const cluster_index = it->cluster_index; - std::size_t const previous_index - = cluster_index == 0 ? cluster_size - 1 : cluster_index - 1; - std::size_t const next_index - = cluster_index + 1 >= cluster_size ? 0 : cluster_index + 1; - - if (directions[cluster_index].first - && directions[cluster_index].second) - { - it->blocked = true; - } - else if (!directions[cluster_index].first - && directions[cluster_index].second - && directions[previous_index].second) - { - // Only outgoing, previous was also outgoing: block this one - it->blocked = true; - } - else if (directions[cluster_index].first - && !directions[cluster_index].second - && !directions[previous_index].first - && directions[previous_index].second) - { - // Only incoming, previous was only outgoing: block this one - it->blocked = true; - } - else if (directions[cluster_index].first - && !directions[cluster_index].second - && directions[next_index].first - && !directions[next_index].second) - { - // Only incoming, next also incoming, block this one - it->blocked = true; - } - } -} - -#if defined(BOOST_GEOMETRY_BUFFER_ENLARGED_CLUSTERS) -template -inline bool has_rounding_issues(AngleCollection const& angles, Point const& origin) -{ - for (typename boost::range_iterator::type it = - angles.begin(); it != angles.end(); ++it) - { - // Vector origin -> p and origin -> q - typedef Point vector_type; - vector_type v = it->point; - geometry::subtract_point(v, origin); - return geometry::math::abs(geometry::get<0>(v)) <= 1 - || geometry::math::abs(geometry::get<1>(v)) <= 1 - ; - } - return false; -} -#endif - - -} // namespace left_turns - -} // namespace detail -#endif // DOXYGEN_NO_DETAIL - - -}} // namespace boost::geometry - -#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_GET_LEFT_TURNS_HPP diff --git a/include/boost/geometry/algorithms/detail/occupation_info.hpp b/include/boost/geometry/algorithms/detail/occupation_info.hpp deleted file mode 100644 index fc74f0cc7..000000000 --- a/include/boost/geometry/algorithms/detail/occupation_info.hpp +++ /dev/null @@ -1,219 +0,0 @@ -// Boost.Geometry (aka GGL, Generic Geometry Library) - -// Copyright (c) 2012-2014 Barend Gehrels, Amsterdam, the Netherlands. - -// This file was modified by Oracle on 2017. -// Modifications copyright (c) 2017, Oracle and/or its affiliates. - -// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle - -// Use, modification and distribution is subject to the Boost Software License, -// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_OCCUPATION_INFO_HPP -#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OCCUPATION_INFO_HPP - -#include -#include - -#include -#include -#include - -#include -#include - -#include - - -namespace boost { namespace geometry -{ - - -#ifndef DOXYGEN_NO_DETAIL -namespace detail -{ - -template -struct angle_info -{ - typedef T angle_type; - typedef Point point_type; - - segment_identifier seg_id; - std::size_t turn_index; - int operation_index; - std::size_t cluster_index; - Point intersection_point; - Point point; // either incoming or outgoing point - bool incoming; - bool blocked; - bool included; - - inline angle_info() - : blocked(false) - , included(false) - {} -}; - -template -class occupation_info -{ -public : - typedef std::vector collection_type; - - std::size_t count; - - inline occupation_info() - : count(0) - {} - - template - inline void add(RobustPoint const& incoming_point, - RobustPoint const& outgoing_point, - RobustPoint const& intersection_point, - std::size_t turn_index, int operation_index, - segment_identifier const& seg_id) - { - geometry::equal_to comparator; - if (comparator(incoming_point, intersection_point)) - { - return; - } - if (comparator(outgoing_point, intersection_point)) - { - return; - } - - AngleInfo info; - info.seg_id = seg_id; - info.turn_index = turn_index; - info.operation_index = operation_index; - info.intersection_point = intersection_point; - - { - info.point = incoming_point; - info.incoming = true; - m_angles.push_back(info); - } - { - info.point = outgoing_point; - info.incoming = false; - m_angles.push_back(info); - } - } - - template - inline void get_left_turns(RobustPoint const& origin, Turns& turns, - SideStrategy const& strategy) - { - typedef detail::left_turns::angle_less - < - typename AngleInfo::point_type, - SideStrategy - > angle_less; - - // Sort on angle - std::sort(m_angles.begin(), m_angles.end(), angle_less(origin, strategy)); - - // Group same-angled elements - std::size_t cluster_size = detail::left_turns::assign_cluster_indices(m_angles, origin); - // Block all turns on the right side of any turn - detail::left_turns::block_turns(m_angles, cluster_size); - detail::left_turns::get_left_turns(m_angles, turns); - } - -#if defined(BOOST_GEOMETRY_BUFFER_ENLARGED_CLUSTERS) - template - inline bool has_rounding_issues(RobustPoint const& origin) const - { - return detail::left_turns::has_rounding_issues(angles, origin); - } -#endif - -private : - collection_type m_angles; // each turn splitted in incoming/outgoing vectors -}; - -template -inline void move_index(Pieces const& pieces, signed_size_type& index, signed_size_type& piece_index, int direction) -{ - BOOST_GEOMETRY_ASSERT(direction == 1 || direction == -1); - BOOST_GEOMETRY_ASSERT( - piece_index >= 0 - && piece_index < static_cast(boost::size(pieces)) ); - BOOST_GEOMETRY_ASSERT( - index >= 0 - && index < static_cast(boost::size(pieces[piece_index].robust_ring))); - - // NOTE: both index and piece_index must be in valid range - // this means that then they could be of type std::size_t - // if the code below was refactored - - index += direction; - if (direction == -1 && index < 0) - { - piece_index--; - if (piece_index < 0) - { - piece_index = boost::size(pieces) - 1; - } - index = boost::size(pieces[piece_index].robust_ring) - 1; - } - if (direction == 1 - && index >= static_cast(boost::size(pieces[piece_index].robust_ring))) - { - piece_index++; - if (piece_index >= static_cast(boost::size(pieces))) - { - piece_index = 0; - } - index = 0; - } -} - - -template -< - typename RobustPoint, - typename Turn, - typename Pieces, - typename Info -> -inline void add_incoming_and_outgoing_angles( - RobustPoint const& intersection_point, // rescaled - Turn const& turn, - Pieces const& pieces, // using rescaled offsets of it - int operation_index, - segment_identifier seg_id, - Info& info) -{ - segment_identifier real_seg_id = seg_id; - geometry::equal_to comparator; - - // Move backward and forward - RobustPoint direction_points[2]; - for (int i = 0; i < 2; i++) - { - signed_size_type index = turn.operations[operation_index].index_in_robust_ring; - signed_size_type piece_index = turn.operations[operation_index].piece_index; - while(comparator(pieces[piece_index].robust_ring[index], intersection_point)) - { - move_index(pieces, index, piece_index, i == 0 ? -1 : 1); - } - direction_points[i] = pieces[piece_index].robust_ring[index]; - } - - info.add(direction_points[0], direction_points[1], intersection_point, - turn.turn_index, operation_index, real_seg_id); -} - - -} // namespace detail -#endif // DOXYGEN_NO_DETAIL - - -}} // namespace boost::geometry - -#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_OCCUPATION_INFO_HPP diff --git a/include/boost/geometry/algorithms/detail/overlaps/interface.hpp b/include/boost/geometry/algorithms/detail/overlaps/interface.hpp index f9f6a853f..088b51fe2 100644 --- a/include/boost/geometry/algorithms/detail/overlaps/interface.hpp +++ b/include/boost/geometry/algorithms/detail/overlaps/interface.hpp @@ -99,6 +99,11 @@ inline bool overlaps(Geometry1 const& geometry1, \return \return_check2{overlap} \qbk{[include reference/algorithms/overlaps.qbk]} +\qbk{ +[heading Examples] +[overlaps] +[overlaps_output] +} */ template inline bool overlaps(Geometry1 const& geometry1, Geometry2 const& geometry2) diff --git a/include/boost/geometry/algorithms/detail/overlay/check_enrich.hpp b/include/boost/geometry/algorithms/detail/overlay/check_enrich.hpp index e07e056c3..843e120a1 100644 --- a/include/boost/geometry/algorithms/detail/overlay/check_enrich.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/check_enrich.hpp @@ -26,7 +26,6 @@ #include #include -#include namespace boost { namespace geometry diff --git a/include/boost/geometry/algorithms/detail/overlay/convert_ring.hpp b/include/boost/geometry/algorithms/detail/overlay/convert_ring.hpp index e2b3cfe06..9aade10bb 100644 --- a/include/boost/geometry/algorithms/detail/overlay/convert_ring.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/convert_ring.hpp @@ -18,7 +18,6 @@ #include #include -#include #include #include diff --git a/include/boost/geometry/algorithms/detail/overlay/get_distance_measure.hpp b/include/boost/geometry/algorithms/detail/overlay/get_distance_measure.hpp index c6565f9fd..96adc9049 100644 --- a/include/boost/geometry/algorithms/detail/overlay/get_distance_measure.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/get_distance_measure.hpp @@ -14,6 +14,7 @@ #include #include #include +#include #include #include diff --git a/include/boost/geometry/algorithms/detail/overlay/handle_colocations.hpp b/include/boost/geometry/algorithms/detail/overlay/handle_colocations.hpp index d948f9f27..951e91706 100644 --- a/include/boost/geometry/algorithms/detail/overlay/handle_colocations.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/handle_colocations.hpp @@ -31,7 +31,6 @@ #include #include #include -#include #include #include diff --git a/include/boost/geometry/algorithms/detail/overlay/overlay.hpp b/include/boost/geometry/algorithms/detail/overlay/overlay.hpp index ab2d1c406..479d7a405 100644 --- a/include/boost/geometry/algorithms/detail/overlay/overlay.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/overlay.hpp @@ -137,12 +137,7 @@ inline void get_ring_turn_info(TurnInfoMap& turn_info_map, Turns const& turns, C ++op_it) { turn_operation_type const& op = *op_it; - ring_identifier const ring_id - ( - op.seg_id.source_index, - op.seg_id.multi_index, - op.seg_id.ring_index - ); + ring_identifier const ring_id = ring_id_by_seg_id(op.seg_id); if (! is_self_turn(turn) && ( diff --git a/include/boost/geometry/algorithms/detail/overlay/segment_identifier.hpp b/include/boost/geometry/algorithms/detail/overlay/segment_identifier.hpp index 14e84c949..b2d6d7f34 100644 --- a/include/boost/geometry/algorithms/detail/overlay/segment_identifier.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/segment_identifier.hpp @@ -20,6 +20,7 @@ #include +#include namespace boost { namespace geometry @@ -95,7 +96,18 @@ struct segment_identifier signed_size_type piece_index; }; +#ifndef DOXYGEN_NO_DETAIL +namespace detail { namespace overlay +{ +// Create a ring identifier from a segment identifier +inline ring_identifier ring_id_by_seg_id(segment_identifier const& seg_id) +{ + return ring_identifier(seg_id.source_index, seg_id.multi_index, seg_id.ring_index); +} + +}} // namespace detail::overlay +#endif // DOXYGEN_NO_DETAIL }} // namespace boost::geometry diff --git a/include/boost/geometry/algorithms/detail/overlay/traversal.hpp b/include/boost/geometry/algorithms/detail/overlay/traversal.hpp index 0edacad0a..e0e1ee28d 100644 --- a/include/boost/geometry/algorithms/detail/overlay/traversal.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/traversal.hpp @@ -148,12 +148,7 @@ public : || op.visited.started() || op.visited.finished() ) { - ring_identifier const ring_id - ( - op.seg_id.source_index, - op.seg_id.multi_index, - op.seg_id.ring_index - ); + ring_identifier const ring_id = ring_id_by_seg_id(op.seg_id); turn_info_map[ring_id].has_traversed_turn = true; if (op.operation == operation_continue) @@ -162,11 +157,7 @@ public : // as traversed too turn_operation_type& other_op = turn.operations[1 - i]; ring_identifier const other_ring_id - ( - other_op.seg_id.source_index, - other_op.seg_id.multi_index, - other_op.seg_id.ring_index - ); + = ring_id_by_seg_id(other_op.seg_id); turn_info_map[other_ring_id].has_traversed_turn = true; } } diff --git a/include/boost/geometry/algorithms/detail/overlay/traversal_switch_detector.hpp b/include/boost/geometry/algorithms/detail/overlay/traversal_switch_detector.hpp index 273253132..d8053deb7 100644 --- a/include/boost/geometry/algorithms/detail/overlay/traversal_switch_detector.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/traversal_switch_detector.hpp @@ -35,12 +35,6 @@ namespace boost { namespace geometry namespace detail { namespace overlay { -// Generic function (is this used somewhere else too?) -inline ring_identifier ring_id_by_seg_id(segment_identifier const& seg_id) -{ - return ring_identifier(seg_id.source_index, seg_id.multi_index, seg_id.ring_index); -} - template < bool Reverse1, diff --git a/include/boost/geometry/algorithms/detail/touches/interface.hpp b/include/boost/geometry/algorithms/detail/touches/interface.hpp index d2e0cc8c4..9f41b3608 100644 --- a/include/boost/geometry/algorithms/detail/touches/interface.hpp +++ b/include/boost/geometry/algorithms/detail/touches/interface.hpp @@ -261,6 +261,11 @@ struct self_touches > \qbk{distinguish,one geometry} \qbk{[def __one_parameter__]} \qbk{[include reference/algorithms/touches.qbk]} +\qbk{ +[heading Examples] +[touches_one_geometry] +[touches_one_geometry_output] +} */ template inline bool touches(Geometry const& geometry) @@ -280,6 +285,11 @@ inline bool touches(Geometry const& geometry) \qbk{distinguish,two geometries} \qbk{[include reference/algorithms/touches.qbk]} +\qbk{ +[heading Examples] +[touches_two_geometries] +[touches_two_geometries_output] +} */ template inline bool touches(Geometry1 const& geometry1, Geometry2 const& geometry2) diff --git a/include/boost/geometry/algorithms/detail/within/implementation.hpp b/include/boost/geometry/algorithms/detail/within/implementation.hpp index 163092b2c..9544e9d6b 100644 --- a/include/boost/geometry/algorithms/detail/within/implementation.hpp +++ b/include/boost/geometry/algorithms/detail/within/implementation.hpp @@ -38,8 +38,6 @@ #include #include -#include -#include #include #include diff --git a/include/boost/geometry/algorithms/perimeter.hpp b/include/boost/geometry/algorithms/perimeter.hpp index 47b064972..f8fbb03a1 100644 --- a/include/boost/geometry/algorithms/perimeter.hpp +++ b/include/boost/geometry/algorithms/perimeter.hpp @@ -192,6 +192,11 @@ struct perimeter > \return \return_calc{perimeter} \qbk{[include reference/algorithms/perimeter.qbk]} +\qbk{ +[heading Example] +[perimeter] +[perimeter_output] +} */ template inline typename default_length_result::type perimeter( diff --git a/include/boost/geometry/arithmetic/cross_product.hpp b/include/boost/geometry/arithmetic/cross_product.hpp index 485c2123b..1df1147ef 100644 --- a/include/boost/geometry/arithmetic/cross_product.hpp +++ b/include/boost/geometry/arithmetic/cross_product.hpp @@ -90,7 +90,8 @@ struct cross_product<3> \param p1 first vector \param p2 second vector \return the cross product vector - */ + +*/ template inline ResultP cross_product(P1 const& p1, P2 const& p2) { @@ -110,6 +111,9 @@ inline ResultP cross_product(P1 const& p1, P2 const& p2) \param p1 first vector \param p2 second vector \return the cross product vector + +\qbk{[heading Examples]} +\qbk{[cross_product] [cross_product_output]} */ template inline P cross_product(P const& p1, P const& p2) diff --git a/include/boost/geometry/arithmetic/dot_product.hpp b/include/boost/geometry/arithmetic/dot_product.hpp index 747bd01ab..69214980d 100644 --- a/include/boost/geometry/arithmetic/dot_product.hpp +++ b/include/boost/geometry/arithmetic/dot_product.hpp @@ -64,6 +64,10 @@ struct dot_product_maker \param p1 first point \param p2 second point \return the dot product + + \qbk{[heading Examples]} + \qbk{[dot_product] [dot_product_output]} + */ template inline typename select_coordinate_type::type dot_product( diff --git a/include/boost/geometry/formulas/andoyer_inverse.hpp b/include/boost/geometry/formulas/andoyer_inverse.hpp index 7513e3b70..98f5dcd79 100644 --- a/include/boost/geometry/formulas/andoyer_inverse.hpp +++ b/include/boost/geometry/formulas/andoyer_inverse.hpp @@ -2,7 +2,7 @@ // Copyright (c) 2018 Adam Wulkiewicz, Lodz, Poland. -// Copyright (c) 2015-2017 Oracle and/or its affiliates. +// Copyright (c) 2015-2020 Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle @@ -106,7 +106,8 @@ public: CT const one_minus_cos_d = c1 - cos_d; CT const one_plus_cos_d = c1 + cos_d; - // cos_d = 1 or cos_d = -1 means that the points are antipodal + // cos_d = 1 means that the points are very close + // cos_d = -1 means that the points are antipodal CT const H = math::equals(one_minus_cos_d, c0) ? c0 : @@ -124,7 +125,7 @@ public: if ( BOOST_GEOMETRY_CONDITION(CalcAzimuths) ) { - // sin_d = 0 <=> antipodal points (incl. poles) + // sin_d = 0 <=> antipodal points (incl. poles) or very close if (math::equals(sin_d, c0)) { // T = inf @@ -140,16 +141,26 @@ public: // The most correct way of fixing it is to handle antipodal regions // correctly and consistently across all formulas. - // Set azimuth to 0 unless the first endpoint is the north pole - if (! math::equals(sin_lat1, c1)) + // points very close + if (cos_d >= c0) { result.azimuth = c0; - result.reverse_azimuth = pi; + result.reverse_azimuth = c0; } + // antipodal points else { - result.azimuth = pi; - result.reverse_azimuth = 0; + // Set azimuth to 0 unless the first endpoint is the north pole + if (! math::equals(sin_lat1, c1)) + { + result.azimuth = c0; + result.reverse_azimuth = pi; + } + else + { + result.azimuth = pi; + result.reverse_azimuth = c0; + } } } else diff --git a/include/boost/geometry/formulas/karney_inverse.hpp b/include/boost/geometry/formulas/karney_inverse.hpp index 2cd6b64ed..f3a72fa23 100644 --- a/include/boost/geometry/formulas/karney_inverse.hpp +++ b/include/boost/geometry/formulas/karney_inverse.hpp @@ -97,24 +97,6 @@ class karney_inverse public: typedef result_inverse result_type; - static CT constexpr c0 = 0; - static CT constexpr c0_001 = 0.001; - static CT constexpr c0_01 = 0.01; - static CT constexpr c0_1 = 0.1; - static CT constexpr c0_5 = 0.5; - static CT constexpr c1 = 1; - static CT constexpr c2 = 2; - static CT constexpr c3 = 3; - static CT constexpr c4 = 4; - static CT constexpr c6 = 6; - static CT constexpr c8 = 8; - static CT constexpr c10 = 10; - static CT constexpr c16 = 16; - static CT constexpr c20 = 20; - static CT constexpr c90 = 90; - static CT constexpr c180 = 180; - static CT constexpr c200 = 200; - static CT constexpr c1000 = 1000; template static inline result_type apply(T1 const& lo1, @@ -123,6 +105,21 @@ public: T2 const& la2, Spheroid const& spheroid) { + static CT const c0 = 0; + static CT const c0_001 = 0.001; + static CT const c0_1 = 0.1; + static CT const c1 = 1; + static CT const c2 = 2; + static CT const c3 = 3; + static CT const c8 = 8; + static CT const c16 = 16; + static CT const c90 = 90; + static CT const c180 = 180; + static CT const c200 = 200; + static CT const pi = math::pi(); + static CT const d2r = math::d2r(); + static CT const r2d = math::r2d(); + result_type result; CT lat1 = la1; @@ -145,7 +142,7 @@ public: CT const tol_bisection = tol0 * tol2; CT const etol2 = c0_1 * tol2 / - sqrt((std::max)(CT(0.001), std::abs(f)) * (std::min)(CT(1), CT(1) - f / CT(2)) / c2); + sqrt((std::max)(c0_001, std::abs(f)) * (std::min)(c1, c1 - f / c2) / c2); CT tiny = std::sqrt((std::numeric_limits::min)()); @@ -164,7 +161,7 @@ public: lon12_error = (c180 - lon12) - lon12_sign * lon12_error; // Convert to radians. - CT lam12 = lon12 * math::d2r(); + CT lam12 = lon12 * d2r; CT sin_lam12; CT cos_lam12; @@ -268,8 +265,8 @@ public: CT sin_sigma2 = sin_beta2; CT cos_sigma2 = cos_alpha2 * cos_beta2; - CT sigma12 = std::atan2((std::max)(CT(0), cos_sigma1 * sin_sigma2 - sin_sigma1 * cos_sigma2), - cos_sigma1 * cos_sigma2 + sin_sigma1 * sin_sigma2); + CT sigma12 = std::atan2((std::max)(c0, cos_sigma1 * sin_sigma2 - sin_sigma1 * cos_sigma2), + cos_sigma1 * cos_sigma2 + sin_sigma1 * sin_sigma2); CT dummy; meridian_length(n, ep2, sigma12, sin_sigma1, cos_sigma1, dn1, @@ -401,7 +398,7 @@ public: CT nsin_alpha1 = sin_alpha1 * cos_diff_alpha1 + cos_alpha1 * sin_diff_alpha1; - if (nsin_alpha1 > c0 && std::abs(diff_alpha1) < math::pi()) + if (nsin_alpha1 > c0 && std::abs(diff_alpha1) < pi) { cos_alpha1 = cos_alpha1 * cos_diff_alpha1 - sin_alpha1 * sin_diff_alpha1; sin_alpha1 = nsin_alpha1; @@ -468,12 +465,12 @@ public: { if (BOOST_GEOMETRY_CONDITION(CalcFwdAzimuth)) { - result.azimuth = atan2(sin_alpha1, cos_alpha1) * math::r2d(); + result.azimuth = atan2(sin_alpha1, cos_alpha1) * r2d; } if (BOOST_GEOMETRY_CONDITION(CalcRevAzimuth)) { - result.reverse_azimuth = atan2(sin_alpha2, cos_alpha2) * math::r2d(); + result.reverse_azimuth = atan2(sin_alpha2, cos_alpha2) * r2d; } } @@ -486,14 +483,16 @@ public: } template - static inline void meridian_length(CT epsilon, CT ep2, CT sigma12, - CT sin_sigma1, CT cos_sigma1, CT dn1, - CT sin_sigma2, CT cos_sigma2, CT dn2, - CT cos_beta1, CT cos_beta2, + static inline void meridian_length(CT const& epsilon, CT const& ep2, CT const& sigma12, + CT const& sin_sigma1, CT const& cos_sigma1, CT const& dn1, + CT const& sin_sigma2, CT const& cos_sigma2, CT const& dn2, + CT const& cos_beta1, CT const& cos_beta2, CT& s12x, CT& m12x, CT& m0, CT& M12, CT& M21, - CoeffsC1 coeffs_C1) + CoeffsC1 const& coeffs_C1) { + static CT const c1 = 1; + CT A12x = 0, J12 = 0; CT expansion_A1, expansion_A2; @@ -578,14 +577,24 @@ public: cos_alpha2 and function value is sig12. */ template - static inline CT newton_start(CT sin_beta1, CT cos_beta1, CT dn1, - CT sin_beta2, CT cos_beta2, CT dn2, - CT lam12, CT sin_lam12, CT cos_lam12, + static inline CT newton_start(CT const& sin_beta1, CT const& cos_beta1, CT const& dn1, + CT const& sin_beta2, CT const& cos_beta2, CT dn2, + CT const& lam12, CT const& sin_lam12, CT const& cos_lam12, CT& sin_alpha1, CT& cos_alpha1, CT& sin_alpha2, CT& cos_alpha2, - CT& dnm, CoeffsC1 coeffs_C1, CT ep2, - CT tol1, CT tol2, CT etol2, CT n, CT f) + CT& dnm, CoeffsC1 const& coeffs_C1, CT const& ep2, + CT const& tol1, CT const& tol2, CT const& etol2, CT const& n, CT const& f) { + static CT const c0 = 0; + static CT const c0_01 = 0.01; + static CT const c0_1 = 0.1; + static CT const c0_5 = 0.5; + static CT const c1 = 1; + static CT const c2 = 2; + static CT const c6 = 6; + static CT const c1000 = 1000; + static CT const pi = math::pi(); + CT const one_minus_f = c1 - f; CT const x_thresh = c1000 * tol2; @@ -646,7 +655,7 @@ public: // Skip astroid calculation if too eccentric. else if (std::abs(n) > c0_1 || cos_sigma12 >= c0 || - sin_sigma12 >= c6 * std::abs(n) * math::pi() * + sin_sigma12 >= c6 * std::abs(n) * pi * math::sqr(cos_beta1)) { // Nothing to do, zeroth order spherical approximation will do. @@ -670,7 +679,7 @@ public: CT const A3 = math::horner_evaluate(eps, coeffs_A3.begin(), coeffs_A3.end()); - lambda_scale = f * cos_beta1 * A3 * math::pi(); + lambda_scale = f * cos_beta1 * A3 * pi; beta_scale = lambda_scale * cos_beta1; x = lam12x / lambda_scale; @@ -682,15 +691,16 @@ public: CT beta12a = atan2(sin_beta12a, cos_beta12a); CT m12b, m0, dummy; - meridian_length(n, ep2, math::pi() + beta12a, + meridian_length(n, ep2, pi + beta12a, sin_beta1, -cos_beta1, dn1, sin_beta2, cos_beta2, dn2, cos_beta1, cos_beta2, dummy, m12b, m0, dummy, dummy, coeffs_C1); - x = -c1 + m12b / (cos_beta1 * cos_beta2 * m0 * math::pi()); - beta_scale = x < -c0_01 ? sin_beta12a / x : - -f * math::sqr(cos_beta1) * math::pi(); + x = -c1 + m12b / (cos_beta1 * cos_beta2 * m0 * pi); + beta_scale = x < -c0_01 + ? sin_beta12a / x + : -f * math::sqr(cos_beta1) * pi; lambda_scale = beta_scale / cos_beta1; y = lam12x / lambda_scale; @@ -701,7 +711,7 @@ public: // Strip near cut. if (f >= c0) { - sin_alpha1 = (std::min)(CT(1), -CT(x)); + sin_alpha1 = (std::min)(c1, -CT(x)); cos_alpha1 = - math::sqrt(c1 - math::sqr(sin_alpha1)); } else @@ -713,7 +723,7 @@ public: else { // Solve the astroid problem. - CT k = astroid(x, y); + CT k = astroid(CT(x), y); CT omega12a = lambda_scale * (f >= c0 ? -x * k / (c1 + k) : -y * (c1 + k) / k); @@ -750,8 +760,15 @@ public: Geodesics on an ellipsoid of revolution, Charles F.F Karney, https://arxiv.org/abs/1102.1215 */ - static inline CT astroid(CT x, CT y) + static inline CT astroid(CT const& x, CT const& y) { + static CT const c0 = 0; + static CT const c1 = 1; + static CT const c2 = 2; + static CT const c3 = 3; + static CT const c4 = 4; + static CT const c6 = 6; + CT k; CT p = math::sqr(x); @@ -815,19 +832,23 @@ public: } template - static inline CT lambda12(CT sin_beta1, CT cos_beta1, CT dn1, - CT sin_beta2, CT cos_beta2, CT dn2, - CT sin_alpha1, CT cos_alpha1, - CT sin_lam120, CT cos_lam120, + static inline CT lambda12(CT const& sin_beta1, CT const& cos_beta1, CT const& dn1, + CT const& sin_beta2, CT const& cos_beta2, CT const& dn2, + CT const& sin_alpha1, CT cos_alpha1, + CT const& sin_lam120, CT const& cos_lam120, CT& sin_alpha2, CT& cos_alpha2, CT& sigma12, CT& sin_sigma1, CT& cos_sigma1, CT& sin_sigma2, CT& cos_sigma2, CT& eps, CT& diff_omega12, bool diffp, CT& diff_lam12, - CT f, CT n, CT ep2, CT tiny, - CoeffsC1 coeffs_C1) + CT const& f, CT const& n, CT const& ep2, CT const& tiny, + CoeffsC1 const& coeffs_C1) { + static CT const c0 = 0; + static CT const c1 = 1; + static CT const c2 = 2; + CT const one_minus_f = c1 - f; if (sin_beta1 == c0 && cos_alpha1 == c0) @@ -878,11 +899,11 @@ public: // sig12 = sig2 - sig1, limit to [0, pi]. - sigma12 = atan2((std::max)(CT(0), cos_sigma1 * sin_sigma2 - sin_sigma1 * cos_sigma2), + sigma12 = atan2((std::max)(c0, cos_sigma1 * sin_sigma2 - sin_sigma1 * cos_sigma2), cos_sigma1 * cos_sigma2 + sin_sigma1 * sin_sigma2); // omg12 = omg2 - omg1, limit to [0, pi]. - sin_omega12 = (std::max)(CT(0), cos_omega1 * sin_omega2 - sin_omega1 * cos_omega2); + sin_omega12 = (std::max)(c0, cos_omega1 * sin_omega2 - sin_omega1 * cos_omega2); cos_omega12 = cos_omega1 * cos_omega2 + sin_omega1 * sin_omega2; // eta = omg12 - lam120. diff --git a/include/boost/geometry/geometries/point_xyz.hpp b/include/boost/geometry/geometries/point_xyz.hpp new file mode 100644 index 000000000..39e04f493 --- /dev/null +++ b/include/boost/geometry/geometries/point_xyz.hpp @@ -0,0 +1,137 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2020 Digvijay Janartha, Hamirpur, India. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_GEOMETRY_GEOMETRIES_POINT_XYZ_HPP +#define BOOST_GEOMETRY_GEOMETRIES_POINT_XYZ_HPP + +#include + +#include +#include + +#include +#include + +namespace boost { namespace geometry +{ + +namespace model { namespace d3 +{ + +/*! +\brief 3D point in Cartesian coordinate system +\tparam CoordinateType numeric type, for example, double, float, int +\tparam CoordinateSystem coordinate system, defaults to cs::cartesian + +\qbk{[include reference/geometries/point_xyz.qbk]} +\qbk{before.synopsis, +[heading Model of] +[link geometry.reference.concepts.concept_point Point Concept] +} + +\qbk{[include reference/geometries/point_assign_warning.qbk]} + +*/ +template +class point_xyz : public model::point +{ +public: + +#ifndef BOOST_NO_CXX11_DEFAULTED_FUNCTIONS + /// \constructor_default_no_init + point_xyz() = default; +#else + /// \constructor_default_no_init + inline point_xyz() + {} +#endif + + /// Constructor with x/y/z values + inline point_xyz(CoordinateType const& x, CoordinateType const& y, CoordinateType const& z) + : model::point(x, y, z) + {} + + /// Get x-value + inline CoordinateType const& x() const + { return this->template get<0>(); } + + /// Get y-value + inline CoordinateType const& y() const + { return this->template get<1>(); } + + /// Get z-value + inline CoordinateType const& z() const + { return this->template get<2>(); } + + /// Set x-value + inline void x(CoordinateType const& v) + { this->template set<0>(v); } + + /// Set y-value + inline void y(CoordinateType const& v) + { this->template set<1>(v); } + + /// Set z-value + inline void z(CoordinateType const& v) + { this->template set<2>(v); } +}; + + +}} // namespace model::d3 + + +// Adapt the point_xyz to the concept +#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS +namespace traits +{ + +template +struct tag > +{ + typedef point_tag type; +}; + +template +struct coordinate_type > +{ + typedef CoordinateType type; +}; + +template +struct coordinate_system > +{ + typedef CoordinateSystem type; +}; + +template +struct dimension > + : boost::mpl::int_<3> +{}; + +template +struct access, Dimension > +{ + static inline CoordinateType get( + model::d3::point_xyz const& p) + { + return p.template get(); + } + + static inline void set(model::d3::point_xyz& p, + CoordinateType const& value) + { + p.template set(value); + } +}; + +} // namespace traits +#endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS + +}} // namespace boost::geometry + +#endif // BOOST_GEOMETRY_GEOMETRIES_POINT_XYZ_HPP diff --git a/include/boost/geometry/index/detail/rtree/linear/redistribute_elements.hpp b/include/boost/geometry/index/detail/rtree/linear/redistribute_elements.hpp index a0635acab..88fb3358c 100644 --- a/include/boost/geometry/index/detail/rtree/linear/redistribute_elements.hpp +++ b/include/boost/geometry/index/detail/rtree/linear/redistribute_elements.hpp @@ -322,28 +322,31 @@ inline void pick_seeds(Elements const& elements, // from void split_node(node_pointer const& n, node_pointer& n1, node_pointer& n2) const -template -struct redistribute_elements +template +struct redistribute_elements { - typedef typename Options::parameters_type parameters_type; + typedef typename MembersHolder::box_type box_type; + typedef typename MembersHolder::parameters_type parameters_type; + typedef typename MembersHolder::translator_type translator_type; + typedef typename MembersHolder::allocators_type allocators_type; - typedef typename rtree::node::type node; - typedef typename rtree::internal_node::type internal_node; - typedef typename rtree::leaf::type leaf; + typedef typename MembersHolder::node node; + typedef typename MembersHolder::internal_node internal_node; + typedef typename MembersHolder::leaf leaf; template static inline void apply(Node & n, Node & second_node, - Box & box1, - Box & box2, + box_type & box1, + box_type & box2, parameters_type const& parameters, - Translator const& translator, - Allocators & allocators) + translator_type const& translator, + allocators_type & allocators) { typedef typename rtree::elements_type::type elements_type; typedef typename elements_type::value_type element_type; - typedef typename rtree::element_indexable_type::type indexable_type; - typedef typename index::detail::default_content_result::type content_type; + typedef typename rtree::element_indexable_type::type indexable_type; + typedef typename index::detail::default_content_result::type content_type; typename index::detail::strategy_type::type const& strategy = index::detail::get_strategy(parameters); @@ -414,8 +417,8 @@ struct redistribute_elements::apply(elements_copy, allocators); + rtree::destroy_elements::apply(elements_copy, allocators); //elements_copy.clear(); BOOST_RETHROW // RETHROW, BASIC diff --git a/include/boost/geometry/index/detail/rtree/node/node.hpp b/include/boost/geometry/index/detail/rtree/node/node.hpp index 51ba2c7e7..ad3e24c15 100644 --- a/include/boost/geometry/index/detail/rtree/node/node.hpp +++ b/include/boost/geometry/index/detail/rtree/node/node.hpp @@ -31,10 +31,9 @@ #include #include -#include - #include +#include #include #include @@ -102,41 +101,47 @@ inline Box values_box(FwdIter first, FwdIter last, Translator const& tr, } // destroys subtree if the element is internal node's element -template +template struct destroy_element { - typedef typename Options::parameters_type parameters_type; + typedef typename MembersHolder::parameters_type parameters_type; + typedef typename MembersHolder::allocators_type allocators_type; - typedef typename rtree::internal_node::type internal_node; - typedef typename rtree::leaf::type leaf; + typedef typename MembersHolder::internal_node internal_node; + typedef typename MembersHolder::leaf leaf; - typedef rtree::subtree_destroyer subtree_destroyer; - - inline static void apply(typename internal_node::elements_type::value_type & element, Allocators & allocators) + inline static void apply(typename internal_node::elements_type::value_type & element, + allocators_type & allocators) { - subtree_destroyer dummy(element.second, allocators); + detail::rtree::visitors::destroy::apply(element.second, allocators); + element.second = 0; } - inline static void apply(typename leaf::elements_type::value_type &, Allocators &) {} + inline static void apply(typename leaf::elements_type::value_type &, + allocators_type &) + {} }; // destroys stored subtrees if internal node's elements are passed -template +template struct destroy_elements { + typedef typename MembersHolder::value_type value_type; + typedef typename MembersHolder::allocators_type allocators_type; + template - inline static void apply(Range & elements, Allocators & allocators) + inline static void apply(Range & elements, allocators_type & allocators) { apply(boost::begin(elements), boost::end(elements), allocators); } template - inline static void apply(It first, It last, Allocators & allocators) + inline static void apply(It first, It last, allocators_type & allocators) { typedef boost::mpl::bool_< boost::is_same< - Value, typename std::iterator_traits::value_type + value_type, typename std::iterator_traits::value_type >::value > is_range_of_values; @@ -145,37 +150,38 @@ struct destroy_elements private: template - inline static void apply_dispatch(It first, It last, Allocators & allocators, + inline static void apply_dispatch(It first, It last, allocators_type & allocators, boost::mpl::bool_ const& /*is_range_of_values*/) { - typedef rtree::subtree_destroyer subtree_destroyer; - for ( ; first != last ; ++first ) { - subtree_destroyer dummy(first->second, allocators); + detail::rtree::visitors::destroy::apply(first->second, allocators); + first->second = 0; } } template - inline static void apply_dispatch(It /*first*/, It /*last*/, Allocators & /*allocators*/, + inline static void apply_dispatch(It /*first*/, It /*last*/, allocators_type & /*allocators*/, boost::mpl::bool_ const& /*is_range_of_values*/) {} }; // clears node, deletes all subtrees stored in node -template +/* +template struct clear_node { - typedef typename Options::parameters_type parameters_type; + typedef typename MembersHolder::parameters_type parameters_type; + typedef typename MembersHolder::allocators_type allocators_type; - typedef typename rtree::node::type node; - typedef typename rtree::internal_node::type internal_node; - typedef typename rtree::leaf::type leaf; + typedef typename MembersHolder::node node; + typedef typename MembersHolder::internal_node internal_node; + typedef typename MembersHolder::leaf leaf; - inline static void apply(node & node, Allocators & allocators) + inline static void apply(node & node, allocators_type & allocators) { - rtree::visitors::is_leaf ilv; + rtree::visitors::is_leaf ilv; rtree::apply_visitor(ilv, node); if ( ilv.result ) { @@ -187,17 +193,18 @@ struct clear_node } } - inline static void apply(internal_node & internal_node, Allocators & allocators) + inline static void apply(internal_node & internal_node, allocators_type & allocators) { - destroy_elements::apply(rtree::elements(internal_node), allocators); + destroy_elements::apply(rtree::elements(internal_node), allocators); rtree::elements(internal_node).clear(); } - inline static void apply(leaf & leaf, Allocators &) + inline static void apply(leaf & leaf, allocators_type &) { rtree::elements(leaf).clear(); } }; +*/ template void move_from_back(Container & container, Iterator it) diff --git a/include/boost/geometry/index/detail/rtree/node/subtree_destroyer.hpp b/include/boost/geometry/index/detail/rtree/node/subtree_destroyer.hpp index 3376068ee..838d757ab 100644 --- a/include/boost/geometry/index/detail/rtree/node/subtree_destroyer.hpp +++ b/include/boost/geometry/index/detail/rtree/node/subtree_destroyer.hpp @@ -4,6 +4,10 @@ // // Copyright (c) 2011-2015 Adam Wulkiewicz, Lodz, Poland. // +// This file was modified by Oracle on 2019. +// Modifications copyright (c) 2019 Oracle and/or its affiliates. +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle +// // Use, modification and distribution is subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) @@ -17,17 +21,19 @@ namespace boost { namespace geometry { namespace index { namespace detail { namespace rtree { -template +template class subtree_destroyer { - typedef typename rtree::node::type node; - typedef typename Allocators::node_pointer pointer; + typedef typename MembersHolder::node node; + + typedef typename MembersHolder::allocators_type allocators_type; + typedef typename MembersHolder::node_pointer pointer; subtree_destroyer(subtree_destroyer const&); subtree_destroyer & operator=(subtree_destroyer const&); public: - subtree_destroyer(pointer ptr, Allocators & allocators) + subtree_destroyer(pointer ptr, allocators_type & allocators) : m_ptr(ptr) , m_allocators(allocators) {} @@ -41,8 +47,7 @@ public: { if ( m_ptr && m_ptr != ptr ) { - detail::rtree::visitors::destroy del_v(m_ptr, m_allocators); - detail::rtree::apply_visitor(del_v, *m_ptr); + detail::rtree::visitors::destroy::apply(m_ptr, m_allocators); } m_ptr = ptr; } @@ -69,7 +74,7 @@ public: private: pointer m_ptr; - Allocators & m_allocators; + allocators_type & m_allocators; }; }} // namespace detail::rtree diff --git a/include/boost/geometry/index/detail/rtree/pack_create.hpp b/include/boost/geometry/index/detail/rtree/pack_create.hpp index f8565bfb3..52a3846fb 100644 --- a/include/boost/geometry/index/detail/rtree/pack_create.hpp +++ b/include/boost/geometry/index/detail/rtree/pack_create.hpp @@ -20,6 +20,7 @@ #include #include #include +#include #include @@ -126,37 +127,45 @@ struct nth_element_and_half_boxes // L2 25 25 25 25 25 25 17 10 // L3 5x5 5x5 5x5 5x5 5x5 5x5 3x5+2 2x5 -template +template class pack { - typedef typename rtree::node::type node; - typedef typename rtree::internal_node::type internal_node; - typedef typename rtree::leaf::type leaf; + typedef typename MembersHolder::node node; + typedef typename MembersHolder::internal_node internal_node; + typedef typename MembersHolder::leaf leaf; - typedef typename Allocators::node_pointer node_pointer; - typedef rtree::subtree_destroyer subtree_destroyer; - typedef typename Allocators::size_type size_type; + typedef typename MembersHolder::node_pointer node_pointer; + typedef typename MembersHolder::size_type size_type; + typedef typename MembersHolder::parameters_type parameters_type; + typedef typename MembersHolder::translator_type translator_type; + typedef typename MembersHolder::allocators_type allocators_type; - typedef typename geometry::point_type::type point_type; + typedef typename MembersHolder::box_type box_type; + typedef typename geometry::point_type::type point_type; typedef typename geometry::coordinate_type::type coordinate_type; - typedef typename detail::default_content_result::type content_type; - typedef typename Options::parameters_type parameters_type; + typedef typename detail::default_content_result::type content_type; typedef typename detail::strategy_type::type strategy_type; static const std::size_t dimension = geometry::dimension::value; typedef typename rtree::container_from_elements_type< typename rtree::elements_type::type, - std::size_t + size_type >::type values_counts_container; typedef typename rtree::elements_type::type internal_elements; typedef typename internal_elements::value_type internal_element; + typedef rtree::subtree_destroyer subtree_destroyer; + public: // Arbitrary iterators template inline static - node_pointer apply(InIt first, InIt last, size_type & values_count, size_type & leafs_level, - parameters_type const& parameters, Translator const& translator, Allocators & allocators) + node_pointer apply(InIt first, InIt last, + size_type & values_count, + size_type & leafs_level, + parameters_type const& parameters, + translator_type const& translator, + allocators_type & allocators) { typedef typename std::iterator_traits::difference_type diff_type; @@ -170,7 +179,7 @@ public: values_count = static_cast(diff); entries.reserve(values_count); - expandable_box hint_box(detail::get_strategy(parameters)); + expandable_box hint_box(detail::get_strategy(parameters)); for ( ; first != last ; ++first ) { // NOTE: support for iterators not returning true references adapted @@ -178,7 +187,7 @@ public: // An alternative would be to dereference the iterator and translate // in one expression each time the indexable was needed. typename std::iterator_traits::reference in_ref = *first; - typename Translator::result_type indexable = translator(in_ref); + typename translator_type::result_type indexable = translator(in_ref); // NOTE: added for consistency with insert() // CONSIDER: alternative - ignore invalid indexable or throw an exception @@ -250,16 +259,21 @@ private: struct subtree_elements_counts { - subtree_elements_counts(std::size_t ma, std::size_t mi) : maxc(ma), minc(mi) {} - std::size_t maxc; - std::size_t minc; + subtree_elements_counts(size_type ma, size_type mi) : maxc(ma), minc(mi) {} + size_type maxc; + size_type minc; }; template inline static - internal_element per_level(EIt first, EIt last, Box const& hint_box, std::size_t values_count, subtree_elements_counts const& subtree_counts, - parameters_type const& parameters, Translator const& translator, Allocators & allocators) + internal_element per_level(EIt first, EIt last, + box_type const& hint_box, + size_type values_count, + subtree_elements_counts const& subtree_counts, + parameters_type const& parameters, + translator_type const& translator, + allocators_type & allocators) { - BOOST_GEOMETRY_INDEX_ASSERT(0 < std::distance(first, last) && static_cast(std::distance(first, last)) == values_count, + BOOST_GEOMETRY_INDEX_ASSERT(0 < std::distance(first, last) && static_cast(std::distance(first, last)) == values_count, "unexpected parameters"); if ( subtree_counts.maxc <= 1 ) @@ -270,7 +284,7 @@ private: // if !root check m_parameters.get_min_elements() <= count // create new leaf node - node_pointer n = rtree::create_node::apply(allocators); // MAY THROW (A) + node_pointer n = rtree::create_node::apply(allocators); // MAY THROW (A) subtree_destroyer auto_remover(n, allocators); leaf & l = rtree::get(*n); @@ -279,8 +293,8 @@ private: // calculate values box and copy values // initialize the box explicitly to avoid GCC-4.4 uninitialized variable warnings with O2 - expandable_box elements_box(translator(*(first->second)), - detail::get_strategy(parameters)); + expandable_box elements_box(translator(*(first->second)), + detail::get_strategy(parameters)); rtree::elements(l).push_back(*(first->second)); // MAY THROW (A?,C) for ( ++first ; first != last ; ++first ) { @@ -301,7 +315,7 @@ private: if ( BOOST_GEOMETRY_CONDITION(( ! index::detail::is_bounding_geometry < - typename indexable_type::type + typename indexable_type::type >::value )) ) { elements_box.expand_by_epsilon(); @@ -318,15 +332,15 @@ private: next_subtree_counts.minc /= parameters.get_max_elements(); // create new internal node - node_pointer n = rtree::create_node::apply(allocators); // MAY THROW (A) + node_pointer n = rtree::create_node::apply(allocators); // MAY THROW (A) subtree_destroyer auto_remover(n, allocators); internal_node & in = rtree::get(*n); // reserve space for values - std::size_t nodes_count = calculate_nodes_count(values_count, subtree_counts); + size_type nodes_count = calculate_nodes_count(values_count, subtree_counts); rtree::elements(in).reserve(nodes_count); // MAY THROW (A) // calculate values box and copy values - expandable_box elements_box(detail::get_strategy(parameters)); + expandable_box elements_box(detail::get_strategy(parameters)); per_level_packets(first, last, hint_box, values_count, subtree_counts, next_subtree_counts, rtree::elements(in), elements_box, @@ -337,14 +351,18 @@ private: } template inline static - void per_level_packets(EIt first, EIt last, Box const& hint_box, - std::size_t values_count, + void per_level_packets(EIt first, EIt last, + box_type const& hint_box, + size_type values_count, subtree_elements_counts const& subtree_counts, subtree_elements_counts const& next_subtree_counts, - internal_elements & elements, ExpandableBox & elements_box, - parameters_type const& parameters, Translator const& translator, Allocators & allocators) + internal_elements & elements, + ExpandableBox & elements_box, + parameters_type const& parameters, + translator_type const& translator, + allocators_type & allocators) { - BOOST_GEOMETRY_INDEX_ASSERT(0 < std::distance(first, last) && static_cast(std::distance(first, last)) == values_count, + BOOST_GEOMETRY_INDEX_ASSERT(0 < std::distance(first, last) && static_cast(std::distance(first, last)) == values_count, "unexpected parameters"); BOOST_GEOMETRY_INDEX_ASSERT(subtree_counts.minc <= values_count, @@ -369,13 +387,13 @@ private: return; } - std::size_t median_count = calculate_median_count(values_count, subtree_counts); + size_type median_count = calculate_median_count(values_count, subtree_counts); EIt median = first + median_count; coordinate_type greatest_length; std::size_t greatest_dim_index = 0; pack_utils::biggest_edge::apply(hint_box, greatest_length, greatest_dim_index); - Box left, right; + box_type left, right; pack_utils::nth_element_and_half_boxes<0, dimension> ::apply(first, median, last, hint_box, left, right, greatest_dim_index); @@ -390,14 +408,14 @@ private: } inline static - subtree_elements_counts calculate_subtree_elements_counts(std::size_t elements_count, parameters_type const& parameters, size_type & leafs_level) + subtree_elements_counts calculate_subtree_elements_counts(size_type elements_count, parameters_type const& parameters, size_type & leafs_level) { boost::ignore_unused(parameters); subtree_elements_counts res(1, 1); leafs_level = 0; - std::size_t smax = parameters.get_max_elements(); + size_type smax = parameters.get_max_elements(); for ( ; smax < elements_count ; smax *= parameters.get_max_elements(), ++leafs_level ) res.maxc = smax; @@ -407,15 +425,15 @@ private: } inline static - std::size_t calculate_nodes_count(std::size_t count, - subtree_elements_counts const& subtree_counts) + size_type calculate_nodes_count(size_type count, + subtree_elements_counts const& subtree_counts) { - std::size_t n = count / subtree_counts.maxc; - std::size_t r = count % subtree_counts.maxc; + size_type n = count / subtree_counts.maxc; + size_type r = count % subtree_counts.maxc; if ( 0 < r && r < subtree_counts.minc ) { - std::size_t count_minus_min = count - subtree_counts.minc; + size_type count_minus_min = count - subtree_counts.minc; n = count_minus_min / subtree_counts.maxc; r = count_minus_min % subtree_counts.maxc; ++n; @@ -428,14 +446,14 @@ private: } inline static - std::size_t calculate_median_count(std::size_t count, - subtree_elements_counts const& subtree_counts) + size_type calculate_median_count(size_type count, + subtree_elements_counts const& subtree_counts) { // e.g. for max = 5, min = 2, count = 52, subtree_max = 25, subtree_min = 10 - std::size_t n = count / subtree_counts.maxc; // e.g. 52 / 25 = 2 - std::size_t r = count % subtree_counts.maxc; // e.g. 52 % 25 = 2 - std::size_t median_count = (n / 2) * subtree_counts.maxc; // e.g. 2 / 2 * 25 = 25 + size_type n = count / subtree_counts.maxc; // e.g. 52 / 25 = 2 + size_type r = count % subtree_counts.maxc; // e.g. 52 % 25 = 2 + size_type median_count = (n / 2) * subtree_counts.maxc; // e.g. 2 / 2 * 25 = 25 if ( 0 != r ) // e.g. 0 != 2 { @@ -446,7 +464,7 @@ private: } else // r < subtree_counts.second // e.g. 2 < 10 == true { - std::size_t count_minus_min = count - subtree_counts.minc; // e.g. 52 - 10 = 42 + size_type count_minus_min = count - subtree_counts.minc; // e.g. 52 - 10 = 42 n = count_minus_min / subtree_counts.maxc; // e.g. 42 / 25 = 1 r = count_minus_min % subtree_counts.maxc; // e.g. 42 % 25 = 17 if ( r == 0 ) // e.g. false diff --git a/include/boost/geometry/index/detail/rtree/quadratic/redistribute_elements.hpp b/include/boost/geometry/index/detail/rtree/quadratic/redistribute_elements.hpp index 3fd51d56f..05e71fb0e 100644 --- a/include/boost/geometry/index/detail/rtree/quadratic/redistribute_elements.hpp +++ b/include/boost/geometry/index/detail/rtree/quadratic/redistribute_elements.hpp @@ -92,29 +92,32 @@ inline void pick_seeds(Elements const& elements, } // namespace quadratic -template -struct redistribute_elements +template +struct redistribute_elements { - typedef typename Options::parameters_type parameters_type; + typedef typename MembersHolder::box_type box_type; + typedef typename MembersHolder::parameters_type parameters_type; + typedef typename MembersHolder::translator_type translator_type; + typedef typename MembersHolder::allocators_type allocators_type; - typedef typename rtree::node::type node; - typedef typename rtree::internal_node::type internal_node; - typedef typename rtree::leaf::type leaf; + typedef typename MembersHolder::node node; + typedef typename MembersHolder::internal_node internal_node; + typedef typename MembersHolder::leaf leaf; - typedef typename index::detail::default_content_result::type content_type; + typedef typename index::detail::default_content_result::type content_type; template static inline void apply(Node & n, Node & second_node, - Box & box1, - Box & box2, + box_type & box1, + box_type & box2, parameters_type const& parameters, - Translator const& translator, - Allocators & allocators) + translator_type const& translator, + allocators_type & allocators) { typedef typename rtree::elements_type::type elements_type; typedef typename elements_type::value_type element_type; - typedef typename rtree::element_indexable_type::type indexable_type; + typedef typename rtree::element_indexable_type::type indexable_type; elements_type & elements1 = rtree::elements(n); elements_type & elements2 = rtree::elements(second_node); @@ -131,7 +134,7 @@ struct redistribute_elements(elements_copy, parameters, translator, seed1, seed2); + quadratic::pick_seeds(elements_copy, parameters, translator, seed1, seed2); // prepare nodes' elements containers elements1.clear(); @@ -249,7 +252,7 @@ struct redistribute_elements::apply(elements_backup, allocators); + rtree::destroy_elements::apply(elements_backup, allocators); //elements_backup.clear(); BOOST_RETHROW // RETHROW, BASIC @@ -261,14 +264,14 @@ struct redistribute_elements static inline It pick_next(It first, It last, - Box const& box1, Box const& box2, + box_type const& box1, box_type const& box2, content_type const& content1, content_type const& content2, - Translator const& translator, + translator_type const& translator, typename index::detail::strategy_type::type const& strategy, content_type & out_content_increase1, content_type & out_content_increase2) { typedef typename boost::iterator_value::type element_type; - typedef typename rtree::element_indexable_type::type indexable_type; + typedef typename rtree::element_indexable_type::type indexable_type; content_type greatest_content_incrase_diff = 0; It out_it = first; @@ -281,8 +284,8 @@ struct redistribute_elements +template class spatial_query_iterator { - typedef typename Options::parameters_type parameters_type; - typedef visitors::spatial_query_incremental visitor_type; + typedef typename MembersHolder::parameters_type parameters_type; + typedef typename MembersHolder::translator_type translator_type; + typedef typename MembersHolder::allocators_type allocators_type; + + typedef visitors::spatial_query_incremental visitor_type; typedef typename visitor_type::node_pointer node_pointer; public: typedef std::forward_iterator_tag iterator_category; - typedef Value value_type; - typedef typename Allocators::const_reference reference; - typedef typename Allocators::difference_type difference_type; - typedef typename Allocators::const_pointer pointer; + typedef typename MembersHolder::value_type value_type; + typedef typename allocators_type::const_reference reference; + typedef typename allocators_type::difference_type difference_type; + typedef typename allocators_type::const_pointer pointer; inline spatial_query_iterator() {} - inline spatial_query_iterator(parameters_type const& par, Translator const& t, Predicates const& p) + inline spatial_query_iterator(parameters_type const& par, translator_type const& t, Predicates const& p) : m_visitor(par, t, p) {} - inline spatial_query_iterator(node_pointer root, parameters_type const& par, Translator const& t, Predicates const& p) + inline spatial_query_iterator(node_pointer root, parameters_type const& par, translator_type const& t, Predicates const& p) : m_visitor(par, t, p) { m_visitor.initialize(root); @@ -113,12 +120,12 @@ public: return l.m_visitor == r.m_visitor; } - friend bool operator==(spatial_query_iterator const& l, end_query_iterator const& /*r*/) + friend bool operator==(spatial_query_iterator const& l, end_query_iterator const& /*r*/) { return l.m_visitor.is_end(); } - friend bool operator==(end_query_iterator const& /*l*/, spatial_query_iterator const& r) + friend bool operator==(end_query_iterator const& /*l*/, spatial_query_iterator const& r) { return r.m_visitor.is_end(); } @@ -127,28 +134,31 @@ private: visitor_type m_visitor; }; -template +template class distance_query_iterator { - typedef typename Options::parameters_type parameters_type; - typedef visitors::distance_query_incremental visitor_type; + typedef typename MembersHolder::parameters_type parameters_type; + typedef typename MembersHolder::translator_type translator_type; + typedef typename MembersHolder::allocators_type allocators_type; + + typedef visitors::distance_query_incremental visitor_type; typedef typename visitor_type::node_pointer node_pointer; public: typedef std::forward_iterator_tag iterator_category; - typedef Value value_type; - typedef typename Allocators::const_reference reference; - typedef typename Allocators::difference_type difference_type; - typedef typename Allocators::const_pointer pointer; + typedef typename MembersHolder::value_type value_type; + typedef typename allocators_type::const_reference reference; + typedef typename allocators_type::difference_type difference_type; + typedef typename allocators_type::const_pointer pointer; inline distance_query_iterator() {} - inline distance_query_iterator(parameters_type const& par, Translator const& t, Predicates const& p) + inline distance_query_iterator(parameters_type const& par, translator_type const& t, Predicates const& p) : m_visitor(par, t, p) {} - inline distance_query_iterator(node_pointer root, parameters_type const& par, Translator const& t, Predicates const& p) + inline distance_query_iterator(node_pointer root, parameters_type const& par, translator_type const& t, Predicates const& p) : m_visitor(par, t, p) { m_visitor.initialize(root); @@ -182,12 +192,12 @@ public: return l.m_visitor == r.m_visitor; } - friend bool operator==(distance_query_iterator const& l, end_query_iterator const& /*r*/) + friend bool operator==(distance_query_iterator const& l, end_query_iterator const& /*r*/) { return l.m_visitor.is_end(); } - friend bool operator==(end_query_iterator const& /*l*/, distance_query_iterator const& r) + friend bool operator==(end_query_iterator const& /*l*/, distance_query_iterator const& r) { return r.m_visitor.is_end(); } diff --git a/include/boost/geometry/index/detail/rtree/rstar/choose_next_node.hpp b/include/boost/geometry/index/detail/rtree/rstar/choose_next_node.hpp index 209f6ebb2..7ba5f0f99 100644 --- a/include/boost/geometry/index/detail/rtree/rstar/choose_next_node.hpp +++ b/include/boost/geometry/index/detail/rtree/rstar/choose_next_node.hpp @@ -33,19 +33,20 @@ namespace boost { namespace geometry { namespace index { namespace detail { namespace rtree { -template -class choose_next_node +template +class choose_next_node { - typedef typename rtree::node::type node; - typedef typename rtree::internal_node::type internal_node; - typedef typename rtree::leaf::type leaf; + typedef typename MembersHolder::box_type box_type; + typedef typename MembersHolder::parameters_type parameters_type; + + typedef typename MembersHolder::node node; + typedef typename MembersHolder::internal_node internal_node; + typedef typename MembersHolder::leaf leaf; typedef typename rtree::elements_type::type children_type; typedef typename children_type::value_type child_type; - typedef typename Options::parameters_type parameters_type; - - typedef typename index::detail::default_content_result::type content_type; + typedef typename index::detail::default_content_result::type content_type; public: template @@ -109,7 +110,7 @@ private: child_type const& ch_i = children[i]; // expanded child node's box - Box box_exp(ch_i.first); + box_type box_exp(ch_i.first); index::detail::expand(box_exp, indexable, strategy); // areas difference @@ -183,7 +184,7 @@ private: child_type const& ch_i = children[i]; - Box box_exp(ch_i.first); + box_type box_exp(ch_i.first); // calculate expanded box of child node ch_i index::detail::expand(box_exp, indexable, strategy); @@ -238,7 +239,7 @@ private: child_type const& ch_i = children[i]; // expanded child node's box - Box box_exp(ch_i.first); + box_type box_exp(ch_i.first); index::detail::expand(box_exp, indexable, strategy); // areas difference diff --git a/include/boost/geometry/index/detail/rtree/rstar/insert.hpp b/include/boost/geometry/index/detail/rtree/rstar/insert.hpp index 73a5ccefc..e11636f0f 100644 --- a/include/boost/geometry/index/detail/rtree/rstar/insert.hpp +++ b/include/boost/geometry/index/detail/rtree/rstar/insert.hpp @@ -56,15 +56,18 @@ struct comparable_distance_point_point } }; -template +template class remove_elements_to_reinsert { public: - typedef typename rtree::node::type node; - typedef typename rtree::internal_node::type internal_node; - typedef typename rtree::leaf::type leaf; + typedef typename MembersHolder::box_type box_type; + typedef typename MembersHolder::parameters_type parameters_type; + typedef typename MembersHolder::translator_type translator_type; + typedef typename MembersHolder::allocators_type allocators_type; - typedef typename Options::parameters_type parameters_type; + typedef typename MembersHolder::node node; + typedef typename MembersHolder::internal_node internal_node; + typedef typename MembersHolder::leaf leaf; //typedef typename Allocators::internal_node_pointer internal_node_pointer; typedef internal_node * internal_node_pointer; @@ -75,12 +78,12 @@ public: internal_node_pointer parent, size_t current_child_index, parameters_type const& parameters, - Translator const& translator, - Allocators & allocators) + translator_type const& translator, + allocators_type & allocators) { typedef typename rtree::elements_type::type elements_type; typedef typename elements_type::value_type element_type; - typedef typename geometry::point_type::type point_type; + typedef typename geometry::point_type::type point_type; typedef typename index::detail::strategy_type::type strategy_type; // TODO: awulkiew - change second point_type to the point type of the Indexable? typedef rstar::comparable_distance_point_point @@ -159,7 +162,7 @@ public: for ( typename sorted_elements_type::iterator it = sorted_elements.begin() ; it != sorted_elements.end() ; ++it ) { - destroy_element::apply(it->second, allocators); + destroy_element::apply(it->second, allocators); } BOOST_RETHROW // RETHROW @@ -187,48 +190,69 @@ private: } }; -template +template +< + size_t InsertIndex, + typename Element, + typename MembersHolder, + bool IsValue = boost::is_same::value +> struct level_insert_elements_type { typedef typename rtree::elements_type< - typename rtree::internal_node::type + typename rtree::internal_node< + typename MembersHolder::value_type, + typename MembersHolder::parameters_type, + typename MembersHolder::box_type, + typename MembersHolder::allocators_type, + typename MembersHolder::node_tag + >::type >::type type; }; -template -struct level_insert_elements_type<0, Value, Value, Options, Box, Allocators> +template +struct level_insert_elements_type<0, Value, MembersHolder, true> { typedef typename rtree::elements_type< - typename rtree::leaf::type + typename rtree::leaf< + typename MembersHolder::value_type, + typename MembersHolder::parameters_type, + typename MembersHolder::box_type, + typename MembersHolder::allocators_type, + typename MembersHolder::node_tag + >::type >::type type; }; -template +template struct level_insert_base - : public detail::insert + : public detail::insert { - typedef detail::insert base; + typedef detail::insert base; typedef typename base::node node; typedef typename base::internal_node internal_node; typedef typename base::leaf leaf; - typedef typename level_insert_elements_type::type elements_type; + typedef typename level_insert_elements_type::type elements_type; typedef typename index::detail::rtree::container_from_elements_type< elements_type, typename elements_type::value_type >::type result_elements_type; - typedef typename Options::parameters_type parameters_type; + typedef typename MembersHolder::box_type box_type; + typedef typename MembersHolder::parameters_type parameters_type; + typedef typename MembersHolder::translator_type translator_type; + typedef typename MembersHolder::allocators_type allocators_type; - typedef typename Allocators::node_pointer node_pointer; - typedef typename Allocators::size_type size_type; + typedef typename allocators_type::node_pointer node_pointer; + typedef typename allocators_type::size_type size_type; inline level_insert_base(node_pointer & root, size_type & leafs_level, Element const& element, parameters_type const& parameters, - Translator const& translator, - Allocators & allocators, + translator_type const& translator, + allocators_type & allocators, size_type relative_level) : base(root, leafs_level, element, parameters, translator, allocators, relative_level) , result_relative_level(0) @@ -249,7 +273,7 @@ struct level_insert_base { // NOTE: exception-safety // After an exception result_elements may contain garbage, don't use it - rstar::remove_elements_to_reinsert::apply( + rstar::remove_elements_to_reinsert::apply( result_elements, n, base::m_traverse_data.parent, base::m_traverse_data.current_child_index, base::m_parameters, base::m_translator, base::m_allocators); // MAY THROW, BASIC (V, E: alloc, copy) @@ -287,43 +311,51 @@ struct level_insert_base inline void recalculate_aabb(Node const& n) const { base::m_traverse_data.current_element().first = - elements_box(rtree::elements(n).begin(), rtree::elements(n).end(), - base::m_translator, - index::detail::get_strategy(base::m_parameters)); + elements_box(rtree::elements(n).begin(), rtree::elements(n).end(), + base::m_translator, + index::detail::get_strategy(base::m_parameters)); } inline void recalculate_aabb(leaf const& n) const { base::m_traverse_data.current_element().first = - values_box(rtree::elements(n).begin(), rtree::elements(n).end(), - base::m_translator, - index::detail::get_strategy(base::m_parameters)); + values_box(rtree::elements(n).begin(), rtree::elements(n).end(), + base::m_translator, + index::detail::get_strategy(base::m_parameters)); } size_type result_relative_level; result_elements_type result_elements; }; -template +template +< + size_t InsertIndex, + typename Element, + typename MembersHolder, + bool IsValue = boost::is_same::value +> struct level_insert - : public level_insert_base + : public level_insert_base { - typedef level_insert_base base; + typedef level_insert_base base; typedef typename base::node node; typedef typename base::internal_node internal_node; typedef typename base::leaf leaf; - typedef typename Options::parameters_type parameters_type; + typedef typename base::parameters_type parameters_type; + typedef typename base::translator_type translator_type; + typedef typename base::allocators_type allocators_type; - typedef typename Allocators::node_pointer node_pointer; - typedef typename Allocators::size_type size_type; + typedef typename base::node_pointer node_pointer; + typedef typename base::size_type size_type; inline level_insert(node_pointer & root, size_type & leafs_level, Element const& element, parameters_type const& parameters, - Translator const& translator, - Allocators & allocators, + translator_type const& translator, + allocators_type & allocators, size_type relative_level) : base(root, leafs_level, element, parameters, translator, allocators, relative_level) {} @@ -362,8 +394,7 @@ struct level_insert // NOTE: exception-safety // if the insert fails above, the element won't be stored in the tree, so delete it - rtree::visitors::destroy del_v(base::m_element.second, base::m_allocators); - rtree::apply_visitor(del_v, *base::m_element.second); + rtree::visitors::destroy::apply(base::m_element.second, base::m_allocators); BOOST_RETHROW // RETHROW } @@ -390,26 +421,29 @@ struct level_insert } }; -template -struct level_insert - : public level_insert_base +template +struct level_insert + : public level_insert_base { - typedef level_insert_base base; + typedef level_insert_base base; typedef typename base::node node; typedef typename base::internal_node internal_node; typedef typename base::leaf leaf; - typedef typename Options::parameters_type parameters_type; + typedef typename MembersHolder::value_type value_type; + typedef typename base::parameters_type parameters_type; + typedef typename base::translator_type translator_type; + typedef typename base::allocators_type allocators_type; - typedef typename Allocators::node_pointer node_pointer; - typedef typename Allocators::size_type size_type; + typedef typename base::node_pointer node_pointer; + typedef typename base::size_type size_type; inline level_insert(node_pointer & root, size_type & leafs_level, - Value const& v, + value_type const& v, parameters_type const& parameters, - Translator const& translator, - Allocators & allocators, + translator_type const& translator, + allocators_type & allocators, size_type relative_level) : base(root, leafs_level, v, parameters, translator, allocators, relative_level) {} @@ -446,26 +480,29 @@ struct level_insert -struct level_insert<0, Value, Value, Options, Translator, Box, Allocators> - : public level_insert_base<0, Value, Value, Options, Translator, Box, Allocators> +template +struct level_insert<0, Value, MembersHolder, true> + : public level_insert_base<0, typename MembersHolder::value_type, MembersHolder> { - typedef level_insert_base<0, Value, Value, Options, Translator, Box, Allocators> base; + typedef level_insert_base<0, typename MembersHolder::value_type, MembersHolder> base; typedef typename base::node node; typedef typename base::internal_node internal_node; typedef typename base::leaf leaf; - typedef typename Options::parameters_type parameters_type; + typedef typename MembersHolder::value_type value_type; + typedef typename base::parameters_type parameters_type; + typedef typename base::translator_type translator_type; + typedef typename base::allocators_type allocators_type; - typedef typename Allocators::node_pointer node_pointer; - typedef typename Allocators::size_type size_type; + typedef typename base::node_pointer node_pointer; + typedef typename base::size_type size_type; inline level_insert(node_pointer & root, size_type & leafs_level, - Value const& v, + value_type const& v, parameters_type const& parameters, - Translator const& translator, - Allocators & allocators, + translator_type const& translator, + allocators_type & allocators, size_type relative_level) : base(root, leafs_level, v, parameters, translator, allocators, relative_level) {} @@ -505,26 +542,28 @@ struct level_insert<0, Value, Value, Options, Translator, Box, Allocators> // After passing the Element to insert visitor the Element is managed by the tree // I.e. one should not delete the node passed to the insert visitor after exception is thrown // because this visitor may delete it -template -class insert - : public rtree::visitor::type +template +class insert + : public MembersHolder::visitor { - typedef typename Options::parameters_type parameters_type; + typedef typename MembersHolder::parameters_type parameters_type; + typedef typename MembersHolder::translator_type translator_type; + typedef typename MembersHolder::allocators_type allocators_type; - typedef typename rtree::node::type node; - typedef typename rtree::internal_node::type internal_node; - typedef typename rtree::leaf::type leaf; + typedef typename MembersHolder::node node; + typedef typename MembersHolder::internal_node internal_node; + typedef typename MembersHolder::leaf leaf; - typedef typename Allocators::node_pointer node_pointer; - typedef typename Allocators::size_type size_type; + typedef typename allocators_type::node_pointer node_pointer; + typedef typename allocators_type::size_type size_type; public: inline insert(node_pointer & root, size_type & leafs_level, Element const& element, parameters_type const& parameters, - Translator const& translator, - Allocators & allocators, + translator_type const& translator, + allocators_type & allocators, size_type relative_level = 0) : m_root(root), m_leafs_level(leafs_level), m_element(element) , m_parameters(parameters), m_translator(translator) @@ -539,7 +578,7 @@ public: // Distinguish between situation when reinserts are required and use adequate visitor, otherwise use default one if ( m_parameters.get_reinserted_elements() > 0 ) { - rstar::level_insert<0, Element, Value, Options, Translator, Box, Allocators> lins_v( + rstar::level_insert<0, Element, MembersHolder> lins_v( m_root, m_leafs_level, m_element, m_parameters, m_translator, m_allocators, m_relative_level); rtree::apply_visitor(lins_v, *m_root); // MAY THROW (V, E: alloc, copy, N: alloc) @@ -551,7 +590,7 @@ public: } else { - visitors::insert ins_v( + visitors::insert ins_v( m_root, m_leafs_level, m_element, m_parameters, m_translator, m_allocators, m_relative_level); rtree::apply_visitor(ins_v, *m_root); @@ -566,7 +605,7 @@ public: // Distinguish between situation when reinserts are required and use adequate visitor, otherwise use default one if ( m_parameters.get_reinserted_elements() > 0 ) { - rstar::level_insert<0, Element, Value, Options, Translator, Box, Allocators> lins_v( + rstar::level_insert<0, Element, MembersHolder> lins_v( m_root, m_leafs_level, m_element, m_parameters, m_translator, m_allocators, m_relative_level); rtree::apply_visitor(lins_v, *m_root); // MAY THROW (V, E: alloc, copy, N: alloc) @@ -576,7 +615,7 @@ public: } else { - visitors::insert ins_v( + visitors::insert ins_v( m_root, m_leafs_level, m_element, m_parameters, m_translator, m_allocators, m_relative_level); rtree::apply_visitor(ins_v, *m_root); @@ -593,7 +632,7 @@ private: typename Elements::reverse_iterator it = elements.rbegin(); for ( ; it != elements.rend() ; ++it) { - rstar::level_insert<1, element_type, Value, Options, Translator, Box, Allocators> lins_v( + rstar::level_insert<1, element_type, MembersHolder> lins_v( m_root, m_leafs_level, *it, m_parameters, m_translator, m_allocators, relative_level); BOOST_TRY @@ -604,7 +643,7 @@ private: { ++it; for ( ; it != elements.rend() ; ++it) - rtree::destroy_element::apply(*it, m_allocators); + rtree::destroy_element::apply(*it, m_allocators); BOOST_RETHROW // RETHROW } BOOST_CATCH_END @@ -624,11 +663,11 @@ private: Element const& m_element; parameters_type const& m_parameters; - Translator const& m_translator; + translator_type const& m_translator; size_type m_relative_level; - Allocators & m_allocators; + allocators_type & m_allocators; }; }}} // namespace detail::rtree::visitors diff --git a/include/boost/geometry/index/detail/rtree/rstar/redistribute_elements.hpp b/include/boost/geometry/index/detail/rtree/rstar/redistribute_elements.hpp index 0b19a9e9b..f8093e2f2 100644 --- a/include/boost/geometry/index/detail/rtree/rstar/redistribute_elements.hpp +++ b/include/boost/geometry/index/detail/rtree/rstar/redistribute_elements.hpp @@ -397,29 +397,32 @@ struct nth_element } // namespace rstar -template -struct redistribute_elements +template +struct redistribute_elements { - typedef typename rtree::node::type node; - typedef typename rtree::internal_node::type internal_node; - typedef typename rtree::leaf::type leaf; + typedef typename MembersHolder::box_type box_type; + typedef typename MembersHolder::parameters_type parameters_type; + typedef typename MembersHolder::translator_type translator_type; + typedef typename MembersHolder::allocators_type allocators_type; - typedef typename Options::parameters_type parameters_type; + typedef typename MembersHolder::node node; + typedef typename MembersHolder::internal_node internal_node; + typedef typename MembersHolder::leaf leaf; - static const size_t dimension = geometry::dimension::value; + static const size_t dimension = geometry::dimension::value; - typedef typename index::detail::default_margin_result::type margin_type; - typedef typename index::detail::default_content_result::type content_type; + typedef typename index::detail::default_margin_result::type margin_type; + typedef typename index::detail::default_content_result::type content_type; template static inline void apply( Node & n, Node & second_node, - Box & box1, - Box & box2, + box_type & box1, + box_type & box2, parameters_type const& parameters, - Translator const& translator, - Allocators & allocators) + translator_type const& translator, + allocators_type & allocators) { typedef typename rtree::elements_type::type elements_type; typedef typename elements_type::value_type element_type; @@ -446,7 +449,7 @@ struct redistribute_elements + rstar::choose_split_axis_and_index ::apply(elements_copy, split_axis, split_corner, split_index, smallest_sum_of_margins, smallest_overlap, smallest_content, @@ -479,10 +482,10 @@ struct redistribute_elements(elements1.begin(), elements1.end(), - translator, strategy); - box2 = rtree::elements_box(elements2.begin(), elements2.end(), - translator, strategy); + box1 = rtree::elements_box(elements1.begin(), elements1.end(), + translator, strategy); + box2 = rtree::elements_box(elements2.begin(), elements2.end(), + translator, strategy); } BOOST_CATCH(...) { @@ -490,7 +493,7 @@ struct redistribute_elements::apply(elements_backup, allocators); + rtree::destroy_elements::apply(elements_backup, allocators); //elements_backup.clear(); BOOST_RETHROW // RETHROW, BASIC diff --git a/include/boost/geometry/index/detail/rtree/utilities/are_boxes_ok.hpp b/include/boost/geometry/index/detail/rtree/utilities/are_boxes_ok.hpp index b5fe5a0e2..64c4d7470 100644 --- a/include/boost/geometry/index/detail/rtree/utilities/are_boxes_ok.hpp +++ b/include/boost/geometry/index/detail/rtree/utilities/are_boxes_ok.hpp @@ -22,17 +22,19 @@ namespace boost { namespace geometry { namespace index { namespace detail { name namespace visitors { -template +template class are_boxes_ok - : public rtree::visitor::type + : public MembersHolder::visitor_const { - typedef typename Options::parameters_type parameters_type; + typedef typename MembersHolder::box_type box_type; + typedef typename MembersHolder::parameters_type parameters_type; + typedef typename MembersHolder::translator_type translator_type; - typedef typename rtree::internal_node::type internal_node; - typedef typename rtree::leaf::type leaf; + typedef typename MembersHolder::internal_node internal_node; + typedef typename MembersHolder::leaf leaf; public: - are_boxes_ok(parameters_type const& parameters, Translator const& tr, bool exact_match) + are_boxes_ok(parameters_type const& parameters, translator_type const& tr, bool exact_match) : result(false), m_parameters(parameters), m_tr(tr), m_is_root(true), m_exact_match(exact_match) {} @@ -47,7 +49,7 @@ public: return; } - Box box_bckup = m_box; + box_type box_bckup = m_box; bool is_root_bckup = m_is_root; m_is_root = false; @@ -66,8 +68,8 @@ public: m_box = box_bckup; m_is_root = is_root_bckup; - Box box_exp = rtree::elements_box(elements.begin(), elements.end(), m_tr, - index::detail::get_strategy(m_parameters)); + box_type box_exp = rtree::elements_box(elements.begin(), elements.end(), m_tr, + index::detail::get_strategy(m_parameters)); if ( m_exact_match ) result = m_is_root || geometry::equals(box_exp, m_box); @@ -89,8 +91,8 @@ public: return; } - Box box_exp = rtree::values_box(elements.begin(), elements.end(), m_tr, - index::detail::get_strategy(m_parameters)); + box_type box_exp = rtree::values_box(elements.begin(), elements.end(), m_tr, + index::detail::get_strategy(m_parameters)); if ( m_exact_match ) result = geometry::equals(box_exp, m_box); @@ -105,8 +107,8 @@ public: private: parameters_type const& m_parameters; - Translator const& m_tr; - Box m_box; + translator_type const& m_tr; + box_type m_box; bool m_is_root; bool m_exact_match; }; @@ -120,11 +122,7 @@ bool are_boxes_ok(Rtree const& tree, bool exact_match = true) RTV rtv(tree); visitors::are_boxes_ok< - typename RTV::value_type, - typename RTV::options_type, - typename RTV::translator_type, - typename RTV::box_type, - typename RTV::allocators_type + typename RTV::members_holder > v(tree.parameters(), rtv.translator(), exact_match); rtv.apply_visitor(v); diff --git a/include/boost/geometry/index/detail/rtree/utilities/are_counts_ok.hpp b/include/boost/geometry/index/detail/rtree/utilities/are_counts_ok.hpp index 10a1bec6a..5c8fc9ef2 100644 --- a/include/boost/geometry/index/detail/rtree/utilities/are_counts_ok.hpp +++ b/include/boost/geometry/index/detail/rtree/utilities/are_counts_ok.hpp @@ -4,6 +4,10 @@ // // Copyright (c) 2011-2015 Adam Wulkiewicz, Lodz, Poland. // +// This file was modified by Oracle on 2019. +// Modifications copyright (c) 2019 Oracle and/or its affiliates. +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle +// // Use, modification and distribution is subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) @@ -17,17 +21,21 @@ namespace boost { namespace geometry { namespace index { namespace detail { name namespace visitors { -template +template class are_counts_ok - : public rtree::visitor::type + : public MembersHolder::visitor_const { - typedef typename rtree::internal_node::type internal_node; - typedef typename rtree::leaf::type leaf; - typedef typename Options::parameters_type parameters_type; + typedef typename MembersHolder::parameters_type parameters_type; + + typedef typename MembersHolder::internal_node internal_node; + typedef typename MembersHolder::leaf leaf; public: - inline are_counts_ok(parameters_type const& parameters) - : result(true), m_current_level(0), m_parameters(parameters) + inline are_counts_ok(parameters_type const& parameters, bool check_min = true) + : result(true) + , m_current_level(0) + , m_parameters(parameters) + , m_check_min(check_min) {} inline void operator()(internal_node const& n) @@ -36,7 +44,7 @@ public: elements_type const& elements = rtree::elements(n); // root internal node shouldn't contain 0 elements - if ( elements.empty() + if ( (elements.empty() && m_check_min) || !check_count(elements) ) { result = false; @@ -62,7 +70,7 @@ public: elements_type const& elements = rtree::elements(n); // empty leaf in non-root node - if ( ( m_current_level > 0 && elements.empty() ) + if ( (m_current_level > 0 && elements.empty() && m_check_min) || !check_count(elements) ) { result = false; @@ -78,27 +86,25 @@ private: // root may contain count < min but should never contain count > max return elements.size() <= m_parameters.get_max_elements() && ( elements.size() >= m_parameters.get_min_elements() - || m_current_level == 0 ); + || m_current_level == 0 || !m_check_min ); } size_t m_current_level; parameters_type const& m_parameters; + bool m_check_min; }; } // namespace visitors template inline -bool are_counts_ok(Rtree const& tree) +bool are_counts_ok(Rtree const& tree, bool check_min = true) { typedef utilities::view RTV; RTV rtv(tree); visitors::are_counts_ok< - typename RTV::value_type, - typename RTV::options_type, - typename RTV::box_type, - typename RTV::allocators_type - > v(tree.parameters()); + typename RTV::members_holder + > v(tree.parameters(), check_min); rtv.apply_visitor(v); diff --git a/include/boost/geometry/index/detail/rtree/utilities/are_levels_ok.hpp b/include/boost/geometry/index/detail/rtree/utilities/are_levels_ok.hpp index 4860dbcb9..a76cf38bf 100644 --- a/include/boost/geometry/index/detail/rtree/utilities/are_levels_ok.hpp +++ b/include/boost/geometry/index/detail/rtree/utilities/are_levels_ok.hpp @@ -4,6 +4,10 @@ // // Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland. // +// This file was modified by Oracle on 2019. +// Modifications copyright (c) 2019 Oracle and/or its affiliates. +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle +// // Use, modification and distribution is subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) @@ -17,12 +21,12 @@ namespace boost { namespace geometry { namespace index { namespace detail { name namespace visitors { -template +template class are_levels_ok - : public rtree::visitor::type + : public MembersHolder::visitor_const { - typedef typename rtree::internal_node::type internal_node; - typedef typename rtree::leaf::type leaf; + typedef typename MembersHolder::internal_node internal_node; + typedef typename MembersHolder::leaf leaf; public: inline are_levels_ok() @@ -93,10 +97,7 @@ bool are_levels_ok(Rtree const& tree) RTV rtv(tree); visitors::are_levels_ok< - typename RTV::value_type, - typename RTV::options_type, - typename RTV::box_type, - typename RTV::allocators_type + typename RTV::members_holder > v; rtv.apply_visitor(v); diff --git a/include/boost/geometry/index/detail/rtree/utilities/gl_draw.hpp b/include/boost/geometry/index/detail/rtree/utilities/gl_draw.hpp index 84201b6af..25c08dba0 100644 --- a/include/boost/geometry/index/detail/rtree/utilities/gl_draw.hpp +++ b/include/boost/geometry/index/detail/rtree/utilities/gl_draw.hpp @@ -4,6 +4,10 @@ // // Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland. // +// This file was modified by Oracle on 2019. +// Modifications copyright (c) 2019 Oracle and/or its affiliates. +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle +// // Use, modification and distribution is subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) @@ -114,16 +118,20 @@ namespace rtree { namespace utilities { namespace visitors { -template -struct gl_draw : public rtree::visitor::type +template +struct gl_draw + : public MembersHolder::visitor_const { - typedef typename rtree::internal_node::type internal_node; - typedef typename rtree::leaf::type leaf; + typedef typename MembersHolder::box_type box_type; + typedef typename MembersHolder::translator_type translator_type; - inline gl_draw(Translator const& t, + typedef typename MembersHolder::internal_node internal_node; + typedef typename MembersHolder::leaf leaf; + + inline gl_draw(translator_type const& t, size_t level_first = 0, size_t level_last = (std::numeric_limits::max)(), - typename coordinate_type::type z_coord_level_multiplier = 1 + typename coordinate_type::type z_coord_level_multiplier = 1 ) : tr(t) , level_f(level_first) @@ -197,10 +205,10 @@ struct gl_draw : public rtree::visitor::type z_mul; + typename coordinate_type::type z_mul; size_t level; }; @@ -226,11 +234,7 @@ void gl_draw(Rtree const& tree, } visitors::gl_draw< - typename RTV::value_type, - typename RTV::options_type, - typename RTV::translator_type, - typename RTV::box_type, - typename RTV::allocators_type + typename RTV::members_holder > gl_draw_v(rtv.translator(), level_first, level_last, z_coord_level_multiplier); rtv.apply_visitor(gl_draw_v); diff --git a/include/boost/geometry/index/detail/rtree/utilities/print.hpp b/include/boost/geometry/index/detail/rtree/utilities/print.hpp index 4c42659c6..d512add24 100644 --- a/include/boost/geometry/index/detail/rtree/utilities/print.hpp +++ b/include/boost/geometry/index/detail/rtree/utilities/print.hpp @@ -4,6 +4,10 @@ // // Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland. // +// This file was modified by Oracle on 2019. +// Modifications copyright (c) 2019 Oracle and/or its affiliates. +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle +// // Use, modification and distribution is subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) @@ -129,13 +133,16 @@ namespace rtree { namespace utilities { namespace visitors { -template -struct print : public rtree::visitor::type +template +struct print + : public MembersHolder::visitor_const { - typedef typename rtree::internal_node::type internal_node; - typedef typename rtree::leaf::type leaf; + typedef typename MembersHolder::translator_type translator_type; - inline print(std::ostream & o, Translator const& t) + typedef typename MembersHolder::internal_node internal_node; + typedef typename MembersHolder::leaf leaf; + + inline print(std::ostream & o, translator_type const& t) : os(o), tr(t), level(0) {} @@ -189,7 +196,7 @@ struct print : public rtree::visitor print_v(os, rtv.translator()); rtv.apply_visitor(print_v); } diff --git a/include/boost/geometry/index/detail/rtree/utilities/statistics.hpp b/include/boost/geometry/index/detail/rtree/utilities/statistics.hpp index bbaed8100..169253510 100644 --- a/include/boost/geometry/index/detail/rtree/utilities/statistics.hpp +++ b/include/boost/geometry/index/detail/rtree/utilities/statistics.hpp @@ -5,6 +5,10 @@ // Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland. // Copyright (c) 2013 Mateusz Loskot, London, UK. // +// This file was modified by Oracle on 2019. +// Modifications copyright (c) 2019 Oracle and/or its affiliates. +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle +// // Use, modification and distribution is subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) @@ -19,11 +23,12 @@ namespace boost { namespace geometry { namespace index { namespace detail { name namespace visitors { -template -struct statistics : public rtree::visitor::type +template +struct statistics + : public MembersHolder::visitor_const { - typedef typename rtree::internal_node::type internal_node; - typedef typename rtree::leaf::type leaf; + typedef typename MembersHolder::internal_node internal_node; + typedef typename MembersHolder::leaf leaf; inline statistics() : level(0) @@ -89,10 +94,7 @@ statistics(Rtree const& tree) RTV rtv(tree); visitors::statistics< - typename RTV::value_type, - typename RTV::options_type, - typename RTV::box_type, - typename RTV::allocators_type + typename RTV::members_holder > stats_v; rtv.apply_visitor(stats_v); diff --git a/include/boost/geometry/index/detail/rtree/utilities/view.hpp b/include/boost/geometry/index/detail/rtree/utilities/view.hpp index 6dbbd07bf..edaa045ac 100644 --- a/include/boost/geometry/index/detail/rtree/utilities/view.hpp +++ b/include/boost/geometry/index/detail/rtree/utilities/view.hpp @@ -4,6 +4,10 @@ // // Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland. // +// This file was modified by Oracle on 2019. +// Modifications copyright (c) 2019 Oracle and/or its affiliates. +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle +// // Use, modification and distribution is subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) @@ -19,6 +23,8 @@ template class view { public: + typedef typename Rtree::members_holder members_holder; + typedef typename Rtree::size_type size_type; typedef typename Rtree::translator_type translator_type; diff --git a/include/boost/geometry/index/detail/rtree/visitors/children_box.hpp b/include/boost/geometry/index/detail/rtree/visitors/children_box.hpp index 0d26a79c3..1dde1408c 100644 --- a/include/boost/geometry/index/detail/rtree/visitors/children_box.hpp +++ b/include/boost/geometry/index/detail/rtree/visitors/children_box.hpp @@ -19,17 +19,21 @@ namespace boost { namespace geometry { namespace index { namespace detail { namespace rtree { namespace visitors { -template +template class children_box - : public rtree::visitor::type + : public MembersHolder::visitor_const { - typedef typename Options::parameters_type parameters_type; + typedef typename MembersHolder::parameters_type parameters_type; + typedef typename MembersHolder::translator_type translator_type; + typedef typename MembersHolder::box_type box_type; - typedef typename rtree::internal_node::type internal_node; - typedef typename rtree::leaf::type leaf; + typedef typename MembersHolder::internal_node internal_node; + typedef typename MembersHolder::leaf leaf; public: - inline children_box(Box & result, parameters_type const& parameters, Translator const& tr) + inline children_box(box_type & result, + parameters_type const& parameters, + translator_type const& tr) : m_result(result), m_parameters(parameters), m_tr(tr) {} @@ -38,8 +42,8 @@ public: typedef typename rtree::elements_type::type elements_type; elements_type const& elements = rtree::elements(n); - m_result = rtree::elements_box(elements.begin(), elements.end(), m_tr, - index::detail::get_strategy(m_parameters)); + m_result = rtree::elements_box(elements.begin(), elements.end(), m_tr, + index::detail::get_strategy(m_parameters)); } inline void operator()(leaf const& n) @@ -47,14 +51,14 @@ public: typedef typename rtree::elements_type::type elements_type; elements_type const& elements = rtree::elements(n); - m_result = rtree::values_box(elements.begin(), elements.end(), m_tr, - index::detail::get_strategy(m_parameters)); + m_result = rtree::values_box(elements.begin(), elements.end(), m_tr, + index::detail::get_strategy(m_parameters)); } private: - Box & m_result; + box_type & m_result; parameters_type const& m_parameters; - Translator const& m_tr; + translator_type const& m_tr; }; }}} // namespace detail::rtree::visitors diff --git a/include/boost/geometry/index/detail/rtree/visitors/copy.hpp b/include/boost/geometry/index/detail/rtree/visitors/copy.hpp index 86ffc99ca..1dee43d63 100644 --- a/include/boost/geometry/index/detail/rtree/visitors/copy.hpp +++ b/include/boost/geometry/index/detail/rtree/visitors/copy.hpp @@ -4,6 +4,10 @@ // // Copyright (c) 2011-2015 Adam Wulkiewicz, Lodz, Poland. // +// This file was modified by Oracle on 2019. +// Modifications copyright (c) 2019 Oracle and/or its affiliates. +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle +// // Use, modification and distribution is subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) @@ -11,30 +15,34 @@ #ifndef BOOST_GEOMETRY_INDEX_DETAIL_RTREE_VISITORS_COPY_HPP #define BOOST_GEOMETRY_INDEX_DETAIL_RTREE_VISITORS_COPY_HPP +#include + namespace boost { namespace geometry { namespace index { namespace detail { namespace rtree { namespace visitors { -template +template class copy - : public rtree::visitor::type + : public MembersHolder::visitor { + typedef typename MembersHolder::allocators_type allocators_type; + + typedef typename MembersHolder::node node; + typedef typename MembersHolder::internal_node internal_node; + typedef typename MembersHolder::leaf leaf; + + typedef rtree::subtree_destroyer subtree_destroyer; + typedef typename allocators_type::node_pointer node_pointer; + public: - typedef typename rtree::node::type node; - typedef typename rtree::internal_node::type internal_node; - typedef typename rtree::leaf::type leaf; - - typedef rtree::subtree_destroyer subtree_destroyer; - typedef typename Allocators::node_pointer node_pointer; - - explicit inline copy(Allocators & allocators) + explicit inline copy(allocators_type & allocators) : result(0) , m_allocators(allocators) {} inline void operator()(internal_node & n) { - node_pointer raw_new_node = rtree::create_node::apply(m_allocators); // MAY THROW, STRONG (N: alloc) + node_pointer raw_new_node = rtree::create_node::apply(m_allocators); // MAY THROW, STRONG (N: alloc) subtree_destroyer new_node(raw_new_node, m_allocators); typedef typename rtree::elements_type::type elements_type; @@ -61,7 +69,7 @@ public: inline void operator()(leaf & l) { - node_pointer raw_new_node = rtree::create_node::apply(m_allocators); // MAY THROW, STRONG (N: alloc) + node_pointer raw_new_node = rtree::create_node::apply(m_allocators); // MAY THROW, STRONG (N: alloc) subtree_destroyer new_node(raw_new_node, m_allocators); typedef typename rtree::elements_type::type elements_type; @@ -82,7 +90,7 @@ public: node_pointer result; private: - Allocators & m_allocators; + allocators_type & m_allocators; }; }}} // namespace detail::rtree::visitors diff --git a/include/boost/geometry/index/detail/rtree/visitors/count.hpp b/include/boost/geometry/index/detail/rtree/visitors/count.hpp index 2cdbd8c0e..c166fe3e3 100644 --- a/include/boost/geometry/index/detail/rtree/visitors/count.hpp +++ b/include/boost/geometry/index/detail/rtree/visitors/count.hpp @@ -49,19 +49,21 @@ struct count_helper } }; -template +template struct count - : public rtree::visitor::type + : public MembersHolder::visitor_const { - typedef typename Options::parameters_type parameters_type; + typedef typename MembersHolder::value_type value_type; + typedef typename MembersHolder::parameters_type parameters_type; + typedef typename MembersHolder::translator_type translator_type; - typedef typename rtree::node::type node; - typedef typename rtree::internal_node::type internal_node; - typedef typename rtree::leaf::type leaf; + typedef typename MembersHolder::node node; + typedef typename MembersHolder::internal_node internal_node; + typedef typename MembersHolder::leaf leaf; - typedef count_helper count_help; + typedef count_helper count_help; - inline count(ValueOrIndexable const& vori, parameters_type const& parameters, Translator const& t) + inline count(ValueOrIndexable const& vori, parameters_type const& parameters, translator_type const& t) : value_or_indexable(vori), m_parameters(parameters), tr(t), found_count(0) {} @@ -103,8 +105,8 @@ struct count ValueOrIndexable const& value_or_indexable; parameters_type const& m_parameters; - Translator const& tr; - typename Allocators::size_type found_count; + translator_type const& tr; + typename MembersHolder::size_type found_count; }; }}} // namespace detail::rtree::visitors diff --git a/include/boost/geometry/index/detail/rtree/visitors/destroy.hpp b/include/boost/geometry/index/detail/rtree/visitors/destroy.hpp index b4a800eac..4afb867cd 100644 --- a/include/boost/geometry/index/detail/rtree/visitors/destroy.hpp +++ b/include/boost/geometry/index/detail/rtree/visitors/destroy.hpp @@ -4,6 +4,10 @@ // // Copyright (c) 2011-2014 Adam Wulkiewicz, Lodz, Poland. // +// This file was modified by Oracle on 2019. +// Modifications copyright (c) 2019 Oracle and/or its affiliates. +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle +// // Use, modification and distribution is subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) @@ -15,19 +19,20 @@ namespace boost { namespace geometry { namespace index { namespace detail { namespace rtree { namespace visitors { -template +template class destroy - : public rtree::visitor::type + : public MembersHolder::visitor { public: - typedef typename rtree::node::type node; - typedef typename rtree::internal_node::type internal_node; - typedef typename rtree::leaf::type leaf; + typedef typename MembersHolder::node node; + typedef typename MembersHolder::internal_node internal_node; + typedef typename MembersHolder::leaf leaf; - typedef typename Allocators::node_pointer node_pointer; + typedef typename MembersHolder::allocators_type allocators_type; + typedef typename MembersHolder::node_pointer node_pointer; - inline destroy(node_pointer root_node, Allocators & allocators) - : m_current_node(root_node) + inline destroy(node_pointer node, allocators_type & allocators) + : m_current_node(node) , m_allocators(allocators) {} @@ -48,7 +53,7 @@ public: it->second = 0; } - rtree::destroy_node::apply(m_allocators, node_to_destroy); + rtree::destroy_node::apply(m_allocators, node_to_destroy); } inline void operator()(leaf & l) @@ -56,12 +61,18 @@ public: boost::ignore_unused(l); BOOST_GEOMETRY_INDEX_ASSERT(&l == &rtree::get(*m_current_node), "invalid pointers"); - rtree::destroy_node::apply(m_allocators, m_current_node); + rtree::destroy_node::apply(m_allocators, m_current_node); + } + + static inline void apply(node_pointer node, allocators_type & allocators) + { + destroy v(node, allocators); + rtree::apply_visitor(v, *node); } private: node_pointer m_current_node; - Allocators & m_allocators; + allocators_type & m_allocators; }; }}} // namespace detail::rtree::visitors diff --git a/include/boost/geometry/index/detail/rtree/visitors/distance_query.hpp b/include/boost/geometry/index/detail/rtree/visitors/distance_query.hpp index 20a954dc4..edf47f90b 100644 --- a/include/boost/geometry/index/detail/rtree/visitors/distance_query.hpp +++ b/include/boost/geometry/index/detail/rtree/visitors/distance_query.hpp @@ -93,39 +93,41 @@ private: std::vector< std::pair > m_neighbors; }; -template < - typename Value, - typename Options, - typename Translator, - typename Box, - typename Allocators, +template +< + typename MembersHolder, typename Predicates, unsigned DistancePredicateIndex, typename OutIter > class distance_query - : public rtree::visitor::type + : public MembersHolder::visitor_const { public: - typedef typename Options::parameters_type parameters_type; + typedef typename MembersHolder::value_type value_type; + typedef typename MembersHolder::box_type box_type; + typedef typename MembersHolder::parameters_type parameters_type; + typedef typename MembersHolder::translator_type translator_type; + typedef typename MembersHolder::allocators_type allocators_type; + typedef typename index::detail::strategy_type::type strategy_type; - typedef typename rtree::node::type node; - typedef typename rtree::internal_node::type internal_node; - typedef typename rtree::leaf::type leaf; + typedef typename MembersHolder::node node; + typedef typename MembersHolder::internal_node internal_node; + typedef typename MembersHolder::leaf leaf; typedef index::detail::predicates_element nearest_predicate_access; typedef typename nearest_predicate_access::type nearest_predicate_type; - typedef typename indexable_type::type indexable_type; + typedef typename indexable_type::type indexable_type; typedef index::detail::calculate_distance calculate_value_distance; - typedef index::detail::calculate_distance calculate_node_distance; + typedef index::detail::calculate_distance calculate_node_distance; typedef typename calculate_value_distance::result_type value_distance_type; typedef typename calculate_node_distance::result_type node_distance_type; static const unsigned predicates_len = index::detail::predicates_length::value; - inline distance_query(parameters_type const& parameters, Translator const& translator, Predicates const& pred, OutIter out_it) + inline distance_query(parameters_type const& parameters, translator_type const& translator, Predicates const& pred, OutIter out_it) : m_parameters(parameters), m_translator(translator) , m_pred(pred) , m_result(nearest_predicate_access::get(m_pred).count, out_it) @@ -139,7 +141,7 @@ public: // array of active nodes typedef typename index::detail::rtree::container_from_elements_type< elements_type, - std::pair + std::pair >::type active_branch_list_type; active_branch_list_type active_branch_list; @@ -261,15 +263,15 @@ public: private: static inline bool abl_less( - std::pair const& p1, - std::pair const& p2) + std::pair const& p1, + std::pair const& p2) { return p1.first < p2.first; } //static inline bool abl_greater( - // std::pair const& p1, - // std::pair const& p2) + // std::pair const& p1, + // std::pair const& p2) //{ // return p1.first > p2.first; //} @@ -286,46 +288,47 @@ private: } parameters_type const& m_parameters; - Translator const& m_translator; + translator_type const& m_translator; Predicates m_pred; - distance_query_result m_result; + distance_query_result m_result; strategy_type m_strategy; }; template < - typename Value, - typename Options, - typename Translator, - typename Box, - typename Allocators, + typename MembersHolder, typename Predicates, unsigned DistancePredicateIndex > class distance_query_incremental - : public rtree::visitor::type + : public MembersHolder::visitor_const { public: - typedef typename Options::parameters_type parameters_type; + typedef typename MembersHolder::value_type value_type; + typedef typename MembersHolder::box_type box_type; + typedef typename MembersHolder::parameters_type parameters_type; + typedef typename MembersHolder::translator_type translator_type; + typedef typename MembersHolder::allocators_type allocators_type; + typedef typename index::detail::strategy_type::type strategy_type; - typedef typename rtree::node::type node; - typedef typename rtree::internal_node::type internal_node; - typedef typename rtree::leaf::type leaf; + typedef typename MembersHolder::node node; + typedef typename MembersHolder::internal_node internal_node; + typedef typename MembersHolder::leaf leaf; typedef index::detail::predicates_element nearest_predicate_access; typedef typename nearest_predicate_access::type nearest_predicate_type; - typedef typename indexable_type::type indexable_type; + typedef typename indexable_type::type indexable_type; typedef index::detail::calculate_distance calculate_value_distance; - typedef index::detail::calculate_distance calculate_node_distance; + typedef index::detail::calculate_distance calculate_node_distance; typedef typename calculate_value_distance::result_type value_distance_type; typedef typename calculate_node_distance::result_type node_distance_type; - typedef typename Allocators::size_type size_type; - typedef typename Allocators::const_reference const_reference; - typedef typename Allocators::node_pointer node_pointer; + typedef typename allocators_type::size_type size_type; + typedef typename allocators_type::const_reference const_reference; + typedef typename allocators_type::node_pointer node_pointer; static const unsigned predicates_len = index::detail::predicates_length::value; @@ -362,7 +365,7 @@ public: // , m_strategy_type() {} - inline distance_query_incremental(parameters_type const& params, Translator const& translator, Predicates const& pred) + inline distance_query_incremental(parameters_type const& params, translator_type const& translator, Predicates const& pred) : m_translator(::boost::addressof(translator)) , m_pred(pred) , current_neighbor((std::numeric_limits::max)()) @@ -552,14 +555,14 @@ public: } private: - static inline bool abl_less(std::pair const& p1, - std::pair const& p2) + static inline bool abl_less(std::pair const& p1, + std::pair const& p2) { return p1.first < p2.first; } - static inline bool neighbors_less(std::pair const& p1, - std::pair const& p2) + static inline bool neighbors_less(std::pair const& p1, + std::pair const& p2) { return p1.first < p2.first; } @@ -597,12 +600,12 @@ private: return nearest_predicate_access::get(m_pred); } - const Translator * m_translator; + const translator_type * m_translator; Predicates m_pred; internal_stack_type internal_stack; - std::vector< std::pair > neighbors; + std::vector< std::pair > neighbors; size_type current_neighbor; node_distance_type next_closest_node_distance; diff --git a/include/boost/geometry/index/detail/rtree/visitors/insert.hpp b/include/boost/geometry/index/detail/rtree/visitors/insert.hpp index 3c9501f37..2d324cb7f 100644 --- a/include/boost/geometry/index/detail/rtree/visitors/insert.hpp +++ b/include/boost/geometry/index/detail/rtree/visitors/insert.hpp @@ -23,27 +23,34 @@ #include #include +#include + namespace boost { namespace geometry { namespace index { namespace detail { namespace rtree { // Default choose_next_node -template +template +< + typename MembersHolder, + typename ChooseNextNodeTag = typename MembersHolder::options_type::choose_next_node_tag +> class choose_next_node; -template -class choose_next_node +template +class choose_next_node { public: - typedef typename Options::parameters_type parameters_type; + typedef typename MembersHolder::box_type box_type; + typedef typename MembersHolder::parameters_type parameters_type; - typedef typename rtree::node::type node; - typedef typename rtree::internal_node::type internal_node; - typedef typename rtree::leaf::type leaf; + typedef typename MembersHolder::node node; + typedef typename MembersHolder::internal_node internal_node; + typedef typename MembersHolder::leaf leaf; typedef typename rtree::elements_type::type children_type; - typedef typename index::detail::default_content_result::type content_type; + typedef typename index::detail::default_content_result::type content_type; template static inline size_t apply(internal_node & n, @@ -69,7 +76,7 @@ public: child_type const& ch_i = children[i]; // expanded child node's box - Box box_exp(ch_i.first); + box_type box_exp(ch_i.first); index::detail::expand(box_exp, indexable, index::detail::get_strategy(parameters)); @@ -94,7 +101,11 @@ public: // ----------------------------------------------------------------------- // // Not implemented here -template +template +< + typename MembersHolder, + typename RedistributeTag = typename MembersHolder::options_type::redistribute_tag +> struct redistribute_elements { BOOST_MPL_ASSERT_MSG( @@ -106,7 +117,11 @@ struct redistribute_elements // ----------------------------------------------------------------------- // // Split algorithm -template +template +< + typename MembersHolder, + typename SplitTag = typename MembersHolder::options_type::split_tag +> class split { BOOST_MPL_ASSERT_MSG( @@ -116,17 +131,21 @@ class split }; // Default split algorithm -template -class split +template +class split { protected: - typedef typename Options::parameters_type parameters_type; + typedef typename MembersHolder::parameters_type parameters_type; + typedef typename MembersHolder::box_type box_type; + typedef typename MembersHolder::translator_type translator_type; + typedef typename MembersHolder::allocators_type allocators_type; + typedef typename MembersHolder::size_type size_type; - typedef typename rtree::node::type node; - typedef typename rtree::internal_node::type internal_node; - typedef typename rtree::leaf::type leaf; + typedef typename MembersHolder::node node; + typedef typename MembersHolder::internal_node internal_node; + typedef typename MembersHolder::leaf leaf; - typedef rtree::subtree_destroyer subtree_destroyer; + typedef typename MembersHolder::node_pointer node_pointer; public: typedef index::detail::varray< @@ -137,51 +156,63 @@ public: template static inline void apply(nodes_container_type & additional_nodes, Node & n, - Box & n_box, + box_type & n_box, parameters_type const& parameters, - Translator const& translator, - Allocators & allocators) + translator_type const& translator, + allocators_type & allocators) { // TODO - consider creating nodes always with sufficient memory allocated // create additional node, use auto destroyer for automatic destruction on exception - subtree_destroyer second_node(rtree::create_node::apply(allocators), allocators); // MAY THROW, STRONG (N: alloc) + node_pointer n2_ptr = rtree::create_node::apply(allocators); // MAY THROW, STRONG (N: alloc) // create reference to the newly created node - Node & n2 = rtree::get(*second_node); + Node & n2 = rtree::get(*n2_ptr); - // NOTE: thread-safety - // After throwing an exception by redistribute_elements the original node may be not changed or - // both nodes may be empty. In both cases the tree won't be valid r-tree. - // The alternative is to create 2 (or more) additional nodes here and store backup info - // in the original node, then, if exception was thrown, the node would always have more than max - // elements. - // The alternative is to use moving semantics in the implementations of redistribute_elements, - // it will be possible to throw from boost::move() in the case of e.g. static size nodes. + BOOST_TRY + { + // NOTE: thread-safety + // After throwing an exception by redistribute_elements the original node may be not changed or + // both nodes may be empty. In both cases the tree won't be valid r-tree. + // The alternative is to create 2 (or more) additional nodes here and store backup info + // in the original node, then, if exception was thrown, the node would always have more than max + // elements. + // The alternative is to use moving semantics in the implementations of redistribute_elements, + // it will be possible to throw from boost::move() in the case of e.g. static size nodes. - // redistribute elements - Box box2; - redistribute_elements< - Value, - Options, - Translator, - Box, - Allocators, - typename Options::redistribute_tag - >::apply(n, n2, n_box, box2, parameters, translator, allocators); // MAY THROW (V, E: alloc, copy, copy) + // redistribute elements + box_type box2; + redistribute_elements + ::apply(n, n2, n_box, box2, parameters, translator, allocators); // MAY THROW (V, E: alloc, copy, copy) - // check numbers of elements - BOOST_GEOMETRY_INDEX_ASSERT(parameters.get_min_elements() <= rtree::elements(n).size() && - rtree::elements(n).size() <= parameters.get_max_elements(), - "unexpected number of elements"); - BOOST_GEOMETRY_INDEX_ASSERT(parameters.get_min_elements() <= rtree::elements(n2).size() && - rtree::elements(n2).size() <= parameters.get_max_elements(), - "unexpected number of elements"); + // check numbers of elements + BOOST_GEOMETRY_INDEX_ASSERT(parameters.get_min_elements() <= rtree::elements(n).size() && + rtree::elements(n).size() <= parameters.get_max_elements(), + "unexpected number of elements"); + BOOST_GEOMETRY_INDEX_ASSERT(parameters.get_min_elements() <= rtree::elements(n2).size() && + rtree::elements(n2).size() <= parameters.get_max_elements(), + "unexpected number of elements"); - // return the list of newly created nodes (this algorithm returns one) - additional_nodes.push_back(rtree::make_ptr_pair(box2, second_node.get())); // MAY THROW, STRONG (alloc, copy) + // return the list of newly created nodes (this algorithm returns one) + additional_nodes.push_back(rtree::make_ptr_pair(box2, n2_ptr)); // MAY THROW, STRONG (alloc, copy) + } + BOOST_CATCH(...) + { + // NOTE: This code is here to prevent leaving the rtree in a state + // after an exception is thrown in which pushing new element could + // result in assert or putting it outside the memory of node elements. + typename rtree::elements_type::type & elements = rtree::elements(n); + size_type const max_size = parameters.get_max_elements(); + if (elements.size() > max_size) + { + rtree::destroy_element::apply(elements[max_size], allocators); + elements.pop_back(); + } - // release the ptr - second_node.release(); + rtree::visitors::destroy::apply(n2_ptr, allocators); + + BOOST_RETHROW + } + BOOST_CATCH_END } }; @@ -232,30 +263,34 @@ struct insert_traverse_data }; // Default insert visitor -template +template class insert - : public rtree::visitor::type + : MembersHolder::visitor { protected: - typedef typename Options::parameters_type parameters_type; + typedef typename MembersHolder::box_type box_type; + typedef typename MembersHolder::value_type value_type; + typedef typename MembersHolder::parameters_type parameters_type; + typedef typename MembersHolder::translator_type translator_type; + typedef typename MembersHolder::allocators_type allocators_type; - typedef typename rtree::node::type node; - typedef typename rtree::internal_node::type internal_node; - typedef typename rtree::leaf::type leaf; + typedef typename MembersHolder::node node; + typedef typename MembersHolder::internal_node internal_node; + typedef typename MembersHolder::leaf leaf; - typedef rtree::subtree_destroyer subtree_destroyer; - typedef typename Allocators::node_pointer node_pointer; - typedef typename Allocators::size_type size_type; + typedef rtree::subtree_destroyer subtree_destroyer; + typedef typename allocators_type::node_pointer node_pointer; + typedef typename allocators_type::size_type size_type; - //typedef typename Allocators::internal_node_pointer internal_node_pointer; + //typedef typename allocators_type::internal_node_pointer internal_node_pointer; typedef internal_node * internal_node_pointer; inline insert(node_pointer & root, size_type & leafs_level, Element const& element, parameters_type const& parameters, - Translator const& translator, - Allocators & allocators, + translator_type const& translator, + allocators_type & allocators, size_type relative_level = 0 ) : m_element(element) @@ -289,10 +324,10 @@ protected: // It's because Points and Segments are compared WRT machine epsilon // This ensures that leafs bounds correspond to the stored elements if (BOOST_GEOMETRY_CONDITION(( - boost::is_same::value + boost::is_same::value && ! index::detail::is_bounding_geometry < - typename indexable_type::type + typename indexable_type::type >::value )) ) { geometry::detail::expand_by_epsilon(m_element_bounds); @@ -304,8 +339,10 @@ protected: inline void traverse(Visitor & visitor, internal_node & n) { // choose next node - size_t choosen_node_index = rtree::choose_next_node:: - apply(n, rtree::element_indexable(m_element, m_translator), m_parameters, m_leafs_level - m_traverse_data.current_level); + size_t choosen_node_index = rtree::choose_next_node + ::apply(n, rtree::element_indexable(m_element, m_translator), + m_parameters, + m_leafs_level - m_traverse_data.current_level); // expand the node to contain value index::detail::expand( @@ -357,10 +394,10 @@ protected: template inline void split(Node & n) const { - typedef rtree::split split_algo; + typedef rtree::split split_algo; typename split_algo::nodes_container_type additional_nodes; - Box n_box; + box_type n_box; split_algo::apply(additional_nodes, n, n_box, m_parameters, m_translator, m_allocators); // MAY THROW (V, E: alloc, copy, N:alloc) @@ -387,7 +424,7 @@ protected: boost::is_same::value && ! index::detail::is_bounding_geometry < - typename indexable_type::type + typename indexable_type::type >::value ))) { geometry::detail::expand_by_epsilon(n_box); @@ -409,7 +446,7 @@ protected: BOOST_GEOMETRY_INDEX_ASSERT(&n == &rtree::get(*m_root_node), "node should be the root"); // create new root and add nodes - subtree_destroyer new_root(rtree::create_node::apply(m_allocators), m_allocators); // MAY THROW, STRONG (N:alloc) + subtree_destroyer new_root(rtree::create_node::apply(m_allocators), m_allocators); // MAY THROW, STRONG (N:alloc) BOOST_TRY { @@ -436,9 +473,9 @@ protected: // TODO: awulkiew - implement dispatchable split::apply to enable additional nodes creation Element const& m_element; - Box m_element_bounds; + box_type m_element_bounds; parameters_type const& m_parameters; - Translator const& m_translator; + translator_type const& m_translator; size_type const m_relative_level; size_type const m_level; @@ -448,30 +485,39 @@ protected: // traversing input parameters insert_traverse_data m_traverse_data; - Allocators & m_allocators; + allocators_type & m_allocators; }; } // namespace detail // Insert visitor forward declaration -template +template +< + typename Element, + typename MembersHolder, + typename InsertTag = typename MembersHolder::options_type::insert_tag +> class insert; // Default insert visitor used for nodes elements // After passing the Element to insert visitor the Element is managed by the tree // I.e. one should not delete the node passed to the insert visitor after exception is thrown // because this visitor may delete it -template -class insert - : public detail::insert +template +class insert + : public detail::insert { public: - typedef detail::insert base; + typedef detail::insert base; + + typedef typename base::parameters_type parameters_type; + typedef typename base::translator_type translator_type; + typedef typename base::allocators_type allocators_type; + typedef typename base::node node; typedef typename base::internal_node internal_node; typedef typename base::leaf leaf; - typedef typename Options::parameters_type parameters_type; typedef typename base::node_pointer node_pointer; typedef typename base::size_type size_type; @@ -479,8 +525,8 @@ public: size_type & leafs_level, Element const& element, parameters_type const& parameters, - Translator const& translator, - Allocators & allocators, + translator_type const& translator, + allocators_type & allocators, size_type relative_level = 0 ) : base(root, leafs_level, element, parameters, translator, allocators, relative_level) @@ -508,8 +554,7 @@ public: { // if the insert fails above, the element won't be stored in the tree - rtree::visitors::destroy del_v(base::m_element.second, base::m_allocators); - rtree::apply_visitor(del_v, *base::m_element.second); + rtree::visitors::destroy::apply(base::m_element.second, base::m_allocators); BOOST_RETHROW // RETHROW } @@ -526,26 +571,31 @@ public: }; // Default insert visitor specialized for Values elements -template -class insert - : public detail::insert +template +class insert + : public detail::insert { public: - typedef detail::insert base; + typedef detail::insert base; + + typedef typename base::value_type value_type; + typedef typename base::parameters_type parameters_type; + typedef typename base::translator_type translator_type; + typedef typename base::allocators_type allocators_type; + typedef typename base::node node; typedef typename base::internal_node internal_node; typedef typename base::leaf leaf; - typedef typename Options::parameters_type parameters_type; typedef typename base::node_pointer node_pointer; typedef typename base::size_type size_type; inline insert(node_pointer & root, size_type & leafs_level, - Value const& value, + value_type const& value, parameters_type const& parameters, - Translator const& translator, - Allocators & allocators, + translator_type const& translator, + allocators_type & allocators, size_type relative_level = 0 ) : base(root, leafs_level, value, parameters, translator, allocators, relative_level) diff --git a/include/boost/geometry/index/detail/rtree/visitors/is_leaf.hpp b/include/boost/geometry/index/detail/rtree/visitors/is_leaf.hpp index dd2159c71..d4b8293ef 100644 --- a/include/boost/geometry/index/detail/rtree/visitors/is_leaf.hpp +++ b/include/boost/geometry/index/detail/rtree/visitors/is_leaf.hpp @@ -4,6 +4,10 @@ // // Copyright (c) 2011-2015 Adam Wulkiewicz, Lodz, Poland. // +// This file was modified by Oracle on 2019. +// Modifications copyright (c) 2019 Oracle and/or its affiliates. +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle +// // Use, modification and distribution is subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) @@ -15,11 +19,12 @@ namespace boost { namespace geometry { namespace index { namespace detail { namespace rtree { namespace visitors { -template -struct is_leaf : public rtree::visitor::type +template +struct is_leaf + : public MembersHolder::visitor_const { - typedef typename rtree::internal_node::type internal_node; - typedef typename rtree::leaf::type leaf; + typedef typename MembersHolder::internal_node internal_node; + typedef typename MembersHolder::leaf leaf; is_leaf() : result(false) diff --git a/include/boost/geometry/index/detail/rtree/visitors/remove.hpp b/include/boost/geometry/index/detail/rtree/visitors/remove.hpp index 1a3ccd796..59f486163 100644 --- a/include/boost/geometry/index/detail/rtree/visitors/remove.hpp +++ b/include/boost/geometry/index/detail/rtree/visitors/remove.hpp @@ -15,6 +15,7 @@ #ifndef BOOST_GEOMETRY_INDEX_DETAIL_RTREE_VISITORS_REMOVE_HPP #define BOOST_GEOMETRY_INDEX_DETAIL_RTREE_VISITORS_REMOVE_HPP +#include #include #include @@ -24,19 +25,23 @@ namespace boost { namespace geometry { namespace index { namespace detail { namespace rtree { namespace visitors { // Default remove algorithm -template +template class remove - : public rtree::visitor::type + : public MembersHolder::visitor { - typedef typename Options::parameters_type parameters_type; + typedef typename MembersHolder::box_type box_type; + typedef typename MembersHolder::value_type value_type; + typedef typename MembersHolder::parameters_type parameters_type; + typedef typename MembersHolder::translator_type translator_type; + typedef typename MembersHolder::allocators_type allocators_type; - typedef typename rtree::node::type node; - typedef typename rtree::internal_node::type internal_node; - typedef typename rtree::leaf::type leaf; + typedef typename MembersHolder::node node; + typedef typename MembersHolder::internal_node internal_node; + typedef typename MembersHolder::leaf leaf; - typedef rtree::subtree_destroyer subtree_destroyer; - typedef typename Allocators::node_pointer node_pointer; - typedef typename Allocators::size_type size_type; + typedef rtree::subtree_destroyer subtree_destroyer; + typedef typename allocators_type::node_pointer node_pointer; + typedef typename allocators_type::size_type size_type; typedef typename rtree::elements_type::type::size_type internal_size_type; @@ -46,10 +51,10 @@ class remove public: inline remove(node_pointer & root, size_type & leafs_level, - Value const& value, + value_type const& value, parameters_type const& parameters, - Translator const& translator, - Allocators & allocators) + translator_type const& translator, + allocators_type & allocators) : m_value(value) , m_parameters(parameters) , m_translator(translator) @@ -116,8 +121,8 @@ public: BOOST_GEOMETRY_INDEX_ASSERT((elements.size() < m_parameters.get_min_elements()) == m_is_underflow, "unexpected state"); rtree::elements(*m_parent)[m_current_child_index].first - = rtree::elements_box(elements.begin(), elements.end(), m_translator, - index::detail::get_strategy(m_parameters)); + = rtree::elements_box(elements.begin(), elements.end(), m_translator, + index::detail::get_strategy(m_parameters)); } // n is root node else @@ -140,7 +145,7 @@ public: m_root_node = rtree::elements(n)[0].second; --m_leafs_level; - rtree::destroy_node::apply(m_allocators, root_to_destroy); + rtree::destroy_node::apply(m_allocators, root_to_destroy); } } } @@ -175,8 +180,8 @@ public: if ( 0 != m_parent ) { rtree::elements(*m_parent)[m_current_child_index].first - = rtree::values_box(elements.begin(), elements.end(), m_translator, - index::detail::get_strategy(m_parameters)); + = rtree::values_box(elements.begin(), elements.end(), m_translator, + index::detail::get_strategy(m_parameters)); } } } @@ -188,7 +193,7 @@ public: private: - typedef std::vector< std::pair > UnderflowNodes; + typedef std::vector< std::pair > underflow_nodes; void traverse_apply_visitor(internal_node &n, internal_size_type choosen_node_index) { @@ -239,14 +244,14 @@ private: static inline bool is_leaf(node const& n) { - visitors::is_leaf ilv; + visitors::is_leaf ilv; rtree::apply_visitor(ilv, n); return ilv.result; } void reinsert_removed_nodes_elements() { - typename UnderflowNodes::reverse_iterator it = m_underflowed_nodes.rbegin(); + typename underflow_nodes::reverse_iterator it = m_underflowed_nodes.rbegin(); BOOST_TRY { @@ -262,13 +267,13 @@ private: { reinsert_node_elements(rtree::get(*it->second), it->first); // MAY THROW (V, E: alloc, copy, N: alloc) - rtree::destroy_node::apply(m_allocators, it->second); + rtree::destroy_node::apply(m_allocators, it->second); } else { reinsert_node_elements(rtree::get(*it->second), it->first); // MAY THROW (V, E: alloc, copy, N: alloc) - rtree::destroy_node::apply(m_allocators, it->second); + rtree::destroy_node::apply(m_allocators, it->second); } } @@ -279,7 +284,7 @@ private: // destroy current and remaining nodes for ( ; it != m_underflowed_nodes.rend() ; ++it ) { - subtree_destroyer dummy(it->second, m_allocators); + rtree::visitors::destroy::apply(it->second, m_allocators); } //m_underflowed_nodes.clear(); @@ -300,14 +305,10 @@ private: { for ( ; it != elements.end() ; ++it ) { - visitors::insert< - typename elements_type::value_type, - Value, Options, Translator, Box, Allocators, - typename Options::insert_tag - > insert_v( - m_root_node, m_leafs_level, *it, - m_parameters, m_translator, m_allocators, - node_relative_level - 1); + visitors::insert + insert_v(m_root_node, m_leafs_level, *it, + m_parameters, m_translator, m_allocators, + node_relative_level - 1); rtree::apply_visitor(insert_v, *m_root_node); // MAY THROW (V, E: alloc, copy, N: alloc) } @@ -315,24 +316,23 @@ private: BOOST_CATCH(...) { ++it; - rtree::destroy_elements - ::apply(it, elements.end(), m_allocators); + rtree::destroy_elements::apply(it, elements.end(), m_allocators); elements.clear(); BOOST_RETHROW // RETHROW } BOOST_CATCH_END } - Value const& m_value; + value_type const& m_value; parameters_type const& m_parameters; - Translator const& m_translator; - Allocators & m_allocators; + translator_type const& m_translator; + allocators_type & m_allocators; node_pointer & m_root_node; size_type & m_leafs_level; bool m_is_value_removed; - UnderflowNodes m_underflowed_nodes; + underflow_nodes m_underflowed_nodes; // traversing input parameters internal_node_pointer m_parent; diff --git a/include/boost/geometry/index/detail/rtree/visitors/spatial_query.hpp b/include/boost/geometry/index/detail/rtree/visitors/spatial_query.hpp index c94248cfd..cdef103b3 100644 --- a/include/boost/geometry/index/detail/rtree/visitors/spatial_query.hpp +++ b/include/boost/geometry/index/detail/rtree/visitors/spatial_query.hpp @@ -19,22 +19,25 @@ namespace boost { namespace geometry { namespace index { namespace detail { namespace rtree { namespace visitors { -template +template struct spatial_query - : public rtree::visitor::type + : public MembersHolder::visitor_const { - typedef typename Options::parameters_type parameters_type; + typedef typename MembersHolder::parameters_type parameters_type; + typedef typename MembersHolder::translator_type translator_type; + typedef typename MembersHolder::allocators_type allocators_type; + typedef typename index::detail::strategy_type::type strategy_type; - typedef typename rtree::node::type node; - typedef typename rtree::internal_node::type internal_node; - typedef typename rtree::leaf::type leaf; + typedef typename MembersHolder::node node; + typedef typename MembersHolder::internal_node internal_node; + typedef typename MembersHolder::leaf leaf; - typedef typename Allocators::size_type size_type; + typedef typename allocators_type::size_type size_type; static const unsigned predicates_len = index::detail::predicates_length::value; - inline spatial_query(parameters_type const& par, Translator const& t, Predicates const& p, OutIter out_it) + inline spatial_query(parameters_type const& par, translator_type const& t, Predicates const& p, OutIter out_it) : tr(t), pred(p), out_iter(out_it), found_count(0), strategy(index::detail::get_strategy(par)) {} @@ -82,7 +85,7 @@ struct spatial_query } } - Translator const& tr; + translator_type const& tr; Predicates pred; @@ -92,21 +95,25 @@ struct spatial_query strategy_type strategy; }; -template +template class spatial_query_incremental - : public rtree::visitor::type + : public MembersHolder::visitor_const { - typedef typename Options::parameters_type parameters_type; + typedef typename MembersHolder::value_type value_type; + typedef typename MembersHolder::parameters_type parameters_type; + typedef typename MembersHolder::translator_type translator_type; + typedef typename MembersHolder::allocators_type allocators_type; + typedef typename index::detail::strategy_type::type strategy_type; public: - typedef typename rtree::node::type node; - typedef typename rtree::internal_node::type internal_node; - typedef typename rtree::leaf::type leaf; + typedef typename MembersHolder::node node; + typedef typename MembersHolder::internal_node internal_node; + typedef typename MembersHolder::leaf leaf; - typedef typename Allocators::size_type size_type; - typedef typename Allocators::const_reference const_reference; - typedef typename Allocators::node_pointer node_pointer; + typedef typename allocators_type::size_type size_type; + typedef typename allocators_type::const_reference const_reference; + typedef typename allocators_type::node_pointer node_pointer; typedef typename rtree::elements_type::type::const_iterator internal_iterator; typedef typename rtree::elements_type::type leaf_elements; @@ -122,7 +129,7 @@ public: // , m_strategy() {} - inline spatial_query_incremental(parameters_type const& params, Translator const& t, Predicates const& p) + inline spatial_query_incremental(parameters_type const& params, translator_type const& t, Predicates const& p) : m_translator(::boost::addressof(t)) , m_pred(p) , m_values(NULL) @@ -172,7 +179,7 @@ public: if ( m_current != m_values->end() ) { // return if next value is found - Value const& v = *m_current; + value_type const& v = *m_current; if (index::detail::predicates_check < index::detail::value_tag, 0, predicates_len @@ -230,7 +237,7 @@ public: private: - const Translator * m_translator; + const translator_type * m_translator; Predicates m_pred; diff --git a/include/boost/geometry/index/detail/serialization.hpp b/include/boost/geometry/index/detail/serialization.hpp index 550a37565..14961d7f4 100644 --- a/include/boost/geometry/index/detail/serialization.hpp +++ b/include/boost/geometry/index/detail/serialization.hpp @@ -343,22 +343,29 @@ private: // TODO - move to index/detail/rtree/load.hpp namespace boost { namespace geometry { namespace index { namespace detail { namespace rtree { -template +template class load { - typedef typename rtree::node::type node; - typedef typename rtree::internal_node::type internal_node; - typedef typename rtree::leaf::type leaf; + typedef typename MembersHolder::parameters_type parameters_type; + typedef typename MembersHolder::translator_type translator_type; + typedef typename MembersHolder::allocators_type allocators_type; - typedef typename Options::parameters_type parameters_type; + typedef typename MembersHolder::node node; + typedef typename MembersHolder::internal_node internal_node; + typedef typename MembersHolder::leaf leaf; - typedef typename Allocators::node_pointer node_pointer; - typedef rtree::subtree_destroyer subtree_destroyer; - typedef typename Allocators::size_type size_type; + typedef typename allocators_type::node_pointer node_pointer; + typedef typename allocators_type::size_type size_type; + + typedef rtree::subtree_destroyer subtree_destroyer; public: template inline static - node_pointer apply(Archive & ar, unsigned int version, size_type leafs_level, size_type & values_count, parameters_type const& parameters, Translator const& translator, Allocators & allocators) + node_pointer apply(Archive & ar, unsigned int version, size_type leafs_level, + size_type & values_count, + parameters_type const& parameters, + translator_type const& translator, + allocators_type & allocators) { values_count = 0; return raw_apply(ar, version, leafs_level, values_count, parameters, translator, allocators); @@ -366,7 +373,12 @@ public: private: template inline static - node_pointer raw_apply(Archive & ar, unsigned int version, size_type leafs_level, size_type & values_count, parameters_type const& parameters, Translator const& translator, Allocators & allocators, size_type current_level = 0) + node_pointer raw_apply(Archive & ar, unsigned int version, size_type leafs_level, + size_type & values_count, + parameters_type const& parameters, + translator_type const& translator, + allocators_type & allocators, + size_type current_level = 0) { //BOOST_GEOMETRY_INDEX_ASSERT(current_level <= leafs_level, "invalid parameter"); diff --git a/include/boost/geometry/index/rtree.hpp b/include/boost/geometry/index/rtree.hpp index ab770fd6a..edf694743 100644 --- a/include/boost/geometry/index/rtree.hpp +++ b/include/boost/geometry/index/rtree.hpp @@ -190,51 +190,119 @@ public: private: - typedef detail::translator translator_type; - typedef bounds_type box_type; - typedef typename detail::rtree::options_type::type options_type; - typedef typename options_type::node_tag node_tag; - typedef detail::rtree::allocators - < - allocator_type, - value_type, - typename options_type::parameters_type, - box_type, - node_tag - > allocators_type; - typedef typename detail::rtree::node - < - value_type, - typename options_type::parameters_type, - box_type, - allocators_type, - node_tag - >::type node; - typedef typename detail::rtree::internal_node - < - value_type, - typename options_type::parameters_type, - box_type, - allocators_type, - node_tag - >::type internal_node; - typedef typename detail::rtree::leaf - < - value_type, - typename options_type::parameters_type, - box_type, - allocators_type, - node_tag - >::type leaf; + struct members_holder + : public detail::translator + , public Parameters + , public detail::rtree::allocators + < + Allocator, + Value, + Parameters, + bounds_type, + typename detail::rtree::options_type::type::node_tag + > + { + typedef Value value_type; + typedef typename rtree::bounds_type bounds_type; + typedef Parameters parameters_type; + //typedef IndexableGetter indexable_getter; + //typedef EqualTo value_equal; + //typedef Allocator allocator_type; - typedef typename allocators_type::node_pointer node_pointer; - typedef ::boost::container::allocator_traits allocator_traits_type; - typedef detail::rtree::subtree_destroyer - < - value_type, options_type, translator_type, box_type, allocators_type - > subtree_destroyer; + typedef bounds_type box_type; + typedef detail::translator translator_type; + typedef typename detail::rtree::options_type::type options_type; + typedef typename options_type::node_tag node_tag; + typedef detail::rtree::allocators + < + Allocator, Value, Parameters, bounds_type, node_tag + > allocators_type; + + typedef typename detail::rtree::node + < + value_type, parameters_type, bounds_type, allocators_type, node_tag + >::type node; + typedef typename detail::rtree::internal_node + < + value_type, parameters_type, bounds_type, allocators_type, node_tag + >::type internal_node; + typedef typename detail::rtree::leaf + < + value_type, parameters_type, bounds_type, allocators_type, node_tag + >::type leaf; + + // TODO: only one visitor type is needed + typedef typename detail::rtree::visitor + < + value_type, parameters_type, bounds_type, allocators_type, node_tag, false + >::type visitor; + typedef typename detail::rtree::visitor + < + value_type, parameters_type, bounds_type, allocators_type, node_tag, true + >::type visitor_const; + + typedef typename allocators_type::node_pointer node_pointer; + + typedef ::boost::container::allocator_traits allocator_traits_type; + typedef typename allocators_type::size_type size_type; + + private: + members_holder(members_holder const&); + members_holder & operator=(members_holder const&); + + public: + template + members_holder(IndGet const& ind_get, + ValEq const& val_eq, + Parameters const& parameters, + BOOST_FWD_REF(Alloc) alloc) + : translator_type(ind_get, val_eq) + , Parameters(parameters) + , allocators_type(boost::forward(alloc)) + , values_count(0) + , leafs_level(0) + , root(0) + {} + + template + members_holder(IndGet const& ind_get, + ValEq const& val_eq, + Parameters const& parameters) + : translator_type(ind_get, val_eq) + , Parameters(parameters) + , allocators_type() + , values_count(0) + , leafs_level(0) + , root(0) + {} + + translator_type const& translator() const { return *this; } + + IndexableGetter const& indexable_getter() const { return *this; } + IndexableGetter & indexable_getter() { return *this; } + EqualTo const& equal_to() const { return *this; } + EqualTo & equal_to() { return *this; } + Parameters const& parameters() const { return *this; } + Parameters & parameters() { return *this; } + allocators_type const& allocators() const { return *this; } + allocators_type & allocators() { return *this; } + + size_type values_count; + size_type leafs_level; + node_pointer root; + }; + + typedef typename members_holder::translator_type translator_type; + typedef typename members_holder::options_type options_type; + typedef typename members_holder::allocators_type allocators_type; + typedef typename members_holder::node node; + typedef typename members_holder::internal_node internal_node; + typedef typename members_holder::leaf leaf; + + typedef typename members_holder::node_pointer node_pointer; + typedef typename members_holder::allocator_traits_type allocator_traits_type; friend class detail::rtree::utilities::view; #ifdef BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL @@ -330,10 +398,11 @@ public: allocator_type const& allocator = allocator_type()) : m_members(getter, equal, parameters, allocator) { - typedef detail::rtree::pack pack; + typedef detail::rtree::pack pack; size_type vc = 0, ll = 0; m_members.root = pack::apply(first, last, vc, ll, - m_members.parameters(), m_members.translator(), m_members.allocators()); + m_members.parameters(), m_members.translator(), + m_members.allocators()); m_members.values_count = vc; m_members.leafs_level = ll; } @@ -362,10 +431,11 @@ public: allocator_type const& allocator = allocator_type()) : m_members(getter, equal, parameters, allocator) { - typedef detail::rtree::pack pack; + typedef detail::rtree::pack pack; size_type vc = 0, ll = 0; m_members.root = pack::apply(::boost::begin(rng), ::boost::end(rng), vc, ll, - m_members.parameters(), m_members.translator(), m_members.allocators()); + m_members.parameters(), m_members.translator(), + m_members.allocators()); m_members.values_count = vc; m_members.leafs_level = ll; } @@ -1023,9 +1093,9 @@ private: template typename boost::mpl::if_c< detail::predicates_count_distance::value == 0, - detail::rtree::iterators::spatial_query_iterator, + detail::rtree::iterators::spatial_query_iterator, detail::rtree::iterators::distance_query_iterator< - value_type, options_type, translator_type, box_type, allocators_type, Predicates, + members_holder, Predicates, detail::predicates_find_distance::value > >::type @@ -1036,9 +1106,9 @@ private: typedef typename boost::mpl::if_c< detail::predicates_count_distance::value == 0, - detail::rtree::iterators::spatial_query_iterator, + detail::rtree::iterators::spatial_query_iterator, detail::rtree::iterators::distance_query_iterator< - value_type, options_type, translator_type, box_type, allocators_type, Predicates, + members_holder, Predicates, detail::predicates_find_distance::value > >::type iterator_type; @@ -1084,9 +1154,9 @@ private: template typename boost::mpl::if_c< detail::predicates_count_distance::value == 0, - detail::rtree::iterators::spatial_query_iterator, + detail::rtree::iterators::spatial_query_iterator, detail::rtree::iterators::distance_query_iterator< - value_type, options_type, translator_type, box_type, allocators_type, Predicates, + members_holder, Predicates, detail::predicates_find_distance::value > >::type @@ -1097,9 +1167,9 @@ private: typedef typename boost::mpl::if_c< detail::predicates_count_distance::value == 0, - detail::rtree::iterators::spatial_query_iterator, + detail::rtree::iterators::spatial_query_iterator, detail::rtree::iterators::distance_query_iterator< - value_type, options_type, translator_type, box_type, allocators_type, Predicates, + members_holder, Predicates, detail::predicates_find_distance::value > >::type iterator_type; @@ -1305,7 +1375,7 @@ public: { detail::rtree::visitors::children_box < - value_type, options_type, translator_type, box_type, allocators_type + members_holder > box_v(result, m_members.parameters(), m_members.translator()); detail::rtree::apply_visitor(box_v, *m_members.root); } @@ -1468,12 +1538,9 @@ private: // CONSIDER: alternative - ignore invalid indexable or throw an exception BOOST_GEOMETRY_INDEX_ASSERT(detail::is_valid(m_members.translator()(value)), "Indexable is invalid"); - detail::rtree::visitors::insert< - value_type, - value_type, options_type, translator_type, box_type, allocators_type, - typename options_type::insert_tag - > insert_v(m_members.root, m_members.leafs_level, value, - m_members.parameters(), m_members.translator(), m_members.allocators()); + detail::rtree::visitors::insert + insert_v(m_members.root, m_members.leafs_level, value, + m_members.parameters(), m_members.translator(), m_members.allocators()); detail::rtree::apply_visitor(insert_v, *m_members.root); @@ -1499,10 +1566,9 @@ private: // TODO: awulkiew - assert for correct value (indexable) ? BOOST_GEOMETRY_INDEX_ASSERT(m_members.root, "The root must exist"); - detail::rtree::visitors::remove< - value_type, options_type, translator_type, box_type, allocators_type - > remove_v(m_members.root, m_members.leafs_level, value, - m_members.parameters(), m_members.translator(), m_members.allocators()); + detail::rtree::visitors::remove + remove_v(m_members.root, m_members.leafs_level, value, + m_members.parameters(), m_members.translator(), m_members.allocators()); detail::rtree::apply_visitor(remove_v, *m_members.root); @@ -1547,9 +1613,8 @@ private: { if ( t.m_members.root ) { - detail::rtree::visitors::destroy - del_v(t.m_members.root, t.m_members.allocators()); - detail::rtree::apply_visitor(del_v, *t.m_members.root); + detail::rtree::visitors::destroy + ::apply(t.m_members.root, t.m_members.allocators()); t.m_members.root = 0; } @@ -1570,8 +1635,7 @@ private: */ inline void raw_copy(rtree const& src, rtree & dst, bool copy_tr_and_params) const { - detail::rtree::visitors::copy - copy_v(dst.m_members.allocators()); + detail::rtree::visitors::copy copy_v(dst.m_members.allocators()); if ( src.m_members.root ) detail::rtree::apply_visitor(copy_v, *src.m_members.root); // MAY THROW (V, E: alloc, copy, N: alloc) @@ -1586,9 +1650,9 @@ private: // TODO use subtree_destroyer if ( dst.m_members.root ) { - detail::rtree::visitors::destroy - del_v(dst.m_members.root, dst.m_members.allocators()); - detail::rtree::apply_visitor(del_v, *dst.m_members.root); + detail::rtree::visitors::destroy + ::apply(dst.m_members.root, dst.m_members.allocators()); + dst.m_members.root = 0; } @@ -1680,10 +1744,8 @@ private: template size_type query_dispatch(Predicates const& predicates, OutIter out_it, boost::mpl::bool_ const& /*is_distance_predicate*/) const { - detail::rtree::visitors::spatial_query - < - value_type, options_type, translator_type, box_type, allocators_type, Predicates, OutIter - >find_v(m_members.parameters(), m_members.translator(), predicates, out_it); + detail::rtree::visitors::spatial_query + find_v(m_members.parameters(), m_members.translator(), predicates, out_it); detail::rtree::apply_visitor(find_v, *m_members.root); @@ -1703,11 +1765,7 @@ private: static const unsigned distance_predicate_index = detail::predicates_find_distance::value; detail::rtree::visitors::distance_query< - value_type, - options_type, - translator_type, - box_type, - allocators_type, + members_holder, Predicates, distance_predicate_index, OutIter @@ -1732,11 +1790,7 @@ private: detail::rtree::visitors::count < ValueOrIndexable, - value_type, - options_type, - translator_type, - box_type, - allocators_type + members_holder > count_v(vori, m_members.parameters(), m_members.translator()); detail::rtree::apply_visitor(count_v, *m_members.root); @@ -1744,57 +1798,6 @@ private: return count_v.found_count; } - struct members_holder - : public translator_type - , public Parameters - , public allocators_type - { - private: - members_holder(members_holder const&); - members_holder & operator=(members_holder const&); - - public: - template - members_holder(IndGet const& ind_get, - ValEq const& val_eq, - Parameters const& parameters, - BOOST_FWD_REF(Alloc) alloc) - : translator_type(ind_get, val_eq) - , Parameters(parameters) - , allocators_type(boost::forward(alloc)) - , values_count(0) - , leafs_level(0) - , root(0) - {} - - template - members_holder(IndGet const& ind_get, - ValEq const& val_eq, - Parameters const& parameters) - : translator_type(ind_get, val_eq) - , Parameters(parameters) - , allocators_type() - , values_count(0) - , leafs_level(0) - , root(0) - {} - - translator_type const& translator() const { return *this; } - - IndexableGetter const& indexable_getter() const { return *this; } - IndexableGetter & indexable_getter() { return *this; } - EqualTo const& equal_to() const { return *this; } - EqualTo & equal_to() { return *this; } - Parameters const& parameters() const { return *this; } - Parameters & parameters() { return *this; } - allocators_type const& allocators() const { return *this; } - allocators_type & allocators() { return *this; } - - size_type values_count; - size_type leafs_level; - node_pointer root; - }; - members_holder m_members; }; diff --git a/include/boost/geometry/strategies/agnostic/hull_graham_andrew.hpp b/include/boost/geometry/strategies/agnostic/hull_graham_andrew.hpp index f86dcbdd9..7a69ecb5b 100644 --- a/include/boost/geometry/strategies/agnostic/hull_graham_andrew.hpp +++ b/include/boost/geometry/strategies/agnostic/hull_graham_andrew.hpp @@ -33,7 +33,6 @@ #include #include #include -#include namespace boost { namespace geometry diff --git a/include/boost/geometry/strategies/cartesian/buffer_end_round.hpp b/include/boost/geometry/strategies/cartesian/buffer_end_round.hpp index 70b3f0e64..b3bd6f2ab 100644 --- a/include/boost/geometry/strategies/cartesian/buffer_end_round.hpp +++ b/include/boost/geometry/strategies/cartesian/buffer_end_round.hpp @@ -14,6 +14,8 @@ #ifndef BOOST_GEOMETRY_STRATEGIES_CARTESIAN_BUFFER_END_ROUND_HPP #define BOOST_GEOMETRY_STRATEGIES_CARTESIAN_BUFFER_END_ROUND_HPP +#include + #include #include #include @@ -116,6 +118,7 @@ public : DistanceStrategy const& distance, RangeOut& range_out) const { + boost::ignore_unused(perp_left_point); typedef typename coordinate_type::type coordinate_type; typedef typename geometry::select_most_precise diff --git a/include/boost/geometry/strategies/transform/matrix_transformers.hpp b/include/boost/geometry/strategies/transform/matrix_transformers.hpp index 6fec3a940..36e60f3b6 100644 --- a/include/boost/geometry/strategies/transform/matrix_transformers.hpp +++ b/include/boost/geometry/strategies/transform/matrix_transformers.hpp @@ -74,7 +74,7 @@ template struct set_point_from_vec { template - static inline void apply(Point &, Vector const& v) {} + static inline void apply(Point &, Vector const&) {} }; template @@ -101,7 +101,7 @@ template struct set_vec_from_point { template - static inline void apply(Point const& p, Vector & v) {} + static inline void apply(Point const&, Vector &) {} }; template diff --git a/index/Jamfile.v2 b/index/Jamfile similarity index 100% rename from index/Jamfile.v2 rename to index/Jamfile diff --git a/index/example/Jamfile.v2 b/index/example/Jamfile similarity index 100% rename from index/example/Jamfile.v2 rename to index/example/Jamfile diff --git a/index/test/Jamfile.v2 b/index/test/Jamfile similarity index 100% rename from index/test/Jamfile.v2 rename to index/test/Jamfile diff --git a/index/test/algorithms/Jamfile.v2 b/index/test/algorithms/Jamfile similarity index 100% rename from index/test/algorithms/Jamfile.v2 rename to index/test/algorithms/Jamfile diff --git a/index/test/rtree/Jamfile.v2 b/index/test/rtree/Jamfile similarity index 100% rename from index/test/rtree/Jamfile.v2 rename to index/test/rtree/Jamfile diff --git a/index/test/rtree/exceptions/Jamfile.v2 b/index/test/rtree/exceptions/Jamfile similarity index 100% rename from index/test/rtree/exceptions/Jamfile.v2 rename to index/test/rtree/exceptions/Jamfile diff --git a/index/test/rtree/exceptions/test_exceptions.hpp b/index/test/rtree/exceptions/test_exceptions.hpp index 25f9fb844..df85e217c 100644 --- a/index/test/rtree/exceptions/test_exceptions.hpp +++ b/index/test/rtree/exceptions/test_exceptions.hpp @@ -5,6 +5,10 @@ // // Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland. // +// This file was modified by Oracle on 2019. +// Modifications copyright (c) 2019 Oracle and/or its affiliates. +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle +// // Use, modification and distribution is subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) @@ -45,6 +49,8 @@ void test_rtree_value_exceptions(Parameters const& parameters = Parameters()) throwing_value::set_max_calls(i); BOOST_CHECK_THROW( tree.insert(input.begin(), input.end()), throwing_value_copy_exception ); + + BOOST_CHECK(bgi::detail::rtree::utilities::are_counts_ok(tree, false)); } for ( size_t i = 0 ; i < 20 ; i += 1 ) @@ -68,6 +74,8 @@ void test_rtree_value_exceptions(Parameters const& parameters = Parameters()) throwing_value::set_max_calls(i); BOOST_CHECK_THROW( tree.remove(input.begin(), input.end()), throwing_value_copy_exception ); + + BOOST_CHECK(bgi::detail::rtree::utilities::are_counts_ok(tree, false)); } for ( size_t i = 0 ; i < 20 ; i += 2 ) @@ -99,6 +107,8 @@ void test_rtree_value_exceptions(Parameters const& parameters = Parameters()) throwing_value::set_max_calls(i); BOOST_CHECK_THROW(tree2 = tree, throwing_value_copy_exception ); + + BOOST_CHECK(tree2.empty()); } } @@ -128,6 +138,8 @@ void test_rtree_elements_exceptions(Parameters const& parameters = Parameters()) throwing_varray_settings::set_max_calls(i); BOOST_CHECK_THROW( tree.insert(input.begin(), input.end()), throwing_varray_exception ); + + BOOST_CHECK(bgi::detail::rtree::utilities::are_counts_ok(tree, false)); } for ( size_t i = 0 ; i < 100 ; i += 2 ) @@ -156,6 +168,8 @@ void test_rtree_elements_exceptions(Parameters const& parameters = Parameters()) throwing_varray_settings::set_max_calls(i); BOOST_CHECK_THROW( tree.remove(input.begin(), input.end()), throwing_varray_exception ); + + BOOST_CHECK(bgi::detail::rtree::utilities::are_counts_ok(tree, false)); } for ( size_t i = 0 ; i < 50 ; i += 2 ) @@ -187,6 +201,8 @@ void test_rtree_elements_exceptions(Parameters const& parameters = Parameters()) throwing_varray_settings::set_max_calls(i); BOOST_CHECK_THROW(tree2 = tree, throwing_varray_exception ); + + BOOST_CHECK(tree2.empty()); } } diff --git a/index/test/rtree/generated/Jamfile.v2 b/index/test/rtree/generated/Jamfile similarity index 100% rename from index/test/rtree/generated/Jamfile.v2 rename to index/test/rtree/generated/Jamfile diff --git a/index/test/rtree/generated/b2d/Jamfile.v2 b/index/test/rtree/generated/b2d/Jamfile similarity index 100% rename from index/test/rtree/generated/b2d/Jamfile.v2 rename to index/test/rtree/generated/b2d/Jamfile diff --git a/index/test/rtree/generated/b3d/Jamfile.v2 b/index/test/rtree/generated/b3d/Jamfile similarity index 100% rename from index/test/rtree/generated/b3d/Jamfile.v2 rename to index/test/rtree/generated/b3d/Jamfile diff --git a/index/test/rtree/generated/p2d/Jamfile.v2 b/index/test/rtree/generated/p2d/Jamfile similarity index 100% rename from index/test/rtree/generated/p2d/Jamfile.v2 rename to index/test/rtree/generated/p2d/Jamfile diff --git a/index/test/rtree/generated/p3d/Jamfile.v2 b/index/test/rtree/generated/p3d/Jamfile similarity index 100% rename from index/test/rtree/generated/p3d/Jamfile.v2 rename to index/test/rtree/generated/p3d/Jamfile diff --git a/index/test/rtree/generated/s2d/Jamfile.v2 b/index/test/rtree/generated/s2d/Jamfile similarity index 100% rename from index/test/rtree/generated/s2d/Jamfile.v2 rename to index/test/rtree/generated/s2d/Jamfile diff --git a/index/test/rtree/interprocess/Jamfile.v2 b/index/test/rtree/interprocess/Jamfile similarity index 100% rename from index/test/rtree/interprocess/Jamfile.v2 rename to index/test/rtree/interprocess/Jamfile diff --git a/index/test/rtree/test_rtree.hpp b/index/test/rtree/test_rtree.hpp index f937e768a..89aaf02dd 100644 --- a/index/test/rtree/test_rtree.hpp +++ b/index/test/rtree/test_rtree.hpp @@ -26,8 +26,9 @@ #include #include -#include #include +#include +#include //#include //#include diff --git a/test/Jamfile.v2 b/test/Jamfile similarity index 100% rename from test/Jamfile.v2 rename to test/Jamfile diff --git a/test/algorithms/Jamfile.v2 b/test/algorithms/Jamfile similarity index 100% rename from test/algorithms/Jamfile.v2 rename to test/algorithms/Jamfile diff --git a/test/algorithms/area/Jamfile.v2 b/test/algorithms/area/Jamfile similarity index 100% rename from test/algorithms/area/Jamfile.v2 rename to test/algorithms/area/Jamfile diff --git a/test/algorithms/buffer/Jamfile.v2 b/test/algorithms/buffer/Jamfile similarity index 100% rename from test/algorithms/buffer/Jamfile.v2 rename to test/algorithms/buffer/Jamfile diff --git a/test/algorithms/buffer/buffer_multi_polygon.cpp b/test/algorithms/buffer/buffer_multi_polygon.cpp index e2c0d525f..b3548e355 100644 --- a/test/algorithms/buffer/buffer_multi_polygon.cpp +++ b/test/algorithms/buffer/buffer_multi_polygon.cpp @@ -374,8 +374,8 @@ void test_all() test_one("rt_d", rt_d, join_miter, end_flat, 19.8823, 0.3); test_one("rt_e", rt_e, join_miter, end_flat, 15.1198, 0.3); test_one("rt_f", rt_f, join_miter, end_flat, 4.60853, 0.3); - test_one("rt_g1", rt_g1, join_miter, end_flat, 30.3137, 1.0); #if defined(BOOST_GEOMETRY_USE_RESCALING) || ! defined(BOOST_GEOMETRY_USE_KRAMER_RULE) || defined(BOOST_GEOMETRY_TEST_FAILURES) + test_one("rt_g1", rt_g1, join_miter, end_flat, 30.3137, 1.0); test_one("rt_g2", rt_g2, join_miter, end_flat, 18.5711, 1.0); #endif diff --git a/test/algorithms/buffer/test_buffer_svg.hpp b/test/algorithms/buffer/test_buffer_svg.hpp index a898bd4ef..85e2cc614 100644 --- a/test/algorithms/buffer/test_buffer_svg.hpp +++ b/test/algorithms/buffer/test_buffer_svg.hpp @@ -176,11 +176,9 @@ private : << ":" << bg::operation_char(it->operations[0].operation) << "/" << bg::operation_char(it->operations[1].operation); out << " " - << (it->count_on_offsetted > 0 ? "b" : "") // b: offsetted border << (it->count_within_near_offsetted > 0 ? "n" : "") << (it->count_within > 0 ? "w" : "") << (it->count_on_helper > 0 ? "h" : "") - << (it->count_on_multi > 0 ? "m" : "") ; offsets[it->get_robust_point()] += 10; diff --git a/test/algorithms/covered_by/Jamfile.v2 b/test/algorithms/covered_by/Jamfile similarity index 100% rename from test/algorithms/covered_by/Jamfile.v2 rename to test/algorithms/covered_by/Jamfile diff --git a/test/algorithms/crosses/Jamfile.v2 b/test/algorithms/crosses/Jamfile similarity index 100% rename from test/algorithms/crosses/Jamfile.v2 rename to test/algorithms/crosses/Jamfile diff --git a/test/algorithms/detail/Jamfile.v2 b/test/algorithms/detail/Jamfile similarity index 100% rename from test/algorithms/detail/Jamfile.v2 rename to test/algorithms/detail/Jamfile diff --git a/test/algorithms/detail/get_left_turns.cpp b/test/algorithms/detail/get_left_turns.cpp deleted file mode 100644 index d420b0c91..000000000 --- a/test/algorithms/detail/get_left_turns.cpp +++ /dev/null @@ -1,321 +0,0 @@ -// Boost.Geometry (aka GGL, Generic Geometry Library) -// -// Copyright (c) 2012-2014 Barend Gehrels, Amsterdam, the Netherlands. - -// Use, modification and distribution is subject to the Boost Software License, -// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#include - -#include -#include - -#include -#include - -#if defined(TEST_WITH_SVG) -# include -#endif - - -NOTE: this unit test is out of date. -get_left_turns is used by buffer and might be used in the future by solving self-tangencies in overlays. -it is currently being changed by buffer. - -namespace bglt = boost::geometry::detail::left_turns; - -#if defined(TEST_WITH_SVG) -template -inline Point further_than(Point const& p, Point const& origin, int mul, int div) -{ - typedef Point vector_type; - - vector_type v = p; - bg::subtract_point(v, origin); - - bg::divide_value(v, div); - bg::multiply_value(v, mul); - Point result = origin; - bg::add_point(result, v); - return result; -} - -inline std::string get_color(int index) -{ - switch (index) - { - case 0 : return "rgb(0,192,0)"; - case 1 : return "rgb(0,0,255)"; - case 2 : return "rgb(255,0,0)"; - case 3 : return "rgb(255,255,0)"; - } - return "rgb(128,128,128)"; -} -#endif - - -template -void test_one(std::string const& caseid, - Point const& p, - std::vector > const& angles, - std::string const& expected_sorted_indices, - std::string const& expected_left_indices) -{ - typedef Point vector_type; - - std::vector > sorted; - for (typename std::vector >::const_iterator it = - angles.begin(); it != angles.end(); ++it) - { - for (int i = 0; i < 2; i++) - { - bglt::angle_info info(it->seg_id, i == 0, it->points[i]); - sorted.push_back(info); - } - } - - // Sort on angle - std::sort(sorted.begin(), sorted.end(), bglt::angle_less(p)); - - // Block all turns on the right side of any turn - bglt::block_turns_on_right_sides(angles, sorted); - - // Check the sorting - { - std::ostringstream out; - out << std::boolalpha; - for (typename std::vector >::const_iterator it = - sorted.begin(); it != sorted.end(); ++it) - { - out << " " << it->seg_id.segment_index - << "-" << it->incoming; - } - std::string detected = boost::trim_copy(out.str()); - BOOST_CHECK_EQUAL(expected_sorted_indices, detected); - } - - - // Check outgoing lines - std::vector seg_ids; - bglt::get_left_turns(sorted, p, seg_ids); - { - std::ostringstream out; - out << std::boolalpha; - for (std::vector::const_iterator it = - seg_ids.begin(); it != seg_ids.end(); ++it) - { - out - << " " << it->from.segment_index - << "->" << it->to.segment_index - ; - } - std::string detected = boost::trim_copy(out.str()); - BOOST_CHECK_EQUAL(expected_left_indices, detected); - } - -#if defined(TEST_WITH_SVG) - { - std::ostringstream filename; - filename << "get_left_turns_" << caseid - << "_" << string_from_type::type>::name() - << ".svg"; - - std::ofstream svg(filename.str().c_str()); - - bg::svg_mapper mapper(svg, 500, 500); - mapper.add(p); - for (typename std::vector >::const_iterator it = - angles.begin(); it != angles.end(); ++it) - { - // Add a point further then it->to_point, just for the mapping - for (int i = 0; i < 2; i++) - { - mapper.add(further_than(it->points[i], p, 12, 10)); - } - } - - int color_index = 0; - typedef bg::model::referring_segment segment_type; - for (typename std::vector >::const_iterator it = - angles.begin(); it != angles.end(); ++it, color_index++) - { - for (int i = 0; i < 2; i++) - { - std::string style = "opacity:0.5;stroke-width:1;stroke:rgb(0,0,0);fill:" + get_color(color_index); - - bool const incoming = i == 0; - Point const& pf = incoming ? it->points[i] : p; - Point const& pt = incoming ? p : it->points[i]; - vector_type v = pt; - bg::subtract_point(v, pf); - - bg::divide_value(v, 10.0); - - // Generate perpendicular vector to right-side - vector_type perpendicular; - bg::set<0>(perpendicular, bg::get<1>(v)); - bg::set<1>(perpendicular, -bg::get<0>(v)); - - bg::model::ring ring; - ring.push_back(pf); - ring.push_back(pt); - - // Extra point at 9/10 - { - Point pe = pt; - bg::add_point(pe, perpendicular); - ring.push_back(pe); - } - { - Point pe = pf; - bg::add_point(pe, perpendicular); - ring.push_back(pe); - } - ring.push_back(pf); - - mapper.map(ring, style); - - segment_type s(pf, pt); - mapper.map(s, "opacity:0.9;stroke-width:4;stroke:rgb(0,0,0);"); - } - } - - // Output angles for left-turns - for (std::vector::const_iterator ltit = - seg_ids.begin(); ltit != seg_ids.end(); ++ltit) - { - for (typename std::vector >::const_iterator sit = - sorted.begin(); sit != sorted.end(); ++sit, color_index++) - { - Point pf, pt; - int factor = 0; - if (sit->seg_id == ltit->from && sit->incoming) - { - pf = sit->point; - pt = p; - factor = -1; // left side - } - else if (sit->seg_id == ltit->to && ! sit->incoming) - { - pf = p; - pt = sit->point; - factor = -1; // left side - } - if (factor != 0) - { - vector_type v = pt; - bg::subtract_point(v, pf); - bg::divide_value(v, 10.0); - - // Generate perpendicular vector to right-side - vector_type perpendicular; - bg::set<0>(perpendicular, factor * bg::get<1>(v)); - bg::set<1>(perpendicular, -factor * bg::get<0>(v)); - - bg::add_point(pf, v); - bg::subtract_point(pt, v); - - bg::add_point(pf, perpendicular); - bg::add_point(pt, perpendicular); - - segment_type s(pf, pt); - mapper.map(s, "opacity:0.9;stroke-width:4;stroke:rgb(255,0,0);"); - } - } - } - - // Output texts with info about sorted/blocked - int index = 0; - for (typename std::vector >::const_iterator it = - sorted.begin(); it != sorted.end(); ++it, ++index) - { - std::ostringstream out; - out << std::boolalpha; - out << " seg:" << it->seg_id.segment_index - << " " << (it->incoming ? "in" : "out") - << " idx:" << index - << (it->blocked ? " blocked" : "") - ; - mapper.text(further_than(it->point, p, 11, 10), out.str(), "fill:rgb(0,0,0);font-family='Verdana'"); - } - - mapper.map(p, "fill:rgb(255,0,0)"); - - } - -#endif - -} - - -template -void test_all() -{ - using bglt::turn_angle_info; - - test_one

("cross", - bg::make

(50, 50), // ip - boost::assign::list_of - (turn_angle_info

(bg::segment_identifier(0, -1, -1, 1), bg::make

(100, 100), bg::make

(0, 0))) - (turn_angle_info

(bg::segment_identifier(0, -1, -1, 2), bg::make

(100, 0), bg::make

(0, 100))) - , "1-true 2-true 1-false 2-false" - , "2->1" - ); - - test_one

("occupied", - bg::make

(50, 50), // ip - boost::assign::list_of - (turn_angle_info

(bg::segment_identifier(0, -1, -1, 1), bg::make

(100, 100), bg::make

(0, 0))) - (turn_angle_info

(bg::segment_identifier(0, -1, -1, 2), bg::make

(100, 0), bg::make

(0, 100))) - (turn_angle_info

(bg::segment_identifier(0, -1, -1, 3), bg::make

(0, 30), bg::make

(100, 70))) - , "1-true 3-false 2-true 1-false 3-true 2-false" - , "" - ); - - test_one

("uu", - bg::make

(50, 50), // ip - boost::assign::list_of - (turn_angle_info

(bg::segment_identifier(0, -1, -1, 1), bg::make

(0, 0), bg::make

(100, 0))) - (turn_angle_info

(bg::segment_identifier(0, -1, -1, 2), bg::make

(100, 100), bg::make

(0, 100))) - , "2-true 1-false 1-true 2-false" - , "2->1 1->2" - ); - - test_one

("uu2", - bg::make

(50, 50), // ip - boost::assign::list_of - (turn_angle_info

(bg::segment_identifier(0, -1, -1, 1), bg::make

(0, 0), bg::make

(100, 0))) - (turn_angle_info

(bg::segment_identifier(0, -1, -1, 2), bg::make

(100, 100), bg::make

(0, 100))) - (turn_angle_info

(bg::segment_identifier(0, -1, -1, 3), bg::make

(0, 50), bg::make

(100, 50))) - , "2-true 3-false 1-false 1-true 3-true 2-false" - , "2->3 3->2" - ); - - test_one

("uu3", - bg::make

(50, 50), // ip - boost::assign::list_of - (turn_angle_info

(bg::segment_identifier(0, -1, -1, 1), bg::make

(0, 0), bg::make

(100, 0))) - (turn_angle_info

(bg::segment_identifier(0, -1, -1, 2), bg::make

(100, 100), bg::make

(0, 100))) - (turn_angle_info

(bg::segment_identifier(0, -1, -1, 3), bg::make

(50, 0), bg::make

(50, 100))) - , "3-false 2-true 1-false 3-true 1-true 2-false" - , "1->2" - ); - - test_one

("longer", - bg::make

(50, 50), // ip - boost::assign::list_of - (turn_angle_info

(bg::segment_identifier(0, -1, -1, 1), bg::make

(100, 100), bg::make

(0, 0))) - (turn_angle_info

(bg::segment_identifier(0, -1, -1, 2), bg::make

(100, 0), bg::make

(0, 100))) - (turn_angle_info

(bg::segment_identifier(0, -1, -1, 3), bg::make

(90, 10), bg::make

(10, 10))) - , "1-true 2-true 3-true 1-false 3-false 2-false" - , "3->1" - ); -} - -int test_main( int , char* [] ) -{ - test_all >(); - - return 0; -} diff --git a/test/algorithms/detail/sections/Jamfile.v2 b/test/algorithms/detail/sections/Jamfile similarity index 100% rename from test/algorithms/detail/sections/Jamfile.v2 rename to test/algorithms/detail/sections/Jamfile diff --git a/test/algorithms/disjoint/Jamfile.v2 b/test/algorithms/disjoint/Jamfile similarity index 100% rename from test/algorithms/disjoint/Jamfile.v2 rename to test/algorithms/disjoint/Jamfile diff --git a/test/algorithms/distance/Jamfile.v2 b/test/algorithms/distance/Jamfile similarity index 100% rename from test/algorithms/distance/Jamfile.v2 rename to test/algorithms/distance/Jamfile diff --git a/test/algorithms/envelope_expand/Jamfile.v2 b/test/algorithms/envelope_expand/Jamfile similarity index 100% rename from test/algorithms/envelope_expand/Jamfile.v2 rename to test/algorithms/envelope_expand/Jamfile diff --git a/test/algorithms/equals/Jamfile.v2 b/test/algorithms/equals/Jamfile similarity index 100% rename from test/algorithms/equals/Jamfile.v2 rename to test/algorithms/equals/Jamfile diff --git a/test/algorithms/intersects/Jamfile.v2 b/test/algorithms/intersects/Jamfile similarity index 100% rename from test/algorithms/intersects/Jamfile.v2 rename to test/algorithms/intersects/Jamfile diff --git a/test/algorithms/length/Jamfile.v2 b/test/algorithms/length/Jamfile similarity index 100% rename from test/algorithms/length/Jamfile.v2 rename to test/algorithms/length/Jamfile diff --git a/test/algorithms/overlaps/Jamfile.v2 b/test/algorithms/overlaps/Jamfile similarity index 100% rename from test/algorithms/overlaps/Jamfile.v2 rename to test/algorithms/overlaps/Jamfile diff --git a/test/algorithms/overlay/Jamfile.v2 b/test/algorithms/overlay/Jamfile similarity index 100% rename from test/algorithms/overlay/Jamfile.v2 rename to test/algorithms/overlay/Jamfile diff --git a/test/algorithms/overlay/multi_overlay_cases.hpp b/test/algorithms/overlay/multi_overlay_cases.hpp index 86d4f695d..865e2bef7 100644 --- a/test/algorithms/overlay/multi_overlay_cases.hpp +++ b/test/algorithms/overlay/multi_overlay_cases.hpp @@ -1494,6 +1494,12 @@ static std::string issue_630_c[2] = "MULTIPOLYGON(((-0.9099999999999999 +0.4625,-0.1912799075873667 +1.181220092412633,+0.9707630752925609 +0.01917710953270602,+0.2520429828799277 -0.6995429828799273,-0.9099999999999999 +0.4625)))" }; +static std::string issue_643[2] = +{ + "MULTIPOLYGON(((-0.420825839394717959862646239344 0.168094877926996288941552393226,5.29161113734201116187705338234 5.76881481261494233336861725547,12.2925110557019436896553088445 -1.37173140830596795858298264648,6.58007407896521545609402892296 -6.97245134299391278176472042105,-0.420825839394717959862646239344 0.168094877926996288941552393226)))", + "MULTIPOLYGON(((4.75985680877701196159479187986e-16 -0.26112514220036736611874061964,0 0,0.72337592336357892097709054724 0.600648602980154100450249643472,1.223386680467822174023240222 1.19163154396839887638748223253,1.72339743757206620422550713556 2.1342216197599452875977021904,1.72339742847305732453833115869 -2.01889900623749607433410346857,4.75985680877701196159479187986e-16 -0.26112514220036736611874061964)))" +}; + static std::string bug_21155501[2] = { "MULTIPOLYGON(((-8.3935546875 27.449790329784214,4.9658203125 18.729501999072138,11.8212890625 23.563987128451217,9.7119140625 25.48295117535531,9.8876953125 31.728167146023935,8.3056640625 32.99023555965106,8.5693359375 37.16031654673677,-1.8896484375 35.60371874069731,-0.5712890625 32.02670629333614,-8.9208984375 29.458731185355344,-8.3935546875 27.449790329784214)))", diff --git a/test/algorithms/perimeter/Jamfile.v2 b/test/algorithms/perimeter/Jamfile similarity index 100% rename from test/algorithms/perimeter/Jamfile.v2 rename to test/algorithms/perimeter/Jamfile diff --git a/test/algorithms/relate/Jamfile.v2 b/test/algorithms/relate/Jamfile similarity index 100% rename from test/algorithms/relate/Jamfile.v2 rename to test/algorithms/relate/Jamfile diff --git a/test/algorithms/set_operations/Jamfile.v2 b/test/algorithms/set_operations/Jamfile similarity index 100% rename from test/algorithms/set_operations/Jamfile.v2 rename to test/algorithms/set_operations/Jamfile diff --git a/test/algorithms/set_operations/difference/Jamfile.v2 b/test/algorithms/set_operations/difference/Jamfile similarity index 100% rename from test/algorithms/set_operations/difference/Jamfile.v2 rename to test/algorithms/set_operations/difference/Jamfile diff --git a/test/algorithms/set_operations/difference/difference_multi.cpp b/test/algorithms/set_operations/difference/difference_multi.cpp index 5cdbb668d..374e5d450 100644 --- a/test/algorithms/set_operations/difference/difference_multi.cpp +++ b/test/algorithms/set_operations/difference/difference_multi.cpp @@ -184,6 +184,26 @@ void test_areal() TEST_DIFFERENCE(ticket_12503, 46, 920.625, 4, 7.625, 50); + { + // Reported issues going wrong with rescaling (except for 630b) + ut_settings settings; + settings.percentage = 0.001; + +#if ! defined(BOOST_GEOMETRY_USE_RESCALING) || defined(BOOST_GEOMETRY_TEST_FAILURES) + TEST_DIFFERENCE_WITH(0, 1, issue_630_a, 0, 0.0, 1, BG_IF_KRAMER(2.023326, 2.200326), 1); +#endif + TEST_DIFFERENCE_WITH(0, 1, issue_630_b, 1, 0.0056089, 2, 1.498976, 3); +#if ! defined(BOOST_GEOMETRY_USE_RESCALING) || defined(BOOST_GEOMETRY_TEST_FAILURES) + +#if defined(BOOST_GEOMETRY_USE_KRAMER) || defined(BOOST_GEOMETRY_TEST_FAILURES) + // Only succeeds with Kramer rule and no rescaling + TEST_DIFFERENCE_WITH(0, 1, issue_630_c, 0, 0, 1, 1.493367, 1); +#endif + + TEST_DIFFERENCE_WITH(0, 1, issue_643, 1, 76.5385, BG_IF_KRAMER(1, 0), BG_IF_KRAMER(2.8634e-09, 0.0), 1); +#endif + } + // Areas and #clips correspond with POSTGIS (except sym case) test_one("case_101_multi", case_101_multi[0], case_101_multi[1], diff --git a/test/algorithms/set_operations/intersection/Jamfile.v2 b/test/algorithms/set_operations/intersection/Jamfile similarity index 100% rename from test/algorithms/set_operations/intersection/Jamfile.v2 rename to test/algorithms/set_operations/intersection/Jamfile diff --git a/test/algorithms/set_operations/intersection/intersection_multi.cpp b/test/algorithms/set_operations/intersection/intersection_multi.cpp index f1212d083..7bc1d4615 100644 --- a/test/algorithms/set_operations/intersection/intersection_multi.cpp +++ b/test/algorithms/set_operations/intersection/intersection_multi.cpp @@ -374,10 +374,15 @@ void test_areal() #endif #if ! defined(BOOST_GEOMETRY_USE_KRAMER_RULE) || defined(BOOST_GEOMETRY_TEST_FAILURES) // Two cases produce either too large, or no output if Kramer rule is used - TEST_INTERSECTION(issue_630_b, 1, -1, 0.1714); + TEST_INTERSECTION(issue_630_b, 1, -1, BG_IF_KRAMER(0.1714, 0.1713911)); TEST_INTERSECTION(issue_630_c, 1, -1, 0.1770); #endif +#if ! defined(BOOST_GEOMETRY_USE_RESCALING) || defined(BOOST_GEOMETRY_TEST_FAILURES) + // Result is missing with rescaling + TEST_INTERSECTION(issue_643, 1, -1, 3.4615); +#endif + test_one("mysql_23023665_7", mysql_23023665_7[0], mysql_23023665_7[1], 2, 11, 9.80505786783); diff --git a/test/algorithms/set_operations/sym_difference/Jamfile.v2 b/test/algorithms/set_operations/sym_difference/Jamfile similarity index 100% rename from test/algorithms/set_operations/sym_difference/Jamfile.v2 rename to test/algorithms/set_operations/sym_difference/Jamfile diff --git a/test/algorithms/set_operations/union/Jamfile.v2 b/test/algorithms/set_operations/union/Jamfile similarity index 100% rename from test/algorithms/set_operations/union/Jamfile.v2 rename to test/algorithms/set_operations/union/Jamfile diff --git a/test/algorithms/set_operations/union/union_multi.cpp b/test/algorithms/set_operations/union/union_multi.cpp index b1efa0d4e..c76bbcd5e 100644 --- a/test/algorithms/set_operations/union/union_multi.cpp +++ b/test/algorithms/set_operations/union/union_multi.cpp @@ -426,6 +426,11 @@ void test_areal() TEST_UNION(issue_630_c, 1, 0, -1, 1.670367); #endif +#if ! defined(BOOST_GEOMETRY_USE_RESCALING) || defined(BOOST_GEOMETRY_TEST_FAILURES) + // With rescaling the small polygon is added on top of the outer polygon + TEST_UNION(issue_643, 1, 0, -1, 80.0); +#endif + #if defined(BOOST_GEOMETRY_USE_KRAMER_RULE) // Two polygons, should ideally be merged TEST_UNION(mail_2019_01_21_johan, 2, 0, -1, 0.00058896); diff --git a/test/algorithms/similarity/Jamfile.v2 b/test/algorithms/similarity/Jamfile similarity index 100% rename from test/algorithms/similarity/Jamfile.v2 rename to test/algorithms/similarity/Jamfile diff --git a/test/algorithms/touches/Jamfile.v2 b/test/algorithms/touches/Jamfile similarity index 100% rename from test/algorithms/touches/Jamfile.v2 rename to test/algorithms/touches/Jamfile diff --git a/test/algorithms/within/Jamfile.v2 b/test/algorithms/within/Jamfile similarity index 100% rename from test/algorithms/within/Jamfile.v2 rename to test/algorithms/within/Jamfile diff --git a/test/arithmetic/Jamfile.v2 b/test/arithmetic/Jamfile similarity index 100% rename from test/arithmetic/Jamfile.v2 rename to test/arithmetic/Jamfile diff --git a/test/concepts/Jamfile.v2 b/test/concepts/Jamfile similarity index 100% rename from test/concepts/Jamfile.v2 rename to test/concepts/Jamfile diff --git a/test/core/Jamfile.v2 b/test/core/Jamfile similarity index 100% rename from test/core/Jamfile.v2 rename to test/core/Jamfile diff --git a/test/cs_undefined/Jamfile.v2 b/test/cs_undefined/Jamfile similarity index 100% rename from test/cs_undefined/Jamfile.v2 rename to test/cs_undefined/Jamfile diff --git a/test/formulas/Jamfile.v2 b/test/formulas/Jamfile similarity index 100% rename from test/formulas/Jamfile.v2 rename to test/formulas/Jamfile diff --git a/test/formulas/inverse_cases.hpp b/test/formulas/inverse_cases.hpp index b3b868d56..586ed54ba 100644 --- a/test/formulas/inverse_cases.hpp +++ b/test/formulas/inverse_cases.hpp @@ -1,7 +1,7 @@ // Boost.Geometry // Unit Test -// Copyright (c) 2016-2017 Oracle and/or its affiliates. +// Copyright (c) 2016-2020 Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle @@ -583,7 +583,8 @@ expected_results expected[] = {10001965.72931179217994213104, -180.00000000000000000000, -179.00000000000000000000, 6378136.99999999906867742538, 0.00000000000000000000}, {10001965.71749142371118068695, 180.00000000000000000000, -179.00000000000000000000, 6378136.99999999906867742538, 0.00000000000000000000}, {10001958.67847795411944389343, 180.00000000000000000000, -179.00000000000000000000, 6378136.99999999906867742538, 0.00000000000000000000} - }/*, { + } + /*, { // antipodal {-90, -45}, {90, 45}, {20003931.45862544700503349304, -180.00000000000000000000, 0.00000000000000000000, 33675.52452803074265830219, -0.99472900658949181540}, @@ -597,6 +598,26 @@ expected_results expected[] = {19987083.06974205747246742249, 90.00000000000000000000, 90.00000000000000000000, -000000.00000000078240703623, -1.00000000000000000000}, {00000000.00000000000000000000, 0.00000000000000000000, 0.00000000000000000000, 000000.00000000000000000000, 1.00000000000000000000}, {20020712.84987257421016693115, 180.00000000000000000000, 0.00000000000000000000, 33590.79639541531651047990, -1.00525773151080621837} + } + // pi = 3.1415926535897931 + // r2d = 57.295779513082323 + // commented out because of inconsistencies + /*, { + {0.26387320519564444 * 57.295779513082323, 0.84008767903244352 * 57.295779513082323}, + {0.26387320679785603 * 57.295779513082323, 0.84008767099694759 * 57.295779513082323}, + {0.051647212499179529, 172.39749230932208, 172.39749237768564, 0.051647212499179536, 1.0000000000000000}, + {0.051647209427812361, 172.39750897806516, 172.39750904523200, 0.051638407375539180, 0.99999999999999734}, + // TODO: This is wrong + {0.00000000000000000, 0.00000000000000000, 0.00000000000000000, 0.00000000000000000, 1.0000000000000000}, + {0.00000000000000000, 0.00000000000000000, 0.00000000000000000, -0.051193490763866173, 1.0000000000000000} + }, { + {0.26387320519564444 * 57.295779513082323, 0.84008767903244352 * 57.295779513082323}, + {(0.26387320679785603 - 3.1415926535897931) * 57.295779513082323, -0.84008767099694759 * 57.295779513082323}, + {20003931.407432225, -1.3045327945402774e-05, -179.99998695467218, 30010.522036068141, -0.99475954491334551}, + {20003669.536724485, -7.5912543895164619, -172.40874567755344, 29487.136123182696, -0.99480541226332386}, + // TODO: This is wrong + {0.00000000000000000, 0.00000000000000000, 0.00000000000000000, 0.00000000000000000, 1.0000000000000000}, + {20018879.436128609, 0.00000000000000000, 180.00000000000000, 29935.015234617360, -0.99477272997811228} }*/ }; diff --git a/test/geometries/Jamfile.v2 b/test/geometries/Jamfile similarity index 70% rename from test/geometries/Jamfile.v2 rename to test/geometries/Jamfile index 15f8c60c5..89a2b3ccb 100644 --- a/test/geometries/Jamfile.v2 +++ b/test/geometries/Jamfile @@ -26,6 +26,15 @@ test-suite boost-geometry-geometries #] [ run custom_linestring.cpp : : : : geometries_custom_linestring ] [ run initialization.cpp : : : : geometries_initialization ] + [ run linestring.cpp : : : : geometries_linestring ] + [ run multi_linestring.cpp : : : : geometries_multi_linestring ] + [ run multi_point.cpp : : : : geometries_multi_point ] + [ run multi_polygon.cpp : : : : geometries_multi_polygon ] + [ run point.cpp : : : : geometries_point ] + [ run point_xy.cpp : : : : geometries_point_xy ] + [ run point_xyz.cpp : : : : geometries_point_xyz ] + [ run polygon.cpp : : : : geometries_polygon ] + [ run ring.cpp : : : : geometries_ring ] [ run segment.cpp : : : : geometries_segment ] [ run infinite_line.cpp : : : : geometries_infinite_line ] ; diff --git a/test/geometries/linestring.cpp b/test/geometries/linestring.cpp new file mode 100644 index 000000000..3f32eee7e --- /dev/null +++ b/test/geometries/linestring.cpp @@ -0,0 +1,136 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// Unit Test + +// Copyright (c) 2020 Digvijay Janartha, Hamirpur, India. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +BOOST_GEOMETRY_REGISTER_C_ARRAY_CS(cs::cartesian) +BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian) + +#ifdef BOOST_NO_CXX11_HDR_INITIALIZER_LIST +#include +#endif//BOOST_NO_CXX11_HDR_INITIALIZER_LIST + + +template +bg::model::linestring

create_linestring() +{ + bg::model::linestring

l1; + P p1; + bg::assign_values(p1, 1, 2, 3); + bg::append(l1, p1); + return l1; +} + +template +void check_linestring(L& to_check, T x, T y, T z) +{ + BOOST_CHECK_EQUAL(bg::get<0>(to_check[0]), x); + BOOST_CHECK_EQUAL(bg::get<1>(to_check[0]), y); + BOOST_CHECK_EQUAL(bg::get<2>(to_check[0]), z); +} + +template +void test_default_constructor() +{ + bg::model::linestring

l1(create_linestring

()); + check_linestring(l1, 1, 2, 3); +} + +template +void test_copy_constructor() +{ + bg::model::linestring

l1 = create_linestring

(); + check_linestring(l1, 1, 2, 3); +} + +template +void test_copy_assignment() +{ + bg::model::linestring

l1(create_linestring

()), l2; + l2 = l1; + check_linestring(l2, 1, 2, 3); +} + +template +void test_concept() +{ + typedef bg::model::linestring

L; + + BOOST_CONCEPT_ASSERT( (bg::concepts::ConstLinestring) ); + BOOST_CONCEPT_ASSERT( (bg::concepts::Linestring) ); + + typedef typename bg::coordinate_type::type T; + typedef typename bg::point_type::type LP; + boost::ignore_unused(); +} + +template +void test_all() +{ + test_default_constructor

(); + test_copy_constructor

(); + test_copy_assignment

(); + test_concept

(); +} + +template +void test_custom_linestring(std::initializer_list

IL) +{ + bg::model::linestring

l1(IL); + std::ostringstream out; + out << bg::dsv(l1); + BOOST_CHECK_EQUAL(out.str(), "((1, 2), (2, 3), (3, 4))"); +} + +template +void test_custom() +{ +#ifdef BOOST_NO_CXX11_HDR_INITIALIZER_LIST + std::initializer_list

IL = {P(1, 2), P(2, 3), P(3, 4)}; + test_custom_linestring

(IL); +#endif//BOOST_NO_CXX11_HDR_INITIALIZER_LIST +} + +template +void test_cs() +{ + test_all >(); + test_all >(); + test_all >(); + + test_custom >(); +} + + +int test_main(int, char* []) +{ + test_cs(); + test_cs >(); + test_cs >(); + test_cs >(); + + test_custom >(); + + return 0; +} diff --git a/test/geometries/multi_linestring.cpp b/test/geometries/multi_linestring.cpp new file mode 100644 index 000000000..74ac3f5f7 --- /dev/null +++ b/test/geometries/multi_linestring.cpp @@ -0,0 +1,159 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// Unit Test + +// Copyright (c) 2020 Digvijay Janartha, Hamirpur, India. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +BOOST_GEOMETRY_REGISTER_C_ARRAY_CS(cs::cartesian) +BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian) + +#ifdef BOOST_NO_CXX11_HDR_INITIALIZER_LIST +#include +#endif//BOOST_NO_CXX11_HDR_INITIALIZER_LIST + +template +bg::model::linestring

create_linestring() +{ + bg::model::linestring

l1; + P p1(1, 2); + bg::append(l1, p1); + return l1; +} + +template +bg::model::multi_linestring create_multi_linestring() +{ + bg::model::multi_linestring ml1; + L l1(create_linestring

()); + ml1.push_back(l1); + ml1.push_back(l1); + return ml1; +} + +template +void check_multi_linestring(ML& to_check, L l1) +{ + ML cur; + cur.push_back(l1); + cur.push_back(l1); + + std::ostringstream out1, out2; + out1 << bg::dsv(to_check); + out2 << bg::dsv(cur); + BOOST_CHECK_EQUAL(out1.str(), out2.str()); +} + +template +void test_default_constructor() +{ + bg::model::multi_linestring ml1(create_multi_linestring()); + check_multi_linestring(ml1, L(create_linestring

())); +} + +template +void test_copy_constructor() +{ + bg::model::multi_linestring ml1 = create_multi_linestring(); + check_multi_linestring(ml1, L(create_linestring

())); +} + +template +void test_copy_assignment() +{ + bg::model::multi_linestring ml1(create_multi_linestring()), ml2; + ml2 = ml1; + check_multi_linestring(ml2, L(create_linestring

())); +} + +template +void test_concept() +{ + typedef bg::model::multi_linestring ML; + + BOOST_CONCEPT_ASSERT( (bg::concepts::ConstMultiLinestring) ); + BOOST_CONCEPT_ASSERT( (bg::concepts::MultiLinestring) ); + + typedef typename bg::coordinate_type::type T; + typedef typename bg::point_type::type PML; + boost::ignore_unused(); +} + +template +void test_all() +{ + typedef bg::model::linestring

L; + + test_default_constructor(); + test_copy_constructor(); + test_copy_assignment(); + test_concept(); +} + +template +void test_custom_multi_linestring(bg::model::linestring

IL) +{ + typedef bg::model::linestring

L; + + std::initializer_list LIL = {IL}; + bg::model::multi_linestring ml1(LIL); + std::ostringstream out; + out << bg::dsv(ml1); + BOOST_CHECK_EQUAL(out.str(), "(((1, 1), (2, 2), (3, 3), (0, 0), (0, 2), (0, 3)))"); +} + +template +void test_custom() +{ +#ifdef BOOST_NO_CXX11_HDR_INITIALIZER_LIST + std::initializer_list

IL1 = {P(1, 1), P(2, 2), P(3, 3)}; + std::initializer_list

IL2 = {P(0, 0), P(0, 2), P(0, 3)}; + bg::model::linestring

l1; + bg::append(l1, IL1); + bg::append(l1, IL2); + test_custom_multi_linestring

(l1); +#endif//BOOST_NO_CXX11_HDR_INITIALIZER_LIST +} + +template +void test_cs() +{ + test_all >(); + test_all >(); + test_all >(); + + test_custom >(); +} + + +int test_main(int, char* []) +{ + test_cs(); + test_cs >(); + test_cs >(); + test_cs >(); + + test_custom >(); + + return 0; +} diff --git a/test/geometries/multi_point.cpp b/test/geometries/multi_point.cpp new file mode 100644 index 000000000..b10af2281 --- /dev/null +++ b/test/geometries/multi_point.cpp @@ -0,0 +1,135 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// Unit Test + +// Copyright (c) 2020 Digvijay Janartha, Hamirpur, India. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +BOOST_GEOMETRY_REGISTER_C_ARRAY_CS(cs::cartesian) +BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian) + +#ifdef BOOST_NO_CXX11_HDR_INITIALIZER_LIST +#include +#endif//BOOST_NO_CXX11_HDR_INITIALIZER_LIST + +template +bg::model::multi_point

create_multi_point() +{ + bg::model::multi_point

mp1; + P p1; + bg::assign_values(p1, 1, 2, 3); + bg::append(mp1, p1); + return mp1; +} + +template +void check_multi_point(L& to_check, T x, T y, T z) +{ + BOOST_CHECK_EQUAL(bg::get<0>(to_check[0]), x); + BOOST_CHECK_EQUAL(bg::get<1>(to_check[0]), y); + BOOST_CHECK_EQUAL(bg::get<2>(to_check[0]), z); +} + +template +void test_default_constructor() +{ + bg::model::multi_point

mp1(create_multi_point

()); + check_multi_point(mp1, 1, 2, 3); +} + +template +void test_copy_constructor() +{ + bg::model::multi_point

mp1 = create_multi_point

(); + check_multi_point(mp1, 1, 2, 3); +} + +template +void test_copy_assignment() +{ + bg::model::multi_point

mp1(create_multi_point

()), mp2; + mp2 = mp1; + check_multi_point(mp2, 1, 2, 3); +} + +template +void test_concept() +{ + typedef bg::model::multi_point

MP; + + BOOST_CONCEPT_ASSERT( (bg::concepts::ConstMultiPoint) ); + BOOST_CONCEPT_ASSERT( (bg::concepts::MultiPoint) ); + + typedef typename bg::coordinate_type::type T; + typedef typename bg::point_type::type MPP; + boost::ignore_unused(); +} + +template +void test_all() +{ + test_default_constructor

(); + test_copy_constructor

(); + test_copy_assignment

(); + test_concept

(); +} + +template +void test_custom_multi_point(std::initializer_list

IL) +{ + bg::model::multi_point

mp1(IL); + std::ostringstream out; + out << bg::dsv(mp1); + BOOST_CHECK_EQUAL(out.str(), "((0, 0), (1, 2), (2, 0))"); +} + +template +void test_custom() +{ +#ifdef BOOST_NO_CXX11_HDR_INITIALIZER_LIST + std::initializer_list

IL = {P(0, 0), P(1, 2), P(2, 0)}; + test_custom_multi_point

(IL); +#endif//BOOST_NO_CXX11_HDR_INITIALIZER_LIST +} + +template +void test_cs() +{ + test_all >(); + test_all >(); + test_all >(); + + test_custom >(); +} + + +int test_main(int, char* []) +{ + test_cs(); + test_cs >(); + test_cs >(); + test_cs >(); + + test_custom >(); + + return 0; +} diff --git a/test/geometries/multi_polygon.cpp b/test/geometries/multi_polygon.cpp new file mode 100644 index 000000000..f0c474db5 --- /dev/null +++ b/test/geometries/multi_polygon.cpp @@ -0,0 +1,166 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// Unit Test + +// Copyright (c) 2020 Digvijay Janartha, Hamirpur, India. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +BOOST_GEOMETRY_REGISTER_C_ARRAY_CS(cs::cartesian) +BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian) + +#ifdef BOOST_NO_CXX11_HDR_INITIALIZER_LIST +#include +#endif//BOOST_NO_CXX11_HDR_INITIALIZER_LIST + +template +bg::model::polygon

create_polygon() +{ + bg::model::polygon

pl1; + P p1; + P p2; + P p3; + bg::assign_values(p1, 1, 2); + bg::assign_values(p2, 2, 0); + bg::assign_values(p3, 0, 0); + + bg::append(pl1, p1); + bg::append(pl1, p2); + bg::append(pl1, p3); + bg::append(pl1, p1); + return pl1; +} + +template +bg::model::multi_polygon create_multi_polygon() +{ + bg::model::multi_polygon mpl1; + PL pl1(create_polygon

()); + mpl1.push_back(pl1); + mpl1.push_back(pl1); + return mpl1; +} + +template +void check_multi_polygon(MPL& to_check, PL pl1) +{ + MPL cur; + cur.push_back(pl1); + cur.push_back(pl1); + + std::ostringstream out1, out2; + out1 << bg::dsv(to_check); + out2 << bg::dsv(cur); + BOOST_CHECK_EQUAL(out1.str(), out2.str()); +} + +template +void test_default_constructor() +{ + bg::model::multi_polygon mpl1(create_multi_polygon()); + check_multi_polygon(mpl1, PL(create_polygon

())); +} + +template +void test_copy_constructor() +{ + bg::model::multi_polygon mpl1 = create_multi_polygon(); + check_multi_polygon(mpl1, PL(create_polygon

())); +} + +template +void test_copy_assignment() +{ + bg::model::multi_polygon mpl1(create_multi_polygon()), mpl2; + mpl2 = mpl1; + check_multi_polygon(mpl2, PL(create_polygon

())); +} + +template +void test_concept() +{ + typedef bg::model::multi_polygon MPL; + + BOOST_CONCEPT_ASSERT( (bg::concepts::ConstMultiPolygon) ); + BOOST_CONCEPT_ASSERT( (bg::concepts::MultiPolygon) ); + + typedef typename bg::coordinate_type::type T; + typedef typename bg::point_type::type PMPL; + boost::ignore_unused(); +} + +template +void test_all() +{ + typedef bg::model::polygon

PL; + + test_default_constructor(); + test_copy_constructor(); + test_copy_assignment(); + test_concept(); +} + +template +void test_custom_multi_polygon(bg::model::polygon

IL) +{ + typedef bg::model::polygon

PL; + + std::initializer_list PIL = {IL}; + bg::model::multi_polygon mpl1(PIL); + std::ostringstream out; + out << bg::dsv(mpl1); + BOOST_CHECK_EQUAL(out.str(), "((((3, 3), (3, 0), (0, 0), (0, 3), (3, 3))))"); +} + +template +void test_custom() +{ +#ifdef BOOST_NO_CXX11_HDR_INITIALIZER_LIST + std::initializer_list

IL = {P(3, 3), P(3, 0), P(0, 0), P(0, 3), P(3, 3)}; + bg::model::ring

r1(IL); + std::initializer_list > RIL = {r1}; + test_custom_multi_polygon

(RIL); +#endif//BOOST_NO_CXX11_HDR_INITIALIZER_LIST +} + +template +void test_cs() +{ + test_all >(); + test_all >(); + test_all >(); + + test_custom >(); +} + + +int test_main(int, char* []) +{ + test_cs(); + test_cs >(); + test_cs >(); + test_cs >(); + + test_custom >(); + + return 0; +} diff --git a/test/geometries/point.cpp b/test/geometries/point.cpp new file mode 100644 index 000000000..23a4151a4 --- /dev/null +++ b/test/geometries/point.cpp @@ -0,0 +1,101 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// Unit Test + +// Copyright (c) 2020 Digvijay Janartha, Hamirpur, India. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + + +#include + +#include +#include +#include +#include + +#include + + +template +bg::model::point create_point() +{ + T t1 = 1; + T t2 = 2; + T t3 = 3; + return bg::model::point(t1, t2, t3); +} + +template +void check_point(P& to_check, T x, T y, T z) +{ + BOOST_CHECK_EQUAL(bg::get<0>(to_check), x); + BOOST_CHECK_EQUAL(bg::get<1>(to_check), y); + BOOST_CHECK_EQUAL(bg::get<2>(to_check), z); +} + +template +void test_default_constructor() +{ + bg::model::point p(create_point()); + check_point(p, 1, 2, 3); +} + +template +void test_copy_constructor() +{ + bg::model::point p = create_point(); + check_point(p, 1, 2, 3); +} + +template +void test_copy_assignment() +{ + bg::model::point p(create_point()); + bg::set<0>(p, 4); + bg::set<1>(p, 5); + bg::set<2>(p, 6); + check_point(p, 4, 5, 6); +} + +template +void test_concept() +{ + typedef bg::model::point P; + + // Compilation tests, all things should compile. + BOOST_CONCEPT_ASSERT( (bg::concepts::ConstPoint

) ); + BOOST_CONCEPT_ASSERT( (bg::concepts::Point

) ); + + typedef typename bg::coordinate_type

::type T1; + boost::ignore_unused(); +} + +template +void test_all() +{ + test_default_constructor(); + test_copy_constructor(); + test_copy_assignment(); + test_concept(); +} + +template +void test_cs() +{ + test_all(); + test_all(); + test_all(); +} + + +int test_main(int, char* []) +{ + test_cs(); + test_cs >(); + test_cs >(); + test_cs >(); + + return 0; +} diff --git a/test/geometries/point_xy.cpp b/test/geometries/point_xy.cpp new file mode 100644 index 000000000..791940140 --- /dev/null +++ b/test/geometries/point_xy.cpp @@ -0,0 +1,75 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// Unit Test + +// Copyright (c) 2020 Digvijay Janartha, Hamirpur, India. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + + +#include + +#include +#include +#include + +#include + + +template +bg::model::d2::point_xy create_point_xy() +{ + T t1 = 1; + T t2 = 2; + return bg::model::d2::point_xy(t1, t2); +} + +template +void check_point_xy(P& to_check, T x, T y) +{ + BOOST_CHECK_EQUAL(bg::get<0>(to_check), x); + BOOST_CHECK_EQUAL(bg::get<1>(to_check), y); + BOOST_CHECK_EQUAL(to_check.x(), x); + BOOST_CHECK_EQUAL(to_check.y(), y); +} + +template +void test_default_constructor() +{ + bg::model::d2::point_xy p(create_point_xy()); + check_point_xy(p, 1, 2); +} + +template +void test_copy_constructor() +{ + bg::model::d2::point_xy p(create_point_xy()); + check_point_xy(p, 1, 2); +} + +template +void test_copy_assignment() +{ + bg::model::d2::point_xy p(create_point_xy()); + bg::set<0>(p, 4); + bg::set<1>(p, 5); + check_point_xy(p, 4, 5); +} + +template +void test_all() +{ + test_default_constructor(); + test_copy_constructor(); + test_copy_assignment(); +} + +int test_main(int, char* []) +{ + test_all(); + test_all(); + test_all(); + + return 0; +} diff --git a/test/geometries/point_xyz.cpp b/test/geometries/point_xyz.cpp new file mode 100644 index 000000000..f52484a2a --- /dev/null +++ b/test/geometries/point_xyz.cpp @@ -0,0 +1,79 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// Unit Test + +// Copyright (c) 2020 Digvijay Janartha, Hamirpur, India. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + + +#include + +#include +#include +#include + +#include + + +template +bg::model::d3::point_xyz create_point_xyz() +{ + T t1 = 1; + T t2 = 2; + T t3 = 3; + return bg::model::d3::point_xyz(t1, t2, t3); +} + +template +void check_point_xyz(P& to_check, T x, T y, T z) +{ + BOOST_CHECK_EQUAL(bg::get<0>(to_check), x); + BOOST_CHECK_EQUAL(bg::get<1>(to_check), y); + BOOST_CHECK_EQUAL(bg::get<2>(to_check), z); + BOOST_CHECK_EQUAL(to_check.x(), x); + BOOST_CHECK_EQUAL(to_check.y(), y); + BOOST_CHECK_EQUAL(to_check.z(), z); +} + +template +void test_default_constructor() +{ + bg::model::d3::point_xyz p(create_point_xyz()); + check_point_xyz(p, 1, 2, 3); +} + +template +void test_copy_constructor() +{ + bg::model::d3::point_xyz p = create_point_xyz(); + check_point_xyz(p, 1, 2, 3); +} + +template +void test_copy_assignment() +{ + bg::model::d3::point_xyz p(create_point_xyz()); + bg::set<0>(p, 4); + bg::set<1>(p, 5); + bg::set<2>(p, 6); + check_point_xyz(p, 4, 5, 6); +} + +template +void test_all() +{ + test_default_constructor(); + test_copy_constructor(); + test_copy_assignment(); +} + +int test_main(int, char* []) +{ + test_all(); + test_all(); + test_all(); + + return 0; +} diff --git a/test/geometries/polygon.cpp b/test/geometries/polygon.cpp new file mode 100644 index 000000000..bf9aeb337 --- /dev/null +++ b/test/geometries/polygon.cpp @@ -0,0 +1,152 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// Unit Test + +// Copyright (c) 2020 Digvijay Janartha, Hamirpur, India. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +BOOST_GEOMETRY_REGISTER_C_ARRAY_CS(cs::cartesian) +BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian) + +#ifdef BOOST_NO_CXX11_HDR_INITIALIZER_LIST +#include +#endif//BOOST_NO_CXX11_HDR_INITIALIZER_LIST + +template +bg::model::polygon

create_polygon() +{ + bg::model::polygon

pl1; + P p1; + P p2; + P p3; + bg::assign_values(p1, 1, 2); + bg::assign_values(p2, 2, 0); + bg::assign_values(p3, 0, 0); + + bg::append(pl1, p1); + bg::append(pl1, p2); + bg::append(pl1, p3); + bg::append(pl1, p1); + return pl1; +} + +template +void check_polygon(PL& to_check, P p1, P p2, P p3) +{ + PL cur; + bg::append(cur, p1); + bg::append(cur, p2); + bg::append(cur, p3); + bg::append(cur, p1); + + std::ostringstream out1, out2; + out1 << bg::dsv(to_check); + out2 << bg::dsv(cur); + BOOST_CHECK_EQUAL(out1.str(), out2.str()); +} + +template +void test_default_constructor() +{ + bg::model::polygon

pl1(create_polygon

()); + check_polygon(pl1, P(1, 2), P(2, 0), P(0, 0)); +} + +template +void test_copy_constructor() +{ + bg::model::polygon

pl1 = create_polygon

(); + check_polygon(pl1, P(1, 2), P(2, 0), P(0, 0)); +} + +template +void test_copy_assignment() +{ + bg::model::polygon

pl1(create_polygon

()), pl2; + pl2 = pl1; + check_polygon(pl2, P(1, 2), P(2, 0), P(0, 0)); +} + +template +void test_concept() +{ + typedef bg::model::polygon

PL; + + BOOST_CONCEPT_ASSERT( (bg::concepts::ConstPolygon) ); + BOOST_CONCEPT_ASSERT( (bg::concepts::Polygon) ); + + typedef typename bg::coordinate_type::type T; + typedef typename bg::point_type::type PPL; + boost::ignore_unused(); +} + +template +void test_all() +{ + test_default_constructor

(); + test_copy_constructor

(); + test_copy_assignment

(); + test_concept

(); +} + +template +void test_custom_polygon(bg::model::ring

IL) +{ +#ifdef BOOST_NO_CXX11_HDR_INITIALIZER_LIST + std::initializer_list > RIL = {IL}; + bg::model::polygon

pl1(RIL); + std::ostringstream out; + out << bg::dsv(pl1); + BOOST_CHECK_EQUAL(out.str(), "(((3, 3), (3, 0), (0, 0), (0, 3), (3, 3)))"); +#endif//BOOST_NO_CXX11_HDR_INITIALIZER_LIST +} + +template +void test_custom() +{ + std::initializer_list

IL = {P(3, 3), P(3, 0), P(0, 0), P(0, 3), P(3, 3)}; + bg::model::ring

r1(IL); + test_custom_polygon

(r1); +} + +template +void test_cs() +{ + test_all >(); + test_all >(); + test_all >(); + + test_custom >(); +} + + +int test_main(int, char* []) +{ + test_cs(); + test_cs >(); + test_cs >(); + test_cs >(); + + test_custom >(); + + return 0; +} diff --git a/test/geometries/ring.cpp b/test/geometries/ring.cpp new file mode 100644 index 000000000..e74378090 --- /dev/null +++ b/test/geometries/ring.cpp @@ -0,0 +1,155 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// Unit Test + +// Copyright (c) 2020 Digvijay Janartha, Hamirpur, India. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +BOOST_GEOMETRY_REGISTER_C_ARRAY_CS(cs::cartesian) +BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian) + +#ifdef BOOST_NO_CXX11_HDR_INITIALIZER_LIST +#include +#endif//BOOST_NO_CXX11_HDR_INITIALIZER_LIST + +template +bg::model::ring

create_ring() +{ + bg::model::ring

r1; + P p1; + P p2; + P p3; + P p4; + bg::assign_values(p1, 2, 2); + bg::assign_values(p2, 2, 0); + bg::assign_values(p3, 0, 0); + bg::assign_values(p4, 0, 2); + + bg::append(r1, p1); + bg::append(r1, p2); + bg::append(r1, p3); + bg::append(r1, p4); + bg::append(r1, p1); + return r1; +} + +template +void check_point(P& to_check, T x, T y) +{ + BOOST_CHECK_EQUAL(bg::get<0>(to_check), x); + BOOST_CHECK_EQUAL(bg::get<1>(to_check), y); +} + +template +void check_ring(R& to_check, P p1, P p2, P p3, P p4) +{ + check_point(to_check[0], bg::get<0>(p1), bg::get<1>(p1)); + check_point(to_check[1], bg::get<0>(p2), bg::get<1>(p2)); + check_point(to_check[2], bg::get<0>(p3), bg::get<1>(p3)); + check_point(to_check[3], bg::get<0>(p4), bg::get<1>(p4)); + check_point(to_check[4], bg::get<0>(p1), bg::get<1>(p1)); +} + +template +void test_default_constructor() +{ + bg::model::ring

r1(create_ring

()); + check_ring(r1, P(2, 2), P(2, 0), P(0, 0), P(0, 2)); +} + +template +void test_copy_constructor() +{ + bg::model::ring

r1 = create_ring

(); + check_ring(r1, P(2, 2), P(2, 0), P(0, 0), P(0, 2)); +} + +template +void test_copy_assignment() +{ + bg::model::ring

r1(create_ring

()), r2; + r2 = r1; + check_ring(r2, P(2, 2), P(2, 0), P(0, 0), P(0, 2)); +} + +template +void test_concept() +{ + typedef bg::model::ring

R; + + BOOST_CONCEPT_ASSERT( (bg::concepts::ConstRing) ); + BOOST_CONCEPT_ASSERT( (bg::concepts::Ring) ); + + typedef typename bg::coordinate_type::type T; + typedef typename bg::point_type::type PR; + boost::ignore_unused(); +} + +template +void test_all() +{ + test_default_constructor

(); + test_copy_constructor

(); + test_copy_assignment

(); + test_concept

(); +} + +template +void test_custom_ring(bg::model::ring

IL) +{ + bg::model::ring

r1(IL); + std::ostringstream out; + out << bg::dsv(r1); + BOOST_CHECK_EQUAL(out.str(), "((3, 3), (3, 0), (0, 0), (0, 3), (3, 3))"); +} + +template +void test_custom() +{ +#ifdef BOOST_NO_CXX11_HDR_INITIALIZER_LIST + std::initializer_list

IL = {P(3, 3), P(3, 0), P(0, 0), P(0, 3), P(3, 3)}; + test_custom_ring

(IL); +#endif//BOOST_NO_CXX11_HDR_INITIALIZER_LIST +} + +template +void test_cs() +{ + test_all >(); + test_all >(); + test_all >(); + + test_custom >(); +} + + +int test_main(int, char* []) +{ + test_cs(); + test_cs >(); + test_cs >(); + test_cs >(); + + test_custom >(); + + return 0; +} diff --git a/test/io/Jamfile.v2 b/test/io/Jamfile similarity index 100% rename from test/io/Jamfile.v2 rename to test/io/Jamfile diff --git a/test/io/dsv/Jamfile.v2 b/test/io/dsv/Jamfile similarity index 100% rename from test/io/dsv/Jamfile.v2 rename to test/io/dsv/Jamfile diff --git a/test/io/svg/Jamfile.v2 b/test/io/svg/Jamfile similarity index 100% rename from test/io/svg/Jamfile.v2 rename to test/io/svg/Jamfile diff --git a/test/io/wkt/Jamfile.v2 b/test/io/wkt/Jamfile similarity index 100% rename from test/io/wkt/Jamfile.v2 rename to test/io/wkt/Jamfile diff --git a/test/iterators/Jamfile.v2 b/test/iterators/Jamfile similarity index 100% rename from test/iterators/Jamfile.v2 rename to test/iterators/Jamfile diff --git a/test/policies/Jamfile.v2 b/test/policies/Jamfile similarity index 100% rename from test/policies/Jamfile.v2 rename to test/policies/Jamfile diff --git a/test/robustness/convex_hull/Jamfile.v2 b/test/robustness/convex_hull/Jamfile similarity index 100% rename from test/robustness/convex_hull/Jamfile.v2 rename to test/robustness/convex_hull/Jamfile diff --git a/test/robustness/overlay/areal_areal/Jamfile.v2 b/test/robustness/overlay/areal_areal/Jamfile similarity index 100% rename from test/robustness/overlay/areal_areal/Jamfile.v2 rename to test/robustness/overlay/areal_areal/Jamfile diff --git a/test/robustness/overlay/buffer/Jamfile.v2 b/test/robustness/overlay/buffer/Jamfile similarity index 100% rename from test/robustness/overlay/buffer/Jamfile.v2 rename to test/robustness/overlay/buffer/Jamfile diff --git a/test/robustness/overlay/linear_areal/Jamfile.v2 b/test/robustness/overlay/linear_areal/Jamfile similarity index 100% rename from test/robustness/overlay/linear_areal/Jamfile.v2 rename to test/robustness/overlay/linear_areal/Jamfile diff --git a/test/srs/Jamfile.v2 b/test/srs/Jamfile similarity index 100% rename from test/srs/Jamfile.v2 rename to test/srs/Jamfile diff --git a/test/strategies/Jamfile.v2 b/test/strategies/Jamfile similarity index 100% rename from test/strategies/Jamfile.v2 rename to test/strategies/Jamfile diff --git a/test/util/Jamfile.v2 b/test/util/Jamfile similarity index 100% rename from test/util/Jamfile.v2 rename to test/util/Jamfile diff --git a/test/views/Jamfile.v2 b/test/views/Jamfile similarity index 100% rename from test/views/Jamfile.v2 rename to test/views/Jamfile