diff --git a/README.md b/README.md index 27ba8cdad..bbba7d46f 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,15 @@ Boost.Geometry, part of collection of the [Boost C++ Libraries](http://github.co * **index** - examples and tests for the Spatial Index * **test** - Boost.Geometry unit tests +### Test results + +@ | Build | Coverage | Regression +------------|---------------|----------------|------------ +**master** | [![status](https://img.shields.io/circleci/project/awulkiew/geometry/master.png)](https://circleci.com/gh/awulkiew/geometry/tree/master) | [![status](https://img.shields.io/coveralls/awulkiew/geometry/master.png)](https://coveralls.io/r/awulkiew/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://img.shields.io/circleci/project/awulkiew/geometry/develop.png)](https://circleci.com/gh/awulkiew/geometry/tree/develop) | [![status](https://img.shields.io/coveralls/awulkiew/geometry/develop.png)](https://coveralls.io/r/awulkiew/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) + ### More information -* [Wiki](http://github.com/boostorg/geometry/wiki) * [Documentation](http://boost.org/libs/geometry) +* [Wiki](http://github.com/boostorg/geometry/wiki) + diff --git a/circle.yml b/circle.yml new file mode 100644 index 000000000..4a421267a --- /dev/null +++ b/circle.yml @@ -0,0 +1,174 @@ +# Use, modification, and distribution are +# 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) +# +# Copyright Antony Polukhin 2014. +# Copyright Adam Wulkiewicz 2015. + +general: + branches: + only: + - master + - develop + - test + +machine: + environment: + # define tests list, if parallelism is enabled they are run in parallel + TESTS: test index/test + + # this is not fully bulletproof, ideally one should check + # if the current branch originates in master or develop + # but it's good enough + # test library using corresponding branch of Boost repository + BOOST_BRANCH: $([[ "$CIRCLE_BRANCH" = "master" ]] && echo master || echo develop) + + # required directories + BOOST_DIR: boost-local + COVERAGE_DIR: coverage-local + + # helper variables + PROJECT_ROOT: $HOME/$CIRCLE_PROJECT_REPONAME + BOOST_ROOT: $PROJECT_ROOT/$BOOST_DIR + COVERAGE_ROOT: $PROJECT_ROOT/$COVERAGE_DIR + #COVERAGE_ROOT: $CIRCLE_ARTIFACTS + +dependencies: + pre: + - sudo apt-get update + + # gcc, g++, gcov + - sudo apt-get install gcc-4.8 g++-4.8 build-essential + - sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 10 + - sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 10 + - sudo update-alternatives --install /usr/bin/gcov gcov /usr/bin/gcov-4.8 10 + - sudo update-alternatives --install /usr/bin/cc cc /usr/bin/gcc 20 + - sudo update-alternatives --set cc /usr/bin/gcc + - sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++ 20 + - sudo update-alternatives --set c++ /usr/bin/g++ + - sudo update-alternatives --config gcc + - sudo update-alternatives --config g++ + - sudo update-alternatives --config gcov + + # coveralls-lcov for lcov *.info to JSON conversion + - gem install coveralls-lcov + + # jq for JSON handling + - sudo apt-get install jq + + # curl for HTTP + - sudo apt-get install curl + + # clone boost repository + - mkdir $BOOST_ROOT + - cd $BOOST_ROOT && git init . + - cd $BOOST_ROOT && git remote add --no-tags -t $BOOST_BRANCH origin https://github.com/boostorg/boost.git + - cd $BOOST_ROOT && git fetch --depth=1 + - cd $BOOST_ROOT && git checkout $BOOST_BRANCH + - cd $BOOST_ROOT && git submodule update --init --merge + - cd $BOOST_ROOT && git remote set-branches --add origin $BOOST_BRANCH + - cd $BOOST_ROOT && git pull --recurse-submodules + - cd $BOOST_ROOT && git submodule update --init + - cd $BOOST_ROOT && git checkout $BOOST_BRANCH + - cd $BOOST_ROOT && git submodule foreach "git reset --quiet --hard; git clean -fxd" + - cd $BOOST_ROOT && git reset --hard; git clean -fxd + - cd $BOOST_ROOT && git status + # replace the content of the library with the currently tested repo + - cd $BOOST_ROOT && rm -rf libs/geometry/ + - mkdir $BOOST_ROOT/libs/geometry + - cp -R `ls -A | grep -v $BOOST_DIR` $BOOST_ROOT/libs/geometry/ + # build b2 and create headers + - cd $BOOST_ROOT && ./bootstrap.sh + - cd $BOOST_ROOT && ./b2 headers + + # wait with the modifications of the project directory until now + # to avoid copying into the $BOOST_ROOT/libs/geometry/ + + # download and install the latest lcov + # do not use the old one from sources + - wget http://downloads.sourceforge.net/ltp/lcov-1.11.tar.gz + - tar xvzf lcov-1.11.tar.gz + - cd lcov-1.11 && sudo make install + + # create a direcotry for temporary coverage data + - if [ ! -d $COVERAGE_ROOT ]; then mkdir $COVERAGE_ROOT; fi + +test: + override: + # `--coverage` flags required to generate coverage info for Coveralls + # temporary for test purposes + #- cd $BOOST_ROOT/libs/geometry && ../../b2 cxxflags="--coverage" linkflags="--coverage" test/algorithms + #- cd $BOOST_ROOT/libs/geometry && ../../b2 cxxflags="--coverage" linkflags="--coverage" test/algorithms/detail + #- cd $BOOST_ROOT/libs/geometry && ../../b2 cxxflags="--coverage" linkflags="--coverage" test/algorithms/relational_operations + #- cd $BOOST_ROOT/libs/geometry && ../../b2 cxxflags="--coverage" linkflags="--coverage" test + #- cd $BOOST_ROOT/libs/geometry && ../../b2 cxxflags="--coverage" linkflags="--coverage" index/test/algorithms + #- cd $BOOST_ROOT/libs/geometry && ../../b2 cxxflags="--coverage" linkflags="--coverage" index/test/rtree/exceptions + # this is the first step of the first approach to automatic balancing + # the problem is that first the upper-level dir is handled + # then the tests from lower dir are executed, so the tests in various containers overlap + #- cd $BOOST_ROOT/libs/geometry && index=0 ; run_tests() { for i in "$1"/* ; do if [ -f "$i"/Jamfile* ] ; then ((index++)) ; echo "$index - $i" ; ../../b2 cxxflags="--coverage" linkflags="--coverage" "$i" ; run_tests "$i" ; fi ; done } ; run_tests test + + # so for now just run the tests from the list + - cd $BOOST_ROOT/libs/geometry && index=0 ; for t in ${TESTS[@]} ; do if [ $((index%CIRCLE_NODE_TOTAL)) -eq $CIRCLE_NODE_INDEX ] ; then ../../b2 cxxflags="--coverage" linkflags="--coverage" $t ; fi ; ((index++)) ; done : + parallel: true + + post: + ## Copying Coveralls data to a separate folder + #- find $BOOST_ROOT/bin.v2/ -name "*.gcda" -exec mv "{}" $COVERAGE_ROOT \; + #- find $BOOST_ROOT/bin.v2/ -name "*.gcno" -exec mv "{}" $COVERAGE_ROOT \; + # upgraded version - change the file name if exists + - find $BOOST_ROOT/bin.v2/ -name "*.gcda" -exec bash -c 'filen=$(basename $1) ; filen=${filen%.*} ; dirn=$(dirname $1) ; dstfilen=$filen ; while [ -f $COVERAGE_ROOT/$dstfilen.gcda ]; do dstfilen=$filen.$RANDOM ; done ; mv $dirn/$filen.gcda $COVERAGE_ROOT/$dstfilen.gcda ; mv $dirn/$filen.gcno $COVERAGE_ROOT/$dstfilen.gcno ; echo $dstfilen' bash "{}" \; : + parallel: true + + ## Preparing Coveralls data by + + ## ... changind data format to a readable one + + - cd $BOOST_ROOT/libs/geometry && lcov --directory $COVERAGE_ROOT --base-directory ./ --capture --output-file $COVERAGE_ROOT/coverage.info : + parallel: true + + ## ... erasing /usr and unneeded directories data + - lcov --remove $COVERAGE_ROOT/coverage.info "/usr*" "*/libs/geometry/*" -o $COVERAGE_ROOT/coverage.info : + parallel: true + + ## ... erasing data that is not related to this project directly + - ls $BOOST_ROOT/boost | sed -r '/(geometry.*)/d' | sed -r 's/(.+)/"*\/boost\/\1\/*"/g' | sed -r 's/(.+\.hpp)\/\*/\1/g' | sed ':a;N;$!ba;s/\n/ /g' | xargs lcov --remove $COVERAGE_ROOT/coverage.info -o $COVERAGE_ROOT/coverage.info : + parallel: true + + ## ... sanity check + - ls -lah $COVERAGE_ROOT : + parallel: true + + ## Sending data to Coveralls + + ## ... gather all files in one container + - if [ $CIRCLE_NODE_INDEX = 0 ]; then mv $COVERAGE_ROOT/coverage.info $COVERAGE_ROOT/coverage0.info ; else scp $COVERAGE_ROOT/coverage.info node0:$COVERAGE_ROOT/coverage$CIRCLE_NODE_INDEX.info ; fi : + parallel: true + + ## ... merge info files + - lcov `ls $COVERAGE_ROOT/coverage*.info | sed -r 's/(.+)/--add-tracefile \1/g'` -o $COVERAGE_ROOT/coverage.info + + ## ... handle sending manually + ## ... convert data with coveralls-lcov + - coveralls-lcov --repo-token=$COVERALLS_REPO_TOKEN -v -n $COVERAGE_ROOT/coverage.info > $COVERAGE_ROOT/coverage.json #: + #parallel: true + + ## ... alter the json file + - jq -c ".service_name = \"circle-ci\" | .service_job_id = \"$CIRCLE_BUILD_NUM\" | .git .branch =\"$CIRCLE_BRANCH\"" $COVERAGE_ROOT/coverage.json > $COVERAGE_ROOT/processed.json + #- jq -c ".service_name = \"circle-ci\" | .service_job_id = \"$CIRCLE_BUILD_NUM\" | .parallel = true | .git .branch =\"$CIRCLE_BRANCH\"" $COVERAGE_ROOT/coverage.json > $COVERAGE_ROOT/processed.json #: + #parallel: true + + ## ... send it to Coveralls + - curl --retry 3 -F "json_file=@$COVERAGE_ROOT/processed.json" 'https://coveralls.io/api/v1/jobs' #: + #parallel: true + + ## ... notify Coveralls that the parallel build has ended + # this doesn't work - Coveralls returns an error + #- echo "{\"payload\":{\"build_num\":\"$CIRCLE_BUILD_NUM\",\"status\":\"done\"}}" > $COVERAGE_ROOT/payload.json && curl --retry 3 -F "json_file=@$COVERAGE_ROOT/payload.json" "https://coveralls.io/webhook?repo_token=$COVERALLS_REPO_TOKEN" + #- echo "{\"payload\":{\"build_num\":\"$CIRCLE_BUILD_NUM\",\"status\":\"done\"}}" > $COVERAGE_ROOT/payload.json && curl --retry 3 -d "@$COVERAGE_ROOT/payload.json" "https://coveralls.io/webhook?repo_token=$COVERALLS_REPO_TOKEN" + +## This doesn't work - no effect +#notify: +# webhooks: + # Notify Coveralls that the build has ended + #- url: https://coveralls.io/webhook?repo_token=$COVERALLS_REPO_TOKEN diff --git a/include/boost/geometry/policies/robustness/get_rescale_policy.hpp b/include/boost/geometry/policies/robustness/get_rescale_policy.hpp index 51e969152..32306f686 100644 --- a/include/boost/geometry/policies/robustness/get_rescale_policy.hpp +++ b/include/boost/geometry/policies/robustness/get_rescale_policy.hpp @@ -28,6 +28,7 @@ #include #include +#include #include #include #include @@ -87,6 +88,11 @@ static inline void init_rescale_policy(Geometry const& geometry, RobustPoint& min_robust_point, Factor& factor) { + if (geometry::is_empty(geometry)) + { + return; + } + // Get bounding boxes model::box env = geometry::return_envelope >(geometry); @@ -100,10 +106,36 @@ static inline void init_rescale_policy(Geometry1 const& geometry1, RobustPoint& min_robust_point, Factor& factor) { - // Get bounding boxes - model::box env = geometry::return_envelope >(geometry1); - model::box env2 = geometry::return_envelope >(geometry2); - geometry::expand(env, env2); + // Get bounding boxes (when at least one of the geometries is not empty) + bool const is_empty1 = geometry::is_empty(geometry1); + bool const is_empty2 = geometry::is_empty(geometry2); + if (is_empty1 && is_empty2) + { + return; + } + + model::box env; + if (is_empty1) + { + geometry::envelope(geometry2, env); + } + else if (is_empty2) + { + geometry::envelope(geometry1, env); + } + else + { + // The following approach (envelope + expand) may not give the + // optimal MBR when then two geometries are in the spherical + // equatorial or geographic coordinate systems. + // TODO: implement envelope for two (or possibly more geometries) + geometry::envelope(geometry1, env); + model::box env2 = geometry::return_envelope + < + model::box + >(geometry2); + geometry::expand(env, env2); + } scale_box_to_integer_range(env, min_point, min_robust_point, factor); } diff --git a/test/algorithms/envelope_on_spheroid.cpp b/test/algorithms/envelope_on_spheroid.cpp index 1f3aa4114..3938418ed 100644 --- a/test/algorithms/envelope_on_spheroid.cpp +++ b/test/algorithms/envelope_on_spheroid.cpp @@ -998,15 +998,11 @@ BOOST_AUTO_TEST_CASE( envelope_linestring ) from_wkt("LINESTRING(10 10,20 20,10 30)"), 10, 10, 20, 30); - // linestring that circles most of the globe - tester::apply("l03", - from_wkt("LINESTRING(-170 25,-50 10,10 10,20 20,100 5,180 15)"), - -170, 5, 180, 25.15036418555258); - // linestring that circles the entire globe tester::apply("l03", from_wkt("LINESTRING(-185 0,-170 25,-50 10,10 10,20 20,100 5,180 15)"), - -180, 0, 180, 25.15036418555258); + -180, 0, 180, 25.15036418555258, + 4.0 * std::numeric_limits::epsilon()); // linestring that crosses the antimeridian but staying close to it tester::apply("l04", diff --git a/test/algorithms/expand_on_spheroid.cpp b/test/algorithms/expand_on_spheroid.cpp index 8199fe842..98db446ad 100644 --- a/test/algorithms/expand_on_spheroid.cpp +++ b/test/algorithms/expand_on_spheroid.cpp @@ -616,7 +616,8 @@ BOOST_AUTO_TEST_CASE( expand_segment ) tester::apply("s03", from_wkt("BOX(5 5,50 10)"), from_wkt("SEGMENT(40 10,10 10)"), - 5, 5, 50, 10.34527004614999); + 5, 5, 50, 10.34527004614999, + 4.0 * std::numeric_limits::epsilon()); // segment ending at the north pole tester::apply("s04", diff --git a/test/algorithms/relational_operations/Jamfile.v2 b/test/algorithms/relational_operations/Jamfile.v2 index a0c110b1b..89ce7c88b 100644 --- a/test/algorithms/relational_operations/Jamfile.v2 +++ b/test/algorithms/relational_operations/Jamfile.v2 @@ -22,13 +22,11 @@ test-suite boost-geometry-algorithms-relational [ run equals.cpp : : : : algorithms_equals ] [ run equals_multi.cpp : : : : algorithms_equals_multi ] [ run equals_on_spheroid.cpp : : : : algorithms_equals_on_spheroid ] - [ run intersects.cpp : : : : algorithms_intersects ] - [ run intersects_multi.cpp : : : : algorithms_intersects_multi ] - [ run overlaps.cpp : : : : algorithms_overlaps ] - [ run touches.cpp : : : : algorithms_touches ] - [ run touches_multi.cpp : : : : algorithms_touches_multi ] ; build-project disjoint ; +build-project intersects ; +build-project overlaps ; build-project relate ; +build-project touches ; build-project within ; diff --git a/test/algorithms/relational_operations/disjoint/Jamfile.v2 b/test/algorithms/relational_operations/disjoint/Jamfile.v2 index f05fff767..ef3122f91 100644 --- a/test/algorithms/relational_operations/disjoint/Jamfile.v2 +++ b/test/algorithms/relational_operations/disjoint/Jamfile.v2 @@ -16,7 +16,13 @@ test-suite boost-geometry-algorithms-disjoint : - [ run disjoint.cpp : : : : algorithms_disjoint ] - [ run disjoint_coverage.cpp : : : : algorithms_disjoint_coverage ] - [ run disjoint_multi.cpp : : : : algorithms_disjoint_multi ] + [ run disjoint.cpp : : : : algorithms_disjoint ] + [ run disjoint_coverage_a_a.cpp : : : : algorithms_disjoint_coverage_a_a ] + [ run disjoint_coverage_l_a.cpp : : : : algorithms_disjoint_coverage_l_a ] + [ run disjoint_coverage_l_l.cpp : : : : algorithms_disjoint_coverage_l_l ] + [ run disjoint_coverage_p_a.cpp : : : : algorithms_disjoint_coverage_p_a ] + [ run disjoint_coverage_p_l.cpp : : : : algorithms_disjoint_coverage_p_l ] + [ run disjoint_coverage_p_p.cpp : : : : algorithms_disjoint_coverage_p_p ] + [ run disjoint_multi.cpp : : : : algorithms_disjoint_multi ] + [ run disjoint_point_box_geometry.cpp : : : : algorithms_disjoint_point_box_geometry ] ; diff --git a/test/algorithms/relational_operations/disjoint/disjoint.cpp b/test/algorithms/relational_operations/disjoint/disjoint.cpp index 7299af406..2d0225daf 100644 --- a/test/algorithms/relational_operations/disjoint/disjoint.cpp +++ b/test/algorithms/relational_operations/disjoint/disjoint.cpp @@ -1,9 +1,14 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test -// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. -// Copyright (c) 2008-2012 Bruno Lalande, Paris, France. -// Copyright (c) 2009-2012 Mateusz Loskot, London, UK. +// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2015 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2015 Mateusz Loskot, London, UK. + +// This file was modified by Oracle on 2015. +// Modifications copyright (c) 2015, Oracle and/or its affiliates. + +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. @@ -29,33 +34,6 @@ template void test_all() { - typedef bg::model::box

box; - - test_disjoint("pp1", "point(1 1)", "point(1 1)", false); - test_disjoint("pp2", "point(1 1)", "point(1.001 1)", true); - - // left-right - test_disjoint("bb1", "box(1 1, 2 2)", "box(3 1, 4 2)", true); - test_disjoint("bb2", "box(1 1, 2 2)", "box(2 1, 3 2)", false); - test_disjoint("bb3", "box(1 1, 2 2)", "box(2 2, 3 3)", false); - test_disjoint("bb4", "box(1 1, 2 2)", "box(2.001 2, 3 3)", true); - - // up-down - test_disjoint("bb5", "box(1 1, 2 2)", "box(1 3, 2 4)", true); - test_disjoint("bb6", "box(1 1, 2 2)", "box(1 2, 2 3)", false); - // right-left - test_disjoint("bb7", "box(1 1, 2 2)", "box(0 1, 1 2)", false); - test_disjoint("bb8", "box(1 1, 2 2)", "box(0 1, 1 2)", false); - - // point-box - test_disjoint("pb1", "point(1 1)", "box(0 0, 2 2)", false); - test_disjoint("pb2", "point(2 2)", "box(0 0, 2 2)", false); - test_disjoint("pb3", "point(2.0001 2)", "box(1 1, 2 2)", true); - test_disjoint("pb4", "point(0.9999 2)", "box(1 1, 2 2)", true); - - // box-point (to test reverse compiling) - test_disjoint("bp1", "box(1 1, 2 2)", "point(2 2)", false); - // Test triangles for polygons/rings, boxes // Note that intersections are tested elsewhere, they don't need // thorough test at this place @@ -75,27 +53,10 @@ void test_all() // Testing touch test_disjoint("touch_simplex_pp", touch_simplex[0], touch_simplex[1], false); - // Testing overlap (and test compiling with box) - test_disjoint("overlaps_box_pp", overlaps_box[0], overlaps_box[1], false); - test_disjoint("overlaps_box_bp", overlaps_box[0], overlaps_box[1], false); - test_disjoint("overlaps_box_br", overlaps_box[0], overlaps_box[1], false); - test_disjoint("overlaps_box_pb", overlaps_box[1], overlaps_box[0], false); - test_disjoint("overlaps_box_rb", overlaps_box[1], overlaps_box[0], false); - // Test if within(a,b) returns false for disjoint test_disjoint("within_simplex_rr1", within_simplex[0], within_simplex[1], false); test_disjoint("within_simplex_rr2", within_simplex[1], within_simplex[0], false); - test_disjoint("point_ring1", "POINT(0 0)", "POLYGON((0 0,3 3,6 0,0 0))", false); - test_disjoint("point_ring2", "POINT(3 1)", "POLYGON((0 0,3 3,6 0,0 0))", false); - test_disjoint("point_ring3", "POINT(0 3)", "POLYGON((0 0,3 3,6 0,0 0))", true); - test_disjoint("point_polygon1", "POINT(0 0)", "POLYGON((0 0,3 3,6 0,0 0))", false); - test_disjoint("point_polygon2", "POINT(3 1)", "POLYGON((0 0,3 3,6 0,0 0))", false); - test_disjoint("point_polygon3", "POINT(0 3)", "POLYGON((0 0,3 3,6 0,0 0))", true); - - test_disjoint("point_ring2", "POLYGON((0 0,3 3,6 0,0 0))", "POINT(0 0)", false); - test_disjoint("point_polygon2", "POLYGON((0 0,3 3,6 0,0 0))", "POINT(0 0)", false); - // Linear typedef bg::model::linestring

ls; typedef bg::model::segment

segment; @@ -116,15 +77,6 @@ void test_all() test_disjoint("ls/ls co-e", "linestring(0 0,1 1)", "linestring(1 1,0 0)", false); - // Problem described by Volker/Albert 2012-06-01 - test_disjoint("volker_albert_1", - "POLYGON((1992 3240,1992 1440,3792 1800,3792 3240,1992 3240))", - "BOX(1941 2066, 2055 2166)", false); - - test_disjoint("volker_albert_2", - "POLYGON((1941 2066,2055 2066,2055 2166,1941 2166))", - "BOX(1941 2066, 2055 2166)", false); - // Degenerate linestrings { // Submitted by Zachary on the Boost.Geometry Mailing List, on 2012-01-29 @@ -199,21 +151,6 @@ void test_all() } -template -void test_3d() -{ - typedef bg::model::box

box; - - test_disjoint("pp 3d 1", "point(1 1 1)", "point(1 1 1)", false); - test_disjoint("pp 3d 2", "point(1 1 1)", "point(1.001 1 1)", true); - - test_disjoint("bb1", "box(1 1 1, 2 2 2)", "box(3 1 1, 4 2 1)", true); - test_disjoint("bb2", "box(1 1 1, 2 2 2)", "box(2 1 1, 3 2 1)", false); - test_disjoint("bb3", "box(1 1 1, 2 2 2)", "box(2 2 1, 3 3 1)", false); - test_disjoint("bb4", "box(1 1 1, 2 2 2)", "box(2.001 2 1, 3 3 1)", true); - -} - int test_main(int, char* []) { test_all >(); @@ -223,8 +160,6 @@ int test_main(int, char* []) test_all >(); #endif - test_3d >(); - return 0; } diff --git a/test/algorithms/relational_operations/disjoint/disjoint_coverage.cpp b/test/algorithms/relational_operations/disjoint/disjoint_coverage.cpp deleted file mode 100644 index d0d6bdc40..000000000 --- a/test/algorithms/relational_operations/disjoint/disjoint_coverage.cpp +++ /dev/null @@ -1,1759 +0,0 @@ -// Boost.Geometry (aka GGL, Generic Geometry Library) - -// Copyright (c) 2014-2015, Oracle and/or its affiliates. - -// Licensed under the Boost Software License version 1.0. -// http://www.boost.org/users/license.html - -// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle - -#ifndef BOOST_TEST_MODULE -#define BOOST_TEST_MODULE test_disjoint_coverage -#endif - -// unit test to test disjoint for all geometry combinations - -#include - -#include - -#include -#include - -#include - -#include -#include - -#include - -#include - -#include - - -#ifdef HAVE_TTMATH -#include -#endif - -namespace bg = ::boost::geometry; - -//============================================================================ - -struct test_disjoint -{ - template - static inline void apply(std::string const& case_id, - Geometry1 const& geometry1, - Geometry2 const& geometry2, - bool expected_result) - { - bool result = bg::disjoint(geometry1, geometry2); - BOOST_CHECK_MESSAGE(result == expected_result, - "case ID: " << case_id << ", G1: " << bg::wkt(geometry1) - << ", G2: " << bg::wkt(geometry2) << " -> Expected: " - << expected_result << ", detected: " << result); - - result = bg::disjoint(geometry2, geometry1); - BOOST_CHECK_MESSAGE(result == expected_result, - "case ID: " << case_id << ", G1: " << bg::wkt(geometry2) - << ", G2: " << bg::wkt(geometry1) << " -> Expected: " - << expected_result << ", detected: " << result); - -#ifdef BOOST_GEOMETRY_TEST_DEBUG - std::cout << "case ID: " << case_id << "; G1 - G2: "; - std::cout << bg::wkt(geometry1) << " - "; - std::cout << bg::wkt(geometry2) << std::endl; - std::cout << std::boolalpha; - std::cout << "expected/computed result: " - << expected_result << " / " << result << std::endl; - std::cout << std::endl; - std::cout << std::noboolalpha; -#endif - } -}; - -//============================================================================ - -// pointlike-pointlike geometries -template -inline void test_point_point() -{ - typedef test_disjoint tester; - - tester::apply("p-p-01", - from_wkt

("POINT(0 0)"), - from_wkt

("POINT(0 0)"), - false); - - tester::apply("p-p-02", - from_wkt

("POINT(0 0)"), - from_wkt

("POINT(1 1)"), - true); -} - -template -inline void test_point_multipoint() -{ - typedef bg::model::multi_point

MP; - - typedef test_disjoint tester; - - tester::apply("p-mp-01", - from_wkt

("POINT(0 0)"), - from_wkt("MULTIPOINT(0 0,1 1)"), - false); - - tester::apply("p-mp-02", - from_wkt

("POINT(0 0)"), - from_wkt("MULTIPOINT(1 1,2 2)"), - true); - - tester::apply("p-mp-03", - from_wkt

("POINT(0 0)"), - from_wkt("MULTIPOINT()"), - true); -} - -template -inline void test_multipoint_multipoint() -{ - typedef bg::model::multi_point

MP; - - typedef test_disjoint tester; - - tester::apply("mp-mp-01", - from_wkt("MULTIPOINT(0 0,1 0)"), - from_wkt("MULTIPOINT(0 0,1 1)"), - false); - - tester::apply("mp-mp-02", - from_wkt("MULTIPOINT(0 0,1 0)"), - from_wkt("MULTIPOINT(1 1,2 2)"), - true); - - tester::apply("mp-mp-03", - from_wkt("MULTIPOINT()"), - from_wkt("MULTIPOINT(1 1,2 2)"), - true); - - tester::apply("mp-mp-04", - from_wkt("MULTIPOINT(0 0,1 0)"), - from_wkt("MULTIPOINT()"), - true); -} - -//============================================================================ - -// pointlike-linear geometries -template -inline void test_point_segment() -{ - typedef test_disjoint tester; - typedef bg::model::segment

