[DEV] add v1.76.0

This commit is contained in:
2021-10-05 21:37:46 +02:00
parent a97e9ae7d4
commit d0115b733d
45133 changed files with 4744437 additions and 1026325 deletions

View File

@@ -0,0 +1,30 @@
# 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, 2016, 2017.
# Modifications copyright (c) 2014-2017, 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-disjoint
:
[ 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 ]
[ run disjoint_seg_box.cpp : : : : algorithms_disjoint_seg_box ]
[ run disjoint_sph.cpp : : : : algorithms_disjoint_sph ]
;

View File

@@ -0,0 +1,160 @@
// 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()
{
// 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;
// Four times same test with other types
test_disjoint<polygon, polygon>("disjoint_simplex_pp", disjoint_simplex[0], disjoint_simplex[1], true);
test_disjoint<ring, polygon>("disjoint_simplex_rp", disjoint_simplex[0], disjoint_simplex[1], true);
test_disjoint<ring, ring>("disjoint_simplex_rr", disjoint_simplex[0], disjoint_simplex[1], true);
test_disjoint<polygon, ring>("disjoint_simplex_pr", disjoint_simplex[0], disjoint_simplex[1], true);
test_disjoint<polygon, polygon>("ticket_8310a", ticket_8310a[0], ticket_8310a[1], false);
test_disjoint<polygon, polygon>("ticket_8310b", ticket_8310b[0], ticket_8310b[1], false);
test_disjoint<polygon, polygon>("ticket_8310c", ticket_8310c[0], ticket_8310c[1], false);
// Testing touch
test_disjoint<polygon, polygon>("touch_simplex_pp", touch_simplex[0], touch_simplex[1], 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);
// Linear
typedef bg::model::linestring<P> ls;
typedef bg::model::segment<P> segment;
test_disjoint<ls, ls>("ls/ls 1", "linestring(0 0,1 1)", "linestring(1 0,0 1)", false);
test_disjoint<ls, ls>("ls/ls 2", "linestring(0 0,1 1)", "linestring(1 0,2 1)", true);
test_disjoint<segment, segment>("s/s 1", "linestring(0 0,1 1)", "linestring(1 0,0 1)", false);
test_disjoint<segment, segment>("s/s 2", "linestring(0 0,1 1)", "linestring(1 0,2 1)", true);
// Test degenerate segments (patched by Karsten Ahnert on 2012-07-25)
test_disjoint<segment, segment>("s/s 3", "linestring(0 0,0 0)", "linestring(1 0,0 1)", true);
test_disjoint<segment, segment>("s/s 4", "linestring(0 0,0 0)", "linestring(0 0,0 0)", false);
test_disjoint<segment, segment>("s/s 5", "linestring(0 0,0 0)", "linestring(1 0,1 0)", true);
test_disjoint<segment, segment>("s/s 6", "linestring(0 0,0 0)", "linestring(0 1,0 1)", true);
// Collinear opposite
test_disjoint<ls, ls>("ls/ls co", "linestring(0 0,2 2)", "linestring(1 1,0 0)", false);
// Collinear opposite and equal
test_disjoint<ls, ls>("ls/ls co-e", "linestring(0 0,1 1)", "linestring(1 1,0 0)", false);
// Degenerate linestrings
{
// Submitted by Zachary on the Boost.Geometry Mailing List, on 2012-01-29
std::string const a = "linestring(100 10, 0 10)";
std::string const b = "linestring(50 10, 50 10)"; // one point only, with same y-coordinate
std::string const c = "linestring(100 10, 100 10)"; // idem, at left side
test_disjoint<ls, ls>("dls/dls 1", a, b, false);
test_disjoint<ls, ls>("dls/dls 2", b, a, false);
test_disjoint<segment, segment>("ds/ds 1", a, b, false);
test_disjoint<segment, segment>("ds/ds 2", b, a, false);
test_disjoint<ls, ls>("dls/dls 1", a, c, false);
}
// Linestrings making angles normally ignored
{
// These (non-disjoint) cases
// correspond to the test "segment_intersection_collinear"
// Collinear ('a')
// a1---------->a2
// b1--->b2
test_disjoint<ls, ls>("n1", "linestring(2 0,0 6)", "linestring(0 0,2 0)", false);
// a1---------->a2
// b1--->b2
test_disjoint<ls, ls>("n7", "linestring(2 0,6 0)", "linestring(6 0,8 0)", false);
// Collinear - opposite ('f')
// a1---------->a2
// b2<---b1
test_disjoint<ls, ls>("o1", "linestring(2 0,6 0)", "linestring(2 0,0 0)", false);
}
{
// Starting in the middle ('s')
// b2
// ^
// |
// |
// a1--------b1----->a2
test_disjoint<ls, ls>("case_s", "linestring(0 0,4 0)", "linestring(2 0,2 2)", false);
// Collinear, but disjoint
test_disjoint<ls, ls>("c-d", "linestring(2 0,6 0)", "linestring(7 0,8 0)", true);
// Parallel, disjoint
test_disjoint<ls, ls>("c-d", "linestring(2 0,6 0)", "linestring(2 1,6 1)", true);
// Error still there until 1.48 (reported "error", was reported to disjoint, so that's why it did no harm)
test_disjoint<ls, ls>("case_recursive_boxes_1",
"linestring(10 7,10 6)", "linestring(10 10,10 9)", true);
}
// TODO test_disjoint<segment, ls>("s/ls 1", "linestring(0 0,1 1)", "linestring(1 0,0 1)", false);
// TODO test_disjoint<segment, ls>("s/ls 2", "linestring(0 0,1 1)", "linestring(1 0,2 1)", true);
// TODO test_disjoint<ls, segment>("ls/s 1", "linestring(0 0,1 1)", "linestring(1 0,0 1)", false);
// TODO test_disjoint<ls, segment>("ls/s 2", "linestring(0 0,1 1)", "linestring(1 0,2 1)", true);
// 22.01.2015
test_disjoint<ls, ls>("col-op", "LINESTRING(5 5,10 10)", "LINESTRING(6 6,3 3)", false);
test_disjoint<ls, ls>("col-op", "LINESTRING(5 5,2 8)", "LINESTRING(4 6,7 3)", false);
test_disjoint<ls, polygon>("col-op", "LINESTRING(10 10,11 10)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", false);
test_disjoint<ls, polygon>("col-op", "LINESTRING(9 10,11 10)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", false);
// assertion failure in 1.57
test_disjoint<ls, ls>("point_ll_assert_1_57",
"LINESTRING(-2305843009213693956 4611686018427387906, -33 -92, 78 83)",
"LINESTRING(31 -97, -46 57, -20 -4)",
false);
}
int test_main(int, char* [])
{
test_all<bg::model::d2::point_xy<float> >();
test_all<bg::model::d2::point_xy<double> >();
return 0;
}

