mirror of
https://github.com/boostorg/geometry.git
synced 2026-02-02 08:52:10 +00:00
Merge branch 'develop' of github.com:boostorg/geometry into develop
This commit is contained in:
10
README.md
10
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** | [](https://circleci.com/gh/awulkiew/geometry/tree/master) | [](https://coveralls.io/r/awulkiew/geometry?branch=master) | [](http://www.boost.org/development/tests/master/developer/geometry.html) [](http://www.boost.org/development/tests/master/developer/geometry-index.html)
|
||||
**develop** | [](https://circleci.com/gh/awulkiew/geometry/tree/develop) | [](https://coveralls.io/r/awulkiew/geometry?branch=develop) | [](http://www.boost.org/development/tests/develop/developer/geometry.html) [](http://www.boost.org/development/tests/develop/developer/geometry-index.html) [](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)
|
||||
|
||||
|
||||
174
circle.yml
Normal file
174
circle.yml
Normal file
@@ -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
|
||||
@@ -28,6 +28,7 @@
|
||||
|
||||
#include <boost/geometry/algorithms/envelope.hpp>
|
||||
#include <boost/geometry/algorithms/expand.hpp>
|
||||
#include <boost/geometry/algorithms/is_empty.hpp>
|
||||
#include <boost/geometry/algorithms/detail/recalculate.hpp>
|
||||
#include <boost/geometry/algorithms/detail/get_max_size.hpp>
|
||||
#include <boost/geometry/policies/robustness/robust_type.hpp>
|
||||
@@ -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<Point> env = geometry::return_envelope<model::box<Point> >(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<Point> env = geometry::return_envelope<model::box<Point> >(geometry1);
|
||||
model::box<Point> env2 = geometry::return_envelope<model::box<Point> >(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<Point> 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<Point> env2 = geometry::return_envelope
|
||||
<
|
||||
model::box<Point>
|
||||
>(geometry2);
|
||||
geometry::expand(env, env2);
|
||||
}
|
||||
|
||||
scale_box_to_integer_range(env, min_point, min_robust_point, factor);
|
||||
}
|
||||
|
||||
@@ -998,15 +998,11 @@ BOOST_AUTO_TEST_CASE( envelope_linestring )
|
||||
from_wkt<G>("LINESTRING(10 10,20 20,10 30)"),
|
||||
10, 10, 20, 30);
|
||||
|
||||
// linestring that circles most of the globe
|
||||
tester::apply("l03",
|
||||
from_wkt<G>("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<G>("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<double>::epsilon());
|
||||
|
||||
// linestring that crosses the antimeridian but staying close to it
|
||||
tester::apply("l04",
|
||||
|
||||
@@ -616,7 +616,8 @@ BOOST_AUTO_TEST_CASE( expand_segment )
|
||||
tester::apply("s03",
|
||||
from_wkt<B>("BOX(5 5,50 10)"),
|
||||
from_wkt<G>("SEGMENT(40 10,10 10)"),
|
||||
5, 5, 50, 10.34527004614999);
|
||||
5, 5, 50, 10.34527004614999,
|
||||
4.0 * std::numeric_limits<double>::epsilon());
|
||||
|
||||
// segment ending at the north pole
|
||||
tester::apply("s04",
|
||||
|
||||
@@ -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 ;
|
||||
|
||||
@@ -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 ]
|
||||
;
|
||||
|
||||
@@ -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 <typename P>
|
||||
void test_all()
|
||||
{
|
||||
typedef bg::model::box<P> box;
|
||||
|
||||
test_disjoint<P, P>("pp1", "point(1 1)", "point(1 1)", false);
|
||||
test_disjoint<P, P>("pp2", "point(1 1)", "point(1.001 1)", true);
|
||||
|
||||
// left-right
|
||||
test_disjoint<box, box>("bb1", "box(1 1, 2 2)", "box(3 1, 4 2)", true);
|
||||
test_disjoint<box, box>("bb2", "box(1 1, 2 2)", "box(2 1, 3 2)", false);
|
||||
test_disjoint<box, box>("bb3", "box(1 1, 2 2)", "box(2 2, 3 3)", false);
|
||||
test_disjoint<box, box>("bb4", "box(1 1, 2 2)", "box(2.001 2, 3 3)", true);
|
||||
|
||||
// up-down
|
||||
test_disjoint<box, box>("bb5", "box(1 1, 2 2)", "box(1 3, 2 4)", true);
|
||||
test_disjoint<box, box>("bb6", "box(1 1, 2 2)", "box(1 2, 2 3)", false);
|
||||
// right-left
|
||||
test_disjoint<box, box>("bb7", "box(1 1, 2 2)", "box(0 1, 1 2)", false);
|
||||
test_disjoint<box, box>("bb8", "box(1 1, 2 2)", "box(0 1, 1 2)", false);
|
||||
|
||||
// point-box
|
||||
test_disjoint<P, box>("pb1", "point(1 1)", "box(0 0, 2 2)", false);
|
||||
test_disjoint<P, box>("pb2", "point(2 2)", "box(0 0, 2 2)", false);
|
||||
test_disjoint<P, box>("pb3", "point(2.0001 2)", "box(1 1, 2 2)", true);
|
||||
test_disjoint<P, box>("pb4", "point(0.9999 2)", "box(1 1, 2 2)", true);
|
||||
|
||||
// box-point (to test reverse compiling)
|
||||
test_disjoint<box, P>("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<polygon, polygon>("touch_simplex_pp", touch_simplex[0], touch_simplex[1], false);
|
||||
|
||||
// Testing overlap (and test compiling with box)
|
||||
test_disjoint<polygon, polygon>("overlaps_box_pp", overlaps_box[0], overlaps_box[1], false);
|
||||
test_disjoint<box, polygon>("overlaps_box_bp", overlaps_box[0], overlaps_box[1], false);
|
||||
test_disjoint<box, ring>("overlaps_box_br", overlaps_box[0], overlaps_box[1], false);
|
||||
test_disjoint<polygon, box>("overlaps_box_pb", overlaps_box[1], overlaps_box[0], false);
|
||||
test_disjoint<ring, box>("overlaps_box_rb", overlaps_box[1], overlaps_box[0], false);
|
||||
|
||||
// Test if within(a,b) returns false for disjoint
|
||||
test_disjoint<ring, ring>("within_simplex_rr1", within_simplex[0], within_simplex[1], false);
|
||||
test_disjoint<ring, ring>("within_simplex_rr2", within_simplex[1], within_simplex[0], false);
|
||||
|
||||
test_disjoint<P, ring>("point_ring1", "POINT(0 0)", "POLYGON((0 0,3 3,6 0,0 0))", false);
|
||||
test_disjoint<P, ring>("point_ring2", "POINT(3 1)", "POLYGON((0 0,3 3,6 0,0 0))", false);
|
||||
test_disjoint<P, ring>("point_ring3", "POINT(0 3)", "POLYGON((0 0,3 3,6 0,0 0))", true);
|
||||
test_disjoint<P, polygon>("point_polygon1", "POINT(0 0)", "POLYGON((0 0,3 3,6 0,0 0))", false);
|
||||
test_disjoint<P, polygon>("point_polygon2", "POINT(3 1)", "POLYGON((0 0,3 3,6 0,0 0))", false);
|
||||
test_disjoint<P, polygon>("point_polygon3", "POINT(0 3)", "POLYGON((0 0,3 3,6 0,0 0))", true);
|
||||
|
||||
test_disjoint<ring, P>("point_ring2", "POLYGON((0 0,3 3,6 0,0 0))", "POINT(0 0)", false);
|
||||
test_disjoint<polygon, P>("point_polygon2", "POLYGON((0 0,3 3,6 0,0 0))", "POINT(0 0)", false);
|
||||
|
||||
// Linear
|
||||
typedef bg::model::linestring<P> ls;
|
||||
typedef bg::model::segment<P> segment;
|
||||
@@ -116,15 +77,6 @@ void test_all()
|
||||
test_disjoint<ls, ls>("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<polygon, box>("volker_albert_1",
|
||||
"POLYGON((1992 3240,1992 1440,3792 1800,3792 3240,1992 3240))",
|
||||
"BOX(1941 2066, 2055 2166)", false);
|
||||
|
||||
test_disjoint<polygon, box>("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 <typename P>
|
||||
void test_3d()
|
||||
{
|
||||
typedef bg::model::box<P> box;
|
||||
|
||||
test_disjoint<P, P>("pp 3d 1", "point(1 1 1)", "point(1 1 1)", false);
|
||||
test_disjoint<P, P>("pp 3d 2", "point(1 1 1)", "point(1.001 1 1)", true);
|
||||
|
||||
test_disjoint<box, box>("bb1", "box(1 1 1, 2 2 2)", "box(3 1 1, 4 2 1)", true);
|
||||
test_disjoint<box, box>("bb2", "box(1 1 1, 2 2 2)", "box(2 1 1, 3 2 1)", false);
|
||||
test_disjoint<box, box>("bb3", "box(1 1 1, 2 2 2)", "box(2 2 1, 3 3 1)", false);
|
||||
test_disjoint<box, box>("bb4", "box(1 1 1, 2 2 2)", "box(2.001 2 1, 3 3 1)", true);
|
||||
|
||||
}
|
||||
|
||||
int test_main(int, char* [])
|
||||
{
|
||||
test_all<bg::model::d2::point_xy<float> >();
|
||||
@@ -223,8 +160,6 @@ int test_main(int, char* [])
|
||||
test_all<bg::model::d2::point_xy<ttmath_big> >();
|
||||
#endif
|
||||
|
||||
test_3d<bg::model::point<double, 3, bg::cs::cartesian> >();
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -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 <iostream>
|
||||
|
||||
#include <boost/test/included/unit_test.hpp>
|
||||
|
||||
#include <boost/geometry/core/tag.hpp>
|
||||
#include <boost/geometry/core/tags.hpp>
|
||||
|
||||
#include <boost/geometry/strategies/strategies.hpp>
|
||||
|
||||
#include <boost/geometry/io/wkt/wkt.hpp>
|
||||
#include <boost/geometry/io/dsv/write.hpp>
|
||||
|
||||
#include <boost/geometry/geometries/geometries.hpp>
|
||||
|
||||
#include <boost/geometry/algorithms/disjoint.hpp>
|
||||
|
||||
#include <from_wkt.hpp>
|
||||
|
||||
|
||||
#ifdef HAVE_TTMATH
|
||||
#include <boost/geometry/extensions/contrib/ttmath_stub.hpp>
|
||||
#endif
|
||||
|
||||
namespace bg = ::boost::geometry;
|
||||
|
||||
//============================================================================
|
||||
|
||||
struct test_disjoint
|
||||
{
|
||||
template <typename Geometry1, typename Geometry2>
|
||||
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 <typename P>
|
||||
inline void test_box_box()
|
||||
{
|
||||
typedef bg::model::box<P> B;
|
||||
|
||||
typedef test_disjoint tester;
|
||||
|
||||
tester::apply("b-b-01",
|
||||
from_wkt<B>("BOX(2 2,3 3)"),
|
||||
from_wkt<B>("BOX(0 0,2 2)"),
|
||||
false);
|
||||
|
||||
tester::apply("b-b-02",
|
||||
from_wkt<B>("BOX(1 1,3 3)"),
|
||||
from_wkt<B>("BOX(0 0,2 2)"),
|
||||
false);
|
||||
|
||||
tester::apply("b-b-03",
|
||||
from_wkt<B>("BOX(3 3,4 4)"),
|
||||
from_wkt<B>("BOX(0 0,2 2)"),
|
||||
true);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
inline void test_ring_box()
|
||||
{
|
||||
typedef bg::model::box<P> B;
|
||||
typedef bg::model::ring<P, false, false> R; // ccw, open
|
||||
|
||||
typedef test_disjoint tester;
|
||||
|
||||
tester::apply("r-b-01",
|
||||
from_wkt<B>("BOX(2 2,3 3)"),
|
||||
from_wkt<R>("POLYGON((0 0,2 0,2 2,0 2))"),
|
||||
false);
|
||||
|
||||
tester::apply("r-b-02",
|
||||
from_wkt<B>("BOX(1 1,3 3)"),
|
||||
from_wkt<R>("POLYGON((0 0,2 0,2 2,0 2))"),
|
||||
false);
|
||||
|
||||
tester::apply("r-b-03",
|
||||
from_wkt<B>("BOX(3 3,4 4)"),
|
||||
from_wkt<R>("POLYGON((0 0,2 0,2 2,0 2))"),
|
||||
true);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
inline void test_polygon_box()
|
||||
{
|
||||
typedef bg::model::box<P> B;
|
||||
typedef bg::model::polygon<P, false, false> PL; // ccw, open
|
||||
|
||||
typedef test_disjoint tester;
|
||||
|
||||
tester::apply("pg-b-01",
|
||||
from_wkt<B>("BOX(2 2,3 3)"),
|
||||
from_wkt<PL>("POLYGON((0 0,2 0,2 2,0 2))"),
|
||||
false);
|
||||
|
||||
tester::apply("pg-b-02",
|
||||
from_wkt<B>("BOX(1 1,3 3)"),
|
||||
from_wkt<PL>("POLYGON((0 0,2 0,2 2,0 2))"),
|
||||
false);
|
||||
|
||||
tester::apply("pg-b-03",
|
||||
from_wkt<B>("BOX(3 3,4 4)"),
|
||||
from_wkt<PL>("POLYGON((0 0,2 0,2 2,0 2))"),
|
||||
true);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
inline void test_multipolygon_box()
|
||||
{
|
||||
typedef bg::model::box<P> B;
|
||||
typedef bg::model::polygon<P, false, false> PL; // ccw, open
|
||||
typedef bg::model::multi_polygon<PL> MPL;
|
||||
|
||||
typedef test_disjoint tester;
|
||||
|
||||
tester::apply("mpg-b-01",
|
||||
from_wkt<B>("BOX(2 2,3 3)"),
|
||||
from_wkt<MPL>("MULTIPOLYGON(((0 0,2 0,2 2,0 2)))"),
|
||||
false);
|
||||
|
||||
tester::apply("mpg-b-02",
|
||||
from_wkt<B>("BOX(1 1,3 3)"),
|
||||
from_wkt<MPL>("MULTIPOLYGON(((0 0,2 0,2 2,0 2)))"),
|
||||
false);
|
||||
|
||||
tester::apply("mpg-b-03",
|
||||
from_wkt<B>("BOX(3 3,4 4)"),
|
||||
from_wkt<MPL>("MULTIPOLYGON(((0 0,2 0,2 2,0 2)))"),
|
||||
true);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
inline void test_ring_ring()
|
||||
{
|
||||
typedef bg::model::ring<P, false, false> R; // ccw, open
|
||||
|
||||
typedef test_disjoint tester;
|
||||
|
||||
tester::apply("r-r-01",
|
||||
from_wkt<R>("POLYGON((2 2,2 3,3 3,3 2))"),
|
||||
from_wkt<R>("POLYGON((0 0,2 0,2 2,0 2))"),
|
||||
false);
|
||||
|
||||
tester::apply("r-r-02",
|
||||
from_wkt<R>("POLYGON((1 1,1 3,3 3,3 1))"),
|
||||
from_wkt<R>("POLYGON((0 0,2 0,2 2,0 2))"),
|
||||
false);
|
||||
|
||||
tester::apply("r-r-03",
|
||||
from_wkt<R>("POLYGON((3 3,3 4,4 4,4 3))"),
|
||||
from_wkt<R>("POLYGON((0 0,2 0,2 2,0 2))"),
|
||||
true);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
inline void test_polygon_ring()
|
||||
{
|
||||
typedef bg::model::ring<P, false, false> R; // ccw, open
|
||||
typedef bg::model::polygon<P, false, false> PL; // ccw, open
|
||||
|
||||
typedef test_disjoint tester;
|
||||
|
||||
tester::apply("pg-r-01",
|
||||
from_wkt<R>("POLYGON((2 2,2 3,3 3,3 2))"),
|
||||
from_wkt<PL>("POLYGON((0 0,2 0,2 2,0 2))"),
|
||||
false);
|
||||
|
||||
tester::apply("pg-r-02",
|
||||
from_wkt<R>("POLYGON((1 1,1 3,3 3,3 1))"),
|
||||
from_wkt<PL>("POLYGON((0 0,2 0,2 2,0 2))"),
|
||||
false);
|
||||
|
||||
tester::apply("pg-r-03",
|
||||
from_wkt<R>("POLYGON((3 3,3 4,4 4,4 3))"),
|
||||
from_wkt<PL>("POLYGON((0 0,2 0,2 2,0 2))"),
|
||||
true);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
inline void test_multipolygon_ring()
|
||||
{
|
||||
typedef bg::model::ring<P, false, false> R; // ccw, open
|
||||
typedef bg::model::polygon<P, false, false> PL; // ccw, open
|
||||
typedef bg::model::multi_polygon<PL> MPL;
|
||||
|
||||
typedef test_disjoint tester;
|
||||
|
||||
tester::apply("mpg-r-01",
|
||||
from_wkt<R>("POLYGON((2 2,2 3,3 3,3 2))"),
|
||||
from_wkt<MPL>("MULTIPOLYGON(((0 0,2 0,2 2,0 2)))"),
|
||||
false);
|
||||
|
||||
tester::apply("mpg-r-02",
|
||||
from_wkt<R>("POLYGON((1 1,1 3,3 3,3 1))"),
|
||||
from_wkt<MPL>("MULTIPOLYGON(((0 0,2 0,2 2,0 2)))"),
|
||||
false);
|
||||
|
||||
tester::apply("mpg-r-03",
|
||||
from_wkt<R>("POLYGON((3 3,3 4,4 4,4 3))"),
|
||||
from_wkt<MPL>("MULTIPOLYGON(((0 0,2 0,2 2,0 2)))"),
|
||||
true);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
inline void test_polygon_polygon()
|
||||
{
|
||||
typedef bg::model::polygon<P, false, false> PL; // ccw, open
|
||||
|
||||
typedef test_disjoint tester;
|
||||
|
||||
tester::apply("pg-pg-01",
|
||||
from_wkt<PL>("POLYGON((2 2,2 3,3 3,3 2))"),
|
||||
from_wkt<PL>("POLYGON((0 0,2 0,2 2,0 2))"),
|
||||
false);
|
||||
|
||||
tester::apply("pg-pg-02",
|
||||
from_wkt<PL>("POLYGON((1 1,1 3,3 3,3 1))"),
|
||||
from_wkt<PL>("POLYGON((0 0,2 0,2 2,0 2))"),
|
||||
false);
|
||||
|
||||
tester::apply("pg-pg-03",
|
||||
from_wkt<PL>("POLYGON((3 3,3 4,4 4,4 3))"),
|
||||
from_wkt<PL>("POLYGON((0 0,2 0,2 2,0 2))"),
|
||||
true);
|
||||
|
||||
tester::apply("pg-pg-04",
|
||||
from_wkt<PL>("POLYGON((0 0,9 0,9 9,0 9))"),
|
||||
from_wkt<PL>("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<PL>("POLYGON((0 0,9 0,9 9,0 9),(2 2,2 7,7 7,7 2))"),
|
||||
from_wkt<PL>("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<PL>("POLYGON((0 0,9 0,9 9,0 9),(3 2,3 7,7 7,7 2))"),
|
||||
from_wkt<PL>("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<PL>("POLYGON((0 0,9 0,9 9,0 9),(6 2,6 7,7 7,7 2))"),
|
||||
from_wkt<PL>("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<PL>("POLYGON((0 0,9 0,9 9,0 9),(3 3,3 6,6 6,6 3))"),
|
||||
from_wkt<PL>("POLYGON((2 2,7 2,7 7,2 7))"),
|
||||
false);
|
||||
|
||||
{
|
||||
typedef bg::model::polygon<P> PL; // cw, closed
|
||||
|
||||
// https://svn.boost.org/trac/boost/ticket/10647
|
||||
tester::apply("ticket-10647",
|
||||
from_wkt<PL>("POLYGON((0 0, 0 5, 5 5, 5 0, 0 0)(1 1, 4 1, 4 4, 1 4, 1 1))"),
|
||||
from_wkt<PL>("POLYGON((2 2, 2 3, 3 3, 3 2, 2 2))"),
|
||||
true);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
inline void test_polygon_multipolygon()
|
||||
{
|
||||
typedef bg::model::polygon<P, false, false> PL; // ccw, open
|
||||
typedef bg::model::multi_polygon<PL> MPL;
|
||||
|
||||
typedef test_disjoint tester;
|
||||
|
||||
tester::apply("pg-mpg-01",
|
||||
from_wkt<PL>("POLYGON((2 2,2 3,3 3,3 2))"),
|
||||
from_wkt<MPL>("MULTIPOLYGON(((0 0,2 0,2 2,0 2)))"),
|
||||
false);
|
||||
|
||||
tester::apply("pg-mpg-02",
|
||||
from_wkt<PL>("POLYGON((1 1,1 3,3 3,3 1))"),
|
||||
from_wkt<MPL>("MULTIPOLYGON(((0 0,2 0,2 2,0 2)))"),
|
||||
false);
|
||||
|
||||
tester::apply("pg-mpg-03",
|
||||
from_wkt<PL>("POLYGON((3 3,3 4,4 4,4 3))"),
|
||||
from_wkt<MPL>("MULTIPOLYGON(((0 0,2 0,2 2,0 2)))"),
|
||||
true);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
inline void test_multipolygon_multipolygon()
|
||||
{
|
||||
typedef bg::model::polygon<P, false, false> PL; // ccw, open
|
||||
typedef bg::model::multi_polygon<PL> MPL;
|
||||
|
||||
typedef test_disjoint tester;
|
||||
|
||||
tester::apply("mpg-mpg-01",
|
||||
from_wkt<MPL>("MULTIPOLYGON(((2 2,2 3,3 3,3 2)))"),
|
||||
from_wkt<MPL>("MULTIPOLYGON(((0 0,2 0,2 2,0 2)))"),
|
||||
false);
|
||||
|
||||
tester::apply("mpg-mpg-02",
|
||||
from_wkt<MPL>("MULTIPOLYGON(((1 1,1 3,3 3,3 1)))"),
|
||||
from_wkt<MPL>("MULTIPOLYGON(((0 0,2 0,2 2,0 2)))"),
|
||||
false);
|
||||
|
||||
tester::apply("mpg-mpg-03",
|
||||
from_wkt<MPL>("MULTIPOLYGON(((3 3,3 4,4 4,4 3)))"),
|
||||
from_wkt<MPL>("MULTIPOLYGON(((0 0,2 0,2 2,0 2)))"),
|
||||
true);
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
|
||||
template <typename CoordinateType>
|
||||
inline void test_areal_areal()
|
||||
{
|
||||
typedef bg::model::point<CoordinateType, 2, bg::cs::cartesian> point_type;
|
||||
|
||||
test_polygon_polygon<point_type>();
|
||||
test_polygon_multipolygon<point_type>();
|
||||
test_polygon_ring<point_type>();
|
||||
test_polygon_box<point_type>();
|
||||
|
||||
test_multipolygon_multipolygon<point_type>();
|
||||
test_multipolygon_ring<point_type>();
|
||||
test_multipolygon_box<point_type>();
|
||||
|
||||
test_ring_ring<point_type>();
|
||||
test_ring_box<point_type>();
|
||||
|
||||
test_box_box<point_type>();
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
|
||||
BOOST_AUTO_TEST_CASE( test_areal_areal_all )
|
||||
{
|
||||
test_areal_areal<double>();
|
||||
test_areal_areal<int>();
|
||||
#ifdef HAVE_TTMATH
|
||||
test_areal_areal<ttmath_big>();
|
||||
#endif
|
||||
}
|
||||
@@ -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 <iostream>
|
||||
|
||||
#include <boost/test/included/unit_test.hpp>
|
||||
|
||||
#include <boost/geometry/core/tag.hpp>
|
||||
#include <boost/geometry/core/tags.hpp>
|
||||
|
||||
#include <boost/geometry/strategies/strategies.hpp>
|
||||
|
||||
#include <boost/geometry/io/wkt/wkt.hpp>
|
||||
#include <boost/geometry/io/dsv/write.hpp>
|
||||
|
||||
#include <boost/geometry/geometries/geometries.hpp>
|
||||
|
||||
#include <boost/geometry/algorithms/disjoint.hpp>
|
||||
|
||||
#include <from_wkt.hpp>
|
||||
|
||||
|
||||
#ifdef HAVE_TTMATH
|
||||
#include <boost/geometry/extensions/contrib/ttmath_stub.hpp>
|
||||
#endif
|
||||
|
||||
namespace bg = ::boost::geometry;
|
||||
|
||||
//============================================================================
|
||||
|
||||
struct test_disjoint
|
||||
{
|
||||
template <typename Geometry1, typename Geometry2>
|
||||
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 <typename P>
|
||||
inline void test_segment_box()
|
||||
{
|
||||
typedef bg::model::segment<P> S;
|
||||
typedef bg::model::box<P> B;
|
||||
|
||||
typedef test_disjoint tester;
|
||||
|
||||
tester::apply("s-b-01",
|
||||
from_wkt<S>("SEGMENT(0 0,2 0)"),
|
||||
from_wkt<B>("BOX(0 0,2 2)"),
|
||||
false);
|
||||
|
||||
tester::apply("s-b-02",
|
||||
from_wkt<S>("SEGMENT(1 1,3 3)"),
|
||||
from_wkt<B>("BOX(0 0,2 2)"),
|
||||
false);
|
||||
|
||||
tester::apply("s-b-03",
|
||||
from_wkt<S>("SEGMENT(2 2,3 3)"),
|
||||
from_wkt<B>("BOX(0 0,2 2)"),
|
||||
false);
|
||||
|
||||
tester::apply("s-b-04",
|
||||
from_wkt<S>("SEGMENT(4 4,3 3)"),
|
||||
from_wkt<B>("BOX(0 0,2 2)"),
|
||||
true);
|
||||
|
||||
tester::apply("s-b-05",
|
||||
from_wkt<S>("SEGMENT(0 4,4 4)"),
|
||||
from_wkt<B>("BOX(0 0,2 2)"),
|
||||
true);
|
||||
|
||||
tester::apply("s-b-06",
|
||||
from_wkt<S>("SEGMENT(4 0,4 4)"),
|
||||
from_wkt<B>("BOX(0 0,2 2)"),
|
||||
true);
|
||||
|
||||
tester::apply("s-b-07",
|
||||
from_wkt<S>("SEGMENT(0 -2,0 -1)"),
|
||||
from_wkt<B>("BOX(0 0,1 1)"),
|
||||
true);
|
||||
|
||||
tester::apply("s-b-08",
|
||||
from_wkt<S>("SEGMENT(-2 -2,-2 -1)"),
|
||||
from_wkt<B>("BOX(0 0,1 1)"),
|
||||
true);
|
||||
|
||||
tester::apply("s-b-09",
|
||||
from_wkt<S>("SEGMENT(-2 -2,-2 -2)"),
|
||||
from_wkt<B>("BOX(0 0,1 1)"),
|
||||
true);
|
||||
|
||||
tester::apply("s-b-10",
|
||||
from_wkt<S>("SEGMENT(-2 0,-2 0)"),
|
||||
from_wkt<B>("BOX(0 0,1 1)"),
|
||||
true);
|
||||
|
||||
tester::apply("s-b-11",
|
||||
from_wkt<S>("SEGMENT(0 -2,0 -2)"),
|
||||
from_wkt<B>("BOX(0 0,1 1)"),
|
||||
true);
|
||||
|
||||
tester::apply("s-b-12",
|
||||
from_wkt<S>("SEGMENT(-2 0,-1 0)"),
|
||||
from_wkt<B>("BOX(0 0,1 1)"),
|
||||
true);
|
||||
|
||||
// segment degenerates to a point
|
||||
tester::apply("s-b-13",
|
||||
from_wkt<S>("SEGMENT(0 0,0 0)"),
|
||||
from_wkt<B>("BOX(0 0,1 1)"),
|
||||
false);
|
||||
|
||||
tester::apply("s-b-14",
|
||||
from_wkt<S>("SEGMENT(1 1,1 1)"),
|
||||
from_wkt<B>("BOX(0 0,2 2)"),
|
||||
false);
|
||||
|
||||
tester::apply("s-b-15",
|
||||
from_wkt<S>("SEGMENT(2 2,2 2)"),
|
||||
from_wkt<B>("BOX(0 0,2 2)"),
|
||||
false);
|
||||
|
||||
tester::apply("s-b-16",
|
||||
from_wkt<S>("SEGMENT(2 0,2 0)"),
|
||||
from_wkt<B>("BOX(0 0,2 2)"),
|
||||
false);
|
||||
|
||||
tester::apply("s-b-17",
|
||||
from_wkt<S>("SEGMENT(0 2,0 2)"),
|
||||
from_wkt<B>("BOX(0 0,2 2)"),
|
||||
false);
|
||||
|
||||
tester::apply("s-b-18",
|
||||
from_wkt<S>("SEGMENT(2 2,2 2)"),
|
||||
from_wkt<B>("BOX(0 0,1 1)"),
|
||||
true);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
inline void test_segment_ring()
|
||||
{
|
||||
typedef bg::model::segment<P> S;
|
||||
typedef bg::model::ring<P, false, false> R; // ccw, open
|
||||
|
||||
typedef test_disjoint tester;
|
||||
|
||||
tester::apply("s-r-01",
|
||||
from_wkt<S>("SEGMENT(0 0,2 0)"),
|
||||
from_wkt<R>("POLYGON((0 0,2 0,0 2))"),
|
||||
false);
|
||||
|
||||
tester::apply("s-r-02",
|
||||
from_wkt<S>("SEGMENT(1 0,3 3)"),
|
||||
from_wkt<R>("POLYGON((0 0,2 0,0 2))"),
|
||||
false);
|
||||
|
||||
tester::apply("s-r-03",
|
||||
from_wkt<S>("SEGMENT(1 1,3 3)"),
|
||||
from_wkt<R>("POLYGON((0 0,2 0,0 2))"),
|
||||
false);
|
||||
|
||||
tester::apply("s-r-04",
|
||||
from_wkt<S>("SEGMENT(2 2,3 3)"),
|
||||
from_wkt<R>("POLYGON((0 0,2 0,0 2))"),
|
||||
true);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
inline void test_segment_polygon()
|
||||
{
|
||||
typedef bg::model::segment<P> S;
|
||||
typedef bg::model::polygon<P, false, false> PL; // ccw, open
|
||||
|
||||
typedef test_disjoint tester;
|
||||
|
||||
tester::apply("s-pg-01",
|
||||
from_wkt<S>("SEGMENT(0 0,2 0)"),
|
||||
from_wkt<PL>("POLYGON((0 0,2 0,0 2))"),
|
||||
false);
|
||||
|
||||
tester::apply("s-pg-02",
|
||||
from_wkt<S>("SEGMENT(1 0,3 3)"),
|
||||
from_wkt<PL>("POLYGON((0 0,2 0,0 2))"),
|
||||
false);
|
||||
|
||||
tester::apply("s-pg-03",
|
||||
from_wkt<S>("SEGMENT(1 1,3 3)"),
|
||||
from_wkt<PL>("POLYGON((0 0,2 0,0 2))"),
|
||||
false);
|
||||
|
||||
tester::apply("s-pg-04",
|
||||
from_wkt<S>("SEGMENT(2 2,3 3)"),
|
||||
from_wkt<PL>("POLYGON((0 0,2 0,0 2))"),
|
||||
true);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
inline void test_segment_multipolygon()
|
||||
{
|
||||
typedef bg::model::segment<P> S;
|
||||
typedef bg::model::polygon<P, false, false> PL; // ccw, open
|
||||
typedef bg::model::multi_polygon<PL> MPL;
|
||||
|
||||
typedef test_disjoint tester;
|
||||
|
||||
tester::apply("s-mpg-01",
|
||||
from_wkt<S>("SEGMENT(0 0,2 0)"),
|
||||
from_wkt<MPL>("MULTIPOLYGON(((0 0,2 0,0 2)))"),
|
||||
false);
|
||||
|
||||
tester::apply("s-mpg-02",
|
||||
from_wkt<S>("SEGMENT(1 0,3 3)"),
|
||||
from_wkt<MPL>("MULTIPOLYGON(((0 0,2 0,0 2)))"),
|
||||
false);
|
||||
|
||||
tester::apply("s-mpg-03",
|
||||
from_wkt<S>("SEGMENT(1 1,3 3)"),
|
||||
from_wkt<MPL>("MULTIPOLYGON(((0 0,2 0,0 2)))"),
|
||||
false);
|
||||
|
||||
tester::apply("s-mpg-04",
|
||||
from_wkt<S>("SEGMENT(2 2,3 3)"),
|
||||
from_wkt<MPL>("MULTIPOLYGON(((0 0,2 0,0 2)))"),
|
||||
true);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
inline void test_linestring_box()
|
||||
{
|
||||
typedef bg::model::linestring<P> L;
|
||||
typedef bg::model::box<P> B;
|
||||
|
||||
typedef test_disjoint tester;
|
||||
|
||||
tester::apply("l-b-01",
|
||||
from_wkt<L>("LINESTRING(0 0,2 0)"),
|
||||
from_wkt<B>("BOX(0 0,2 2)"),
|
||||
false);
|
||||
|
||||
tester::apply("l-b-02",
|
||||
from_wkt<L>("LINESTRING(1 1,3 3)"),
|
||||
from_wkt<B>("BOX(0 0,2 2)"),
|
||||
false);
|
||||
|
||||
tester::apply("l-b-03",
|
||||
from_wkt<L>("LINESTRING(2 2,3 3)"),
|
||||
from_wkt<B>("BOX(0 0,2 2)"),
|
||||
false);
|
||||
|
||||
tester::apply("l-b-04",
|
||||
from_wkt<L>("LINESTRING(4 4,3 3)"),
|
||||
from_wkt<B>("BOX(0 0,2 2)"),
|
||||
true);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
inline void test_linestring_ring()
|
||||
{
|
||||
typedef bg::model::linestring<P> L;
|
||||
typedef bg::model::ring<P, false, false> R; // ccw, open
|
||||
|
||||
typedef test_disjoint tester;
|
||||
|
||||
tester::apply("l-r-01",
|
||||
from_wkt<L>("LINESTRING(0 0,2 0)"),
|
||||
from_wkt<R>("POLYGON((0 0,2 0,0 2))"),
|
||||
false);
|
||||
|
||||
tester::apply("l-r-02",
|
||||
from_wkt<L>("LINESTRING(1 0,3 3)"),
|
||||
from_wkt<R>("POLYGON((0 0,2 0,0 2))"),
|
||||
false);
|
||||
|
||||
tester::apply("l-r-03",
|
||||
from_wkt<L>("LINESTRING(1 1,3 3)"),
|
||||
from_wkt<R>("POLYGON((0 0,2 0,0 2))"),
|
||||
false);
|
||||
|
||||
tester::apply("l-r-04",
|
||||
from_wkt<L>("LINESTRING(2 2,3 3)"),
|
||||
from_wkt<R>("POLYGON((0 0,2 0,0 2))"),
|
||||
true);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
inline void test_linestring_polygon()
|
||||
{
|
||||
typedef bg::model::linestring<P> L;
|
||||
typedef bg::model::polygon<P, false, false> PL; // ccw, open
|
||||
|
||||
typedef test_disjoint tester;
|
||||
|
||||
tester::apply("l-pg-01",
|
||||
from_wkt<L>("LINESTRING(0 0,2 0)"),
|
||||
from_wkt<PL>("POLYGON((0 0,2 0,0 2))"),
|
||||
false);
|
||||
|
||||
tester::apply("l-pg-02",
|
||||
from_wkt<L>("LINESTRING(1 0,3 3)"),
|
||||
from_wkt<PL>("POLYGON((0 0,2 0,0 2))"),
|
||||
false);
|
||||
|
||||
tester::apply("l-pg-03",
|
||||
from_wkt<L>("LINESTRING(1 1,3 3)"),
|
||||
from_wkt<PL>("POLYGON((0 0,2 0,0 2))"),
|
||||
false);
|
||||
|
||||
tester::apply("l-pg-04",
|
||||
from_wkt<L>("LINESTRING(2 2,3 3)"),
|
||||
from_wkt<PL>("POLYGON((0 0,2 0,0 2))"),
|
||||
true);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
inline void test_linestring_multipolygon()
|
||||
{
|
||||
typedef bg::model::linestring<P> L;
|
||||
typedef bg::model::polygon<P, false, false> PL; // ccw, open
|
||||
typedef bg::model::multi_polygon<PL> MPL;
|
||||
|
||||
typedef test_disjoint tester;
|
||||
|
||||
tester::apply("l-mpg-01",
|
||||
from_wkt<L>("LINESTRING(0 0,2 0)"),
|
||||
from_wkt<MPL>("MULTIPOLYGON(((0 0,2 0,0 2)))"),
|
||||
false);
|
||||
|
||||
tester::apply("l-mpg-02",
|
||||
from_wkt<L>("LINESTRING(1 0,3 3)"),
|
||||
from_wkt<MPL>("MULTIPOLYGON(((0 0,2 0,0 2)))"),
|
||||
false);
|
||||
|
||||
tester::apply("l-mpg-03",
|
||||
from_wkt<L>("LINESTRING(1 1,3 3)"),
|
||||
from_wkt<MPL>("MULTIPOLYGON(((0 0,2 0,0 2)))"),
|
||||
false);
|
||||
|
||||
tester::apply("l-mpg-04",
|
||||
from_wkt<L>("LINESTRING(2 2,3 3)"),
|
||||
from_wkt<MPL>("MULTIPOLYGON(((0 0,2 0,0 2)))"),
|
||||
true);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
inline void test_multilinestring_box()
|
||||
{
|
||||
typedef bg::model::linestring<P> L;
|
||||
typedef bg::model::multi_linestring<L> ML;
|
||||
typedef bg::model::box<P> B;
|
||||
|
||||
typedef test_disjoint tester;
|
||||
|
||||
tester::apply("ml-b-01",
|
||||
from_wkt<ML>("MULTILINESTRING((0 0,2 0))"),
|
||||
from_wkt<B>("BOX(0 0,2 2)"),
|
||||
false);
|
||||
|
||||
tester::apply("ml-b-02",
|
||||
from_wkt<ML>("MULTILINESTRING((1 1,3 3))"),
|
||||
from_wkt<B>("BOX(0 0,2 2)"),
|
||||
false);
|
||||
|
||||
tester::apply("ml-b-03",
|
||||
from_wkt<ML>("MULTILINESTRING((2 2,3 3))"),
|
||||
from_wkt<B>("BOX(0 0,2 2)"),
|
||||
false);
|
||||
|
||||
tester::apply("ml-b-04",
|
||||
from_wkt<ML>("MULTILINESTRING((4 4,3 3))"),
|
||||
from_wkt<B>("BOX(0 0,2 2)"),
|
||||
true);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
inline void test_multilinestring_ring()
|
||||
{
|
||||
typedef bg::model::linestring<P> L;
|
||||
typedef bg::model::multi_linestring<L> ML;
|
||||
typedef bg::model::ring<P, false, false> R; // ccw, open
|
||||
|
||||
typedef test_disjoint tester;
|
||||
|
||||
tester::apply("ml-r-01",
|
||||
from_wkt<ML>("MULTILINESTRING((0 0,2 0))"),
|
||||
from_wkt<R>("POLYGON((0 0,2 0,0 2))"),
|
||||
false);
|
||||
|
||||
tester::apply("ml-r-02",
|
||||
from_wkt<ML>("MULTILINESTRING((1 0,3 3))"),
|
||||
from_wkt<R>("POLYGON((0 0,2 0,0 2))"),
|
||||
false);
|
||||
|
||||
tester::apply("ml-r-03",
|
||||
from_wkt<ML>("MULTILINESTRING((1 1,3 3))"),
|
||||
from_wkt<R>("POLYGON((0 0,2 0,0 2))"),
|
||||
false);
|
||||
|
||||
tester::apply("ml-r-04",
|
||||
from_wkt<ML>("MULTILINESTRING((2 2,3 3))"),
|
||||
from_wkt<R>("POLYGON((0 0,2 0,0 2))"),
|
||||
true);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
inline void test_multilinestring_polygon()
|
||||
{
|
||||
typedef bg::model::linestring<P> L;
|
||||
typedef bg::model::multi_linestring<L> ML;
|
||||
typedef bg::model::polygon<P, false, false> PL; // ccw, open
|
||||
|
||||
typedef test_disjoint tester;
|
||||
|
||||
tester::apply("ml-pg-01",
|
||||
from_wkt<ML>("MULTILINESTRING((0 0,2 0))"),
|
||||
from_wkt<PL>("POLYGON((0 0,2 0,0 2))"),
|
||||
false);
|
||||
|
||||
tester::apply("ml-pg-02",
|
||||
from_wkt<ML>("MULTILINESTRING((1 0,3 3))"),
|
||||
from_wkt<PL>("POLYGON((0 0,2 0,0 2))"),
|
||||
false);
|
||||
|
||||
tester::apply("ml-pg-03",
|
||||
from_wkt<ML>("MULTILINESTRING((1 1,3 3))"),
|
||||
from_wkt<PL>("POLYGON((0 0,2 0,0 2))"),
|
||||
false);
|
||||
|
||||
tester::apply("ml-pg-04",
|
||||
from_wkt<ML>("MULTILINESTRING((2 2,3 3))"),
|
||||
from_wkt<PL>("POLYGON((0 0,2 0,0 2))"),
|
||||
true);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
inline void test_multilinestring_multipolygon()
|
||||
{
|
||||
typedef bg::model::linestring<P> L;
|
||||
typedef bg::model::multi_linestring<L> ML;
|
||||
typedef bg::model::polygon<P, false, false> PL; // ccw, open
|
||||
typedef bg::model::multi_polygon<PL> MPL;
|
||||
|
||||
typedef test_disjoint tester;
|
||||
|
||||
tester::apply("ml-mpg-01",
|
||||
from_wkt<ML>("MULTILINESTRING((0 0,2 0))"),
|
||||
from_wkt<MPL>("MULTIPOLYGON(((0 0,2 0,0 2)))"),
|
||||
false);
|
||||
|
||||
tester::apply("ml-mpg-02",
|
||||
from_wkt<ML>("MULTILINESTRING((1 0,3 3))"),
|
||||
from_wkt<MPL>("MULTIPOLYGON(((0 0,2 0,0 2)))"),
|
||||
false);
|
||||
|
||||
tester::apply("ml-mpg-03",
|
||||
from_wkt<ML>("MULTILINESTRING((1 1,3 3))"),
|
||||
from_wkt<MPL>("MULTIPOLYGON(((0 0,2 0,0 2)))"),
|
||||
false);
|
||||
|
||||
tester::apply("ml-mpg-04",
|
||||
from_wkt<ML>("MULTILINESTRING((2 2,3 3))"),
|
||||
from_wkt<MPL>("MULTIPOLYGON(((0 0,2 0,0 2)))"),
|
||||
true);
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
|
||||
template <typename CoordinateType>
|
||||
inline void test_linear_areal()
|
||||
{
|
||||
typedef bg::model::point<CoordinateType, 2, bg::cs::cartesian> point_type;
|
||||
|
||||
test_segment_polygon<point_type>();
|
||||
test_segment_multipolygon<point_type>();
|
||||
test_segment_ring<point_type>();
|
||||
test_segment_box<point_type>();
|
||||
|
||||
test_linestring_polygon<point_type>();
|
||||
test_linestring_multipolygon<point_type>();
|
||||
test_linestring_ring<point_type>();
|
||||
test_linestring_box<point_type>();
|
||||
|
||||
test_multilinestring_polygon<point_type>();
|
||||
test_multilinestring_multipolygon<point_type>();
|
||||
test_multilinestring_ring<point_type>();
|
||||
test_multilinestring_box<point_type>();
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
|
||||
BOOST_AUTO_TEST_CASE( test_linear_areal_all )
|
||||
{
|
||||
test_linear_areal<double>();
|
||||
test_linear_areal<int>();
|
||||
#ifdef HAVE_TTMATH
|
||||
test_linear_areal<ttmath_big>();
|
||||
#endif
|
||||
}
|
||||
@@ -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 <iostream>
|
||||
|
||||
#include <boost/test/included/unit_test.hpp>
|
||||
|
||||
#include <boost/geometry/core/tag.hpp>
|
||||
#include <boost/geometry/core/tags.hpp>
|
||||
|
||||
#include <boost/geometry/strategies/strategies.hpp>
|
||||
|
||||
#include <boost/geometry/io/wkt/wkt.hpp>
|
||||
#include <boost/geometry/io/dsv/write.hpp>
|
||||
|
||||
#include <boost/geometry/geometries/geometries.hpp>
|
||||
|
||||
#include <boost/geometry/algorithms/disjoint.hpp>
|
||||
|
||||
#include <from_wkt.hpp>
|
||||
|
||||
|
||||
#ifdef HAVE_TTMATH
|
||||
#include <boost/geometry/extensions/contrib/ttmath_stub.hpp>
|
||||
#endif
|
||||
|
||||
namespace bg = ::boost::geometry;
|
||||
|
||||
//============================================================================
|
||||
|
||||
struct test_disjoint
|
||||
{
|
||||
template <typename Geometry1, typename Geometry2>
|
||||
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 <typename P>
|
||||
inline void test_segment_segment()
|
||||
{
|
||||
typedef bg::model::segment<P> S;
|
||||
|
||||
typedef test_disjoint tester;
|
||||
|
||||
tester::apply("s-s-01",
|
||||
from_wkt<S>("SEGMENT(0 0,2 0)"),
|
||||
from_wkt<S>("SEGMENT(0 0,0 2)"),
|
||||
false);
|
||||
|
||||
tester::apply("s-s-02",
|
||||
from_wkt<S>("SEGMENT(0 0,2 0)"),
|
||||
from_wkt<S>("SEGMENT(2 0,3 0)"),
|
||||
false);
|
||||
|
||||
tester::apply("s-s-03",
|
||||
from_wkt<S>("SEGMENT(0 0,2 0)"),
|
||||
from_wkt<S>("SEGMENT(1 0,3 0)"),
|
||||
false);
|
||||
|
||||
tester::apply("s-s-04",
|
||||
from_wkt<S>("SEGMENT(0 0,2 0)"),
|
||||
from_wkt<S>("SEGMENT(1 0,1 1)"),
|
||||
false);
|
||||
|
||||
tester::apply("s-s-05",
|
||||
from_wkt<S>("SEGMENT(0 0,2 0)"),
|
||||
from_wkt<S>("SEGMENT(1 1,2 2)"),
|
||||
true);
|
||||
|
||||
tester::apply("s-s-06",
|
||||
from_wkt<S>("SEGMENT(0 0,1 1)"),
|
||||
from_wkt<S>("SEGMENT(1 1,1 1)"),
|
||||
false);
|
||||
|
||||
tester::apply("s-s-07",
|
||||
from_wkt<S>("SEGMENT(0 0,1 1)"),
|
||||
from_wkt<S>("SEGMENT(2 2,2 2)"),
|
||||
true);
|
||||
|
||||
tester::apply("s-s-08",
|
||||
from_wkt<S>("SEGMENT(0 0,1 1)"),
|
||||
from_wkt<S>("SEGMENT(2 2,3 3)"),
|
||||
true);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
inline void test_linestring_segment()
|
||||
{
|
||||
typedef bg::model::segment<P> S;
|
||||
typedef bg::model::linestring<P> L;
|
||||
|
||||
typedef test_disjoint tester;
|
||||
|
||||
tester::apply("l-s-01",
|
||||
from_wkt<S>("SEGMENT(0 0,2 0)"),
|
||||
from_wkt<L>("LINESTRING(0 0,0 2)"),
|
||||
false);
|
||||
|
||||
tester::apply("l-s-02",
|
||||
from_wkt<S>("SEGMENT(0 0,2 0)"),
|
||||
from_wkt<L>("LINESTRING(2 0,3 0)"),
|
||||
false);
|
||||
|
||||
tester::apply("l-s-03",
|
||||
from_wkt<S>("SEGMENT(0 0,2 0)"),
|
||||
from_wkt<L>("LINESTRING(1 0,3 0)"),
|
||||
false);
|
||||
|
||||
tester::apply("l-s-04",
|
||||
from_wkt<S>("SEGMENT(0 0,2 0)"),
|
||||
from_wkt<L>("LINESTRING(1 0,1 1)"),
|
||||
false);
|
||||
|
||||
tester::apply("l-s-05",
|
||||
from_wkt<S>("SEGMENT(0 0,2 0)"),
|
||||
from_wkt<L>("LINESTRING(1 1,2 2)"),
|
||||
true);
|
||||
|
||||
tester::apply("l-s-06",
|
||||
from_wkt<S>("SEGMENT(0 0,2 0)"),
|
||||
from_wkt<L>("LINESTRING(1 1,1 1,2 2)"),
|
||||
true);
|
||||
|
||||
tester::apply("l-s-07",
|
||||
from_wkt<S>("SEGMENT(0 0,2 0)"),
|
||||
from_wkt<L>("LINESTRING(1 0,1 0,1 1,2 2)"),
|
||||
false);
|
||||
|
||||
tester::apply("l-s-08",
|
||||
from_wkt<S>("SEGMENT(0 0,2 0)"),
|
||||
from_wkt<L>("LINESTRING(1 0,1 0,3 0)"),
|
||||
false);
|
||||
|
||||
tester::apply("l-s-09",
|
||||
from_wkt<S>("SEGMENT(0 0,2 0)"),
|
||||
from_wkt<L>("LINESTRING(3 0,3 0,4 0)"),
|
||||
true);
|
||||
|
||||
tester::apply("l-s-10",
|
||||
from_wkt<S>("SEGMENT(0 0,2 0)"),
|
||||
from_wkt<L>("LINESTRING(3 0,3 0)"),
|
||||
true);
|
||||
|
||||
tester::apply("l-s-11",
|
||||
from_wkt<S>("SEGMENT(0 0,2 0)"),
|
||||
from_wkt<L>("LINESTRING(-1 0,-1 0)"),
|
||||
true);
|
||||
|
||||
tester::apply("l-s-12",
|
||||
from_wkt<S>("SEGMENT(0 0,2 0)"),
|
||||
from_wkt<L>("LINESTRING(1 0,1 0)"),
|
||||
false);
|
||||
|
||||
tester::apply("l-s-13",
|
||||
from_wkt<S>("SEGMENT(0 0,2 0)"),
|
||||
from_wkt<L>("LINESTRING(1 1,1 1)"),
|
||||
true);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
inline void test_multilinestring_segment()
|
||||
{
|
||||
typedef bg::model::segment<P> S;
|
||||
typedef bg::model::linestring<P> L;
|
||||
typedef bg::model::multi_linestring<L> ML;
|
||||
|
||||
typedef test_disjoint tester;
|
||||
|
||||
tester::apply("s-ml-01",
|
||||
from_wkt<S>("SEGMENT(0 0,2 0)"),
|
||||
from_wkt<ML>("MULTILINESTRING((0 0,0 2))"),
|
||||
false);
|
||||
|
||||
tester::apply("s-ml-02",
|
||||
from_wkt<S>("SEGMENT(0 0,2 0)"),
|
||||
from_wkt<ML>("MULTILINESTRING((2 0,3 0))"),
|
||||
false);
|
||||
|
||||
tester::apply("s-ml-03",
|
||||
from_wkt<S>("SEGMENT(0 0,2 0)"),
|
||||
from_wkt<ML>("MULTILINESTRING((1 0,3 0))"),
|
||||
false);
|
||||
|
||||
tester::apply("s-ml-04",
|
||||
from_wkt<S>("SEGMENT(0 0,2 0)"),
|
||||
from_wkt<ML>("MULTILINESTRING((1 0,1 1))"),
|
||||
false);
|
||||
|
||||
tester::apply("s-ml-05",
|
||||
from_wkt<S>("SEGMENT(0 0,2 0)"),
|
||||
from_wkt<ML>("MULTILINESTRING((1 1,2 2))"),
|
||||
true);
|
||||
|
||||
tester::apply("s-ml-06",
|
||||
from_wkt<S>("SEGMENT(0 0,2 0)"),
|
||||
from_wkt<ML>("MULTILINESTRING((1 1,2 2),(3 3,3 3))"),
|
||||
true);
|
||||
|
||||
tester::apply("s-ml-07",
|
||||
from_wkt<S>("SEGMENT(0 0,2 0)"),
|
||||
from_wkt<ML>("MULTILINESTRING((1 1,2 2),(1 0,1 0))"),
|
||||
false);
|
||||
|
||||
tester::apply("s-ml-08",
|
||||
from_wkt<S>("SEGMENT(0 0,2 0)"),
|
||||
from_wkt<ML>("MULTILINESTRING((1 1,2 2),(3 0,3 0))"),
|
||||
true);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
inline void test_linestring_linestring()
|
||||
{
|
||||
typedef bg::model::linestring<P> L;
|
||||
|
||||
typedef test_disjoint tester;
|
||||
|
||||
tester::apply("l-l-01",
|
||||
from_wkt<L>("LINESTRING(0 0,2 0)"),
|
||||
from_wkt<L>("LINESTRING(0 0,0 2)"),
|
||||
false);
|
||||
|
||||
tester::apply("l-l-02",
|
||||
from_wkt<L>("LINESTRING(0 0,2 0)"),
|
||||
from_wkt<L>("LINESTRING(2 0,3 0)"),
|
||||
false);
|
||||
|
||||
tester::apply("l-l-03",
|
||||
from_wkt<L>("LINESTRING(0 0,2 0)"),
|
||||
from_wkt<L>("LINESTRING(1 0,3 0)"),
|
||||
false);
|
||||
|
||||
tester::apply("l-l-04",
|
||||
from_wkt<L>("LINESTRING(0 0,2 0)"),
|
||||
from_wkt<L>("LINESTRING(1 0,1 1)"),
|
||||
false);
|
||||
|
||||
tester::apply("l-l-05",
|
||||
from_wkt<L>("LINESTRING(0 0,2 0)"),
|
||||
from_wkt<L>("LINESTRING(1 1,2 2)"),
|
||||
true);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
inline void test_linestring_multilinestring()
|
||||
{
|
||||
typedef bg::model::linestring<P> L;
|
||||
typedef bg::model::multi_linestring<L> ML;
|
||||
|
||||
typedef test_disjoint tester;
|
||||
|
||||
tester::apply("l-ml-01",
|
||||
from_wkt<L>("LINESTRING(0 0,2 0)"),
|
||||
from_wkt<ML>("MULTILINESTRING((0 0,0 2))"),
|
||||
false);
|
||||
|
||||
tester::apply("l-ml-02",
|
||||
from_wkt<L>("LINESTRING(0 0,2 0)"),
|
||||
from_wkt<ML>("MULTILINESTRING((2 0,3 0))"),
|
||||
false);
|
||||
|
||||
tester::apply("l-ml-03",
|
||||
from_wkt<L>("LINESTRING(0 0,2 0)"),
|
||||
from_wkt<ML>("MULTILINESTRING((1 0,3 0))"),
|
||||
false);
|
||||
|
||||
tester::apply("l-ml-04",
|
||||
from_wkt<L>("LINESTRING(0 0,2 0)"),
|
||||
from_wkt<ML>("MULTILINESTRING((1 0,1 1))"),
|
||||
false);
|
||||
|
||||
tester::apply("l-ml-05",
|
||||
from_wkt<L>("LINESTRING(0 0,2 0)"),
|
||||
from_wkt<ML>("MULTILINESTRING((1 1,2 2))"),
|
||||
true);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
inline void test_multilinestring_multilinestring()
|
||||
{
|
||||
typedef bg::model::linestring<P> L;
|
||||
typedef bg::model::multi_linestring<L> ML;
|
||||
|
||||
typedef test_disjoint tester;
|
||||
|
||||
tester::apply("ml-ml-01",
|
||||
from_wkt<ML>("MULTILINESTRING((0 0,2 0))"),
|
||||
from_wkt<ML>("MULTILINESTRING((0 0,0 2))"),
|
||||
false);
|
||||
|
||||
tester::apply("ml-ml-02",
|
||||
from_wkt<ML>("MULTILINESTRING((0 0,2 0))"),
|
||||
from_wkt<ML>("MULTILINESTRING((2 0,3 0))"),
|
||||
false);
|
||||
|
||||
tester::apply("ml-ml-03",
|
||||
from_wkt<ML>("MULTILINESTRING((0 0,2 0))"),
|
||||
from_wkt<ML>("MULTILINESTRING((1 0,3 0))"),
|
||||
false);
|
||||
|
||||
tester::apply("ml-ml-04",
|
||||
from_wkt<ML>("MULTILINESTRING((0 0,2 0))"),
|
||||
from_wkt<ML>("MULTILINESTRING((1 0,1 1))"),
|
||||
false);
|
||||
|
||||
tester::apply("ml-ml-05",
|
||||
from_wkt<ML>("MULTILINESTRING((0 0,2 0))"),
|
||||
from_wkt<ML>("MULTILINESTRING((1 1,2 2))"),
|
||||
true);
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
|
||||
template <typename CoordinateType>
|
||||
inline void test_linear_linear()
|
||||
{
|
||||
typedef bg::model::point<CoordinateType, 2, bg::cs::cartesian> point_type;
|
||||
|
||||
test_linestring_linestring<point_type>();
|
||||
test_linestring_multilinestring<point_type>();
|
||||
test_linestring_segment<point_type>();
|
||||
|
||||
test_multilinestring_multilinestring<point_type>();
|
||||
test_multilinestring_segment<point_type>();
|
||||
|
||||
test_segment_segment<point_type>();
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
|
||||
BOOST_AUTO_TEST_CASE( test_linear_linear_all )
|
||||
{
|
||||
test_linear_linear<double>();
|
||||
test_linear_linear<int>();
|
||||
#ifdef HAVE_TTMATH
|
||||
test_linear_linear<ttmath_big>();
|
||||
#endif
|
||||
}
|
||||
@@ -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 <iostream>
|
||||
|
||||
#include <boost/test/included/unit_test.hpp>
|
||||
|
||||
#include <boost/geometry/core/tag.hpp>
|
||||
#include <boost/geometry/core/tags.hpp>
|
||||
|
||||
#include <boost/geometry/strategies/strategies.hpp>
|
||||
|
||||
#include <boost/geometry/io/wkt/wkt.hpp>
|
||||
#include <boost/geometry/io/dsv/write.hpp>
|
||||
|
||||
#include <boost/geometry/geometries/geometries.hpp>
|
||||
|
||||
#include <boost/geometry/algorithms/disjoint.hpp>
|
||||
|
||||
#include <from_wkt.hpp>
|
||||
|
||||
|
||||
#ifdef HAVE_TTMATH
|
||||
#include <boost/geometry/extensions/contrib/ttmath_stub.hpp>
|
||||
#endif
|
||||
|
||||
namespace bg = ::boost::geometry;
|
||||
|
||||
//============================================================================
|
||||
|
||||
struct test_disjoint
|
||||
{
|
||||
template <typename Geometry1, typename Geometry2>
|
||||
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 <typename P>
|
||||
inline void test_point_box()
|
||||
{
|
||||
typedef test_disjoint tester;
|
||||
typedef bg::model::box<P> B;
|
||||
|
||||
tester::apply("p-b-01",
|
||||
from_wkt<P>("POINT(0 0)"),
|
||||
from_wkt<B>("BOX(0 0,1 1)"),
|
||||
false);
|
||||
|
||||
tester::apply("p-b-02",
|
||||
from_wkt<P>("POINT(2 2)"),
|
||||
from_wkt<B>("BOX(0 0,1 0)"),
|
||||
true);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
inline void test_point_ring()
|
||||
{
|
||||
typedef bg::model::ring<P, false, false> R; // ccw, open
|
||||
|
||||
typedef test_disjoint tester;
|
||||
|
||||
tester::apply("p-r-01",
|
||||
from_wkt<P>("POINT(0 0)"),
|
||||
from_wkt<R>("POLYGON((0 0,1 0,0 1))"),
|
||||
false);
|
||||
|
||||
tester::apply("p-r-02",
|
||||
from_wkt<P>("POINT(1 1)"),
|
||||
from_wkt<R>("POLYGON((0 0,1 0,0 1))"),
|
||||
true);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
inline void test_point_polygon()
|
||||
{
|
||||
typedef bg::model::polygon<P, false, false> PL; // ccw, open
|
||||
|
||||
typedef test_disjoint tester;
|
||||
|
||||
tester::apply("p-pg-01",
|
||||
from_wkt<P>("POINT(0 0)"),
|
||||
from_wkt<PL>("POLYGON((0 0,1 0,0 1))"),
|
||||
false);
|
||||
|
||||
tester::apply("p-pg-02",
|
||||
from_wkt<P>("POINT(1 1)"),
|
||||
from_wkt<PL>("POLYGON((0 0,1 0,0 1))"),
|
||||
true);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
inline void test_point_multipolygon()
|
||||
{
|
||||
typedef bg::model::polygon<P, false, false> PL; // ccw, open
|
||||
typedef bg::model::multi_polygon<PL> MPL;
|
||||
|
||||
typedef test_disjoint tester;
|
||||
|
||||
tester::apply("p-mpg-01",
|
||||
from_wkt<P>("POINT(0 0)"),
|
||||
from_wkt<MPL>("MULTIPOLYGON(((0 0,1 0,0 1)),((2 0,3 0,2 1)))"),
|
||||
false);
|
||||
|
||||
tester::apply("p-mpg-02",
|
||||
from_wkt<P>("POINT(1 1)"),
|
||||
from_wkt<MPL>("MULTIPOLYGON(((0 0,1 0,0 1)),((2 0,3 0,2 1)))"),
|
||||
true);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
inline void test_multipoint_box()
|
||||
{
|
||||
typedef test_disjoint tester;
|
||||
typedef bg::model::multi_point<P> MP;
|
||||
typedef bg::model::box<P> B;
|
||||
|
||||
tester::apply("mp-b-01",
|
||||
from_wkt<MP>("MULTIPOINT(0 0,1 1)"),
|
||||
from_wkt<B>("BOX(0 0,2 2)"),
|
||||
false);
|
||||
|
||||
tester::apply("mp-b-02",
|
||||
from_wkt<MP>("MULTIPOINT(1 1,3 3)"),
|
||||
from_wkt<B>("BOX(0 0,2 2)"),
|
||||
false);
|
||||
|
||||
tester::apply("mp-b-03",
|
||||
from_wkt<MP>("MULTIPOINT(3 3,4 4)"),
|
||||
from_wkt<B>("BOX(0 0,2 2)"),
|
||||
true);
|
||||
|
||||
tester::apply("mp-b-04",
|
||||
from_wkt<MP>("MULTIPOINT()"),
|
||||
from_wkt<B>("BOX(0 0,2 2)"),
|
||||
true);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
inline void test_multipoint_ring()
|
||||
{
|
||||
typedef bg::model::multi_point<P> MP;
|
||||
typedef bg::model::ring<P, false, false> R; // ccw, open
|
||||
|
||||
typedef test_disjoint tester;
|
||||
|
||||
tester::apply("mp-r-01",
|
||||
from_wkt<MP>("MULTIPOINT(0 0,1 0)"),
|
||||
from_wkt<R>("POLYGON((0 0,1 0,0 1))"),
|
||||
false);
|
||||
|
||||
tester::apply("mp-r-02",
|
||||
from_wkt<MP>("MULTIPOINT(1 0,1 1)"),
|
||||
from_wkt<R>("POLYGON((0 0,1 0,0 1))"),
|
||||
false);
|
||||
|
||||
tester::apply("mp-r-03",
|
||||
from_wkt<MP>("MULTIPOINT(1 1,2 2)"),
|
||||
from_wkt<R>("POLYGON((0 0,1 0,0 1))"),
|
||||
true);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
inline void test_multipoint_polygon()
|
||||
{
|
||||
typedef bg::model::multi_point<P> MP;
|
||||
typedef bg::model::polygon<P, false, false> PL; // ccw, open
|
||||
|
||||
typedef test_disjoint tester;
|
||||
|
||||
tester::apply("mp-pg-01",
|
||||
from_wkt<MP>("MULTIPOINT(0 0,1 0)"),
|
||||
from_wkt<PL>("POLYGON(((0 0,1 0,0 1)))"),
|
||||
false);
|
||||
|
||||
tester::apply("mp-pg-02",
|
||||
from_wkt<MP>("MULTIPOINT(0 0,2 0)"),
|
||||
from_wkt<PL>("POLYGON(((0 0,1 0,0 1)))"),
|
||||
false);
|
||||
|
||||
tester::apply("mp-pg-03",
|
||||
from_wkt<MP>("MULTIPOINT(1 1,2 0)"),
|
||||
from_wkt<PL>("POLYGON(((0 0,1 0,0 1)))"),
|
||||
true);
|
||||
|
||||
tester::apply("mp-pg-04",
|
||||
from_wkt<MP>("MULTIPOINT(1 1,2 3)"),
|
||||
from_wkt<PL>("POLYGON(((0 0,1 0,0 1)))"),
|
||||
true);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
inline void test_multipoint_multipolygon()
|
||||
{
|
||||
typedef bg::model::multi_point<P> MP;
|
||||
typedef bg::model::polygon<P, false, false> PL; // ccw, open
|
||||
typedef bg::model::multi_polygon<PL> MPL;
|
||||
|
||||
typedef test_disjoint tester;
|
||||
|
||||
tester::apply("mp-mp-01",
|
||||
from_wkt<MP>("MULTIPOINT(0 0,2 0)"),
|
||||
from_wkt<MPL>("MULTIPOLYGON((0 0,1 0,0 1)),(2 0,3 0,2 1))"),
|
||||
false);
|
||||
|
||||
tester::apply("mp-mp-02",
|
||||
from_wkt<MP>("MULTIPOINT(0 0,1 0)"),
|
||||
from_wkt<MPL>("MULTIPOLYGON((0 0,1 0,0 1)),(2 0,3 0,2 1))"),
|
||||
false);
|
||||
|
||||
tester::apply("mp-mp-03",
|
||||
from_wkt<MP>("MULTIPOINT(1 1,2 0)"),
|
||||
from_wkt<MPL>("MULTIPOLYGON((0 0,1 0,0 1)),(2 0,3 0,2 1))"),
|
||||
false);
|
||||
|
||||
tester::apply("mp-mp-04",
|
||||
from_wkt<MP>("MULTIPOINT(1 1,2 3)"),
|
||||
from_wkt<MPL>("MULTIPOLYGON((0 0,1 0,0 1)),(2 0,3 0,2 1))"),
|
||||
true);
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
|
||||
template <typename CoordinateType>
|
||||
inline void test_pointlike_areal()
|
||||
{
|
||||
typedef bg::model::point<CoordinateType, 2, bg::cs::cartesian> point_type;
|
||||
|
||||
test_point_polygon<point_type>();
|
||||
test_point_multipolygon<point_type>();
|
||||
test_point_ring<point_type>();
|
||||
test_point_box<point_type>();
|
||||
|
||||
// not implemented yet
|
||||
// test_multipoint_polygon<point_type>();
|
||||
// test_multipoint_multipolygon<point_type>();
|
||||
// test_multipoint_ring<point_type>();
|
||||
test_multipoint_box<point_type>();
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
|
||||
BOOST_AUTO_TEST_CASE( test_pointlike_areal_all )
|
||||
{
|
||||
test_pointlike_areal<double>();
|
||||
test_pointlike_areal<int>();
|
||||
#ifdef HAVE_TTMATH
|
||||
test_pointlike_areal<ttmath_big>();
|
||||
#endif
|
||||
}
|
||||
@@ -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 <iostream>
|
||||
|
||||
#include <boost/test/included/unit_test.hpp>
|
||||
|
||||
#include <boost/geometry/core/tag.hpp>
|
||||
#include <boost/geometry/core/tags.hpp>
|
||||
|
||||
#include <boost/geometry/strategies/strategies.hpp>
|
||||
|
||||
#include <boost/geometry/io/wkt/wkt.hpp>
|
||||
#include <boost/geometry/io/dsv/write.hpp>
|
||||
|
||||
#include <boost/geometry/geometries/geometries.hpp>
|
||||
|
||||
#include <boost/geometry/algorithms/disjoint.hpp>
|
||||
|
||||
#include <from_wkt.hpp>
|
||||
|
||||
|
||||
#ifdef HAVE_TTMATH
|
||||
#include <boost/geometry/extensions/contrib/ttmath_stub.hpp>
|
||||
#endif
|
||||
|
||||
namespace bg = ::boost::geometry;
|
||||
|
||||
//============================================================================
|
||||
|
||||
struct test_disjoint
|
||||
{
|
||||
template <typename Geometry1, typename Geometry2>
|
||||
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 <typename P>
|
||||
inline void test_point_segment()
|
||||
{
|
||||
typedef test_disjoint tester;
|
||||
typedef bg::model::segment<P> S;
|
||||
|
||||
tester::apply("p-s-01",
|
||||
from_wkt<P>("POINT(0 0)"),
|
||||
from_wkt<S>("SEGMENT(0 0,2 0)"),
|
||||
false);
|
||||
|
||||
tester::apply("p-s-02",
|
||||
from_wkt<P>("POINT(2 0)"),
|
||||
from_wkt<S>("SEGMENT(0 0,2 0)"),
|
||||
false);
|
||||
|
||||
tester::apply("p-s-03",
|
||||
from_wkt<P>("POINT(1 0)"),
|
||||
from_wkt<S>("SEGMENT(0 0,2 0)"),
|
||||
false);
|
||||
|
||||
tester::apply("p-s-04",
|
||||
from_wkt<P>("POINT(1 1)"),
|
||||
from_wkt<S>("SEGMENT(0 0,2 0)"),
|
||||
true);
|
||||
|
||||
tester::apply("p-s-05",
|
||||
from_wkt<P>("POINT(3 0)"),
|
||||
from_wkt<S>("SEGMENT(0 0,2 0)"),
|
||||
true);
|
||||
|
||||
tester::apply("p-s-06",
|
||||
from_wkt<P>("POINT(-1 0)"),
|
||||
from_wkt<S>("SEGMENT(0 0,2 0)"),
|
||||
true);
|
||||
|
||||
// degenerate segment
|
||||
tester::apply("p-s-07",
|
||||
from_wkt<P>("POINT(-1 0)"),
|
||||
from_wkt<S>("SEGMENT(2 0,2 0)"),
|
||||
true);
|
||||
|
||||
// degenerate segment
|
||||
tester::apply("p-s-08",
|
||||
from_wkt<P>("POINT(2 0)"),
|
||||
from_wkt<S>("SEGMENT(2 0,2 0)"),
|
||||
false);
|
||||
|
||||
// degenerate segment
|
||||
tester::apply("p-s-09",
|
||||
from_wkt<P>("POINT(3 0)"),
|
||||
from_wkt<S>("SEGMENT(2 0,2 0)"),
|
||||
true);
|
||||
|
||||
// degenerate segment
|
||||
tester::apply("p-s-10",
|
||||
from_wkt<P>("POINT(1 1)"),
|
||||
from_wkt<S>("SEGMENT(2 0,2 0)"),
|
||||
true);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
inline void test_point_linestring()
|
||||
{
|
||||
typedef bg::model::linestring<P> L;
|
||||
|
||||
typedef test_disjoint tester;
|
||||
|
||||
tester::apply("p-l-01",
|
||||
from_wkt<P>("POINT(0 0)"),
|
||||
from_wkt<L>("LINESTRING(0 0,2 2,4 4)"),
|
||||
false);
|
||||
|
||||
tester::apply("p-l-02",
|
||||
from_wkt<P>("POINT(1 1)"),
|
||||
from_wkt<L>("LINESTRING(0 0,2 2,4 4)"),
|
||||
false);
|
||||
|
||||
tester::apply("p-l-03",
|
||||
from_wkt<P>("POINT(3 3)"),
|
||||
from_wkt<L>("LINESTRING(0 0,2 2,4 4)"),
|
||||
false);
|
||||
|
||||
tester::apply("p-l-04",
|
||||
from_wkt<P>("POINT(1 0)"),
|
||||
from_wkt<L>("LINESTRING(0 0,2 2,4 4)"),
|
||||
true);
|
||||
|
||||
tester::apply("p-l-05",
|
||||
from_wkt<P>("POINT(5 5)"),
|
||||
from_wkt<L>("LINESTRING(0 0,2 2,4 4)"),
|
||||
true);
|
||||
|
||||
tester::apply("p-l-06",
|
||||
from_wkt<P>("POINT(5 5)"),
|
||||
from_wkt<L>("LINESTRING(0 0,2 2)"),
|
||||
true);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
inline void test_point_multilinestring()
|
||||
{
|
||||
typedef bg::model::linestring<P> L;
|
||||
typedef bg::model::multi_linestring<L> ML;
|
||||
|
||||
typedef test_disjoint tester;
|
||||
|
||||
tester::apply("p-ml-01",
|
||||
from_wkt<P>("POINT(0 1)"),
|
||||
from_wkt<ML>("MULTILINESTRING((0 0,2 2,4 4),(0 0,2 0,4 0))"),
|
||||
true);
|
||||
|
||||
tester::apply("p-ml-02",
|
||||
from_wkt<P>("POINT(0 0)"),
|
||||
from_wkt<ML>("MULTILINESTRING((0 0,2 2,4 4),(0 0,2 0,4 0))"),
|
||||
false);
|
||||
|
||||
tester::apply("p-ml-03",
|
||||
from_wkt<P>("POINT(1 1)"),
|
||||
from_wkt<ML>("MULTILINESTRING((0 0,2 2,4 4),(0 0,2 0,4 0))"),
|
||||
false);
|
||||
|
||||
tester::apply("p-ml-04",
|
||||
from_wkt<P>("POINT(1 0)"),
|
||||
from_wkt<ML>("MULTILINESTRING((0 0,2 2,4 4),(0 0,2 0,4 0))"),
|
||||
false);
|
||||
|
||||
tester::apply("p-ml-05",
|
||||
from_wkt<P>("POINT(0 0)"),
|
||||
from_wkt<ML>("MULTILINESTRING((1 1,2 2,4 4),(3 0,4 0))"),
|
||||
true);
|
||||
|
||||
tester::apply("p-ml-06",
|
||||
from_wkt<P>("POINT(0 0)"),
|
||||
from_wkt<ML>("MULTILINESTRING((1 1,2 2,4 4),(0 0,4 0))"),
|
||||
false);
|
||||
|
||||
tester::apply("p-ml-07",
|
||||
from_wkt<P>("POINT(0 0)"),
|
||||
from_wkt<ML>("MULTILINESTRING((1 1,2 2,4 4),(-1 0,4 0))"),
|
||||
false);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
inline void test_multipoint_segment()
|
||||
{
|
||||
typedef test_disjoint tester;
|
||||
typedef bg::model::multi_point<P> MP;
|
||||
typedef bg::model::segment<P> S;
|
||||
|
||||
tester::apply("mp-s-01",
|
||||
from_wkt<MP>("MULTIPOINT(0 0,1 1)"),
|
||||
from_wkt<S>("SEGMENT(0 0,2 0)"),
|
||||
false);
|
||||
|
||||
tester::apply("mp-s-02",
|
||||
from_wkt<MP>("MULTIPOINT(1 0,1 1)"),
|
||||
from_wkt<S>("SEGMENT(0 0,2 0)"),
|
||||
false);
|
||||
|
||||
tester::apply("mp-s-03",
|
||||
from_wkt<MP>("MULTIPOINT(1 1,2 2)"),
|
||||
from_wkt<S>("SEGMENT(0 0,2 0)"),
|
||||
true);
|
||||
|
||||
tester::apply("mp-s-04",
|
||||
from_wkt<MP>("MULTIPOINT()"),
|
||||
from_wkt<S>("SEGMENT(0 0,2 0)"),
|
||||
true);
|
||||
|
||||
tester::apply("mp-s-05",
|
||||
from_wkt<MP>("MULTIPOINT(3 0,4 0)"),
|
||||
from_wkt<S>("SEGMENT(0 0,2 0)"),
|
||||
true);
|
||||
|
||||
tester::apply("mp-s-06",
|
||||
from_wkt<MP>("MULTIPOINT(1 0,4 0)"),
|
||||
from_wkt<S>("SEGMENT(0 0,2 0)"),
|
||||
false);
|
||||
|
||||
// segments that degenerate to a point
|
||||
tester::apply("mp-s-07",
|
||||
from_wkt<MP>("MULTIPOINT(1 1,2 2)"),
|
||||
from_wkt<S>("SEGMENT(0 0,0 0)"),
|
||||
true);
|
||||
|
||||
tester::apply("mp-s-08",
|
||||
from_wkt<MP>("MULTIPOINT(1 1,2 2)"),
|
||||
from_wkt<S>("SEGMENT(1 1,1 1)"),
|
||||
false);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
inline void test_multipoint_linestring()
|
||||
{
|
||||
typedef bg::model::multi_point<P> MP;
|
||||
typedef bg::model::linestring<P> L;
|
||||
|
||||
typedef test_disjoint tester;
|
||||
|
||||
tester::apply("mp-l-01",
|
||||
from_wkt<MP>("MULTIPOINT(0 0,1 0)"),
|
||||
from_wkt<L>("LINESTRING(0 0,2 2,4 4)"),
|
||||
false);
|
||||
|
||||
tester::apply("mp-l-02",
|
||||
from_wkt<MP>("MULTIPOINT(1 0,1 1)"),
|
||||
from_wkt<L>("LINESTRING(0 0,2 2,4 4)"),
|
||||
false);
|
||||
|
||||
tester::apply("mp-l-03",
|
||||
from_wkt<MP>("MULTIPOINT(1 0,3 3)"),
|
||||
from_wkt<L>("LINESTRING(0 0,2 2,4 4)"),
|
||||
false);
|
||||
|
||||
tester::apply("mp-l-04",
|
||||
from_wkt<MP>("MULTIPOINT(1 0,2 0)"),
|
||||
from_wkt<L>("LINESTRING(0 0,2 2,4 4)"),
|
||||
true);
|
||||
|
||||
tester::apply("mp-l-05",
|
||||
from_wkt<MP>("MULTIPOINT(-1 -1,2 0)"),
|
||||
from_wkt<L>("LINESTRING(0 0,2 2,4 4)"),
|
||||
true);
|
||||
|
||||
tester::apply("mp-l-06",
|
||||
from_wkt<MP>("MULTIPOINT(-1 -1,2 0)"),
|
||||
from_wkt<L>("LINESTRING(1 0,3 0)"),
|
||||
false);
|
||||
|
||||
tester::apply("mp-l-07",
|
||||
from_wkt<MP>("MULTIPOINT(-1 -1,2 0,-1 -1,2 0)"),
|
||||
from_wkt<L>("LINESTRING(1 0,3 0)"),
|
||||
false);
|
||||
|
||||
tester::apply("mp-l-08",
|
||||
from_wkt<MP>("MULTIPOINT(2 0)"),
|
||||
from_wkt<L>("LINESTRING(1 0)"),
|
||||
true);
|
||||
|
||||
tester::apply("mp-l-09",
|
||||
from_wkt<MP>("MULTIPOINT(3 0,0 0,3 0)"),
|
||||
from_wkt<L>("LINESTRING(1 0,2 0)"),
|
||||
true);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
inline void test_multipoint_multilinestring()
|
||||
{
|
||||
typedef bg::model::multi_point<P> MP;
|
||||
typedef bg::model::linestring<P> L;
|
||||
typedef bg::model::multi_linestring<L> ML;
|
||||
|
||||
typedef test_disjoint tester;
|
||||
|
||||
tester::apply("mp-ml-01",
|
||||
from_wkt<MP>("MULTIPOINT(0 1,0 2)"),
|
||||
from_wkt<ML>("MULTILINESTRING((0 0,2 2,4 4),(0 0,2 0,4 0))"),
|
||||
true);
|
||||
|
||||
tester::apply("mp-ml-02",
|
||||
from_wkt<MP>("MULTIPOINT(0 0,1 0)"),
|
||||
from_wkt<ML>("MULTILINESTRING((0 0,2 2,4 4),(0 0,2 0,4 0))"),
|
||||
false);
|
||||
|
||||
tester::apply("mp-ml-03",
|
||||
from_wkt<MP>("MULTIPOINT(0 1,1 1)"),
|
||||
from_wkt<ML>("MULTILINESTRING((0 0,2 2,4 4),(0 0,2 0,4 0))"),
|
||||
false);
|
||||
|
||||
tester::apply("mp-ml-04",
|
||||
from_wkt<MP>("MULTIPOINT(0 1,1 0)"),
|
||||
from_wkt<ML>("MULTILINESTRING((0 0,2 2,4 4),(0 0,2 0,4 0))"),
|
||||
false);
|
||||
|
||||
tester::apply("mp-ml-05",
|
||||
from_wkt<MP>("MULTIPOINT(0 0,10 0)"),
|
||||
from_wkt<ML>("MULTILINESTRING((0 0,2 2,4 4),(0 0,2 0,4 0))"),
|
||||
false);
|
||||
|
||||
tester::apply("mp-ml-06",
|
||||
from_wkt<MP>("MULTIPOINT(-1 0,3 0)"),
|
||||
from_wkt<ML>("MULTILINESTRING((0 0,2 2,4 4),(0 0,2 0,4 0))"),
|
||||
false);
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
|
||||
template <typename CoordinateType>
|
||||
inline void test_pointlike_linear()
|
||||
{
|
||||
typedef bg::model::point<CoordinateType, 2, bg::cs::cartesian> point_type;
|
||||
|
||||
test_point_linestring<point_type>();
|
||||
test_point_multilinestring<point_type>();
|
||||
test_point_segment<point_type>();
|
||||
|
||||
test_multipoint_linestring<point_type>();
|
||||
test_multipoint_multilinestring<point_type>();
|
||||
test_multipoint_segment<point_type>();
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
|
||||
BOOST_AUTO_TEST_CASE( test_pointlike_linear_all )
|
||||
{
|
||||
test_pointlike_linear<double>();
|
||||
test_pointlike_linear<int>();
|
||||
#ifdef HAVE_TTMATH
|
||||
test_pointlike_linear<ttmath_big>();
|
||||
#endif
|
||||
}
|
||||
@@ -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 <iostream>
|
||||
|
||||
#include <boost/test/included/unit_test.hpp>
|
||||
|
||||
#include <boost/geometry/core/tag.hpp>
|
||||
#include <boost/geometry/core/tags.hpp>
|
||||
|
||||
#include <boost/geometry/strategies/strategies.hpp>
|
||||
|
||||
#include <boost/geometry/io/wkt/wkt.hpp>
|
||||
#include <boost/geometry/io/dsv/write.hpp>
|
||||
|
||||
#include <boost/geometry/geometries/geometries.hpp>
|
||||
|
||||
#include <boost/geometry/algorithms/disjoint.hpp>
|
||||
|
||||
#include <from_wkt.hpp>
|
||||
|
||||
|
||||
#ifdef HAVE_TTMATH
|
||||
#include <boost/geometry/extensions/contrib/ttmath_stub.hpp>
|
||||
#endif
|
||||
|
||||
namespace bg = ::boost::geometry;
|
||||
|
||||
//============================================================================
|
||||
|
||||
struct test_disjoint
|
||||
{
|
||||
template <typename Geometry1, typename Geometry2>
|
||||
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 <typename P>
|
||||
inline void test_point_point()
|
||||
{
|
||||
typedef test_disjoint tester;
|
||||
|
||||
tester::apply("p-p-01",
|
||||
from_wkt<P>("POINT(0 0)"),
|
||||
from_wkt<P>("POINT(0 0)"),
|
||||
false);
|
||||
|
||||
tester::apply("p-p-02",
|
||||
from_wkt<P>("POINT(0 0)"),
|
||||
from_wkt<P>("POINT(1 1)"),
|
||||
true);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
inline void test_point_multipoint()
|
||||
{
|
||||
typedef bg::model::multi_point<P> MP;
|
||||
|
||||
typedef test_disjoint tester;
|
||||
|
||||
tester::apply("p-mp-01",
|
||||
from_wkt<P>("POINT(0 0)"),
|
||||
from_wkt<MP>("MULTIPOINT(0 0,1 1)"),
|
||||
false);
|
||||
|
||||
tester::apply("p-mp-02",
|
||||
from_wkt<P>("POINT(0 0)"),
|
||||
from_wkt<MP>("MULTIPOINT(1 1,2 2)"),
|
||||
true);
|
||||
|
||||
tester::apply("p-mp-03",
|
||||
from_wkt<P>("POINT(0 0)"),
|
||||
from_wkt<MP>("MULTIPOINT()"),
|
||||
true);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
inline void test_multipoint_multipoint()
|
||||
{
|
||||
typedef bg::model::multi_point<P> MP;
|
||||
|
||||
typedef test_disjoint tester;
|
||||
|
||||
tester::apply("mp-mp-01",
|
||||
from_wkt<MP>("MULTIPOINT(0 0,1 0)"),
|
||||
from_wkt<MP>("MULTIPOINT(0 0,1 1)"),
|
||||
false);
|
||||
|
||||
tester::apply("mp-mp-02",
|
||||
from_wkt<MP>("MULTIPOINT(0 0,1 0)"),
|
||||
from_wkt<MP>("MULTIPOINT(1 1,2 2)"),
|
||||
true);
|
||||
|
||||
tester::apply("mp-mp-03",
|
||||
from_wkt<MP>("MULTIPOINT()"),
|
||||
from_wkt<MP>("MULTIPOINT(1 1,2 2)"),
|
||||
true);
|
||||
|
||||
tester::apply("mp-mp-04",
|
||||
from_wkt<MP>("MULTIPOINT(0 0,1 0)"),
|
||||
from_wkt<MP>("MULTIPOINT()"),
|
||||
true);
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
|
||||
template <typename CoordinateType>
|
||||
inline void test_pointlike_pointlike()
|
||||
{
|
||||
typedef bg::model::point<CoordinateType, 2, bg::cs::cartesian> point_type;
|
||||
|
||||
test_point_point<point_type>();
|
||||
test_point_multipoint<point_type>();
|
||||
|
||||
test_multipoint_multipoint<point_type>();
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
|
||||
BOOST_AUTO_TEST_CASE( test_pointlike_pointlike_all )
|
||||
{
|
||||
test_pointlike_pointlike<double>();
|
||||
test_pointlike_pointlike<int>();
|
||||
#ifdef HAVE_TTMATH
|
||||
test_pointlike_pointlike<ttmath_big>();
|
||||
#endif
|
||||
}
|
||||
@@ -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 <boost/geometry/geometries/geometries.hpp>
|
||||
#include <boost/geometry/geometries/point_xy.hpp>
|
||||
#include <boost/geometry/strategies/strategies.hpp>
|
||||
|
||||
#include <test_common/test_point.hpp>
|
||||
|
||||
#include <algorithms/overlay/overlay_cases.hpp>
|
||||
|
||||
#include <algorithms/predef_relop.hpp>
|
||||
|
||||
|
||||
template <typename P>
|
||||
void test_all()
|
||||
{
|
||||
typedef bg::model::box<P> box;
|
||||
|
||||
test_disjoint<P, P>("pp1", "point(1 1)", "point(1 1)", false);
|
||||
test_disjoint<P, P>("pp2", "point(1 1)", "point(1.001 1)", true);
|
||||
|
||||
// left-right
|
||||
test_disjoint<box, box>("bb1", "box(1 1, 2 2)", "box(3 1, 4 2)", true);
|
||||
test_disjoint<box, box>("bb2", "box(1 1, 2 2)", "box(2 1, 3 2)", false);
|
||||
test_disjoint<box, box>("bb3", "box(1 1, 2 2)", "box(2 2, 3 3)", false);
|
||||
test_disjoint<box, box>("bb4", "box(1 1, 2 2)", "box(2.001 2, 3 3)", true);
|
||||
|
||||
// up-down
|
||||
test_disjoint<box, box>("bb5", "box(1 1, 2 2)", "box(1 3, 2 4)", true);
|
||||
test_disjoint<box, box>("bb6", "box(1 1, 2 2)", "box(1 2, 2 3)", false);
|
||||
// right-left
|
||||
test_disjoint<box, box>("bb7", "box(1 1, 2 2)", "box(0 1, 1 2)", false);
|
||||
test_disjoint<box, box>("bb8", "box(1 1, 2 2)", "box(0 1, 1 2)", false);
|
||||
|
||||
// point-box
|
||||
test_disjoint<P, box>("pb1", "point(1 1)", "box(0 0, 2 2)", false);
|
||||
test_disjoint<P, box>("pb2", "point(2 2)", "box(0 0, 2 2)", false);
|
||||
test_disjoint<P, box>("pb3", "point(2.0001 2)", "box(1 1, 2 2)", true);
|
||||
test_disjoint<P, box>("pb4", "point(0.9999 2)", "box(1 1, 2 2)", true);
|
||||
|
||||
// box-point (to test reverse compiling)
|
||||
test_disjoint<box, P>("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<P> polygon;
|
||||
typedef bg::model::ring<P> ring;
|
||||
|
||||
// Testing overlap (and test compiling with box)
|
||||
test_disjoint<polygon, polygon>("overlaps_box_pp", overlaps_box[0], overlaps_box[1], false);
|
||||
test_disjoint<box, polygon>("overlaps_box_bp", overlaps_box[0], overlaps_box[1], false);
|
||||
test_disjoint<box, ring>("overlaps_box_br", overlaps_box[0], overlaps_box[1], false);
|
||||
test_disjoint<polygon, box>("overlaps_box_pb", overlaps_box[1], overlaps_box[0], false);
|
||||
test_disjoint<ring, box>("overlaps_box_rb", overlaps_box[1], overlaps_box[0], false);
|
||||
|
||||
test_disjoint<P, ring>("point_ring1", "POINT(0 0)", "POLYGON((0 0,3 3,6 0,0 0))", false);
|
||||
test_disjoint<P, ring>("point_ring2", "POINT(3 1)", "POLYGON((0 0,3 3,6 0,0 0))", false);
|
||||
test_disjoint<P, ring>("point_ring3", "POINT(0 3)", "POLYGON((0 0,3 3,6 0,0 0))", true);
|
||||
test_disjoint<P, polygon>("point_polygon1", "POINT(0 0)", "POLYGON((0 0,3 3,6 0,0 0))", false);
|
||||
test_disjoint<P, polygon>("point_polygon2", "POINT(3 1)", "POLYGON((0 0,3 3,6 0,0 0))", false);
|
||||
test_disjoint<P, polygon>("point_polygon3", "POINT(0 3)", "POLYGON((0 0,3 3,6 0,0 0))", true);
|
||||
|
||||
test_disjoint<ring, P>("point_ring2", "POLYGON((0 0,3 3,6 0,0 0))", "POINT(0 0)", false);
|
||||
test_disjoint<polygon, P>("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<polygon, box>("volker_albert_1",
|
||||
"POLYGON((1992 3240,1992 1440,3792 1800,3792 3240,1992 3240))",
|
||||
"BOX(1941 2066, 2055 2166)", false);
|
||||
|
||||
test_disjoint<polygon, box>("volker_albert_2",
|
||||
"POLYGON((1941 2066,2055 2066,2055 2166,1941 2166))",
|
||||
"BOX(1941 2066, 2055 2166)", false);
|
||||
}
|
||||
|
||||
|
||||
template <typename P>
|
||||
void test_3d()
|
||||
{
|
||||
typedef bg::model::box<P> box;
|
||||
|
||||
test_disjoint<P, P>("pp 3d 1", "point(1 1 1)", "point(1 1 1)", false);
|
||||
test_disjoint<P, P>("pp 3d 2", "point(1 1 1)", "point(1.001 1 1)", true);
|
||||
|
||||
test_disjoint<box, box>("bb1", "box(1 1 1, 2 2 2)", "box(3 1 1, 4 2 1)", true);
|
||||
test_disjoint<box, box>("bb2", "box(1 1 1, 2 2 2)", "box(2 1 1, 3 2 1)", false);
|
||||
test_disjoint<box, box>("bb3", "box(1 1 1, 2 2 2)", "box(2 2 1, 3 3 1)", false);
|
||||
test_disjoint<box, box>("bb4", "box(1 1 1, 2 2 2)", "box(2.001 2 1, 3 3 1)", true);
|
||||
|
||||
}
|
||||
|
||||
int test_main(int, char* [])
|
||||
{
|
||||
test_all<bg::model::d2::point_xy<float> >();
|
||||
test_all<bg::model::d2::point_xy<double> >();
|
||||
|
||||
#ifdef HAVE_TTMATH
|
||||
test_all<bg::model::d2::point_xy<ttmath_big> >();
|
||||
#endif
|
||||
|
||||
test_3d<bg::model::point<double, 3, bg::cs::cartesian> >();
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
24
test/algorithms/relational_operations/intersects/Jamfile.v2
Normal file
24
test/algorithms/relational_operations/intersects/Jamfile.v2
Normal file
@@ -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 ]
|
||||
;
|
||||
|
||||
@@ -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<P> polygon;
|
||||
typedef bg::model::ring<P> ring;
|
||||
|
||||
// intersect <=> ! disjoint (in most cases)
|
||||
// so most tests are done in disjoint test.
|
||||
// We only test compilation of a few cases.
|
||||
test_geometry<P, bg::model::box<P> >("POINT(1 1)", "BOX(0 0,2 2)", true);
|
||||
|
||||
test_geometry<polygon, bg::model::box<P> >(
|
||||
"POLYGON((1992 3240,1992 1440,3792 1800,3792 3240,1992 3240))",
|
||||
"BOX(1941 2066, 2055 2166)", true);
|
||||
|
||||
test_geometry<ring, bg::model::box<P> >(
|
||||
"POLYGON((1992 3240,1992 1440,3792 1800,3792 3240,1992 3240))",
|
||||
"BOX(1941 2066, 2055 2166)", true);
|
||||
|
||||
test_geometry<polygon, bg::model::box<P> >(
|
||||
"POLYGON((1941 2066,2055 2066,2055 2166,1941 2166))",
|
||||
"BOX(1941 2066, 2055 2166)", true);
|
||||
|
||||
test_intersects_point_segment<P>();
|
||||
test_intersects_point_linestring<P>();
|
||||
test_intersects_polygon_polygon<P>();
|
||||
@@ -193,157 +176,28 @@ void test_all()
|
||||
test_multi_linestring_polygon<P>();
|
||||
test_multi_polygon_polygon<P>();
|
||||
|
||||
// self-intersecting is not tested in disjoint, so that is done here.
|
||||
|
||||
// Just a normal polygon
|
||||
test_self_intersects<polygon>("POLYGON((0 0,0 4,1.5 2.5,2.5 1.5,4 0,0 0))", false);
|
||||
|
||||
// Self intersecting
|
||||
test_self_intersects<polygon>("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>("POLYGON((0 2,2 4,2 0,4 2,0 2))", true);
|
||||
|
||||
// Self tangent
|
||||
test_self_intersects<polygon>("POLYGON((0 0,0 4,4 4,4 0,2 4,0 0))", true);
|
||||
|
||||
// Self tangent in corner
|
||||
test_self_intersects<polygon>("POLYGON((0 0,0 4,4 4,4 0,0 4,2 0,0 0))", true);
|
||||
|
||||
// With spike
|
||||
test_self_intersects<polygon>("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>("POLYGON((0 0,0 4,4 0,4 0,0 0))", false);
|
||||
|
||||
// With many duplicates
|
||||
test_self_intersects<polygon>(
|
||||
"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>("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>("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>(
|
||||
"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<bg::model::linestring<P> >(
|
||||
"LINESTRING(0 0,0 4,4 4,2 2,2 5)", true);
|
||||
|
||||
test_self_intersects<bg::model::linestring<P> >(
|
||||
"LINESTRING(0 4,4 4,2 2,2 5)", true);
|
||||
|
||||
// Test self-intersections at last segment in close/open rings:
|
||||
test_self_intersects<bg::model::ring<P> >(
|
||||
"POLYGON((0 0,3 3,4 1,0 0))", false);
|
||||
|
||||
test_self_intersects<bg::model::ring<P, true, false> >(
|
||||
"POLYGON((0 0,3 3,4 1))", false);
|
||||
|
||||
test_self_intersects<bg::model::ring<P> >(
|
||||
"POLYGON((0 0,3 3,4 1,0 1,0 0))", true);
|
||||
|
||||
test_self_intersects<bg::model::ring<P, true, false> >(
|
||||
"POLYGON((0 0,3 3,4 1,0 1))", true);
|
||||
|
||||
// Duplicates in first or last
|
||||
test_self_intersects<bg::model::ring<P> >(
|
||||
"POLYGON((0 0,3 3,4 1,0 1,0 1,0 0))", true);
|
||||
test_self_intersects<bg::model::ring<P> >(
|
||||
"POLYGON((0 0,3 3,4 1,0 1,0 0,0 0))", true);
|
||||
test_self_intersects<bg::model::ring<P, true, false> >(
|
||||
"POLYGON((0 0,3 3,4 1,0 1,0 1))", true);
|
||||
test_self_intersects<bg::model::ring<P> >(
|
||||
"POLYGON((0 0,0 0,3 3,4 1,0 1,0 1,0 0))", true);
|
||||
test_self_intersects<bg::model::ring<P, true, false> >(
|
||||
"POLYGON((0 0,0 0,3 3,4 1,0 1,0 1))", true);
|
||||
test_self_intersects<bg::model::ring<P> >(
|
||||
"POLYGON((0 0,3 3,3 3,4 1,0 1,0 1,0 0))", true);
|
||||
test_self_intersects<bg::model::ring<P, true, false> >(
|
||||
"POLYGON((0 0,3 3,3 3,4 1,0 1,0 1))", true);
|
||||
|
||||
test_self_intersects<bg::model::ring<P> >(
|
||||
"POLYGON((0 0,3 3,4 1,0 0,0 0))", false);
|
||||
test_self_intersects<bg::model::ring<P> >(
|
||||
"POLYGON((0 0,3 3,4 1,4 1,0 0))", false);
|
||||
test_self_intersects<bg::model::ring<P, true, false> >(
|
||||
"POLYGON((0 0,3 3,4 1,4 1))", false);
|
||||
test_self_intersects<bg::model::ring<P> >(
|
||||
"POLYGON((0 0,0 0,3 3,4 1,0 0))", false);
|
||||
test_self_intersects<bg::model::ring<P, true, false> >(
|
||||
"POLYGON((0 0,0 0,3 3,4 1))", false);
|
||||
test_self_intersects<bg::model::ring<P> >(
|
||||
"POLYGON((0 0,3 3,3 3,4 1,0 0))", false);
|
||||
test_self_intersects<bg::model::ring<P, true, false> >(
|
||||
"POLYGON((0 0,3 3,3 3,4 1))", false);
|
||||
|
||||
test_geometry<P, bg::model::box<P> >(
|
||||
"POINT(0 0)",
|
||||
"BOX(0 0,4 4)",
|
||||
true);
|
||||
test_geometry<P, bg::model::ring<P> >(
|
||||
test_geometry<P, ring>(
|
||||
"POINT(0 0)",
|
||||
"POLYGON((0 0,3 3,3 3,4 1))",
|
||||
true);
|
||||
test_geometry<P, bg::model::polygon<P> >(
|
||||
test_geometry<P, polygon>(
|
||||
"POINT(0 0)",
|
||||
"POLYGON((0 0,3 3,3 3,4 1))",
|
||||
true);
|
||||
|
||||
test_geometry<bg::model::ring<P>, P>(
|
||||
test_geometry<ring, P>(
|
||||
"POLYGON((0 0,3 3,3 3,4 1))",
|
||||
"POINT(0 0)",
|
||||
true);
|
||||
test_geometry<bg::model::polygon<P>, P>(
|
||||
test_geometry<polygon, P>(
|
||||
"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 <typename P>
|
||||
void test_additional()
|
||||
{
|
||||
test_geometry<bg::model::segment<P>, bg::model::box<P> >(
|
||||
"SEGMENT(0 0,3 3)",
|
||||
"BOX(1 2,3 5)",
|
||||
true);
|
||||
test_geometry<bg::model::segment<P>, bg::model::box<P> >(
|
||||
"SEGMENT(1 1,2 3)",
|
||||
"BOX(0 0,4 4)",
|
||||
true);
|
||||
test_geometry<bg::model::segment<P>, bg::model::box<P> >(
|
||||
"SEGMENT(1 1,1 1)",
|
||||
"BOX(1 0,3 5)",
|
||||
true);
|
||||
test_geometry<bg::model::segment<P>, bg::model::box<P> >(
|
||||
"SEGMENT(0 1,0 1)",
|
||||
"BOX(1 0,3 5)",
|
||||
false);
|
||||
test_geometry<bg::model::segment<P>, bg::model::box<P> >(
|
||||
"SEGMENT(2 1,2 1)",
|
||||
"BOX(1 0,3 5)",
|
||||
true);
|
||||
test_geometry<bg::model::linestring<P>, bg::model::box<P> >(
|
||||
"LINESTRING(0 0,1 0,10 10)",
|
||||
"BOX(1 2,3 5)",
|
||||
true);
|
||||
test_geometry<bg::model::linestring<P>, bg::model::box<P> >(
|
||||
"LINESTRING(1 2)",
|
||||
"BOX(0 0,3 5)",
|
||||
true);
|
||||
}
|
||||
|
||||
|
||||
int test_main( int , char* [] )
|
||||
{
|
||||
test_all<bg::model::d2::point_xy<double> >();
|
||||
test_additional<bg::model::d2::point_xy<double> >();
|
||||
|
||||
#if ! defined(BOOST_GEOMETRY_RESCALE_TO_ROBUST)
|
||||
test_all<bg::model::d2::point_xy<boost::rational<int> > >();
|
||||
@@ -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 <boost/geometry/geometries/geometries.hpp>
|
||||
#include <boost/geometry/geometries/point_xy.hpp>
|
||||
|
||||
#include <boost/geometry/util/rational.hpp>
|
||||
|
||||
|
||||
template <typename P>
|
||||
void test_all()
|
||||
{
|
||||
typedef bg::model::polygon<P> polygon;
|
||||
typedef bg::model::ring<P> ring;
|
||||
|
||||
// intersect <=> ! disjoint (in most cases)
|
||||
// so most tests are done in disjoint test.
|
||||
// We only test compilation of a few cases.
|
||||
test_geometry<P, bg::model::box<P> >("POINT(1 1)", "BOX(0 0,2 2)", true);
|
||||
|
||||
test_geometry<polygon, bg::model::box<P> >(
|
||||
"POLYGON((1992 3240,1992 1440,3792 1800,3792 3240,1992 3240))",
|
||||
"BOX(1941 2066, 2055 2166)", true);
|
||||
|
||||
test_geometry<ring, bg::model::box<P> >(
|
||||
"POLYGON((1992 3240,1992 1440,3792 1800,3792 3240,1992 3240))",
|
||||
"BOX(1941 2066, 2055 2166)", true);
|
||||
|
||||
test_geometry<polygon, bg::model::box<P> >(
|
||||
"POLYGON((1941 2066,2055 2066,2055 2166,1941 2166))",
|
||||
"BOX(1941 2066, 2055 2166)", true);
|
||||
|
||||
test_geometry<P, bg::model::box<P> >(
|
||||
"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 <typename P>
|
||||
void test_additional()
|
||||
{
|
||||
test_geometry<bg::model::segment<P>, bg::model::box<P> >(
|
||||
"SEGMENT(0 0,3 3)",
|
||||
"BOX(1 2,3 5)",
|
||||
true);
|
||||
test_geometry<bg::model::segment<P>, bg::model::box<P> >(
|
||||
"SEGMENT(1 1,2 3)",
|
||||
"BOX(0 0,4 4)",
|
||||
true);
|
||||
test_geometry<bg::model::segment<P>, bg::model::box<P> >(
|
||||
"SEGMENT(1 1,1 1)",
|
||||
"BOX(1 0,3 5)",
|
||||
true);
|
||||
test_geometry<bg::model::segment<P>, bg::model::box<P> >(
|
||||
"SEGMENT(0 1,0 1)",
|
||||
"BOX(1 0,3 5)",
|
||||
false);
|
||||
test_geometry<bg::model::segment<P>, bg::model::box<P> >(
|
||||
"SEGMENT(2 1,2 1)",
|
||||
"BOX(1 0,3 5)",
|
||||
true);
|
||||
test_geometry<bg::model::linestring<P>, bg::model::box<P> >(
|
||||
"LINESTRING(0 0,1 0,10 10)",
|
||||
"BOX(1 2,3 5)",
|
||||
true);
|
||||
test_geometry<bg::model::linestring<P>, bg::model::box<P> >(
|
||||
"LINESTRING(1 2)",
|
||||
"BOX(0 0,3 5)",
|
||||
true);
|
||||
}
|
||||
|
||||
|
||||
int test_main( int , char* [] )
|
||||
{
|
||||
test_all<bg::model::d2::point_xy<double> >();
|
||||
test_additional<bg::model::d2::point_xy<double> >();
|
||||
|
||||
#if ! defined(BOOST_GEOMETRY_RESCALE_TO_ROBUST)
|
||||
test_all<bg::model::d2::point_xy<boost::rational<int> > >();
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_TTMATH)
|
||||
test_all<bg::model::d2::point_xy<ttmath_big> >();
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -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 <boost/geometry/geometries/geometries.hpp>
|
||||
#include <boost/geometry/geometries/point_xy.hpp>
|
||||
|
||||
#include <boost/geometry/util/rational.hpp>
|
||||
|
||||
|
||||
template <typename P>
|
||||
void test_all()
|
||||
{
|
||||
typedef bg::model::linestring<P> linestring;
|
||||
typedef bg::model::polygon<P> polygon;
|
||||
typedef bg::model::ring<P> ring;
|
||||
typedef bg::model::ring<P, true, false> ring_open;
|
||||
|
||||
// self-intersecting is not tested in disjoint, so that is done here.
|
||||
|
||||
// Just a normal polygon
|
||||
test_self_intersects<polygon>("POLYGON((0 0,0 4,1.5 2.5,2.5 1.5,4 0,0 0))", false);
|
||||
|
||||
// Self intersecting
|
||||
test_self_intersects<polygon>("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>("POLYGON((0 2,2 4,2 0,4 2,0 2))", true);
|
||||
|
||||
// Self tangent
|
||||
test_self_intersects<polygon>("POLYGON((0 0,0 4,4 4,4 0,2 4,0 0))", true);
|
||||
|
||||
// Self tangent in corner
|
||||
test_self_intersects<polygon>("POLYGON((0 0,0 4,4 4,4 0,0 4,2 0,0 0))", true);
|
||||
|
||||
// With spike
|
||||
test_self_intersects<polygon>("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>("POLYGON((0 0,0 4,4 0,4 0,0 0))", false);
|
||||
|
||||
// With many duplicates
|
||||
test_self_intersects<polygon>(
|
||||
"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>("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>("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>(
|
||||
"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>(
|
||||
"LINESTRING(0 0,0 4,4 4,2 2,2 5)", true);
|
||||
|
||||
test_self_intersects<linestring>(
|
||||
"LINESTRING(0 4,4 4,2 2,2 5)", true);
|
||||
|
||||
// Test self-intersections at last segment in close/open rings:
|
||||
test_self_intersects<ring>(
|
||||
"POLYGON((0 0,3 3,4 1,0 0))", false);
|
||||
|
||||
test_self_intersects<ring_open>(
|
||||
"POLYGON((0 0,3 3,4 1))", false);
|
||||
|
||||
test_self_intersects<ring>(
|
||||
"POLYGON((0 0,3 3,4 1,0 1,0 0))", true);
|
||||
|
||||
test_self_intersects<ring_open>(
|
||||
"POLYGON((0 0,3 3,4 1,0 1))", true);
|
||||
|
||||
// Duplicates in first or last
|
||||
test_self_intersects<ring>(
|
||||
"POLYGON((0 0,3 3,4 1,0 1,0 1,0 0))", true);
|
||||
test_self_intersects<ring>(
|
||||
"POLYGON((0 0,3 3,4 1,0 1,0 0,0 0))", true);
|
||||
test_self_intersects<ring_open>(
|
||||
"POLYGON((0 0,3 3,4 1,0 1,0 1))", true);
|
||||
test_self_intersects<ring>(
|
||||
"POLYGON((0 0,0 0,3 3,4 1,0 1,0 1,0 0))", true);
|
||||
test_self_intersects<ring_open>(
|
||||
"POLYGON((0 0,0 0,3 3,4 1,0 1,0 1))", true);
|
||||
test_self_intersects<ring>(
|
||||
"POLYGON((0 0,3 3,3 3,4 1,0 1,0 1,0 0))", true);
|
||||
test_self_intersects<ring_open>(
|
||||
"POLYGON((0 0,3 3,3 3,4 1,0 1,0 1))", true);
|
||||
|
||||
test_self_intersects<ring>(
|
||||
"POLYGON((0 0,3 3,4 1,0 0,0 0))", false);
|
||||
test_self_intersects<ring>(
|
||||
"POLYGON((0 0,3 3,4 1,4 1,0 0))", false);
|
||||
test_self_intersects<ring_open>(
|
||||
"POLYGON((0 0,3 3,4 1,4 1))", false);
|
||||
test_self_intersects<ring>(
|
||||
"POLYGON((0 0,0 0,3 3,4 1,0 0))", false);
|
||||
test_self_intersects<ring_open>(
|
||||
"POLYGON((0 0,0 0,3 3,4 1))", false);
|
||||
test_self_intersects<ring>(
|
||||
"POLYGON((0 0,3 3,3 3,4 1,0 0))", false);
|
||||
test_self_intersects<ring_open>(
|
||||
"POLYGON((0 0,3 3,3 3,4 1))", false);
|
||||
}
|
||||
|
||||
int test_main( int , char* [] )
|
||||
{
|
||||
test_all<bg::model::d2::point_xy<double> >();
|
||||
|
||||
#if ! defined(BOOST_GEOMETRY_RESCALE_TO_ROBUST)
|
||||
test_all<bg::model::d2::point_xy<boost::rational<int> > >();
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_TTMATH)
|
||||
test_all<bg::model::d2::point_xy<ttmath_big> >();
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
23
test/algorithms/relational_operations/overlaps/Jamfile.v2
Normal file
23
test/algorithms/relational_operations/overlaps/Jamfile.v2
Normal file
@@ -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 ]
|
||||
;
|
||||
|
||||
56
test/algorithms/relational_operations/overlaps/overlaps.cpp
Normal file
56
test/algorithms/relational_operations/overlaps/overlaps.cpp
Normal file
@@ -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 <typename P>
|
||||
void test_pp()
|
||||
{
|
||||
typedef bg::model::multi_point<P> mpt;
|
||||
|
||||
test_geometry<mpt, mpt>("MULTIPOINT(0 0,1 1,2 2)", "MULTIPOINT(1 1,3 3,4 4)", true);
|
||||
test_geometry<mpt, mpt>("MULTIPOINT(0 0,1 1,2 2)", "MULTIPOINT(1 1,2 2)", false);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
void test_ll()
|
||||
{
|
||||
typedef bg::model::linestring<P> ls;
|
||||
typedef bg::model::multi_linestring<ls> mls;
|
||||
|
||||
test_geometry<ls, ls>("LINESTRING(0 0,2 2,3 1)", "LINESTRING(1 1,2 2,4 4)", true);
|
||||
test_geometry<ls, ls>("LINESTRING(0 0,2 2,4 0)", "LINESTRING(0 1,2 1,3 2)", false);
|
||||
|
||||
test_geometry<ls, mls>("LINESTRING(0 0,2 2,3 1)", "MULTILINESTRING((1 1,2 2),(2 2,4 4))", true);
|
||||
test_geometry<ls, mls>("LINESTRING(0 0,2 2,3 1)", "MULTILINESTRING((1 1,2 2),(3 3,4 4))", true);
|
||||
test_geometry<ls, mls>("LINESTRING(0 0,3 3,3 1)", "MULTILINESTRING((3 3,2 2),(0 0,1 1))", false);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
void test_2d()
|
||||
{
|
||||
test_pp<P>();
|
||||
test_ll<P>();
|
||||
}
|
||||
|
||||
int test_main( int , char* [] )
|
||||
{
|
||||
test_2d<bg::model::d2::point_xy<int> >();
|
||||
test_2d<bg::model::d2::point_xy<double> >();
|
||||
|
||||
#if defined(HAVE_TTMATH)
|
||||
test_2d<bg::model::d2::point_xy<ttmath_big> >();
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -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 <typename P>
|
||||
void test_box_box_2d()
|
||||
{
|
||||
#if defined(BOOST_GEOMETRY_COMPILE_FAIL)
|
||||
test_geometry<P, P>("POINT(1 1)", "POINT(1 1)", true);
|
||||
#endif
|
||||
|
||||
test_geometry<bg::model::box<P>, bg::model::box<P> >("BOX(1 1, 3 3)", "BOX(0 0,2 2)", true);
|
||||
|
||||
// touch -> false
|
||||
test_geometry<bg::model::box<P>, bg::model::box<P> >("BOX(1 1, 3 3)", "BOX(3 3,5 5)", false);
|
||||
|
||||
// disjoint -> false
|
||||
test_geometry<bg::model::box<P>, bg::model::box<P> >("BOX(1 1, 3 3)", "BOX(4 4,6 6)", false);
|
||||
|
||||
// within -> false
|
||||
test_geometry<bg::model::box<P>, bg::model::box<P> >("BOX(1 1, 5 5)", "BOX(2 2,3 3)", false);
|
||||
|
||||
// within+touch -> false
|
||||
test_geometry<bg::model::box<P>, bg::model::box<P> >("BOX(1 1, 5 5)", "BOX(2 2,5 5)", false);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
void test_3d()
|
||||
{
|
||||
test_geometry<bg::model::box<P>, bg::model::box<P> >("BOX(1 1 1, 3 3 3)", "BOX(0 0 0,2 2 2)", true);
|
||||
test_geometry<bg::model::box<P>, bg::model::box<P> >("BOX(1 1 1, 3 3 3)", "BOX(3 3 3,5 5 5)", false);
|
||||
test_geometry<bg::model::box<P>, bg::model::box<P> >("BOX(1 1 1, 3 3 3)", "BOX(4 4 4,6 6 6)", false);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
void test_pp()
|
||||
{
|
||||
typedef bg::model::multi_point<P> mpt;
|
||||
|
||||
test_geometry<mpt, mpt>("MULTIPOINT(0 0,1 1,2 2)", "MULTIPOINT(1 1,3 3,4 4)", true);
|
||||
test_geometry<mpt, mpt>("MULTIPOINT(0 0,1 1,2 2)", "MULTIPOINT(1 1,2 2)", false);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
void test_ll()
|
||||
{
|
||||
typedef bg::model::linestring<P> ls;
|
||||
typedef bg::model::multi_linestring<ls> mls;
|
||||
|
||||
test_geometry<ls, ls>("LINESTRING(0 0,2 2,3 1)", "LINESTRING(1 1,2 2,4 4)", true);
|
||||
test_geometry<ls, ls>("LINESTRING(0 0,2 2,4 0)", "LINESTRING(0 1,2 1,3 2)", false);
|
||||
|
||||
test_geometry<ls, mls>("LINESTRING(0 0,2 2,3 1)", "MULTILINESTRING((1 1,2 2),(2 2,4 4))", true);
|
||||
test_geometry<ls, mls>("LINESTRING(0 0,2 2,3 1)", "MULTILINESTRING((1 1,2 2),(3 3,4 4))", true);
|
||||
test_geometry<ls, mls>("LINESTRING(0 0,3 3,3 1)", "MULTILINESTRING((3 3,2 2),(0 0,1 1))", false);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
void test_aa()
|
||||
{
|
||||
@@ -102,11 +49,7 @@ void test_aa()
|
||||
template <typename P>
|
||||
void test_2d()
|
||||
{
|
||||
test_pp<P>();
|
||||
test_ll<P>();
|
||||
test_aa<P>();
|
||||
|
||||
test_box_box_2d<P>();
|
||||
}
|
||||
|
||||
int test_main( int , char* [] )
|
||||
@@ -118,7 +61,5 @@ int test_main( int , char* [] )
|
||||
test_2d<bg::model::d2::point_xy<ttmath_big> >();
|
||||
#endif
|
||||
|
||||
//test_3d<bg::model::point<double, 3, bg::cs::cartesian> >();
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -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 <typename P>
|
||||
void test_box_box_2d()
|
||||
{
|
||||
#if defined(BOOST_GEOMETRY_COMPILE_FAIL)
|
||||
test_geometry<P, P>("POINT(1 1)", "POINT(1 1)", true);
|
||||
#endif
|
||||
|
||||
test_geometry<bg::model::box<P>, bg::model::box<P> >("BOX(1 1, 3 3)", "BOX(0 0,2 2)", true);
|
||||
|
||||
// touch -> false
|
||||
test_geometry<bg::model::box<P>, bg::model::box<P> >("BOX(1 1, 3 3)", "BOX(3 3,5 5)", false);
|
||||
|
||||
// disjoint -> false
|
||||
test_geometry<bg::model::box<P>, bg::model::box<P> >("BOX(1 1, 3 3)", "BOX(4 4,6 6)", false);
|
||||
|
||||
// within -> false
|
||||
test_geometry<bg::model::box<P>, bg::model::box<P> >("BOX(1 1, 5 5)", "BOX(2 2,3 3)", false);
|
||||
|
||||
// within+touch -> false
|
||||
test_geometry<bg::model::box<P>, bg::model::box<P> >("BOX(1 1, 5 5)", "BOX(2 2,5 5)", false);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
void test_3d()
|
||||
{
|
||||
test_geometry<bg::model::box<P>, bg::model::box<P> >("BOX(1 1 1, 3 3 3)", "BOX(0 0 0,2 2 2)", true);
|
||||
test_geometry<bg::model::box<P>, bg::model::box<P> >("BOX(1 1 1, 3 3 3)", "BOX(3 3 3,5 5 5)", false);
|
||||
test_geometry<bg::model::box<P>, bg::model::box<P> >("BOX(1 1 1, 3 3 3)", "BOX(4 4 4,6 6 6)", false);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
void test_2d()
|
||||
{
|
||||
test_box_box_2d<P>();
|
||||
}
|
||||
|
||||
int test_main( int , char* [] )
|
||||
{
|
||||
test_2d<bg::model::d2::point_xy<int> >();
|
||||
test_2d<bg::model::d2::point_xy<double> >();
|
||||
|
||||
#if defined(HAVE_TTMATH)
|
||||
test_2d<bg::model::d2::point_xy<ttmath_big> >();
|
||||
#endif
|
||||
|
||||
//test_3d<bg::model::point<double, 3, bg::cs::cartesian> >();
|
||||
|
||||
return 0;
|
||||
}
|
||||
23
test/algorithms/relational_operations/touches/Jamfile.v2
Normal file
23
test/algorithms/relational_operations/touches/Jamfile.v2
Normal file
@@ -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 ]
|
||||
;
|
||||
@@ -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 <typename P>
|
||||
void test_all()
|
||||
{
|
||||
typedef bg::model::box<P> box;
|
||||
typedef bg::model::ring<P> ring;
|
||||
typedef bg::model::polygon<P> polygon;
|
||||
typedef bg::model::linestring<P> linestring;
|
||||
typedef bg::model::multi_polygon<polygon> mpolygon;
|
||||
typedef bg::model::multi_linestring<linestring> mlinestring;
|
||||
|
||||
// Just a normal polygon
|
||||
test_self_touches<polygon>("POLYGON((0 0,0 4,1.5 2.5,2.5 1.5,4 0,0 0))", false);
|
||||
|
||||
// Self intersecting
|
||||
test_self_touches<polygon>("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>("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>("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<polygon, polygon>
|
||||
(
|
||||
@@ -196,35 +183,11 @@ void test_all()
|
||||
test_touches<linestring, mpolygon>("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<mlinestring, mpolygon>("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<box, box>("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<box, box>("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<box, box>("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<box, box>("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<box, box>("POLYGON((5 5,5 5,5 5,5 5,5 5))", "POLYGON((5 5,5 5,5 5,5 5,5 5))", true);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
void test_box_3d()
|
||||
{
|
||||
typedef bg::model::box<P> box;
|
||||
|
||||
check_touches<box, box>(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, box>(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<bg::model::d2::point_xy<double> >();
|
||||
test_box_3d<bg::model::point<double, 3, bg::cs::cartesian> >();
|
||||
|
||||
#if defined(HAVE_TTMATH)
|
||||
test_all<bg::model::d2::point_xy<ttmath_big> >();
|
||||
@@ -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 <typename P>
|
||||
void test_all()
|
||||
{
|
||||
typedef bg::model::box<P> box;
|
||||
|
||||
test_touches<box, box>("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<box, box>("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<box, box>("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<box, box>("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<box, box>("POLYGON((5 5,5 5,5 5,5 5,5 5))", "POLYGON((5 5,5 5,5 5,5 5,5 5))", true);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
void test_box_3d()
|
||||
{
|
||||
typedef bg::model::box<P> box;
|
||||
|
||||
check_touches<box, box>(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, box>(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<bg::model::d2::point_xy<double> >();
|
||||
test_box_3d<bg::model::point<double, 3, bg::cs::cartesian> >();
|
||||
|
||||
#if defined(HAVE_TTMATH)
|
||||
test_all<bg::model::d2::point_xy<ttmath_big> >();
|
||||
#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
|
||||
*/
|
||||
@@ -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 <typename P>
|
||||
void test_all()
|
||||
{
|
||||
typedef bg::model::polygon<P> polygon;
|
||||
|
||||
// Just a normal polygon
|
||||
test_self_touches<polygon>("POLYGON((0 0,0 4,1.5 2.5,2.5 1.5,4 0,0 0))", false);
|
||||
|
||||
// Self intersecting
|
||||
test_self_touches<polygon>("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>("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>("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<bg::model::d2::point_xy<double> >();
|
||||
|
||||
#if defined(HAVE_TTMATH)
|
||||
test_all<bg::model::d2::point_xy<ttmath_big> >();
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user