S; - - tester::apply("p-s-01", - from_wkt

("POINT(0 0)"), - from_wkt("SEGMENT(0 0,2 0)"), - false); - - tester::apply("p-s-02", - from_wkt

("POINT(2 0)"), - from_wkt("SEGMENT(0 0,2 0)"), - false); - - tester::apply("p-s-03", - from_wkt

("POINT(1 0)"), - from_wkt("SEGMENT(0 0,2 0)"), - false); - - tester::apply("p-s-04", - from_wkt

("POINT(1 1)"), - from_wkt("SEGMENT(0 0,2 0)"), - true); - - tester::apply("p-s-05", - from_wkt

("POINT(3 0)"), - from_wkt("SEGMENT(0 0,2 0)"), - true); - - tester::apply("p-s-06", - from_wkt

("POINT(-1 0)"), - from_wkt("SEGMENT(0 0,2 0)"), - true); - - // degenerate segment - tester::apply("p-s-07", - from_wkt

("POINT(-1 0)"), - from_wkt("SEGMENT(2 0,2 0)"), - true); - - // degenerate segment - tester::apply("p-s-08", - from_wkt

("POINT(2 0)"), - from_wkt("SEGMENT(2 0,2 0)"), - false); - - // degenerate segment - tester::apply("p-s-09", - from_wkt

("POINT(3 0)"), - from_wkt("SEGMENT(2 0,2 0)"), - true); - - // degenerate segment - tester::apply("p-s-10", - from_wkt

("POINT(1 1)"), - from_wkt("SEGMENT(2 0,2 0)"), - true); -} - -template -inline void test_point_linestring() -{ - typedef bg::model::linestring

L; - - typedef test_disjoint tester; - - tester::apply("p-l-01", - from_wkt

("POINT(0 0)"), - from_wkt("LINESTRING(0 0,2 2,4 4)"), - false); - - tester::apply("p-l-02", - from_wkt

("POINT(1 1)"), - from_wkt("LINESTRING(0 0,2 2,4 4)"), - false); - - tester::apply("p-l-03", - from_wkt

("POINT(3 3)"), - from_wkt("LINESTRING(0 0,2 2,4 4)"), - false); - - tester::apply("p-l-04", - from_wkt

("POINT(1 0)"), - from_wkt("LINESTRING(0 0,2 2,4 4)"), - true); - - tester::apply("p-l-05", - from_wkt

("POINT(5 5)"), - from_wkt("LINESTRING(0 0,2 2,4 4)"), - true); - - tester::apply("p-l-06", - from_wkt

("POINT(5 5)"), - from_wkt("LINESTRING(0 0,2 2)"), - true); -} - -template -inline void test_point_multilinestring() -{ - typedef bg::model::linestring

L; - typedef bg::model::multi_linestring ML; - - typedef test_disjoint tester; - - tester::apply("p-ml-01", - from_wkt

("POINT(0 1)"), - from_wkt("MULTILINESTRING((0 0,2 2,4 4),(0 0,2 0,4 0))"), - true); - - tester::apply("p-ml-02", - from_wkt

("POINT(0 0)"), - from_wkt("MULTILINESTRING((0 0,2 2,4 4),(0 0,2 0,4 0))"), - false); - - tester::apply("p-ml-03", - from_wkt

("POINT(1 1)"), - from_wkt("MULTILINESTRING((0 0,2 2,4 4),(0 0,2 0,4 0))"), - false); - - tester::apply("p-ml-04", - from_wkt

("POINT(1 0)"), - from_wkt("MULTILINESTRING((0 0,2 2,4 4),(0 0,2 0,4 0))"), - false); - - tester::apply("p-ml-05", - from_wkt

("POINT(0 0)"), - from_wkt("MULTILINESTRING((1 1,2 2,4 4),(3 0,4 0))"), - true); - - tester::apply("p-ml-06", - from_wkt

("POINT(0 0)"), - from_wkt("MULTILINESTRING((1 1,2 2,4 4),(0 0,4 0))"), - false); - - tester::apply("p-ml-07", - from_wkt

("POINT(0 0)"), - from_wkt("MULTILINESTRING((1 1,2 2,4 4),(-1 0,4 0))"), - false); -} - -template -inline void test_multipoint_segment() -{ - typedef test_disjoint tester; - typedef bg::model::multi_point

MP; - typedef bg::model::segment

S; - - tester::apply("mp-s-01", - from_wkt("MULTIPOINT(0 0,1 1)"), - from_wkt("SEGMENT(0 0,2 0)"), - false); - - tester::apply("mp-s-02", - from_wkt("MULTIPOINT(1 0,1 1)"), - from_wkt("SEGMENT(0 0,2 0)"), - false); - - tester::apply("mp-s-03", - from_wkt("MULTIPOINT(1 1,2 2)"), - from_wkt("SEGMENT(0 0,2 0)"), - true); - - tester::apply("mp-s-04", - from_wkt("MULTIPOINT()"), - from_wkt("SEGMENT(0 0,2 0)"), - true); - - tester::apply("mp-s-05", - from_wkt("MULTIPOINT(3 0,4 0)"), - from_wkt("SEGMENT(0 0,2 0)"), - true); - - tester::apply("mp-s-06", - from_wkt("MULTIPOINT(1 0,4 0)"), - from_wkt("SEGMENT(0 0,2 0)"), - false); - - // segments that degenerate to a point - tester::apply("mp-s-07", - from_wkt("MULTIPOINT(1 1,2 2)"), - from_wkt("SEGMENT(0 0,0 0)"), - true); - - tester::apply("mp-s-08", - from_wkt("MULTIPOINT(1 1,2 2)"), - from_wkt("SEGMENT(1 1,1 1)"), - false); -} - -template -inline void test_multipoint_linestring() -{ - typedef bg::model::multi_point

MP; - typedef bg::model::linestring

L; - - typedef test_disjoint tester; - - tester::apply("mp-l-01", - from_wkt("MULTIPOINT(0 0,1 0)"), - from_wkt("LINESTRING(0 0,2 2,4 4)"), - false); - - tester::apply("mp-l-02", - from_wkt("MULTIPOINT(1 0,1 1)"), - from_wkt("LINESTRING(0 0,2 2,4 4)"), - false); - - tester::apply("mp-l-03", - from_wkt("MULTIPOINT(1 0,3 3)"), - from_wkt("LINESTRING(0 0,2 2,4 4)"), - false); - - tester::apply("mp-l-04", - from_wkt("MULTIPOINT(1 0,2 0)"), - from_wkt("LINESTRING(0 0,2 2,4 4)"), - true); - - tester::apply("mp-l-05", - from_wkt("MULTIPOINT(-1 -1,2 0)"), - from_wkt("LINESTRING(0 0,2 2,4 4)"), - true); - - tester::apply("mp-l-06", - from_wkt("MULTIPOINT(-1 -1,2 0)"), - from_wkt("LINESTRING(1 0,3 0)"), - false); - - tester::apply("mp-l-07", - from_wkt("MULTIPOINT(-1 -1,2 0,-1 -1,2 0)"), - from_wkt("LINESTRING(1 0,3 0)"), - false); - - tester::apply("mp-l-08", - from_wkt("MULTIPOINT(2 0)"), - from_wkt("LINESTRING(1 0)"), - true); - - tester::apply("mp-l-09", - from_wkt("MULTIPOINT(3 0,0 0,3 0)"), - from_wkt("LINESTRING(1 0,2 0)"), - true); -} - -template -inline void test_multipoint_multilinestring() -{ - typedef bg::model::multi_point

MP; - typedef bg::model::linestring

L; - typedef bg::model::multi_linestring ML; - - typedef test_disjoint tester; - - tester::apply("mp-ml-01", - from_wkt("MULTIPOINT(0 1,0 2)"), - from_wkt("MULTILINESTRING((0 0,2 2,4 4),(0 0,2 0,4 0))"), - true); - - tester::apply("mp-ml-02", - from_wkt("MULTIPOINT(0 0,1 0)"), - from_wkt("MULTILINESTRING((0 0,2 2,4 4),(0 0,2 0,4 0))"), - false); - - tester::apply("mp-ml-03", - from_wkt("MULTIPOINT(0 1,1 1)"), - from_wkt("MULTILINESTRING((0 0,2 2,4 4),(0 0,2 0,4 0))"), - false); - - tester::apply("mp-ml-04", - from_wkt("MULTIPOINT(0 1,1 0)"), - from_wkt("MULTILINESTRING((0 0,2 2,4 4),(0 0,2 0,4 0))"), - false); - - tester::apply("mp-ml-05", - from_wkt("MULTIPOINT(0 0,10 0)"), - from_wkt("MULTILINESTRING((0 0,2 2,4 4),(0 0,2 0,4 0))"), - false); - - tester::apply("mp-ml-06", - from_wkt("MULTIPOINT(-1 0,3 0)"), - from_wkt("MULTILINESTRING((0 0,2 2,4 4),(0 0,2 0,4 0))"), - false); -} - -//============================================================================ - -// pointlike-areal geometries -template -inline void test_point_box() -{ - typedef test_disjoint tester; - typedef bg::model::box

B; - - tester::apply("p-b-01", - from_wkt

("POINT(0 0)"), - from_wkt("BOX(0 0,1 1)"), - false); - - tester::apply("p-b-02", - from_wkt

("POINT(2 2)"), - from_wkt("BOX(0 0,1 0)"), - true); -} - -template -inline void test_point_ring() -{ - typedef bg::model::ring R; // ccw, open - - typedef test_disjoint tester; - - tester::apply("p-r-01", - from_wkt

("POINT(0 0)"), - from_wkt("POLYGON((0 0,1 0,0 1))"), - false); - - tester::apply("p-r-02", - from_wkt

("POINT(1 1)"), - from_wkt("POLYGON((0 0,1 0,0 1))"), - true); -} - -template -inline void test_point_polygon() -{ - typedef bg::model::polygon PL; // ccw, open - - typedef test_disjoint tester; - - tester::apply("p-pg-01", - from_wkt

("POINT(0 0)"), - from_wkt("POLYGON((0 0,1 0,0 1))"), - false); - - tester::apply("p-pg-02", - from_wkt

("POINT(1 1)"), - from_wkt("POLYGON((0 0,1 0,0 1))"), - true); -} - -template -inline void test_point_multipolygon() -{ - typedef bg::model::polygon PL; // ccw, open - typedef bg::model::multi_polygon MPL; - - typedef test_disjoint tester; - - tester::apply("p-mpg-01", - from_wkt

("POINT(0 0)"), - from_wkt("MULTIPOLYGON(((0 0,1 0,0 1)),((2 0,3 0,2 1)))"), - false); - - tester::apply("p-mpg-02", - from_wkt

("POINT(1 1)"), - from_wkt("MULTIPOLYGON(((0 0,1 0,0 1)),((2 0,3 0,2 1)))"), - true); -} - -template -inline void test_multipoint_box() -{ - typedef test_disjoint tester; - typedef bg::model::multi_point

MP; - typedef bg::model::box

B; - - tester::apply("mp-b-01", - from_wkt("MULTIPOINT(0 0,1 1)"), - from_wkt("BOX(0 0,2 2)"), - false); - - tester::apply("mp-b-02", - from_wkt("MULTIPOINT(1 1,3 3)"), - from_wkt("BOX(0 0,2 2)"), - false); - - tester::apply("mp-b-03", - from_wkt("MULTIPOINT(3 3,4 4)"), - from_wkt("BOX(0 0,2 2)"), - true); - - tester::apply("mp-b-04", - from_wkt("MULTIPOINT()"), - from_wkt("BOX(0 0,2 2)"), - true); -} - -template -inline void test_multipoint_ring() -{ - typedef bg::model::multi_point

MP; - typedef bg::model::ring R; // ccw, open - - typedef test_disjoint tester; - - tester::apply("mp-r-01", - from_wkt("MULTIPOINT(0 0,1 0)"), - from_wkt("POLYGON((0 0,1 0,0 1))"), - false); - - tester::apply("mp-r-02", - from_wkt("MULTIPOINT(1 0,1 1)"), - from_wkt("POLYGON((0 0,1 0,0 1))"), - false); - - tester::apply("mp-r-03", - from_wkt("MULTIPOINT(1 1,2 2)"), - from_wkt("POLYGON((0 0,1 0,0 1))"), - true); -} - -template -inline void test_multipoint_polygon() -{ - typedef bg::model::multi_point

MP; - typedef bg::model::polygon PL; // ccw, open - - typedef test_disjoint tester; - - tester::apply("mp-pg-01", - from_wkt("MULTIPOINT(0 0,1 0)"), - from_wkt("POLYGON(((0 0,1 0,0 1)))"), - false); - - tester::apply("mp-pg-02", - from_wkt("MULTIPOINT(0 0,2 0)"), - from_wkt("POLYGON(((0 0,1 0,0 1)))"), - false); - - tester::apply("mp-pg-03", - from_wkt("MULTIPOINT(1 1,2 0)"), - from_wkt("POLYGON(((0 0,1 0,0 1)))"), - true); - - tester::apply("mp-pg-04", - from_wkt("MULTIPOINT(1 1,2 3)"), - from_wkt("POLYGON(((0 0,1 0,0 1)))"), - true); -} - -template -inline void test_multipoint_multipolygon() -{ - typedef bg::model::multi_point

MP; - typedef bg::model::polygon PL; // ccw, open - typedef bg::model::multi_polygon MPL; - - typedef test_disjoint tester; - - tester::apply("mp-mp-01", - from_wkt("MULTIPOINT(0 0,2 0)"), - from_wkt("MULTIPOLYGON((0 0,1 0,0 1)),(2 0,3 0,2 1))"), - false); - - tester::apply("mp-mp-02", - from_wkt("MULTIPOINT(0 0,1 0)"), - from_wkt("MULTIPOLYGON((0 0,1 0,0 1)),(2 0,3 0,2 1))"), - false); - - tester::apply("mp-mp-03", - from_wkt("MULTIPOINT(1 1,2 0)"), - from_wkt("MULTIPOLYGON((0 0,1 0,0 1)),(2 0,3 0,2 1))"), - false); - - tester::apply("mp-mp-04", - from_wkt("MULTIPOINT(1 1,2 3)"), - from_wkt("MULTIPOLYGON((0 0,1 0,0 1)),(2 0,3 0,2 1))"), - true); -} - -//============================================================================ - -// linear-linear geometries -template -inline void test_segment_segment() -{ - typedef bg::model::segment

S; - - typedef test_disjoint tester; - - tester::apply("s-s-01", - from_wkt("SEGMENT(0 0,2 0)"), - from_wkt("SEGMENT(0 0,0 2)"), - false); - - tester::apply("s-s-02", - from_wkt("SEGMENT(0 0,2 0)"), - from_wkt("SEGMENT(2 0,3 0)"), - false); - - tester::apply("s-s-03", - from_wkt("SEGMENT(0 0,2 0)"), - from_wkt("SEGMENT(1 0,3 0)"), - false); - - tester::apply("s-s-04", - from_wkt("SEGMENT(0 0,2 0)"), - from_wkt("SEGMENT(1 0,1 1)"), - false); - - tester::apply("s-s-05", - from_wkt("SEGMENT(0 0,2 0)"), - from_wkt("SEGMENT(1 1,2 2)"), - true); - - tester::apply("s-s-06", - from_wkt("SEGMENT(0 0,1 1)"), - from_wkt("SEGMENT(1 1,1 1)"), - false); - - tester::apply("s-s-07", - from_wkt("SEGMENT(0 0,1 1)"), - from_wkt("SEGMENT(2 2,2 2)"), - true); - - tester::apply("s-s-08", - from_wkt("SEGMENT(0 0,1 1)"), - from_wkt("SEGMENT(2 2,3 3)"), - true); -} - -template -inline void test_linestring_segment() -{ - typedef bg::model::segment

S; - typedef bg::model::linestring

L; - - typedef test_disjoint tester; - - tester::apply("l-s-01", - from_wkt("SEGMENT(0 0,2 0)"), - from_wkt("LINESTRING(0 0,0 2)"), - false); - - tester::apply("l-s-02", - from_wkt("SEGMENT(0 0,2 0)"), - from_wkt("LINESTRING(2 0,3 0)"), - false); - - tester::apply("l-s-03", - from_wkt("SEGMENT(0 0,2 0)"), - from_wkt("LINESTRING(1 0,3 0)"), - false); - - tester::apply("l-s-04", - from_wkt("SEGMENT(0 0,2 0)"), - from_wkt("LINESTRING(1 0,1 1)"), - false); - - tester::apply("l-s-05", - from_wkt("SEGMENT(0 0,2 0)"), - from_wkt("LINESTRING(1 1,2 2)"), - true); - - tester::apply("l-s-06", - from_wkt("SEGMENT(0 0,2 0)"), - from_wkt("LINESTRING(1 1,1 1,2 2)"), - true); - - tester::apply("l-s-07", - from_wkt("SEGMENT(0 0,2 0)"), - from_wkt("LINESTRING(1 0,1 0,1 1,2 2)"), - false); - - tester::apply("l-s-08", - from_wkt("SEGMENT(0 0,2 0)"), - from_wkt("LINESTRING(1 0,1 0,3 0)"), - false); - - tester::apply("l-s-09", - from_wkt("SEGMENT(0 0,2 0)"), - from_wkt("LINESTRING(3 0,3 0,4 0)"), - true); - - tester::apply("l-s-10", - from_wkt("SEGMENT(0 0,2 0)"), - from_wkt("LINESTRING(3 0,3 0)"), - true); - - tester::apply("l-s-11", - from_wkt("SEGMENT(0 0,2 0)"), - from_wkt("LINESTRING(-1 0,-1 0)"), - true); - - tester::apply("l-s-12", - from_wkt("SEGMENT(0 0,2 0)"), - from_wkt("LINESTRING(1 0,1 0)"), - false); - - tester::apply("l-s-13", - from_wkt("SEGMENT(0 0,2 0)"), - from_wkt("LINESTRING(1 1,1 1)"), - true); -} - -template -inline void test_multilinestring_segment() -{ - typedef bg::model::segment

S; - typedef bg::model::linestring

L; - typedef bg::model::multi_linestring ML; - - typedef test_disjoint tester; - - tester::apply("s-ml-01", - from_wkt("SEGMENT(0 0,2 0)"), - from_wkt("MULTILINESTRING((0 0,0 2))"), - false); - - tester::apply("s-ml-02", - from_wkt("SEGMENT(0 0,2 0)"), - from_wkt("MULTILINESTRING((2 0,3 0))"), - false); - - tester::apply("s-ml-03", - from_wkt("SEGMENT(0 0,2 0)"), - from_wkt("MULTILINESTRING((1 0,3 0))"), - false); - - tester::apply("s-ml-04", - from_wkt("SEGMENT(0 0,2 0)"), - from_wkt("MULTILINESTRING((1 0,1 1))"), - false); - - tester::apply("s-ml-05", - from_wkt("SEGMENT(0 0,2 0)"), - from_wkt("MULTILINESTRING((1 1,2 2))"), - true); - - tester::apply("s-ml-06", - from_wkt("SEGMENT(0 0,2 0)"), - from_wkt("MULTILINESTRING((1 1,2 2),(3 3,3 3))"), - true); - - tester::apply("s-ml-07", - from_wkt("SEGMENT(0 0,2 0)"), - from_wkt("MULTILINESTRING((1 1,2 2),(1 0,1 0))"), - false); - - tester::apply("s-ml-08", - from_wkt("SEGMENT(0 0,2 0)"), - from_wkt("MULTILINESTRING((1 1,2 2),(3 0,3 0))"), - true); -} - -template -inline void test_linestring_linestring() -{ - typedef bg::model::linestring

L; - - typedef test_disjoint tester; - - tester::apply("l-l-01", - from_wkt("LINESTRING(0 0,2 0)"), - from_wkt("LINESTRING(0 0,0 2)"), - false); - - tester::apply("l-l-02", - from_wkt("LINESTRING(0 0,2 0)"), - from_wkt("LINESTRING(2 0,3 0)"), - false); - - tester::apply("l-l-03", - from_wkt("LINESTRING(0 0,2 0)"), - from_wkt("LINESTRING(1 0,3 0)"), - false); - - tester::apply("l-l-04", - from_wkt("LINESTRING(0 0,2 0)"), - from_wkt("LINESTRING(1 0,1 1)"), - false); - - tester::apply("l-l-05", - from_wkt("LINESTRING(0 0,2 0)"), - from_wkt("LINESTRING(1 1,2 2)"), - true); -} - -template -inline void test_linestring_multilinestring() -{ - typedef bg::model::linestring

L; - typedef bg::model::multi_linestring ML; - - typedef test_disjoint tester; - - tester::apply("l-ml-01", - from_wkt("LINESTRING(0 0,2 0)"), - from_wkt("MULTILINESTRING((0 0,0 2))"), - false); - - tester::apply("l-ml-02", - from_wkt("LINESTRING(0 0,2 0)"), - from_wkt("MULTILINESTRING((2 0,3 0))"), - false); - - tester::apply("l-ml-03", - from_wkt("LINESTRING(0 0,2 0)"), - from_wkt("MULTILINESTRING((1 0,3 0))"), - false); - - tester::apply("l-ml-04", - from_wkt("LINESTRING(0 0,2 0)"), - from_wkt("MULTILINESTRING((1 0,1 1))"), - false); - - tester::apply("l-ml-05", - from_wkt("LINESTRING(0 0,2 0)"), - from_wkt("MULTILINESTRING((1 1,2 2))"), - true); -} - -template -inline void test_multilinestring_multilinestring() -{ - typedef bg::model::linestring

L; - typedef bg::model::multi_linestring ML; - - typedef test_disjoint tester; - - tester::apply("ml-ml-01", - from_wkt("MULTILINESTRING((0 0,2 0))"), - from_wkt("MULTILINESTRING((0 0,0 2))"), - false); - - tester::apply("ml-ml-02", - from_wkt("MULTILINESTRING((0 0,2 0))"), - from_wkt("MULTILINESTRING((2 0,3 0))"), - false); - - tester::apply("ml-ml-03", - from_wkt("MULTILINESTRING((0 0,2 0))"), - from_wkt("MULTILINESTRING((1 0,3 0))"), - false); - - tester::apply("ml-ml-04", - from_wkt("MULTILINESTRING((0 0,2 0))"), - from_wkt("MULTILINESTRING((1 0,1 1))"), - false); - - tester::apply("ml-ml-05", - from_wkt("MULTILINESTRING((0 0,2 0))"), - from_wkt("MULTILINESTRING((1 1,2 2))"), - true); -} - -//============================================================================ - -// linear-areal geometries -template -inline void test_segment_box() -{ - typedef bg::model::segment