View File

@@ -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>
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>();
}

View File

@@ -0,0 +1,530 @@
// 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>
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>();
}

View File

@@ -0,0 +1,372 @@
// 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>
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>();
}

View File

@@ -0,0 +1,285 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// Copyright (c) 2014-2017, 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
// Licensed under the Boost Software License version 1.0.
// http://www.boost.org/users/license.html
#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>
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>();
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>();
}

View File

@@ -0,0 +1,384 @@
// 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>
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>();
}

View File

@@ -0,0 +1,180 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// Copyright (c) 2014-2017, 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
// Licensed under the Boost Software License version 1.0.
// http://www.boost.org/users/license.html
#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>
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_point()
{
typedef bg::model::multi_point<P> MP;
typedef test_disjoint tester;
tester::apply("mp-p-01",
from_wkt<MP>("MULTIPOINT(0 0,1 1)"),
from_wkt<P>("POINT(0 0)"),
false);
tester::apply("mp-p-02",
from_wkt<MP>("MULTIPOINT(1 1,2 2)"),
from_wkt<P>("POINT(0 0)"),
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_point<point_type>();
test_multipoint_multipoint<point_type>();
}
//============================================================================
BOOST_AUTO_TEST_CASE( test_pointlike_pointlike_all )
{
test_pointlike_pointlike<double>();
test_pointlike_pointlike<int>();
}

View File

@@ -0,0 +1,125 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// Unit Test
// Copyright (c) 2012-2015 Barend Gehrels, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include "test_disjoint.hpp"
#include <boost/geometry/strategies/strategies.hpp>
#include <boost/geometry/geometries/geometries.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
#include <test_common/test_point.hpp>
#include <algorithms/predef_relop.hpp>
template <typename P>
void test_all()
{
typedef bg::model::linestring<P> ls;
typedef bg::model::multi_linestring<ls> mls;
typedef bg::model::polygon<P> polygon;
typedef bg::model::multi_polygon<polygon> mp;
test_disjoint<mp, mp>("",
"MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)))",
"MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)))",
false);
// True disjoint
test_disjoint<mp, mp>("",
"MULTIPOLYGON(((0 0,0 4,4 4,4 0,0 0)))",
"MULTIPOLYGON(((6 6,6 10,10 10,10 6,6 6)))",
true);
// Touch -> not disjoint
test_disjoint<mp, mp>("",
"MULTIPOLYGON(((0 0,0 5,5 5,5 0,0 0)))",
"MULTIPOLYGON(((5 5,5 10,10 10,10 5,5 5)))",
false);
// Not disjoint but no IP's
test_disjoint<mp, mp>("no_ips",
"MULTIPOLYGON(((2 2,2 8,8 8,8 2,2 2)),((20 0,20 10,30 10,30 0,20 0)))",
"MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)),((22 2,28 2,28 8,22 8,22 2)))",
false);
// Not disjoint and not inside each other (in first ring) but wrapped (in second rings)
test_disjoint<mp, mp>("no_ips2",
"MULTIPOLYGON(((2 2,2 8,8 8,8 2,2 2)),((20 0,20 10,30 10,30 0,20 0)))",
"MULTIPOLYGON(((2 12,2 18,8 18,8 12,2 12)),((22 2,28 2,28 8,22 8,22 2)))",
false);
test_disjoint<mp, mp>("no_ips2_rev",
"MULTIPOLYGON(((2 12,2 18,8 18,8 12,2 12)),((22 2,28 2,28 8,22 8,22 2)))",
"MULTIPOLYGON(((2 2,2 8,8 8,8 2,2 2)),((20 0,20 10,30 10,30 0,20 0)))",
false);
test_disjoint<P, mp>("point_mp1",
"POINT(0 0)",
"MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)))",
false);
test_disjoint<P, mp>("point_mp2",
"POINT(5 5)",
"MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)))",
false);
test_disjoint<P, mp>("point_mp1",
"POINT(11 11)",
"MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)))",
true);
std::string polygon_inside_hole("MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0), (2 2,8 2,8 8,2 8,2 2)),((4 4,4 6,6 6,6 4,4 4)))");
test_disjoint<P, mp>("point_mp_pih1",
"POINT(5 5)",
polygon_inside_hole,
false);
test_disjoint<P, mp>("point_mp_pih2",
"POINT(3 3)",
polygon_inside_hole,
true);
test_disjoint<mp, P>("point_mp1rev",
"MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)))",
"POINT(0 0)",
false);
// assertion failure in 1.57
test_disjoint<ls, mls>("point_l_ml_assert_1_57",
"LINESTRING(-2305843009213693956 4611686018427387906, -33 -92, 78 83)",
"MULTILINESTRING((20 100, 31 -97, -46 57, -20 -4))",
false);
test_disjoint<ls, mls>("point_l_ml_assert_1_57",
"LINESTRING(-2305843009213693956 4611686018427387906, -33 -92, 78 83)",
"MULTILINESTRING((20 100, 31 -97, -46 57, -20 -4),(-71 -4))",
false);
}
int test_main(int, char* [])
{
//test_all<bg::model::d2::point_xy<float> >();
test_all<bg::model::d2::point_xy<double> >();
return 0;
}
/*
with viewy as
(
select geometry::STGeomFromText('MULTIPOLYGON(((2 2,2 8,8 8,8 2,2 2)),((20 0,20 10,30 10,30 0,20 0)))',0) as p
, geometry::STGeomFromText('MULTIPOLYGON(((2 12,2 18,8 18,8 12,2 12)),((22 2,28 2,28 8,22 8,22 2)))',0) as q
)
select p from viewy union all select q from viewy
-- select p.STDisjoint(q) from viewy
*/

View File

@@ -0,0 +1,124 @@
// 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> >();
test_3d<bg::model::point<double, 3, bg::cs::cartesian> >();
return 0;
}