S; - typedef bg::model::box

B; - - typedef test_disjoint tester; - - tester::apply("s-b-01", - from_wkt("SEGMENT(0 0,2 0)"), - from_wkt("BOX(0 0,2 2)"), - false); - - tester::apply("s-b-02", - from_wkt("SEGMENT(1 1,3 3)"), - from_wkt("BOX(0 0,2 2)"), - false); - - tester::apply("s-b-03", - from_wkt("SEGMENT(2 2,3 3)"), - from_wkt("BOX(0 0,2 2)"), - false); - - tester::apply("s-b-04", - from_wkt("SEGMENT(4 4,3 3)"), - from_wkt("BOX(0 0,2 2)"), - true); - - tester::apply("s-b-05", - from_wkt("SEGMENT(0 4,4 4)"), - from_wkt("BOX(0 0,2 2)"), - true); - - tester::apply("s-b-06", - from_wkt("SEGMENT(4 0,4 4)"), - from_wkt("BOX(0 0,2 2)"), - true); - - tester::apply("s-b-07", - from_wkt("SEGMENT(0 -2,0 -1)"), - from_wkt("BOX(0 0,1 1)"), - true); - - tester::apply("s-b-08", - from_wkt("SEGMENT(-2 -2,-2 -1)"), - from_wkt("BOX(0 0,1 1)"), - true); - - tester::apply("s-b-09", - from_wkt("SEGMENT(-2 -2,-2 -2)"), - from_wkt("BOX(0 0,1 1)"), - true); - - tester::apply("s-b-10", - from_wkt("SEGMENT(-2 0,-2 0)"), - from_wkt("BOX(0 0,1 1)"), - true); - - tester::apply("s-b-11", - from_wkt("SEGMENT(0 -2,0 -2)"), - from_wkt("BOX(0 0,1 1)"), - true); - - tester::apply("s-b-12", - from_wkt("SEGMENT(-2 0,-1 0)"), - from_wkt("BOX(0 0,1 1)"), - true); - - // segment degenerates to a point - tester::apply("s-b-13", - from_wkt("SEGMENT(0 0,0 0)"), - from_wkt("BOX(0 0,1 1)"), - false); - - tester::apply("s-b-14", - from_wkt("SEGMENT(1 1,1 1)"), - from_wkt("BOX(0 0,2 2)"), - false); - - tester::apply("s-b-15", - from_wkt("SEGMENT(2 2,2 2)"), - from_wkt("BOX(0 0,2 2)"), - false); - - tester::apply("s-b-16", - from_wkt("SEGMENT(2 0,2 0)"), - from_wkt("BOX(0 0,2 2)"), - false); - - tester::apply("s-b-17", - from_wkt("SEGMENT(0 2,0 2)"), - from_wkt("BOX(0 0,2 2)"), - false); - - tester::apply("s-b-18", - from_wkt("SEGMENT(2 2,2 2)"), - from_wkt("BOX(0 0,1 1)"), - true); -} - -template -inline void test_segment_ring() -{ - typedef bg::model::segment

S; - typedef bg::model::ring R; // ccw, open - - typedef test_disjoint tester; - - tester::apply("s-r-01", - from_wkt("SEGMENT(0 0,2 0)"), - from_wkt("POLYGON((0 0,2 0,0 2))"), - false); - - tester::apply("s-r-02", - from_wkt("SEGMENT(1 0,3 3)"), - from_wkt("POLYGON((0 0,2 0,0 2))"), - false); - - tester::apply("s-r-03", - from_wkt("SEGMENT(1 1,3 3)"), - from_wkt("POLYGON((0 0,2 0,0 2))"), - false); - - tester::apply("s-r-04", - from_wkt("SEGMENT(2 2,3 3)"), - from_wkt("POLYGON((0 0,2 0,0 2))"), - true); -} - -template -inline void test_segment_polygon() -{ - typedef bg::model::segment

S; - typedef bg::model::polygon PL; // ccw, open - - typedef test_disjoint tester; - - tester::apply("s-pg-01", - from_wkt("SEGMENT(0 0,2 0)"), - from_wkt("POLYGON((0 0,2 0,0 2))"), - false); - - tester::apply("s-pg-02", - from_wkt("SEGMENT(1 0,3 3)"), - from_wkt("POLYGON((0 0,2 0,0 2))"), - false); - - tester::apply("s-pg-03", - from_wkt("SEGMENT(1 1,3 3)"), - from_wkt("POLYGON((0 0,2 0,0 2))"), - false); - - tester::apply("s-pg-04", - from_wkt("SEGMENT(2 2,3 3)"), - from_wkt("POLYGON((0 0,2 0,0 2))"), - true); -} - -template -inline void test_segment_multipolygon() -{ - typedef bg::model::segment

S; - typedef bg::model::polygon PL; // ccw, open - typedef bg::model::multi_polygon MPL; - - typedef test_disjoint tester; - - tester::apply("s-mpg-01", - from_wkt("SEGMENT(0 0,2 0)"), - from_wkt("MULTIPOLYGON(((0 0,2 0,0 2)))"), - false); - - tester::apply("s-mpg-02", - from_wkt("SEGMENT(1 0,3 3)"), - from_wkt("MULTIPOLYGON(((0 0,2 0,0 2)))"), - false); - - tester::apply("s-mpg-03", - from_wkt("SEGMENT(1 1,3 3)"), - from_wkt("MULTIPOLYGON(((0 0,2 0,0 2)))"), - false); - - tester::apply("s-mpg-04", - from_wkt("SEGMENT(2 2,3 3)"), - from_wkt("MULTIPOLYGON(((0 0,2 0,0 2)))"), - true); -} - -template -inline void test_linestring_box() -{ - typedef bg::model::linestring

L; - typedef bg::model::box

B; - - typedef test_disjoint tester; - - tester::apply("l-b-01", - from_wkt("LINESTRING(0 0,2 0)"), - from_wkt("BOX(0 0,2 2)"), - false); - - tester::apply("l-b-02", - from_wkt("LINESTRING(1 1,3 3)"), - from_wkt("BOX(0 0,2 2)"), - false); - - tester::apply("l-b-03", - from_wkt("LINESTRING(2 2,3 3)"), - from_wkt("BOX(0 0,2 2)"), - false); - - tester::apply("l-b-04", - from_wkt("LINESTRING(4 4,3 3)"), - from_wkt("BOX(0 0,2 2)"), - true); -} - -template -inline void test_linestring_ring() -{ - typedef bg::model::linestring

L; - typedef bg::model::ring R; // ccw, open - - typedef test_disjoint tester; - - tester::apply("l-r-01", - from_wkt("LINESTRING(0 0,2 0)"), - from_wkt("POLYGON((0 0,2 0,0 2))"), - false); - - tester::apply("l-r-02", - from_wkt("LINESTRING(1 0,3 3)"), - from_wkt("POLYGON((0 0,2 0,0 2))"), - false); - - tester::apply("l-r-03", - from_wkt("LINESTRING(1 1,3 3)"), - from_wkt("POLYGON((0 0,2 0,0 2))"), - false); - - tester::apply("l-r-04", - from_wkt("LINESTRING(2 2,3 3)"), - from_wkt("POLYGON((0 0,2 0,0 2))"), - true); -} - -template -inline void test_linestring_polygon() -{ - typedef bg::model::linestring

L; - typedef bg::model::polygon PL; // ccw, open - - typedef test_disjoint tester; - - tester::apply("l-pg-01", - from_wkt("LINESTRING(0 0,2 0)"), - from_wkt("POLYGON((0 0,2 0,0 2))"), - false); - - tester::apply("l-pg-02", - from_wkt("LINESTRING(1 0,3 3)"), - from_wkt("POLYGON((0 0,2 0,0 2))"), - false); - - tester::apply("l-pg-03", - from_wkt("LINESTRING(1 1,3 3)"), - from_wkt("POLYGON((0 0,2 0,0 2))"), - false); - - tester::apply("l-pg-04", - from_wkt("LINESTRING(2 2,3 3)"), - from_wkt("POLYGON((0 0,2 0,0 2))"), - true); -} - -template -inline void test_linestring_multipolygon() -{ - typedef bg::model::linestring

L; - typedef bg::model::polygon PL; // ccw, open - typedef bg::model::multi_polygon MPL; - - typedef test_disjoint tester; - - tester::apply("l-mpg-01", - from_wkt("LINESTRING(0 0,2 0)"), - from_wkt("MULTIPOLYGON(((0 0,2 0,0 2)))"), - false); - - tester::apply("l-mpg-02", - from_wkt("LINESTRING(1 0,3 3)"), - from_wkt("MULTIPOLYGON(((0 0,2 0,0 2)))"), - false); - - tester::apply("l-mpg-03", - from_wkt("LINESTRING(1 1,3 3)"), - from_wkt("MULTIPOLYGON(((0 0,2 0,0 2)))"), - false); - - tester::apply("l-mpg-04", - from_wkt("LINESTRING(2 2,3 3)"), - from_wkt("MULTIPOLYGON(((0 0,2 0,0 2)))"), - true); -} - -template -inline void test_multilinestring_box() -{ - typedef bg::model::linestring

L; - typedef bg::model::multi_linestring ML; - typedef bg::model::box

B; - - typedef test_disjoint tester; - - tester::apply("ml-b-01", - from_wkt("MULTILINESTRING((0 0,2 0))"), - from_wkt("BOX(0 0,2 2)"), - false); - - tester::apply("ml-b-02", - from_wkt("MULTILINESTRING((1 1,3 3))"), - from_wkt("BOX(0 0,2 2)"), - false); - - tester::apply("ml-b-03", - from_wkt("MULTILINESTRING((2 2,3 3))"), - from_wkt("BOX(0 0,2 2)"), - false); - - tester::apply("ml-b-04", - from_wkt("MULTILINESTRING((4 4,3 3))"), - from_wkt("BOX(0 0,2 2)"), - true); -} - -template -inline void test_multilinestring_ring() -{ - typedef bg::model::linestring

L; - typedef bg::model::multi_linestring ML; - typedef bg::model::ring R; // ccw, open - - typedef test_disjoint tester; - - tester::apply("ml-r-01", - from_wkt("MULTILINESTRING((0 0,2 0))"), - from_wkt("POLYGON((0 0,2 0,0 2))"), - false); - - tester::apply("ml-r-02", - from_wkt("MULTILINESTRING((1 0,3 3))"), - from_wkt("POLYGON((0 0,2 0,0 2))"), - false); - - tester::apply("ml-r-03", - from_wkt("MULTILINESTRING((1 1,3 3))"), - from_wkt("POLYGON((0 0,2 0,0 2))"), - false); - - tester::apply("ml-r-04", - from_wkt("MULTILINESTRING((2 2,3 3))"), - from_wkt("POLYGON((0 0,2 0,0 2))"), - true); -} - -template -inline void test_multilinestring_polygon() -{ - typedef bg::model::linestring

L; - typedef bg::model::multi_linestring ML; - typedef bg::model::polygon PL; // ccw, open - - typedef test_disjoint tester; - - tester::apply("ml-pg-01", - from_wkt("MULTILINESTRING((0 0,2 0))"), - from_wkt("POLYGON((0 0,2 0,0 2))"), - false); - - tester::apply("ml-pg-02", - from_wkt("MULTILINESTRING((1 0,3 3))"), - from_wkt("POLYGON((0 0,2 0,0 2))"), - false); - - tester::apply("ml-pg-03", - from_wkt("MULTILINESTRING((1 1,3 3))"), - from_wkt("POLYGON((0 0,2 0,0 2))"), - false); - - tester::apply("ml-pg-04", - from_wkt("MULTILINESTRING((2 2,3 3))"), - from_wkt("POLYGON((0 0,2 0,0 2))"), - true); -} - -template -inline void test_multilinestring_multipolygon() -{ - typedef bg::model::linestring

L; - typedef bg::model::multi_linestring ML; - typedef bg::model::polygon PL; // ccw, open - typedef bg::model::multi_polygon MPL; - - typedef test_disjoint tester; - - tester::apply("ml-mpg-01", - from_wkt("MULTILINESTRING((0 0,2 0))"), - from_wkt("MULTIPOLYGON(((0 0,2 0,0 2)))"), - false); - - tester::apply("ml-mpg-02", - from_wkt("MULTILINESTRING((1 0,3 3))"), - from_wkt("MULTIPOLYGON(((0 0,2 0,0 2)))"), - false); - - tester::apply("ml-mpg-03", - from_wkt("MULTILINESTRING((1 1,3 3))"), - from_wkt("MULTIPOLYGON(((0 0,2 0,0 2)))"), - false); - - tester::apply("ml-mpg-04", - from_wkt("MULTILINESTRING((2 2,3 3))"), - from_wkt("MULTIPOLYGON(((0 0,2 0,0 2)))"), - true); -} - -//============================================================================ - -// areal-areal geometries -template -inline void test_box_box() -{ - typedef bg::model::box

B; - - typedef test_disjoint tester; - - tester::apply("b-b-01", - from_wkt("BOX(2 2,3 3)"), - from_wkt("BOX(0 0,2 2)"), - false); - - tester::apply("b-b-02", - from_wkt("BOX(1 1,3 3)"), - from_wkt("BOX(0 0,2 2)"), - false); - - tester::apply("b-b-03", - from_wkt("BOX(3 3,4 4)"), - from_wkt("BOX(0 0,2 2)"), - true); -} - -template -inline void test_ring_box() -{ - typedef bg::model::box

B; - typedef bg::model::ring R; // ccw, open - - typedef test_disjoint tester; - - tester::apply("r-b-01", - from_wkt("BOX(2 2,3 3)"), - from_wkt("POLYGON((0 0,2 0,2 2,0 2))"), - false); - - tester::apply("r-b-02", - from_wkt("BOX(1 1,3 3)"), - from_wkt("POLYGON((0 0,2 0,2 2,0 2))"), - false); - - tester::apply("r-b-03", - from_wkt("BOX(3 3,4 4)"), - from_wkt("POLYGON((0 0,2 0,2 2,0 2))"), - true); -} - -template -inline void test_polygon_box() -{ - typedef bg::model::box

B; - typedef bg::model::polygon PL; // ccw, open - - typedef test_disjoint tester; - - tester::apply("pg-b-01", - from_wkt("BOX(2 2,3 3)"), - from_wkt("POLYGON((0 0,2 0,2 2,0 2))"), - false); - - tester::apply("pg-b-02", - from_wkt("BOX(1 1,3 3)"), - from_wkt("POLYGON((0 0,2 0,2 2,0 2))"), - false); - - tester::apply("pg-b-03", - from_wkt("BOX(3 3,4 4)"), - from_wkt("POLYGON((0 0,2 0,2 2,0 2))"), - true); -} - -template -inline void test_multipolygon_box() -{ - typedef bg::model::box

B; - typedef bg::model::polygon PL; // ccw, open - typedef bg::model::multi_polygon MPL; - - typedef test_disjoint tester; - - tester::apply("mpg-b-01", - from_wkt("BOX(2 2,3 3)"), - from_wkt("MULTIPOLYGON(((0 0,2 0,2 2,0 2)))"), - false); - - tester::apply("mpg-b-02", - from_wkt("BOX(1 1,3 3)"), - from_wkt("MULTIPOLYGON(((0 0,2 0,2 2,0 2)))"), - false); - - tester::apply("mpg-b-03", - from_wkt("BOX(3 3,4 4)"), - from_wkt("MULTIPOLYGON(((0 0,2 0,2 2,0 2)))"), - true); -} - -template -inline void test_ring_ring() -{ - typedef bg::model::ring R; // ccw, open - - typedef test_disjoint tester; - - tester::apply("r-r-01", - from_wkt("POLYGON((2 2,2 3,3 3,3 2))"), - from_wkt("POLYGON((0 0,2 0,2 2,0 2))"), - false); - - tester::apply("r-r-02", - from_wkt("POLYGON((1 1,1 3,3 3,3 1))"), - from_wkt("POLYGON((0 0,2 0,2 2,0 2))"), - false); - - tester::apply("r-r-03", - from_wkt("POLYGON((3 3,3 4,4 4,4 3))"), - from_wkt("POLYGON((0 0,2 0,2 2,0 2))"), - true); -} - -template -inline void test_polygon_ring() -{ - typedef bg::model::ring R; // ccw, open - typedef bg::model::polygon PL; // ccw, open - - typedef test_disjoint tester; - - tester::apply("pg-r-01", - from_wkt("POLYGON((2 2,2 3,3 3,3 2))"), - from_wkt("POLYGON((0 0,2 0,2 2,0 2))"), - false); - - tester::apply("pg-r-02", - from_wkt("POLYGON((1 1,1 3,3 3,3 1))"), - from_wkt("POLYGON((0 0,2 0,2 2,0 2))"), - false); - - tester::apply("pg-r-03", - from_wkt("POLYGON((3 3,3 4,4 4,4 3))"), - from_wkt("POLYGON((0 0,2 0,2 2,0 2))"), - true); -} - -template -inline void test_multipolygon_ring() -{ - typedef bg::model::ring R; // ccw, open - typedef bg::model::polygon PL; // ccw, open - typedef bg::model::multi_polygon MPL; - - typedef test_disjoint tester; - - tester::apply("mpg-r-01", - from_wkt("POLYGON((2 2,2 3,3 3,3 2))"), - from_wkt("MULTIPOLYGON(((0 0,2 0,2 2,0 2)))"), - false); - - tester::apply("mpg-r-02", - from_wkt("POLYGON((1 1,1 3,3 3,3 1))"), - from_wkt("MULTIPOLYGON(((0 0,2 0,2 2,0 2)))"), - false); - - tester::apply("mpg-r-03", - from_wkt("POLYGON((3 3,3 4,4 4,4 3))"), - from_wkt("MULTIPOLYGON(((0 0,2 0,2 2,0 2)))"), - true); -} - -template -inline void test_polygon_polygon() -{ - typedef bg::model::polygon PL; // ccw, open - - typedef test_disjoint tester; - - tester::apply("pg-pg-01", - from_wkt("POLYGON((2 2,2 3,3 3,3 2))"), - from_wkt("POLYGON((0 0,2 0,2 2,0 2))"), - false); - - tester::apply("pg-pg-02", - from_wkt("POLYGON((1 1,1 3,3 3,3 1))"), - from_wkt("POLYGON((0 0,2 0,2 2,0 2))"), - false); - - tester::apply("pg-pg-03", - from_wkt("POLYGON((3 3,3 4,4 4,4 3))"), - from_wkt("POLYGON((0 0,2 0,2 2,0 2))"), - true); - - tester::apply("pg-pg-04", - from_wkt("POLYGON((0 0,9 0,9 9,0 9))"), - from_wkt("POLYGON((3 3,6 3,6 6,3 6))"), - false); - // polygon with a hole which entirely contains the other polygon - tester::apply("pg-pg-05", - from_wkt("POLYGON((0 0,9 0,9 9,0 9),(2 2,2 7,7 7,7 2))"), - from_wkt("POLYGON((3 3,6 3,6 6,3 6))"), - true); - // polygon with a hole, but the inner ring intersects the other polygon - tester::apply("pg-pg-06", - from_wkt("POLYGON((0 0,9 0,9 9,0 9),(3 2,3 7,7 7,7 2))"), - from_wkt("POLYGON((2 3,6 3,6 6,2 6))"), - false); - // polygon with a hole, but the other polygon is entirely contained - // between the inner and outer rings. - tester::apply("pg-pg-07", - from_wkt("POLYGON((0 0,9 0,9 9,0 9),(6 2,6 7,7 7,7 2))"), - from_wkt("POLYGON((3 3,5 3,5 6,3 6))"), - false); - // polygon with a hole and the outer ring of the other polygon lies - // between the inner and outer, but without touching either. - tester::apply("pg-pg-08", - from_wkt("POLYGON((0 0,9 0,9 9,0 9),(3 3,3 6,6 6,6 3))"), - from_wkt("POLYGON((2 2,7 2,7 7,2 7))"), - false); - - { - typedef bg::model::polygon

PL; // cw, closed - - // https://svn.boost.org/trac/boost/ticket/10647 - tester::apply("ticket-10647", - from_wkt("POLYGON((0 0, 0 5, 5 5, 5 0, 0 0)(1 1, 4 1, 4 4, 1 4, 1 1))"), - from_wkt("POLYGON((2 2, 2 3, 3 3, 3 2, 2 2))"), - true); - } -} - -template -inline void test_polygon_multipolygon() -{ - typedef bg::model::polygon PL; // ccw, open - typedef bg::model::multi_polygon MPL; - - typedef test_disjoint tester; - - tester::apply("pg-mpg-01", - from_wkt("POLYGON((2 2,2 3,3 3,3 2))"), - from_wkt("MULTIPOLYGON(((0 0,2 0,2 2,0 2)))"), - false); - - tester::apply("pg-mpg-02", - from_wkt("POLYGON((1 1,1 3,3 3,3 1))"), - from_wkt("MULTIPOLYGON(((0 0,2 0,2 2,0 2)))"), - false); - - tester::apply("pg-mpg-03", - from_wkt("POLYGON((3 3,3 4,4 4,4 3))"), - from_wkt("MULTIPOLYGON(((0 0,2 0,2 2,0 2)))"), - true); -} - -template -inline void test_multipolygon_multipolygon() -{ - typedef bg::model::polygon PL; // ccw, open - typedef bg::model::multi_polygon MPL; - - typedef test_disjoint tester; - - tester::apply("mpg-mpg-01", - from_wkt("MULTIPOLYGON(((2 2,2 3,3 3,3 2)))"), - from_wkt("MULTIPOLYGON(((0 0,2 0,2 2,0 2)))"), - false); - - tester::apply("mpg-mpg-02", - from_wkt("MULTIPOLYGON(((1 1,1 3,3 3,3 1)))"), - from_wkt("MULTIPOLYGON(((0 0,2 0,2 2,0 2)))"), - false); - - tester::apply("mpg-mpg-03", - from_wkt("MULTIPOLYGON(((3 3,3 4,4 4,4 3)))"), - from_wkt("MULTIPOLYGON(((0 0,2 0,2 2,0 2)))"), - true); -} - -//============================================================================ - -template -inline void test_pointlike_pointlike() -{ - typedef bg::model::point point_type; - - test_point_point(); - test_point_multipoint(); - - test_multipoint_multipoint(); -} - -template -inline void test_pointlike_linear() -{ - typedef bg::model::point point_type; - - test_point_linestring(); - test_point_multilinestring(); - test_point_segment(); - - test_multipoint_linestring(); - test_multipoint_multilinestring(); - test_multipoint_segment(); -} - -template -inline void test_pointlike_areal() -{ - typedef bg::model::point point_type; - - test_point_polygon(); - test_point_multipolygon(); - test_point_ring(); - test_point_box(); - - // not implemented yet - // test_multipoint_polygon(); - // test_multipoint_multipolygon(); - // test_multipoint_ring(); - test_multipoint_box(); -} - -template -inline void test_linear_linear() -{ - typedef bg::model::point point_type; - - test_linestring_linestring(); - test_linestring_multilinestring(); - test_linestring_segment(); - - test_multilinestring_multilinestring(); - test_multilinestring_segment(); - - test_segment_segment(); -} - -template -inline void test_linear_areal() -{ - typedef bg::model::point point_type; - - test_segment_polygon(); - test_segment_multipolygon(); - test_segment_ring(); - test_segment_box(); - - test_linestring_polygon(); - test_linestring_multipolygon(); - test_linestring_ring(); - test_linestring_box(); - - test_multilinestring_polygon(); - test_multilinestring_multipolygon(); - test_multilinestring_ring(); - test_multilinestring_box(); -} - -template -inline void test_areal_areal() -{ - typedef bg::model::point point_type; - - test_polygon_polygon(); - test_polygon_multipolygon(); - test_polygon_ring(); - test_polygon_box(); - - test_multipolygon_multipolygon(); - test_multipolygon_ring(); - test_multipolygon_box(); - - test_ring_ring(); - test_ring_box(); - - test_box_box(); -} - -//============================================================================ - -BOOST_AUTO_TEST_CASE( test_pointlike_pointlike_all ) -{ - test_pointlike_pointlike(); - test_pointlike_pointlike(); -#ifdef HAVE_TTMATH - test_pointlike_pointlike(); -#endif -} - -BOOST_AUTO_TEST_CASE( test_pointlike_linear_all ) -{ - test_pointlike_linear(); - test_pointlike_linear(); -#ifdef HAVE_TTMATH - test_pointlike_linear(); -#endif -} - -BOOST_AUTO_TEST_CASE( test_pointlike_areal_all ) -{ - test_pointlike_areal(); - test_pointlike_areal(); -#ifdef HAVE_TTMATH - test_pointlike_areal(); -#endif -} - -BOOST_AUTO_TEST_CASE( test_linear_linear_all ) -{ - test_linear_linear(); - test_linear_linear(); -#ifdef HAVE_TTMATH - test_linear_linear(); -#endif -} - -BOOST_AUTO_TEST_CASE( test_linear_areal_all ) -{ - test_linear_areal(); - test_linear_areal(); -#ifdef HAVE_TTMATH - test_linear_areal(); -#endif -} - -BOOST_AUTO_TEST_CASE( test_areal_areal_all ) -{ - test_areal_areal(); - test_areal_areal(); -#ifdef HAVE_TTMATH - test_areal_areal(); -#endif -} diff --git a/test/algorithms/relational_operations/disjoint/disjoint_coverage_a_a.cpp b/test/algorithms/relational_operations/disjoint/disjoint_coverage_a_a.cpp new file mode 100644 index 000000000..25d6c5d77 --- /dev/null +++ b/test/algorithms/relational_operations/disjoint/disjoint_coverage_a_a.cpp @@ -0,0 +1,387 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2014-2015, Oracle and/or its affiliates. + +// Licensed under the Boost Software License version 1.0. +// http://www.boost.org/users/license.html + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle + +#ifndef BOOST_TEST_MODULE +#define BOOST_TEST_MODULE test_disjoint_coverage +#endif + +// unit test to test disjoint for all geometry combinations + +#include + +#include + +#include +#include + +#include + +#include +#include + +#include + +#include + +#include + + +#ifdef HAVE_TTMATH +#include +#endif + +namespace bg = ::boost::geometry; + +//============================================================================ + +struct test_disjoint +{ + template + static inline void apply(std::string const& case_id, + Geometry1 const& geometry1, + Geometry2 const& geometry2, + bool expected_result) + { + bool result = bg::disjoint(geometry1, geometry2); + BOOST_CHECK_MESSAGE(result == expected_result, + "case ID: " << case_id << ", G1: " << bg::wkt(geometry1) + << ", G2: " << bg::wkt(geometry2) << " -> Expected: " + << expected_result << ", detected: " << result); + + result = bg::disjoint(geometry2, geometry1); + BOOST_CHECK_MESSAGE(result == expected_result, + "case ID: " << case_id << ", G1: " << bg::wkt(geometry2) + << ", G2: " << bg::wkt(geometry1) << " -> Expected: " + << expected_result << ", detected: " << result); + +#ifdef BOOST_GEOMETRY_TEST_DEBUG + std::cout << "case ID: " << case_id << "; G1 - G2: "; + std::cout << bg::wkt(geometry1) << " - "; + std::cout << bg::wkt(geometry2) << std::endl; + std::cout << std::boolalpha; + std::cout << "expected/computed result: " + << expected_result << " / " << result << std::endl; + std::cout << std::endl; + std::cout << std::noboolalpha; +#endif + } +}; + +//============================================================================ + +// areal-areal geometries +template +inline void test_box_box() +{ + typedef bg::model::box

B; + + typedef test_disjoint tester; + + tester::apply("b-b-01", + from_wkt("BOX(2 2,3 3)"), + from_wkt("BOX(0 0,2 2)"), + false); + + tester::apply("b-b-02", + from_wkt("BOX(1 1,3 3)"), + from_wkt("BOX(0 0,2 2)"), + false); + + tester::apply("b-b-03", + from_wkt("BOX(3 3,4 4)"), + from_wkt("BOX(0 0,2 2)"), + true); +} + +template +inline void test_ring_box() +{ + typedef bg::model::box

B; + typedef bg::model::ring R; // ccw, open + + typedef test_disjoint tester; + + tester::apply("r-b-01", + from_wkt("BOX(2 2,3 3)"), + from_wkt("POLYGON((0 0,2 0,2 2,0 2))"), + false); + + tester::apply("r-b-02", + from_wkt("BOX(1 1,3 3)"), + from_wkt("POLYGON((0 0,2 0,2 2,0 2))"), + false); + + tester::apply("r-b-03", + from_wkt("BOX(3 3,4 4)"), + from_wkt("POLYGON((0 0,2 0,2 2,0 2))"), + true); +} + +template +inline void test_polygon_box() +{ + typedef bg::model::box

B; + typedef bg::model::polygon PL; // ccw, open + + typedef test_disjoint tester; + + tester::apply("pg-b-01", + from_wkt("BOX(2 2,3 3)"), + from_wkt("POLYGON((0 0,2 0,2 2,0 2))"), + false); + + tester::apply("pg-b-02", + from_wkt("BOX(1 1,3 3)"), + from_wkt("POLYGON((0 0,2 0,2 2,0 2))"), + false); + + tester::apply("pg-b-03", + from_wkt("BOX(3 3,4 4)"), + from_wkt("POLYGON((0 0,2 0,2 2,0 2))"), + true); +} + +template +inline void test_multipolygon_box() +{ + typedef bg::model::box

B; + typedef bg::model::polygon PL; // ccw, open + typedef bg::model::multi_polygon MPL; + + typedef test_disjoint tester; + + tester::apply("mpg-b-01", + from_wkt("BOX(2 2,3 3)"), + from_wkt("MULTIPOLYGON(((0 0,2 0,2 2,0 2)))"), + false); + + tester::apply("mpg-b-02", + from_wkt("BOX(1 1,3 3)"), + from_wkt("MULTIPOLYGON(((0 0,2 0,2 2,0 2)))"), + false); + + tester::apply("mpg-b-03", + from_wkt("BOX(3 3,4 4)"), + from_wkt("MULTIPOLYGON(((0 0,2 0,2 2,0 2)))"), + true); +} + +template +inline void test_ring_ring() +{ + typedef bg::model::ring R; // ccw, open + + typedef test_disjoint tester; + + tester::apply("r-r-01", + from_wkt("POLYGON((2 2,2 3,3 3,3 2))"), + from_wkt("POLYGON((0 0,2 0,2 2,0 2))"), + false); + + tester::apply("r-r-02", + from_wkt("POLYGON((1 1,1 3,3 3,3 1))"), + from_wkt("POLYGON((0 0,2 0,2 2,0 2))"), + false); + + tester::apply("r-r-03", + from_wkt("POLYGON((3 3,3 4,4 4,4 3))"), + from_wkt("POLYGON((0 0,2 0,2 2,0 2))"), + true); +} + +template +inline void test_polygon_ring() +{ + typedef bg::model::ring R; // ccw, open + typedef bg::model::polygon PL; // ccw, open + + typedef test_disjoint tester; + + tester::apply("pg-r-01", + from_wkt("POLYGON((2 2,2 3,3 3,3 2))"), + from_wkt("POLYGON((0 0,2 0,2 2,0 2))"), + false); + + tester::apply("pg-r-02", + from_wkt("POLYGON((1 1,1 3,3 3,3 1))"), + from_wkt("POLYGON((0 0,2 0,2 2,0 2))"), + false); + + tester::apply("pg-r-03", + from_wkt("POLYGON((3 3,3 4,4 4,4 3))"), + from_wkt("POLYGON((0 0,2 0,2 2,0 2))"), + true); +} + +template +inline void test_multipolygon_ring() +{ + typedef bg::model::ring R; // ccw, open + typedef bg::model::polygon PL; // ccw, open + typedef bg::model::multi_polygon MPL; + + typedef test_disjoint tester; + + tester::apply("mpg-r-01", + from_wkt("POLYGON((2 2,2 3,3 3,3 2))"), + from_wkt("MULTIPOLYGON(((0 0,2 0,2 2,0 2)))"), + false); + + tester::apply("mpg-r-02", + from_wkt("POLYGON((1 1,1 3,3 3,3 1))"), + from_wkt("MULTIPOLYGON(((0 0,2 0,2 2,0 2)))"), + false); + + tester::apply("mpg-r-03", + from_wkt("POLYGON((3 3,3 4,4 4,4 3))"), + from_wkt("MULTIPOLYGON(((0 0,2 0,2 2,0 2)))"), + true); +} + +template +inline void test_polygon_polygon() +{ + typedef bg::model::polygon PL; // ccw, open + + typedef test_disjoint tester; + + tester::apply("pg-pg-01", + from_wkt("POLYGON((2 2,2 3,3 3,3 2))"), + from_wkt("POLYGON((0 0,2 0,2 2,0 2))"), + false); + + tester::apply("pg-pg-02", + from_wkt("POLYGON((1 1,1 3,3 3,3 1))"), + from_wkt("POLYGON((0 0,2 0,2 2,0 2))"), + false); + + tester::apply("pg-pg-03", + from_wkt("POLYGON((3 3,3 4,4 4,4 3))"), + from_wkt("POLYGON((0 0,2 0,2 2,0 2))"), + true); + + tester::apply("pg-pg-04", + from_wkt("POLYGON((0 0,9 0,9 9,0 9))"), + from_wkt("POLYGON((3 3,6 3,6 6,3 6))"), + false); + // polygon with a hole which entirely contains the other polygon + tester::apply("pg-pg-05", + from_wkt("POLYGON((0 0,9 0,9 9,0 9),(2 2,2 7,7 7,7 2))"), + from_wkt("POLYGON((3 3,6 3,6 6,3 6))"), + true); + // polygon with a hole, but the inner ring intersects the other polygon + tester::apply("pg-pg-06", + from_wkt("POLYGON((0 0,9 0,9 9,0 9),(3 2,3 7,7 7,7 2))"), + from_wkt("POLYGON((2 3,6 3,6 6,2 6))"), + false); + // polygon with a hole, but the other polygon is entirely contained + // between the inner and outer rings. + tester::apply("pg-pg-07", + from_wkt("POLYGON((0 0,9 0,9 9,0 9),(6 2,6 7,7 7,7 2))"), + from_wkt("POLYGON((3 3,5 3,5 6,3 6))"), + false); + // polygon with a hole and the outer ring of the other polygon lies + // between the inner and outer, but without touching either. + tester::apply("pg-pg-08", + from_wkt("POLYGON((0 0,9 0,9 9,0 9),(3 3,3 6,6 6,6 3))"), + from_wkt("POLYGON((2 2,7 2,7 7,2 7))"), + false); + + { + typedef bg::model::polygon

PL; // cw, closed + + // https://svn.boost.org/trac/boost/ticket/10647 + tester::apply("ticket-10647", + from_wkt("POLYGON((0 0, 0 5, 5 5, 5 0, 0 0)(1 1, 4 1, 4 4, 1 4, 1 1))"), + from_wkt("POLYGON((2 2, 2 3, 3 3, 3 2, 2 2))"), + true); + } +} + +template +inline void test_polygon_multipolygon() +{ + typedef bg::model::polygon PL; // ccw, open + typedef bg::model::multi_polygon MPL; + + typedef test_disjoint tester; + + tester::apply("pg-mpg-01", + from_wkt("POLYGON((2 2,2 3,3 3,3 2))"), + from_wkt("MULTIPOLYGON(((0 0,2 0,2 2,0 2)))"), + false); + + tester::apply("pg-mpg-02", + from_wkt("POLYGON((1 1,1 3,3 3,3 1))"), + from_wkt("MULTIPOLYGON(((0 0,2 0,2 2,0 2)))"), + false); + + tester::apply("pg-mpg-03", + from_wkt("POLYGON((3 3,3 4,4 4,4 3))"), + from_wkt("MULTIPOLYGON(((0 0,2 0,2 2,0 2)))"), + true); +} + +template +inline void test_multipolygon_multipolygon() +{ + typedef bg::model::polygon PL; // ccw, open + typedef bg::model::multi_polygon MPL; + + typedef test_disjoint tester; + + tester::apply("mpg-mpg-01", + from_wkt("MULTIPOLYGON(((2 2,2 3,3 3,3 2)))"), + from_wkt("MULTIPOLYGON(((0 0,2 0,2 2,0 2)))"), + false); + + tester::apply("mpg-mpg-02", + from_wkt("MULTIPOLYGON(((1 1,1 3,3 3,3 1)))"), + from_wkt("MULTIPOLYGON(((0 0,2 0,2 2,0 2)))"), + false); + + tester::apply("mpg-mpg-03", + from_wkt("MULTIPOLYGON(((3 3,3 4,4 4,4 3)))"), + from_wkt("MULTIPOLYGON(((0 0,2 0,2 2,0 2)))"), + true); +} + +//============================================================================ + +template +inline void test_areal_areal() +{ + typedef bg::model::point point_type; + + test_polygon_polygon(); + test_polygon_multipolygon(); + test_polygon_ring(); + test_polygon_box(); + + test_multipolygon_multipolygon(); + test_multipolygon_ring(); + test_multipolygon_box(); + + test_ring_ring(); + test_ring_box(); + + test_box_box(); +} + +//============================================================================ + +BOOST_AUTO_TEST_CASE( test_areal_areal_all ) +{ + test_areal_areal(); + test_areal_areal(); +#ifdef HAVE_TTMATH + test_areal_areal(); +#endif +} diff --git a/test/algorithms/relational_operations/disjoint/disjoint_coverage_l_a.cpp b/test/algorithms/relational_operations/disjoint/disjoint_coverage_l_a.cpp new file mode 100644 index 000000000..cb55aaa8d --- /dev/null +++ b/test/algorithms/relational_operations/disjoint/disjoint_coverage_l_a.cpp @@ -0,0 +1,538 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2014-2015, Oracle and/or its affiliates. + +// Licensed under the Boost Software License version 1.0. +// http://www.boost.org/users/license.html + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle + +#ifndef BOOST_TEST_MODULE +#define BOOST_TEST_MODULE test_disjoint_coverage +#endif + +// unit test to test disjoint for all geometry combinations + +#include + +#include + +#include +#include + +#include + +#include +#include + +#include + +#include + +#include + + +#ifdef HAVE_TTMATH +#include +#endif + +namespace bg = ::boost::geometry; + +//============================================================================ + +struct test_disjoint +{ + template + static inline void apply(std::string const& case_id, + Geometry1 const& geometry1, + Geometry2 const& geometry2, + bool expected_result) + { + bool result = bg::disjoint(geometry1, geometry2); + BOOST_CHECK_MESSAGE(result == expected_result, + "case ID: " << case_id << ", G1: " << bg::wkt(geometry1) + << ", G2: " << bg::wkt(geometry2) << " -> Expected: " + << expected_result << ", detected: " << result); + + result = bg::disjoint(geometry2, geometry1); + BOOST_CHECK_MESSAGE(result == expected_result, + "case ID: " << case_id << ", G1: " << bg::wkt(geometry2) + << ", G2: " << bg::wkt(geometry1) << " -> Expected: " + << expected_result << ", detected: " << result); + +#ifdef BOOST_GEOMETRY_TEST_DEBUG + std::cout << "case ID: " << case_id << "; G1 - G2: "; + std::cout << bg::wkt(geometry1) << " - "; + std::cout << bg::wkt(geometry2) << std::endl; + std::cout << std::boolalpha; + std::cout << "expected/computed result: " + << expected_result << " / " << result << std::endl; + std::cout << std::endl; + std::cout << std::noboolalpha; +#endif + } +}; + +//============================================================================ + +// linear-areal geometries +template +inline void test_segment_box() +{ + typedef bg::model::segment

S; + typedef bg::model::box

B; + + typedef test_disjoint tester; + + tester::apply("s-b-01", + from_wkt("SEGMENT(0 0,2 0)"), + from_wkt("BOX(0 0,2 2)"), + false); + + tester::apply("s-b-02", + from_wkt("SEGMENT(1 1,3 3)"), + from_wkt("BOX(0 0,2 2)"), + false); + + tester::apply("s-b-03", + from_wkt("SEGMENT(2 2,3 3)"), + from_wkt("BOX(0 0,2 2)"), + false); + + tester::apply("s-b-04", + from_wkt("SEGMENT(4 4,3 3)"), + from_wkt("BOX(0 0,2 2)"), + true); + + tester::apply("s-b-05", + from_wkt("SEGMENT(0 4,4 4)"), + from_wkt("BOX(0 0,2 2)"), + true); + + tester::apply("s-b-06", + from_wkt("SEGMENT(4 0,4 4)"), + from_wkt("BOX(0 0,2 2)"), + true); + + tester::apply("s-b-07", + from_wkt("SEGMENT(0 -2,0 -1)"), + from_wkt("BOX(0 0,1 1)"), + true); + + tester::apply("s-b-08", + from_wkt("SEGMENT(-2 -2,-2 -1)"), + from_wkt("BOX(0 0,1 1)"), + true); + + tester::apply("s-b-09", + from_wkt("SEGMENT(-2 -2,-2 -2)"), + from_wkt("BOX(0 0,1 1)"), + true); + + tester::apply("s-b-10", + from_wkt("SEGMENT(-2 0,-2 0)"), + from_wkt("BOX(0 0,1 1)"), + true); + + tester::apply("s-b-11", + from_wkt("SEGMENT(0 -2,0 -2)"), + from_wkt("BOX(0 0,1 1)"), + true); + + tester::apply("s-b-12", + from_wkt("SEGMENT(-2 0,-1 0)"), + from_wkt("BOX(0 0,1 1)"), + true); + + // segment degenerates to a point + tester::apply("s-b-13", + from_wkt("SEGMENT(0 0,0 0)"), + from_wkt("BOX(0 0,1 1)"), + false); + + tester::apply("s-b-14", + from_wkt("SEGMENT(1 1,1 1)"), + from_wkt("BOX(0 0,2 2)"), + false); + + tester::apply("s-b-15", + from_wkt("SEGMENT(2 2,2 2)"), + from_wkt("BOX(0 0,2 2)"), + false); + + tester::apply("s-b-16", + from_wkt("SEGMENT(2 0,2 0)"), + from_wkt("BOX(0 0,2 2)"), + false); + + tester::apply("s-b-17", + from_wkt("SEGMENT(0 2,0 2)"), + from_wkt("BOX(0 0,2 2)"), + false); + + tester::apply("s-b-18", + from_wkt("SEGMENT(2 2,2 2)"), + from_wkt("BOX(0 0,1 1)"), + true); +} + +template +inline void test_segment_ring() +{ + typedef bg::model::segment

S; + typedef bg::model::ring R; // ccw, open + + typedef test_disjoint tester; + + tester::apply("s-r-01", + from_wkt("SEGMENT(0 0,2 0)"), + from_wkt("POLYGON((0 0,2 0,0 2))"), + false); + + tester::apply("s-r-02", + from_wkt("SEGMENT(1 0,3 3)"), + from_wkt("POLYGON((0 0,2 0,0 2))"), + false); + + tester::apply("s-r-03", + from_wkt("SEGMENT(1 1,3 3)"), + from_wkt("POLYGON((0 0,2 0,0 2))"), + false); + + tester::apply("s-r-04", + from_wkt("SEGMENT(2 2,3 3)"), + from_wkt("POLYGON((0 0,2 0,0 2))"), + true); +} + +template +inline void test_segment_polygon() +{ + typedef bg::model::segment

S; + typedef bg::model::polygon PL; // ccw, open + + typedef test_disjoint tester; + + tester::apply("s-pg-01", + from_wkt("SEGMENT(0 0,2 0)"), + from_wkt("POLYGON((0 0,2 0,0 2))"), + false); + + tester::apply("s-pg-02", + from_wkt("SEGMENT(1 0,3 3)"), + from_wkt("POLYGON((0 0,2 0,0 2))"), + false); + + tester::apply("s-pg-03", + from_wkt("SEGMENT(1 1,3 3)"), + from_wkt("POLYGON((0 0,2 0,0 2))"), + false); + + tester::apply("s-pg-04", + from_wkt("SEGMENT(2 2,3 3)"), + from_wkt("POLYGON((0 0,2 0,0 2))"), + true); +} + +template +inline void test_segment_multipolygon() +{ + typedef bg::model::segment

S; + typedef bg::model::polygon PL; // ccw, open + typedef bg::model::multi_polygon MPL; + + typedef test_disjoint tester; + + tester::apply("s-mpg-01", + from_wkt("SEGMENT(0 0,2 0)"), + from_wkt("MULTIPOLYGON(((0 0,2 0,0 2)))"), + false); + + tester::apply("s-mpg-02", + from_wkt("SEGMENT(1 0,3 3)"), + from_wkt("MULTIPOLYGON(((0 0,2 0,0 2)))"), + false); + + tester::apply("s-mpg-03", + from_wkt("SEGMENT(1 1,3 3)"), + from_wkt("MULTIPOLYGON(((0 0,2 0,0 2)))"), + false); + + tester::apply("s-mpg-04", + from_wkt("SEGMENT(2 2,3 3)"), + from_wkt("MULTIPOLYGON(((0 0,2 0,0 2)))"), + true); +} + +template +inline void test_linestring_box() +{ + typedef bg::model::linestring

L; + typedef bg::model::box

B; + + typedef test_disjoint tester; + + tester::apply("l-b-01", + from_wkt("LINESTRING(0 0,2 0)"), + from_wkt("BOX(0 0,2 2)"), + false); + + tester::apply("l-b-02", + from_wkt("LINESTRING(1 1,3 3)"), + from_wkt("BOX(0 0,2 2)"), + false); + + tester::apply("l-b-03", + from_wkt("LINESTRING(2 2,3 3)"), + from_wkt("BOX(0 0,2 2)"), + false); + + tester::apply("l-b-04", + from_wkt("LINESTRING(4 4,3 3)"), + from_wkt("BOX(0 0,2 2)"), + true); +} + +template +inline void test_linestring_ring() +{ + typedef bg::model::linestring

L; + typedef bg::model::ring R; // ccw, open + + typedef test_disjoint tester; + + tester::apply("l-r-01", + from_wkt("LINESTRING(0 0,2 0)"), + from_wkt("POLYGON((0 0,2 0,0 2))"), + false); + + tester::apply("l-r-02", + from_wkt("LINESTRING(1 0,3 3)"), + from_wkt("POLYGON((0 0,2 0,0 2))"), + false); + + tester::apply("l-r-03", + from_wkt("LINESTRING(1 1,3 3)"), + from_wkt("POLYGON((0 0,2 0,0 2))"), + false); + + tester::apply("l-r-04", + from_wkt("LINESTRING(2 2,3 3)"), + from_wkt("POLYGON((0 0,2 0,0 2))"), + true); +} + +template +inline void test_linestring_polygon() +{ + typedef bg::model::linestring

L; + typedef bg::model::polygon PL; // ccw, open + + typedef test_disjoint tester; + + tester::apply("l-pg-01", + from_wkt("LINESTRING(0 0,2 0)"), + from_wkt("POLYGON((0 0,2 0,0 2))"), + false); + + tester::apply("l-pg-02", + from_wkt("LINESTRING(1 0,3 3)"), + from_wkt("POLYGON((0 0,2 0,0 2))"), + false); + + tester::apply("l-pg-03", + from_wkt("LINESTRING(1 1,3 3)"), + from_wkt("POLYGON((0 0,2 0,0 2))"), + false); + + tester::apply("l-pg-04", + from_wkt("LINESTRING(2 2,3 3)"), + from_wkt("POLYGON((0 0,2 0,0 2))"), + true); +} + +template +inline void test_linestring_multipolygon() +{ + typedef bg::model::linestring

L; + typedef bg::model::polygon PL; // ccw, open + typedef bg::model::multi_polygon MPL; + + typedef test_disjoint tester; + + tester::apply("l-mpg-01", + from_wkt("LINESTRING(0 0,2 0)"), + from_wkt("MULTIPOLYGON(((0 0,2 0,0 2)))"), + false); + + tester::apply("l-mpg-02", + from_wkt("LINESTRING(1 0,3 3)"), + from_wkt("MULTIPOLYGON(((0 0,2 0,0 2)))"), + false); + + tester::apply("l-mpg-03", + from_wkt("LINESTRING(1 1,3 3)"), + from_wkt("MULTIPOLYGON(((0 0,2 0,0 2)))"), + false); + + tester::apply("l-mpg-04", + from_wkt("LINESTRING(2 2,3 3)"), + from_wkt("MULTIPOLYGON(((0 0,2 0,0 2)))"), + true); +} + +template +inline void test_multilinestring_box() +{ + typedef bg::model::linestring

L; + typedef bg::model::multi_linestring ML; + typedef bg::model::box

B; + + typedef test_disjoint tester; + + tester::apply("ml-b-01", + from_wkt("MULTILINESTRING((0 0,2 0))"), + from_wkt("BOX(0 0,2 2)"), + false); + + tester::apply("ml-b-02", + from_wkt("MULTILINESTRING((1 1,3 3))"), + from_wkt("BOX(0 0,2 2)"), + false); + + tester::apply("ml-b-03", + from_wkt("MULTILINESTRING((2 2,3 3))"), + from_wkt("BOX(0 0,2 2)"), + false); + + tester::apply("ml-b-04", + from_wkt("MULTILINESTRING((4 4,3 3))"), + from_wkt("BOX(0 0,2 2)"), + true); +} + +template +inline void test_multilinestring_ring() +{ + typedef bg::model::linestring

L; + typedef bg::model::multi_linestring ML; + typedef bg::model::ring R; // ccw, open + + typedef test_disjoint tester; + + tester::apply("ml-r-01", + from_wkt("MULTILINESTRING((0 0,2 0))"), + from_wkt("POLYGON((0 0,2 0,0 2))"), + false); + + tester::apply("ml-r-02", + from_wkt("MULTILINESTRING((1 0,3 3))"), + from_wkt("POLYGON((0 0,2 0,0 2))"), + false); + + tester::apply("ml-r-03", + from_wkt("MULTILINESTRING((1 1,3 3))"), + from_wkt("POLYGON((0 0,2 0,0 2))"), + false); + + tester::apply("ml-r-04", + from_wkt("MULTILINESTRING((2 2,3 3))"), + from_wkt("POLYGON((0 0,2 0,0 2))"), + true); +} + +template +inline void test_multilinestring_polygon() +{ + typedef bg::model::linestring

L; + typedef bg::model::multi_linestring ML; + typedef bg::model::polygon PL; // ccw, open + + typedef test_disjoint tester; + + tester::apply("ml-pg-01", + from_wkt("MULTILINESTRING((0 0,2 0))"), + from_wkt("POLYGON((0 0,2 0,0 2))"), + false); + + tester::apply("ml-pg-02", + from_wkt("MULTILINESTRING((1 0,3 3))"), + from_wkt("POLYGON((0 0,2 0,0 2))"), + false); + + tester::apply("ml-pg-03", + from_wkt("MULTILINESTRING((1 1,3 3))"), + from_wkt("POLYGON((0 0,2 0,0 2))"), + false); + + tester::apply("ml-pg-04", + from_wkt("MULTILINESTRING((2 2,3 3))"), + from_wkt("POLYGON((0 0,2 0,0 2))"), + true); +} + +template +inline void test_multilinestring_multipolygon() +{ + typedef bg::model::linestring

L; + typedef bg::model::multi_linestring ML; + typedef bg::model::polygon PL; // ccw, open + typedef bg::model::multi_polygon MPL; + + typedef test_disjoint tester; + + tester::apply("ml-mpg-01", + from_wkt("MULTILINESTRING((0 0,2 0))"), + from_wkt("MULTIPOLYGON(((0 0,2 0,0 2)))"), + false); + + tester::apply("ml-mpg-02", + from_wkt("MULTILINESTRING((1 0,3 3))"), + from_wkt("MULTIPOLYGON(((0 0,2 0,0 2)))"), + false); + + tester::apply("ml-mpg-03", + from_wkt("MULTILINESTRING((1 1,3 3))"), + from_wkt("MULTIPOLYGON(((0 0,2 0,0 2)))"), + false); + + tester::apply("ml-mpg-04", + from_wkt("MULTILINESTRING((2 2,3 3))"), + from_wkt("MULTIPOLYGON(((0 0,2 0,0 2)))"), + true); +} + +//============================================================================ + +template +inline void test_linear_areal() +{ + typedef bg::model::point point_type; + + test_segment_polygon(); + test_segment_multipolygon(); + test_segment_ring(); + test_segment_box(); + + test_linestring_polygon(); + test_linestring_multipolygon(); + test_linestring_ring(); + test_linestring_box(); + + test_multilinestring_polygon(); + test_multilinestring_multipolygon(); + test_multilinestring_ring(); + test_multilinestring_box(); +} + +//============================================================================ + +BOOST_AUTO_TEST_CASE( test_linear_areal_all ) +{ + test_linear_areal(); + test_linear_areal(); +#ifdef HAVE_TTMATH + test_linear_areal(); +#endif +} diff --git a/test/algorithms/relational_operations/disjoint/disjoint_coverage_l_l.cpp b/test/algorithms/relational_operations/disjoint/disjoint_coverage_l_l.cpp new file mode 100644 index 000000000..1d1161e1c --- /dev/null +++ b/test/algorithms/relational_operations/disjoint/disjoint_coverage_l_l.cpp @@ -0,0 +1,379 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2014-2015, Oracle and/or its affiliates. + +// Licensed under the Boost Software License version 1.0. +// http://www.boost.org/users/license.html + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle + +#ifndef BOOST_TEST_MODULE +#define BOOST_TEST_MODULE test_disjoint_coverage +#endif + +// unit test to test disjoint for all geometry combinations + +#include + +#include + +#include +#include + +#include + +#include +#include + +#include + +#include + +#include + + +#ifdef HAVE_TTMATH +#include +#endif + +namespace bg = ::boost::geometry; + +//============================================================================ + +struct test_disjoint +{ + template + static inline void apply(std::string const& case_id, + Geometry1 const& geometry1, + Geometry2 const& geometry2, + bool expected_result) + { + bool result = bg::disjoint(geometry1, geometry2); + BOOST_CHECK_MESSAGE(result == expected_result, + "case ID: " << case_id << ", G1: " << bg::wkt(geometry1) + << ", G2: " << bg::wkt(geometry2) << " -> Expected: " + << expected_result << ", detected: " << result); + + result = bg::disjoint(geometry2, geometry1); + BOOST_CHECK_MESSAGE(result == expected_result, + "case ID: " << case_id << ", G1: " << bg::wkt(geometry2) + << ", G2: " << bg::wkt(geometry1) << " -> Expected: " + << expected_result << ", detected: " << result); + +#ifdef BOOST_GEOMETRY_TEST_DEBUG + std::cout << "case ID: " << case_id << "; G1 - G2: "; + std::cout << bg::wkt(geometry1) << " - "; + std::cout << bg::wkt(geometry2) << std::endl; + std::cout << std::boolalpha; + std::cout << "expected/computed result: " + << expected_result << " / " << result << std::endl; + std::cout << std::endl; + std::cout << std::noboolalpha; +#endif + } +}; + +//============================================================================ + +// linear-linear geometries +template +inline void test_segment_segment() +{ + typedef bg::model::segment

S; + + typedef test_disjoint tester; + + tester::apply("s-s-01", + from_wkt("SEGMENT(0 0,2 0)"), + from_wkt("SEGMENT(0 0,0 2)"), + false); + + tester::apply("s-s-02", + from_wkt("SEGMENT(0 0,2 0)"), + from_wkt("SEGMENT(2 0,3 0)"), + false); + + tester::apply("s-s-03", + from_wkt("SEGMENT(0 0,2 0)"), + from_wkt("SEGMENT(1 0,3 0)"), + false); + + tester::apply("s-s-04", + from_wkt("SEGMENT(0 0,2 0)"), + from_wkt("SEGMENT(1 0,1 1)"), + false); + + tester::apply("s-s-05", + from_wkt("SEGMENT(0 0,2 0)"), + from_wkt("SEGMENT(1 1,2 2)"), + true); + + tester::apply("s-s-06", + from_wkt("SEGMENT(0 0,1 1)"), + from_wkt("SEGMENT(1 1,1 1)"), + false); + + tester::apply("s-s-07", + from_wkt("SEGMENT(0 0,1 1)"), + from_wkt("SEGMENT(2 2,2 2)"), + true); + + tester::apply("s-s-08", + from_wkt("SEGMENT(0 0,1 1)"), + from_wkt("SEGMENT(2 2,3 3)"), + true); +} + +template +inline void test_linestring_segment() +{ + typedef bg::model::segment

S; + typedef bg::model::linestring

L; + + typedef test_disjoint tester; + + tester::apply("l-s-01", + from_wkt("SEGMENT(0 0,2 0)"), + from_wkt("LINESTRING(0 0,0 2)"), + false); + + tester::apply("l-s-02", + from_wkt("SEGMENT(0 0,2 0)"), + from_wkt("LINESTRING(2 0,3 0)"), + false); + + tester::apply("l-s-03", + from_wkt("SEGMENT(0 0,2 0)"), + from_wkt("LINESTRING(1 0,3 0)"), + false); + + tester::apply("l-s-04", + from_wkt("SEGMENT(0 0,2 0)"), + from_wkt("LINESTRING(1 0,1 1)"), + false); + + tester::apply("l-s-05", + from_wkt("SEGMENT(0 0,2 0)"), + from_wkt("LINESTRING(1 1,2 2)"), + true); + + tester::apply("l-s-06", + from_wkt("SEGMENT(0 0,2 0)"), + from_wkt("LINESTRING(1 1,1 1,2 2)"), + true); + + tester::apply("l-s-07", + from_wkt("SEGMENT(0 0,2 0)"), + from_wkt("LINESTRING(1 0,1 0,1 1,2 2)"), + false); + + tester::apply("l-s-08", + from_wkt("SEGMENT(0 0,2 0)"), + from_wkt("LINESTRING(1 0,1 0,3 0)"), + false); + + tester::apply("l-s-09", + from_wkt("SEGMENT(0 0,2 0)"), + from_wkt("LINESTRING(3 0,3 0,4 0)"), + true); + + tester::apply("l-s-10", + from_wkt("SEGMENT(0 0,2 0)"), + from_wkt("LINESTRING(3 0,3 0)"), + true); + + tester::apply("l-s-11", + from_wkt("SEGMENT(0 0,2 0)"), + from_wkt("LINESTRING(-1 0,-1 0)"), + true); + + tester::apply("l-s-12", + from_wkt("SEGMENT(0 0,2 0)"), + from_wkt("LINESTRING(1 0,1 0)"), + false); + + tester::apply("l-s-13", + from_wkt("SEGMENT(0 0,2 0)"), + from_wkt("LINESTRING(1 1,1 1)"), + true); +} + +template +inline void test_multilinestring_segment() +{ + typedef bg::model::segment

S; + typedef bg::model::linestring

L; + typedef bg::model::multi_linestring ML; + + typedef test_disjoint tester; + + tester::apply("s-ml-01", + from_wkt("SEGMENT(0 0,2 0)"), + from_wkt("MULTILINESTRING((0 0,0 2))"), + false); + + tester::apply("s-ml-02", + from_wkt("SEGMENT(0 0,2 0)"), + from_wkt("MULTILINESTRING((2 0,3 0))"), + false); + + tester::apply("s-ml-03", + from_wkt("SEGMENT(0 0,2 0)"), + from_wkt("MULTILINESTRING((1 0,3 0))"), + false); + + tester::apply("s-ml-04", + from_wkt("SEGMENT(0 0,2 0)"), + from_wkt("MULTILINESTRING((1 0,1 1))"), + false); + + tester::apply("s-ml-05", + from_wkt("SEGMENT(0 0,2 0)"), + from_wkt("MULTILINESTRING((1 1,2 2))"), + true); + + tester::apply("s-ml-06", + from_wkt("SEGMENT(0 0,2 0)"), + from_wkt("MULTILINESTRING((1 1,2 2),(3 3,3 3))"), + true); + + tester::apply("s-ml-07", + from_wkt("SEGMENT(0 0,2 0)"), + from_wkt("MULTILINESTRING((1 1,2 2),(1 0,1 0))"), + false); + + tester::apply("s-ml-08", + from_wkt("SEGMENT(0 0,2 0)"), + from_wkt("MULTILINESTRING((1 1,2 2),(3 0,3 0))"), + true); +} + +template +inline void test_linestring_linestring() +{ + typedef bg::model::linestring

L; + + typedef test_disjoint tester; + + tester::apply("l-l-01", + from_wkt("LINESTRING(0 0,2 0)"), + from_wkt("LINESTRING(0 0,0 2)"), + false); + + tester::apply("l-l-02", + from_wkt("LINESTRING(0 0,2 0)"), + from_wkt("LINESTRING(2 0,3 0)"), + false); + + tester::apply("l-l-03", + from_wkt("LINESTRING(0 0,2 0)"), + from_wkt("LINESTRING(1 0,3 0)"), + false); + + tester::apply("l-l-04", + from_wkt("LINESTRING(0 0,2 0)"), + from_wkt("LINESTRING(1 0,1 1)"), + false); + + tester::apply("l-l-05", + from_wkt("LINESTRING(0 0,2 0)"), + from_wkt("LINESTRING(1 1,2 2)"), + true); +} + +template +inline void test_linestring_multilinestring() +{ + typedef bg::model::linestring

L; + typedef bg::model::multi_linestring ML; + + typedef test_disjoint tester; + + tester::apply("l-ml-01", + from_wkt("LINESTRING(0 0,2 0)"), + from_wkt("MULTILINESTRING((0 0,0 2))"), + false); + + tester::apply("l-ml-02", + from_wkt("LINESTRING(0 0,2 0)"), + from_wkt("MULTILINESTRING((2 0,3 0))"), + false); + + tester::apply("l-ml-03", + from_wkt("LINESTRING(0 0,2 0)"), + from_wkt("MULTILINESTRING((1 0,3 0))"), + false); + + tester::apply("l-ml-04", + from_wkt("LINESTRING(0 0,2 0)"), + from_wkt("MULTILINESTRING((1 0,1 1))"), + false); + + tester::apply("l-ml-05", + from_wkt("LINESTRING(0 0,2 0)"), + from_wkt("MULTILINESTRING((1 1,2 2))"), + true); +} + +template +inline void test_multilinestring_multilinestring() +{ + typedef bg::model::linestring

L; + typedef bg::model::multi_linestring ML; + + typedef test_disjoint tester; + + tester::apply("ml-ml-01", + from_wkt("MULTILINESTRING((0 0,2 0))"), + from_wkt("MULTILINESTRING((0 0,0 2))"), + false); + + tester::apply("ml-ml-02", + from_wkt("MULTILINESTRING((0 0,2 0))"), + from_wkt("MULTILINESTRING((2 0,3 0))"), + false); + + tester::apply("ml-ml-03", + from_wkt("MULTILINESTRING((0 0,2 0))"), + from_wkt("MULTILINESTRING((1 0,3 0))"), + false); + + tester::apply("ml-ml-04", + from_wkt("MULTILINESTRING((0 0,2 0))"), + from_wkt("MULTILINESTRING((1 0,1 1))"), + false); + + tester::apply("ml-ml-05", + from_wkt("MULTILINESTRING((0 0,2 0))"), + from_wkt("MULTILINESTRING((1 1,2 2))"), + true); +} + +//============================================================================ + +template +inline void test_linear_linear() +{ + typedef bg::model::point point_type; + + test_linestring_linestring(); + test_linestring_multilinestring(); + test_linestring_segment(); + + test_multilinestring_multilinestring(); + test_multilinestring_segment(); + + test_segment_segment(); +} + +//============================================================================ + +BOOST_AUTO_TEST_CASE( test_linear_linear_all ) +{ + test_linear_linear(); + test_linear_linear(); +#ifdef HAVE_TTMATH + test_linear_linear(); +#endif +} diff --git a/test/algorithms/relational_operations/disjoint/disjoint_coverage_p_a.cpp b/test/algorithms/relational_operations/disjoint/disjoint_coverage_p_a.cpp new file mode 100644 index 000000000..0f42fd7ec --- /dev/null +++ b/test/algorithms/relational_operations/disjoint/disjoint_coverage_p_a.cpp @@ -0,0 +1,291 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2014-2015, Oracle and/or its affiliates. + +// Licensed under the Boost Software License version 1.0. +// http://www.boost.org/users/license.html + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle + +#ifndef BOOST_TEST_MODULE +#define BOOST_TEST_MODULE test_disjoint_coverage +#endif + +// unit test to test disjoint for all geometry combinations + +#include + +#include + +#include +#include + +#include + +#include +#include + +#include + +#include + +#include + + +#ifdef HAVE_TTMATH +#include +#endif + +namespace bg = ::boost::geometry; + +//============================================================================ + +struct test_disjoint +{ + template + static inline void apply(std::string const& case_id, + Geometry1 const& geometry1, + Geometry2 const& geometry2, + bool expected_result) + { + bool result = bg::disjoint(geometry1, geometry2); + BOOST_CHECK_MESSAGE(result == expected_result, + "case ID: " << case_id << ", G1: " << bg::wkt(geometry1) + << ", G2: " << bg::wkt(geometry2) << " -> Expected: " + << expected_result << ", detected: " << result); + + result = bg::disjoint(geometry2, geometry1); + BOOST_CHECK_MESSAGE(result == expected_result, + "case ID: " << case_id << ", G1: " << bg::wkt(geometry2) + << ", G2: " << bg::wkt(geometry1) << " -> Expected: " + << expected_result << ", detected: " << result); + +#ifdef BOOST_GEOMETRY_TEST_DEBUG + std::cout << "case ID: " << case_id << "; G1 - G2: "; + std::cout << bg::wkt(geometry1) << " - "; + std::cout << bg::wkt(geometry2) << std::endl; + std::cout << std::boolalpha; + std::cout << "expected/computed result: " + << expected_result << " / " << result << std::endl; + std::cout << std::endl; + std::cout << std::noboolalpha; +#endif + } +}; + +//============================================================================ + +// pointlike-areal geometries +template +inline void test_point_box() +{ + typedef test_disjoint tester; + typedef bg::model::box