View File

@@ -0,0 +1,296 @@
// Boost.Geometry
// Copyright (c) 2016-2019 Oracle and/or its affiliates.
// Contributed and/or modified by Vissarion Fysikopoulos, 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)
#include <boost/geometry/geometries/box.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/geometries/geometries.hpp>
#include <boost/geometry/geometries/adapted/c_array.hpp>
#include <boost/geometry/geometries/adapted/boost_tuple.hpp>
#include <test_common/test_point.hpp>
#include <boost/geometry/formulas/andoyer_inverse.hpp>
#include <boost/geometry/formulas/thomas_inverse.hpp>
#include <boost/geometry/formulas/vincenty_inverse.hpp>
#include <boost/geometry/strategies/strategies.hpp>
#include <boost/geometry/algorithms/disjoint.hpp>
#include <geometry_test_common.hpp>
#include "test_disjoint_seg_box.hpp"
namespace bg = boost::geometry;
//Tests for disjoint(point, box), disjoint(box, box) and disjoint(segment, box)
template <typename P>
void disjoint_tests_1()
{
test_disjoint<bg::model::box<P>, P>("BOX(1 1,3 3)", "POINT(4 4)", true);
test_disjoint<bg::model::box<P>, P>("BOX(1 1,3 3)", "POINT(2 2)", false);
test_disjoint<bg::model::box<P>, P>("BOX(1 1,3 3)", "POINT(3 3)", false);
test_disjoint<bg::model::box<P>, P>("BOX(1 1,3 3)", "POINT(2 3)", false);
test_disjoint<bg::model::box<P>, bg::model::box<P> >("BOX(1 1,3 3)",
"BOX(1 4,5 5)",
true);
test_disjoint<bg::model::box<P>, bg::model::box<P> >("BOX(1 1,3 3)",
"BOX(2 2,4 4)",
false);
test_disjoint<bg::model::box<P>, bg::model::box<P> >("BOX(1 1,3 3)",
"BOX(3 3,4 4)",
false);
test_disjoint<bg::model::box<P>, bg::model::box<P> >("BOX(1 1,3 3)",
"BOX(2 3,4 4)",
false);
test_disjoint<bg::model::box<P>, bg::model::segment<P> >("BOX(1 1,3 3)",
"SEGMENT(1 4, 5 5)",
true);
test_disjoint<bg::model::box<P>, bg::model::segment<P> >("BOX(1 1,3 3)",
"SEGMENT(3 3, 5 5)",
false);
test_disjoint<bg::model::box<P>, bg::model::segment<P> >("BOX(1 1,3 3)",
"SEGMENT(1 1, 4 1)",
false);
test_disjoint<bg::model::box<P>, bg::model::segment<P> >("BOX(1 1,3 3)",
"SEGMENT(1 2, 5 5)",
false);
test_disjoint<bg::model::box<P>, bg::model::segment<P> >("BOX(1 1,3 3)",
"SEGMENT(1 2, 3 2)",
false);
test_disjoint<bg::model::box<P>, bg::model::segment<P> >("BOX(1 1,3 3)",
"SEGMENT(0 0, 4 0)",
true);
test_disjoint<bg::model::box<P>, bg::model::segment<P> >("BOX(1 1,3 3)",
"SEGMENT(2 2, 4 4)",
false);
test_disjoint<bg::model::box<P>, bg::model::segment<P> >("BOX(1 1,3 3)",
"SEGMENT(4 4, 2 2)",
false);
test_disjoint<bg::model::box<P>, bg::model::segment<P> >("BOX(1 1,3 3)",
"SEGMENT(1.5 1.5, 2 2)",
false);
}
template <typename P>
void disjoint_tests_2(bool expected_result)
{
test_disjoint<bg::model::box<P>, bg::model::segment<P> >("BOX(1 1,3 3)",
"SEGMENT(1 0.999, 10 0.999)",
expected_result);
test_disjoint<bg::model::box<P>, bg::model::segment<P> >("BOX(1 1,3 3)",
"SEGMENT(10 0.999, 1 0.999)",
expected_result);
}
template <typename P>
void disjoint_tests_3(bool expected_result)
{
test_disjoint<bg::model::box<P>, bg::model::segment<P> >("BOX(3 4.42, 100 5)",
"SEGMENT(2 2.9, 100 2.9)",
expected_result);
test_disjoint<bg::model::box<P>, bg::model::segment<P> >("BOX(3 4.42, 100 5)",
"SEGMENT(100 2.9, 2 2.9)",
expected_result);
}
template <typename P>
void disjoint_tests_4(bool expected_result)
{
test_disjoint<bg::model::box<P>, bg::model::segment<P> >("BOX(1 1,3 3)",
"SEGMENT(0 0.99999999, 2 0.99999999)",
expected_result);
test_disjoint<bg::model::box<P>, bg::model::segment<P> >("BOX(1 1,3 3)",
"SEGMENT(2 0.99999999, 0 0.99999999)",
expected_result);
}
template <typename P, typename CT>
void disjoint_tests_with_strategy(bool expected_result)
{
bg::strategy::disjoint::segment_box_geographic
<
bg::strategy::andoyer,
bg::srs::spheroid<CT>,
CT
> geographic_andoyer;
bg::strategy::disjoint::segment_box_geographic
<
bg::strategy::thomas,
bg::srs::spheroid<CT>,
CT
> geographic_thomas;
bg::strategy::disjoint::segment_box_geographic
<
bg::strategy::vincenty,
bg::srs::spheroid<CT>,
CT
> geographic_vincenty;
test_disjoint_strategy<bg::model::box<P>, bg::model::segment<P> >
("BOX(1 1,3 3)", "SEGMENT(1 0.999, 10 0.999)",
expected_result, geographic_andoyer);
test_disjoint_strategy<bg::model::box<P>, bg::model::segment<P> >
("BOX(1 1,3 3)", "SEGMENT(1 0.999, 10 0.999)",
expected_result, geographic_thomas);
test_disjoint_strategy<bg::model::box<P>, bg::model::segment<P> >
("BOX(1 1,3 3)", "SEGMENT(1 0.999, 10 0.999)",
expected_result, geographic_vincenty);
}
template <typename P>
void disjoint_tests_sph_geo()
{
//Case A: box intersects without containing the vertex
test_disjoint<bg::model::box<P>, bg::model::segment<P> >("BOX(0 6, 120 7)",
"SEGMENT(0 5, 120 5)",
false);
test_disjoint<bg::model::box<P>, bg::model::segment<P> >("BOX(0 -6, 120 -7)",
"SEGMENT(0 -5, 120 -5)",
false);
//Case B: box intersects and contains the vertex
test_disjoint<bg::model::box<P>, bg::model::segment<P> >("BOX(0 9, 120 10)",
"SEGMENT(0 5, 120 5)",
false);
test_disjoint<bg::model::box<P>, bg::model::segment<P> >("BOX(0 -10, 120 -9)",
"SEGMENT(0 -5, 120 -5)",
false);
//Case C: bounding boxes disjoint
test_disjoint<bg::model::box<P>, bg::model::segment<P> >("BOX(0 10, 10 20)",
"SEGMENT(0 5, 120 5)",
true);
test_disjoint<bg::model::box<P>, bg::model::segment<P> >("BOX(0 -20, 10 -10)",
"SEGMENT(0 -5, 120 -5)",
true);
//Case D: bounding boxes intersect but box segment are disjoint
test_disjoint<bg::model::box<P>, bg::model::segment<P> >("BOX(0 9, 0.1 20)",
"SEGMENT(0 5, 120 5)",
true);
test_disjoint<bg::model::box<P>, bg::model::segment<P> >("BOX(0 -20, 0.1 -9)",
"SEGMENT(0 -5, 120 -5)",
true);
//Case E: geodesic intersects box but box segment are disjoint
test_disjoint<bg::model::box<P>, bg::model::segment<P> >("BOX(121 0, 122 10)",
"SEGMENT(0 5, 120 5)",
true);
test_disjoint<bg::model::box<P>, bg::model::segment<P> >("BOX(121 -10, 122 0)",
"SEGMENT(0 -5, 120 -5)",
true);
//Case F: segment crosses box
test_disjoint<bg::model::box<P>, bg::model::segment<P> >("BOX(100 0, 110 20)",
"SEGMENT(0 5, 120 5)",
false);
test_disjoint<bg::model::box<P>, bg::model::segment<P> >("BOX(100 -20, 110 0)",
"SEGMENT(0 -5, 120 -5)",
false);
//Case G: box contains one segment endpoint
test_disjoint<bg::model::box<P>, bg::model::segment<P> >("BOX(110 0, 130 10)",
"SEGMENT(0 5, 120 5)",
false);
test_disjoint<bg::model::box<P>, bg::model::segment<P> >("BOX(110 -10, 130 0)",
"SEGMENT(0 -5, 120 -5)",
false);
//Case H: box below segment
test_disjoint<bg::model::box<P>, bg::model::segment<P> >("BOX(50 0, 70 6)",
"SEGMENT(0 5, 120 5)",
true);
test_disjoint<bg::model::box<P>, bg::model::segment<P> >("BOX(50 -6, 70 0)",
"SEGMENT(0 -5, 120 -5)",
true);
//Case I: box contains segment
test_disjoint<bg::model::box<P>, bg::model::segment<P> >("BOX(-10 0, 130 10)",
"SEGMENT(0 5, 120 5)",
false);
test_disjoint<bg::model::box<P>, bg::model::segment<P> >("BOX(-10 -10, 130 0)",
"SEGMENT(0 -5, 120 -5)",
false);
//ascending segment
test_disjoint<bg::model::box<P>, bg::model::segment<P> >("BOX(0 10, 120 10.1)",
"SEGMENT(0 5, 120 5.1)",
false);
//descending segment
test_disjoint<bg::model::box<P>, bg::model::segment<P> >("BOX(0 9.8, 120 10)",
"SEGMENT(0 5, 120 4.9)",
false);
//ascending segment both hemispheres
test_disjoint<bg::model::box<P>, bg::model::segment<P> >("BOX(100 5, 120 6)",
"SEGMENT(0 -1, 120 4.9)",
false);
//descending segment both hemispheres
test_disjoint<bg::model::box<P>, bg::model::segment<P> >("BOX(0 5, 20 6)",
"SEGMENT(0 4.9, 120 -1)",
false);
//https://github.com/boostorg/geometry/issues/579
test_disjoint<bg::model::box<P>, bg::model::segment<P> >("BOX(10 10,20 20)",
"SEGMENT(12 2,12 1)",
true);
test_disjoint<bg::model::box<P>, bg::model::segment<P> >("BOX(10 10,20 20)",
"SEGMENT(12 1,12 2)",
true);
}
template <typename CT>
void test_all()
{
typedef bg::model::d2::point_xy<CT> point;
typedef bg::model::point<CT, 2,
bg::cs::spherical_equatorial<bg::degree> > sph_point;
typedef bg::model::point<CT, 2,
bg::cs::geographic<bg::degree> > geo_point;
disjoint_tests_1<point>();
disjoint_tests_1<sph_point>();
disjoint_tests_1<geo_point>();
disjoint_tests_2<point>(true);
disjoint_tests_2<sph_point>(false);
disjoint_tests_2<geo_point>(false);
//illustrate difference between spherical and geographic computation on same data
disjoint_tests_3<point>(true);
disjoint_tests_3<sph_point>(true);
disjoint_tests_3<geo_point>(false);
disjoint_tests_4<sph_point>(false);
disjoint_tests_4<geo_point>(false);
disjoint_tests_with_strategy<geo_point, CT>(false);
disjoint_tests_sph_geo<sph_point>();
disjoint_tests_sph_geo<geo_point>();
}
int test_main( int , char* [] )
{
test_all<float>();
test_all<double>();
return 0;
}