B; + + tester::apply("p-b-01", + from_wkt

("POINT(0 0)"), + from_wkt("BOX(0 0,1 1)"), + false); + + tester::apply("p-b-02", + from_wkt

("POINT(2 2)"), + from_wkt("BOX(0 0,1 0)"), + true); +} + +template +inline void test_point_ring() +{ + typedef bg::model::ring R; // ccw, open + + typedef test_disjoint tester; + + tester::apply("p-r-01", + from_wkt

("POINT(0 0)"), + from_wkt("POLYGON((0 0,1 0,0 1))"), + false); + + tester::apply("p-r-02", + from_wkt

("POINT(1 1)"), + from_wkt("POLYGON((0 0,1 0,0 1))"), + true); +} + +template +inline void test_point_polygon() +{ + typedef bg::model::polygon PL; // ccw, open + + typedef test_disjoint tester; + + tester::apply("p-pg-01", + from_wkt

("POINT(0 0)"), + from_wkt("POLYGON((0 0,1 0,0 1))"), + false); + + tester::apply("p-pg-02", + from_wkt

("POINT(1 1)"), + from_wkt("POLYGON((0 0,1 0,0 1))"), + true); +} + +template +inline void test_point_multipolygon() +{ + typedef bg::model::polygon PL; // ccw, open + typedef bg::model::multi_polygon MPL; + + typedef test_disjoint tester; + + tester::apply("p-mpg-01", + from_wkt

("POINT(0 0)"), + from_wkt("MULTIPOLYGON(((0 0,1 0,0 1)),((2 0,3 0,2 1)))"), + false); + + tester::apply("p-mpg-02", + from_wkt

("POINT(1 1)"), + from_wkt("MULTIPOLYGON(((0 0,1 0,0 1)),((2 0,3 0,2 1)))"), + true); +} + +template +inline void test_multipoint_box() +{ + typedef test_disjoint tester; + typedef bg::model::multi_point

MP; + typedef bg::model::box

B; + + tester::apply("mp-b-01", + from_wkt("MULTIPOINT(0 0,1 1)"), + from_wkt("BOX(0 0,2 2)"), + false); + + tester::apply("mp-b-02", + from_wkt("MULTIPOINT(1 1,3 3)"), + from_wkt("BOX(0 0,2 2)"), + false); + + tester::apply("mp-b-03", + from_wkt("MULTIPOINT(3 3,4 4)"), + from_wkt("BOX(0 0,2 2)"), + true); + + tester::apply("mp-b-04", + from_wkt("MULTIPOINT()"), + from_wkt("BOX(0 0,2 2)"), + true); +} + +template +inline void test_multipoint_ring() +{ + typedef bg::model::multi_point

MP; + typedef bg::model::ring R; // ccw, open + + typedef test_disjoint tester; + + tester::apply("mp-r-01", + from_wkt("MULTIPOINT(0 0,1 0)"), + from_wkt("POLYGON((0 0,1 0,0 1))"), + false); + + tester::apply("mp-r-02", + from_wkt("MULTIPOINT(1 0,1 1)"), + from_wkt("POLYGON((0 0,1 0,0 1))"), + false); + + tester::apply("mp-r-03", + from_wkt("MULTIPOINT(1 1,2 2)"), + from_wkt("POLYGON((0 0,1 0,0 1))"), + true); +} + +template +inline void test_multipoint_polygon() +{ + typedef bg::model::multi_point

MP; + typedef bg::model::polygon PL; // ccw, open + + typedef test_disjoint tester; + + tester::apply("mp-pg-01", + from_wkt("MULTIPOINT(0 0,1 0)"), + from_wkt("POLYGON(((0 0,1 0,0 1)))"), + false); + + tester::apply("mp-pg-02", + from_wkt("MULTIPOINT(0 0,2 0)"), + from_wkt("POLYGON(((0 0,1 0,0 1)))"), + false); + + tester::apply("mp-pg-03", + from_wkt("MULTIPOINT(1 1,2 0)"), + from_wkt("POLYGON(((0 0,1 0,0 1)))"), + true); + + tester::apply("mp-pg-04", + from_wkt("MULTIPOINT(1 1,2 3)"), + from_wkt("POLYGON(((0 0,1 0,0 1)))"), + true); +} + +template +inline void test_multipoint_multipolygon() +{ + typedef bg::model::multi_point

MP; + typedef bg::model::polygon PL; // ccw, open + typedef bg::model::multi_polygon MPL; + + typedef test_disjoint tester; + + tester::apply("mp-mp-01", + from_wkt("MULTIPOINT(0 0,2 0)"), + from_wkt("MULTIPOLYGON((0 0,1 0,0 1)),(2 0,3 0,2 1))"), + false); + + tester::apply("mp-mp-02", + from_wkt("MULTIPOINT(0 0,1 0)"), + from_wkt("MULTIPOLYGON((0 0,1 0,0 1)),(2 0,3 0,2 1))"), + false); + + tester::apply("mp-mp-03", + from_wkt("MULTIPOINT(1 1,2 0)"), + from_wkt("MULTIPOLYGON((0 0,1 0,0 1)),(2 0,3 0,2 1))"), + false); + + tester::apply("mp-mp-04", + from_wkt("MULTIPOINT(1 1,2 3)"), + from_wkt("MULTIPOLYGON((0 0,1 0,0 1)),(2 0,3 0,2 1))"), + true); +} + +//============================================================================ + +template +inline void test_pointlike_areal() +{ + typedef bg::model::point point_type; + + test_point_polygon(); + test_point_multipolygon(); + test_point_ring(); + test_point_box(); + + // not implemented yet + // test_multipoint_polygon(); + // test_multipoint_multipolygon(); + // test_multipoint_ring(); + test_multipoint_box(); +} + +//============================================================================ + +BOOST_AUTO_TEST_CASE( test_pointlike_areal_all ) +{ + test_pointlike_areal(); + test_pointlike_areal(); +#ifdef HAVE_TTMATH + test_pointlike_areal(); +#endif +} diff --git a/test/algorithms/relational_operations/disjoint/disjoint_coverage_p_l.cpp b/test/algorithms/relational_operations/disjoint/disjoint_coverage_p_l.cpp new file mode 100644 index 000000000..ab4b8839a --- /dev/null +++ b/test/algorithms/relational_operations/disjoint/disjoint_coverage_p_l.cpp @@ -0,0 +1,391 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2014-2015, Oracle and/or its affiliates. + +// Licensed under the Boost Software License version 1.0. +// http://www.boost.org/users/license.html + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle + +#ifndef BOOST_TEST_MODULE +#define BOOST_TEST_MODULE test_disjoint_coverage +#endif + +// unit test to test disjoint for all geometry combinations + +#include + +#include + +#include +#include + +#include + +#include +#include + +#include + +#include + +#include + + +#ifdef HAVE_TTMATH +#include +#endif + +namespace bg = ::boost::geometry; + +//============================================================================ + +struct test_disjoint +{ + template + static inline void apply(std::string const& case_id, + Geometry1 const& geometry1, + Geometry2 const& geometry2, + bool expected_result) + { + bool result = bg::disjoint(geometry1, geometry2); + BOOST_CHECK_MESSAGE(result == expected_result, + "case ID: " << case_id << ", G1: " << bg::wkt(geometry1) + << ", G2: " << bg::wkt(geometry2) << " -> Expected: " + << expected_result << ", detected: " << result); + + result = bg::disjoint(geometry2, geometry1); + BOOST_CHECK_MESSAGE(result == expected_result, + "case ID: " << case_id << ", G1: " << bg::wkt(geometry2) + << ", G2: " << bg::wkt(geometry1) << " -> Expected: " + << expected_result << ", detected: " << result); + +#ifdef BOOST_GEOMETRY_TEST_DEBUG + std::cout << "case ID: " << case_id << "; G1 - G2: "; + std::cout << bg::wkt(geometry1) << " - "; + std::cout << bg::wkt(geometry2) << std::endl; + std::cout << std::boolalpha; + std::cout << "expected/computed result: " + << expected_result << " / " << result << std::endl; + std::cout << std::endl; + std::cout << std::noboolalpha; +#endif + } +}; + +//============================================================================ + +// pointlike-linear geometries +template +inline void test_point_segment() +{ + typedef test_disjoint tester; + typedef bg::model::segment

S; + + tester::apply("p-s-01", + from_wkt

("POINT(0 0)"), + from_wkt("SEGMENT(0 0,2 0)"), + false); + + tester::apply("p-s-02", + from_wkt

("POINT(2 0)"), + from_wkt("SEGMENT(0 0,2 0)"), + false); + + tester::apply("p-s-03", + from_wkt

("POINT(1 0)"), + from_wkt("SEGMENT(0 0,2 0)"), + false); + + tester::apply("p-s-04", + from_wkt

("POINT(1 1)"), + from_wkt("SEGMENT(0 0,2 0)"), + true); + + tester::apply("p-s-05", + from_wkt

("POINT(3 0)"), + from_wkt("SEGMENT(0 0,2 0)"), + true); + + tester::apply("p-s-06", + from_wkt

("POINT(-1 0)"), + from_wkt("SEGMENT(0 0,2 0)"), + true); + + // degenerate segment + tester::apply("p-s-07", + from_wkt

("POINT(-1 0)"), + from_wkt("SEGMENT(2 0,2 0)"), + true); + + // degenerate segment + tester::apply("p-s-08", + from_wkt

("POINT(2 0)"), + from_wkt("SEGMENT(2 0,2 0)"), + false); + + // degenerate segment + tester::apply("p-s-09", + from_wkt

("POINT(3 0)"), + from_wkt("SEGMENT(2 0,2 0)"), + true); + + // degenerate segment + tester::apply("p-s-10", + from_wkt

("POINT(1 1)"), + from_wkt("SEGMENT(2 0,2 0)"), + true); +} + +template +inline void test_point_linestring() +{ + typedef bg::model::linestring

L; + + typedef test_disjoint tester; + + tester::apply("p-l-01", + from_wkt

("POINT(0 0)"), + from_wkt("LINESTRING(0 0,2 2,4 4)"), + false); + + tester::apply("p-l-02", + from_wkt

("POINT(1 1)"), + from_wkt("LINESTRING(0 0,2 2,4 4)"), + false); + + tester::apply("p-l-03", + from_wkt

("POINT(3 3)"), + from_wkt("LINESTRING(0 0,2 2,4 4)"), + false); + + tester::apply("p-l-04", + from_wkt

("POINT(1 0)"), + from_wkt("LINESTRING(0 0,2 2,4 4)"), + true); + + tester::apply("p-l-05", + from_wkt

("POINT(5 5)"), + from_wkt("LINESTRING(0 0,2 2,4 4)"), + true); + + tester::apply("p-l-06", + from_wkt

("POINT(5 5)"), + from_wkt("LINESTRING(0 0,2 2)"), + true); +} + +template +inline void test_point_multilinestring() +{ + typedef bg::model::linestring

L; + typedef bg::model::multi_linestring ML; + + typedef test_disjoint tester; + + tester::apply("p-ml-01", + from_wkt

("POINT(0 1)"), + from_wkt("MULTILINESTRING((0 0,2 2,4 4),(0 0,2 0,4 0))"), + true); + + tester::apply("p-ml-02", + from_wkt

("POINT(0 0)"), + from_wkt("MULTILINESTRING((0 0,2 2,4 4),(0 0,2 0,4 0))"), + false); + + tester::apply("p-ml-03", + from_wkt

("POINT(1 1)"), + from_wkt("MULTILINESTRING((0 0,2 2,4 4),(0 0,2 0,4 0))"), + false); + + tester::apply("p-ml-04", + from_wkt

("POINT(1 0)"), + from_wkt("MULTILINESTRING((0 0,2 2,4 4),(0 0,2 0,4 0))"), + false); + + tester::apply("p-ml-05", + from_wkt

("POINT(0 0)"), + from_wkt("MULTILINESTRING((1 1,2 2,4 4),(3 0,4 0))"), + true); + + tester::apply("p-ml-06", + from_wkt

("POINT(0 0)"), + from_wkt("MULTILINESTRING((1 1,2 2,4 4),(0 0,4 0))"), + false); + + tester::apply("p-ml-07", + from_wkt

("POINT(0 0)"), + from_wkt("MULTILINESTRING((1 1,2 2,4 4),(-1 0,4 0))"), + false); +} + +template +inline void test_multipoint_segment() +{ + typedef test_disjoint tester; + typedef bg::model::multi_point

MP; + typedef bg::model::segment

S; + + tester::apply("mp-s-01", + from_wkt("MULTIPOINT(0 0,1 1)"), + from_wkt("SEGMENT(0 0,2 0)"), + false); + + tester::apply("mp-s-02", + from_wkt("MULTIPOINT(1 0,1 1)"), + from_wkt("SEGMENT(0 0,2 0)"), + false); + + tester::apply("mp-s-03", + from_wkt("MULTIPOINT(1 1,2 2)"), + from_wkt("SEGMENT(0 0,2 0)"), + true); + + tester::apply("mp-s-04", + from_wkt("MULTIPOINT()"), + from_wkt("SEGMENT(0 0,2 0)"), + true); + + tester::apply("mp-s-05", + from_wkt("MULTIPOINT(3 0,4 0)"), + from_wkt("SEGMENT(0 0,2 0)"), + true); + + tester::apply("mp-s-06", + from_wkt("MULTIPOINT(1 0,4 0)"), + from_wkt("SEGMENT(0 0,2 0)"), + false); + + // segments that degenerate to a point + tester::apply("mp-s-07", + from_wkt("MULTIPOINT(1 1,2 2)"), + from_wkt("SEGMENT(0 0,0 0)"), + true); + + tester::apply("mp-s-08", + from_wkt("MULTIPOINT(1 1,2 2)"), + from_wkt("SEGMENT(1 1,1 1)"), + false); +} + +template +inline void test_multipoint_linestring() +{ + typedef bg::model::multi_point

MP; + typedef bg::model::linestring

L; + + typedef test_disjoint tester; + + tester::apply("mp-l-01", + from_wkt("MULTIPOINT(0 0,1 0)"), + from_wkt("LINESTRING(0 0,2 2,4 4)"), + false); + + tester::apply("mp-l-02", + from_wkt("MULTIPOINT(1 0,1 1)"), + from_wkt("LINESTRING(0 0,2 2,4 4)"), + false); + + tester::apply("mp-l-03", + from_wkt("MULTIPOINT(1 0,3 3)"), + from_wkt("LINESTRING(0 0,2 2,4 4)"), + false); + + tester::apply("mp-l-04", + from_wkt("MULTIPOINT(1 0,2 0)"), + from_wkt("LINESTRING(0 0,2 2,4 4)"), + true); + + tester::apply("mp-l-05", + from_wkt("MULTIPOINT(-1 -1,2 0)"), + from_wkt("LINESTRING(0 0,2 2,4 4)"), + true); + + tester::apply("mp-l-06", + from_wkt("MULTIPOINT(-1 -1,2 0)"), + from_wkt("LINESTRING(1 0,3 0)"), + false); + + tester::apply("mp-l-07", + from_wkt("MULTIPOINT(-1 -1,2 0,-1 -1,2 0)"), + from_wkt("LINESTRING(1 0,3 0)"), + false); + + tester::apply("mp-l-08", + from_wkt("MULTIPOINT(2 0)"), + from_wkt("LINESTRING(1 0)"), + true); + + tester::apply("mp-l-09", + from_wkt("MULTIPOINT(3 0,0 0,3 0)"), + from_wkt("LINESTRING(1 0,2 0)"), + true); +} + +template +inline void test_multipoint_multilinestring() +{ + typedef bg::model::multi_point

MP; + typedef bg::model::linestring

L; + typedef bg::model::multi_linestring ML; + + typedef test_disjoint tester; + + tester::apply("mp-ml-01", + from_wkt("MULTIPOINT(0 1,0 2)"), + from_wkt("MULTILINESTRING((0 0,2 2,4 4),(0 0,2 0,4 0))"), + true); + + tester::apply("mp-ml-02", + from_wkt("MULTIPOINT(0 0,1 0)"), + from_wkt("MULTILINESTRING((0 0,2 2,4 4),(0 0,2 0,4 0))"), + false); + + tester::apply("mp-ml-03", + from_wkt("MULTIPOINT(0 1,1 1)"), + from_wkt("MULTILINESTRING((0 0,2 2,4 4),(0 0,2 0,4 0))"), + false); + + tester::apply("mp-ml-04", + from_wkt("MULTIPOINT(0 1,1 0)"), + from_wkt("MULTILINESTRING((0 0,2 2,4 4),(0 0,2 0,4 0))"), + false); + + tester::apply("mp-ml-05", + from_wkt("MULTIPOINT(0 0,10 0)"), + from_wkt("MULTILINESTRING((0 0,2 2,4 4),(0 0,2 0,4 0))"), + false); + + tester::apply("mp-ml-06", + from_wkt("MULTIPOINT(-1 0,3 0)"), + from_wkt("MULTILINESTRING((0 0,2 2,4 4),(0 0,2 0,4 0))"), + false); +} + +//============================================================================ + +template +inline void test_pointlike_linear() +{ + typedef bg::model::point point_type; + + test_point_linestring(); + test_point_multilinestring(); + test_point_segment(); + + test_multipoint_linestring(); + test_multipoint_multilinestring(); + test_multipoint_segment(); +} + +//============================================================================ + +BOOST_AUTO_TEST_CASE( test_pointlike_linear_all ) +{ + test_pointlike_linear(); + test_pointlike_linear(); +#ifdef HAVE_TTMATH + test_pointlike_linear(); +#endif +} diff --git a/test/algorithms/relational_operations/disjoint/disjoint_coverage_p_p.cpp b/test/algorithms/relational_operations/disjoint/disjoint_coverage_p_p.cpp new file mode 100644 index 000000000..9121e0f02 --- /dev/null +++ b/test/algorithms/relational_operations/disjoint/disjoint_coverage_p_p.cpp @@ -0,0 +1,169 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2014-2015, Oracle and/or its affiliates. + +// Licensed under the Boost Software License version 1.0. +// http://www.boost.org/users/license.html + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle + +#ifndef BOOST_TEST_MODULE +#define BOOST_TEST_MODULE test_disjoint_coverage +#endif + +// unit test to test disjoint for all geometry combinations + +#include + +#include + +#include +#include + +#include + +#include +#include + +#include + +#include + +#include + + +#ifdef HAVE_TTMATH +#include +#endif + +namespace bg = ::boost::geometry; + +//============================================================================ + +struct test_disjoint +{ + template + static inline void apply(std::string const& case_id, + Geometry1 const& geometry1, + Geometry2 const& geometry2, + bool expected_result) + { + bool result = bg::disjoint(geometry1, geometry2); + BOOST_CHECK_MESSAGE(result == expected_result, + "case ID: " << case_id << ", G1: " << bg::wkt(geometry1) + << ", G2: " << bg::wkt(geometry2) << " -> Expected: " + << expected_result << ", detected: " << result); + + result = bg::disjoint(geometry2, geometry1); + BOOST_CHECK_MESSAGE(result == expected_result, + "case ID: " << case_id << ", G1: " << bg::wkt(geometry2) + << ", G2: " << bg::wkt(geometry1) << " -> Expected: " + << expected_result << ", detected: " << result); + +#ifdef BOOST_GEOMETRY_TEST_DEBUG + std::cout << "case ID: " << case_id << "; G1 - G2: "; + std::cout << bg::wkt(geometry1) << " - "; + std::cout << bg::wkt(geometry2) << std::endl; + std::cout << std::boolalpha; + std::cout << "expected/computed result: " + << expected_result << " / " << result << std::endl; + std::cout << std::endl; + std::cout << std::noboolalpha; +#endif + } +}; + +//============================================================================ + +// pointlike-pointlike geometries +template +inline void test_point_point() +{ + typedef test_disjoint tester; + + tester::apply("p-p-01", + from_wkt