View File

@@ -0,0 +1,323 @@
// Boost.Geometry
// Copyright (c) 2016, 2019 Oracle and/or its affiliates.
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
// Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include "test_disjoint.hpp"
#include <algorithms/overlay/overlay_cases.hpp>
#include <algorithms/overlay/multi_overlay_cases.hpp>
#include <boost/geometry/geometries/geometries.hpp>
#include <boost/geometry/strategies/strategies.hpp>
template <typename P>
void test_polygon_polygon()
{
typedef bg::model::polygon<P> poly;
typedef bg::model::ring<P> ring;
test_geometry<ring, ring>(case_1[0], case_1[1],
false);
test_geometry<ring, poly>(case_1[0], case_1[1],
false);
test_geometry<poly, poly>(case_1[0], case_1[1],
false);
test_geometry<poly, poly>(case_2[0], case_2[1],
false);
test_geometry<poly, poly>(case_3_sph[0], case_3_sph[1],
false);
test_geometry<poly, poly>(case_3_2_sph[0], case_3_2_sph[1],
false);
test_geometry<poly, poly>(case_4[0], case_4[1],
false);
test_geometry<poly, poly>(case_5[0], case_5[1],
false);
test_geometry<poly, poly>(case_6_sph[0], case_6_sph[1],
false);
test_geometry<poly, poly>(case_7[0], case_7[1],
false);
test_geometry<poly, poly>(case_8_sph[0], case_8_sph[1],
false);
test_geometry<poly, poly>(case_9_sph[0], case_9_sph[1],
false);
test_geometry<poly, poly>(case_10_sph[0], case_10_sph[1],
false);
test_geometry<poly, poly>(case_11_sph[0], case_11_sph[1],
false);
test_geometry<poly, poly>(case_12[0], case_12[1],
false);
test_geometry<poly, poly>(case_13_sph[0], case_13_sph[1],
false);
test_geometry<poly, poly>(case_14_sph[0], case_14_sph[1],
false);
test_geometry<poly, poly>(case_15_sph[0], case_15_sph[1],
false);
test_geometry<poly, poly>(case_16_sph[0], case_16_sph[1],
false);
test_geometry<poly, poly>(case_17_sph[0], case_17_sph[1],
false);
test_geometry<poly, poly>(case_17_sph[1], case_17_sph[0],
false);
test_geometry<poly, poly>(case_18_sph[0], case_18_sph[1],
false);
test_geometry<poly, poly>(case_18_sph[1], case_18_sph[0],
false);
}
template <typename P>
void test_polygon_multi_polygon()
{
typedef bg::model::polygon<P> poly;
typedef bg::model::ring<P> ring;
typedef bg::model::multi_polygon<poly> mpoly;
test_geometry<ring, mpoly>(case_1[0], case_multi_2[0],
false);
test_geometry<poly, mpoly>(case_2[0], case_multi_2[0],
false);
}
template <typename P>
void test_multi_polygon_multi_polygon()
{
typedef bg::model::polygon<P> poly;
typedef bg::model::multi_polygon<poly> mpoly;
test_geometry<mpoly, mpoly>(case_multi_2[0], case_multi_2[1],
false);
}
template <typename P>
void test_linestring_polygon()
{
typedef bg::model::linestring<P> ls;
typedef bg::model::polygon<P> poly;
typedef bg::model::polygon<P> ring;
test_geometry<ls, poly>("LINESTRING(11 0,11 10)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", true);
test_geometry<ls, ring>("LINESTRING(11 0,11 10)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", true);
test_geometry<ls, poly>("LINESTRING(0 0,10 10)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", false);
test_geometry<ls, poly>("LINESTRING(5 0,5 5,10 5)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", false);
test_geometry<ls, poly>("LINESTRING(5 1,5 5,9 5)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", false);
test_geometry<ls, poly>("LINESTRING(11 1,11 5)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", true);
test_geometry<ls, poly>("LINESTRING(9 1,10 5,9 9)",
"POLYGON((0 0,0 10,10 10,10 0,0 0),(10 5,2 8,2 2,10 5))",
false);
test_geometry<ls, poly>("LINESTRING(9 1,10 5,9 9,1 9,1 1,9 1)",
"POLYGON((0 0,0 10,10 10,10 0,0 0),(10 5,2 8,2 2,10 5))",
false);
test_geometry<ls, poly>("LINESTRING(0 0,10 0,10 10,0 10,0 0)",
"POLYGON((0 0,0 10,10 10,10 0,0 0))",
false);
}
template <typename P>
void test_linestring_multi_polygon()
{
typedef bg::model::linestring<P> ls;
typedef bg::model::polygon<P> poly;
typedef bg::model::multi_polygon<poly> mpoly;
test_geometry<ls, mpoly>("LINESTRING(10 1,10 5,10 9)",
"MULTIPOLYGON(((0 20,0 30,10 30,10 20,0 20)),((0 0,0 10,10 10,10 0,0 0),(10 5,2 8,2 2,10 5)))",
false);
}
template <typename P>
void test_multi_linestring_polygon()
{
typedef bg::model::linestring<P> ls;
typedef bg::model::polygon<P> poly;
typedef bg::model::ring<P> ring;
typedef bg::model::multi_linestring<ls> mls;
test_geometry<mls, poly>("MULTILINESTRING((11 11, 20 20),(5 7, 4 1))",
"POLYGON((0 0,0 10,10 10,10 0,0 0),(2 2,4 2,4 4,2 4,2 2))",
false);
test_geometry<mls, ring>("MULTILINESTRING((6 6,15 15),(0 0, 7 7))",
"POLYGON((5 5,5 15,15 15,15 5,5 5))",
false);
test_geometry<mls, poly>("MULTILINESTRING((3 10.031432746397092, 1 5, 1 10.013467818052765, 3 4, 7 8, 6 10.035925377760330, 10 2))",
"POLYGON((0 0,0 10,10 10,10 0,0 0))",
false);
}
template <typename P>
void test_multi_linestring_multi_polygon()
{
typedef bg::model::linestring<P> ls;
typedef bg::model::polygon<P> poly;
typedef bg::model::multi_linestring<ls> mls;
typedef bg::model::multi_polygon<poly> mpoly;
test_geometry<mls, mpoly>("MULTILINESTRING((0 0,10 0,10 10,0 10,0 0),(2 2,5 5,2 8,2 2))",
"MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0),(2 2,5 5,2 8,2 2)))",
false);
test_geometry<mls, mpoly>("MULTILINESTRING((0 0,10 0,10 10),(10 10,0 10,0 0),(20 20,50 50,20 80,20 20))",
"MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)))",
false);
test_geometry<mls, mpoly>("MULTILINESTRING((5 -2,4 -2,5 0),(5 -2,6 -2,5 0))",
"MULTIPOLYGON(((5 0,0 5,10 5,5 0)),((5 0,10 -5,0 -5,5 0)))",
false);
}
template <typename P>
void test_linestring_linestring()
{
typedef bg::model::linestring<P> ls;
test_geometry<ls, ls>("LINESTRING(0 0, 2 2, 3 2)", "LINESTRING(0 0, 2 2, 3 2)", false);
test_geometry<ls, ls>("LINESTRING(1 0,2 2,2 3)", "LINESTRING(0 0, 2 2, 3 2)", false);
}
//https://svn.boost.org/trac10/ticket/13057
template <typename P>
void test_linestring_linestring_radians()
{
typedef bg::model::linestring<P> ls;
test_geometry<ls, ls>("LINESTRING(0 -0.31415926535897897853,\
0.26179938779914918578 0,\
-0.034906585039886556254 0.13962634015954622502,\
-0.12217304763960294689 0.12217304763960294689)",\
"LINESTRING(-0.034906585039886556254 0.13962634015954622502,\
-0.26179938779914918578 0)", false);
}
template <typename P>
void test_linestring_multi_linestring()
{
typedef bg::model::linestring<P> ls;
typedef bg::model::multi_linestring<ls> mls;
test_geometry<ls, mls>("LINESTRING(0 0,10 0)",
"MULTILINESTRING((1 0,2 0),(1 1,2 1))",
false);
test_geometry<ls, mls>("LINESTRING(0 0,5 0,5 5,0 5,0 0)",
"MULTILINESTRING((5 5,0 5,0 0),(0 0,5 0,5 5))",
false);
}
template <typename P>
void test_multi_linestring_multi_linestring()
{
typedef bg::model::linestring<P> ls;
typedef bg::model::multi_linestring<ls> mls;
test_geometry<mls, mls>("MULTILINESTRING((0 0,0 0,18 0,18 0,19 0,19 0,19 0,30 0,30 0))",
"MULTILINESTRING((0 10,5 0,20 0,20 0,30 0))",
false);
}
template <typename P>
void test_point_polygon()
{
typedef bg::model::polygon<P> poly;
// https://svn.boost.org/trac/boost/ticket/9162
test_geometry<P, poly>("POINT(0 90)",
"POLYGON((0 80,-90 80, -180 80, 90 80, 0 80))",
false);
test_geometry<P, poly>("POINT(-120 21)",
"POLYGON((30 0,30 30,90 30, 90 0, 30 0))",
true);
// extended
test_geometry<P, poly>("POINT(0 -90)",
"POLYGON((0 -80,90 -80, -180 -80, -90 -80, 0 -80))",
false);
test_geometry<P, poly>("POINT(0 89)",
"POLYGON((0 80,-90 80, -180 80, 90 80, 0 80))",
false);
test_geometry<P, poly>("POINT(-180 89)",
"POLYGON((0 80,-90 80, -180 80, 90 80, 0 80))",
false);
}
template <typename P>
void test_box_polygon()
{
typedef bg::model::box<P> box;
typedef bg::model::polygon<P> poly;
// https://github.com/boostorg/geometry/issues/466
test_geometry<box, poly>("BOX(2.2 48.88, 2.5 48.9021)",
"POLYGON((2.4 48.90205, 2.4 48.89, 2.3 48.89, 2.3 48.90205, 2.4 48.90205))",
false);
test_geometry<box, poly>("BOX(2.2 48.88, 2.5 48.9021)",
"POLYGON((2.4 48.9021, 2.4 48.89, 2.3 48.89, 2.3 48.9021, 2.4 48.9021))",
false);
test_geometry<box, poly>("BOX(2.2 48.88, 2.5 48.9021)",
"POLYGON((2.4 48.90215, 2.4 48.89, 2.3 48.89, 2.3 48.90215, 2.4 48.90215))",
false);
// extended
test_geometry<box, poly>("BOX(2.2 48.88, 2.5 48.9021)",
"POLYGON((2.4 48.9022, 2.4 48.89, 2.3 48.89, 2.3 48.9022, 2.4 48.9022))",
false);
// box within poly
test_geometry<box, poly>("BOX(2.2 48.88, 2.5 48.9021)",
"POLYGON((2.6 48.9021, 2.6 48.8, 2.1 48.8, 2.1 48.9021, 2.6 48.9021))",
false);
test_geometry<box, poly>("BOX(2.2 48.88, 2.5 48.9021)",
"POLYGON((2.6 48.9022, 2.6 48.8, 2.1 48.8, 2.1 48.9022, 2.6 48.9022))",
false);
// related to https://github.com/boostorg/geometry/issues/579
test_geometry<box, poly>("BOX(10 10,20 20)",
"POLYGON((11 0,10 1,11 2,12 3,13 1,11 0),"
"(12 1,11 1,12 2,12 1))",
true);
}
template <typename P>
void test_all()
{
test_polygon_polygon<P>();
test_polygon_multi_polygon<P>();
test_multi_polygon_multi_polygon<P>();
test_linestring_polygon<P>();
test_linestring_multi_polygon<P>();
test_multi_linestring_polygon<P>();
test_multi_linestring_multi_polygon<P>();
test_linestring_linestring<P>();
test_linestring_multi_linestring<P>();
test_multi_linestring_multi_linestring<P>();
test_point_polygon<P>();
test_box_polygon<P>();
}
int test_main( int , char* [] )
{
typedef bg::model::point<double, 2, bg::cs::spherical_equatorial<bg::degree> > point_deg;
typedef bg::model::point<double, 2, bg::cs::spherical_equatorial<bg::radian> > point_rad;
test_all<point_deg>();
test_linestring_linestring_radians<point_rad>();
return 0;
}