("POINT(0 0)"), + from_wkt

("POINT(0 0)"), + false); + + tester::apply("p-p-02", + from_wkt

("POINT(0 0)"), + from_wkt

("POINT(1 1)"), + true); +} + +template +inline void test_point_multipoint() +{ + typedef bg::model::multi_point

MP; + + typedef test_disjoint tester; + + tester::apply("p-mp-01", + from_wkt

("POINT(0 0)"), + from_wkt("MULTIPOINT(0 0,1 1)"), + false); + + tester::apply("p-mp-02", + from_wkt

("POINT(0 0)"), + from_wkt("MULTIPOINT(1 1,2 2)"), + true); + + tester::apply("p-mp-03", + from_wkt

("POINT(0 0)"), + from_wkt("MULTIPOINT()"), + true); +} + +template +inline void test_multipoint_multipoint() +{ + typedef bg::model::multi_point

MP; + + typedef test_disjoint tester; + + tester::apply("mp-mp-01", + from_wkt("MULTIPOINT(0 0,1 0)"), + from_wkt("MULTIPOINT(0 0,1 1)"), + false); + + tester::apply("mp-mp-02", + from_wkt("MULTIPOINT(0 0,1 0)"), + from_wkt("MULTIPOINT(1 1,2 2)"), + true); + + tester::apply("mp-mp-03", + from_wkt("MULTIPOINT()"), + from_wkt("MULTIPOINT(1 1,2 2)"), + true); + + tester::apply("mp-mp-04", + from_wkt("MULTIPOINT(0 0,1 0)"), + from_wkt("MULTIPOINT()"), + true); +} + +//============================================================================ + +template +inline void test_pointlike_pointlike() +{ + typedef bg::model::point point_type; + + test_point_point(); + test_point_multipoint(); + + test_multipoint_multipoint(); +} + +//============================================================================ + +BOOST_AUTO_TEST_CASE( test_pointlike_pointlike_all ) +{ + test_pointlike_pointlike(); + test_pointlike_pointlike(); +#ifdef HAVE_TTMATH + test_pointlike_pointlike(); +#endif +} diff --git a/test/algorithms/relational_operations/disjoint/disjoint_point_box_geometry.cpp b/test/algorithms/relational_operations/disjoint/disjoint_point_box_geometry.cpp new file mode 100644 index 000000000..f1de2de0e --- /dev/null +++ b/test/algorithms/relational_operations/disjoint/disjoint_point_box_geometry.cpp @@ -0,0 +1,127 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// Unit Test + +// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2015 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2015 Mateusz Loskot, London, UK. + +// This file was modified by Oracle on 2015. +// Modifications copyright (c) 2015, Oracle and/or its affiliates. + +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle + +// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library +// (geolib/GGL), copyright (c) 1995-2010 Geodan, 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 "test_disjoint.hpp" + +#include +#include +#include + +#include + +#include + +#include + + +template +void test_all() +{ + typedef bg::model::box

box; + + test_disjoint("pp1", "point(1 1)", "point(1 1)", false); + test_disjoint("pp2", "point(1 1)", "point(1.001 1)", true); + + // left-right + test_disjoint("bb1", "box(1 1, 2 2)", "box(3 1, 4 2)", true); + test_disjoint("bb2", "box(1 1, 2 2)", "box(2 1, 3 2)", false); + test_disjoint("bb3", "box(1 1, 2 2)", "box(2 2, 3 3)", false); + test_disjoint("bb4", "box(1 1, 2 2)", "box(2.001 2, 3 3)", true); + + // up-down + test_disjoint("bb5", "box(1 1, 2 2)", "box(1 3, 2 4)", true); + test_disjoint("bb6", "box(1 1, 2 2)", "box(1 2, 2 3)", false); + // right-left + test_disjoint("bb7", "box(1 1, 2 2)", "box(0 1, 1 2)", false); + test_disjoint("bb8", "box(1 1, 2 2)", "box(0 1, 1 2)", false); + + // point-box + test_disjoint("pb1", "point(1 1)", "box(0 0, 2 2)", false); + test_disjoint("pb2", "point(2 2)", "box(0 0, 2 2)", false); + test_disjoint("pb3", "point(2.0001 2)", "box(1 1, 2 2)", true); + test_disjoint("pb4", "point(0.9999 2)", "box(1 1, 2 2)", true); + + // box-point (to test reverse compiling) + test_disjoint("bp1", "box(1 1, 2 2)", "point(2 2)", false); + + // Test triangles for polygons/rings, boxes + // Note that intersections are tested elsewhere, they don't need + // thorough test at this place + typedef bg::model::polygon

polygon; + typedef bg::model::ring

ring; + + // Testing overlap (and test compiling with box) + test_disjoint("overlaps_box_pp", overlaps_box[0], overlaps_box[1], false); + test_disjoint("overlaps_box_bp", overlaps_box[0], overlaps_box[1], false); + test_disjoint("overlaps_box_br", overlaps_box[0], overlaps_box[1], false); + test_disjoint("overlaps_box_pb", overlaps_box[1], overlaps_box[0], false); + test_disjoint("overlaps_box_rb", overlaps_box[1], overlaps_box[0], false); + + test_disjoint("point_ring1", "POINT(0 0)", "POLYGON((0 0,3 3,6 0,0 0))", false); + test_disjoint("point_ring2", "POINT(3 1)", "POLYGON((0 0,3 3,6 0,0 0))", false); + test_disjoint("point_ring3", "POINT(0 3)", "POLYGON((0 0,3 3,6 0,0 0))", true); + test_disjoint("point_polygon1", "POINT(0 0)", "POLYGON((0 0,3 3,6 0,0 0))", false); + test_disjoint("point_polygon2", "POINT(3 1)", "POLYGON((0 0,3 3,6 0,0 0))", false); + test_disjoint("point_polygon3", "POINT(0 3)", "POLYGON((0 0,3 3,6 0,0 0))", true); + + test_disjoint("point_ring2", "POLYGON((0 0,3 3,6 0,0 0))", "POINT(0 0)", false); + test_disjoint("point_polygon2", "POLYGON((0 0,3 3,6 0,0 0))", "POINT(0 0)", false); + + + // Problem described by Volker/Albert 2012-06-01 + test_disjoint("volker_albert_1", + "POLYGON((1992 3240,1992 1440,3792 1800,3792 3240,1992 3240))", + "BOX(1941 2066, 2055 2166)", false); + + test_disjoint("volker_albert_2", + "POLYGON((1941 2066,2055 2066,2055 2166,1941 2166))", + "BOX(1941 2066, 2055 2166)", false); +} + + +template +void test_3d() +{ + typedef bg::model::box