View File

@@ -0,0 +1,112 @@
// 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 2017.
// Modifications copyright (c) 2017 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)
#ifndef BOOST_GEOMETRY_TEST_DISJOINT_HPP
#define BOOST_GEOMETRY_TEST_DISJOINT_HPP
#include <iostream>
#include <string>
#include <boost/variant/variant.hpp>
#include <geometry_test_common.hpp>
#include <boost/geometry/algorithms/disjoint.hpp>
#include <boost/geometry/io/wkt/read.hpp>
struct no_strategy {};
template <typename Geometry1, typename Geometry2, typename Strategy>
bool call_disjoint(Geometry1 const& geometry1,
Geometry2 const& geometry2,
Strategy const& strategy)
{
return bg::disjoint(geometry1, geometry2, strategy);
}
template <typename Geometry1, typename Geometry2>
bool call_disjoint(Geometry1 const& geometry1,
Geometry2 const& geometry2,
no_strategy)
{
return bg::disjoint(geometry1, geometry2);
}
template <typename G1, typename G2, typename Strategy>
void check_disjoint(std::string const& id,
std::string const& wkt1,
std::string const& wkt2,
G1 const& g1,
G2 const& g2,
bool expected,
Strategy const& strategy)
{
bool detected = call_disjoint(g1, g2, strategy);
if (id.empty())
{
BOOST_CHECK_MESSAGE(detected == expected,
"disjoint: " << wkt1 << " and " << wkt2
<< " -> Expected: " << expected
<< " detected: " << detected);
}
else
{
BOOST_CHECK_MESSAGE(detected == expected,
"disjoint: " << id
<< " -> Expected: " << expected
<< " detected: " << detected);
}
}
template <typename G1, typename G2>
void test_disjoint(std::string const& id,
std::string const& wkt1,
std::string const& wkt2,
bool expected)
{
G1 g1;
bg::read_wkt(wkt1, g1);
G2 g2;
bg::read_wkt(wkt2, g2);
boost::variant<G1> v1(g1);
boost::variant<G2> v2(g2);
typedef typename bg::strategy::disjoint::services::default_strategy
<
G1, G2
>::type strategy_type;
check_disjoint(id, wkt1, wkt2, g1, g2, expected, no_strategy());
check_disjoint(id, wkt1, wkt2, g1, g2, expected, strategy_type());
check_disjoint(id, wkt1, wkt2, g1, g2, expected, no_strategy());
check_disjoint(id, wkt1, wkt2, v1, g2, expected, no_strategy());
check_disjoint(id, wkt1, wkt2, g1, v2, expected, no_strategy());
check_disjoint(id, wkt1, wkt2, v1, v2, expected, no_strategy());
}
template <typename G1, typename G2>
void test_geometry(std::string const& wkt1,
std::string const& wkt2,
bool expected)
{
test_disjoint<G1, G2>("", wkt1, wkt2, expected);
}
#endif // BOOST_GEOMETRY_TEST_DISJOINT_HPP

View File

@@ -0,0 +1,62 @@
// Boost.Geometry
// Copyright (c) 2016-2017 Oracle and/or its affiliates.
// Contributed and/or modified by Vissarion Fysikopoulos, 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)
#include <boost/geometry/algorithms/disjoint.hpp>
#include <boost/geometry/algorithms/make.hpp>
#include <boost/geometry/io/wkt/read.hpp>
template <typename Geometry1, typename Geometry2>
inline void test_disjoint_check(bool result, bool expected_result,
Geometry1 const& geometry1, Geometry2 const& geometry2)
{
BOOST_CHECK_MESSAGE((result == expected_result),
"result {" << result << "} different than expected result {"
<< expected_result << "} for geometries "
<< bg::wkt(geometry1) << " and " << bg::wkt(geometry2));
}
template <typename Geometry1, typename Geometry2>
inline void test_disjoint(std::string const& wkt1,
std::string const& wkt2,
bool const expected_result)
{
Geometry1 geometry1;
bg::read_wkt(wkt1, geometry1);
Geometry2 geometry2;
bg::read_wkt(wkt2, geometry2);
test_disjoint_check(bg::disjoint(geometry1, geometry2), expected_result,
geometry1, geometry2);
//reverse
test_disjoint_check(bg::disjoint(geometry2, geometry1), expected_result,
geometry2, geometry1);
}
template <typename Geometry1, typename Geometry2, typename Strategy>
inline void test_disjoint_strategy(std::string const& wkt1,
std::string const& wkt2,
bool const expected_result,
Strategy strategy)
{
Geometry1 geometry1;
bg::read_wkt(wkt1, geometry1);
Geometry2 geometry2;
bg::read_wkt(wkt2, geometry2);
test_disjoint_check(bg::disjoint(geometry1, geometry2, strategy), expected_result,
geometry1, geometry2);
//reverse
test_disjoint_check(bg::disjoint(geometry2, geometry1, strategy), expected_result,
geometry2, geometry1);
}