box; + + test_disjoint("pp 3d 1", "point(1 1 1)", "point(1 1 1)", false); + test_disjoint("pp 3d 2", "point(1 1 1)", "point(1.001 1 1)", true); + + test_disjoint("bb1", "box(1 1 1, 2 2 2)", "box(3 1 1, 4 2 1)", true); + test_disjoint("bb2", "box(1 1 1, 2 2 2)", "box(2 1 1, 3 2 1)", false); + test_disjoint("bb3", "box(1 1 1, 2 2 2)", "box(2 2 1, 3 3 1)", false); + test_disjoint("bb4", "box(1 1 1, 2 2 2)", "box(2.001 2 1, 3 3 1)", true); + +} + +int test_main(int, char* []) +{ + test_all >(); + test_all >(); + +#ifdef HAVE_TTMATH + test_all >(); +#endif + + test_3d >(); + + + return 0; +} diff --git a/test/algorithms/relational_operations/intersects/Jamfile.v2 b/test/algorithms/relational_operations/intersects/Jamfile.v2 new file mode 100644 index 000000000..a8a0d9127 --- /dev/null +++ b/test/algorithms/relational_operations/intersects/Jamfile.v2 @@ -0,0 +1,24 @@ +# Boost.Geometry (aka GGL, Generic Geometry Library) +# +# Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. +# Copyright (c) 2008-2015 Bruno Lalande, Paris, France. +# Copyright (c) 2009-2015 Mateusz Loskot, London, UK. +# +# This file was modified by Oracle on 2014, 2015. +# Modifications copyright (c) 2014-2015, Oracle and/or its affiliates. +# +# Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle +# 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) + +test-suite boost-geometry-algorithms-relational-intersects + : + [ run intersects.cpp : : : : algorithms_intersects ] + [ run intersects_box_geometry.cpp : : : : algorithms_intersects_box_geometry ] + [ run intersects_multi.cpp : : : : algorithms_intersects_multi ] + [ run intersects_self.cpp : : : : algorithms_intersects_self ] + ; + diff --git a/test/algorithms/relational_operations/intersects.cpp b/test/algorithms/relational_operations/intersects/intersects.cpp similarity index 56% rename from test/algorithms/relational_operations/intersects.cpp rename to test/algorithms/relational_operations/intersects/intersects.cpp index 8a2f9cf14..5ef71ba00 100644 --- a/test/algorithms/relational_operations/intersects.cpp +++ b/test/algorithms/relational_operations/intersects/intersects.cpp @@ -1,10 +1,10 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) -// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. -// Copyright (c) 2013 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2013-2015 Adam Wulkiewicz, Lodz, Poland. -// This file was modified by Oracle on 2013. -// Modifications copyright (c) 2013, Oracle and/or its affiliates. +// This file was modified by Oracle on 2013, 2015. +// Modifications copyright (c) 2013-2015, Oracle and/or its affiliates. // Use, modification and distribution is subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at @@ -165,23 +165,6 @@ void test_all() typedef bg::model::polygon

polygon; typedef bg::model::ring

ring; - // intersect <=> ! disjoint (in most cases) - // so most tests are done in disjoint test. - // We only test compilation of a few cases. - test_geometry >("POINT(1 1)", "BOX(0 0,2 2)", true); - - test_geometry >( - "POLYGON((1992 3240,1992 1440,3792 1800,3792 3240,1992 3240))", - "BOX(1941 2066, 2055 2166)", true); - - test_geometry >( - "POLYGON((1992 3240,1992 1440,3792 1800,3792 3240,1992 3240))", - "BOX(1941 2066, 2055 2166)", true); - - test_geometry >( - "POLYGON((1941 2066,2055 2066,2055 2166,1941 2166))", - "BOX(1941 2066, 2055 2166)", true); - test_intersects_point_segment

(); test_intersects_point_linestring

(); test_intersects_polygon_polygon

(); @@ -193,157 +176,28 @@ void test_all() test_multi_linestring_polygon

(); test_multi_polygon_polygon

(); - // self-intersecting is not tested in disjoint, so that is done here. - - // Just a normal polygon - test_self_intersects("POLYGON((0 0,0 4,1.5 2.5,2.5 1.5,4 0,0 0))", false); - - // Self intersecting - test_self_intersects("POLYGON((1 2,1 1,2 1,2 2.25,3 2.25,3 0,0 0,0 3,3 3,2.75 2,1 2))", true); - - // Self intersecting in last segment - test_self_intersects("POLYGON((0 2,2 4,2 0,4 2,0 2))", true); - - // Self tangent - test_self_intersects("POLYGON((0 0,0 4,4 4,4 0,2 4,0 0))", true); - - // Self tangent in corner - test_self_intersects("POLYGON((0 0,0 4,4 4,4 0,0 4,2 0,0 0))", true); - - // With spike - test_self_intersects("POLYGON((0 0,0 4,4 4,4 2,6 2,4 2,4 0,0 0))", true); - - // Non intersection, but with duplicate - test_self_intersects("POLYGON((0 0,0 4,4 0,4 0,0 0))", false); - - // With many duplicates - test_self_intersects( - "POLYGON((0 0,0 1,0 1,0 1,0 2,0 2,0 3,0 3,0 3,0 3,0 4,2 4,2 4,4 4,4 0,4 0,3 0,3 0,3 0,3 0,3 0,0 0))", - false); - - // Hole: interior tangent to exterior - test_self_intersects("POLYGON((0 0,0 4,4 4,4 0,0 0),(1 2,2 4,3 2,1 2))", true); - - // Hole: interior intersecting exterior - test_self_intersects("POLYGON((0 0,0 4,4 4,4 0,0 0),(1 1,1 3,5 4,1 1))", true); - - // Hole: two intersecting holes - test_self_intersects( - "POLYGON((0 0,0 4,4 4,4 0,0 0),(1 1,1 3,3 3,3 1,1 1),(2 2,2 3.5,3.5 3.5,3.5 2,2 2))", true); - - // Mail Akira T on [Boost-users] at 27-7-2011 3:17 - test_self_intersects >( - "LINESTRING(0 0,0 4,4 4,2 2,2 5)", true); - - test_self_intersects >( - "LINESTRING(0 4,4 4,2 2,2 5)", true); - - // Test self-intersections at last segment in close/open rings: - test_self_intersects >( - "POLYGON((0 0,3 3,4 1,0 0))", false); - - test_self_intersects >( - "POLYGON((0 0,3 3,4 1))", false); - - test_self_intersects >( - "POLYGON((0 0,3 3,4 1,0 1,0 0))", true); - - test_self_intersects >( - "POLYGON((0 0,3 3,4 1,0 1))", true); - - // Duplicates in first or last - test_self_intersects >( - "POLYGON((0 0,3 3,4 1,0 1,0 1,0 0))", true); - test_self_intersects >( - "POLYGON((0 0,3 3,4 1,0 1,0 0,0 0))", true); - test_self_intersects >( - "POLYGON((0 0,3 3,4 1,0 1,0 1))", true); - test_self_intersects >( - "POLYGON((0 0,0 0,3 3,4 1,0 1,0 1,0 0))", true); - test_self_intersects >( - "POLYGON((0 0,0 0,3 3,4 1,0 1,0 1))", true); - test_self_intersects >( - "POLYGON((0 0,3 3,3 3,4 1,0 1,0 1,0 0))", true); - test_self_intersects >( - "POLYGON((0 0,3 3,3 3,4 1,0 1,0 1))", true); - - test_self_intersects >( - "POLYGON((0 0,3 3,4 1,0 0,0 0))", false); - test_self_intersects >( - "POLYGON((0 0,3 3,4 1,4 1,0 0))", false); - test_self_intersects >( - "POLYGON((0 0,3 3,4 1,4 1))", false); - test_self_intersects >( - "POLYGON((0 0,0 0,3 3,4 1,0 0))", false); - test_self_intersects >( - "POLYGON((0 0,0 0,3 3,4 1))", false); - test_self_intersects >( - "POLYGON((0 0,3 3,3 3,4 1,0 0))", false); - test_self_intersects >( - "POLYGON((0 0,3 3,3 3,4 1))", false); - - test_geometry >( - "POINT(0 0)", - "BOX(0 0,4 4)", - true); - test_geometry >( + test_geometry( "POINT(0 0)", "POLYGON((0 0,3 3,3 3,4 1))", true); - test_geometry >( + test_geometry( "POINT(0 0)", "POLYGON((0 0,3 3,3 3,4 1))", true); - test_geometry, P>( + test_geometry( "POLYGON((0 0,3 3,3 3,4 1))", "POINT(0 0)", true); - test_geometry, P>( + test_geometry( "POLYGON((0 0,3 3,3 3,4 1))", "POINT(0 0)", true); } -// Those tests won't pass for rational<> because numeric_limits<> isn't specialized for this type -template -void test_additional() -{ - test_geometry, bg::model::box

>( - "SEGMENT(0 0,3 3)", - "BOX(1 2,3 5)", - true); - test_geometry, bg::model::box

>( - "SEGMENT(1 1,2 3)", - "BOX(0 0,4 4)", - true); - test_geometry, bg::model::box

>( - "SEGMENT(1 1,1 1)", - "BOX(1 0,3 5)", - true); - test_geometry, bg::model::box

>( - "SEGMENT(0 1,0 1)", - "BOX(1 0,3 5)", - false); - test_geometry, bg::model::box

>( - "SEGMENT(2 1,2 1)", - "BOX(1 0,3 5)", - true); - test_geometry, bg::model::box

>( - "LINESTRING(0 0,1 0,10 10)", - "BOX(1 2,3 5)", - true); - test_geometry, bg::model::box

>( - "LINESTRING(1 2)", - "BOX(0 0,3 5)", - true); -} - - int test_main( int , char* [] ) { test_all >(); - test_additional >(); #if ! defined(BOOST_GEOMETRY_RESCALE_TO_ROBUST) test_all > >(); diff --git a/test/algorithms/relational_operations/intersects/intersects_box_geometry.cpp b/test/algorithms/relational_operations/intersects/intersects_box_geometry.cpp new file mode 100644 index 000000000..50a332436 --- /dev/null +++ b/test/algorithms/relational_operations/intersects/intersects_box_geometry.cpp @@ -0,0 +1,100 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2013-2015 Adam Wulkiewicz, Lodz, Poland. + +// This file was modified by Oracle on 2013, 2015. +// Modifications copyright (c) 2013-2015, Oracle and/or its affiliates. + +// 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 "test_intersects.hpp" + + +#include +#include + +#include + + +template +void test_all() +{ + typedef bg::model::polygon

polygon; + typedef bg::model::ring

ring; + + // intersect <=> ! disjoint (in most cases) + // so most tests are done in disjoint test. + // We only test compilation of a few cases. + test_geometry >("POINT(1 1)", "BOX(0 0,2 2)", true); + + test_geometry >( + "POLYGON((1992 3240,1992 1440,3792 1800,3792 3240,1992 3240))", + "BOX(1941 2066, 2055 2166)", true); + + test_geometry >( + "POLYGON((1992 3240,1992 1440,3792 1800,3792 3240,1992 3240))", + "BOX(1941 2066, 2055 2166)", true); + + test_geometry >( + "POLYGON((1941 2066,2055 2066,2055 2166,1941 2166))", + "BOX(1941 2066, 2055 2166)", true); + + test_geometry >( + "POINT(0 0)", + "BOX(0 0,4 4)", + true); +} + +// Those tests won't pass for rational<> because numeric_limits<> isn't specialized for this type +template +void test_additional() +{ + test_geometry, bg::model::box

>( + "SEGMENT(0 0,3 3)", + "BOX(1 2,3 5)", + true); + test_geometry, bg::model::box

>( + "SEGMENT(1 1,2 3)", + "BOX(0 0,4 4)", + true); + test_geometry, bg::model::box

>( + "SEGMENT(1 1,1 1)", + "BOX(1 0,3 5)", + true); + test_geometry, bg::model::box

>( + "SEGMENT(0 1,0 1)", + "BOX(1 0,3 5)", + false); + test_geometry, bg::model::box

>( + "SEGMENT(2 1,2 1)", + "BOX(1 0,3 5)", + true); + test_geometry, bg::model::box

>( + "LINESTRING(0 0,1 0,10 10)", + "BOX(1 2,3 5)", + true); + test_geometry, bg::model::box

>( + "LINESTRING(1 2)", + "BOX(0 0,3 5)", + true); +} + + +int test_main( int , char* [] ) +{ + test_all >(); + test_additional >(); + +#if ! defined(BOOST_GEOMETRY_RESCALE_TO_ROBUST) + test_all > >(); +#endif + +#if defined(HAVE_TTMATH) + test_all >(); +#endif + + return 0; +} diff --git a/test/algorithms/relational_operations/intersects_multi.cpp b/test/algorithms/relational_operations/intersects/intersects_multi.cpp similarity index 100% rename from test/algorithms/relational_operations/intersects_multi.cpp rename to test/algorithms/relational_operations/intersects/intersects_multi.cpp diff --git a/test/algorithms/relational_operations/intersects/intersects_self.cpp b/test/algorithms/relational_operations/intersects/intersects_self.cpp new file mode 100644 index 000000000..6d6c4172a --- /dev/null +++ b/test/algorithms/relational_operations/intersects/intersects_self.cpp @@ -0,0 +1,133 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2013-2015 Adam Wulkiewicz, Lodz, Poland. + +// This file was modified by Oracle on 2013, 2015. +// Modifications copyright (c) 2013-2015, Oracle and/or its affiliates. + +// 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 "test_intersects.hpp" + + +#include +#include + +#include + + +template +void test_all() +{ + typedef bg::model::linestring

linestring; + typedef bg::model::polygon

polygon; + typedef bg::model::ring

ring; + typedef bg::model::ring ring_open; + + // self-intersecting is not tested in disjoint, so that is done here. + + // Just a normal polygon + test_self_intersects("POLYGON((0 0,0 4,1.5 2.5,2.5 1.5,4 0,0 0))", false); + + // Self intersecting + test_self_intersects("POLYGON((1 2,1 1,2 1,2 2.25,3 2.25,3 0,0 0,0 3,3 3,2.75 2,1 2))", true); + + // Self intersecting in last segment + test_self_intersects("POLYGON((0 2,2 4,2 0,4 2,0 2))", true); + + // Self tangent + test_self_intersects("POLYGON((0 0,0 4,4 4,4 0,2 4,0 0))", true); + + // Self tangent in corner + test_self_intersects("POLYGON((0 0,0 4,4 4,4 0,0 4,2 0,0 0))", true); + + // With spike + test_self_intersects("POLYGON((0 0,0 4,4 4,4 2,6 2,4 2,4 0,0 0))", true); + + // Non intersection, but with duplicate + test_self_intersects("POLYGON((0 0,0 4,4 0,4 0,0 0))", false); + + // With many duplicates + test_self_intersects( + "POLYGON((0 0,0 1,0 1,0 1,0 2,0 2,0 3,0 3,0 3,0 3,0 4,2 4,2 4,4 4,4 0,4 0,3 0,3 0,3 0,3 0,3 0,0 0))", + false); + + // Hole: interior tangent to exterior + test_self_intersects("POLYGON((0 0,0 4,4 4,4 0,0 0),(1 2,2 4,3 2,1 2))", true); + + // Hole: interior intersecting exterior + test_self_intersects("POLYGON((0 0,0 4,4 4,4 0,0 0),(1 1,1 3,5 4,1 1))", true); + + // Hole: two intersecting holes + test_self_intersects( + "POLYGON((0 0,0 4,4 4,4 0,0 0),(1 1,1 3,3 3,3 1,1 1),(2 2,2 3.5,3.5 3.5,3.5 2,2 2))", true); + + // Mail Akira T on [Boost-users] at 27-7-2011 3:17 + test_self_intersects( + "LINESTRING(0 0,0 4,4 4,2 2,2 5)", true); + + test_self_intersects( + "LINESTRING(0 4,4 4,2 2,2 5)", true); + + // Test self-intersections at last segment in close/open rings: + test_self_intersects( + "POLYGON((0 0,3 3,4 1,0 0))", false); + + test_self_intersects( + "POLYGON((0 0,3 3,4 1))", false); + + test_self_intersects( + "POLYGON((0 0,3 3,4 1,0 1,0 0))", true); + + test_self_intersects( + "POLYGON((0 0,3 3,4 1,0 1))", true); + + // Duplicates in first or last + test_self_intersects( + "POLYGON((0 0,3 3,4 1,0 1,0 1,0 0))", true); + test_self_intersects( + "POLYGON((0 0,3 3,4 1,0 1,0 0,0 0))", true); + test_self_intersects( + "POLYGON((0 0,3 3,4 1,0 1,0 1))", true); + test_self_intersects( + "POLYGON((0 0,0 0,3 3,4 1,0 1,0 1,0 0))", true); + test_self_intersects( + "POLYGON((0 0,0 0,3 3,4 1,0 1,0 1))", true); + test_self_intersects( + "POLYGON((0 0,3 3,3 3,4 1,0 1,0 1,0 0))", true); + test_self_intersects( + "POLYGON((0 0,3 3,3 3,4 1,0 1,0 1))", true); + + test_self_intersects( + "POLYGON((0 0,3 3,4 1,0 0,0 0))", false); + test_self_intersects( + "POLYGON((0 0,3 3,4 1,4 1,0 0))", false); + test_self_intersects( + "POLYGON((0 0,3 3,4 1,4 1))", false); + test_self_intersects( + "POLYGON((0 0,0 0,3 3,4 1,0 0))", false); + test_self_intersects( + "POLYGON((0 0,0 0,3 3,4 1))", false); + test_self_intersects( + "POLYGON((0 0,3 3,3 3,4 1,0 0))", false); + test_self_intersects( + "POLYGON((0 0,3 3,3 3,4 1))", false); +} + +int test_main( int , char* [] ) +{ + test_all >(); + +#if ! defined(BOOST_GEOMETRY_RESCALE_TO_ROBUST) + test_all > >(); +#endif + +#if defined(HAVE_TTMATH) + test_all >(); +#endif + + return 0; +} diff --git a/test/algorithms/relational_operations/test_intersects.hpp b/test/algorithms/relational_operations/intersects/test_intersects.hpp similarity index 100% rename from test/algorithms/relational_operations/test_intersects.hpp rename to test/algorithms/relational_operations/intersects/test_intersects.hpp diff --git a/test/algorithms/relational_operations/overlaps/Jamfile.v2 b/test/algorithms/relational_operations/overlaps/Jamfile.v2 new file mode 100644 index 000000000..2f9410b62 --- /dev/null +++ b/test/algorithms/relational_operations/overlaps/Jamfile.v2 @@ -0,0 +1,23 @@ +# Boost.Geometry (aka GGL, Generic Geometry Library) +# +# Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. +# Copyright (c) 2008-2015 Bruno Lalande, Paris, France. +# Copyright (c) 2009-2015 Mateusz Loskot, London, UK. +# +# This file was modified by Oracle on 2014, 2015. +# Modifications copyright (c) 2014-2015, Oracle and/or its affiliates. +# +# Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle +# 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) + +test-suite boost-geometry-algorithms-relational-overlaps + : + [ run overlaps.cpp : : : : algorithms_overlaps ] + [ run overlaps_areal.cpp : : : : algorithms_overlaps_areal ] + [ run overlaps_box.cpp : : : : algorithms_overlaps_box ] + ; + diff --git a/test/algorithms/relational_operations/overlaps/overlaps.cpp b/test/algorithms/relational_operations/overlaps/overlaps.cpp new file mode 100644 index 000000000..c6407f756 --- /dev/null +++ b/test/algorithms/relational_operations/overlaps/overlaps.cpp @@ -0,0 +1,56 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. + +// This file was modified by Oracle on 2014, 2015. +// Modifications copyright (c) 2014-2015 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) + +#include "test_overlaps.hpp" + +template +void test_pp() +{ + typedef bg::model::multi_point

mpt; + + test_geometry("MULTIPOINT(0 0,1 1,2 2)", "MULTIPOINT(1 1,3 3,4 4)", true); + test_geometry("MULTIPOINT(0 0,1 1,2 2)", "MULTIPOINT(1 1,2 2)", false); +} + +template +void test_ll() +{ + typedef bg::model::linestring

ls; + typedef bg::model::multi_linestring mls; + + test_geometry("LINESTRING(0 0,2 2,3 1)", "LINESTRING(1 1,2 2,4 4)", true); + test_geometry("LINESTRING(0 0,2 2,4 0)", "LINESTRING(0 1,2 1,3 2)", false); + + test_geometry("LINESTRING(0 0,2 2,3 1)", "MULTILINESTRING((1 1,2 2),(2 2,4 4))", true); + test_geometry("LINESTRING(0 0,2 2,3 1)", "MULTILINESTRING((1 1,2 2),(3 3,4 4))", true); + test_geometry("LINESTRING(0 0,3 3,3 1)", "MULTILINESTRING((3 3,2 2),(0 0,1 1))", false); +} + +template +void test_2d() +{ + test_pp

(); + test_ll

(); +} + +int test_main( int , char* [] ) +{ + test_2d >(); + test_2d >(); + +#if defined(HAVE_TTMATH) + test_2d >(); +#endif + + return 0; +} diff --git a/test/algorithms/relational_operations/overlaps.cpp b/test/algorithms/relational_operations/overlaps/overlaps_areal.cpp similarity index 53% rename from test/algorithms/relational_operations/overlaps.cpp rename to test/algorithms/relational_operations/overlaps/overlaps_areal.cpp index 3d627af43..c41da0639 100644 --- a/test/algorithms/relational_operations/overlaps.cpp +++ b/test/algorithms/relational_operations/overlaps/overlaps_areal.cpp @@ -1,6 +1,6 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) -// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. // This file was modified by Oracle on 2014, 2015. // Modifications copyright (c) 2014-2015 Oracle and/or its affiliates. @@ -13,59 +13,6 @@ #include "test_overlaps.hpp" -template -void test_box_box_2d() -{ -#if defined(BOOST_GEOMETRY_COMPILE_FAIL) - test_geometry("POINT(1 1)", "POINT(1 1)", true); -#endif - - test_geometry, bg::model::box

>("BOX(1 1, 3 3)", "BOX(0 0,2 2)", true); - - // touch -> false - test_geometry, bg::model::box

>("BOX(1 1, 3 3)", "BOX(3 3,5 5)", false); - - // disjoint -> false - test_geometry, bg::model::box

>("BOX(1 1, 3 3)", "BOX(4 4,6 6)", false); - - // within -> false - test_geometry, bg::model::box

>("BOX(1 1, 5 5)", "BOX(2 2,3 3)", false); - - // within+touch -> false - test_geometry, bg::model::box

>("BOX(1 1, 5 5)", "BOX(2 2,5 5)", false); -} - -template -void test_3d() -{ - test_geometry, bg::model::box

>("BOX(1 1 1, 3 3 3)", "BOX(0 0 0,2 2 2)", true); - test_geometry, bg::model::box

>("BOX(1 1 1, 3 3 3)", "BOX(3 3 3,5 5 5)", false); - test_geometry, bg::model::box

>("BOX(1 1 1, 3 3 3)", "BOX(4 4 4,6 6 6)", false); -} - -template -void test_pp() -{ - typedef bg::model::multi_point

mpt; - - test_geometry("MULTIPOINT(0 0,1 1,2 2)", "MULTIPOINT(1 1,3 3,4 4)", true); - test_geometry("MULTIPOINT(0 0,1 1,2 2)", "MULTIPOINT(1 1,2 2)", false); -} - -template -void test_ll() -{ - typedef bg::model::linestring

ls; - typedef bg::model::multi_linestring mls; - - test_geometry("LINESTRING(0 0,2 2,3 1)", "LINESTRING(1 1,2 2,4 4)", true); - test_geometry("LINESTRING(0 0,2 2,4 0)", "LINESTRING(0 1,2 1,3 2)", false); - - test_geometry("LINESTRING(0 0,2 2,3 1)", "MULTILINESTRING((1 1,2 2),(2 2,4 4))", true); - test_geometry("LINESTRING(0 0,2 2,3 1)", "MULTILINESTRING((1 1,2 2),(3 3,4 4))", true); - test_geometry("LINESTRING(0 0,3 3,3 1)", "MULTILINESTRING((3 3,2 2),(0 0,1 1))", false); -} - template void test_aa() { @@ -102,11 +49,7 @@ void test_aa() template void test_2d() { - test_pp

(); - test_ll

(); test_aa

(); - - test_box_box_2d

(); } int test_main( int , char* [] ) @@ -118,7 +61,5 @@ int test_main( int , char* [] ) test_2d >(); #endif - //test_3d >(); - return 0; } diff --git a/test/algorithms/relational_operations/overlaps/overlaps_box.cpp b/test/algorithms/relational_operations/overlaps/overlaps_box.cpp new file mode 100644 index 000000000..c80ff6de4 --- /dev/null +++ b/test/algorithms/relational_operations/overlaps/overlaps_box.cpp @@ -0,0 +1,64 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. + +// This file was modified by Oracle on 2014, 2015. +// Modifications copyright (c) 2014-2015 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) + +#include "test_overlaps.hpp" + +template +void test_box_box_2d() +{ +#if defined(BOOST_GEOMETRY_COMPILE_FAIL) + test_geometry("POINT(1 1)", "POINT(1 1)", true); +#endif + + test_geometry, bg::model::box

>("BOX(1 1, 3 3)", "BOX(0 0,2 2)", true); + + // touch -> false + test_geometry, bg::model::box

>("BOX(1 1, 3 3)", "BOX(3 3,5 5)", false); + + // disjoint -> false + test_geometry, bg::model::box

>("BOX(1 1, 3 3)", "BOX(4 4,6 6)", false); + + // within -> false + test_geometry, bg::model::box

>("BOX(1 1, 5 5)", "BOX(2 2,3 3)", false); + + // within+touch -> false + test_geometry, bg::model::box

>("BOX(1 1, 5 5)", "BOX(2 2,5 5)", false); +} + +template +void test_3d() +{ + test_geometry, bg::model::box

>("BOX(1 1 1, 3 3 3)", "BOX(0 0 0,2 2 2)", true); + test_geometry, bg::model::box

>("BOX(1 1 1, 3 3 3)", "BOX(3 3 3,5 5 5)", false); + test_geometry, bg::model::box

>("BOX(1 1 1, 3 3 3)", "BOX(4 4 4,6 6 6)", false); +} + +template +void test_2d() +{ + test_box_box_2d

(); +} + +int test_main( int , char* [] ) +{ + test_2d >(); + test_2d >(); + +#if defined(HAVE_TTMATH) + test_2d >(); +#endif + + //test_3d >(); + + return 0; +} diff --git a/test/algorithms/relational_operations/test_overlaps.hpp b/test/algorithms/relational_operations/overlaps/test_overlaps.hpp similarity index 100% rename from test/algorithms/relational_operations/test_overlaps.hpp rename to test/algorithms/relational_operations/overlaps/test_overlaps.hpp diff --git a/test/algorithms/relational_operations/touches/Jamfile.v2 b/test/algorithms/relational_operations/touches/Jamfile.v2 new file mode 100644 index 000000000..b2d6afef8 --- /dev/null +++ b/test/algorithms/relational_operations/touches/Jamfile.v2 @@ -0,0 +1,23 @@ +# Boost.Geometry (aka GGL, Generic Geometry Library) +# +# Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. +# Copyright (c) 2008-2015 Bruno Lalande, Paris, France. +# Copyright (c) 2009-2015 Mateusz Loskot, London, UK. +# +# This file was modified by Oracle on 2014, 2015. +# Modifications copyright (c) 2014-2015, Oracle and/or its affiliates. +# +# Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle +# 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) + +test-suite boost-geometry-algorithms-relational-touches + : + [ run touches.cpp : : : : algorithms_touches ] + [ run touches_box.cpp : : : : algorithms_touches_box ] + [ run touches_multi.cpp : : : : algorithms_touches_multi ] + [ run touches_self.cpp : : : : algorithms_touches_self ] + ; diff --git a/test/algorithms/relational_operations/test_touches.hpp b/test/algorithms/relational_operations/touches/test_touches.hpp similarity index 100% rename from test/algorithms/relational_operations/test_touches.hpp rename to test/algorithms/relational_operations/touches/test_touches.hpp diff --git a/test/algorithms/relational_operations/touches.cpp b/test/algorithms/relational_operations/touches/touches.cpp similarity index 82% rename from test/algorithms/relational_operations/touches.cpp rename to test/algorithms/relational_operations/touches/touches.cpp index d7a92c8e0..88a0cc269 100644 --- a/test/algorithms/relational_operations/touches.cpp +++ b/test/algorithms/relational_operations/touches/touches.cpp @@ -1,40 +1,27 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // -// Copyright (c) 2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2012-2015 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2013, 2014. -// Modifications copyright (c) 2013, 2014, Oracle and/or its affiliates. +// This file was modified by Oracle on 2013, 2014. 2015. +// Modifications copyright (c) 2013-2015, 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) -// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle - #include "test_touches.hpp" template void test_all() { - typedef bg::model::box

box; typedef bg::model::ring

ring; typedef bg::model::polygon

polygon; typedef bg::model::linestring

linestring; typedef bg::model::multi_polygon mpolygon; typedef bg::model::multi_linestring mlinestring; - // Just a normal polygon - test_self_touches("POLYGON((0 0,0 4,1.5 2.5,2.5 1.5,4 0,0 0))", false); - - // Self intersecting - test_self_touches("POLYGON((1 2,1 1,2 1,2 2.25,3 2.25,3 0,0 0,0 3,3 3,2.75 2,1 2))", false); - - // Self touching at a point - test_self_touches("POLYGON((0 0,0 3,2 3,2 2,1 2,1 1,2 1,2 2,3 2,3 0,0 0))", true); - - // Self touching at a segment - test_self_touches("POLYGON((0 0,0 3,2 3,2 2,1 2,1 1,2 1,2 2.5,3 2.5,3 0,0 0))", true); - // Touching at corner test_touches ( @@ -196,35 +183,11 @@ void test_all() test_touches("LINESTRING(-1 -1,3 3)", "MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0),(0 0,9 1,9 9,1 9,0 0)))", true); test_touches("MULTILINESTRING((0 0,11 11))", "MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0),(0 0,9 1,9 9,1 9,0 0)))", false); - - test_touches("POLYGON((0 0,0 5,5 5,5 0,0 0))", "POLYGON((5 1,5 2,6 2,6 1,5 1))", true); - test_touches("POLYGON((0 0,0 5,5 5,5 0,0 0))", "POLYGON((4 1,4 2,5 2,5 1,4 1))", false); - test_touches("POLYGON((0 0,0 5,5 5,5 0,0 0))", "POLYGON((4 1,4 2,6 2,6 1,4 1))", false); - - // Point-size - test_touches("POLYGON((0 0,0 5,5 5,5 0,0 0))", "POLYGON((5 5,5 5,5 5,5 5,5 5))", true); - // TODO: should it be TRUE? - test_touches("POLYGON((5 5,5 5,5 5,5 5,5 5))", "POLYGON((5 5,5 5,5 5,5 5,5 5))", true); -} - -template -void test_box_3d() -{ - typedef bg::model::box

box; - - check_touches(box(P(0,0,0),P(5,5,5)), box(P(5,1,2),P(6,6,6)), - "box(P(0,0,0),P(5,5,5))", "box(P(5,1,2),P(6,6,6))", - true); - - check_touches(box(P(0,0,0),P(5,5,5)), box(P(5,5,5),P(6,6,6)), - "box(P(0,0,0),P(5,5,5))", "box(P(5,5,5),P(6,6,6))", - true); } int test_main( int , char* [] ) { test_all >(); - test_box_3d >(); #if defined(HAVE_TTMATH) test_all >(); diff --git a/test/algorithms/relational_operations/touches/touches_box.cpp b/test/algorithms/relational_operations/touches/touches_box.cpp new file mode 100644 index 000000000..4e8b932f1 --- /dev/null +++ b/test/algorithms/relational_operations/touches/touches_box.cpp @@ -0,0 +1,65 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// +// Copyright (c) 2012-2015 Barend Gehrels, Amsterdam, the Netherlands. + +// This file was modified by Oracle on 2013, 2014. 2015. +// Modifications copyright (c) 2013-2015, 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) + +#include "test_touches.hpp" + +template +void test_all() +{ + typedef bg::model::box

box; + + test_touches("POLYGON((0 0,0 5,5 5,5 0,0 0))", "POLYGON((5 1,5 2,6 2,6 1,5 1))", true); + test_touches("POLYGON((0 0,0 5,5 5,5 0,0 0))", "POLYGON((4 1,4 2,5 2,5 1,4 1))", false); + test_touches("POLYGON((0 0,0 5,5 5,5 0,0 0))", "POLYGON((4 1,4 2,6 2,6 1,4 1))", false); + + // Point-size + test_touches("POLYGON((0 0,0 5,5 5,5 0,0 0))", "POLYGON((5 5,5 5,5 5,5 5,5 5))", true); + // TODO: should it be TRUE? + test_touches("POLYGON((5 5,5 5,5 5,5 5,5 5))", "POLYGON((5 5,5 5,5 5,5 5,5 5))", true); +} + +template +void test_box_3d() +{ + typedef bg::model::box

box; + + check_touches(box(P(0,0,0),P(5,5,5)), box(P(5,1,2),P(6,6,6)), + "box(P(0,0,0),P(5,5,5))", "box(P(5,1,2),P(6,6,6))", + true); + + check_touches(box(P(0,0,0),P(5,5,5)), box(P(5,5,5),P(6,6,6)), + "box(P(0,0,0),P(5,5,5))", "box(P(5,5,5),P(6,6,6))", + true); +} + +int test_main( int , char* [] ) +{ + test_all >(); + test_box_3d >(); + +#if defined(HAVE_TTMATH) + test_all >(); +#endif + + return 0; +} + +/* +with viewy as +( +select geometry::STGeomFromText('POLYGON((0 0,0 100,100 100,100 0,0 0))',0) as p + , geometry::STGeomFromText('POLYGON((200 0,100 50,200 100,200 0))',0) as q +) +-- select p from viewy union all select q from viewy +select p.STTouches(q) from viewy +*/ diff --git a/test/algorithms/relational_operations/touches_multi.cpp b/test/algorithms/relational_operations/touches/touches_multi.cpp similarity index 100% rename from test/algorithms/relational_operations/touches_multi.cpp rename to test/algorithms/relational_operations/touches/touches_multi.cpp diff --git a/test/algorithms/relational_operations/touches/touches_self.cpp b/test/algorithms/relational_operations/touches/touches_self.cpp new file mode 100644 index 000000000..00ea47daa --- /dev/null +++ b/test/algorithms/relational_operations/touches/touches_self.cpp @@ -0,0 +1,43 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// +// Copyright (c) 2012-2015 Barend Gehrels, Amsterdam, the Netherlands. + +// This file was modified by Oracle on 2013, 2014. 2015. +// Modifications copyright (c) 2013-2015, 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) + +#include "test_touches.hpp" + +template +void test_all() +{ + typedef bg::model::polygon

polygon; + + // Just a normal polygon + test_self_touches("POLYGON((0 0,0 4,1.5 2.5,2.5 1.5,4 0,0 0))", false); + + // Self intersecting + test_self_touches("POLYGON((1 2,1 1,2 1,2 2.25,3 2.25,3 0,0 0,0 3,3 3,2.75 2,1 2))", false); + + // Self touching at a point + test_self_touches("POLYGON((0 0,0 3,2 3,2 2,1 2,1 1,2 1,2 2,3 2,3 0,0 0))", true); + + // Self touching at a segment + test_self_touches("POLYGON((0 0,0 3,2 3,2 2,1 2,1 1,2 1,2 2.5,3 2.5,3 0,0 0))", true); +} + +int test_main( int , char* [] ) +{ + test_all >(); + +#if defined(HAVE_TTMATH) + test_all >(); +#endif + + return 0; +} diff --git a/test/iterators/point_iterator.cpp b/test/iterators/point_iterator.cpp index 3fa888212..7eaee6af0 100644 --- a/test/iterators/point_iterator.cpp +++ b/test/iterators/point_iterator.cpp @@ -742,6 +742,7 @@ BOOST_AUTO_TEST_CASE( test_multipoint_of_point_pointers ) { delete multipoint[i]; } + delete zero; } @@ -783,6 +784,7 @@ BOOST_AUTO_TEST_CASE( test_linestring_of_point_pointers ) { delete linestring[i]; } + delete zero; }