[DEV] add v1.66.0

This commit is contained in:
2018-01-12 21:47:58 +01:00
parent 87059bb1af
commit a97e9ae7d4
49032 changed files with 7668950 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
# 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.
# Modifications copyright (c) 2014-2016, 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)
build-project covered_by ;
build-project crosses ;
build-project disjoint ;
build-project equals ;
build-project intersects ;
build-project overlaps ;
build-project relate ;
build-project touches ;
build-project within ;

View 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, 2016.
# Modifications copyright (c) 2014-2016, 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-covered_by
:
[ run covered_by.cpp : : : : algorithms_covered_by ]
[ run covered_by_multi.cpp : : : : algorithms_covered_by_multi ]
[ run covered_by_sph.cpp : : : : algorithms_covered_by_sph ]
[ run covered_by_sph_geo.cpp : : : : algorithms_covered_by_sph_geo ]
;

View File

@@ -0,0 +1,197 @@
// 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 2015, 2017.
// Modifications copyright (c) 2017 Oracle and/or its affiliates.
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
// Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include "test_covered_by.hpp"
#include <boost/geometry/geometries/geometries.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
template <typename P>
void test_all()
{
/*
// trivial case
test_ring<P>("POINT(1 1)", "POLYGON((0 0,0 2,2 2,2 0,0 0))", true, false);
// on border/corner
test_ring<P>("POINT(0 0)", "POLYGON((0 0,0 2,2 2,2 0,0 0))", false, true);
test_ring<P>("POINT(0 1)", "POLYGON((0 0,0 2,2 2,2 0,0 0))", false, true);
// aligned to segment/vertex
test_ring<P>("POINT(1 1)", "POLYGON((0 0,0 3,3 3,3 1,2 1,2 0,0 0))", true, false);
test_ring<P>("POINT(1 1)", "POLYGON((0 0,0 3,4 3,3 1,2 2,2 0,0 0))", true, false);
// same polygon, but point on border
test_ring<P>("POINT(3 3)", "POLYGON((0 0,0 3,3 3,3 1,2 1,2 0,0 0))", false, true);
test_ring<P>("POINT(3 3)", "POLYGON((0 0,0 3,4 3,3 1,2 2,2 0,0 0))", false, true);
// holes
test_geometry<P, bg::model::polygon<P> >("POINT(2 2)",
"POLYGON((0 0,0 4,4 4,4 0,0 0),(1 1,3 1,3 3,1 3,1 1))", false);
*/
test_geometry<P, P>("POINT(0 0)", "POINT(0 0)", true);
test_geometry<P, P>("POINT(0 0)", "POINT(1 1)", false);
typedef bg::model::multi_point<P> mpt;
test_geometry<P, mpt>("POINT(0 0)", "MULTIPOINT(0 0, 1 1)", true);
test_geometry<mpt, P>("MULTIPOINT(0 0, 1 1)", "POINT(1 1)", false);
test_geometry<mpt, mpt>("MULTIPOINT(0 0, 1 1)", "MULTIPOINT(1 1, 2 2)", false);
typedef bg::model::segment<P> seg;
test_geometry<P, seg>("POINT(1 1)", "LINESTRING(0 0, 2 2)", true);
test_geometry<P, seg>("POINT(0 0)", "LINESTRING(0 0, 1 1)", true);
test_geometry<P, seg>("POINT(1 0)", "LINESTRING(0 0, 1 1)", false);
// linestrings
typedef bg::model::linestring<P> ls;
test_geometry<P, ls>("POINT(0 0)", "LINESTRING(0 0,1 1,2 2)", true);
test_geometry<P, ls>("POINT(3 3)", "LINESTRING(0 0,1 1,2 2)", false);
test_geometry<P, ls>("POINT(1 1)", "LINESTRING(0 0,2 2,3 3)", true);
// multi_linestrings
typedef bg::model::multi_linestring<ls> mls;
test_geometry<P, mls>("POINT(0 0)", "MULTILINESTRING((0 0,1 1,2 2),(0 0,0 1))", true);
test_geometry<P, mls>("POINT(0 0)", "MULTILINESTRING((0 0,1 1,2 2),(0 0,0 1),(0 0,1 0))", true);
// multi_point/segment
typedef bg::model::multi_point<P> mpt;
test_geometry<mpt, seg>("MULTIPOINT(0 0, 1 1)", "LINESTRING(0 0, 2 2)", true);
// multi_point/linestring
test_geometry<mpt, ls>("MULTIPOINT(0 0, 2 2)", "LINESTRING(0 0, 2 2)", true);
test_geometry<mpt, ls>("MULTIPOINT(1 1, 3 3)", "LINESTRING(0 0, 2 2)", false);
// multi_point/multi_linestring
test_geometry<mpt, mls>("MULTIPOINT(0 0, 1 1)", "MULTILINESTRING((0 0, 2 2),(2 2, 3 3))", true);
test_geometry<mpt, mls>("MULTIPOINT(0 0, 2 2)", "MULTILINESTRING((0 0, 2 2),(2 2, 3 3))", true);
test_geometry<mpt, mls>("MULTIPOINT(0 0, 3 3)", "MULTILINESTRING((0 0, 2 2),(2 2, 3 3))", true);
test_geometry<mpt, mls>("MULTIPOINT(1 1, 4 4)", "MULTILINESTRING((0 0, 2 2),(2 2, 3 3))", false);
// point/A
typedef bg::model::ring<P> ring;
typedef bg::model::polygon<P> poly;
typedef bg::model::multi_polygon<poly> mpoly;
test_geometry<P, ring>("POINT(1 1)", "POLYGON((0 0,0 2,2 2,2 0,0 0))", true);
test_geometry<P, poly>("POINT(1 1)", "POLYGON((0 0,0 2,2 2,2 0,0 0))", true);
test_geometry<P, mpoly>("POINT(1 1)", "MULTIPOLYGON(((0 0,0 2,2 2,2 0,0 0)),((2 2,2 3,3 3,3 2,2 2)))", true);
// multi_point/A
test_geometry<mpt, ring>("MULTIPOINT(0 0, 1 1)", "POLYGON((0 0,0 2,2 2,2 0,0 0))", true);
test_geometry<mpt, poly>("MULTIPOINT(0 0, 2 2)", "POLYGON((0 0,0 2,2 2,2 0,0 0))", true);
test_geometry<mpt, poly>("MULTIPOINT(1 1, 3 3)", "POLYGON((0 0,0 2,2 2,2 0,0 0))", false);
test_geometry<mpt, mpoly>("MULTIPOINT(0 0, 1 1)", "MULTIPOLYGON(((0 0,0 2,2 2,2 0,0 0)),((2 2,2 3,3 3,3 2,2 2)))", true);
test_geometry<mpt, mpoly>("MULTIPOINT(0 0, 2 2)", "MULTIPOLYGON(((0 0,0 2,2 2,2 0,0 0)),((2 2,2 3,3 3,3 2,2 2)))", true);
test_geometry<mpt, mpoly>("MULTIPOINT(0 0, 3 3)", "MULTIPOLYGON(((0 0,0 2,2 2,2 0,0 0)),((2 2,2 3,3 3,3 2,2 2)))", true);
test_geometry<mpt, mpoly>("MULTIPOINT(1 1, 4 4)", "MULTIPOLYGON(((0 0,0 2,2 2,2 0,0 0)),((2 2,2 3,3 3,3 2,2 2)))", false);
typedef bg::model::box<P> box_type;
test_geometry<P, box_type>("POINT(1 1)", "BOX(0 0,2 2)", true);
test_geometry<P, box_type>("POINT(0 0)", "BOX(0 0,2 2)", true);
test_geometry<P, box_type>("POINT(2 2)", "BOX(0 0,2 2)", true);
test_geometry<P, box_type>("POINT(0 1)", "BOX(0 0,2 2)", true);
test_geometry<P, box_type>("POINT(1 0)", "BOX(0 0,2 2)", true);
test_geometry<P, box_type>("POINT(3 3)", "BOX(0 0,2 2)", false);
test_geometry<box_type, box_type>("BOX(1 1,2 2)", "BOX(0 0,3 3)", true);
test_geometry<box_type, box_type>("BOX(0 0,3 3)", "BOX(1 1,2 2)", false);
test_geometry<box_type, box_type>("BOX(0 0,2 2)", "BOX(0 0,3 3)", true);
test_geometry<box_type, box_type>("BOX(1 1,3 3)", "BOX(0 0,3 3)", true);
test_geometry<box_type, box_type>("BOX(1 2,3 3)", "BOX(0 0,3 3)", true);
test_geometry<box_type, box_type>("BOX(1 1,4 3)", "BOX(0 0,3 3)", false);
}
void test_3d()
{
typedef boost::geometry::model::point<double, 3, boost::geometry::cs::cartesian> point_type;
typedef boost::geometry::model::box<point_type> box_type;
box_type box(point_type(0, 0, 0), point_type(4, 4, 4));
BOOST_CHECK_EQUAL(bg::covered_by(point_type(2, 2, 2), box), true);
BOOST_CHECK_EQUAL(bg::covered_by(point_type(2, 4, 2), box), true);
BOOST_CHECK_EQUAL(bg::covered_by(point_type(2, 2, 4), box), true);
BOOST_CHECK_EQUAL(bg::covered_by(point_type(2, 2, 5), box), false);
}
template <typename P1, typename P2>
void test_mixed_of()
{
typedef boost::geometry::model::polygon<P1> polygon_type1;
typedef boost::geometry::model::polygon<P2> polygon_type2;
typedef boost::geometry::model::box<P1> box_type1;
typedef boost::geometry::model::box<P2> box_type2;
polygon_type1 poly1;
polygon_type2 poly2;
boost::geometry::read_wkt("POLYGON((0 0,0 5,5 5,5 0,0 0))", poly1);
boost::geometry::read_wkt("POLYGON((0 0,0 5,5 5,5 0,0 0))", poly2);
box_type1 box1(P1(1, 1), P1(4, 4));
box_type2 box2(P2(0, 0), P2(5, 5));
P1 p1(3, 3);
P2 p2(3, 3);
BOOST_CHECK_EQUAL(bg::covered_by(p1, poly2), true);
BOOST_CHECK_EQUAL(bg::covered_by(p2, poly1), true);
BOOST_CHECK_EQUAL(bg::covered_by(p2, box1), true);
BOOST_CHECK_EQUAL(bg::covered_by(p1, box2), true);
BOOST_CHECK_EQUAL(bg::covered_by(box1, box2), true);
BOOST_CHECK_EQUAL(bg::covered_by(box2, box1), false);
}
void test_mixed()
{
// Mixing point types and coordinate types
test_mixed_of
<
boost::geometry::model::d2::point_xy<double>,
boost::geometry::model::point<double, 2, boost::geometry::cs::cartesian>
>();
test_mixed_of
<
boost::geometry::model::d2::point_xy<float>,
boost::geometry::model::point<double, 2, boost::geometry::cs::cartesian>
>();
test_mixed_of
<
boost::geometry::model::d2::point_xy<int>,
boost::geometry::model::d2::point_xy<double>
>();
}
int test_main( int , char* [] )
{
test_all<bg::model::d2::point_xy<int> >();
test_all<bg::model::d2::point_xy<double> >();
//test_spherical<bg::model::point<double, 2, bg::cs::spherical_equatorial<bg::degree> > >();
test_mixed();
test_3d();
#if defined(HAVE_TTMATH)
test_all<bg::model::d2::point_xy<ttmath_big> >();
test_eps<bg::model::d2::point_xy<ttmath_big> >();
//test_spherical<bg::model::point<ttmath_big, 2, bg::cs::spherical_equatorial<bg::degree> > >();
#endif
return 0;
}

View File

@@ -0,0 +1,56 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
//
// Copyright (c) 2007-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 <geometry_test_common.hpp>
#include <boost/geometry/algorithms/correct.hpp>
#include <boost/geometry/algorithms/covered_by.hpp>
#include <boost/geometry/geometries/box.hpp>
#include <boost/geometry/core/point_order.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/geometries/multi_polygon.hpp>
#include <boost/geometry/io/wkt/wkt.hpp>
#include "test_covered_by.hpp"
template <typename P>
void test_all()
{
typedef bg::model::multi_polygon<bg::model::polygon<P> > mp;
// test multi-with-one-polygon (trivial case)
test_geometry<P, mp>("POINT(1 1)", "MULTIPOLYGON(((0 0,0 2,2 2,2 0,0 0)))", true);
test_geometry<P, mp>("POINT(3 3)", "MULTIPOLYGON(((0 0,0 2,2 2,2 0,0 0)))", false);
test_geometry<P, mp>("POINT(0 1)", "MULTIPOLYGON(((0 0,0 2,2 2,2 0,0 0)))", true);
test_geometry<P, mp>("POINT(4 4)", "MULTIPOLYGON(((0 0,0 2,2 2,2 0,0 0)))", false);
// test if it is in one of them
std::string multi("MULTIPOLYGON("
"((0 0,0 2,2 2,2 0,0 0))"
"((3 3,3 6,6 6,6 3,3 3))"
")");
test_geometry<P, mp>("POINT(4 4)", multi, true);
test_geometry<P, mp>("POINT(1 1)", multi, true);
test_geometry<P, mp>("POINT(0 1)", multi, true);
}
int test_main( int , char* [] )
{
//test_all<bg::model::d2::point_xy<int> >();
test_all<bg::model::d2::point_xy<double> >();
#if defined(HAVE_TTMATH)
test_all<bg::model::d2::point_xy<ttmath_big> >();
#endif
return 0;
}

View File

@@ -0,0 +1,320 @@
// Boost.Geometry
// Copyright (c) 2016 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_covered_by.hpp"
#include <algorithms/overlay/overlay_cases.hpp>
#include <algorithms/overlay/multi_overlay_cases.hpp>
#include <boost/geometry/geometries/geometries.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],
true);
test_geometry<poly, poly>(case_3_2_sph[0], case_3_2_sph[1],
true);
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_6_sph[1], case_6_sph[0],
true);
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_11_sph[1], case_11_sph[0],
true);
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],
true);
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],
true);
}
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))", false);
test_geometry<ls, ring>("LINESTRING(11 0,11 10)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", false);
test_geometry<ls, poly>("LINESTRING(0 0,10 10)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", true);
test_geometry<ls, poly>("LINESTRING(5 0,5 5,10 5)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", true);
test_geometry<ls, poly>("LINESTRING(5 1,5 5,9 5)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", true);
test_geometry<ls, poly>("LINESTRING(11 1,11 5)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", false);
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))",
true);
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))",
true);
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))",
true);
}
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)))",
true);
}
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))",
true);
}
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)))",
true);
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)))",
true);
}
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)", true);
test_geometry<ls, ls>("LINESTRING(1 0,2 2,2 3)", "LINESTRING(0 0, 2 2, 3 2)", 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))",
true);
}
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))",
true);
test_geometry<P, poly>("POINT(-120 21)",
"POLYGON((30 0,30 30,90 30, 90 0, 30 0))",
false);
// extended
test_geometry<P, poly>("POINT(0 90)",
"POLYGON((0 80, 0 81, -90 80, -180 80, 90 80, 0 80))",
true);
test_geometry<P, poly>("POINT(0 90)",
"POLYGON((0 80, -90 80, -90 81, -180 80, 90 80, 0 80))",
true);
test_geometry<P, poly>("POINT(0 89)",
"POLYGON((0 80,-90 80, -180 80, 90 80, 0 80))",
true);
test_geometry<P, poly>("POINT(-180 89)",
"POLYGON((0 80,-90 80, -180 80, 90 80, 0 80))",
true);
test_geometry<P, poly>("POINT(0 -90)",
"POLYGON((0 -80,90 -80, -180 -80, -90 -80, 0 -80))",
true);
test_geometry<P, poly>("POINT(0 -89)",
"POLYGON((0 -80,90 -80, -180 -80, -90 -80, 0 -80))",
true);
test_geometry<P, poly>("POINT(1 -90)",
"POLYGON((0 -80,90 -80, -180 -80, -90 -80, 0 -80))",
true);
test_geometry<P, poly>("POINT(1 -89)",
"POLYGON((0 -80,90 -80, -180 -80, -90 -80, 0 -80))",
true);
test_geometry<P, poly>("POINT(1 90)",
"POLYGON((0 80,-90 80, -180 80, 90 80, 0 80))",
true);
test_geometry<P, poly>("POINT(1 90)",
"POLYGON((0 80,-90 80, -180 80, 90 80, 0 80))",
true);
// MySQL report 08.2017
test_geometry<P, poly>("POINT(-179 0)",
"POLYGON((0 0, 0 2, 2 0, 0 -2, 0 0))",
false);
// extended
test_geometry<P, poly>("POINT(179 0)",
"POLYGON((0 0, 0 2, 2 0, 0 -2, 0 0))",
false);
test_geometry<P, poly>("POINT(180 0)",
"POLYGON((0 0, 0 2, 2 0, 0 -2, 0 0))",
false);
test_geometry<P, poly>("POINT(-179 0)",
"POLYGON((-10 -10, -10 10, 10 10, 10 -10, -10 10))",
false);
test_geometry<P, poly>("POINT(179 0)",
"POLYGON((-10 -10, -10 10, 10 10, 10 -10, -10 10))",
false);
test_geometry<P, poly>("POINT(-179 0)",
"POLYGON((0 0, 0 1, 1 0, 0 -1, 0 0))",
false);
test_geometry<P, poly>("POINT(179 0)",
"POLYGON((0 0, 0 1, 1 0, 0 -1, 0 0))",
false);
}
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>();
}
int test_main( int , char* [] )
{
test_all<bg::model::point<double, 2, bg::cs::spherical_equatorial<bg::degree> > >();
#if defined(HAVE_TTMATH)
test_cs<bg::model::point<ttmath_big, 2, bg::cs::spherical_equatorial<bg::degree> > >();
#endif
return 0;
}

View File

@@ -0,0 +1,132 @@
// Boost.Geometry
// Copyright (c) 2016 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_covered_by.hpp"
#include <boost/geometry/geometries/geometries.hpp>
template <typename P>
void test_point_box()
{
typedef bg::model::box<P> box_t;
test_geometry<P, box_t>("POINT(0 0)", "BOX(0 0, 1 1)", true);
test_geometry<P, box_t>("POINT(1 1)", "BOX(0 0, 2 2)", true);
test_geometry<P, box_t>("POINT(180 1)", "BOX(170 0, 190 2)", true);
test_geometry<P, box_t>("POINT(-180 1)", "BOX(170 0, 190 2)", true);
test_geometry<P, box_t>("POINT(180 1)", "BOX(170 0, 180 2)", true);
test_geometry<P, box_t>("POINT(-180 1)", "BOX(170 0, 180 2)", true);
test_geometry<P, box_t>("POINT(179 1)", "BOX(170 0, 190 2)", true);
test_geometry<P, box_t>("POINT(-179 1)", "BOX(170 0, 190 2)", true);
test_geometry<P, box_t>("POINT(179 1)", "BOX(170 0, 180 2)", true);
test_geometry<P, box_t>("POINT(-179 1)", "BOX(170 0, 180 2)", false);
test_geometry<P, box_t>("POINT(169 1)", "BOX(170 0, 180 2)", false);
// https://svn.boost.org/trac/boost/ticket/12412
test_geometry<P, box_t>("POINT(-0.127592 51.7)", "BOX(-2.08882 51.5034, -0.127592 51.9074)", true);
// and related
test_geometry<P, box_t>("POINT(-2.08882 51.7)", "BOX(-2.08882 51.5034, -0.127592 51.9074)", true);
test_geometry<P, box_t>("POINT(0.127592 51.7)", "BOX(0.127592 51.5034, 2.08882 51.9074)", true);
test_geometry<P, box_t>("POINT(2.08882 51.7)", "BOX(0.127592 51.5034, 2.08882 51.9074)", true);
test_geometry<P, box_t>("POINT(179.08882 1)", "BOX(179.08882 0, 538.127592 2)", true);
test_geometry<P, box_t>("POINT(178.127592 1)", "BOX(179.08882 0, 538.127592 2)", true);
test_geometry<P, box_t>("POINT(179.08882 1)", "BOX(179.08882 0, 182.127592 2)", true);
test_geometry<P, box_t>("POINT(-177.872408 1)", "BOX(179.08882 0, 182.127592 2)", true);
}
template <typename P>
void test_box_box()
{
typedef bg::model::box<P> box_t;
test_geometry<box_t, box_t>("BOX(0 0, 1 1)", "BOX(0 0, 1 1)", true);
test_geometry<box_t, box_t>("BOX(-170 0,-160 1)", "BOX(-180 0, 180 1)", true);
test_geometry<box_t, box_t>("BOX(-170 0,-160 1)", "BOX(170 0, 200 1)", true);
test_geometry<box_t, box_t>("BOX(-170 0,-150 1)", "BOX(170 0, 200 1)", false);
test_geometry<box_t, box_t>("BOX(0 0,1 1)", "BOX(170 0, 370 1)", true);
test_geometry<box_t, box_t>("BOX(0 0,10 1)", "BOX(170 0, 370 1)", true);
test_geometry<box_t, box_t>("BOX(-180 0,10 1)", "BOX(170 0, 370 1)", true);
test_geometry<box_t, box_t>("BOX(-180 0,20 1)", "BOX(170 0, 370 1)", false);
test_geometry<box_t, box_t>("BOX(10 0,20 1)", "BOX(170 0, 370 1)", false);
test_geometry<box_t, box_t>("BOX(160 0,180 1)", "BOX(170 0, 370 1)", false);
test_geometry<box_t, box_t>("BOX(-180 0,-170 1)", "BOX(180 0, 190 1)", true); // invalid?
test_geometry<box_t, box_t>("BOX(-180 0,-170 1)", "BOX(180 0, 191 1)", true); // invalid?
test_geometry<box_t, box_t>("BOX(-180 0,-170 1)", "BOX(179 0, 190 1)", true);
test_geometry<box_t, box_t>("BOX(-180 0,-170 1)", "BOX(181 0, 190 1)", false); // invalid?
test_geometry<box_t, box_t>("BOX(-180 0,-170 1)", "BOX(180 0, 189 1)", false); // invalid?
// Related to https://svn.boost.org/trac/boost/ticket/12412
test_geometry<box_t, box_t>("BOX(-1.346346 51.6, -0.127592 51.7)", "BOX(-2.08882 51.5034, -0.127592 51.9074)", true);
test_geometry<box_t, box_t>("BOX(-2.08882 51.6, -1.346346 51.7)", "BOX(-2.08882 51.5034, -0.127592 51.9074)", true);
test_geometry<box_t, box_t>("BOX(0.127592 51.6, 1.346346 51.7)", "BOX(0.127592 51.5034, 2.08882 51.9074)", true);
test_geometry<box_t, box_t>("BOX(1.346346 51.6, 2.08882 51.7)", "BOX(0.127592 51.5034, 2.08882 51.9074)", true);
test_geometry<box_t, box_t>("BOX(179.08882 1, 180.0 1)", "BOX(179.08882 0, 538.127592 2)", true);
test_geometry<box_t, box_t>("BOX(177.0 1, 178.127592 1)", "BOX(179.08882 0, 538.127592 2)", true);
test_geometry<box_t, box_t>("BOX(179.08882 1, 179.9 1)", "BOX(179.08882 0, 182.127592 2)", true);
test_geometry<box_t, box_t>("BOX(-179.9 1, -177.872408 1)", "BOX(179.08882 0, 182.127592 2)", true);
}
template <typename P>
void test_point_polygon()
{
typename boost::mpl::if_
<
boost::is_same<typename bg::cs_tag<P>::type, bg::geographic_tag>,
bg::strategy::within::geographic_winding<P>,
bg::strategy::within::spherical_winding<P>
>::type s;
typedef bg::model::polygon<P> poly;
// MySQL report 08.2017
test_geometry<P, poly>("POINT(-179 0)",
"POLYGON((0 0, 0 2, 2 0, 0 -2, 0 0))",
false);
test_geometry<P, poly>("POINT(-179 0)",
"POLYGON((0 0, 0 2, 2 0, 0 -2, 0 0))",
false,
s);
test_geometry<P, poly>("POINT(1 0)",
"POLYGON((0 0, 0 2, 2 0, 0 -2, 0 0))",
true);
test_geometry<P, poly>("POINT(1 0)",
"POLYGON((0 0, 0 2, 2 0, 0 -2, 0 0))",
true,
s);
}
template <typename P>
void test_cs()
{
test_point_box<P>();
test_box_box<P>();
test_point_polygon<P>();
}
int test_main( int , char* [] )
{
test_cs<bg::model::point<double, 2, bg::cs::spherical_equatorial<bg::degree> > >();
test_cs<bg::model::point<double, 2, bg::cs::geographic<bg::degree> > >();
#if defined(HAVE_TTMATH)
test_cs<bg::model::point<ttmath_big, 2, bg::cs::spherical_equatorial<bg::degree> > >();
test_cs<bg::model::point<ttmath_big, 2, bg::cs::geographic<bg::degree> > >();;
#endif
return 0;
}

View File

@@ -0,0 +1,184 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// Unit Test
// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands.
// Copyright (c) 2013-2015 Adam Wulkiewicz, Lodz, Poland.
// This file was modified by Oracle on 2017.
// Modifications copyright (c) 2017 Oracle and/or its affiliates.
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
// Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_GEOMETRY_TEST_COVERED_BY_HPP
#define BOOST_GEOMETRY_TEST_COVERED_BY_HPP
#include <geometry_test_common.hpp>
#include <boost/variant/variant.hpp>
#include <boost/geometry/algorithms/covered_by.hpp>
#include <boost/geometry/core/ring_type.hpp>
#include <boost/geometry/geometries/ring.hpp>
#include <boost/geometry/geometries/polygon.hpp>
#include <boost/geometry/geometries/multi_linestring.hpp>
#include <boost/geometry/io/wkt/read.hpp>
#include <boost/geometry/strategies/strategies.hpp>
struct no_strategy {};
template <typename Geometry1, typename Geometry2, typename Strategy>
bool call_covered_by(Geometry1 const& geometry1,
Geometry2 const& geometry2,
Strategy const& strategy)
{
return bg::covered_by(geometry1, geometry2, strategy);
}
template <typename Geometry1, typename Geometry2>
bool call_covered_by(Geometry1 const& geometry1,
Geometry2 const& geometry2,
no_strategy)
{
return bg::covered_by(geometry1, geometry2);
}
template <typename Geometry1, typename Geometry2, typename Strategy>
void check_geometry(Geometry1 const& geometry1,
Geometry2 const& geometry2,
std::string const& wkt1,
std::string const& wkt2,
bool expected,
Strategy const& strategy)
{
bool detected = call_covered_by(geometry1, geometry2, strategy);
BOOST_CHECK_MESSAGE(detected == expected,
"covered_by: " << wkt1
<< " in " << wkt2
<< " -> Expected: " << expected
<< " detected: " << detected);
}
template <typename Geometry1, typename Geometry2>
void test_geometry(std::string const& wkt1,
std::string const& wkt2, bool expected)
{
Geometry1 geometry1;
Geometry2 geometry2;
bg::read_wkt(wkt1, geometry1);
bg::read_wkt(wkt2, geometry2);
boost::variant<Geometry1> v1(geometry1);
boost::variant<Geometry2> v2(geometry2);
typedef typename bg::strategy::covered_by::services::default_strategy
<
Geometry1, Geometry2
>::type strategy_type;
check_geometry(geometry1, geometry2, wkt1, wkt2, expected, no_strategy());
check_geometry(geometry1, geometry2, wkt1, wkt2, expected, strategy_type());
check_geometry(v1, geometry2, wkt1, wkt2, expected, no_strategy());
check_geometry(geometry1, v2, wkt1, wkt2, expected, no_strategy());
check_geometry(v1, v2, wkt1, wkt2, expected, no_strategy());
}
template <typename Geometry1, typename Geometry2, typename Strategy>
void test_geometry(std::string const& wkt1,
std::string const& wkt2,
bool expected,
Strategy const& strategy)
{
Geometry1 geometry1;
Geometry2 geometry2;
bg::read_wkt(wkt1, geometry1);
bg::read_wkt(wkt2, geometry2);
check_geometry(geometry1, geometry2, wkt1, wkt2, expected, strategy);
}
/*
template <typename Point, bool Clockwise, bool Closed>
void test_ordered_ring(std::string const& wkt_point,
std::string const& wkt_geometry, bool expected)
{
typedef bg::model::ring<Point, Clockwise, Closed> ring_type;
ring_type ring;
Point point;
bg::read_wkt(wkt_geometry, ring);
if (! Clockwise)
{
std::reverse(boost::begin(ring), boost::end(ring));
}
if (! Closed)
{
ring.resize(ring.size() - 1);
}
bg::read_wkt(wkt_point, point);
bool detected = bg::covered_by(point, ring);
BOOST_CHECK_MESSAGE(detected == expected,
"covered_by: " << wkt_point
<< " in " << wkt_geometry
<< " -> Expected: " << expected
<< " detected: " << detected
<< " clockwise: " << int(Clockwise)
<< " closed: " << int(Closed)
);
// other strategy (note that this one cannot detect OnBorder
// (without modifications)
bg::strategy::covered_by::franklin<Point> franklin;
detected = bg::covered_by(point, ring, franklin);
if (! on_border)
{
BOOST_CHECK_MESSAGE(detected == expected,
"covered_by: " << wkt_point
<< " in " << wkt_geometry
<< " -> Expected: " << expected
<< " detected: " << detected
<< " clockwise: " << int(Clockwise)
<< " closed: " << int(Closed)
);
}
bg::strategy::covered_by::crossings_multiply<Point> cm;
detected = bg::covered_by(point, ring, cm);
if (! on_border)
{
BOOST_CHECK_MESSAGE(detected == expected,
"covered_by: " << wkt_point
<< " in " << wkt_geometry
<< " -> Expected: " << expected
<< " detected: " << detected
<< " clockwise: " << int(Clockwise)
<< " closed: " << int(Closed)
);
}
}
template <typename Point>
void test_ring(std::string const& wkt_point,
std::string const& wkt_geometry,
bool expected)
{
test_ordered_ring<Point, true, true>(wkt_point, wkt_geometry, expected);
test_ordered_ring<Point, false, true>(wkt_point, wkt_geometry, expected);
test_ordered_ring<Point, true, false>(wkt_point, wkt_geometry, expected);
test_ordered_ring<Point, false, false>(wkt_point, wkt_geometry, expected);
test_geometry<Point, bg::model::polygon<Point> >(wkt_point, wkt_geometry, expected);
}
*/
#endif

View File

@@ -0,0 +1,21 @@
# 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.
# Modifications copyright (c) 2014-2016, 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-crosses
:
[ run crosses.cpp : : : : algorithms_crosses ]
[ run crosses_sph.cpp : : : : algorithms_crosses_sph ]
;

View File

@@ -0,0 +1,107 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
// This file was modified by Oracle on 2014, 2017.
// Modifications copyright (c) 2014-2017 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)
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
#include "test_crosses.hpp"
template <typename P>
void test_pl()
{
typedef bg::model::multi_point<P> mpt;
typedef bg::model::linestring<P> ls;
typedef bg::model::multi_linestring<ls> mls;
test_geometry<mpt, ls>("MULTIPOINT(1 0,1 1)", "LINESTRING(0 0,1 0,3 3)", true);
test_geometry<mpt, ls>("MULTIPOINT(0 0,1 1)", "LINESTRING(0 0,1 0,3 3)", false);
test_geometry<mpt, ls>("MULTIPOINT(0 0,1 1)", "LINESTRING(0 0,1 1,3 3)", false);
test_geometry<mpt, mls>("MULTIPOINT(0 0,3 0)", "MULTILINESTRING((0 0,0 1,1 1),(1 1,1 0,0 0))", true);
test_geometry<mpt, mls>("MULTIPOINT(0 0,1 1)", "MULTILINESTRING((0 0,0 1,1 1),(1 1,1 0,0 0))", false);
}
template <typename P>
void test_pa()
{
typedef bg::model::multi_point<P> mpt;
typedef bg::model::polygon<P> poly;
typedef bg::model::multi_polygon<poly> mpoly;
test_geometry<mpt, poly>("MULTIPOINT(1 1,6 6)", "POLYGON((0 0,0 5,5 5,5 0,0 0))", true);
test_geometry<mpt, poly>("MULTIPOINT(0 0,6 6)", "POLYGON((0 0,0 5,5 5,5 0,0 0))", false);
test_geometry<mpt, poly>("MULTIPOINT(0 0,1 1)", "POLYGON((0 0,0 5,5 5,5 0,0 0))", false);
test_geometry<mpt, mpoly>("MULTIPOINT(0 0,1 1)", "MULTIPOLYGON(((0 0,0 5,5 5,5 0,0 0)),((5 5,5 9,9 9,9 5,5 5)))", false);
test_geometry<mpt, mpoly>("MULTIPOINT(1 1,1 6)", "MULTIPOLYGON(((0 0,0 5,5 5,5 0,0 0)),((5 5,5 9,9 9,9 5,5 5)))", true);
}
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,4 4)", "LINESTRING(0 1,2 1,3 1)", true);
test_geometry<ls, ls>("LINESTRING(0 0,2 2)", "LINESTRING(0 1,2 1)", true);
test_geometry<ls, ls>("LINESTRING(0 0,2 2,4 4)", "LINESTRING(0 1,1 1,2 2,3 2)", false);
test_geometry<ls, mls>("LINESTRING(0 0,2 2,4 4)", "MULTILINESTRING((0 1,4 1),(0 2,4 2))", true);
test_geometry<mls, ls>("MULTILINESTRING((0 1,4 1),(0 2,4 2))", "LINESTRING(0 0,2 2,4 4)", true);
test_geometry<mls, mls>("MULTILINESTRING((0 0,2 2,4 4),(3 0,3 4))", "MULTILINESTRING((0 1,4 1),(0 2,4 2))", true);
// spike - boundary and interior on the same point
test_geometry<ls, ls>("LINESTRING(3 7, 8 8, 2 6)", "LINESTRING(5 7, 10 7, 0 7)", true);
}
template <typename P>
void test_la()
{
typedef bg::model::linestring<P> ls;
typedef bg::model::multi_linestring<ls> mls;
typedef bg::model::ring<P> ring;
typedef bg::model::polygon<P> poly;
typedef bg::model::multi_polygon<poly> mpoly;
test_geometry<ls, ring>("LINESTRING(0 0, 10 10)", "POLYGON((0 0,0 5,5 5,5 0,0 0))", true);
test_geometry<ls, poly>("LINESTRING(0 0, 10 10)", "POLYGON((0 0,0 5,5 5,5 0,0 0))", true);
test_geometry<ls, mpoly>("LINESTRING(0 0, 10 10)", "MULTIPOLYGON(((0 0,0 5,5 5,5 0,0 0)))", true);
test_geometry<ls, poly>("LINESTRING(0 0, 10 0)", "POLYGON((0 0,0 5,5 5,5 0,0 0))", false);
test_geometry<ls, poly>("LINESTRING(1 1, 5 5)", "POLYGON((0 0,0 5,5 5,5 0,0 0))", false);
test_geometry<mls, ring>("MULTILINESTRING((1 1, 5 5),(6 6,7 7))", "POLYGON((0 0,0 5,5 5,5 0,0 0))", true);
test_geometry<mls, poly>("MULTILINESTRING((1 1, 5 5),(6 6,7 7))", "POLYGON((0 0,0 5,5 5,5 0,0 0))", true);
test_geometry<mls, mpoly>("MULTILINESTRING((1 1, 5 5),(6 6,7 7))", "MULTIPOLYGON(((0 0,0 5,5 5,5 0,0 0)))", true);
}
template <typename P>
void test_2d()
{
test_pl<P>();
test_pa<P>();
test_ll<P>();
test_la<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;
}

View File

@@ -0,0 +1,119 @@
// Boost.Geometry
// Copyright (c) 2016 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_crosses.hpp"
#include <algorithms/overlay/overlay_cases.hpp>
#include <algorithms/overlay/multi_overlay_cases.hpp>
#include <boost/geometry/geometries/geometries.hpp>
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))", false);
test_geometry<ls, ring>("LINESTRING(11 0,11 10)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", false);
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))", false);
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))",
true);
test_geometry<mls, ring>("MULTILINESTRING((6 6,15 15),(0 0, 7 7))",
"POLYGON((5 5,5 15,15 15,15 5,5 5))",
true);
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_all()
{
test_linestring_polygon<P>();
test_linestring_multi_polygon<P>();
test_multi_linestring_polygon<P>();
test_multi_linestring_multi_polygon<P>();
}
int test_main( int , char* [] )
{
test_all<bg::model::point<double, 2, bg::cs::spherical_equatorial<bg::degree> > >();
#if defined(HAVE_TTMATH)
test_cs<bg::model::point<ttmath_big, 2, bg::cs::spherical_equatorial<bg::degree> > >();
#endif
return 0;
}

View File

@@ -0,0 +1,110 @@
// Generic Geometry2 Library
// Unit Test
// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
// This file was modified by Oracle on 2014, 2017.
// Modifications copyright (c) 2014-2017 Oracle and/or its affiliates.
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
// Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_GEOMETRY_TEST_CROSSES_HPP
#define BOOST_GEOMETRY_TEST_CROSSES_HPP
#include <geometry_test_common.hpp>
#include <boost/geometry/core/ring_type.hpp>
#include <boost/geometry/algorithms/crosses.hpp>
#include <boost/geometry/strategies/strategies.hpp>
#include <boost/geometry/geometries/geometries.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/io/wkt/read.hpp>
#include <boost/variant/variant.hpp>
struct no_strategy {};
template <typename Geometry1, typename Geometry2, typename Strategy>
bool call_crosses(Geometry1 const& geometry1,
Geometry2 const& geometry2,
Strategy const& strategy)
{
return bg::crosses(geometry1, geometry2, strategy);
}
template <typename Geometry1, typename Geometry2>
bool call_crosses(Geometry1 const& geometry1,
Geometry2 const& geometry2,
no_strategy)
{
return bg::crosses(geometry1, geometry2);
}
template <typename Geometry1, typename Geometry2>
void test_geometry(std::string const& wkt1,
std::string const& wkt2, bool expected)
{
Geometry1 geometry1;
Geometry2 geometry2;
bg::read_wkt(wkt1, geometry1);
bg::read_wkt(wkt2, geometry2);
bool detected = call_crosses(geometry1, geometry2, no_strategy());
BOOST_CHECK_MESSAGE(detected == expected,
"crosses: " << wkt1
<< " with " << wkt2
<< " -> Expected: " << expected
<< " detected: " << detected);
typedef typename bg::strategy::relate::services::default_strategy
<
Geometry1, Geometry2
>::type strategy_type;
detected = call_crosses(geometry1, geometry2, strategy_type());
BOOST_CHECK_MESSAGE(detected == expected,
"crosses: " << wkt1
<< " with " << wkt2
<< " -> Expected: " << expected
<< " detected: " << detected);
#if !defined(BOOST_GEOMETRY_TEST_DEBUG)
detected = bg::crosses(geometry1,
boost::variant<Geometry2>(geometry2));
BOOST_CHECK_MESSAGE(detected == expected,
"crosses: " << wkt1
<< " with " << wkt2
<< " -> Expected: " << expected
<< " detected: " << detected);
detected = bg::crosses(boost::variant<Geometry1>(geometry1),
geometry2);
BOOST_CHECK_MESSAGE(detected == expected,
"crosses: " << wkt1
<< " with " << wkt2
<< " -> Expected: " << expected
<< " detected: " << detected);
detected = bg::crosses(boost::variant<Geometry1>(geometry1),
boost::variant<Geometry2>(geometry2));
BOOST_CHECK_MESSAGE(detected == expected,
"crosses: " << wkt1
<< " with " << wkt2
<< " -> Expected: " << expected
<< " detected: " << detected);
#endif
}
#endif // BOOST_GEOMETRY_TEST_CROSSES_HPP

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,165 @@
// 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> >();
#ifdef HAVE_TTMATH
test_all<bg::model::d2::point_xy<ttmath_big> >();
#endif
return 0;
}

View File

@@ -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
}

View File

@@ -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
}

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>
#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
}

View File

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

View File

@@ -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
}

View File

@@ -0,0 +1,187 @@
// 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>
#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_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>();
#ifdef HAVE_TTMATH
test_pointlike_pointlike<ttmath_big>();
#endif
}

View File

@@ -0,0 +1,129 @@
// 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> >();
#ifdef HAVE_TTMATH
test_all<bg::model::d2::point_xy<ttmath_big> >();
#endif
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,128 @@
// 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;
}

View File

@@ -0,0 +1,293 @@
// 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/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);
}
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>();
#ifdef HAVE_TTMATH
common_tests<bg::model::d2::point_xy<ttmath_big> >();
common_tests<bg::model::point<ttmath_big, 3, bg::cs::cartesian> >();
#endif
return 0;
}

View File

@@ -0,0 +1,289 @@
// Boost.Geometry
// Copyright (c) 2016 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_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_linestring_linestring_radians<bg::model::point<double, 2,
bg::cs::spherical_equatorial<bg::radian> > >();
test_point_polygon<P>();
}
int test_main( int , char* [] )
{
test_all<bg::model::point<double, 2, bg::cs::spherical_equatorial<bg::degree> > >();
#if defined(HAVE_TTMATH)
test_cs<bg::model::point<ttmath_big, 2, bg::cs::spherical_equatorial<bg::degree> > >();
#endif
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);
}

View File

@@ -0,0 +1,22 @@
# 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.
# Modifications copyright (c) 2014-2016, 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-equals
:
[ run equals.cpp : : : : algorithms_equals ]
[ run equals_multi.cpp : : : : algorithms_equals_multi ]
[ run equals_on_spheroid.cpp : : : : algorithms_equals_on_spheroid ]
;

View File

@@ -0,0 +1,318 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
// Copyright (c) 2017 Adam Wulkiewicz, Lodz, Poland.
// This file was modified by Oracle on 2013, 2014.
// Modifications copyright (c) 2013-2014 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_equals.hpp"
#include <boost/type_traits/is_floating_point.hpp>
#include <boost/geometry/geometries/geometries.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
namespace bgm = bg::model;
template <typename P>
void test_pointlike()
{
typedef bgm::multi_point<P> mpt;
test_geometry<P, P>("ptpt2d_1", "POINT(0 0)", "POINT(0 0)", true);
test_geometry<P, P>("ptpt2d_2", "POINT(0 0)", "POINT(1 1)", false);
test_geometry<P, mpt>("ptmpt2d_1", "POINT(0 0)", "MULTIPOINT(0 0)", true);
test_geometry<P, mpt>("ptmpt2d_1", "POINT(0 0)", "MULTIPOINT(0 0, 1 1)", false);
test_geometry<mpt, P>("mptpt2d_1", "MULTIPOINT(0 0)", "POINT(0 0)", true);
test_geometry<mpt, P>("mptpt2d_1", "MULTIPOINT(0 0, 1 1)", "POINT(0 0)", false);
test_geometry<mpt, mpt>("mptmpt2d_1", "MULTIPOINT(0 0, 1 1)", "MULTIPOINT(0 0, 1 1)", true);
test_geometry<mpt, mpt>("mptmpt2d_1", "MULTIPOINT(0 0, 1 1)", "MULTIPOINT(0 0, 2 2)", false);
test_geometry<mpt, mpt>("mptmpt2d_1", "MULTIPOINT(0 0, 1 1)", "MULTIPOINT(2 2, 3 3)", false);
}
template <typename P>
void test_segment_segment()
{
typedef bgm::segment<P> seg;
test_geometry<seg, seg>("seg2d_1", "LINESTRING(0 0, 3 3)", "LINESTRING(0 0, 3 3)", true);
test_geometry<seg, seg>("seg2d_1", "LINESTRING(0 0, 3 3)", "LINESTRING(3 3, 0 0)", true);
test_geometry<seg, seg>("seg2d_1", "LINESTRING(0 0, 3 3)", "LINESTRING(0 0, 1 1)", false);
test_geometry<seg, seg>("seg2d_1", "LINESTRING(0 0, 3 3)", "LINESTRING(3 3, 2 2)", false);
test_geometry<seg, seg>("seg2d_1", "LINESTRING(0 0, 3 3)", "LINESTRING(1 1, 4 4)", false);
test_geometry<seg, seg>("seg2d_1", "LINESTRING(0 0, 3 3)", "LINESTRING(1 0, 2 0)", false);
}
template <typename P>
void test_linestring_linestring()
{
typedef bgm::linestring<P> ls;
test_geometry<ls, ls>("ls2d_1", "LINESTRING(1 1, 3 3)", "LINESTRING(3 3, 1 1)", true);
test_geometry<ls, ls>("ls2d_2", "LINESTRING(1 1, 3 3, 2 5)", "LINESTRING(1 1, 2 2, 3 3, 2 5)", true);
test_geometry<ls, ls>("ls2d_3", "LINESTRING(1 0, 3 3, 2 5)", "LINESTRING(1 1, 2 2, 3 3, 2 5)", false);
test_geometry<ls, ls>("ls2d_4", "LINESTRING(1 0, 3 3, 2 5)", "LINESTRING(1 1, 3 3, 2 5)", false);
test_geometry<ls, ls>("ls2d_5", "LINESTRING(0 5,5 5,10 5,10 0,5 0,5 5,5 10,10 10,15 10,15 5,10 5,10 10,10 15)",
"LINESTRING(0 5,15 5,15 10,5 10,5 0,10 0,10 15)", true);
test_geometry<ls, ls>("ls2d_6", "LINESTRING(0 5,5 5,10 5,10 10,5 10,5 5,5 0)", "LINESTRING(0 5,5 5,5 10,10 10,10 5,5 5,5 0)", true);
test_geometry<ls, ls>("ls2d_7", "LINESTRING(0 5,10 5,10 10,5 10,5 0)", "LINESTRING(0 5,5 5,5 10,10 10,10 5,5 5,5 0)", true);
test_geometry<ls, ls>("ls2d_8", "LINESTRING(0 0,5 0,5 0,6 0)", "LINESTRING(0 0,6 0)", true);
test_geometry<ls, ls>("ls2d_seg", "LINESTRING(1 1,2 2)", "LINESTRING(1 1,2 2)", true);
test_geometry<ls, ls>("ls2d_rev", "LINESTRING(1 1,2 2)", "LINESTRING(2 2,1 1)", true);
test_geometry<ls, ls>("ls2d_spike", "LINESTRING(0 0,5 0,3 0,6 0)", "LINESTRING(0 0,6 0)", true);
test_geometry<ls, ls>("ls2d_ring1", "LINESTRING(0 0,5 0,5 5,0 5,0 0)", "LINESTRING(5 5,0 5,0 0,5 0,5 5)", true);
test_geometry<ls, ls>("ls2d_ring2", "LINESTRING(0 0,5 0,5 5,0 5,0 0)", "LINESTRING(5 5,5 0,0 0,0 5,5 5)", true);
test_geometry<ls, ls>("ls2d_overl_ring1", "LINESTRING(0 0,5 0,5 5,0 5,0 0)", "LINESTRING(5 5,0 5,0 0,5 0,5 5,0 5)", true);
test_geometry<ls, ls>("ls2d_overl_ring2", "LINESTRING(0 0,5 0,5 5,0 5,0 0)", "LINESTRING(5 5,5 0,0 0,0 5,5 5,5 0)", true);
// https://svn.boost.org/trac/boost/ticket/10904
if ( BOOST_GEOMETRY_CONDITION(
boost::is_floating_point<typename bg::coordinate_type<ls>::type>::value ) )
{
test_geometry<ls, ls>("ls2d_small1",
"LINESTRING(5.6956521739130430148634331999347 -0.60869565217391330413931882503675,5.5 -0.50000000000000066613381477509392)",
"LINESTRING(5.5 -0.50000000000000066613381477509392,5.5 -0.5)",
false);
test_geometry<ls, ls>("ls2d_small2",
"LINESTRING(-3.2333333333333333925452279800083 5.5999999999999978683717927196994,-3.2333333333333333925452279800083 5.5999999999999996447286321199499)",
"LINESTRING(-3.2333333333333325043668082798831 5.5999999999999996447286321199499,-3.2333333333333333925452279800083 5.5999999999999996447286321199499)",
false);
}
}
template <typename P>
void test_linestring_multilinestring()
{
typedef bgm::linestring<P> ls;
typedef bgm::multi_linestring<ls> mls;
test_geometry<ls, mls>("ls_mls_1", "LINESTRING(0 0,1 0,2 0)", "MULTILINESTRING((0 0,2 0))", true);
test_geometry<ls, mls>("ls_mls_1", "LINESTRING(0 0,1 0,2 0)", "MULTILINESTRING((0 0,1 0),(1 0,2 0))", true);
test_geometry<ls, mls>("ls_mls_1", "LINESTRING(0 0,2 0,4 0)", "MULTILINESTRING((0 0,2 0),(2 0,3 0),(3 0,4 0))", true);
test_geometry<ls, mls>("ls_mls_1", "LINESTRING(0 0,2 0,4 0)", "MULTILINESTRING((0 0,2 0),(2 0,3 0),(2 0,3 0),(3 0,4 0))", true);
test_geometry<ls, mls>("ls_mls_1", "LINESTRING(0 0,2 0,4 0)", "MULTILINESTRING((0 0,2 0),(3 0,4 0))", false);
test_geometry<ls, mls>("ls_mls_spike", "LINESTRING(0 0,2 0,2 2,2 0,4 0)", "MULTILINESTRING((0 0,4 0),(2 2,2 0))", true);
test_geometry<ls, mls>("ls_mls_spike", "LINESTRING(0 0,2 0,2 2,2 0,4 0)", "MULTILINESTRING((0 0,4 0),(2 2,2 -1))", false);
test_geometry<ls, mls>("ls_mls_ring1", "LINESTRING(0 0,5 0,5 5,0 5,0 0)", "MULTILINESTRING((5 5,0 5,0 0),(0 0,5 0,5 5))", true);
test_geometry<ls, mls>("ls_mls_ring2", "LINESTRING(0 0,5 0,5 5,0 5,0 0)", "MULTILINESTRING((5 5,5 0,0 0),(0 0,0 5,5 5))", true);
test_geometry<ls, mls>("ls_mls_overl_ring1", "LINESTRING(0 0,5 0,5 5,0 5,0 0)", "MULTILINESTRING((5 5,0 5,0 0),(0 0,5 0,5 5,0 5))", true);
test_geometry<ls, mls>("ls_mls_overl_ring2", "LINESTRING(0 0,5 0,5 5,0 5,0 0)", "MULTILINESTRING((5 5,5 0,0 0),(0 0,0 5,5 5,5 0))", true);
}
template <typename P>
void test_multilinestring_multilinestring()
{
typedef bgm::linestring<P> ls;
typedef bgm::multi_linestring<ls> mls;
test_geometry<mls, mls>("ls_mls_mls",
"MULTILINESTRING((0 5,10 5,10 10,5 10),(5 10,5 0,5 2),(5 2,5 5,0 5))",
"MULTILINESTRING((5 5,0 5),(5 5,5 0),(10 10,10 5,5 5,5 10,10 10))",
true);
}
template <typename P>
void test_polygons()
{
typedef bg::model::polygon<P, true, true> poly_cw_c;
typedef bg::model::polygon<P, true, false> poly_cw_o;
typedef bg::model::polygon<P, false, true> poly_ccw_c;
typedef bg::model::polygon<P, false, false> poly_ccw_o;
typedef bg::model::box<P> box;
std::string wkt1 = "POLYGON((-18 1, -23 1, -23 -3, -18 -3))";
std::string wkt2 = "POLYGON((-23 1, -23 -3, -18 -3, -18 1))";
test_geometry<poly_cw_c, poly_cw_c>("polys_cw_c_cw_c", wkt1, wkt2, true, true);
test_geometry<poly_cw_c, poly_cw_o>("polys_cw_c_cw_o", wkt1, wkt2, true, true);
test_geometry<poly_cw_c, poly_ccw_c>("polys_cw_c_ccw_c", wkt1, wkt2, true, true);
test_geometry<poly_cw_c, poly_ccw_o>("polys_cw_c_ccw_o", wkt1, wkt2, true, true);
test_geometry<poly_cw_c, box>("polys_cw_c_box", wkt1, wkt2, true, true);
test_geometry<poly_cw_o, poly_cw_c>("polys_cw_o_cw_c", wkt1, wkt2, true, true);
test_geometry<poly_cw_o, poly_cw_o>("polys_cw_o_cw_o", wkt1, wkt2, true, true);
test_geometry<poly_cw_o, poly_ccw_c>("polys_cw_o_ccw_c", wkt1, wkt2, true, true);
test_geometry<poly_cw_o, poly_ccw_o>("polys_cw_o_ccw_o", wkt1, wkt2, true, true);
test_geometry<poly_cw_o, box>("polys_cw_o_box", wkt1, wkt2, true, true);
test_geometry<poly_ccw_c, poly_cw_c>("polys_ccw_c_cw_c", wkt1, wkt2, true, true);
test_geometry<poly_ccw_c, poly_cw_o>("polys_ccw_c_cw_o", wkt1, wkt2, true, true);
test_geometry<poly_ccw_c, poly_ccw_c>("polys_ccw_c_ccw_c", wkt1, wkt2, true, true);
test_geometry<poly_ccw_c, poly_ccw_o>("polys_ccw_c_ccw_o", wkt1, wkt2, true, true);
test_geometry<poly_ccw_c, box>("polys_cw_o_box", wkt1, wkt2, true, true);
test_geometry<poly_ccw_o, poly_cw_c>("polys_ccw_o_cw_c", wkt1, wkt2, true, true);
test_geometry<poly_ccw_o, poly_cw_o>("polys_ccw_o_cw_o", wkt1, wkt2, true, true);
test_geometry<poly_ccw_o, poly_ccw_c>("polys_ccw_o_ccw_c", wkt1, wkt2, true, true);
test_geometry<poly_ccw_o, poly_ccw_o>("polys_ccw_o_ccw_o", wkt1, wkt2, true, true);
test_geometry<poly_ccw_o, box>("polys_ccw_o_box", wkt1, wkt2, true, true);
}
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;
std::string case_p1 = "POLYGON((0 0,0 2,2 2,0 0))";
test_geometry<P, P>("p1", "POINT(1 1)", "POINT(1 1)", true);
test_geometry<P, P>("p2", "POINT(1 1)", "POINT(1 2)", false);
test_geometry<box, box>("b1", "BOX(1 1,2 2)", "BOX(1 2,2 2)", false);
test_geometry<box, box>("b1", "BOX(1 2,3 4)", "BOX(1 2,3 4)", true);
// Completely equal
test_geometry<ring, ring>("poly_eq", case_p1, case_p1, true);
// Shifted
test_geometry<ring, ring>("poly_sh", "POLYGON((2 2,0 0,0 2,2 2))", case_p1, true);
test_geometry<polygon, polygon>("poly_sh2", case_p1, "POLYGON((0 2,2 2,0 0,0 2))", true);
// Extra coordinate
test_geometry<ring, ring>("poly_extra", case_p1, "POLYGON((0 0,0 2,2 2,1 1,0 0))", true);
// Shifted + extra (redundant) coordinate
test_geometry<ring, ring>("poly_shifted_extra1", "POLYGON((2 2,1 1,0 0,0 2,2 2))", case_p1, true);
// Shifted + extra (redundant) coordinate being first/last point
test_geometry<ring, ring>("poly_shifted_extra2", "POLYGON((1 1,0 0,0 2,2 2,1 1))", case_p1, true);
// Degenerate (duplicate) points
test_geometry<ring, ring>("poly_degenerate", "POLYGON((0 0,0 2,2 2,2 2,0 0))", "POLYGON((0 0,0 2,0 2,2 2,0 0))", true);
// Two different bends, same area, unequal
test_geometry<ring, ring>("poly_bends",
"POLYGON((4 0,5 3,8 4,7 7,4 8,0 4,4 0))",
"POLYGON((4 0,7 1,8 4,5 5,4 8,0 4,4 0))", false);
// Unequal (but same area)
test_geometry<ring, ring>("poly_uneq", case_p1, "POLYGON((1 1,1 3,3 3,1 1))", false);
// One having hole
test_geometry<polygon, polygon>("poly_hole", "POLYGON((0 0,0 4,4 4,0 0))", "POLYGON((0 0,0 4,4 4,0 0),(1 1,2 1,2 2,1 2,1 1))", false);
// Both having holes
test_geometry<polygon, polygon>("poly_holes",
"POLYGON((0 0,0 4,4 4,0 0),(1 1,2 1,2 2,1 2,1 1))",
"POLYGON((0 0,0 4,4 4,0 0),(1 1,2 1,2 2,1 2,1 1))", true);
// Both having holes, outer equal, inner not equal
test_geometry<polygon, polygon>("poly_uneq_holes",
"POLYGON((0 0,0 4,4 4,0 0),(1 1,2 1,2 2,1 2,1 1))",
"POLYGON((0 0,0 4,4 4,0 0),(2 2,3 2,3 3,2 3,2 2))", false);
// Both having 2 holes, equal but in different order
test_geometry<polygon, polygon>("poly_holes_diff_order",
"POLYGON((0 0,0 4,4 4,0 0),(1 1,2 1,2 2,1 2,1 1),(2 2,3 2,3 3,2 3,2 2))",
"POLYGON((0 0,0 4,4 4,0 0),(2 2,3 2,3 3,2 3,2 2),(1 1,2 1,2 2,1 2,1 1))", true);
// Both having 3 holes, equal but in different order
test_geometry<polygon, polygon>("poly_holes_diff_order_3",
"POLYGON((0 0,0 10,10 10,0 0),(1 1,2 1,2 2,1 2,1 1),(4 1,5 1,5 2,4 2,4 1),(2 2,3 2,3 3,2 3,2 2))",
"POLYGON((0 0,0 10,10 10,0 0),(4 1,5 1,5 2,4 2,4 1),(2 2,3 2,3 3,2 3,2 2),(1 1,2 1,2 2,1 2,1 1))", true);
// polygon/ring vv
test_geometry<polygon, ring>("poly_sh2_pr", case_p1, case_p1, true);
test_geometry<ring, polygon>("poly_sh2_rp", case_p1, case_p1, true);
// box/ring/poly
test_geometry<box, ring>("boxring1", "BOX(1 1,2 2)", "POLYGON((1 1,1 2,2 2,2 1,1 1))", true);
test_geometry<ring, box>("boxring2", "POLYGON((1 1,1 2,2 2,2 1,1 1))", "BOX(1 1,2 2)", true);
test_geometry<box, polygon>("boxpoly1", "BOX(1 1,2 2)", "POLYGON((1 1,1 2,2 2,2 1,1 1))", true);
test_geometry<polygon, box>("boxpoly2", "POLYGON((1 1,1 2,2 2,2 1,1 1))", "BOX(1 1,2 2)", true);
test_geometry<polygon, box>("boxpoly2", "POLYGON((1 1,1 2,2 2,2 1,1 1))", "BOX(1 1,2 3)", false);
test_geometry<polygon, polygon>("poly_holes_shifted_points",
"POLYGON((0 0,0 3,3 3,3 0,0 0),(1 1,2 1,2 2,1 2,1 1))",
"POLYGON((0 0,0 3,3 3,3 0,0 0),(2 2,1 2,1 1,2 1,2 2))", true);
test_pointlike<P>();
test_segment_segment<P>();
test_linestring_linestring<P>();
test_linestring_multilinestring<P>();
test_multilinestring_multilinestring<P>();
test_polygons<P>();
}
template <typename T>
void verify()
{
T dxn1, dyn1, dxn2, dyn2;
{
T x1 = "0", y1 = "0", x2 = "3", y2 = "3";
T dx = x2 - x1, dy = y2 - y1;
T mag = sqrt(dx * dx + dy * dy);
dxn1 = dx / mag;
dyn1 = dy / mag;
}
{
T x1 = "0", y1 = "0", x2 = "1", y2 = "1";
T dx = x2 - x1, dy = y2 - y1;
T mag = sqrt(dx * dx + dy * dy);
dxn2 = dx / mag;
dyn2 = dy / mag;
}
if (dxn1 == dxn2 && dyn1 == dyn2)
{
//std::cout << "vectors are equal, using ==" << std::endl;
}
if (boost::geometry::math::equals(dxn1, dxn2)
&& boost::geometry::math::equals(dyn1, dyn2))
{
//std::cout << "vectors are equal, using bg::math::equals" << std::endl;
}
bool equals = boost::geometry::math::equals_with_epsilon(dxn1, dxn2)
&& boost::geometry::math::equals_with_epsilon(dyn1, dyn2);
if (equals)
{
//std::cout << "vectors are equal, using bg::math::equals_with_epsilon" << std::endl;
}
BOOST_CHECK_EQUAL(equals, true);
}
int test_main( int , char* [] )
{
//verify<double>();
#if defined(HAVE_TTMATH)
verify<ttmath_big>();
#endif
test_all<bg::model::d2::point_xy<int> >();
test_all<bg::model::d2::point_xy<double> >();
#if defined(HAVE_TTMATH)
test_all<bg::model::d2::point_xy<ttmath_big> >();
#endif
return 0;
}

View File

@@ -0,0 +1,52 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
//
// Copyright (c) 2010-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_equals.hpp"
#include <boost/geometry/algorithms/area.hpp>
#include <boost/geometry/geometries/geometries.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
template <typename P>
void test_all()
{
std::string case1 = "MULTIPOLYGON(((0 0,0 7,4 2,2 0,0 0)))";
std::string case1_p = "POLYGON((0 0,0 7,4 2,2 0,0 0))";
typedef bg::model::polygon<P> polygon;
typedef bg::model::multi_polygon<polygon> mp;
test_geometry<mp, mp>("c1", case1, case1, true);
test_geometry<mp, mp>("c2",
"MULTIPOLYGON(((0 0,0 7.01,4 2,2 0,0 0)))",
case1, false);
// Different order == equal
test_geometry<mp, mp>("c3",
"MULTIPOLYGON(((0 0,0 7,4 2,2 0,0 0)),((10 10,10 12,12 10,10 10)))",
"MULTIPOLYGON(((10 10,10 12,12 10,10 10)),((0 0,0 7,4 2,2 0,0 0)))",
true);
// check different types
test_geometry<polygon, mp>("c1_p_mp", case1_p, case1, true);
test_geometry<mp, polygon>("c1_mp_p", case1, case1_p, true);
}
int test_main( int , char* [] )
{
test_all<bg::model::d2::point_xy<double> >();
#ifdef HAVE_TTMATH
test_all<bg::model::d2::point_xy<ttmath_big> >();
#endif
return 0;
}

View File

@@ -0,0 +1,255 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// Unit test
// Copyright (c) 2015, Oracle and/or its affiliates.
// Licensed under the Boost Software License version 1.0.
// http://www.boost.org/users/license.html
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
#ifndef BOOST_TEST_MODULE
#define BOOST_TEST_MODULE test_equals_on_spheroid
#endif
#include <iostream>
#include <boost/test/included/unit_test.hpp>
#include "test_equals.hpp"
#include <boost/geometry/geometries/geometries.hpp>
#include <boost/geometry/core/cs.hpp>
namespace bgm = bg::model;
template <typename P1, typename P2 = P1>
struct test_point_point
{
static inline void apply(std::string const& header)
{
std::string const str = header + "-";
test_geometry<P1, P2>(str + "pp_01", "POINT(0 0)", "POINT(0 0)", true);
test_geometry<P1, P2>(str + "pp_02", "POINT(0 0)", "POINT(10 0)", false);
// points whose longitudes differ by 360 degrees
test_geometry<P1, P2>(str + "pp_03", "POINT(0 0)", "POINT(360 0)", true);
test_geometry<P1, P2>(str + "pp_04", "POINT(10 0)", "POINT(370 0)", true);
test_geometry<P1, P2>(str + "pp_05", "POINT(10 0)", "POINT(-350 0)", true);
test_geometry<P1, P2>(str + "pp_06", "POINT(180 10)", "POINT(-180 10)", true);
test_geometry<P1, P2>(str + "pp_06a", "POINT(540 10)", "POINT(-540 10)", true);
#ifdef BOOST_GEOMETRY_NORMALIZE_LATITUDE
test_geometry<P1, P2>(str + "pp_06b", "POINT(540 370)", "POINT(-540 -350)", true);
test_geometry<P1, P2>(str + "pp_06c", "POINT(1260 370)", "POINT(-1260 -350)", true);
test_geometry<P1, P2>(str + "pp_06d", "POINT(2340 370)", "POINT(-2340 -350)", true);
#endif
test_geometry<P1, P2>(str + "pp_06e", "POINT(-180 10)", "POINT(-540 10)", true);
test_geometry<P1, P2>(str + "pp_06f", "POINT(180 10)", "POINT(-540 10)", true);
// north & south pole
test_geometry<P1, P2>(str + "pp_07", "POINT(0 90)", "POINT(0 90)", true);
#ifdef BOOST_GEOMETRY_NORMALIZE_LATITUDE
test_geometry<P1, P2>(str + "pp_07a", "POINT(0 450)", "POINT(10 -270)", true);
test_geometry<P1, P2>(str + "pp_07b", "POINT(0 270)", "POINT(10 90)", false);
test_geometry<P1, P2>(str + "pp_07c", "POINT(0 -450)", "POINT(10 90)", false);
#endif
test_geometry<P1, P2>(str + "pp_08", "POINT(0 90)", "POINT(10 90)", true);
test_geometry<P1, P2>(str + "pp_09", "POINT(0 90)", "POINT(0 -90)", false);
test_geometry<P1, P2>(str + "pp_10", "POINT(0 -90)", "POINT(0 -90)", true);
test_geometry<P1, P2>(str + "pp_11", "POINT(0 -90)", "POINT(10 -90)", true);
test_geometry<P1, P2>(str + "pp_11a", "POINT(0 -90)", "POINT(10 90)", false);
test_geometry<P1, P2>(str + "pp_12", "POINT(0 -90)", "POINT(0 -85)", false);
test_geometry<P1, P2>(str + "pp_13", "POINT(0 90)", "POINT(0 85)", false);
test_geometry<P1, P2>(str + "pp_14", "POINT(0 90)", "POINT(10 85)", false);
// symmetric wrt prime meridian
test_geometry<P1, P2>(str + "pp_15", "POINT(-10 45)", "POINT(10 45)", false);
test_geometry<P1, P2>(str + "pp_16", "POINT(-170 45)", "POINT(170 45)", false);
// other points
test_geometry<P1, P2>(str + "pp_17", "POINT(-10 45)", "POINT(10 -45)", false);
test_geometry<P1, P2>(str + "pp_18", "POINT(-10 -45)", "POINT(10 45)", false);
test_geometry<P1, P2>(str + "pp_19", "POINT(10 -135)", "POINT(10 45)", false);
#ifdef BOOST_GEOMETRY_NORMALIZE_LATITUDE
test_geometry<P1, P2>(str + "pp_20", "POINT(190 135)", "POINT(10 45)", true);
test_geometry<P1, P2>(str + "pp_21", "POINT(190 150)", "POINT(10 30)", true);
test_geometry<P1, P2>(str + "pp_21a", "POINT(-170 150)", "POINT(10 30)", true);
test_geometry<P1, P2>(str + "pp_22", "POINT(190 -135)", "POINT(10 -45)", true);
test_geometry<P1, P2>(str + "pp_23", "POINT(190 -150)", "POINT(10 -30)", true);
test_geometry<P1, P2>(str + "pp_23a", "POINT(-170 -150)", "POINT(10 -30)", true);
#endif
}
};
template <typename P1, typename P2 = P1>
struct test_point_point_with_height
{
static inline void apply(std::string const& header)
{
std::string const str = header + "-";
test_geometry<P1, P2>(str + "pp_01",
"POINT(0 0 10)",
"POINT(0 0 20)",
true);
test_geometry<P1, P2>(str + "pp_02",
"POINT(0 0 10)",
"POINT(10 0 10)",
false);
// points whose longitudes differ by 360 degrees
test_geometry<P1, P2>(str + "pp_03",
"POINT(0 0 10)",
"POINT(360 0 10)",
true);
// points whose longitudes differ by 360 degrees
test_geometry<P1, P2>(str + "pp_04",
"POINT(10 0 10)",
"POINT(370 0 10)",
true);
test_geometry<P1, P2>(str + "pp_05",
"POINT(10 0 10)",
"POINT(10 0 370)",
false);
}
};
template <typename P>
void test_segment_segment(std::string const& header)
{
typedef bgm::segment<P> seg;
std::string const str = header + "-";
test_geometry<seg, seg>(str + "ss_01",
"SEGMENT(10 0,180 0)",
"SEGMENT(10 0,-180 0)",
true);
test_geometry<seg, seg>(str + "ss_02",
"SEGMENT(0 90,180 0)",
"SEGMENT(10 90,-180 0)",
true);
test_geometry<seg, seg>(str + "ss_03",
"SEGMENT(0 90,0 -90)",
"SEGMENT(10 90,20 -90)",
true);
test_geometry<seg, seg>(str + "ss_04",
"SEGMENT(10 80,10 -80)",
"SEGMENT(10 80,20 -80)",
false);
test_geometry<seg, seg>(str + "ss_05",
"SEGMENT(170 10,-170 10)",
"SEGMENT(170 10,350 10)",
false);
}
BOOST_AUTO_TEST_CASE( equals_point_point_se )
{
typedef bg::cs::spherical_equatorial<bg::degree> cs_type;
test_point_point<bgm::point<int, 2, cs_type> >::apply("se");
test_point_point<bgm::point<double, 2, cs_type> >::apply("se");
test_point_point<bgm::point<long double, 2, cs_type> >::apply("se");
// mixed point types
test_point_point
<
bgm::point<double, 2, cs_type>, bgm::point<int, 2, cs_type>
>::apply("se");
test_point_point
<
bgm::point<double, 2, cs_type>, bgm::point<long double, 2, cs_type>
>::apply("se");
#if defined(HAVE_TTMATH)
test_point_point<bgm::point<ttmath_big, 2, cs_type> >::apply("se");
#endif
}
BOOST_AUTO_TEST_CASE( equals_point_point_with_height_se )
{
typedef bg::cs::spherical_equatorial<bg::degree> cs_type;
test_point_point<bgm::point<int, 3, cs_type> >::apply("seh");
test_point_point<bgm::point<double, 3, cs_type> >::apply("seh");
test_point_point<bgm::point<long double, 3, cs_type> >::apply("seh");
// mixed point types
test_point_point
<
bgm::point<double, 3, cs_type>, bgm::point<int, 3, cs_type>
>::apply("seh");
test_point_point
<
bgm::point<double, 3, cs_type>, bgm::point<long double, 3, cs_type>
>::apply("seh");
#if defined(HAVE_TTMATH)
test_point_point<bgm::point<ttmath_big, 3, cs_type> >::apply("seh");
#endif
}
BOOST_AUTO_TEST_CASE( equals_point_point_geo )
{
typedef bg::cs::geographic<bg::degree> cs_type;
test_point_point<bgm::point<int, 2, cs_type> >::apply("geo");
test_point_point<bgm::point<double, 2, cs_type> >::apply("geo");
test_point_point<bgm::point<long double, 2, cs_type> >::apply("geo");
// mixed point types
test_point_point
<
bgm::point<double, 2, cs_type>, bgm::point<int, 2, cs_type>
>::apply("se");
test_point_point
<
bgm::point<double, 2, cs_type>, bgm::point<long double, 2, cs_type>
>::apply("se");
#if defined(HAVE_TTMATH)
test_point_point<bgm::point<ttmath_big, 2, cs_type> >::apply("geo");
#endif
}
BOOST_AUTO_TEST_CASE( equals_segment_segment_se )
{
typedef bg::cs::spherical_equatorial<bg::degree> cs_type;
test_segment_segment<bgm::point<int, 2, cs_type> >("se");
test_segment_segment<bgm::point<double, 2, cs_type> >("se");
test_segment_segment<bgm::point<long double, 2, cs_type> >("se");
#if defined(HAVE_TTMATH)
test_segment_segment<bgm::point<ttmath_big, 2, cs_type> >("se");
#endif
}
BOOST_AUTO_TEST_CASE( equals_segment_segment_geo )
{
typedef bg::cs::geographic<bg::degree> cs_type;
test_segment_segment<bgm::point<int, 2, cs_type> >("geo");
test_segment_segment<bgm::point<double, 2, cs_type> >("geo");
test_segment_segment<bgm::point<long double, 2, cs_type> >("geo");
#if defined(HAVE_TTMATH)
test_segment_segment<bgm::point<ttmath_big, 2, cs_type> >("geo");
#endif
}

View File

@@ -0,0 +1,155 @@
// Boost.Geometry
// Copyright (c) 2016 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_equals.hpp"
#include <algorithms/overlay/overlay_cases.hpp>
#include <algorithms/overlay/multi_overlay_cases.hpp>
#include <boost/geometry/geometries/geometries.hpp>
template <typename P>
void test_polygon_polygon()
{
typedef bg::model::polygon<P> poly;
typedef bg::model::ring<P> ring;
test_geometry<poly, ring>(case_1[0], case_1[0],
true);
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],
true);
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_18_sph[0], case_18_sph[1],
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_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)", true);
test_geometry<ls, ls>("LINESTRING(1 0,2 2,2 3)", "LINESTRING(0 0, 2 2, 3 2)", 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))",
true);
}
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_all()
{
test_polygon_polygon<P>();
test_polygon_multi_polygon<P>();
test_multi_polygon_multi_polygon<P>();
test_linestring_linestring<P>();
test_linestring_multi_linestring<P>();
test_multi_linestring_multi_linestring<P>();
}
int test_main( int , char* [] )
{
test_all<bg::model::point<double, 2, bg::cs::spherical_equatorial<bg::degree> > >();
#if defined(HAVE_TTMATH)
test_cs<bg::model::point<ttmath_big, 2, bg::cs::spherical_equatorial<bg::degree> > >();
#endif
return 0;
}

View File

@@ -0,0 +1,115 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// Unit Test
// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
// Copyright (c) 2014-2017 Adam Wulkiewicz, Lodz, Poland.
// This file was modified by Oracle on 2016-2017.
// Modifications copyright (c) 2016-2017 Oracle and/or its affiliates.
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
// Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_GEOMETRY_TEST_EQUALS_HPP
#define BOOST_GEOMETRY_TEST_EQUALS_HPP
#include <geometry_test_common.hpp>
#include <boost/geometry/core/ring_type.hpp>
#include <boost/geometry/algorithms/correct.hpp>
#include <boost/geometry/algorithms/equals.hpp>
#include <boost/geometry/strategies/strategies.hpp>
#include <boost/geometry/io/wkt/read.hpp>
#include <boost/variant/variant.hpp>
struct no_strategy {};
template <typename Geometry1, typename Geometry2, typename Strategy>
bool call_equals(Geometry1 const& geometry1,
Geometry2 const& geometry2,
Strategy const& strategy)
{
return bg::equals(geometry1, geometry2, strategy);
}
template <typename Geometry1, typename Geometry2>
bool call_equals(Geometry1 const& geometry1,
Geometry2 const& geometry2,
no_strategy)
{
return bg::equals(geometry1, geometry2);
}
template <typename Geometry1, typename Geometry2, typename Strategy>
void check_geometry(Geometry1 const& geometry1,
Geometry2 const& geometry2,
std::string const& caseid,
std::string const& wkt1,
std::string const& wkt2,
bool expected,
Strategy const& strategy)
{
bool detected = call_equals(geometry1, geometry2, strategy);
BOOST_CHECK_MESSAGE(detected == expected,
"case: " << caseid
<< " equals: " << wkt1
<< " to " << wkt2
<< " -> Expected: " << expected
<< " detected: " << detected);
detected = call_equals(geometry2, geometry1, strategy);
BOOST_CHECK_MESSAGE(detected == expected,
"case: " << caseid
<< " equals: " << wkt2
<< " to " << wkt1
<< " -> Expected: " << expected
<< " detected: " << detected);
}
template <typename Geometry1, typename Geometry2>
void test_geometry(std::string const& caseid,
std::string const& wkt1,
std::string const& wkt2,
bool expected,
bool correct_geometries = false)
{
Geometry1 geometry1;
Geometry2 geometry2;
bg::read_wkt(wkt1, geometry1);
bg::read_wkt(wkt2, geometry2);
if (correct_geometries)
{
bg::correct(geometry1);
bg::correct(geometry2);
}
typedef typename bg::strategy::relate::services::default_strategy
<
Geometry1, Geometry2
>::type strategy_type;
check_geometry(geometry1, geometry2, caseid, wkt1, wkt2, expected, no_strategy());
check_geometry(geometry1, geometry2, caseid, wkt1, wkt2, expected, strategy_type());
check_geometry(boost::variant<Geometry1>(geometry1), geometry2, caseid, wkt1, wkt2, expected, no_strategy());
check_geometry(geometry1, boost::variant<Geometry2>(geometry2), caseid, wkt1, wkt2, expected, no_strategy());
check_geometry(boost::variant<Geometry1>(geometry1), boost::variant<Geometry2>(geometry2), caseid, wkt1, wkt2, expected, no_strategy());
}
template <typename Geometry1, typename Geometry2>
void test_geometry(std::string const& wkt1,
std::string const& wkt2,
bool expected)
{
test_geometry<Geometry1, Geometry2>("", wkt1, wkt2, expected);
}
#endif

View File

@@ -0,0 +1,26 @@
# 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.
# Modifications copyright (c) 2014-2016, 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-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 ]
[ run intersects_sph_geo.cpp : : : : algorithms_intersects_sph_geo ]
[ run intersects_sph.cpp : : : : algorithms_intersects_sph ]
;

View File

@@ -0,0 +1,227 @@
// 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, 2016.
// Modifications copyright (c) 2013-2016, 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_intersects.hpp"
#include <boost/geometry/geometries/geometries.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/util/rational.hpp>
template <typename P1, typename P2>
void test_intersects_polygon_polygon()
{
typedef bg::model::polygon<P1, false, false> poly_ccw_o1;
typedef bg::model::polygon<P2, false, false> poly_ccw_o2;
test_geometry<poly_ccw_o1, poly_ccw_o2>("POLYGON((1 1, 3 3, 2 5))", "POLYGON((0 0, 9 0, 9 9, 0 9),(5 5,5 8,8 8,8 5))", true);
test_geometry<poly_ccw_o1, poly_ccw_o2>("POLYGON((6 6, 7 6, 7 7, 6 7))", "POLYGON((0 0, 9 0, 9 9, 0 9),(5 5,5 8,8 8,8 5))", false);
test_geometry<poly_ccw_o1, poly_ccw_o2>("POLYGON((7 7, 9 7, 9 9, 7 9))", "POLYGON((0 0, 9 0, 9 9, 0 9),(5 5,5 8,8 8,8 5))", true);
}
template <typename P1, typename P2>
void test_intersects_linestring_segment()
{
typedef bg::model::linestring<P1> ls;
typedef bg::model::segment<P2> seg;
test_geometry<ls, seg>("LINESTRING(1 1, 3 3, 2 5)", "SEGMENT(2 0, 2 6)", true);
test_geometry<ls, seg>("LINESTRING(1 1, 3 3)", "SEGMENT(1 0, 1 1)", true);
test_geometry<ls, seg>("LINESTRING(1 1, 3 3)", "SEGMENT(2 0, 2 2)", true);
test_geometry<ls, seg>("LINESTRING(1 1, 3 3)", "SEGMENT(3 0, 4 1)", false);
}
template <typename P1, typename P2>
void test_intersects_linestring_linestring()
{
typedef bg::model::linestring<P1> ls1;
typedef bg::model::linestring<P2> ls2;
test_geometry<ls1, ls2>("LINESTRING(0 0,2 0,3 0)", "LINESTRING(0 0,1 1,2 2)", true);
test_geometry<ls1, ls2>("LINESTRING(0 0,2 0,3 0)", "LINESTRING(2 2,1 1,0 0)", true);
test_geometry<ls1, ls2>("LINESTRING(3 0,2 0,0 0)", "LINESTRING(0 0,1 1,2 2)", true);
test_geometry<ls1, ls2>("LINESTRING(3 0,2 0,0 0)", "LINESTRING(2 2,1 1,0 0)", true);
test_geometry<ls1, ls2>("LINESTRING(0 0,2 0,3 0)", "LINESTRING(1 0,4 0,5 0)", true);
test_geometry<ls1, ls2>("LINESTRING(1 0,2 0)", "LINESTRING(1 0,0 0)", true);
}
template <typename P1, typename P2>
void test_intersects_linestring_polygon()
{
typedef bg::model::linestring<P1> ls;
typedef bg::model::multi_linestring<ls> mls;
typedef bg::model::polygon<P2> poly_cw_c;
typedef bg::model::polygon<P2, false> poly_ccw_c;
typedef bg::model::polygon<P2, false, false> poly_ccw_o;
typedef bg::model::multi_polygon<poly_ccw_c> mpoly_ccw_c;
test_geometry<ls, poly_ccw_c>("LINESTRING(1 1,2 2)", "POLYGON((0 0,10 0,10 10,0 10,0 0))", true);
test_geometry<ls, poly_ccw_c>("LINESTRING(1 0,2 2)", "POLYGON((0 0,10 0,10 10,0 10,0 0))", true);
test_geometry<ls, poly_ccw_c>("LINESTRING(11 0,12 12)", "POLYGON((0 0,10 0,10 10,0 10,0 0))", false);
test_geometry<ls, poly_ccw_o>("LINESTRING(1 1, 3 3, 2 5)", "POLYGON((0 0, 9 0, 9 9, 0 9),(5 5,5 8,8 8,8 5))", true);
test_geometry<ls, poly_ccw_o>("LINESTRING(6 6, 7 6, 7 7, 6 7)", "POLYGON((0 0, 9 0, 9 9, 0 9),(5 5,5 8,8 8,8 5))", false);
test_geometry<ls, poly_ccw_o>("LINESTRING(7 7, 9 7, 9 9, 7 9)", "POLYGON((0 0, 9 0, 9 9, 0 9),(5 5,5 8,8 8,8 5))", true);
test_geometry<poly_cw_c, ls>("POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))", "LINESTRING(-2 -2, 12 7)", true);
test_geometry<poly_cw_c, ls>("POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))", "LINESTRING(5 5, 15 4)", true);
test_geometry<poly_cw_c, ls>("POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))", "LINESTRING(7 6, 15 4)", true);
test_geometry<poly_cw_c, ls>("POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))", "LINESTRING(6 2, 12 1)", true);
// MULTI
test_geometry<ls, mpoly_ccw_c>("LINESTRING(1 1,2 2)", "MULTIPOLYGON(((0 0,10 0,10 10,0 10,0 0)))", true);
test_geometry<mls, mpoly_ccw_c>("MULTILINESTRING((1 1,2 2))", "MULTIPOLYGON(((0 0,10 0,10 10,0 10,0 0)))", true);
}
template <typename P1, typename P2>
void test_intersects_linestring_ring()
{
typedef bg::model::linestring<P1> ls;
typedef bg::model::multi_linestring<ls> mls;
typedef bg::model::ring<P2, false> ring_ccw_c;
test_geometry<ls, ring_ccw_c>("LINESTRING(1 1,2 2)", "POLYGON((0 0,10 0,10 10,0 10,0 0))", true);
test_geometry<ls, ring_ccw_c>("LINESTRING(1 0,2 2)", "POLYGON((0 0,10 0,10 10,0 10,0 0))", true);
test_geometry<ls, ring_ccw_c>("LINESTRING(11 0,12 12)", "POLYGON((0 0,10 0,10 10,0 10,0 0))", false);
// MULTI
test_geometry<mls, ring_ccw_c>("MULTILINESTRING((1 1,2 2))", "POLYGON((0 0,10 0,10 10,0 10,0 0))", true);
}
template <typename P1, typename P2>
void test_intersects_ring_polygon()
{
typedef bg::model::ring<P1, false, false> ring_ccw_o;
typedef bg::model::polygon<P2, false, false> poly_ccw_o;
test_geometry<ring_ccw_o, poly_ccw_o>("POLYGON((1 1, 3 3, 2 5))", "POLYGON((0 0, 9 0, 9 9, 0 9),(5 5,5 8,8 8,8 5))", true);
test_geometry<ring_ccw_o, poly_ccw_o>("POLYGON((6 6, 7 6, 7 7, 6 7))", "POLYGON((0 0, 9 0, 9 9, 0 9),(5 5,5 8,8 8,8 5))", false);
test_geometry<ring_ccw_o, poly_ccw_o>("POLYGON((7 7, 9 7, 9 9, 7 9))", "POLYGON((0 0, 9 0, 9 9, 0 9),(5 5,5 8,8 8,8 5))", true);
test_geometry<ring_ccw_o, poly_ccw_o>("POLYGON((6 6,7 6,7 7,6 7))", "POLYGON((0 0, 9 0, 9 9, 0 9),(5 5,5 8,8 8,8 5))", false);
}
template <typename P1, typename P2>
void test_intersects_point_linestring()
{
typedef bg::model::linestring<P2> ls;
typedef bg::model::multi_linestring<ls> mls;
test_geometry<P1, ls>("POINT(0 0)", "LINESTRING(0 0,2 2,4 0)", true);
test_geometry<P1, ls>("POINT(1 1)", "LINESTRING(0 0,2 2,4 0)", true);
test_geometry<P1, ls>("POINT(1 0)", "LINESTRING(0 0,2 2,4 0)", false);
// MULTI
test_geometry<P1, mls>("POINT(0 0)", "MULTILINESTRING((0 0,2 2,4 0))", true);
}
template <typename P1, typename P2>
void test_intersects_point_segment()
{
typedef bg::model::segment<P2> seg;
test_geometry<P1, seg>("POINT(0 0)", "LINESTRING(0 0,2 2)", true);
test_geometry<P1, seg>("POINT(1 1)", "LINESTRING(0 0,2 2)", true);
test_geometry<P1, seg>("POINT(1 0)", "LINESTRING(0 0,2 2)", false);
}
template <typename P1, typename P2>
void test_multi_linestring_polygon()
{
typedef bg::model::linestring<P1> ls;
typedef bg::model::multi_linestring<ls> mls;
typedef bg::model::polygon<P2> poly;
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))",
true);
test_geometry<mls, poly>("MULTILINESTRING((10 0, 18 12),(2 2,2 1))",
"POLYGON((5 0,0 -5,-5 0,0 5,5 0))",
true);
}
template <typename P1, typename P2>
void test_multi_polygon_polygon()
{
typedef bg::model::polygon<P1> poly1;
typedef bg::model::multi_polygon<poly1> mpoly;
typedef bg::model::polygon<P2> poly2;
test_geometry<mpoly, poly2>("MULTIPOLYGON(((11 11,11 20,20 20,20 11,11 11)),((5 5,5 6,6 6,6 5,5 5)))",
"POLYGON((0 0,0 10,10 10,10 0,0 0),(2 2,4 2,4 4,2 4,2 2))",
true);
}
template <typename P1, typename P2>
void test_point_polygon()
{
typedef bg::model::ring<P2> ring;
typedef bg::model::polygon<P2> poly;
test_geometry<P1, ring>(
"POINT(0 0)",
"POLYGON((0 0,3 3,3 3,4 1))",
true);
test_geometry<P1, poly>(
"POINT(0 0)",
"POLYGON((0 0,3 3,3 3,4 1))",
true);
test_geometry<ring, P1>(
"POLYGON((0 0,3 3,3 3,4 1))",
"POINT(0 0)",
true);
test_geometry<poly, P1>(
"POLYGON((0 0,3 3,3 3,4 1))",
"POINT(0 0)",
true);
}
template <typename P1, typename P2>
void test_all()
{
test_intersects_point_segment<P1, P2>();
test_intersects_point_linestring<P1, P2>();
test_intersects_polygon_polygon<P1, P2>();
test_intersects_linestring_polygon<P1, P2>();
test_intersects_linestring_ring<P1, P2>();
test_intersects_linestring_segment<P1, P2>();
test_intersects_linestring_linestring<P1, P2>();
test_intersects_ring_polygon<P1, P2>();
test_multi_linestring_polygon<P1, P2>();
test_multi_polygon_polygon<P1, P2>();
test_point_polygon<P1, P2>();
}
template <typename P>
void test_all()
{
test_all<P, P>();
}
int test_main( int , char* [] )
{
test_all<bg::model::d2::point_xy<double> >();
test_all<bg::model::d2::point_xy<double>, bg::model::point<double, 2, bg::cs::cartesian> >();
#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;
}

View File

@@ -0,0 +1,172 @@
// 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, 2016.
// Modifications copyright (c) 2013-2016, 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 P1, typename P2>
void test_all()
{
typedef bg::model::polygon<P1> polygon;
typedef bg::model::ring<P1> ring;
// intersect <=> ! disjoint (in most cases)
// so most tests are done in disjoint test.
// We only test compilation of a few cases.
test_geometry<P1, bg::model::box<P2> >("POINT(1 1)", "BOX(0 0,2 2)", true);
test_geometry<polygon, bg::model::box<P2> >(
"POLYGON((1992 3240,1992 1440,3792 1800,3792 3240,1992 3240))",
"BOX(1941 2066, 2055 2166)", true);
test_geometry<ring, bg::model::box<P2> >(
"POLYGON((1992 3240,1992 1440,3792 1800,3792 3240,1992 3240))",
"BOX(1941 2066, 2055 2166)", true);
test_geometry<polygon, bg::model::box<P2> >(
"POLYGON((1941 2066,2055 2066,2055 2166,1941 2166))",
"BOX(1941 2066, 2055 2166)", true);
test_geometry<P1, bg::model::box<P2> >(
"POINT(0 0)",
"BOX(0 0,4 4)",
true);
}
template <typename P>
void test_all()
{
test_all<P, P>();
}
// 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);
// http://stackoverflow.com/questions/32457920/boost-rtree-of-box-gives-wrong-intersection-with-segment
// http://lists.boost.org/geometry/2015/09/3476.php
typedef bg::model::point<typename bg::coordinate_type<P>::type, 3, bg::cs::cartesian> point3d_t;
test_geometry<bg::model::segment<point3d_t>, bg::model::box<point3d_t> >(
"SEGMENT(2 1 0,2 1 10)",
"BOX(0 0 0,10 0 10)",
false);
test_geometry<bg::model::segment<point3d_t>, bg::model::box<point3d_t> >(
"SEGMENT(2 1 0,2 1 10)",
"BOX(0 -5 0,10 0 10)",
false);
// and derived from the cases above
test_geometry<bg::model::segment<P>, bg::model::box<P> >(
"SEGMENT(12 0,20 10)",
"BOX(0 0,10 10)",
false);
test_geometry<bg::model::segment<P>, bg::model::box<P> >(
"SEGMENT(2 0,8 6)",
"BOX(0 0,10 10)",
true);
test_geometry<bg::model::segment<P>, bg::model::box<P> >(
"SEGMENT(2 0,18 8)",
"BOX(0 0,10 10)",
true);
test_geometry<bg::model::segment<P>, bg::model::box<P> >(
"SEGMENT(1 0,1 10)",
"BOX(0 0,0 10)",
false);
test_geometry<bg::model::segment<P>, bg::model::box<P> >(
"SEGMENT(-1 0,-1 10)",
"BOX(0 0,0 10)",
false);
test_geometry<bg::model::segment<P>, bg::model::box<P> >(
"SEGMENT(2 1,2 1)",
"BOX(0 0,10 0)",
false);
test_geometry<bg::model::segment<P>, bg::model::box<P> >(
"SEGMENT(2 3,2 3)",
"BOX(0 0,10 0)",
false);
test_geometry<bg::model::segment<P>, bg::model::box<P> >(
"SEGMENT(0 0,10 0)",
"BOX(0 0,10 0)",
true);
test_geometry<bg::model::segment<P>, bg::model::box<P> >(
"SEGMENT(10 0,10 0)",
"BOX(0 0,10 0)",
true);
test_geometry<bg::model::segment<P>, bg::model::box<P> >(
"SEGMENT(1 0,1 0)",
"BOX(0 0,10 0)",
true);
test_geometry<bg::model::segment<P>, bg::model::box<P> >(
"SEGMENT(0 0,0 10)",
"BOX(0 0,0 10)",
true);
test_geometry<bg::model::segment<P>, bg::model::box<P> >(
"SEGMENT(0 10,0 10)",
"BOX(0 0,0 10)",
true);
test_geometry<bg::model::segment<P>, bg::model::box<P> >(
"SEGMENT(0 1,0 1)",
"BOX(0 0,0 10)",
true);
}
int test_main( int , char* [] )
{
test_all<bg::model::d2::point_xy<float>, bg::model::point<double, 2, bg::cs::cartesian> >();
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;
}

View File

@@ -0,0 +1,63 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// Unit Test
// Copyright (c) 2012-2015 Barend Gehrels, Amsterdam, the Netherlands.
// This file was modified by Oracle on 2016.
// Modifications copyright (c) 2016, 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 <iostream>
#include <string>
#include <geometry_test_common.hpp>
#include "test_intersects.hpp"
#include <boost/geometry.hpp>
#include <boost/geometry/geometries/geometries.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
template <typename P1, typename P2>
void test_all()
{
typedef bg::model::polygon<P1> polygon1;
typedef bg::model::multi_polygon<polygon1> mp1;
typedef bg::model::polygon<P2> polygon2;
typedef bg::model::multi_polygon<polygon2> mp2;
test_geometry<mp1, mp2>("MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)))",
"MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)))",
true);
test_geometry<P1, mp2>("POINT(0 0)",
"MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)))",
true);
}
template <typename P>
void test_all()
{
test_all<P, P>();
}
int test_main(int, char* [])
{
//test_all<bg::model::d2::point_xy<float> >();
test_all<bg::model::d2::point_xy<double> >();
test_all<bg::model::d2::point_xy<double>, bg::model::point<double, 2, bg::cs::cartesian> >();
#ifdef HAVE_TTMATH
test_all<bg::model::d2::point_xy<ttmath_big> >();
#endif
return 0;
}

View File

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

View File

@@ -0,0 +1,269 @@
// Boost.Geometry
// Copyright (c) 2016 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_intersects.hpp"
#include <algorithms/overlay/overlay_cases.hpp>
#include <algorithms/overlay/multi_overlay_cases.hpp>
#include <boost/geometry/geometries/geometries.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],
true);
test_geometry<ring, poly>(case_1[0], case_1[1],
true);
test_geometry<poly, poly>(case_1[0], case_1[1],
true);
test_geometry<poly, poly>(case_2[0], case_2[1],
true);
test_geometry<poly, poly>(case_3_sph[0], case_3_sph[1],
true);
test_geometry<poly, poly>(case_3_2_sph[0], case_3_2_sph[1],
true);
test_geometry<poly, poly>(case_4[0], case_4[1],
true);
test_geometry<poly, poly>(case_5[0], case_5[1],
true);
test_geometry<poly, poly>(case_6_sph[0], case_6_sph[1],
true);
test_geometry<poly, poly>(case_7[0], case_7[1],
true);
test_geometry<poly, poly>(case_8_sph[0], case_8_sph[1],
true);
test_geometry<poly, poly>(case_9_sph[0], case_9_sph[1],
true);
test_geometry<poly, poly>(case_10_sph[0], case_10_sph[1],
true);
test_geometry<poly, poly>(case_11_sph[0], case_11_sph[1],
true);
test_geometry<poly, poly>(case_12[0], case_12[1],
true);
test_geometry<poly, poly>(case_13_sph[0], case_13_sph[1],
true);
test_geometry<poly, poly>(case_14_sph[0], case_14_sph[1],
true);
test_geometry<poly, poly>(case_15_sph[0], case_15_sph[1],
true);
test_geometry<poly, poly>(case_16_sph[0], case_16_sph[1],
true);
test_geometry<poly, poly>(case_17_sph[0], case_17_sph[1],
true);
test_geometry<poly, poly>(case_17_sph[1], case_17_sph[0],
true);
test_geometry<poly, poly>(case_18_sph[0], case_18_sph[1],
true);
test_geometry<poly, poly>(case_18_sph[1], case_18_sph[0],
true);
}
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],
true);
test_geometry<poly, mpoly>(case_2[0], case_multi_2[0],
true);
}
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],
true);
}
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))", false);
test_geometry<ls, ring>("LINESTRING(11 0,11 10)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", false);
test_geometry<ls, poly>("LINESTRING(0 0,10 10)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", true);
test_geometry<ls, poly>("LINESTRING(5 0,5 5,10 5)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", true);
test_geometry<ls, poly>("LINESTRING(5 1,5 5,9 5)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", true);
test_geometry<ls, poly>("LINESTRING(11 1,11 5)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", false);
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))",
true);
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))",
true);
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))",
true);
}
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)))",
true);
}
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))",
true);
test_geometry<mls, ring>("MULTILINESTRING((6 6,15 15),(0 0, 7 7))",
"POLYGON((5 5,5 15,15 15,15 5,5 5))",
true);
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))",
true);
}
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)))",
true);
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)))",
true);
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)))",
true);
}
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)", true);
test_geometry<ls, ls>("LINESTRING(1 0,2 2,2 3)", "LINESTRING(0 0, 2 2, 3 2)", true);
}
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))",
true);
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))",
true);
}
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))",
true);
}
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))",
true);
test_geometry<P, poly>("POINT(-120 21)",
"POLYGON((30 0,30 30,90 30, 90 0, 30 0))",
false);
// extended
test_geometry<P, poly>("POINT(0 -90)",
"POLYGON((0 -80,90 -80, -180 -80, -90 -80, 0 -80))",
true);
test_geometry<P, poly>("POINT(0 89)",
"POLYGON((0 80,-90 80, -180 80, 90 80, 0 80))",
true);
test_geometry<P, poly>("POINT(-180 89)",
"POLYGON((0 80,-90 80, -180 80, 90 80, 0 80))",
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>();
}
int test_main( int , char* [] )
{
test_all<bg::model::point<double, 2, bg::cs::spherical_equatorial<bg::degree> > >();
#if defined(HAVE_TTMATH)
test_cs<bg::model::point<ttmath_big, 2, bg::cs::spherical_equatorial<bg::degree> > >();
#endif
return 0;
}

View File

@@ -0,0 +1,86 @@
// Boost.Geometry
// Copyright (c) 2016 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_intersects.hpp"
#include <boost/geometry/geometries/geometries.hpp>
template <typename P>
void test_point_box()
{
typedef bg::model::box<P> box_t;
test_geometry<P, box_t>("POINT(0 0)", "BOX(0 0, 1 1)", true);
test_geometry<P, box_t>("POINT(1 1)", "BOX(0 0, 2 2)", true);
test_geometry<P, box_t>("POINT(180 1)", "BOX(170 0, 190 2)", true);
test_geometry<P, box_t>("POINT(-180 1)", "BOX(170 0, 190 2)", true);
test_geometry<P, box_t>("POINT(180 1)", "BOX(170 0, 180 2)", true);
test_geometry<P, box_t>("POINT(-180 1)", "BOX(170 0, 180 2)", true);
test_geometry<P, box_t>("POINT(179 1)", "BOX(170 0, 190 2)", true);
test_geometry<P, box_t>("POINT(-179 1)", "BOX(170 0, 190 2)", true);
test_geometry<P, box_t>("POINT(179 1)", "BOX(170 0, 180 2)", true);
test_geometry<P, box_t>("POINT(-179 1)", "BOX(170 0, 180 2)", false);
test_geometry<P, box_t>("POINT(169 1)", "BOX(170 0, 180 2)", false);
}
template <typename P>
void test_box_box()
{
typedef bg::model::box<P> box_t;
test_geometry<box_t, box_t>("BOX(0 0, 1 1)", "BOX(0 0, 1 1)", true);
test_geometry<box_t, box_t>("BOX(-170 0,-160 1)", "BOX(-180 0, 180 1)", true);
test_geometry<box_t, box_t>("BOX(-170 0,-160 1)", "BOX(170 0, 200 1)", true);
test_geometry<box_t, box_t>("BOX(-170 0,-150 1)", "BOX(170 0, 200 1)", true);
test_geometry<box_t, box_t>("BOX(201 0,202 1)", "BOX(170 0, 200 1)", false); // invalid g1?
test_geometry<box_t, box_t>("BOX(-159 0,-158 1)", "BOX(170 0, 200 1)", false);
test_geometry<box_t, box_t>("BOX(160 0,169 1)", "BOX(170 0, 200 1)", false);
test_geometry<box_t, box_t>("BOX(-159 0,169 1)", "BOX(170 0, 200 1)", false);
test_geometry<box_t, box_t>("BOX(0 0,1 1)", "BOX(170 0, 370 1)", true);
test_geometry<box_t, box_t>("BOX(0 0,10 1)", "BOX(170 0, 370 1)", true);
test_geometry<box_t, box_t>("BOX(-180 0,10 1)", "BOX(170 0, 370 1)", true);
test_geometry<box_t, box_t>("BOX(-180 0,20 1)", "BOX(170 0, 370 1)", true);
test_geometry<box_t, box_t>("BOX(10 0,20 1)", "BOX(170 0, 370 1)", true);
test_geometry<box_t, box_t>("BOX(160 0,180 1)", "BOX(170 0, 370 1)", true);
test_geometry<box_t, box_t>("BOX(160 0,165 1)", "BOX(170 0, 370 1)", false);
test_geometry<box_t, box_t>("BOX(15 0,20 1)", "BOX(170 0, 370 1)", false);
test_geometry<box_t, box_t>("BOX(375 0,380 1)", "BOX(170 0, 370 1)", false); // invalid g1?
test_geometry<box_t, box_t>("BOX(-180 0,-170 1)", "BOX(180 0, 190 1)", true); // invalid?
test_geometry<box_t, box_t>("BOX(-180 0,-170 1)", "BOX(180 0, 191 1)", true); // invalid?
test_geometry<box_t, box_t>("BOX(-180 0,-170 1)", "BOX(179 0, 190 1)", true);
test_geometry<box_t, box_t>("BOX(-180 0,-170 1)", "BOX(181 0, 190 1)", true); // invalid?
test_geometry<box_t, box_t>("BOX(-180 0,-170 1)", "BOX(180 0, 189 1)", true); // invalid?
}
template <typename P>
void test_cs()
{
test_point_box<P>();
test_box_box<P>();
}
int test_main( int , char* [] )
{
test_cs<bg::model::point<double, 2, bg::cs::spherical_equatorial<bg::degree> > >();
test_cs<bg::model::point<double, 2, bg::cs::geographic<bg::degree> > >();
#if defined(HAVE_TTMATH)
test_cs<bg::model::point<ttmath_big, 2, bg::cs::spherical_equatorial<bg::degree> > >();
test_cs<bg::model::point<ttmath_big, 2, bg::cs::geographic<bg::degree> > >();;
#endif
return 0;
}

View File

@@ -0,0 +1,115 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// Unit Test
// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands.
// Copyright (c) 2013-2015 Adam Wulkiewicz, Lodz, Poland.
// This file was modified by Oracle on 2017.
// Modifications copyright (c) 2017 Oracle and/or its affiliates.
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
// Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_GEOMETRY_TEST_INTERSECTS_HPP
#define BOOST_GEOMETRY_TEST_INTERSECTS_HPP
#include <geometry_test_common.hpp>
#include <boost/geometry/core/geometry_id.hpp>
#include <boost/geometry/core/point_order.hpp>
#include <boost/geometry/core/ring_type.hpp>
#include <boost/geometry/algorithms/covered_by.hpp>
#include <boost/geometry/algorithms/intersects.hpp>
#include <boost/geometry/strategies/strategies.hpp>
#include <boost/geometry/geometries/ring.hpp>
#include <boost/geometry/geometries/polygon.hpp>
#include <boost/geometry/geometries/multi_linestring.hpp>
#include <boost/geometry/geometries/multi_polygon.hpp>
#include <boost/geometry/io/wkt/read.hpp>
struct no_strategy {};
template <typename Geometry1, typename Geometry2, typename Strategy>
bool call_intersects(Geometry1 const& geometry1,
Geometry2 const& geometry2,
Strategy const& strategy)
{
return bg::intersects(geometry1, geometry2, strategy);
}
template <typename Geometry1, typename Geometry2>
bool call_intersects(Geometry1 const& geometry1,
Geometry2 const& geometry2,
no_strategy)
{
return bg::intersects(geometry1, geometry2);
}
template <typename G1, typename G2, typename Strategy>
void check_intersects(std::string const& wkt1,
std::string const& wkt2,
G1 const& g1,
G2 const& g2,
bool expected,
Strategy const& strategy)
{
bool detected = call_intersects(g1, g2, strategy);
BOOST_CHECK_MESSAGE(detected == expected,
"intersects: " << wkt1
<< " with " << wkt2
<< " -> Expected: " << expected
<< " detected: " << detected);
}
template <typename Geometry1, typename Geometry2>
void test_geometry(std::string const& wkt1,
std::string const& wkt2, bool expected)
{
Geometry1 geometry1;
Geometry2 geometry2;
bg::read_wkt(wkt1, geometry1);
bg::read_wkt(wkt2, geometry2);
check_intersects(wkt1, wkt2, geometry1, geometry2, expected, no_strategy());
check_intersects(wkt2, wkt1, geometry2, geometry1, expected, no_strategy());
typedef typename bg::strategy::disjoint::services::default_strategy
<
Geometry1, Geometry2
>::type strategy12_type;
typedef typename bg::strategy::disjoint::services::default_strategy
<
Geometry2, Geometry1
>::type strategy21_type;
check_intersects(wkt1, wkt2, geometry1, geometry2, expected, strategy12_type());
check_intersects(wkt2, wkt1, geometry2, geometry1, expected, strategy21_type());
}
template <typename Geometry>
void test_self_intersects(std::string const& wkt, bool expected)
{
Geometry geometry;
bg::read_wkt(wkt, geometry);
bool detected = bg::intersects(geometry);
BOOST_CHECK_MESSAGE(detected == expected,
"intersects: " << wkt
<< " -> Expected: " << expected
<< " detected: " << detected);
}
#endif

View File

@@ -0,0 +1,130 @@
// Boost.Geometry
// Copyright (c) 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 <geometry_test_common.hpp>
#include <boost/geometry/geometries/geometries.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
#include <boost/range/value_type.hpp>
#include <boost/type_traits/is_same.hpp>
template <typename Container>
struct pusher
: public Container
{
typedef typename Container::value_type value_type;
pusher(value_type const& val)
{
this->push_back(val);
}
pusher & operator()(value_type const& val)
{
this->push_back(val);
return *this;
}
};
template <typename Geometry,
typename Tag = typename bg::tag<Geometry>::type,
typename Coord = typename bg::coordinate_type<Geometry>::type>
struct nan_case_generator
{
static void apply(Geometry & , std::string & )
{}
};
template <typename Geometry>
struct nan_case_generator<Geometry, bg::multi_linestring_tag, double>
{
static void apply(Geometry & geometry, std::string & wkt)
{
typedef typename boost::range_value<Geometry>::type ls;
typedef typename bg::point_type<Geometry>::type P;
typedef typename bg::coordinate_type<Geometry>::type coord_t;
coord_t nan = std::numeric_limits<coord_t>::quiet_NaN();
wkt = "MULTILINESTRING((3.1e+307 1,-nan -nan),(3.1e+307 1,-nan -nan),(3.1e+307 1,5.1e+307 6e+307,nan nan),(-nan -nan,nan nan),(-nan -nan,-1 -3.97843,-1 3.28571,-1 47.6364),(3 78.5455,3 2),(nan nan,3 12.9689),(3 -2,-nan -nan),(3 2,3 12.9689,3 78.5455),(-1 4.29497e+09,-1 7,-nan -nan),(9 5,-nan -nan),(-nan -nan,9 60.8755,9 124.909),(nan nan,1 6.87195e+10,-nan -nan),(nan nan,4 86.2727,4 20.9533),(4 -5,-nan -nan),(4 -5,-nan -nan),(4 -5,-nan -nan),(4 -5,1.1e+308 2.1e+307,nan nan),(-nan -nan,-1 -8),(-nan -nan,-9 -4))";
typedef pusher<Geometry> ml;
typedef pusher<ls> l;
geometry = ml(l(P(3.1e+307, 1))(P(-nan, -nan)))
(l(P(3.1e+307, 1))(P(-nan, -nan)))
(l(P(3.1e+307, 1))(P(5.1e+307, 6e+307))(P(nan, nan)))
(l(P(-nan, -nan))(P(nan, nan)))
(l(P(-nan, -nan))(P(-1, -3.97843))(P(-1, 3.28571))(P(-1, 47.6364)))
(l(P(3, 78.5455))(P(3, 2)))
(l(P(nan, nan))(P(3, 12.9689)))
(l(P(3, -2))(P(-nan, -nan)))
(l(P(3, 2))(P(3, 12.9689))(P(3, 78.5455)))
(l(P(-1, 4.29497e+09))(P(-1, 7))(P(-nan, -nan)))
(l(P(9, 5))(P(-nan, -nan)))
(l(P(-nan, -nan))(P(9, 60.8755))(P(9, 124.909)))
(l(P(nan, nan))(P(1, 6.87195e+10))(P(-nan, -nan)))
(l(P(nan, nan))(P(4, 86.2727))(P(4, 20.9533)))
(l(P(4, -5))(P(-nan, -nan)))
(l(P(4, -5))(P(-nan, -nan)))
(l(P(4, -5))(P(-nan, -nan)))
(l(P(4, -5))(P(1.1e+308, 2.1e+307))(P(nan, nan)))
(l(P(-nan, -nan))(P(-1, -8)))
(l(P(-nan, -nan))(P(-9, -4)));
}
};
template <typename Geometry>
struct nan_case_generator<Geometry, bg::multi_point_tag, double>
{
static void apply(Geometry & geometry, std::string & wkt)
{
typedef typename bg::point_type<Geometry>::type P;
typedef typename bg::coordinate_type<Geometry>::type coord_t;
coord_t nan = std::numeric_limits<coord_t>::quiet_NaN();
wkt = "MULTIPOINT((3.1e+307 1),(-nan -nan),(3.1e+307 1),(-nan -nan),(3.1e+307 1),(5.1e+307 6e+307),(nan nan),(-nan -nan),(nan nan),(-nan -nan),(-1 -3.97843),(-1 3.28571),(-1 47.6364),(3 78.5455),(3 2),(nan nan),(3 12.9689),(3 -2),(-nan -nan),(3 2),(3 12.9689),(3 78.5455),(-1 4.29497e+09),(-1 7),(-nan -nan),(9 5),(-nan -nan),(-nan -nan),(9 60.8755),(9 124.909),(nan nan),(1 6.87195e+10),(-nan -nan),(nan nan),(4 86.2727),(4 20.9533),(4 -5),(-nan -nan),(4 -5),(-nan -nan),(4 -5),(-nan -nan),(4 -5),(1.1e+308 2.1e+307),(nan nan),(-nan -nan),(-1 -8),(-nan -nan),(-9 -4))";
typedef pusher<Geometry> mp;
geometry = mp(P(3.1e+307, 1))(P(-nan, -nan))
(P(3.1e+307, 1))(P(-nan, -nan))
(P(3.1e+307, 1))(P(5.1e+307, 6e+307))(P(nan, nan))
(P(-nan, -nan))(P(nan, nan))
(P(-nan, -nan))(P(-1, -3.97843))(P(-1, 3.28571))(P(-1, 47.6364))
(P(3, 78.5455))(P(3, 2))
(P(nan, nan))(P(3, 12.9689))
(P(3, -2))(P(-nan, -nan))
(P(3, 2))(P(3, 12.9689))(P(3, 78.5455))
(P(-1, 4.29497e+09))(P(-1, 7))(P(-nan, -nan))
(P(9, 5))(P(-nan, -nan))
(P(-nan, -nan))(P(9, 60.8755))(P(9, 124.909))
(P(nan, nan))(P(1, 6.87195e+10))(P(-nan, -nan))
(P(nan, nan))(P(4, 86.2727))(P(4, 20.9533))
(P(4, -5))(P(-nan, -nan))
(P(4, -5))(P(-nan, -nan))
(P(4, -5))(P(-nan, -nan))
(P(4, -5))(P(1.1e+308, 2.1e+307))(P(nan, nan))
(P(-nan, -nan))(P(-1, -8))
(P(-nan, -nan))(P(-9, -4));
}
};
template <typename Geometry>
void nan_case(Geometry & geometry, std::string & wkt)
{
nan_case_generator<Geometry>::apply(geometry, wkt);
}
template <typename Geometry>
struct is_nan_case_supported
{
typedef typename bg::coordinate_type<Geometry>::type coord_t;
static const bool value = boost::is_same<coord_t, double>::value
&& std::numeric_limits<coord_t>::has_quiet_NaN;
};

View 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, 2016.
# Modifications copyright (c) 2014-2016, 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-overlaps
:
[ run overlaps.cpp : : : : algorithms_overlaps ]
[ run overlaps_areal.cpp : : : : algorithms_overlaps_areal ]
[ run overlaps_box.cpp : : : : algorithms_overlaps_box ]
[ run overlaps_sph.cpp : : : : algorithms_overlaps_sph ]
;

View File

@@ -0,0 +1,63 @@
// 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, 2017.
// Modifications copyright (c) 2014-2017 Oracle and/or its affiliates.
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
// Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include "test_overlaps.hpp"
template <typename P>
void test_pp()
{
typedef bg::model::multi_point<P> mpt;
test_geometry<P, P>("POINT(0 0)", "POINT(0 0)", false);
test_geometry<P, P>("POINT(0 0)", "POINT(1 1)", false);
test_geometry<P, mpt>("POINT(0 0)", "MULTIPOINT(0 0, 1 1)", false);
test_geometry<mpt, P>("MULTIPOINT(0 0, 1 1)", "POINT(0 0)", false);
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;
}

View File

@@ -0,0 +1,73 @@
// 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_aa()
{
typedef bg::model::polygon<P> poly;
typedef bg::model::multi_polygon<poly> mpoly;
test_geometry<poly, poly>("POLYGON((0 0,0 5,5 5,5 0,0 0))", "POLYGON((3 3,3 9,9 9,9 3,3 3))", true);
test_geometry<poly, poly>("POLYGON((0 0,0 5,5 5,5 0,0 0))", "POLYGON((5 5,5 9,9 9,9 5,5 5))", false);
test_geometry<poly, poly>("POLYGON((0 0,0 5,5 5,5 0,0 0))", "POLYGON((3 3,3 5,5 5,5 3,3 3))", false);
test_geometry<poly, mpoly>("POLYGON((0 0,0 5,5 5,5 0,0 0))",
"MULTIPOLYGON(((3 3,3 5,5 5,5 3,3 3)),((5 5,5 6,6 6,6 5,5 5)))",
true);
test_geometry<mpoly, mpoly>("MULTIPOLYGON(((3 3,3 5,5 5,5 3,3 3)),((0 0,0 3,3 3,3 0,0,0)))",
"MULTIPOLYGON(((3 3,3 5,5 5,5 3,3 3)),((5 5,5 6,6 6,6 5,5 5)))",
true);
// related to https://svn.boost.org/trac/boost/ticket/10912
test_geometry<poly, poly>("POLYGON((0 0,0 10,10 10,10 0,0 0),(2 2,4 2,4 4,2 4,2 2))",
"POLYGON((3 3,3 9,9 9,9 3,3 3))",
true);
test_geometry<poly, poly>("POLYGON((0 0,0 10,10 10,10 0,0 0),(2 2,4 2,4 4,2 4,2 2),(6 6,8 6,8 8,6 8,6 6))",
"POLYGON((0 0,0 5,5 5,5 0,0 0))",
true);
test_geometry<mpoly, poly>("MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)),((0 0,0 -10,-10 -10,-10 0,0 0)))",
"POLYGON((0 0,0 5,5 5,5 0,0 0))",
false);
test_geometry<mpoly, poly>("MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)),((0 0,0 -10,-10 -10,-10 0,0 0)))",
"POLYGON((0 0,0 10,10 10,10 0,0 0))",
false);
// mysql 21872795
test_geometry<poly, poly>("POLYGON((2 2,2 8,8 8,8 2,2 2))",
"POLYGON((0 0,0 10,10 10,10 0,0 0),(8 8,4 6,4 4,8 8))",
true);
test_geometry<poly, poly>("POLYGON((2 2,2 8,8 8,8 2,2 2))",
"POLYGON((0 0,0 10,10 10,10 0,0 0),(2 2,4 4,4 6,2 2))",
true);
}
template <typename P>
void test_2d()
{
test_aa<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;
}

View File

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

View File

@@ -0,0 +1,153 @@
// Boost.Geometry
// Copyright (c) 2016 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"
#include <algorithms/overlay/overlay_cases.hpp>
#include <algorithms/overlay/multi_overlay_cases.hpp>
#include <boost/geometry/geometries/geometries.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],
true);
test_geometry<ring, poly>(case_1[0], case_1[1],
true);
test_geometry<poly, poly>(case_1[0], case_1[1],
true);
test_geometry<poly, poly>(case_2[0], case_2[1],
true);
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],
true);
test_geometry<poly, poly>(case_5[0], case_5[1],
true);
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],
true);
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_18_sph[0], case_18_sph[1],
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],
true);
test_geometry<poly, mpoly>(case_2[0], case_multi_2[0],
true);
}
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],
true);
}
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);
}
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))",
true);
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))",
true);
}
template <typename P>
void test_all()
{
test_polygon_polygon<P>();
test_polygon_multi_polygon<P>();
test_multi_polygon_multi_polygon<P>();
test_linestring_linestring<P>();
test_linestring_multi_linestring<P>();
test_multi_linestring_multi_linestring<P>();
}
int test_main( int , char* [] )
{
test_all<bg::model::point<double, 2, bg::cs::spherical_equatorial<bg::degree> > >();
#if defined(HAVE_TTMATH)
test_cs<bg::model::point<ttmath_big, 2, bg::cs::spherical_equatorial<bg::degree> > >();
#endif
return 0;
}

View File

@@ -0,0 +1,94 @@
// Generic Geometry2 Library
// Unit Test
// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
// This file was modified by Oracle on 2015, 2017.
// Modifications copyright (c) 2015-2017 Oracle and/or its affiliates.
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
// Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_GEOMETRY_TEST_OVERLAPS_HPP
#define BOOST_GEOMETRY_TEST_OVERLAPS_HPP
#include <geometry_test_common.hpp>
#include <boost/geometry/core/ring_type.hpp>
#include <boost/geometry/algorithms/overlaps.hpp>
#include <boost/geometry/strategies/strategies.hpp>
#include <boost/geometry/geometries/geometries.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/io/wkt/read.hpp>
struct no_strategy {};
template <typename Geometry1, typename Geometry2, typename Strategy>
bool call_overlaps(Geometry1 const& geometry1,
Geometry2 const& geometry2,
Strategy const& strategy)
{
return bg::overlaps(geometry1, geometry2, strategy);
}
template <typename Geometry1, typename Geometry2>
bool call_overlaps(Geometry1 const& geometry1,
Geometry2 const& geometry2,
no_strategy)
{
return bg::overlaps(geometry1, geometry2);
}
template <typename Geometry1, typename Geometry2, typename Strategy>
void test_geometry(Geometry1 const& geometry1,
Geometry2 const& geometry2,
std::string const& wkt1,
std::string const& wkt2,
bool expected,
Strategy const& strategy)
{
bool detected = call_overlaps(geometry1, geometry2, strategy);
BOOST_CHECK_MESSAGE(detected == expected,
"overlaps: " << wkt1
<< " with " << wkt2
<< " -> Expected: " << expected
<< " detected: " << detected);
detected = call_overlaps(geometry2, geometry1, strategy);
BOOST_CHECK_MESSAGE(detected == expected,
"overlaps: " << wkt2
<< " with " << wkt1
<< " -> Expected: " << expected
<< " detected: " << detected);
}
template <typename Geometry1, typename Geometry2>
void test_geometry(std::string const& wkt1,
std::string const& wkt2,
bool expected)
{
Geometry1 geometry1;
Geometry2 geometry2;
bg::read_wkt(wkt1, geometry1);
bg::read_wkt(wkt2, geometry2);
test_geometry(geometry1, geometry2, wkt1, wkt2, expected, no_strategy());
typedef typename bg::strategy::relate::services::default_strategy
<
Geometry1, Geometry2
>::type strategy_type;
test_geometry(geometry1, geometry2, wkt1, wkt2, expected, strategy_type());
}
#endif

View File

@@ -0,0 +1,26 @@
# 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.
# Modifications copyright (c) 2014-2016, 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-relate
:
[ run relate_areal_areal.cpp : : : : algorithms_relate_areal_areal ]
[ run relate_areal_areal_sph.cpp : : : : algorithms_relate_areal_areal_sph ]
[ run relate_linear_areal.cpp : : : : algorithms_relate_linear_areal ]
[ run relate_linear_areal_sph.cpp : : : : algorithms_relate_linear_areal_sph ]
[ run relate_linear_linear.cpp : : : : algorithms_relate_linear_linear ]
[ run relate_linear_linear_sph.cpp : : : : algorithms_relate_linear_linear_sph ]
[ run relate_pointlike_geometry.cpp : : : : algorithms_relate_pointlike_geometry ]
;

View File

@@ -0,0 +1,434 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// Copyright (c) 2007-2012 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_relate.hpp"
//#include <to_svg.hpp>
template <typename P>
void test_polygon_polygon()
{
typedef bg::model::polygon<P> poly;
typedef bg::model::ring<P> ring;
// touching
test_geometry<poly, poly>("POLYGON((0 0,0 10,10 10,10 0,0 0))",
"POLYGON((10 0,10 10,20 10,20 0,10 0))",
"FF2F11212");
test_geometry<poly, poly>("POLYGON((0 0,0 10,10 10,10 0,0 0))",
"POLYGON((0 -10,0 0,10 0,10 -10,0 -10))",
"FF2F11212");
test_geometry<poly, poly>("POLYGON((0 0,0 10,10 10,10 0,0 0))",
"POLYGON((10 0,15 10,20 10,20 0,10 0))",
"FF2F01212");
// containing
test_geometry<poly, poly>("POLYGON((0 0,0 10,10 10,10 0,0 0))",
"POLYGON((5 5,5 10,6 10,6 5,5 5))",
"212F11FF2");
test_geometry<poly, poly>("POLYGON((0 0,0 10,10 10,10 0,0 0))",
"POLYGON((5 5,5 10,6 5,5 5))",
"212F01FF2");
test_geometry<poly, poly>("POLYGON((0 0,0 10,10 10,10 0,0 0))",
"POLYGON((5 5,5 6,6 6,6 5,5 5))",
"212FF1FF2");
// fully containing
test_geometry<poly, poly>("POLYGON((0 0,0 10,10 10,10 0,0 0))",
"POLYGON((5 5,5 9,6 9,6 5,5 5))",
"212FF1FF2");
// fully containing, with a hole
test_geometry<poly, poly>("POLYGON((0 0,0 10,10 10,10 0,0 0),(3 3,7 3,7 7,3 7,3 3))",
"POLYGON((1 1,1 9,9 9,9 1,1 1))",
"2121F12F2");
// fully containing, both with holes
test_geometry<poly, poly>("POLYGON((0 0,0 10,10 10,10 0,0 0),(3 3,7 3,7 7,3 7,3 3))",
"POLYGON((1 1,1 9,9 9,9 1,1 1),(2 2,8 2,8 8,2 8,2 2))",
"212FF1FF2");
// fully containing, both with holes
test_geometry<poly, poly>("POLYGON((0 0,0 10,10 10,10 0,0 0),(3 3,7 3,7 7,3 7,3 3))",
"POLYGON((1 1,1 9,9 9,9 1,1 1),(4 4,6 4,6 6,4 6,4 4))",
"2121F1212");
// overlapping
test_geometry<poly, poly>("POLYGON((0 0,0 10,10 10,10 0,0 0))",
"POLYGON((5 0,5 10,20 10,20 0,5 0))",
"212111212");
test_geometry<ring, poly>("POLYGON((0 0,0 10,10 10,10 0,0 0))",
"POLYGON((5 0,5 10,20 10,20 0,5 0))",
"212111212");
test_geometry<ring, ring>("POLYGON((0 0,0 10,10 10,10 0,0 0))",
"POLYGON((5 0,5 10,20 10,20 0,5 0))",
"212111212");
test_geometry<poly, poly>("POLYGON((0 0,0 10,10 10,15 5,10 0,0 0))",
"POLYGON((10 0,5 5,10 10,20 10,20 0,10 0))",
"212101212");
// equal
test_geometry<poly, poly>("POLYGON((0 0,0 10,10 10,10 0,0 0))",
"POLYGON((10 10,10 5,10 0,5 0,0 0,0 10,5 10,10 10))",
"2FFF1FFF2");
// hole-sized
test_geometry<poly, poly>("POLYGON((0 0,0 10,10 10,10 0,0 0),(5 5,6 5,6 6,5 6,5 5))",
"POLYGON((5 5,5 6,6 6,6 5,5 5))",
"FF2F112F2");
// disjoint
test_geometry<poly, poly>("POLYGON((0 0,0 10,10 10,10 0,0 0))",
"POLYGON((0 20,0 30,10 30,10 20,0 20))",
"FF2FF1212");
// disjoint
test_geometry<poly, poly>("POLYGON((0 0,0 10,10 10,10 0,0 0),(3 3,7 3,7 7,3 7,3 3))",
"POLYGON((0 20,0 30,10 30,10 20,0 20))",
"FF2FF1212");
// equal non-simple / non-simple hole
test_geometry<poly, poly>("POLYGON((0 0,0 10,10 10,10 0,0 0),(5 5,10 5,5 6,5 5))",
"POLYGON((0 0,0 10,10 10,10 5,5 6,5 5,10 5,10 0,0 0))",
"2FFF1FFF2");
// within non-simple / simple
test_geometry<poly, poly>("POLYGON((0 0,0 10,10 10,10 5,5 6,5 5,10 5,10 0,0 0))",
"POLYGON((0 0,5 5,10 5,10 0,0 0))",
"212F11FF2");
// within non-simple hole / simple
test_geometry<poly, poly>("POLYGON((0 0,0 10,10 10,10 0,0 0),(5 5,10 5,5 6,5 5))",
"POLYGON((0 0,5 5,10 5,10 0,0 0))",
"212F11FF2");
// not within non-simple / simple
test_geometry<poly, poly>("POLYGON((0 0,0 10,10 10,10 5,5 6,5 5,10 5,10 0,0 0))",
"POLYGON((0 0,0 10,10 10,10 0,0 0))",
"2FF11F2F2");
// not within non-simple hole / simple
test_geometry<poly, poly>("POLYGON((0 0,0 10,10 10,10 0,0 0),(5 5,10 5,5 6,5 5))",
"POLYGON((0 0,0 10,10 10,10 0,0 0))",
"2FF11F2F2");
// not within simple hole / simple
test_geometry<poly, poly>("POLYGON((0 0,0 10,10 10,10 0,0 0),(5 5,9 5,5 6,5 5))",
"POLYGON((0 0,0 10,10 10,9 5,10 0,0 0))",
"2121112F2");
// within non-simple fake hole / simple
test_geometry<poly, poly>("POLYGON((0 0,0 10,10 10,10 5,4 7,4 3,10 5,10 0,0 0))",
"POLYGON((0 0,0 10,10 10,10 0,0 0))",
"2FF11F2F2");
// within non-simple fake hole / non-simple fake hole
test_geometry<poly, poly>("POLYGON((0 0,0 10,10 10,10 5,4 7,4 3,10 5,10 0,0 0))",
"POLYGON((0 0,0 10,10 10,10 5,5 6,5 4,10 5,10 0,0 0))",
"2FF11F212");
// within non-simple fake hole / non-simple hole
test_geometry<poly, poly>("POLYGON((0 0,0 10,10 10,10 5,4 7,4 3,10 5,10 0,0 0))",
"POLYGON((0 0,0 10,10 10,10 0,0 0),(10 5,5 6,5 4,10 5))",
"2FF11F212");
// containing non-simple fake hole / non-simple hole
test_geometry<poly, poly>("POLYGON((0 0,0 10,10 10,10 5,4 7,4 3,10 5,10 0,0 0))",
"POLYGON((0 0,0 10,10 10,10 0,0 0),(10 5,3 8,3 2,10 5))",
"212F11FF2");
// within non-simple hole / simple
test_geometry<poly, poly>("POLYGON((0 0,0 10,10 10,10 0,0 0),(10 5,4 7,4 3,10 5))",
"POLYGON((0 0,0 10,10 10,10 0,0 0))",
"2FF11F2F2");
// within non-simple hole / non-simple fake hole
test_geometry<poly, poly>("POLYGON((0 0,0 10,10 10,10 0,0 0),(10 5,4 7,4 3,10 5))",
"POLYGON((0 0,0 10,10 10,10 5,5 6,5 4,10 5,10 0,0 0))",
"2FF11F212");
// containing non-simple hole / non-simple fake hole
test_geometry<poly, poly>("POLYGON((0 0,0 10,10 10,10 0,0 0),(10 5,4 7,4 3,10 5))",
"POLYGON((0 0,0 10,10 10,10 5,3 8,3 2,10 5,10 0,0 0))",
"212F11FF2");
// equal non-simple hole / non-simple fake hole
test_geometry<poly, poly>("POLYGON((0 0,0 10,10 10,10 0,0 0),(10 5,4 7,4 3,10 5))",
"POLYGON((0 0,0 10,10 10,10 5,4 7,4 3,10 5,10 0,0 0))",
"2FFF1FFF2");
// within non-simple hole / non-simple hole
test_geometry<poly, poly>("POLYGON((0 0,0 10,10 10,10 0,0 0),(10 5,4 7,4 3,10 5))",
"POLYGON((0 0,0 10,10 10,10 0,0 0),(10 5,5 6,5 4,10 5))",
"2FF11F212");
// containing non-simple hole / non-simple hole
test_geometry<poly, poly>("POLYGON((0 0,0 10,10 10,10 0,0 0),(10 5,4 7,4 3,10 5))",
"POLYGON((0 0,0 10,10 10,10 0,0 0),(10 5,3 8,3 2,10 5))",
"212F11FF2");
// equal non-simple hole / non-simple hole
test_geometry<poly, poly>("POLYGON((0 0,0 10,10 10,10 0,0 0),(10 5,4 7,4 3,10 5))",
"POLYGON((0 0,0 10,10 10,10 0,0 0),(10 5,4 7,4 3,10 5))",
"2FFF1FFF2");
// intersecting non-simple hole / non-simple hole - touching holes
test_geometry<poly, poly>("POLYGON((0 0,0 10,10 10,10 0,0 0),(5 5,10 5,5 6,5 5))",
"POLYGON((0 0,0 10,10 10,10 0,0 0),(0 5,5 4,5 5,0 5))",
"21211F2F2");
// intersecting non-simple fake hole / non-simple hole - touching holes
test_geometry<poly, poly>("POLYGON((0 0,0 10,10 10,10 5,5 6,5 5,10 5,10 0,0 0))",
"POLYGON((0 0,0 10,10 10,10 0,0 0),(0 5,5 4,5 5,0 5))",
"21211F2F2");
// intersecting non-simple fake hole / non-simple fake hole - touching holes
test_geometry<poly, poly>("POLYGON((0 0,0 10,10 10,10 5,5 6,5 5,10 5,10 0,0 0))",
"POLYGON((0 0,0 5,5 4,5 5,0 5,0 10,10 10,10 0,0 0))",
"21211F2F2");
// intersecting simple - i/i
test_geometry<poly, poly>("POLYGON((0 0,0 10,4 10,6 8,5 5,6 2,4 0,0 0))",
"POLYGON((5 5,4 8,6 10,10 10,10 0,6 0,4 2,5 5))",
"212101212");
// intersecting non-simple hole / non-simple hole - i/i
test_geometry<poly, poly>("POLYGON((0 0,0 10,4 10,6 8,5 5,6 2,4 0,0 0),(5 5,2 6,2 4,5 5))",
"POLYGON((5 5,4 8,6 10,10 10,10 0,6 0,4 2,5 5),(5 5,8 4,8 6,5 5))",
"212101212");
// intersecting non-simple hole / simple - i/i
test_geometry<poly, poly>("POLYGON((0 0,0 10,4 10,6 8,5 5,6 2,4 0,0 0),(5 5,2 6,2 4,5 5))",
"POLYGON((5 5,4 8,6 10,10 10,10 0,6 0,4 2,5 5))",
"212101212");
// no turns - disjoint inside a hole
test_geometry<poly, poly>("POLYGON((0 0,0 10,10 10,10 0,0 0),(1 1,9 1,9 9,1 9,1 1))",
"POLYGON((3 3,3 7,7 7,7 3,3 3))",
"FF2FF1212");
// no turns - within
test_geometry<poly, poly>("POLYGON((0 0,0 10,10 10,10 0,0 0),(1 1,9 1,9 9,1 9,1 1))",
"POLYGON((-1 -1,-1 11,11 11,11 -1,-1 -1))",
"2FF1FF212");
// no-turns - intersects
test_geometry<poly, poly>("POLYGON((0 0,0 10,10 10,10 0,0 0),(2 2,8 2,8 8,2 8,2 2))",
"POLYGON((1 1,1 9,9 9,9 1,1 1))",
"2121F12F2");
// no-turns - intersects, hole in a hole
test_geometry<poly, poly>("POLYGON((0 0,0 10,10 10,10 0,0 0),(2 2,8 2,8 8,2 8,2 2))",
"POLYGON((1 1,1 9,9 9,9 1,1 1),(3 3,7 3,7 7,3 7,3 3))",
"2121F1212");
// no-turns ring - for exteriors
test_geometry<poly, poly>("POLYGON((0 0,0 10,10 10,10 0,0 0),(2 2,8 2,8 8,2 8,2 2))",
"POLYGON((1 1,1 9,9 9,9 1,1 1),(2 2,8 2,8 8,2 8,2 2))",
"212F11FF2");
// no-turns ring - for interiors
test_geometry<poly, poly>("POLYGON((0 0,0 10,10 10,10 0,0 0),(3 3,7 3,7 7,3 7,3 3))",
"POLYGON((0 0,0 10,10 10,10 0,0 0),(2 2,8 2,8 8,2 8,2 2))",
"212F11FF2");
{
test_geometry<poly, poly>("POLYGON((0 0,0 10,10 10,10 0,0 0))",
"POLYGON((5 5,5 10,6 10,6 5,5 5))",
"212F11FF2");
test_geometry<poly, poly>("POLYGON((0 0,0 10,10 10,10 0,0 0))",
"POLYGON((10 0,10 10,20 10,20 0,10 0))",
"FF2F11212");
namespace bgdr = bg::detail::relate;
poly p1, p2, p3;
bg::read_wkt("POLYGON((0 0,0 10,10 10,10 0,0 0))", p1);
bg::read_wkt("POLYGON((10 0,10 10,20 10,20 0,10 0))", p2);
bg::read_wkt("POLYGON((5 5,5 10,6 10,6 5,5 5))", p3);
BOOST_CHECK(bg::relate(p1, p2, bg::de9im::mask("FT*******")
|| bg::de9im::mask("F**T*****")
|| bg::de9im::mask("F***T****"))); // touches()
BOOST_CHECK(bg::relate(p1, p3, bg::de9im::mask("T*****FF*"))); // contains()
BOOST_CHECK(bg::relate(p2, p3, bg::de9im::mask("FF*FF****"))); // disjoint()
BOOST_CHECK(bg::relate(p1, p2, bg::de9im::static_mask<'F','T'>()
|| bg::de9im::static_mask<'F','*','*','T'>()
|| bg::de9im::static_mask<'F','*','*','*','T'>()));
}
// CCW
{
typedef bg::model::polygon<P, false> poly;
// within non-simple hole / simple
test_geometry<poly, poly>("POLYGON((0 0,10 0,10 10,0 10,0 0),(5 5,5 6,10 5,5 5))",
"POLYGON((0 0,10 0,10 5,5 5,0 0))",
"212F11FF2");
}
// OPEN
{
typedef bg::model::polygon<P, true, false> poly;
// within non-simple hole / simple
test_geometry<poly, poly>("POLYGON((0 0,0 10,10 10,10 0),(5 5,10 5,5 6))",
"POLYGON((0 0,5 5,10 5,10 0))",
"212F11FF2");
}
// CCW, OPEN
{
typedef bg::model::polygon<P, false, false> poly;
// within non-simple hole / simple
test_geometry<poly, poly>("POLYGON((0 0,10 0,10 10,0 10),(5 5,5 6,10 5))",
"POLYGON((0 0,10 0,10 5,5 5))",
"212F11FF2");
}
// https://svn.boost.org/trac/boost/ticket/10912
{
// external rings touches and G2's hole is inside G1
test_geometry<poly, poly>("POLYGON((0 0,0 5,5 5,5 0,0 0))",
"POLYGON((0 0,0 10,10 10,10 0,0 0),(2 2,4 2,4 4,2 4,2 2),(6 6,8 6,8 8,6 8,6 6))",
"21211F212");
test_geometry<poly, poly>("POLYGON((0 0,0 10,10 10,10 0,0 0))",
"POLYGON((0 0,0 10,10 10,10 0,0 0),(2 2,2 4,4 4,4 2,2 2))",
"212F1FFF2");
// extended
// external rings touches and G1's hole is inside G2
test_geometry<poly, poly>("POLYGON((0 0,0 9,9 9,9 0,0 0),(2 2,7 2,7 7,2 7,2 2))",
"POLYGON((0 0,0 10,10 10,10 0,0 0))",
"2FF11F212");
// external rings touches, holes doesn't
test_geometry<poly, poly>("POLYGON((0 0,0 9,9 9,9 0,0 0),(2 2,7 2,7 7,2 7,2 2))",
"POLYGON((0 0,0 10,10 10,10 0,0 0),(1 1,8 1,8 8,1 8,1 1))",
"212111212");
test_geometry<poly, poly>("POLYGON((0 0,0 10,10 10,10 0,0 0),(2 2,7 2,7 7,2 7,2 2))",
"POLYGON((0 0,0 10,10 10,10 0,0 0),(1 1,8 1,8 8,1 8,1 1))",
"212F11FF2");
// holes touches, external rings doesn't
test_geometry<poly, poly>("POLYGON((1 1,1 9,9 9,9 1,1 1),(2 2,8 2,8 8,2 8,2 2))",
"POLYGON((0 0,0 10,10 10,10 0,0 0),(2 2,7 2,7 7,2 7,2 2))",
"2FF11F212");
test_geometry<poly, poly>("POLYGON((1 1,1 9,9 9,9 1,1 1),(2 2,7 2,7 7,2 7,2 2))",
"POLYGON((0 0,0 10,10 10,10 0,0 0),(2 2,8 2,8 8,2 8,2 2))",
"212111212");
test_geometry<poly, poly>("POLYGON((0 0,0 10,10 10,10 0,0 0),(2 2,8 2,8 8,2 8,2 2))",
"POLYGON((0 0,0 10,10 10,10 0,0 0),(2 2,7 2,7 7,2 7,2 2))",
"2FF11F212");
test_geometry<poly, poly>("POLYGON((3 3,3 9,9 9,9 3,3 3))",
"POLYGON((0 0,0 10,10 10,10 0,0 0),(2 2,4 2,4 4,2 4,2 2))",
"212101212");
}
if ( BOOST_GEOMETRY_CONDITION((
boost::is_same<typename bg::coordinate_type<P>::type, double>::value )) )
{
// original - assertion for CCW
//"POLYGON((-0.593220338983050821113352 -8.05084745762711939676137,1.14285714285714279370154 -4,1.50731707317073171381594 1.10243902439024443751237,1.73758865248226967992196 1.37588652482269591104114,1.21739130434782616418943 -3.82608695652173924628414,2 -2,2 1.68750000000000044408921,2.35384615384615436539661 2.10769230769230775379697,2 2.16666666666666651863693,2 4,1.81967213114754100544701 2.1967213114754100544701,1.5882352941176469673934 2.2352941176470588757752,1.8148148148148146585612 5.4074074074074074403029,-0.538461538461538546940233 4.23076923076923083755219,-1.76510067114094004736558 2.89261744966443012927471,-1.64864864864864868465588 2.7567567567567570208098,-1.83962264150943455298659 2.81132075471698161805989,-1.84337349397590433142113 2.80722891566265086993326,-2.14285714285714279370154 2.85714285714285720629846,-2.11111111111111116045436 2.88888888888888883954564,-2.87234042553191448732264 3.10638297872340407579372,-2.91803278688524558859285 3.4262295081967208965068,-3.1733333333333324510761 3.26666666666666660745477,-2.99999999999999822364316 3.14285714285714234961233,-3.25490196078431326398572 3.21568627450980359938626,-3.47368421052631504153396 3.07894736842105265495206,-7.32000000000000028421709 3.72000000000000019539925,-7.54716981132075481752963 3.62264150943396234794136,-7.75 3.79166666666666651863693,-7.79999999999999982236432 3.79999999999999982236432,-7.59999999999999964472863 3.60000000000000008881784,-8.8556701030927822415606 3.06185567010309300783888,-8.82945736434108674473009 2.8914728682170549589614,-7.73333333333333339254523 2.193939393939393855959,-8 2,-5.94736842105263185942476 -1.42105263157894645686952,-5.32558139534883689947264 -0.488372093023255016142059,-5.85714285714285765038767 1.00000000000000066613381,-4.78723404255319184841255 0.319148936170212838003835,-5.32558139534883689947264 -0.488372093023255016142059,-4.74019607843137258385013 -2.12745098039215774221589,-3.17647058823529437887601 -0.705882352941176627325603,-2.93103448275862055183438 -0.862068965517241436735674,-3 -1,-4.57894736842105309904127 -2.57894736842105265495206,-4.47887323943661996850096 -2.85915492957746497637572,-7.58620689655172419918472 -5.18965517241379359347775,-7.52525252525252508206677 -5.5858585858585865224768,-4.18644067796610119813749 -3.67796610169491522412955,-3.44041450777202051369841 -5.76683937823834202873741,-3.73611111111111116045436 -6.56944444444444464181743,-2.8823529411764705621124 -7.7647058823529411242248,-2.88235294117647100620161 -7.7647058823529411242248,-0.593220338983050821113352 -8.05084745762711939676137),(1.66666666666666696272614 1.59999999999999875655021,1.43749999999999911182158 1.8750000000000002220446,0.0869565217391310429917439 2.26086956521739113057379,0.466666666666667118157363 2.60606060606060552231611,1.04878048780487764801705 2.34146341463414664474385,1.43749999999999911182158 1.8750000000000002220446,1.56756756756756754356275 1.83783783783783771781373,1.66666666666666696272614 1.59999999999999875655021))"
//"POLYGON((-2.33333333333333303727386 -8.66666666666666607454772,-2.26315789473684203514381 -8.63157894736842123961651,-2.88235294117647100620161 -7.7647058823529411242248,-2.8823529411764705621124 -7.7647058823529411242248,-4.11949685534591125701809 -7.61006289308176064878353,-4.32530120481927671249878 -8.16867469879518104391991,-2.33333333333333303727386 -8.66666666666666607454772))"
// assertion failure in 1.57
test_geometry<poly, poly>("POLYGON((-0.59322033898305082 -8.0508474576271194,-2.882352941176471 -7.7647058823529411,-2.8823529411764706 -7.7647058823529411,-3.7361111111111112 -6.5694444444444446,-3.4404145077720205 -5.766839378238342,-4.1864406779661012 -3.6779661016949152,-7.5252525252525251 -5.5858585858585865,-7.5862068965517242 -5.1896551724137936,-4.47887323943662 -2.859154929577465,-4.5789473684210531 -2.5789473684210527,-3 -1,-2.9310344827586206 -0.86206896551724144,-3.1764705882352944 -0.70588235294117663,-4.7401960784313726 -2.1274509803921577,-5.3255813953488369 -0.48837209302325502,-4.7872340425531918 0.31914893617021284,-5.8571428571428577 1.0000000000000007,-5.3255813953488369 -0.48837209302325502,-5.9473684210526319 -1.4210526315789465,-8 2,-7.7333333333333334 2.1939393939393939,-8.8294573643410867 2.891472868217055,-8.8556701030927822 3.061855670103093,-7.5999999999999996 3.6000000000000001,-7.7999999999999998 3.7999999999999998,-7.75 3.7916666666666665,-7.5471698113207548 3.6226415094339623,-7.3200000000000003 3.7200000000000002,-3.473684210526315 3.0789473684210527,-3.2549019607843133 3.2156862745098036,-2.9999999999999982 3.1428571428571423,-3.1733333333333325 3.2666666666666666,-2.9180327868852456 3.4262295081967209,-2.8723404255319145 3.1063829787234041,-2.1111111111111112 2.8888888888888888,-2.1428571428571428 2.8571428571428572,-1.8433734939759043 2.8072289156626509,-1.8396226415094346 2.8113207547169816,-1.6486486486486487 2.756756756756757,-1.76510067114094 2.8926174496644301,-0.53846153846153855 4.2307692307692308,1.8148148148148147 5.4074074074074074,1.588235294117647 2.2352941176470589,1.819672131147541 2.1967213114754101,2 4,2 2.1666666666666665,2.3538461538461544 2.1076923076923078,2 1.6875000000000004,2 -2,1.2173913043478262 -3.8260869565217392,1.7375886524822697 1.3758865248226959,1.5073170731707317 1.1024390243902444,1.1428571428571428 -4,-0.59322033898305082 -8.0508474576271194),(1.666666666666667 1.5999999999999988,1.5675675675675675 1.8378378378378377,1.4374999999999991 1.8750000000000002,1.0487804878048776 2.3414634146341466,0.46666666666666712 2.6060606060606055,0.086956521739131043 2.2608695652173911,1.4374999999999991 1.8750000000000002,1.666666666666667 1.5999999999999988))",
"POLYGON((-2.333333333333333 -8.6666666666666661,-4.3253012048192767 -8.168674698795181,-4.1194968553459113 -7.6100628930817606,-2.8823529411764706 -7.7647058823529411,-2.882352941176471 -7.7647058823529411,-2.263157894736842 -8.6315789473684212,-2.333333333333333 -8.6666666666666661))",
"*********");
// simpler case
test_geometry<poly, poly>("POLYGON((0 0, -0.59322033898305082 -8.0508474576271194, -2.8823529411764710 -7.7647058823529411, -3.7361111111111112 -6.5694444444444446, 0 0))",
"POLYGON((-10 -10, -4.1194968553459113 -7.6100628930817606, -2.8823529411764706 -7.7647058823529411, -2.2631578947368420 -8.6315789473684212, -10 -10))",
"FF2F01212");
// sanity check
test_geometry<poly, poly>("POLYGON((0 0, -0.59322033898305082 -8.0508474576271194, -2.8823529411764710 -7.7647058823529411, -3.7361111111111112 -6.5694444444444446, 0 0))",
"POLYGON((-10 -10, -4.1194968553459113 -7.6100628930817606, -2.8823529411764710 -7.7647058823529411, -2.2631578947368420 -8.6315789473684212, -10 -10))",
"FF2F01212");
// compatibility check
/*test_geometry<poly, poly>("POLYGON((0 0,0 1,1 1,1 0,0 0))",
"POLYGON((1 1,1 2,2 2,2 1,1 1))",
"****0****");
test_geometry<P, P>("POINT(0.9999999999999998 0.9999999999999998)",
"POINT(1 1)",
"0********");
test_geometry<P, P>("POINT(0.9999999999999995 0.9999999999999995)",
"POINT(1 1)",
"F********");
test_geometry<poly, poly>("POLYGON((0 0,0 1,0.9999999999999998 0.9999999999999998,1 0,0 0))",
"POLYGON((1 1,1 2,2 2,2 1,1 1))",
"****0****");
test_geometry<poly, poly>("POLYGON((0 0,0 1,0.9999999999999995 0.9999999999999995,1 0,0 0))",
"POLYGON((1 1,1 2,2 2,2 1,1 1))",
"****F****");*/
}
// mysql 21872795 (overlaps)
test_geometry<poly, poly>("POLYGON((2 2,2 8,8 8,8 2,2 2))",
"POLYGON((0 0,0 10,10 10,10 0,0 0),(8 8,4 6,4 4,8 8))",
"21210F212");
test_geometry<poly, poly>("POLYGON((2 2,2 8,8 8,8 2,2 2))",
"POLYGON((0 0,0 10,10 10,10 0,0 0),(2 2,4 4,4 6,2 2))",
"21210F212");
// mysql 21873343 (touches)
test_geometry<poly, poly>("POLYGON((0 0,0 10,10 10,10 0,0 0), (0 8, 8 5, 8 8, 0 8))",
"POLYGON((0 8,-8 5,-8 8,0 8))",
"FF2F01212");
test_geometry<poly, poly>("POLYGON((0 0,0 10,10 10,10 0,0 0), (0 6, 6 3, 6 6, 0 6))",
"POLYGON((0 6,-6 3,-6 6,0 6))",
"FF2F01212");
// similar but touching from the inside of the hole
test_geometry<poly, poly>("POLYGON((0 0,0 10,10 10,10 0,0 0), (0 8, 8 5, 8 8, 0 8))",
"POLYGON((0 8,7 7, 7 6,0 8))",
"FF2F01212");
}
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<poly, mpoly>("POLYGON((0 0,0 10,10 10,10 0,0 0))",
"MULTIPOLYGON(((5 5,5 10,6 10,6 5,5 5)),((0 20,0 30,10 30,10 20,0 20)))",
"212F11212");
test_geometry<ring, mpoly>("POLYGON((0 0,0 10,10 10,10 0,0 0))",
"MULTIPOLYGON(((5 5,5 10,6 10,6 5,5 5)),((0 20,0 30,10 30,10 20,0 20)))",
"212F11212");
test_geometry<mpoly, poly>("MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)),((0 0,0 -10,-10 -10,-10 0,0 0)))",
"POLYGON((0 0,0 5,5 5,5 0,0 0))",
"212F11FF2");
test_geometry<poly, mpoly>("POLYGON((0 0,0 5,5 5,5 0,0 0))",
"MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)),((0 0,0 -10,-10 -10,-10 0,0 0)))",
"2FF11F212");
test_geometry<poly, mpoly>("POLYGON((0 0,0 5,5 5,5 0,0 0))",
"MULTIPOLYGON(((0 0,0 -10,-10 -10,-10 0,0 0)),((0 0,0 10,10 10,10 0,0 0)))",
"2FF11F212");
test_geometry<poly, mpoly>("POLYGON((0 0,0 10,10 10,10 0,0 0))",
"MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)),((0 0,0 -10,-10 -10,-10 0,0 0)))",
"2FFF1F212");
}
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>("MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)))",
"MULTIPOLYGON(((5 5,5 10,6 10,6 5,5 5)),((0 20,0 30,10 30,10 20,0 20)))",
"212F11212");
test_geometry<mpoly, mpoly>("MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)),((0 20,0 30,10 30,10 20,0 20)))",
"MULTIPOLYGON(((5 5,5 10,6 10,6 5,5 5)))",
"212F11FF2");
test_geometry<mpoly, mpoly>("MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)))",
"MULTIPOLYGON(((5 5,5 6,6 6,6 5,5 5)),((0 20,0 30,10 30,10 20,0 20)))",
"212FF1212");
test_geometry<mpoly, mpoly>("MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)),((0 20,0 30,10 30,10 20,0 20)))",
"MULTIPOLYGON(((5 5,5 6,6 6,6 5,5 5)))",
"212FF1FF2");
}
template <typename P>
void test_all()
{
test_polygon_polygon<P>();
test_polygon_multi_polygon<P>();
test_multi_polygon_multi_polygon<P>();
}
int test_main( int , char* [] )
{
test_all<bg::model::d2::point_xy<int> >();
test_all<bg::model::d2::point_xy<double> >();
#if defined(HAVE_TTMATH)
test_all<bg::model::d2::point_xy<ttmath_big> >();
#endif
return 0;
}

View File

@@ -0,0 +1,115 @@
// Boost.Geometry
// Unit Test
// Copyright (c) 2016, 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_relate.hpp"
#include <algorithms/overlay/overlay_cases.hpp>
#include <algorithms/overlay/multi_overlay_cases.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],
"212101212");
test_geometry<ring, poly>(case_1[0], case_1[1],
"212101212");
test_geometry<poly, poly>(case_1[0], case_1[1],
"212101212");
test_geometry<poly, poly>(case_2[0], case_2[1],
"212101212");
test_geometry<poly, poly>(case_3_sph[0], case_3_sph[1],
"2FF10F212");
test_geometry<poly, poly>(case_3_2_sph[0], case_3_2_sph[1],
"2FFF1FFF2");
test_geometry<poly, poly>(case_4[0], case_4[1],
"212101212");
test_geometry<poly, poly>(case_5[0], case_5[1],
"212101212");
test_geometry<poly, poly>(case_6_sph[0], case_6_sph[1],
"212F11FF2");
test_geometry<poly, poly>(case_7[0], case_7[1],
"FF2F11212");
test_geometry<poly, poly>(case_8_sph[0], case_8_sph[1],
"FF2F11212");
test_geometry<poly, poly>(case_9_sph[0], case_9_sph[1],
"FF2F01212");
test_geometry<poly, poly>(case_10_sph[0], case_10_sph[1],
"FF2F11212");
test_geometry<poly, poly>(case_11_sph[0], case_11_sph[1],
"212F01FF2");
test_geometry<poly, poly>(case_12[0], case_12[1],
"212101212");
test_geometry<poly, poly>(case_13_sph[0], case_13_sph[1],
"FF2F11212");
test_geometry<poly, poly>(case_14_sph[0], case_14_sph[1],
"FF2F11212");
test_geometry<poly, poly>(case_15_sph[0], case_15_sph[1],
"FF2F11212");
test_geometry<poly, poly>(case_16_sph[0], case_16_sph[1],
"FF2F11212");
test_geometry<poly, poly>(case_17_sph[0], case_17_sph[1],
"212F11FF2");
test_geometry<poly, poly>(case_18_sph[0], case_18_sph[1],
"212F11FF2");
}
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],
"212101212");
test_geometry<poly, mpoly>(case_2[0], case_multi_2[0],
"212101212");
}
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],
"212101212");
}
template <typename P>
void test_all()
{
test_polygon_polygon<P>();
test_polygon_multi_polygon<P>();
test_multi_polygon_multi_polygon<P>();
}
int test_main( int , char* [] )
{
typedef bg::cs::spherical_equatorial<bg::degree> cs_t;
test_all<bg::model::point<float, 2, cs_t> >();
test_all<bg::model::point<double, 2, cs_t> >();
#if defined(HAVE_TTMATH)
test_all<bg::model::point<ttmath_big, 2, cs_t> >();
#endif
return 0;
}

View File

@@ -0,0 +1,535 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// Copyright (c) 2007-2012 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_relate.hpp"
#include "../nan_cases.hpp"
//TEST
//#include <to_svg.hpp>
template <typename P>
void test_linestring_polygon()
{
typedef bg::model::linestring<P> ls;
typedef bg::model::polygon<P> poly;
typedef bg::model::ring<P> ring;
// LS disjoint
test_geometry<ls, poly>("LINESTRING(11 0,11 10)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "FF1FF0212");
test_geometry<ls, ring>("LINESTRING(11 0,11 10)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "FF1FF0212");
// II BB
test_geometry<ls, poly>("LINESTRING(0 0,10 10)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "1FFF0F212");
test_geometry<ls, poly>("LINESTRING(5 0,5 5,10 5)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "1FFF0F212");
test_geometry<ls, poly>("LINESTRING(5 1,5 5,9 5)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "1FF0FF212");
// IE
test_geometry<ls, poly>("LINESTRING(11 1,11 5)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "FF1FF0212");
// IE IB0
test_geometry<ls, poly>("LINESTRING(11 1,10 5)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "FF1F00212");
// IE IB1
test_geometry<ls, poly>("LINESTRING(11 1,10 5,10 10)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "F11F00212");
test_geometry<ls, poly>("LINESTRING(11 1,10 10,0 10)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "F11F00212");
test_geometry<ls, poly>("LINESTRING(11 1,10 0,0 0)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "F11F00212");
test_geometry<ls, poly>("LINESTRING(0 -1,1 0,2 0)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "F11F00212");
// IE IB0 II
test_geometry<ls, poly>("LINESTRING(11 1,10 5,5 5)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "1010F0212");
// IE IB0 lring
test_geometry<ls, poly>("LINESTRING(11 1,10 5,11 5,11 1)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "F01FFF212");
// IE IB1 lring
test_geometry<ls, poly>("LINESTRING(11 1,10 5,10 10,11 5,11 1)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "F11FFF212");
// IB1 II
test_geometry<ls, poly>("LINESTRING(0 0,5 0,5 5)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "11F00F212");
// BI0 II IB1
test_geometry<ls, poly>("LINESTRING(5 0,5 5,10 5,10 10)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "11FF0F212");
// IB1 II IB1
test_geometry<ls, poly>("LINESTRING(1 0,2 0,3 1,4 0,5 0)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "11FF0F212");
// IB1 IE IB1
test_geometry<ls, poly>("LINESTRING(1 0,2 0,3 -1,4 0,5 0)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "F11F0F212");
// II IB1
test_geometry<ls, poly>("LINESTRING(5 5,10 5,10 10)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "11F00F212");
// IB1 II
test_geometry<ls, poly>("LINESTRING(10 10,10 5,5 5)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "11F00F212");
// IE IB1
test_geometry<ls, poly>("LINESTRING(15 5,10 5,10 10)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "F11F00212");
// IB1 IE
test_geometry<ls, poly>("LINESTRING(10 10,10 5,15 5)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "F11F00212");
// duplicated points
{
// II IB0 IE
test_geometry<ls, poly>("LINESTRING(5 5,10 5,15 10)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "1010F0212");
test_geometry<ls, poly>("LINESTRING(5 5,5 5,5 5,10 5,10 5,10 5,15 10,15 10,15 10)",
"POLYGON((0 0,0 0,0 0,0 10,0 10,0 10,10 10,10 10,10 10,10 0,10 0,10 0,0 0,0 0,0 0))",
"1010F0212");
test_geometry<ls, poly>("LINESTRING(5 5,5 5,5 5,10 0,10 0,10 0,15 10,15 10,15 10)",
"POLYGON((0 0,0 0,0 0,0 10,0 10,0 10,10 10,10 10,10 10,10 0,10 0,10 0,0 0,0 0,0 0))",
"1010F0212");
// IE IB0 II
test_geometry<ls, poly>("LINESTRING(15 10,15 10,15 10,10 5,10 5,10 5,5 5,5 5,5 5)",
"POLYGON((0 0,0 0,0 0,0 10,0 10,0 10,10 10,10 10,10 10,10 0,10 0,10 0,0 0,0 0,0 0))",
"1010F0212");
test_geometry<ls, poly>("LINESTRING(15 10,15 10,15 10,10 0,10 0,10 0,5 5,5 5,5 5)",
"POLYGON((0 0,0 0,0 0,0 10,0 10,0 10,10 10,10 10,10 10,10 0,10 0,10 0,0 0,0 0,0 0))",
"1010F0212");
// TEST
//test_geometry<ls, poly>("LINESTRING(5 5,5 5,5 5)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "1010F0212");
test_geometry<ls, poly>("LINESTRING(5 5,5 5,5 5,15 5,15 5,15 5)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "1010F0212");
}
// non-simple polygon with hole
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))",
"10F0FF212");
test_geometry<ls, poly>("LINESTRING(10 1,10 5,10 9)",
"POLYGON((0 0,0 10,10 10,10 0,0 0),(10 5,2 8,2 2,10 5))",
"F1FF0F212");
test_geometry<ls, poly>("LINESTRING(2 8,10 5,2 2)",
"POLYGON((0 0,0 10,10 10,10 0,0 0),(10 5,2 8,2 2,10 5))",
"F1FF0F212");
test_geometry<ls, poly>("LINESTRING(10 1,10 5,2 2)",
"POLYGON((0 0,0 10,10 10,10 0,0 0),(10 5,2 8,2 2,10 5))",
"F1FF0F212");
test_geometry<ls, poly>("LINESTRING(10 1,10 5,2 8)",
"POLYGON((0 0,0 10,10 10,10 0,0 0),(10 5,2 8,2 2,10 5))",
"F1FF0F212");
// non-simple polygon with hole, linear ring
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))",
"10FFFF212");
test_geometry<ls, poly>("LINESTRING(10 5,10 9,11 5,10 1,10 5)",
"POLYGON((0 0,0 10,10 10,10 0,0 0),(10 5,2 8,2 2,10 5))",
"F11FFF212");
test_geometry<ls, poly>("LINESTRING(11 5,10 1,10 5,10 9,11 5)",
"POLYGON((0 0,0 10,10 10,10 0,0 0),(10 5,2 8,2 2,10 5))",
"F11FFF212");
// non-simple polygon with self-touching holes
test_geometry<ls, poly>("LINESTRING(7 1,8 5,7 9)",
"POLYGON((0 0,0 10,10 10,10 0,0 0),(8 1,9 1,9 9,8 9,8 1),(2 2,8 5,2 8,2 2))",
"10F0FF212");
test_geometry<ls, poly>("LINESTRING(8 2,8 5,8 8)",
"POLYGON((0 0,0 10,10 10,10 0,0 0),(8 1,9 1,9 9,8 9,8 1),(2 2,8 5,2 8,2 2))",
"F1FF0F212");
test_geometry<ls, poly>("LINESTRING(2 8,8 5,2 2)",
"POLYGON((0 0,0 10,10 10,10 0,0 0),(8 1,9 1,9 9,8 9,8 1),(2 2,8 5,2 8,2 2))",
"F1FF0F212");
// non-simple polygon self-touching
test_geometry<ls, poly>("LINESTRING(9 1,10 5,9 9)",
"POLYGON((0 0,0 10,10 10,10 5,2 8,2 2,10 5,10 0,0 0))",
"10F0FF212");
test_geometry<ls, poly>("LINESTRING(10 1,10 5,10 9)",
"POLYGON((0 0,0 10,10 10,10 5,2 8,2 2,10 5,10 0,0 0))",
"F1FF0F212");
test_geometry<ls, poly>("LINESTRING(2 8,10 5,2 2)",
"POLYGON((0 0,0 10,10 10,10 5,2 8,2 2,10 5,10 0,0 0))",
"F1FF0F212");
// non-simple polygon self-touching, linear ring
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 5,2 8,2 2,10 5,10 0,0 0))",
"10FFFF212");
test_geometry<ls, poly>("LINESTRING(10 5,10 9,11 5,10 1,10 5)",
"POLYGON((0 0,0 10,10 10,10 5,2 8,2 2,10 5,10 0,0 0))",
"F11FFF212");
test_geometry<ls, poly>("LINESTRING(11 5,10 1,10 5,10 9,11 5)",
"POLYGON((0 0,0 10,10 10,10 5,2 8,2 2,10 5,10 0,0 0))",
"F11FFF212");
// polygons with some ring equal to the linestring
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))",
"F1FFFF2F2");
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),(2 2,5 5,2 8,2 2))",
"F1FFFF212");
test_geometry<ls, poly>("LINESTRING(2 2,5 5,2 8,2 2)",
"POLYGON((0 0,0 10,10 10,10 0,0 0),(2 2,5 5,2 8,2 2))",
"F1FFFF212");
// self-IP going on the boundary then into the exterior and to the boundary again
test_geometry<ls, poly>("LINESTRING(2 10,5 10,5 15,6 15,5 10,8 10)", "POLYGON((0 0,0 10,10 10,10 0,0 0))",
"F11F0F212");
// self-IP going on the boundary then into the interior and to the boundary again
test_geometry<ls, poly>("LINESTRING(2 10,5 10,5 5,6 5,5 10,8 10)", "POLYGON((0 0,0 10,10 10,10 0,0 0))",
"11FF0F212");
// self-IP with a hole -> B to I to B to E
test_geometry<ls, poly>("LINESTRING(0 0,3 3)", "POLYGON((0 0,0 10,10 10,10 0,0 0),(0 0,9 1,9 9,1 9,0 0))",
"FF1F00212");
// ccw
{
typedef bg::model::polygon<P, false> ccwpoly;
// IE IB0 II
test_geometry<ls, ccwpoly>("LINESTRING(11 1,10 5,5 5)", "POLYGON((0 0,10 0,10 10,0 10,0 0))", "1010F0212");
// IE IB1 II
test_geometry<ls, ccwpoly>("LINESTRING(11 1,10 1,10 5,5 5)", "POLYGON((0 0,10 0,10 10,0 10,0 0))", "1110F0212");
test_geometry<ls, ccwpoly>("LINESTRING(11 1,10 5,10 1,5 5)", "POLYGON((0 0,10 0,10 10,0 10,0 0))", "1110F0212");
// II IB0 IE
test_geometry<ls, ccwpoly>("LINESTRING(5 1,10 5,11 1)", "POLYGON((0 0,10 0,10 10,0 10,0 0))", "1010F0212");
// IE IB1 II
test_geometry<ls, ccwpoly>("LINESTRING(5 5,10 1,10 5,11 5)", "POLYGON((0 0,10 0,10 10,0 10,0 0))", "1110F0212");
test_geometry<ls, ccwpoly>("LINESTRING(5 5,10 5,10 1,11 5)", "POLYGON((0 0,10 0,10 10,0 10,0 0))", "1110F0212");
}
{
// SPIKES
test_geometry<ls, poly>("LINESTRING(0 0,2 2,3 3,1 1)", "POLYGON((0 0,3 3,3 0,0 0))", "F1FF0F212");
test_geometry<ls, poly>("LINESTRING(0 0,3 3,1 1)", "POLYGON((0 0,3 3,3 0,0 0))", "F1FF0F212");
test_geometry<ls, poly>("LINESTRING(0 0,2 2,1 1)", "POLYGON((0 0,3 3,3 0,0 0))", "F1FF0F212");
test_geometry<ls, poly>("LINESTRING(1 1,3 3,2 2)", "POLYGON((0 0,3 3,3 0,0 0))", "F1FF0F212");
test_geometry<ls, poly>("LINESTRING(1 1,2 2,1 1)", "POLYGON((0 0,3 3,3 0,0 0))", "F1FFFF212");
test_geometry<ls, poly>("LINESTRING(3 3,1 1,0 0,2 2)", "POLYGON((0 0,3 3,3 0,0 0))", "F1FF0F212");
test_geometry<ls, poly>("LINESTRING(3 3,0 0,2 2)", "POLYGON((0 0,3 3,3 0,0 0))", "F1FF0F212");
test_geometry<ls, poly>("LINESTRING(2 2,0 0,1 1)", "POLYGON((0 0,3 3,3 0,0 0))", "F1FF0F212");
test_geometry<ls, poly>("LINESTRING(3 3,1 1,2 2)", "POLYGON((0 0,3 3,3 0,0 0))", "F1FF0F212");
test_geometry<ls, poly>("LINESTRING(2 2,1 1,2 2)", "POLYGON((0 0,3 3,3 0,0 0))", "F1FFFF212");
test_geometry<ls, poly>("LINESTRING(0 0,2 2,4 4,1 1)", "POLYGON((0 0,3 3,3 0,0 0))", "F11F0F212");
test_geometry<ls, poly>("LINESTRING(0 1,1 1,0 1)", "POLYGON((0 0,3 3,3 0,0 0))", "F01FFF212");
test_geometry<ls, poly>("LINESTRING(0 1,3 3,0 1)", "POLYGON((0 0,3 3,3 0,0 0))", "F01FFF212");
test_geometry<ls, poly>("LINESTRING(0 1,0 0,0 1)", "POLYGON((0 0,3 3,3 0,0 0))", "F01FFF212");
test_geometry<ls, poly>("LINESTRING(0 1,1 1,-1 1)", "POLYGON((0 0,3 3,3 0,0 0))", "F01FF0212");
}
{
// POLYGON SPIKES
// note that those are invalid Polygons and in general the result is undefined
// MySQL bug 15.12.2014 (assertion for invalid polygon)
test_geometry<ls, poly>("LINESTRING(6 3,9 0)",
"POLYGON((0 0,5 8,6 1,6 3,8 1,5 4,9 6,2 5,7 4,1 7,0 0))",
"F11F00212");
test_geometry<ls, poly>("LINESTRING(9 0,2 7)",
"POLYGON((4 1,3 2,5 9,8 4,4 5,3 6,8 1,6 2,2 4,6 0,4 1))",
"F11FF0212");
test_geometry<ls, poly>("LINESTRING(6 3,9 0)",
"POLYGON((6 1,6 3,8 1,5 4,6 1))",
"F11F00212");
test_geometry<ls, poly>("LINESTRING(6 3,8 1,9 0)",
"POLYGON((6 1,6 3,8 1,5 4,6 1))",
"F11F00212");
// entry-point spikes are not handled
test_geometry<ls, poly>("LINESTRING(9 0,6 3)",
"POLYGON((6 1,6 3,8 1,5 4,6 1))",
"**1*00212");
test_geometry<ls, poly>("LINESTRING(9 0,8 1,6 3)",
"POLYGON((6 1,6 3,8 1,5 4,6 1))",
"F11F00212");
// Ls going out-in on 2 collinear spikes touching each other
// this works partially, other invalid effect is noticeable here,
// the bottom of a spike shouldn't be there so the algorithm
// thinks the linestring is going into the interior
test_geometry<ls, poly>("LINESTRING(2 2,6 6)",
"POLYGON((0 0,0 2,2 2,4 4,3 3,5 3,5 5,4 4,7 7,7 0,0 0))",
"*1FF0F212");
// Ls going out-in on 2 collinear spikes NOT touching each other
// This is not supported, plus the same as above
test_geometry<ls, poly>("LINESTRING(2 2,6 6)",
"POLYGON((0 0,0 2,2 2,3 3,2 2,5 3,5 5,4 4,7 7,7 0,0 0))",
"*1*F0*212");
}
// 21.01.2015
test_geometry<ls, poly>("LINESTRING(3 7, 9 1)",
"POLYGON((0 0,0 10,10 10,10 0,5 5,0 0))",
"11F00F212");
// inspired by the bug for mls/poly
test_geometry<ls, poly>("LINESTRING(0 0, 7 7)",
"POLYGON((5 5,5 15,15 15,15 5,5 5))",
"1010F0212");
// 25.01.2015
test_geometry<ls, poly>("LINESTRING(4 5, 0 6, 5 6)",
"POLYGON((0 0,0 10,10 10,10 0,0 0),(4 4,6 4,6 6,4 6,4 4))",
"11FF0F212");
test_geometry<ls, poly>("LINESTRING(2 3, 4 5, 0 6, 5 6)",
"POLYGON((0 0,0 10,10 10,10 0,0 0),(4 4,6 4,6 6,4 6,4 4))",
"11F00F212");
test_geometry<ls, poly>("LINESTRING(2 9, 1 1, 10 1, 10 10, 1 10, 0 6, 5 6)",
"POLYGON((0 0,0 10,10 10,10 0,0 0),(4 4,4 6,6 6,6 4,4 4))",
"11F00F212");
}
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)))",
"F1FF0F212");
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)))",
"F1FF0F212");
test_geometry<ls, mpoly>("LINESTRING(10 1,10 5,2 2)",
"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)))",
"F1FF0F212");
test_geometry<ls, mpoly>("LINESTRING(10 1,10 5,2 2)",
"MULTIPOLYGON(((0 20,0 30,10 30,10 20,0 20)),((0 0,0 10,10 10,10 0,0 0)))",
"11F00F212");
test_geometry<ls, mpoly>("LINESTRING(10 1,10 5,2 2)",
"MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0),(10 5,2 8,2 2,10 5)),((10 5,3 3,3 7,10 5)))",
"F1FF0F212");
test_geometry<ls, mpoly>("LINESTRING(10 1,10 5,2 8)",
"MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0),(10 5,2 8,2 2,10 5)),((10 5,3 3,3 7,10 5)))",
"F1FF0F212");
test_geometry<ls, mpoly>("LINESTRING(10 1,10 5,3 3)",
"MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0),(10 5,2 8,2 2,10 5)),((10 5,3 3,3 7,10 5)))",
"F1FF0F212");
test_geometry<ls, mpoly>("LINESTRING(10 1,10 5,3 7)",
"MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0),(10 5,2 8,2 2,10 5)),((10 5,3 3,3 7,10 5)))",
"F1FF0F212");
test_geometry<ls, mpoly>("LINESTRING(10 1,10 5,5 5)",
"MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0),(10 5,2 8,2 2,10 5)),((10 5,3 3,3 7,10 5)))",
"11F00F212");
test_geometry<ls, mpoly>("LINESTRING(0 0,10 0,10 10,0 10,0 0)",
"MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)),((20 0,20 10,30 20,20 0)))",
"F1FFFF212");
// degenerated points
test_geometry<ls, mpoly>("LINESTRING(5 5,10 10,10 10,10 10,15 15)",
"MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)),((10 10,10 20,20 20,20 10,10 10)))",
"10F0FF212");
// self-IP polygon with a hole and second polygon with a hole -> B to I to B to B to I to B to E
test_geometry<ls, mpoly>("LINESTRING(0 0,3 3)",
"MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0),(0 0,9 1,9 9,1 9,0 0)),((0 0,2 8,8 8,8 2,0 0),(0 0,7 3,7 7,3 7,0 0)))",
"FF1F00212");
// self-IP polygon with a hole and second polygon -> B to I to B to B to I
test_geometry<ls, mpoly>("LINESTRING(0 0,3 3)",
"MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0),(0 0,9 1,9 9,1 9,0 0)),((0 0,2 8,8 8,8 2,0 0)))",
"1FF00F212");
test_geometry<ls, mpoly>("LINESTRING(0 0,3 3)",
"MULTIPOLYGON(((0 0,2 8,8 8,8 2,0 0)),((0 0,0 10,10 10,10 0,0 0),(0 0,9 1,9 9,1 9,0 0)))",
"1FF00F212");
// MySQL report 18.12.2014 (https://svn.boost.org/trac/boost/ticket/10887)
test_geometry<ls, mpoly>("LINESTRING(5 -2,5 2)",
"MULTIPOLYGON(((5 0,0 5,10 5,5 0)),((5 0,10 -5,0 -5,5 0)))",
"10F0FF212");
test_geometry<ls, mpoly>("LINESTRING(5 -2,5 5)",
"MULTIPOLYGON(((5 0,0 5,10 5,5 0)),((5 0,10 -5,0 -5,5 0)))",
"10F00F212");
test_geometry<ls, mpoly>("LINESTRING(5 -2,5 0)",
"MULTIPOLYGON(((5 0,0 5,10 5,5 0)),((5 0,10 -5,0 -5,5 0)))",
"1FF00F212");
// MySQL report 18.12.2014 - extended
test_geometry<ls, mpoly>("LINESTRING(5 -2,5 0)",
"MULTIPOLYGON(((5 0,0 5,10 5,5 0)),((5 0,10 -5,0 -5,5 0)),((5 0,7 1,7 -1,5 0)))",
"1FF00F212");
test_geometry<ls, mpoly>("LINESTRING(0 0,5 0)",
"MULTIPOLYGON(((5 0,0 5,10 5,5 0)),((5 0,10 -5,0 -5,5 0)),((5 0,7 1,7 -1,5 0)))",
"FF1F00212");
// 22.01.2015
test_geometry<ls, mpoly>("LINESTRING(5 5,0 0,10 0)",
"MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)),((0 0,0 -10,-10 -10,-10 0,0 0)))",
"11F00F212");
test_geometry<ls, mpoly>("LINESTRING(5 5,0 0,0 10)",
"MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)),((0 0,0 -10,-10 -10,-10 0,0 0)))",
"11F00F212");
// extended
test_geometry<ls, mpoly>("LINESTRING(5 5,0 0,2 1)",
"MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)),((0 0,0 -10,-10 -10,-10 0,0 0)))",
"10F0FF212");
test_geometry<ls, mpoly>("LINESTRING(5 5,0 0,5 -5)",
"MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)),((0 0,0 -10,-10 -10,-10 0,0 0)))",
"1010F0212");
test_geometry<ls, mpoly>("LINESTRING(5 5,0 0,5 -5,5 1)",
"MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)),((0 0,0 -10,-10 -10,-10 0,0 0)))",
"1010FF212");
test_geometry<ls, mpoly>("LINESTRING(-5 5,0 0,5 -5)",
"MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)),((0 0,0 -10,-10 -10,-10 0,0 0)))",
"F01FF0212");
}
template <typename P>
void test_multi_linestring_polygon()
{
typedef bg::model::linestring<P> ls;
typedef bg::model::multi_linestring<ls> mls;
typedef bg::model::polygon<P> poly;
typedef typename bg::coordinate_type<P>::type coord_t;
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))",
"1F10F0212");
test_geometry<mls, poly>("MULTILINESTRING((10 0, 18 12),(2 2,2 1))",
"POLYGON((5 0,0 -5,-5 0,0 5,5 0))",
"1F10F0212");
if ( BOOST_GEOMETRY_CONDITION((
boost::is_same<coord_t, double>::value )) )
{
// assertion failure in 1.57
test_geometry<mls, poly>("MULTILINESTRING((-0.59322033898305082 -8.0508474576271194,-2.882352941176471 -7.7647058823529411,-2.8823529411764706 -7.7647058823529411,-3.7361111111111112 -6.5694444444444446,-3.4404145077720205 -5.766839378238342,-4.1864406779661012 -3.6779661016949152,-7.5252525252525251 -5.5858585858585865,-7.5862068965517242 -5.1896551724137936,-4.47887323943662 -2.859154929577465,-4.5789473684210531 -2.5789473684210527,-3 -1,-2.9310344827586206 -0.86206896551724144,-3.1764705882352944 -0.70588235294117663,-4.7401960784313726 -2.1274509803921577,-5.3255813953488369 -0.48837209302325502,-4.7872340425531918 0.31914893617021284,-5.8571428571428577 1.0000000000000007,-5.3255813953488369 -0.48837209302325502,-5.9473684210526319 -1.4210526315789465,-8 2,-7.7333333333333334 2.1939393939393939,-8.8294573643410867 2.891472868217055,-8.8556701030927822 3.061855670103093,-7.5999999999999996 3.6000000000000001,-7.7999999999999998 3.7999999999999998,-7.75 3.7916666666666665,-7.5471698113207548 3.6226415094339623,-7.3200000000000003 3.7200000000000002,-3.473684210526315 3.0789473684210527,-3.2549019607843133 3.2156862745098036,-2.9999999999999982 3.1428571428571423,-3.1733333333333325 3.2666666666666666,-2.9180327868852456 3.4262295081967209,-2.8723404255319145 3.1063829787234041,-2.1111111111111112 2.8888888888888888,-2.1428571428571428 2.8571428571428572,-1.8433734939759043 2.8072289156626509,-1.8396226415094346 2.8113207547169816,-1.6486486486486487 2.756756756756757,-1.76510067114094 2.8926174496644301,-0.53846153846153855 4.2307692307692308,1.8148148148148147 5.4074074074074074,1.588235294117647 2.2352941176470589,1.819672131147541 2.1967213114754101,2 4,2 2.1666666666666665,2.3538461538461544 2.1076923076923078,2 1.6875000000000004,2 -2,1.2173913043478262 -3.8260869565217392,1.7375886524822697 1.3758865248226959,1.5073170731707317 1.1024390243902444,1.1428571428571428 -4,-0.59322033898305082 -8.0508474576271194),(1.666666666666667 1.5999999999999988,1.5675675675675675 1.8378378378378377,1.4374999999999991 1.8750000000000002,1.0487804878048776 2.3414634146341466,0.46666666666666712 2.6060606060606055,0.086956521739131043 2.2608695652173911,1.4374999999999991 1.8750000000000002,1.666666666666667 1.5999999999999988))",
"POLYGON((-2.333333333333333 -8.6666666666666661,-4.3253012048192767 -8.168674698795181,-4.1194968553459113 -7.6100628930817606,-2.8823529411764706 -7.7647058823529411,-2.882352941176471 -7.7647058823529411,-2.263157894736842 -8.6315789473684212,-2.333333333333333 -8.6666666666666661))",
"*********");
test_geometry<mls, poly>("MULTILINESTRING((-2.333333333333333 -8.6666666666666661,-4.3253012048192767 -8.168674698795181,-4.1194968553459113 -7.6100628930817606,-2.8823529411764706 -7.7647058823529411,-2.882352941176471 -7.7647058823529411,-2.263157894736842 -8.6315789473684212,-2.333333333333333 -8.6666666666666661))",
"POLYGON((-0.59322033898305082 -8.0508474576271194,-2.882352941176471 -7.7647058823529411,-2.8823529411764706 -7.7647058823529411,-3.7361111111111112 -6.5694444444444446,-3.4404145077720205 -5.766839378238342,-4.1864406779661012 -3.6779661016949152,-7.5252525252525251 -5.5858585858585865,-7.5862068965517242 -5.1896551724137936,-4.47887323943662 -2.859154929577465,-4.5789473684210531 -2.5789473684210527,-3 -1,-2.9310344827586206 -0.86206896551724144,-3.1764705882352944 -0.70588235294117663,-4.7401960784313726 -2.1274509803921577,-5.3255813953488369 -0.48837209302325502,-4.7872340425531918 0.31914893617021284,-5.8571428571428577 1.0000000000000007,-5.3255813953488369 -0.48837209302325502,-5.9473684210526319 -1.4210526315789465,-8 2,-7.7333333333333334 2.1939393939393939,-8.8294573643410867 2.891472868217055,-8.8556701030927822 3.061855670103093,-7.5999999999999996 3.6000000000000001,-7.7999999999999998 3.7999999999999998,-7.75 3.7916666666666665,-7.5471698113207548 3.6226415094339623,-7.3200000000000003 3.7200000000000002,-3.473684210526315 3.0789473684210527,-3.2549019607843133 3.2156862745098036,-2.9999999999999982 3.1428571428571423,-3.1733333333333325 3.2666666666666666,-2.9180327868852456 3.4262295081967209,-2.8723404255319145 3.1063829787234041,-2.1111111111111112 2.8888888888888888,-2.1428571428571428 2.8571428571428572,-1.8433734939759043 2.8072289156626509,-1.8396226415094346 2.8113207547169816,-1.6486486486486487 2.756756756756757,-1.76510067114094 2.8926174496644301,-0.53846153846153855 4.2307692307692308,1.8148148148148147 5.4074074074074074,1.588235294117647 2.2352941176470589,1.819672131147541 2.1967213114754101,2 4,2 2.1666666666666665,2.3538461538461544 2.1076923076923078,2 1.6875000000000004,2 -2,1.2173913043478262 -3.8260869565217392,1.7375886524822697 1.3758865248226959,1.5073170731707317 1.1024390243902444,1.1428571428571428 -4,-0.59322033898305082 -8.0508474576271194),(1.666666666666667 1.5999999999999988,1.5675675675675675 1.8378378378378377,1.4374999999999991 1.8750000000000002,1.0487804878048776 2.3414634146341466,0.46666666666666712 2.6060606060606055,0.086956521739131043 2.2608695652173911,1.4374999999999991 1.8750000000000002,1.666666666666667 1.5999999999999988))",
"*********");
}
// 21.01.2015
test_geometry<mls, poly>("MULTILINESTRING((6 6,15 15),(0 0, 7 7))",
"POLYGON((5 5,5 15,15 15,15 5,5 5))",
"101000212");
test_geometry<mls, poly>("MULTILINESTRING((15 15,6 6),(0 0, 7 7))",
"POLYGON((5 5,5 15,15 15,15 5,5 5))",
"101000212");
// extended
test_geometry<mls, poly>("MULTILINESTRING((15 15,6 6),(4 14,6 16))",
"POLYGON((5 5,5 15,15 15,15 5,5 5))",
"101000212");
// 23.01.2015
test_geometry<mls, poly>("MULTILINESTRING((4 10, 3 10, 10 6),(5 0, 7 5, 9 10))",
"POLYGON((0 0,0 10,10 10,10 0,5 5,0 0))",
"111F00212");
// 23.01.2015
test_geometry<mls, poly>("MULTILINESTRING((3 10, 1 5, 1 10, 3 4, 7 8, 6 10, 10 2))",
"POLYGON((0 0,0 10,10 10,10 0,0 0))",
"10FF0F212");
// mysql bug
// assertion failure in relate->boundary_checker->std::equal_range with msvc
if (BOOST_GEOMETRY_CONDITION(is_nan_case_supported<mls>::value))
{
mls g1;
std::string wkt1;
nan_case(g1, wkt1);
std::string wkt2 = "POLYGON((1.1e+308 1.2e+308,-1 -9,1 1e+12,1.1e+308 7.8e+307,1.1e+308 1.2e+308),(3 2,1 1,8e+307 1e+308,3 2),(258 2049,1 -3,1 1,-6 9,258 2049))";
poly g2;
bg::read_wkt(wkt2, g2);
check_geometry(g1, g2, wkt1, wkt2, "*********");
}
}
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;
// polygons with some ring equal to the linestrings
test_geometry<mls, mpoly>("MULTILINESTRING((0 0,10 0,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)))",
"F11FFF2F2");
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)))",
"F1FFFF2F2");
test_geometry<mls, mpoly>("MULTILINESTRING((0 0,10 0,10 10),(10 10,0 10,0 0))",
"MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)))",
"F1FFFF2F2");
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)))",
"F11FFF2F2");
// disjoint
test_geometry<mls, mpoly>("MULTILINESTRING((20 20,30 30),(30 30,40 40))",
"MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)))",
"FF1FF0212");
test_geometry<mls, mpoly>("MULTILINESTRING((5 5,0 5),(5 5,5 0),(10 10,10 5,5 5,5 10,10 10))",
"MULTIPOLYGON(((0 0,0 5,5 5,5 0,0 0)),((5 5,5 10,10 10,10 5,5 5)),((5 5,10 1,10 0,5 5)))",
"F1FF0F212");
test_geometry<mls, mpoly>("MULTILINESTRING((5 5,0 5),(5 5,5 0),(0 5,0 0,5 0),(10 10,10 5,5 5,5 10,10 10))",
"MULTIPOLYGON(((0 0,0 5,5 5,5 0,0 0)),((5 5,5 10,10 10,10 5,5 5)),((5 5,10 1,10 0,5 5)))",
"F1FFFF212");
test_geometry<mls, mpoly>("MULTILINESTRING((5 5,0 0),(5 5,5 0),(10 10,10 5,5 5,5 10,10 10))",
"MULTIPOLYGON(((0 0,0 5,5 5,5 0,0 0)),((5 5,5 10,10 10,10 5,5 5)),((5 5,10 1,10 0,5 5)))",
"11FF0F212");
// MySQL report 18.12.2014 - extended
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)))",
"10FFFF212");
test_geometry<mls, mpoly>("MULTILINESTRING((0 0,0 1,5 0),(0 0,0 -1,5 0))",
"MULTIPOLYGON(((5 0,0 5,10 5,5 0)),((5 0,10 -5,0 -5,5 0)))",
"F01FFF212");
test_geometry<mls, mpoly>("MULTILINESTRING((5 -2,4 -2,5 0),(6 -2,5 0))",
"MULTIPOLYGON(((5 0,0 5,10 5,5 0)),((5 0,10 -5,0 -5,5 0)))",
"10F0FF212");
test_geometry<mls, mpoly>("MULTILINESTRING((0 0,0 1,5 0),(0 -1,5 0))",
"MULTIPOLYGON(((5 0,0 5,10 5,5 0)),((5 0,10 -5,0 -5,5 0)))",
"F01FF0212");
test_geometry<mls, mpoly>("MULTILINESTRING((0 0,5 0),(5 -2,5 0))",
"MULTIPOLYGON(((5 0,0 5,10 5,5 0)),((5 0,10 -5,0 -5,5 0)))",
"1010F0212");
test_geometry<mls, mpoly>("MULTILINESTRING((5 -2,5 0),(0 0,5 0))",
"MULTIPOLYGON(((5 0,0 5,10 5,5 0)),((5 0,10 -5,0 -5,5 0)))",
"1010F0212");
// 22.01.2015 - extended
test_geometry<mls, mpoly>("MULTILINESTRING((10 10,0 10),(5 5,0 0,10 0))",
"MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)),((0 0,0 -10,-10 -10,-10 0,0 0)))",
"11F00F212");
test_geometry<mls, mpoly>("MULTILINESTRING((5 5,0 0,5 -5),(0 0,9 1))",
"MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)),((0 0,0 -10,-10 -10,-10 0,0 0)))",
"101000212");
test_geometry<mls, mpoly>("MULTILINESTRING((5 -5,0 0,5 5),(0 0,5 -1))",
"MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)),((0 0,0 -10,-10 -10,-10 0,0 0)))",
"101000212");
}
template <typename P>
void test_all()
{
test_linestring_polygon<P>();
test_linestring_multi_polygon<P>();
test_multi_linestring_polygon<P>();
test_multi_linestring_multi_polygon<P>();
}
int test_main( int , char* [] )
{
test_all<bg::model::d2::point_xy<int> >();
test_all<bg::model::d2::point_xy<double> >();
#if defined(HAVE_TTMATH)
test_all<bg::model::d2::point_xy<ttmath_big> >();
#endif
return 0;
}

View File

@@ -0,0 +1,419 @@
// Boost.Geometry
// Unit Test
// Copyright (c) 2016, 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_relate.hpp"
template <typename P>
void test_linestring_polygon()
{
typedef bg::model::linestring<P> ls;
typedef bg::model::polygon<P> poly;
typedef bg::model::ring<P> ring;
// LS disjoint
test_geometry<ls, poly>("LINESTRING(11 0,11 10)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "FF1FF0212");
test_geometry<ls, ring>("LINESTRING(11 0,11 10)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "FF1FF0212");
// II BB
test_geometry<ls, poly>("LINESTRING(0 0,10 10)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "1FFF0F212");
test_geometry<ls, poly>("LINESTRING(5 0,5 5,10 5)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "1FFF0F212");
test_geometry<ls, poly>("LINESTRING(5 1,5 5,9 5)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "1FF0FF212");
// IE
test_geometry<ls, poly>("LINESTRING(11 1,11 5)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "FF1FF0212");
// IE IB0
test_geometry<ls, poly>("LINESTRING(11 1,10 5)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "FF1F00212");
// IE IB1
test_geometry<ls, poly>("LINESTRING(11 1,10 5,10 10)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "F11F00212");
test_geometry<ls, poly>("LINESTRING(11 1,10 10,0 10)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "F11F00212");
test_geometry<ls, poly>("LINESTRING(11 1,10 0,0 0)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "F11F00212");
test_geometry<ls, poly>("LINESTRING(0 -1,1 0,2 0)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "F11F00212");
// IE IB0 II
test_geometry<ls, poly>("LINESTRING(11 1,10 5,5 5)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "1010F0212");
// IE IB0 lring
test_geometry<ls, poly>("LINESTRING(11 1,10 5,11 5,11 1)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "F01FFF212");
// IE IB1 lring
test_geometry<ls, poly>("LINESTRING(11 1,10 5,10 10,11 5,11 1)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "F11FFF212");
// IB1 II
test_geometry<ls, poly>("LINESTRING(0 0,5 0,5 5)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "11F00F212");
// BI0 II IB1
test_geometry<ls, poly>("LINESTRING(5 0,5 5,10 5,10 10)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "11FF0F212");
// IB1 II IB1
test_geometry<ls, poly>("LINESTRING(1 0,2 0,3 1,4 0,5 0)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "11FF0F212");
// IB1 IE IB1
test_geometry<ls, poly>("LINESTRING(1 0,2 0,3 -1,4 0,5 0)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "F11F0F212");
// II IB1
test_geometry<ls, poly>("LINESTRING(5 5,10 5,10 10)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "11F00F212");
// IB1 II
test_geometry<ls, poly>("LINESTRING(10 10,10 5,5 5)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "11F00F212");
// IE IB1
test_geometry<ls, poly>("LINESTRING(15 5,10 5,10 10)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "F11F00212");
// IB1 IE
test_geometry<ls, poly>("LINESTRING(10 10,10 5,15 5)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "F11F00212");
// duplicated points
{
// II IB0 IE
test_geometry<ls, poly>("LINESTRING(5 5,10 5,15 10)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "1010F0212");
test_geometry<ls, poly>("LINESTRING(5 5,5 5,5 5,10 5,10 5,10 5,15 10,15 10,15 10)",
"POLYGON((0 0,0 0,0 0,0 10,0 10,0 10,10 10,10 10,10 10,10 0,10 0,10 0,0 0,0 0,0 0))",
"1010F0212");
test_geometry<ls, poly>("LINESTRING(5 5,5 5,5 5,10 0,10 0,10 0,15 10,15 10,15 10)",
"POLYGON((0 0,0 0,0 0,0 10,0 10,0 10,10 10,10 10,10 10,10 0,10 0,10 0,0 0,0 0,0 0))",
"1010F0212");
// IE IB0 II
test_geometry<ls, poly>("LINESTRING(15 10,15 10,15 10,10 5,10 5,10 5,5 5,5 5,5 5)",
"POLYGON((0 0,0 0,0 0,0 10,0 10,0 10,10 10,10 10,10 10,10 0,10 0,10 0,0 0,0 0,0 0))",
"1010F0212");
test_geometry<ls, poly>("LINESTRING(15 10,15 10,15 10,10 0,10 0,10 0,5 5,5 5,5 5)",
"POLYGON((0 0,0 0,0 0,0 10,0 10,0 10,10 10,10 10,10 10,10 0,10 0,10 0,0 0,0 0,0 0))",
"1010F0212");
// TEST
//test_geometry<ls, poly>("LINESTRING(5 5,5 5,5 5)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "1010F0212");
test_geometry<ls, poly>("LINESTRING(5 5,5 5,5 5,15 5,15 5,15 5)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "1010F0212");
}
// non-simple polygon with hole
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))",
"10F0FF212");
test_geometry<ls, poly>("LINESTRING(10 1,10 5,10 9)",
"POLYGON((0 0,0 10,10 10,10 0,0 0),(10 5,2 8,2 2,10 5))",
"F1FF0F212");
test_geometry<ls, poly>("LINESTRING(2 8,10 5,2 2)",
"POLYGON((0 0,0 10,10 10,10 0,0 0),(10 5,2 8,2 2,10 5))",
"F1FF0F212");
test_geometry<ls, poly>("LINESTRING(10 1,10 5,2 2)",
"POLYGON((0 0,0 10,10 10,10 0,0 0),(10 5,2 8,2 2,10 5))",
"F1FF0F212");
test_geometry<ls, poly>("LINESTRING(10 1,10 5,2 8)",
"POLYGON((0 0,0 10,10 10,10 0,0 0),(10 5,2 8,2 2,10 5))",
"F1FF0F212");
// non-simple polygon with hole, linear ring
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))",
"10FFFF212");
test_geometry<ls, poly>("LINESTRING(10 5,10 9,11 5,10 1,10 5)",
"POLYGON((0 0,0 10,10 10,10 0,0 0),(10 5,2 8,2 2,10 5))",
"F11FFF212");
test_geometry<ls, poly>("LINESTRING(11 5,10 1,10 5,10 9,11 5)",
"POLYGON((0 0,0 10,10 10,10 0,0 0),(10 5,2 8,2 2,10 5))",
"F11FFF212");
// non-simple polygon with self-touching holes
test_geometry<ls, poly>("LINESTRING(7 1,8 5,7 9)",
"POLYGON((0 0,0 10,10 10,10 0,0 0),(8 1,9 1,9 9,8 9,8 1),(2 2,8 5,2 8,2 2))",
"10F0FF212");
test_geometry<ls, poly>("LINESTRING(8 2,8 5,8 8)",
"POLYGON((0 0,0 10,10 10,10 0,0 0),(8 1,9 1,9 9,8 9,8 1),(2 2,8 5,2 8,2 2))",
"F1FF0F212");
test_geometry<ls, poly>("LINESTRING(2 8,8 5,2 2)",
"POLYGON((0 0,0 10,10 10,10 0,0 0),(8 1,9 1,9 9,8 9,8 1),(2 2,8 5,2 8,2 2))",
"F1FF0F212");
// non-simple polygon self-touching
test_geometry<ls, poly>("LINESTRING(9 1,10 5,9 9)",
"POLYGON((0 0,0 10,10 10,10 5,2 8,2 2,10 5,10 0,0 0))",
"10F0FF212");
test_geometry<ls, poly>("LINESTRING(10 1,10 5,10 9)",
"POLYGON((0 0,0 10,10 10,10 5,2 8,2 2,10 5,10 0,0 0))",
"F1FF0F212");
test_geometry<ls, poly>("LINESTRING(2 8,10 5,2 2)",
"POLYGON((0 0,0 10,10 10,10 5,2 8,2 2,10 5,10 0,0 0))",
"F1FF0F212");
// non-simple polygon self-touching, linear ring
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 5,2 8,2 2,10 5,10 0,0 0))",
"10FFFF212");
test_geometry<ls, poly>("LINESTRING(10 5,10 9,11 5,10 1,10 5)",
"POLYGON((0 0,0 10,10 10,10 5,2 8,2 2,10 5,10 0,0 0))",
"F11FFF212");
test_geometry<ls, poly>("LINESTRING(11 5,10 1,10 5,10 9,11 5)",
"POLYGON((0 0,0 10,10 10,10 5,2 8,2 2,10 5,10 0,0 0))",
"F11FFF212");
// polygons with some ring equal to the linestring
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))",
"F1FFFF2F2");
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),(2 2,5 5,2 8,2 2))",
"F1FFFF212");
test_geometry<ls, poly>("LINESTRING(2 2,5 5,2 8,2 2)",
"POLYGON((0 0,0 10,10 10,10 0,0 0),(2 2,5 5,2 8,2 2))",
"F1FFFF212");
// self-IP going on the boundary then into the exterior and to the boundary again
test_geometry<ls, poly>("LINESTRING(2 10.023946271183535,5 10.037423045910710,5 15,6 15,5 10.037423045910710,8 10.023946271183535)",
"POLYGON((0 0,0 10,10 10,10 0,0 0))",
"F11F0F212");
// self-IP going on the boundary then into the interior and to the boundary again
test_geometry<ls, poly>("LINESTRING(2 10.023946271183535,5 10.037423045910710,5 5,6 5,5 10.037423045910710,8 10.023946271183535)",
"POLYGON((0 0,0 10,10 10,10 0,0 0))",
"11FF0F212");
// self-IP with a hole -> B to I to B to E
test_geometry<ls, poly>("LINESTRING(0 0,3 3)", "POLYGON((0 0,0 10,10 10,10 0,0 0),(0 0,9 1,9 9,1 9,0 0))",
"FF1F00212");
}
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)))",
"F1FF0F212");
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)))",
"F1FF0F212");
test_geometry<ls, mpoly>("LINESTRING(10 1,10 5,2 2)",
"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)))",
"F1FF0F212");
test_geometry<ls, mpoly>("LINESTRING(10 1,10 5,2 2)",
"MULTIPOLYGON(((0 20,0 30,10 30,10 20,0 20)),((0 0,0 10,10 10,10 0,0 0)))",
"11F00F212");
test_geometry<ls, mpoly>("LINESTRING(10 1,10 5,2 2)",
"MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0),(10 5,2 8,2 2,10 5)),((10 5,3 3,3 7,10 5)))",
"F1FF0F212");
test_geometry<ls, mpoly>("LINESTRING(10 1,10 5,2 8)",
"MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0),(10 5,2 8,2 2,10 5)),((10 5,3 3,3 7,10 5)))",
"F1FF0F212");
test_geometry<ls, mpoly>("LINESTRING(10 1,10 5,3 3)",
"MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0),(10 5,2 8,2 2,10 5)),((10 5,3 3,3 7,10 5)))",
"F1FF0F212");
test_geometry<ls, mpoly>("LINESTRING(10 1,10 5,3 7)",
"MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0),(10 5,2 8,2 2,10 5)),((10 5,3 3,3 7,10 5)))",
"F1FF0F212");
test_geometry<ls, mpoly>("LINESTRING(10 1,10 5,5 5)",
"MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0),(10 5,2 8,2 2,10 5)),((10 5,3 3,3 7,10 5)))",
"11F00F212");
test_geometry<ls, mpoly>("LINESTRING(0 0,10 0,10 10,0 10,0 0)",
"MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)),((20 0,20 10,30 20,20 0)))",
"F1FFFF212");
// degenerated points
test_geometry<ls, mpoly>("LINESTRING(5 5,10 10,10 10,10 10,15 15)",
"MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)),((10 10,10 20,20 20,20 10,10 10)))",
"10F0FF212");
// self-IP polygon with a hole and second polygon with a hole -> B to I to B to B to I to B to E
test_geometry<ls, mpoly>("LINESTRING(0 0,3 3)",
"MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0),(0 0,9 1,9 9,1 9,0 0)),((0 0,2 8,8 8,8 2,0 0),(0 0,7 3,7 7,3 7,0 0)))",
"FF1F00212");
// self-IP polygon with a hole and second polygon -> B to I to B to B to I
test_geometry<ls, mpoly>("LINESTRING(0 0,3 3)",
"MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0),(0 0,9 1,9 9,1 9,0 0)),((0 0,2 8,8 8,8 2,0 0)))",
"1FF00F212");
test_geometry<ls, mpoly>("LINESTRING(0 0,3 3)",
"MULTIPOLYGON(((0 0,2 8,8 8,8 2,0 0)),((0 0,0 10,10 10,10 0,0 0),(0 0,9 1,9 9,1 9,0 0)))",
"1FF00F212");
// MySQL report 18.12.2014 (https://svn.boost.org/trac/boost/ticket/10887)
test_geometry<ls, mpoly>("LINESTRING(5 -2,5 2)",
"MULTIPOLYGON(((5 0,0 5,10 5,5 0)),((5 0,10 -5,0 -5,5 0)))",
"10F0FF212");
test_geometry<ls, mpoly>("LINESTRING(5 -2,5 5.0190018174896416)",
"MULTIPOLYGON(((5 0,0 5,10 5,5 0)),((5 0,10 -5,0 -5,5 0)))",
"10F00F212");
test_geometry<ls, mpoly>("LINESTRING(5 -2,5 0)",
"MULTIPOLYGON(((5 0,0 5,10 5,5 0)),((5 0,10 -5,0 -5,5 0)))",
"1FF00F212");
// MySQL report 18.12.2014 - extended
test_geometry<ls, mpoly>("LINESTRING(5 -2,5 0)",
"MULTIPOLYGON(((5 0,0 5,10 5,5 0)),((5 0,10 -5,0 -5,5 0)),((5 0,7 1,7 -1,5 0)))",
"1FF00F212");
test_geometry<ls, mpoly>("LINESTRING(0 0,5 0)",
"MULTIPOLYGON(((5 0,0 5,10 5,5 0)),((5 0,10 -5,0 -5,5 0)),((5 0,7 1,7 -1,5 0)))",
"FF1F00212");
// 22.01.2015
test_geometry<ls, mpoly>("LINESTRING(5 5,0 0,10 0)",
"MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)),((0 0,0 -10,-10 -10,-10 0,0 0)))",
"11F00F212");
test_geometry<ls, mpoly>("LINESTRING(5 5,0 0,0 10)",
"MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)),((0 0,0 -10,-10 -10,-10 0,0 0)))",
"11F00F212");
// extended
test_geometry<ls, mpoly>("LINESTRING(5 5,0 0,2 1)",
"MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)),((0 0,0 -10,-10 -10,-10 0,0 0)))",
"10F0FF212");
test_geometry<ls, mpoly>("LINESTRING(5 5,0 0,5 -5)",
"MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)),((0 0,0 -10,-10 -10,-10 0,0 0)))",
"1010F0212");
test_geometry<ls, mpoly>("LINESTRING(5 5,0 0,5 -5,5 1)",
"MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)),((0 0,0 -10,-10 -10,-10 0,0 0)))",
"1010FF212");
test_geometry<ls, mpoly>("LINESTRING(-5 5,0 0,5 -5)",
"MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)),((0 0,0 -10,-10 -10,-10 0,0 0)))",
"F01FF0212");
}
template <typename P>
void test_multi_linestring_polygon()
{
typedef bg::model::linestring<P> ls;
typedef bg::model::multi_linestring<ls> mls;
typedef bg::model::polygon<P> poly;
typedef bg::model::ring<P> ring;
typedef typename bg::coordinate_type<P>::type coord_t;
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))",
"1F10F0212");
test_geometry<mls, poly>("MULTILINESTRING((10 0, 18 12),(2 2,2 1))",
"POLYGON((5 0,0 -5,-5 0,0 5,5 0))",
"1F10F0212");
if ( BOOST_GEOMETRY_CONDITION((
boost::is_same<coord_t, double>::value )) )
{
// assertion failure in 1.57
test_geometry<mls, poly>("MULTILINESTRING((-0.59322033898305082 -8.0508474576271194,-2.882352941176471 -7.7647058823529411,-2.8823529411764706 -7.7647058823529411,-3.7361111111111112 -6.5694444444444446,-3.4404145077720205 -5.766839378238342,-4.1864406779661012 -3.6779661016949152,-7.5252525252525251 -5.5858585858585865,-7.5862068965517242 -5.1896551724137936,-4.47887323943662 -2.859154929577465,-4.5789473684210531 -2.5789473684210527,-3 -1,-2.9310344827586206 -0.86206896551724144,-3.1764705882352944 -0.70588235294117663,-4.7401960784313726 -2.1274509803921577,-5.3255813953488369 -0.48837209302325502,-4.7872340425531918 0.31914893617021284,-5.8571428571428577 1.0000000000000007,-5.3255813953488369 -0.48837209302325502,-5.9473684210526319 -1.4210526315789465,-8 2,-7.7333333333333334 2.1939393939393939,-8.8294573643410867 2.891472868217055,-8.8556701030927822 3.061855670103093,-7.5999999999999996 3.6000000000000001,-7.7999999999999998 3.7999999999999998,-7.75 3.7916666666666665,-7.5471698113207548 3.6226415094339623,-7.3200000000000003 3.7200000000000002,-3.473684210526315 3.0789473684210527,-3.2549019607843133 3.2156862745098036,-2.9999999999999982 3.1428571428571423,-3.1733333333333325 3.2666666666666666,-2.9180327868852456 3.4262295081967209,-2.8723404255319145 3.1063829787234041,-2.1111111111111112 2.8888888888888888,-2.1428571428571428 2.8571428571428572,-1.8433734939759043 2.8072289156626509,-1.8396226415094346 2.8113207547169816,-1.6486486486486487 2.756756756756757,-1.76510067114094 2.8926174496644301,-0.53846153846153855 4.2307692307692308,1.8148148148148147 5.4074074074074074,1.588235294117647 2.2352941176470589,1.819672131147541 2.1967213114754101,2 4,2 2.1666666666666665,2.3538461538461544 2.1076923076923078,2 1.6875000000000004,2 -2,1.2173913043478262 -3.8260869565217392,1.7375886524822697 1.3758865248226959,1.5073170731707317 1.1024390243902444,1.1428571428571428 -4,-0.59322033898305082 -8.0508474576271194),(1.666666666666667 1.5999999999999988,1.5675675675675675 1.8378378378378377,1.4374999999999991 1.8750000000000002,1.0487804878048776 2.3414634146341466,0.46666666666666712 2.6060606060606055,0.086956521739131043 2.2608695652173911,1.4374999999999991 1.8750000000000002,1.666666666666667 1.5999999999999988))",
"POLYGON((-2.333333333333333 -8.6666666666666661,-4.3253012048192767 -8.168674698795181,-4.1194968553459113 -7.6100628930817606,-2.8823529411764706 -7.7647058823529411,-2.882352941176471 -7.7647058823529411,-2.263157894736842 -8.6315789473684212,-2.333333333333333 -8.6666666666666661))",
"*********");
test_geometry<mls, poly>("MULTILINESTRING((-2.333333333333333 -8.6666666666666661,-4.3253012048192767 -8.168674698795181,-4.1194968553459113 -7.6100628930817606,-2.8823529411764706 -7.7647058823529411,-2.882352941176471 -7.7647058823529411,-2.263157894736842 -8.6315789473684212,-2.333333333333333 -8.6666666666666661))",
"POLYGON((-0.59322033898305082 -8.0508474576271194,-2.882352941176471 -7.7647058823529411,-2.8823529411764706 -7.7647058823529411,-3.7361111111111112 -6.5694444444444446,-3.4404145077720205 -5.766839378238342,-4.1864406779661012 -3.6779661016949152,-7.5252525252525251 -5.5858585858585865,-7.5862068965517242 -5.1896551724137936,-4.47887323943662 -2.859154929577465,-4.5789473684210531 -2.5789473684210527,-3 -1,-2.9310344827586206 -0.86206896551724144,-3.1764705882352944 -0.70588235294117663,-4.7401960784313726 -2.1274509803921577,-5.3255813953488369 -0.48837209302325502,-4.7872340425531918 0.31914893617021284,-5.8571428571428577 1.0000000000000007,-5.3255813953488369 -0.48837209302325502,-5.9473684210526319 -1.4210526315789465,-8 2,-7.7333333333333334 2.1939393939393939,-8.8294573643410867 2.891472868217055,-8.8556701030927822 3.061855670103093,-7.5999999999999996 3.6000000000000001,-7.7999999999999998 3.7999999999999998,-7.75 3.7916666666666665,-7.5471698113207548 3.6226415094339623,-7.3200000000000003 3.7200000000000002,-3.473684210526315 3.0789473684210527,-3.2549019607843133 3.2156862745098036,-2.9999999999999982 3.1428571428571423,-3.1733333333333325 3.2666666666666666,-2.9180327868852456 3.4262295081967209,-2.8723404255319145 3.1063829787234041,-2.1111111111111112 2.8888888888888888,-2.1428571428571428 2.8571428571428572,-1.8433734939759043 2.8072289156626509,-1.8396226415094346 2.8113207547169816,-1.6486486486486487 2.756756756756757,-1.76510067114094 2.8926174496644301,-0.53846153846153855 4.2307692307692308,1.8148148148148147 5.4074074074074074,1.588235294117647 2.2352941176470589,1.819672131147541 2.1967213114754101,2 4,2 2.1666666666666665,2.3538461538461544 2.1076923076923078,2 1.6875000000000004,2 -2,1.2173913043478262 -3.8260869565217392,1.7375886524822697 1.3758865248226959,1.5073170731707317 1.1024390243902444,1.1428571428571428 -4,-0.59322033898305082 -8.0508474576271194),(1.666666666666667 1.5999999999999988,1.5675675675675675 1.8378378378378377,1.4374999999999991 1.8750000000000002,1.0487804878048776 2.3414634146341466,0.46666666666666712 2.6060606060606055,0.086956521739131043 2.2608695652173911,1.4374999999999991 1.8750000000000002,1.666666666666667 1.5999999999999988))",
"*********");
}
// 21.01.2015
test_geometry<mls, poly>("MULTILINESTRING((6 6,15 15),(0 0, 7 7))",
"POLYGON((5 5,5 15,15 15,15 5,5 5))",
"101000212");
test_geometry<mls, poly>("MULTILINESTRING((15 15,6 6),(0 0, 7 7))",
"POLYGON((5 5,5 15,15 15,15 5,5 5))",
"101000212");
// extended
test_geometry<mls, ring>("MULTILINESTRING((15 15,6 6),(4 14,6 15.986412732589057))",
"POLYGON((5 5,5 15,15 15,15 5,5 5))",
"101000212");
// 23.01.2015
test_geometry<mls, poly>("MULTILINESTRING((4 10.035925377760330, 3 10.031432746397092, 10 6),(5 0, 7 5, 9 10.013467818052765))",
"POLYGON((0 0,0 10,10 10,10 0,5 5,0 0))",
"111F00212");
// 23.01.2015
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))",
"10FF0F212");
}
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;
// polygons with some ring equal to the linestrings
test_geometry<mls, mpoly>("MULTILINESTRING((0 0,10 0,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)))",
"F11FFF2F2");
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)))",
"F1FFFF2F2");
test_geometry<mls, mpoly>("MULTILINESTRING((0 0,10 0,10 10),(10 10,0 10,0 0))",
"MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)))",
"F1FFFF2F2");
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)))",
"F11FFF2F2");
// disjoint
test_geometry<mls, mpoly>("MULTILINESTRING((20 20,30 30),(30 30,40 40))",
"MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)))",
"FF1FF0212");
test_geometry<mls, mpoly>("MULTILINESTRING((5 5,0 5),(5 5,5 0),(10 10,10 5,5 5,5 10,10 10))",
"MULTIPOLYGON(((0 0,0 5,5 5,5 0,0 0)),((5 5,5 10,10 10,10 5,5 5)),((5 5,10 1,10 0,5 5)))",
"F1FF0F212");
test_geometry<mls, mpoly>("MULTILINESTRING((5 5,0 5),(5 5,5 0),(0 5,0 0,5 0),(10 10,10 5,5 5,5 10,10 10))",
"MULTIPOLYGON(((0 0,0 5,5 5,5 0,0 0)),((5 5,5 10,10 10,10 5,5 5)),((5 5,10 1,10 0,5 5)))",
"F1FFFF212");
test_geometry<mls, mpoly>("MULTILINESTRING((5 5,0 0),(5 5,5 0),(10 10,10 5,5 5,5 10,10 10))",
"MULTIPOLYGON(((0 0,0 5,5 5,5 0,0 0)),((5 5,5 10,10 10,10 5,5 5)),((5 5,10 1,10 0,5 5)))",
"11FF0F212");
// MySQL report 18.12.2014 - extended
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)))",
"10FFFF212");
test_geometry<mls, mpoly>("MULTILINESTRING((0 0,0 1,5 0),(0 0,0 -1,5 0))",
"MULTIPOLYGON(((5 0,0 5,10 5,5 0)),((5 0,10 -5,0 -5,5 0)))",
"F01FFF212");
test_geometry<mls, mpoly>("MULTILINESTRING((5 -2,4 -2,5 0),(6 -2,5 0))",
"MULTIPOLYGON(((5 0,0 5,10 5,5 0)),((5 0,10 -5,0 -5,5 0)))",
"10F0FF212");
test_geometry<mls, mpoly>("MULTILINESTRING((0 0,0 1,5 0),(0 -1,5 0))",
"MULTIPOLYGON(((5 0,0 5,10 5,5 0)),((5 0,10 -5,0 -5,5 0)))",
"F01FF0212");
test_geometry<mls, mpoly>("MULTILINESTRING((0 0,5 0),(5 -2,5 0))",
"MULTIPOLYGON(((5 0,0 5,10 5,5 0)),((5 0,10 -5,0 -5,5 0)))",
"1010F0212");
test_geometry<mls, mpoly>("MULTILINESTRING((5 -2,5 0),(0 0,5 0))",
"MULTIPOLYGON(((5 0,0 5,10 5,5 0)),((5 0,10 -5,0 -5,5 0)))",
"1010F0212");
// 22.01.2015 - extended
test_geometry<mls, mpoly>("MULTILINESTRING((10 10,0 10),(5 5,0 0,10 0))",
"MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)),((0 0,0 -10,-10 -10,-10 0,0 0)))",
"11F00F212");
test_geometry<mls, mpoly>("MULTILINESTRING((5 5,0 0,5 -5),(0 0,9 1))",
"MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)),((0 0,0 -10,-10 -10,-10 0,0 0)))",
"101000212");
test_geometry<mls, mpoly>("MULTILINESTRING((5 -5,0 0,5 5),(0 0,5 -1))",
"MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)),((0 0,0 -10,-10 -10,-10 0,0 0)))",
"101000212");
}
template <typename P>
void test_all()
{
test_linestring_polygon<P>();
test_linestring_multi_polygon<P>();
test_multi_linestring_polygon<P>();
test_multi_linestring_multi_polygon<P>();
}
int test_main( int , char* [] )
{
typedef bg::cs::spherical_equatorial<bg::degree> cs_t;
test_all<bg::model::point<float, 2, cs_t> >();
test_all<bg::model::point<double, 2, cs_t> >();
#if defined(HAVE_TTMATH)
test_all<bg::model::point<ttmath_big, 2, cs_t> >();
#endif
return 0;
}

View File

@@ -0,0 +1,446 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// Copyright (c) 2007-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_relate.hpp"
//TEST
//#include <to_svg.hpp>
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)", "1FFF0FFF2");
test_geometry<ls, ls>("LINESTRING(0 0,3 2)", "LINESTRING(0 0, 2 2, 3 2)", "FF1F0F1F2");
test_geometry<ls, ls>("LINESTRING(1 0,2 2,2 3)", "LINESTRING(0 0, 2 2, 3 2)", "0F1FF0102");
test_geometry<ls, ls>("LINESTRING(0 0,5 0)", "LINESTRING(0 0,1 1,2 0,2 -1)", "0F1F00102");
test_geometry<ls, ls>("LINESTRING(0 0, 1 1, 2 2, 3 2)", "LINESTRING(0 0, 2 2, 3 2)", "1FFF0FFF2");
test_geometry<ls, ls>("LINESTRING(3 2, 2 2, 1 1, 0 0)", "LINESTRING(0 0, 2 2, 3 2)", "1FFF0FFF2");
test_geometry<ls, ls>("LINESTRING(0 0, 1 1, 2 2, 3 2)", "LINESTRING(3 2, 2 2, 0 0)", "1FFF0FFF2");
test_geometry<ls, ls>("LINESTRING(3 2, 2 2, 1 1, 0 0)", "LINESTRING(3 2, 2 2, 0 0)", "1FFF0FFF2");
test_geometry<ls, ls>("LINESTRING(3 1, 2 2, 1 1, 0 0)", "LINESTRING(0 0, 2 2, 3 2)", "1F1F00102");
test_geometry<ls, ls>("LINESTRING(3 3, 2 2, 1 1, 0 0)", "LINESTRING(0 0, 2 2, 3 2)", "1F1F00102");
test_geometry<ls, ls>("LINESTRING(0 0, 1 1, 2 2, 2 3)", "LINESTRING(0 0, 2 2, 2 3)", "1FFF0FFF2");
test_geometry<ls, ls>("LINESTRING(2 3, 2 2, 1 1, 0 0)", "LINESTRING(0 0, 2 2, 2 3)", "1FFF0FFF2");
test_geometry<ls, ls>("LINESTRING(0 0, 1 1, 2 2, 2 3)", "LINESTRING(2 3, 2 2, 0 0)", "1FFF0FFF2");
test_geometry<ls, ls>("LINESTRING(2 3, 2 2, 1 1, 0 0)", "LINESTRING(2 3, 2 2, 0 0)", "1FFF0FFF2");
test_geometry<ls, ls>("LINESTRING(1 1, 2 2, 3 2)", "LINESTRING(0 0, 2 2, 4 2)", "1FF0FF102");
test_geometry<ls, ls>("LINESTRING(3 2, 2 2, 1 1)", "LINESTRING(0 0, 2 2, 4 2)", "1FF0FF102");
test_geometry<ls, ls>("LINESTRING(1 1, 2 2, 3 2)", "LINESTRING(4 2, 2 2, 0 0)", "1FF0FF102");
test_geometry<ls, ls>("LINESTRING(3 2, 2 2, 1 1)", "LINESTRING(4 2, 2 2, 0 0)", "1FF0FF102");
// test_geometry<ls, ls>("LINESTRING(1 1, 2 2, 2 2)", "LINESTRING(0 0, 2 2, 4 2)", true);
// test_geometry<ls, ls>("LINESTRING(1 1, 2 2, 3 3)", "LINESTRING(0 0, 2 2, 4 2)", false);
// test_geometry<ls, ls>("LINESTRING(1 1, 2 2, 3 2, 3 3)", "LINESTRING(0 0, 2 2, 4 2)", false);
// test_geometry<ls, ls>("LINESTRING(1 1, 2 2, 3 1)", "LINESTRING(0 0, 2 2, 4 2)", false);
// test_geometry<ls, ls>("LINESTRING(1 1, 2 2, 3 2, 3 1)", "LINESTRING(0 0, 2 2, 4 2)", false);
// test_geometry<ls, ls>("LINESTRING(0 1, 1 1, 2 2, 3 2)", "LINESTRING(0 0, 2 2, 4 2)", false);
// test_geometry<ls, ls>("LINESTRING(0 1, 0 0, 2 2, 3 2)", "LINESTRING(0 0, 2 2, 4 2)", false);
// test_geometry<ls, ls>("LINESTRING(1 0, 1 1, 2 2, 3 2)", "LINESTRING(0 0, 2 2, 4 2)", false);
// test_geometry<ls, ls>("LINESTRING(1 0, 0 0, 2 2, 3 2)", "LINESTRING(0 0, 2 2, 4 2)", false);
// test_geometry<ls, ls>("LINESTRING(0 0)", "LINESTRING(0 0)", false);
// test_geometry<ls, ls>("LINESTRING(1 1)", "LINESTRING(0 0, 2 2)", true);
// test_geometry<ls, ls>("LINESTRING(0 0)", "LINESTRING(0 0, 2 2)", false);
// test_geometry<ls, ls>("LINESTRING(0 0, 1 1)", "LINESTRING(0 0)", false);
// test_geometry<ls, ls>("LINESTRING(0 0,5 0,3 0,6 0)", "LINESTRING(0 0,6 0)", true);
// test_geometry<ls, ls>("LINESTRING(0 0,2 2,3 3,1 1)", "LINESTRING(0 0,3 3,6 3)", true);
// SPIKES!
test_geometry<ls, ls>("LINESTRING(0 0,2 2,3 3,1 1,5 3)", "LINESTRING(0 0,3 3,6 3)", "1F100F102");
test_geometry<ls, ls>("LINESTRING(5 3,1 1,3 3,2 2,0 0)", "LINESTRING(0 0,3 3,6 3)", "1F100F102");
test_geometry<ls, ls>("LINESTRING(0 0,2 2,3 3,1 1,5 3)", "LINESTRING(6 3,3 3,0 0)", "1F100F102");
test_geometry<ls, ls>("LINESTRING(5 3,1 1,3 3,2 2,0 0)", "LINESTRING(6 3,3 3,0 0)", "1F100F102");
test_geometry<ls, ls>("LINESTRING(6 3,3 3,0 0)", "LINESTRING(0 0,2 2,3 3,1 1,5 3)", "101F001F2");
test_geometry<ls, ls>("LINESTRING(0 0,10 0)", "LINESTRING(1 0,9 0,2 0)", "101FF0FF2");
test_geometry<ls, ls>("LINESTRING(0 0,2 2,3 3,1 1)", "LINESTRING(0 0,3 3,6 3)", "1FF00F102");
// TODO: REWRITE MATRICES
// BEGIN
/*test_geometry<ls, ls>("LINESTRING(0 0,2 2,3 3,1 1)", "LINESTRING(0 0,4 4,6 3)", "1FF00F102");
test_geometry<ls, ls>("LINESTRING(0 0,2 0,1 0)", "LINESTRING(0 1,0 0,2 0)", "1FF00F102");
test_geometry<ls, ls>("LINESTRING(2 0,0 0,1 0)", "LINESTRING(0 1,0 0,2 0)", "1FF00F102");
test_geometry<ls, ls>("LINESTRING(0 0,3 3,1 1)", "LINESTRING(3 0,3 3,3 1)", "0F1FF0102");
test_geometry<ls, ls>("LINESTRING(0 0,3 3,1 1)", "LINESTRING(2 0,2 3,2 1)", "0F1FF0102");
test_geometry<ls, ls>("LINESTRING(0 0,3 3,1 1)", "LINESTRING(2 0,2 2,2 1)", "0F1FF0102");
test_geometry<ls, ls>("LINESTRING(0 0,2 2,3 3,4 4)", "LINESTRING(0 0,1 1,4 4)", "1FFF0FFF2");*/
// END
test_geometry<ls, ls>("LINESTRING(0 0,2 2,3 3,4 4)", "LINESTRING(0 0,1 1,4 4)", "1FFF0FFF2");
// loop i/i i/i u/u u/u
test_geometry<ls, ls>("LINESTRING(0 0,10 0)",
"LINESTRING(1 1,1 0,6 0,6 1,4 1,4 0,9 0,9 1)", "1F1FF0102");
// self-intersecting and self-touching equal
test_geometry<ls, ls>("LINESTRING(0 5,5 5,10 5,10 10,5 10,5 5,5 0)",
"LINESTRING(0 5,5 5,5 10,10 10,10 5,5 5,5 0)", "1FFF0FFF2");
// self-intersecting loop and self-touching equal
test_geometry<ls, ls>("LINESTRING(0 5,5 5,10 5,10 10,5 10,5 5,10 5,10 10,5 10,5 5,5 0)",
"LINESTRING(0 5,5 5,5 10,10 10,10 5,5 5,5 0)", "1FFF0FFF2");
test_geometry<ls, ls>("LINESTRING(0 0,1 1)", "LINESTRING(0 1,1 0)", "0F1FF0102");
test_geometry<ls, ls>("LINESTRING(0 0,1 1)", "LINESTRING(1 1,2 0)", "FF1F00102");
test_geometry<ls, ls>("LINESTRING(0 0,1 1)", "LINESTRING(2 0,1 1)", "FF1F00102");
test_geometry<ls, ls>("LINESTRING(0 0,1 0,2 1,3 5,4 0)", "LINESTRING(1 0,2 1,3 5)", "101FF0FF2");
test_geometry<ls, ls>("LINESTRING(0 0,1 0,2 1,3 5,4 0)", "LINESTRING(3 5,2 1,1 0)", "101FF0FF2");
test_geometry<ls, ls>("LINESTRING(1 0,2 1,3 5)", "LINESTRING(4 0,3 5,2 1,1 0,0 0)", "1FF0FF102");
test_geometry<ls, ls>("LINESTRING(3 5,2 1,1 0)", "LINESTRING(4 0,3 5,2 1,1 0,0 0)", "1FF0FF102");
test_geometry<ls, ls>("LINESTRING(0 0,10 0)", "LINESTRING(-1 -1,1 0,10 0,20 -1)", "1F10F0102");
test_geometry<ls, ls>("LINESTRING(0 0,10 0)", "LINESTRING(20 -1,10 0,1 0,-1 -1)", "1F10F0102");
test_geometry<ls, ls>("LINESTRING(-1 1,0 0,1 0,5 0,5 5,10 5,15 0,31 0)",
"LINESTRING(-1 -1,0 0,1 0,2 0,3 1,4 0,30 0)",
"101FF0102");
test_geometry<ls, ls>("LINESTRING(-1 1,0 0,1 0,5 0,5 5,10 5,15 0,31 0)",
"LINESTRING(30 0,4 0,3 1,2 0,1 0,0 0,-1 -1)",
"101FF0102");
test_geometry<ls, ls>("LINESTRING(31 0,15 0,10 5,5 5,5 0,1 0,0 0,-1 1)",
"LINESTRING(-1 -1,0 0,1 0,2 0,3 1,4 0,30 0)",
"101FF0102");
test_geometry<ls, ls>("LINESTRING(31 0,15 0,10 5,5 5,5 0,1 0,0 0,-1 1)",
"LINESTRING(30 0,4 0,3 1,2 0,1 0,0 0,-1 -1)",
"101FF0102");
// self-IP
test_geometry<ls, ls>("LINESTRING(1 0,9 0)",
"LINESTRING(0 0,10 0,10 10,5 0,0 10)",
"1FF0FF102");
test_geometry<ls, ls>("LINESTRING(1 0,5 0,9 0)",
"LINESTRING(0 0,10 0,10 10,5 0,0 10)",
"1FF0FF102");
test_geometry<ls, ls>("LINESTRING(1 0,9 0)",
"LINESTRING(0 0,10 0,10 10,5 10,5 -1)",
"1FF0FF102");
test_geometry<ls, ls>("LINESTRING(1 0,9 0)",
"LINESTRING(0 0,10 0,5 0,5 5)",
"1FF0FF102");
test_geometry<ls, ls>("LINESTRING(1 0,7 0)", "LINESTRING(0 0,10 0,10 10,4 -1)",
"1FF0FF102");
test_geometry<ls, ls>("LINESTRING(1 0,5 0,7 0)", "LINESTRING(0 0,10 0,10 10,4 -1)",
"1FF0FF102");
test_geometry<ls, ls>("LINESTRING(1 0,7 0,8 1)", "LINESTRING(0 0,10 0,10 10,4 -1)",
"1F10F0102");
test_geometry<ls, ls>("LINESTRING(1 0,5 0,7 0,8 1)", "LINESTRING(0 0,10 0,10 10,4 -1)",
"1F10F0102");
// self-IP going out and in on the same point
test_geometry<ls, ls>("LINESTRING(2 0,5 0,5 5,6 5,5 0,8 0)", "LINESTRING(1 0,9 0)",
"1F10FF102");
// duplicated points
test_geometry<ls, ls>("LINESTRING(1 1, 2 2, 2 2)", "LINESTRING(0 0, 2 2, 4 2)", "1FF0FF102");
test_geometry<ls, ls>("LINESTRING(1 1, 1 1, 2 2)", "LINESTRING(0 0, 2 2, 4 2)", "1FF0FF102");
// linear ring
test_geometry<ls, ls>("LINESTRING(0 0,10 0)", "LINESTRING(5 0,9 0,5 5,1 0,5 0)", "1F1FF01F2");
test_geometry<ls, ls>("LINESTRING(0 0,5 0,10 0)", "LINESTRING(5 0,9 0,5 5,1 0,5 0)", "1F1FF01F2");
test_geometry<ls, ls>("LINESTRING(0 0,5 0,10 0)", "LINESTRING(5 0,10 0,5 5,1 0,5 0)", "1F10F01F2");
test_geometry<ls, ls>("LINESTRING(0 0,5 0)", "LINESTRING(5 0,10 0,5 5,0 0,5 0)", "1FF0FF1F2");
test_geometry<ls, ls>("LINESTRING(0 0,5 0)", "LINESTRING(5 0,10 0,5 5,5 0)", "FF10F01F2");
test_geometry<ls, ls>("LINESTRING(1 0,1 6)", "LINESTRING(0 0,5 0,5 5,0 5)", "0F10F0102");
// point-size Linestring
test_geometry<ls, ls>("LINESTRING(1 0,1 0)", "LINESTRING(0 0,5 0)", "0FFFFF102");
test_geometry<ls, ls>("LINESTRING(1 0,1 0)", "LINESTRING(1 0,5 0)", "F0FFFF102");
test_geometry<ls, ls>("LINESTRING(1 0,1 0)", "LINESTRING(0 0,1 0)", "F0FFFF102");
test_geometry<ls, ls>("LINESTRING(1 0,1 0)", "LINESTRING(1 0,1 0)", "0FFFFFFF2");
test_geometry<ls, ls>("LINESTRING(1 0,1 0)", "LINESTRING(0 0,0 0)", "FF0FFF0F2");
//to_svg<ls, ls>("LINESTRING(0 0,5 0)", "LINESTRING(5 0,10 0,5 5,5 0)", "test_relate_00.svg");
// INVALID LINESTRINGS
// 1-point LS (a Point) NOT disjoint
//test_geometry<ls, ls>("LINESTRING(1 0)", "LINESTRING(0 0,5 0)", "0FFFFF102");
//test_geometry<ls, ls>("LINESTRING(0 0,5 0)", "LINESTRING(1 0)", "0F1FF0FF2");
//test_geometry<ls, ls>("LINESTRING(0 0,5 0)", "LINESTRING(1 0,1 0,1 0)", "0F1FF0FF2");
// Point/Point
//test_geometry<ls, ls>("LINESTRING(0 0)", "LINESTRING(0 0)", "0FFFFFFF2");
if ( BOOST_GEOMETRY_CONDITION(
boost::is_floating_point<typename bg::coordinate_type<ls>::type>::value ) )
{
// https://svn.boost.org/trac/boost/ticket/10904
// very small segments
test_geometry<ls, ls>("LINESTRING(5.6956521739130430148634331999347 -0.60869565217391330413931882503675,5.5 -0.50000000000000066613381477509392)",
"LINESTRING(5.5 -0.50000000000000066613381477509392,5.5 -0.5)",
"FF1F00102");
test_geometry<ls, ls>("LINESTRING(-3.2333333333333333925452279800083 5.5999999999999978683717927196994,-3.2333333333333333925452279800083 5.5999999999999996447286321199499)",
"LINESTRING(-3.2333333333333325043668082798831 5.5999999999999996447286321199499,-3.2333333333333333925452279800083 5.5999999999999996447286321199499)",
"FF1F00102", "F0FFFF102"); // on some platforms the first Linestring may be detected as degenerated to Point
}
if ( BOOST_GEOMETRY_CONDITION((
boost::is_same<typename bg::coordinate_type<ls>::type, double>::value )) )
{
// detected as collinear
test_geometry<ls, ls>("LINESTRING(1 -10, 3.069359e+307 3.069359e+307)",
"LINESTRING(1 6, 1 0)",
"*********"); // TODO: be more specific with the result
}
// OTHER MASKS
{
namespace bgdr = bg::detail::relate;
ls ls1, ls2, ls3, ls4;
bg::read_wkt("LINESTRING(0 0,2 0)", ls1);
bg::read_wkt("LINESTRING(2 0,4 0)", ls2);
bg::read_wkt("LINESTRING(1 0,1 1)", ls3);
bg::read_wkt("LINESTRING(1 0,4 0)", ls4);
BOOST_CHECK(bg::relate(ls1, ls2, bg::de9im::mask("FT*******")
|| bg::de9im::mask("F**T*****")
|| bg::de9im::mask("F***T****")));
BOOST_CHECK(bg::relate(ls1, ls3, bg::de9im::mask("FT*******")
|| bg::de9im::mask("F**T*****")
|| bg::de9im::mask("F***T****")));
BOOST_CHECK(bg::relate(ls3, ls1, bg::de9im::mask("FT*******")
|| bg::de9im::mask("F**T*****")
|| bg::de9im::mask("F***T****")));
BOOST_CHECK(bg::relate(ls2, ls4, bg::de9im::mask("T*F**F***"))); // within
BOOST_CHECK(bg::relate(ls1, ls2, bg::de9im::static_mask<'F','T'>()
|| bg::de9im::static_mask<'F','*','*','T'>()
|| bg::de9im::static_mask<'F','*','*','*','T'>()));
BOOST_CHECK(bg::relate(ls1, ls2, bg::de9im::mask("FT")
|| bg::de9im::mask("F**T")
|| bg::de9im::mask("F***T**************")));
BOOST_CHECK_THROW(bg::relate(ls1, ls2, bg::de9im::mask("A")), bg::invalid_input_exception);
}
// spike - boundary and interior on the same point
test_geometry<ls, ls>("LINESTRING(3 7, 8 8, 2 6)", "LINESTRING(5 7, 10 7, 0 7)", "0010F0102");
// 22.01.2015
test_geometry<ls, ls>("LINESTRING(5 5,10 10)", "LINESTRING(6 6,3 3)", "1010F0102");
test_geometry<ls, ls>("LINESTRING(5 5,2 8)", "LINESTRING(4 6,7 3)", "1010F0102");
}
template <typename P>
void test_linestring_multi_linestring()
{
typedef bg::model::linestring<P> ls;
typedef bg::model::multi_linestring<ls> mls;
// LS disjoint
test_geometry<ls, mls>("LINESTRING(0 0,10 0)", "MULTILINESTRING((1 0,2 0),(1 1,2 1))", "101FF0102");
// linear ring disjoint
test_geometry<ls, mls>("LINESTRING(0 0,10 0)", "MULTILINESTRING((1 0,2 0),(1 1,2 1,2 2,1 1))", "101FF01F2");
// 2xLS forming non-simple linear ring disjoint
test_geometry<ls, mls>("LINESTRING(0 0,10 0)", "MULTILINESTRING((1 0,2 0),(1 1,2 1,2 2),(1 1,2 2))", "101FF01F2");
test_geometry<ls, mls>("LINESTRING(0 0,10 0)",
"MULTILINESTRING((1 0,9 0),(9 0,2 0))",
"101FF0FF2");
// rings
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))",
"1FFFFFFF2");
test_geometry<ls, mls>("LINESTRING(0 0,5 0,5 5,0 5,0 0)",
"MULTILINESTRING((5 5,5 0,0 0),(0 0,0 5,5 5))",
"1FFFFFFF2");
// overlapping rings
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,0 5))",
"10FFFFFF2");
test_geometry<ls, mls>("LINESTRING(0 0,5 0,5 5,0 5,0 0)",
"MULTILINESTRING((5 5,5 0,0 0),(0 0,0 5,5 5,5 0))",
"10FFFFFF2");
// INVALID LINESTRINGS
// 1-point LS (a Point) disjoint
//test_geometry<ls, mls>("LINESTRING(0 0,10 0)", "MULTILINESTRING((1 0,2 0),(1 1))", "101FF00F2");
//test_geometry<ls, mls>("LINESTRING(0 0,10 0)", "MULTILINESTRING((1 0,2 0),(1 1,1 1))", "101FF00F2");
//test_geometry<ls, mls>("LINESTRING(0 0,10 0)", "MULTILINESTRING((1 0,2 0),(1 1,1 1,1 1))", "101FF00F2");
// 1-point LS (a Point) NOT disjoint
//test_geometry<ls, mls>("LINESTRING(0 0,10 0)", "MULTILINESTRING((1 0,9 0),(2 0))", "101FF0FF2");
//test_geometry<ls, mls>("LINESTRING(0 0,10 0)", "MULTILINESTRING((1 0,9 0),(2 0,2 0))", "101FF0FF2");
//test_geometry<ls, mls>("LINESTRING(0 0,10 0)", "MULTILINESTRING((1 0,9 0),(2 0,2 0,2 0))", "101FF0FF2");
// point-like
test_geometry<ls, mls>("LINESTRING(0 0, 5 0)", // |--------------|
"MULTILINESTRING((0 0, 1 0),(2 0, 2 0))", // |------| *
"101F00FF2");
test_geometry<ls, mls>("LINESTRING(0 0, 5 0)", // |--------------|
"MULTILINESTRING((0 0, 1 0),(1 0, 1 0))", // |------*
"101F00FF2");
test_geometry<ls, mls>("LINESTRING(0 0, 5 0)", // |--------------|
"MULTILINESTRING((5 0, 1 0),(1 0, 1 0))", // *-------|
"101F00FF2");
test_geometry<ls, mls>("LINESTRING(0 0, 5 0)", // |--------------|
"MULTILINESTRING((0 0, 1 0),(5 0, 5 0))", // |------| *
"10100FFF2");
test_geometry<ls, mls>("LINESTRING(0 0, 5 0)", // |--------------|
"MULTILINESTRING((0 0, 1 0),(0 0, 0 0))", // *------|
"101000FF2");
test_geometry<ls, mls>("LINESTRING(0 0, 5 0)", // |--------------|
"MULTILINESTRING((4 0, 5 0),(5 0, 5 0))", // |------*
"101000FF2");
test_geometry<ls, mls>("LINESTRING(0 0, 5 0)", // |--------------|
"MULTILINESTRING((1 0, 2 0),(0 0, 0 0))", // * |------|
"1010F0FF2");
test_geometry<ls, mls>("LINESTRING(0 0, 5 0)", // |--------------|
"MULTILINESTRING((2 0, 2 0),(2 0, 2 2))", // *
"001FF0102"); // |
// for consistency
test_geometry<ls, mls>("LINESTRING(0 0, 5 0)", // |--------------|
"MULTILINESTRING((0 0, 5 0),(0 0, 2 0))", // |--------------|
"10F00FFF2"); // |------|
test_geometry<ls, mls>("LINESTRING(0 0, 5 0)", // |--------------|
"MULTILINESTRING((0 0, 5 0),(3 0, 5 0))", // |--------------|
"10F00FFF2"); // |------|
test_geometry<ls, mls>("LINESTRING(0 0, 5 0)", // |--------------|
"MULTILINESTRING((0 0, 5 0),(0 0, 6 0))", // |--------------|
"1FF00F102"); // |----------------|
test_geometry<ls, mls>("LINESTRING(0 0, 5 0)", // |--------------|
"MULTILINESTRING((0 0, 5 0),(-1 0, 5 0))", // |--------------|
"1FF00F102"); // |----------------|
test_geometry<ls, mls>("LINESTRING(0 0, 5 0)", // |--------------|
"MULTILINESTRING((0 0, 5 0),(-1 0, 6 0))", // |--------------|
"1FF00F102"); // |------------------|
test_geometry<ls, mls>("LINESTRING(0 0, 5 0)", // |--------------|
"MULTILINESTRING((0 0, 5 0),(-1 0, 2 0))", // |--------------|
"10F00F102"); // |-------|
test_geometry<ls, mls>("LINESTRING(0 0, 5 0)", // |--------------|
"MULTILINESTRING((0 0, 5 0),(2 0, 6 0))", // |--------------|
"10F00F102"); // |-------|
test_geometry<ls, mls>("LINESTRING(0 0, 5 0)", // |--------------|
"MULTILINESTRING((0 0, 5 0),(2 0, 2 2))", // |--------------|
"10FF0F102"); // |
// |
if ( BOOST_GEOMETRY_CONDITION(boost::is_floating_point<typename bg::coordinate_type<ls>::type>::value) )
{
// related to https://svn.boost.org/trac/boost/ticket/10904
test_geometry<ls, mls>("LINESTRING(-2305843009213693956 4611686018427387906, -33 -92, 78 83)",
"MULTILINESTRING((20 100, 31 -97, -46 57, -20 -4),(-71 -4))",
"*********"); // TODO: be more specific with the result
}
// 22.01.2015
// inspired by L/A and A/A
test_geometry<ls, mls>("LINESTRING(1 1,2 2)", "MULTILINESTRING((0 0,1 1),(1 1,3 3))", "1FF0FF102");
// 25.01.2015
test_geometry<ls, mls>("LINESTRING(1 1, 5 5, 4 4)",
"MULTILINESTRING((2 5, 7 5, 8 3, 6 3, 4 0),(0 0,10 10))",
"1FF0FF102");
test_geometry<ls, mls>("LINESTRING(4 1, 4 5, 4 4)",
"MULTILINESTRING((2 5, 7 5, 8 3, 6 3, 4 0),(4 0, 4 8, 0 4))",
"1FF0FF102");
test_geometry<ls, mls>("LINESTRING(1 1,5 5,4 4)",
"MULTILINESTRING((5 0,5 5,5 10),(0 0,10 10))",
"1FF0FF102");
test_geometry<ls, mls>("LINESTRING(1 1,5 5,1 0)",
"MULTILINESTRING((5 0,5 5,5 10),(0 0,5 5,1 0))",
"1FF00F102");
test_geometry<ls, mls>("LINESTRING(5 5,4 4)",
"MULTILINESTRING((5 0,5 5,5 10),(0 0,10 10))",
"1FF0FF102");
test_geometry<ls, mls>("LINESTRING(6 6,5 5,4 4)",
"MULTILINESTRING((5 0,5 5,5 10),(0 0,10 10))",
"1FF0FF102");
test_geometry<ls, mls>("LINESTRING(5 5,4 4)",
"MULTILINESTRING((5 0,5 5,5 10))",
"FF10F0102");
}
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))",
"1F1F00102");
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),(1 10,1 10,1 0,1 0,1 -10),(2 0,2 0),(3 0,3 0,3 0),(0 0,0 0,0 10,0 10),(30 0,30 0,31 0,31 0))",
"MULTILINESTRING((0 10,5 0,20 0,20 0,30 0),(1 10,1 10,1 0,1 0,1 -10),(0 0,0 0,0 10,0 10),(30 0,30 0,31 0,31 0))",
"1F100F102");
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),(0 0,0 0,0 10,0 10))",
"1F1F0F1F2");
// point-like
test_geometry<mls, mls>("MULTILINESTRING((0 0, 0 0),(1 1, 1 1))",
"MULTILINESTRING((0 0, 0 0))",
"0F0FFFFF2");
test_geometry<mls, mls>("MULTILINESTRING((0 0, 0 0),(1 1, 1 1))",
"MULTILINESTRING((0 0, 0 0),(1 1, 1 1))",
"0FFFFFFF2");
test_geometry<mls, mls>("MULTILINESTRING((0 0, 0 0),(1 1, 1 1))",
"MULTILINESTRING((2 2, 2 2),(3 3, 3 3))",
"FF0FFF0F2");
test_geometry<mls, mls>("MULTILINESTRING((0 5,10 5,10 10,5 10),(5 10,5 0,5 2),(5 2,5 5,0 5))",
"MULTILINESTRING((5 5,0 5),(5 5,5 0),(10 10,10 5,5 5,5 10,10 10))",
"10FFFFFF2");
if ( BOOST_GEOMETRY_CONDITION((
boost::is_same<typename bg::coordinate_type<P>::type, double>::value )) )
{
// assertion failure in 1.57
test_geometry<mls, mls>("MULTILINESTRING((-0.59322033898305082 -8.0508474576271194,-2.882352941176471 -7.7647058823529411,-2.8823529411764706 -7.7647058823529411,-3.7361111111111112 -6.5694444444444446,-3.4404145077720205 -5.766839378238342,-4.1864406779661012 -3.6779661016949152,-7.5252525252525251 -5.5858585858585865,-7.5862068965517242 -5.1896551724137936,-4.47887323943662 -2.859154929577465,-4.5789473684210531 -2.5789473684210527,-3 -1,-2.9310344827586206 -0.86206896551724144,-3.1764705882352944 -0.70588235294117663,-4.7401960784313726 -2.1274509803921577,-5.3255813953488369 -0.48837209302325502,-4.7872340425531918 0.31914893617021284,-5.8571428571428577 1.0000000000000007,-5.3255813953488369 -0.48837209302325502,-5.9473684210526319 -1.4210526315789465,-8 2,-7.7333333333333334 2.1939393939393939,-8.8294573643410867 2.891472868217055,-8.8556701030927822 3.061855670103093,-7.5999999999999996 3.6000000000000001,-7.7999999999999998 3.7999999999999998,-7.75 3.7916666666666665,-7.5471698113207548 3.6226415094339623,-7.3200000000000003 3.7200000000000002,-3.473684210526315 3.0789473684210527,-3.2549019607843133 3.2156862745098036,-2.9999999999999982 3.1428571428571423,-3.1733333333333325 3.2666666666666666,-2.9180327868852456 3.4262295081967209,-2.8723404255319145 3.1063829787234041,-2.1111111111111112 2.8888888888888888,-2.1428571428571428 2.8571428571428572,-1.8433734939759043 2.8072289156626509,-1.8396226415094346 2.8113207547169816,-1.6486486486486487 2.756756756756757,-1.76510067114094 2.8926174496644301,-0.53846153846153855 4.2307692307692308,1.8148148148148147 5.4074074074074074,1.588235294117647 2.2352941176470589,1.819672131147541 2.1967213114754101,2 4,2 2.1666666666666665,2.3538461538461544 2.1076923076923078,2 1.6875000000000004,2 -2,1.2173913043478262 -3.8260869565217392,1.7375886524822697 1.3758865248226959,1.5073170731707317 1.1024390243902444,1.1428571428571428 -4,-0.59322033898305082 -8.0508474576271194),(1.666666666666667 1.5999999999999988,1.5675675675675675 1.8378378378378377,1.4374999999999991 1.8750000000000002,1.0487804878048776 2.3414634146341466,0.46666666666666712 2.6060606060606055,0.086956521739131043 2.2608695652173911,1.4374999999999991 1.8750000000000002,1.666666666666667 1.5999999999999988))",
"MULTILINESTRING((-2.333333333333333 -8.6666666666666661,-4.3253012048192767 -8.168674698795181,-4.1194968553459113 -7.6100628930817606,-2.8823529411764706 -7.7647058823529411,-2.882352941176471 -7.7647058823529411,-2.263157894736842 -8.6315789473684212,-2.333333333333333 -8.6666666666666661))",
"*********");
}
}
template <typename P>
void test_all()
{
test_linestring_linestring<P>();
test_linestring_multi_linestring<P>();
test_multi_linestring_multi_linestring<P>();
}
int test_main( int , char* [] )
{
test_all<bg::model::d2::point_xy<int> >();
test_all<bg::model::d2::point_xy<double> >();
#if defined(HAVE_TTMATH)
test_all<bg::model::d2::point_xy<ttmath_big> >();
#endif
return 0;
}

View File

@@ -0,0 +1,451 @@
// Boost.Geometry
// Unit Test
// Copyright (c) 2016, 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_relate.hpp"
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)", "1FFF0FFF2");
test_geometry<ls, ls>("LINESTRING(0 0,3 2)", "LINESTRING(0 0, 2 2, 3 2)", "FF1F0F1F2");
test_geometry<ls, ls>("LINESTRING(1 0,2 2,2 3)", "LINESTRING(0 0, 2 2, 3 2)", "0F1FF0102");
test_geometry<ls, ls>("LINESTRING(0 0,5 0)", "LINESTRING(0 0,1 1,2 0,2 -1)", "0F1F00102");
test_geometry<ls, ls>("LINESTRING(0 0, 1 1.0004570537241206, 2 2, 3 2)", "LINESTRING(0 0, 2 2, 3 2)", "1FFF0FFF2");
test_geometry<ls, ls>("LINESTRING(3 2, 2 2, 1 1.0004570537241206, 0 0)", "LINESTRING(0 0, 2 2, 3 2)", "1FFF0FFF2");
test_geometry<ls, ls>("LINESTRING(0 0, 1 1.0004570537241206, 2 2, 3 2)", "LINESTRING(3 2, 2 2, 0 0)", "1FFF0FFF2");
test_geometry<ls, ls>("LINESTRING(3 2, 2 2, 1 1.0004570537241206, 0 0)", "LINESTRING(3 2, 2 2, 0 0)", "1FFF0FFF2");
test_geometry<ls, ls>("LINESTRING(3 1, 2 2, 1 1.0004570537241206, 0 0)", "LINESTRING(0 0, 2 2, 3 2)", "1F1F00102");
test_geometry<ls, ls>("LINESTRING(3 3, 2 2.0015234344160047, 1 1.0012195839797347, 0 0)", "LINESTRING(0 0, 2 2.0015234344160047, 3 2)", "1F1F00102");
test_geometry<ls, ls>("LINESTRING(0 0, 1 1.0004570537241206, 2 2, 2 3)", "LINESTRING(0 0, 2 2, 2 3)", "1FFF0FFF2");
test_geometry<ls, ls>("LINESTRING(2 3, 2 2, 1 1.0004570537241206, 0 0)", "LINESTRING(0 0, 2 2, 2 3)", "1FFF0FFF2");
test_geometry<ls, ls>("LINESTRING(0 0, 1 1.0004570537241206, 2 2, 2 3)", "LINESTRING(2 3, 2 2, 0 0)", "1FFF0FFF2");
test_geometry<ls, ls>("LINESTRING(2 3, 2 2, 1 1.0004570537241206, 0 0)", "LINESTRING(2 3, 2 2, 0 0)", "1FFF0FFF2");
test_geometry<ls, ls>("LINESTRING(1 1.0004570537241206, 2 2, 3 2.0003044086155000)", "LINESTRING(0 0, 2 2, 4 2)", "1FF0FF102");
test_geometry<ls, ls>("LINESTRING(3 2.0003044086155000, 2 2, 1 1.0004570537241206)", "LINESTRING(0 0, 2 2, 4 2)", "1FF0FF102");
test_geometry<ls, ls>("LINESTRING(1 1.0004570537241206, 2 2, 3 2.0003044086155000)", "LINESTRING(4 2, 2 2, 0 0)", "1FF0FF102");
test_geometry<ls, ls>("LINESTRING(3 2.0003044086155000, 2 2, 1 1.0004570537241206)", "LINESTRING(4 2, 2 2, 0 0)", "1FF0FF102");
// test_geometry<ls, ls>("LINESTRING(1 1, 2 2, 2 2)", "LINESTRING(0 0, 2 2, 4 2)", true);
// test_geometry<ls, ls>("LINESTRING(1 1, 2 2, 3 3)", "LINESTRING(0 0, 2 2, 4 2)", false);
// test_geometry<ls, ls>("LINESTRING(1 1, 2 2, 3 2, 3 3)", "LINESTRING(0 0, 2 2, 4 2)", false);
// test_geometry<ls, ls>("LINESTRING(1 1, 2 2, 3 1)", "LINESTRING(0 0, 2 2, 4 2)", false);
// test_geometry<ls, ls>("LINESTRING(1 1, 2 2, 3 2, 3 1)", "LINESTRING(0 0, 2 2, 4 2)", false);
// test_geometry<ls, ls>("LINESTRING(0 1, 1 1, 2 2, 3 2)", "LINESTRING(0 0, 2 2, 4 2)", false);
// test_geometry<ls, ls>("LINESTRING(0 1, 0 0, 2 2, 3 2)", "LINESTRING(0 0, 2 2, 4 2)", false);
// test_geometry<ls, ls>("LINESTRING(1 0, 1 1, 2 2, 3 2)", "LINESTRING(0 0, 2 2, 4 2)", false);
// test_geometry<ls, ls>("LINESTRING(1 0, 0 0, 2 2, 3 2)", "LINESTRING(0 0, 2 2, 4 2)", false);
// test_geometry<ls, ls>("LINESTRING(0 0)", "LINESTRING(0 0)", false);
// test_geometry<ls, ls>("LINESTRING(1 1)", "LINESTRING(0 0, 2 2)", true);
// test_geometry<ls, ls>("LINESTRING(0 0)", "LINESTRING(0 0, 2 2)", false);
// test_geometry<ls, ls>("LINESTRING(0 0, 1 1)", "LINESTRING(0 0)", false);
// test_geometry<ls, ls>("LINESTRING(0 0,5 0,3 0,6 0)", "LINESTRING(0 0,6 0)", true);
// test_geometry<ls, ls>("LINESTRING(0 0,2 2,3 3,1 1)", "LINESTRING(0 0,3 3,6 3)", true);
// SPIKES!
test_geometry<ls, ls>("LINESTRING(0 0,2 2.0015234344160047,3 3,1 1.0012195839797347,5 3.0009124369434743)", "LINESTRING(0 0,3 3,6 3)", "1F100F102");
test_geometry<ls, ls>("LINESTRING(5 3.0009124369434743,1 1.0012195839797347,3 3,2 2.0015234344160047,0 0)", "LINESTRING(0 0,3 3,6 3)", "1F100F102");
test_geometry<ls, ls>("LINESTRING(0 0,2 2.0015234344160047,3 3,1 1.0012195839797347,5 3.0009124369434743)", "LINESTRING(6 3,3 3,0 0)", "1F100F102");
test_geometry<ls, ls>("LINESTRING(5 3.0009124369434743,1 1.0012195839797347,3 3,2 2.0015234344160047,0 0)", "LINESTRING(6 3,3 3,0 0)", "1F100F102");
test_geometry<ls, ls>("LINESTRING(6 3,3 3,0 0)", "LINESTRING(0 0,2 2.0015234344160047,3 3,1 1.0012195839797347,5 3.0009124369434743)", "101F001F2");
test_geometry<ls, ls>("LINESTRING(0 0,10 0)", "LINESTRING(1 0,9 0,2 0)", "101FF0FF2");
test_geometry<ls, ls>("LINESTRING(0 0,2 2.0015234344160047,3 3,1 1.0012195839797347)", "LINESTRING(0 0,3 3,6 3)", "1FF00F102");
// TODO: REWRITE MATRICES
// BEGIN
/*test_geometry<ls, ls>("LINESTRING(0 0,2 2,3 3,1 1)", "LINESTRING(0 0,4 4,6 3)", "1FF00F102");
test_geometry<ls, ls>("LINESTRING(0 0,2 0,1 0)", "LINESTRING(0 1,0 0,2 0)", "1FF00F102");
test_geometry<ls, ls>("LINESTRING(2 0,0 0,1 0)", "LINESTRING(0 1,0 0,2 0)", "1FF00F102");
test_geometry<ls, ls>("LINESTRING(0 0,3 3,1 1)", "LINESTRING(3 0,3 3,3 1)", "0F1FF0102");
test_geometry<ls, ls>("LINESTRING(0 0,3 3,1 1)", "LINESTRING(2 0,2 3,2 1)", "0F1FF0102");
test_geometry<ls, ls>("LINESTRING(0 0,3 3,1 1)", "LINESTRING(2 0,2 2,2 1)", "0F1FF0102");
test_geometry<ls, ls>("LINESTRING(0 0,2 2,3 3,4 4)", "LINESTRING(0 0,1 1,4 4)", "1FFF0FFF2");*/
// END
test_geometry<ls, ls>("LINESTRING(0 0,2 2.0036594926050868,3 3.0031983963093536,4 4)", "LINESTRING(0 0,1 1.0022887548647632,4 4)", "1FFF0FFF2");
// loop i/i i/i u/u u/u
test_geometry<ls, ls>("LINESTRING(0 0,10 0)",
"LINESTRING(1 1,1 0,6 0,6 1,4 1,4 0,9 0,9 1)", "1F1FF0102");
// self-intersecting and self-touching equal
test_geometry<ls, ls>("LINESTRING(0 5,5 5,10 5,10 10,5 10,5 5,5 0)",
"LINESTRING(0 5,5 5,5 10,10 10,10 5,5 5,5 0)", "1FFF0FFF2");
// self-intersecting loop and self-touching equal
test_geometry<ls, ls>("LINESTRING(0 5,5 5,10 5,10 10,5 10,5 5,10 5,10 10,5 10,5 5,5 0)",
"LINESTRING(0 5,5 5,5 10,10 10,10 5,5 5,5 0)", "1FFF0FFF2");
test_geometry<ls, ls>("LINESTRING(0 0,1 1)", "LINESTRING(0 1,1 0)", "0F1FF0102");
test_geometry<ls, ls>("LINESTRING(0 0,1 1)", "LINESTRING(1 1,2 0)", "FF1F00102");
test_geometry<ls, ls>("LINESTRING(0 0,1 1)", "LINESTRING(2 0,1 1)", "FF1F00102");
test_geometry<ls, ls>("LINESTRING(0 0,1 0,2 1,3 5,4 0)", "LINESTRING(1 0,2 1,3 5)", "101FF0FF2");
test_geometry<ls, ls>("LINESTRING(0 0,1 0,2 1,3 5,4 0)", "LINESTRING(3 5,2 1,1 0)", "101FF0FF2");
test_geometry<ls, ls>("LINESTRING(1 0,2 1,3 5)", "LINESTRING(4 0,3 5,2 1,1 0,0 0)", "1FF0FF102");
test_geometry<ls, ls>("LINESTRING(3 5,2 1,1 0)", "LINESTRING(4 0,3 5,2 1,1 0,0 0)", "1FF0FF102");
test_geometry<ls, ls>("LINESTRING(0 0,10 0)", "LINESTRING(-1 -1,1 0,10 0,20 -1)", "1F10F0102");
test_geometry<ls, ls>("LINESTRING(0 0,10 0)", "LINESTRING(20 -1,10 0,1 0,-1 -1)", "1F10F0102");
test_geometry<ls, ls>("LINESTRING(-1 1,0 0,1 0,5 0,5 5,10 5,15 0,31 0)",
"LINESTRING(-1 -1,0 0,1 0,2 0,3 1,4 0,30 0)",
"101FF0102");
test_geometry<ls, ls>("LINESTRING(-1 1,0 0,1 0,5 0,5 5,10 5,15 0,31 0)",
"LINESTRING(30 0,4 0,3 1,2 0,1 0,0 0,-1 -1)",
"101FF0102");
test_geometry<ls, ls>("LINESTRING(31 0,15 0,10 5,5 5,5 0,1 0,0 0,-1 1)",
"LINESTRING(-1 -1,0 0,1 0,2 0,3 1,4 0,30 0)",
"101FF0102");
test_geometry<ls, ls>("LINESTRING(31 0,15 0,10 5,5 5,5 0,1 0,0 0,-1 1)",
"LINESTRING(30 0,4 0,3 1,2 0,1 0,0 0,-1 -1)",
"101FF0102");
// self-IP
test_geometry<ls, ls>("LINESTRING(1 0,9 0)",
"LINESTRING(0 0,10 0,10 10,5 0,0 10)",
"1FF0FF102");
test_geometry<ls, ls>("LINESTRING(1 0,5 0,9 0)",
"LINESTRING(0 0,10 0,10 10,5 0,0 10)",
"1FF0FF102");
test_geometry<ls, ls>("LINESTRING(1 0,9 0)",
"LINESTRING(0 0,10 0,10 10,5 10,5 -1)",
"1FF0FF102");
test_geometry<ls, ls>("LINESTRING(1 0,9 0)",
"LINESTRING(0 0,10 0,5 0,5 5)",
"1FF0FF102");
test_geometry<ls, ls>("LINESTRING(1 0,7 0)", "LINESTRING(0 0,10 0,10 10,4 -1)",
"1FF0FF102");
test_geometry<ls, ls>("LINESTRING(1 0,5 0,7 0)", "LINESTRING(0 0,10 0,10 10,4 -1)",
"1FF0FF102");
test_geometry<ls, ls>("LINESTRING(1 0,7 0,8 1)", "LINESTRING(0 0,10 0,10 10,4 -1)",
"1F10F0102");
test_geometry<ls, ls>("LINESTRING(1 0,5 0,7 0,8 1)", "LINESTRING(0 0,10 0,10 10,4 -1)",
"1F10F0102");
// self-IP going out and in on the same point
test_geometry<ls, ls>("LINESTRING(2 0,5 0,5 5,6 5,5 0,8 0)", "LINESTRING(1 0,9 0)",
"1F10FF102");
// duplicated points
test_geometry<ls, ls>("LINESTRING(1 1.0004570537241206, 2 2, 2 2)", "LINESTRING(0 0, 2 2, 4 2)", "1FF0FF102");
test_geometry<ls, ls>("LINESTRING(1 1.0004570537241206, 1 1.0004570537241206, 2 2)", "LINESTRING(0 0, 2 2, 4 2)", "1FF0FF102");
// linear ring
test_geometry<ls, ls>("LINESTRING(0 0,10 0)", "LINESTRING(5 0,9 0,5 5,1 0,5 0)", "1F1FF01F2");
test_geometry<ls, ls>("LINESTRING(0 0,5 0,10 0)", "LINESTRING(5 0,9 0,5 5,1 0,5 0)", "1F1FF01F2");
test_geometry<ls, ls>("LINESTRING(0 0,5 0,10 0)", "LINESTRING(5 0,10 0,5 5,1 0,5 0)", "1F10F01F2");
test_geometry<ls, ls>("LINESTRING(0 0,5 0)", "LINESTRING(5 0,10 0,5 5,0 0,5 0)", "1FF0FF1F2");
test_geometry<ls, ls>("LINESTRING(0 0,5 0)", "LINESTRING(5 0,10 0,5 5,5 0)", "FF10F01F2");
test_geometry<ls, ls>("LINESTRING(1 0,1 6)", "LINESTRING(0 0,5 0,5 5,0 5)", "0F10F0102");
// point-size Linestring
test_geometry<ls, ls>("LINESTRING(1 0,1 0)", "LINESTRING(0 0,5 0)", "0FFFFF102");
test_geometry<ls, ls>("LINESTRING(1 0,1 0)", "LINESTRING(1 0,5 0)", "F0FFFF102");
test_geometry<ls, ls>("LINESTRING(1 0,1 0)", "LINESTRING(0 0,1 0)", "F0FFFF102");
test_geometry<ls, ls>("LINESTRING(1 0,1 0)", "LINESTRING(1 0,1 0)", "0FFFFFFF2");
test_geometry<ls, ls>("LINESTRING(1 0,1 0)", "LINESTRING(0 0,0 0)", "FF0FFF0F2");
//to_svg<ls, ls>("LINESTRING(0 0,5 0)", "LINESTRING(5 0,10 0,5 5,5 0)", "test_relate_00.svg");
// INVALID LINESTRINGS
// 1-point LS (a Point) NOT disjoint
//test_geometry<ls, ls>("LINESTRING(1 0)", "LINESTRING(0 0,5 0)", "0FFFFF102");
//test_geometry<ls, ls>("LINESTRING(0 0,5 0)", "LINESTRING(1 0)", "0F1FF0FF2");
//test_geometry<ls, ls>("LINESTRING(0 0,5 0)", "LINESTRING(1 0,1 0,1 0)", "0F1FF0FF2");
// Point/Point
//test_geometry<ls, ls>("LINESTRING(0 0)", "LINESTRING(0 0)", "0FFFFFFF2");
if ( BOOST_GEOMETRY_CONDITION(
boost::is_floating_point<typename bg::coordinate_type<ls>::type>::value ) )
{
// https://svn.boost.org/trac/boost/ticket/10904
// very small segments
test_geometry<ls, ls>("LINESTRING(5.6956521739130430148634331999347 -0.60869565217391330413931882503675,5.5 -0.50000000000000066613381477509392)",
"LINESTRING(5.5 -0.50000000000000066613381477509392,5.5 -0.5)",
"*********"); // TODO: be more specific with the result
test_geometry<ls, ls>("LINESTRING(-3.2333333333333333925452279800083 5.5999999999999978683717927196994,-3.2333333333333333925452279800083 5.5999999999999996447286321199499)",
"LINESTRING(-3.2333333333333325043668082798831 5.5999999999999996447286321199499,-3.2333333333333333925452279800083 5.5999999999999996447286321199499)",
"*********"); // TODO: be more specific with the result
}
if ( BOOST_GEOMETRY_CONDITION((
boost::is_same<typename bg::coordinate_type<ls>::type, double>::value )) )
{
// detected as collinear
test_geometry<ls, ls>("LINESTRING(1 -10, 3.069359e+307 3.069359e+307)",
"LINESTRING(1 6, 1 0)",
"*********"); // TODO: be more specific with the result
}
// OTHER MASKS
{
namespace bgdr = bg::detail::relate;
ls ls1, ls2, ls3, ls4;
bg::read_wkt("LINESTRING(0 0,2 0)", ls1);
bg::read_wkt("LINESTRING(2 0,4 0)", ls2);
bg::read_wkt("LINESTRING(1 0,1 1)", ls3);
bg::read_wkt("LINESTRING(1 0,4 0)", ls4);
BOOST_CHECK(bg::relate(ls1, ls2, bg::de9im::mask("FT*******")
|| bg::de9im::mask("F**T*****")
|| bg::de9im::mask("F***T****")));
BOOST_CHECK(bg::relate(ls1, ls3, bg::de9im::mask("FT*******")
|| bg::de9im::mask("F**T*****")
|| bg::de9im::mask("F***T****")));
BOOST_CHECK(bg::relate(ls3, ls1, bg::de9im::mask("FT*******")
|| bg::de9im::mask("F**T*****")
|| bg::de9im::mask("F***T****")));
BOOST_CHECK(bg::relate(ls2, ls4, bg::de9im::mask("T*F**F***"))); // within
BOOST_CHECK(bg::relate(ls1, ls2, bg::de9im::static_mask<'F','T'>()
|| bg::de9im::static_mask<'F','*','*','T'>()
|| bg::de9im::static_mask<'F','*','*','*','T'>()));
BOOST_CHECK(bg::relate(ls1, ls2, bg::de9im::mask("FT")
|| bg::de9im::mask("F**T")
|| bg::de9im::mask("F***T**************")));
BOOST_CHECK_THROW(bg::relate(ls1, ls2, bg::de9im::mask("A")), bg::invalid_input_exception);
}
// spike - boundary and interior on the same point
test_geometry<ls, ls>("LINESTRING(3 7.0222344894505291, 8 8, 2 6.0297078652914440)", "LINESTRING(5 7.0264720782244758, 10 7, 0 7)", "0010F0102");
// 22.01.2015
test_geometry<ls, ls>("LINESTRING(5 5.0276084891434261,10 10)", "LINESTRING(6 6.0348911579043349,3 3)", "1010F0102");
test_geometry<ls, ls>("LINESTRING(5 5.0146631750126396,2 8)", "LINESTRING(4 6.0155438000959975,7 3)", "1010F0102");
}
template <typename P>
void test_linestring_multi_linestring()
{
typedef bg::model::linestring<P> ls;
typedef bg::model::multi_linestring<ls> mls;
// LS disjoint
test_geometry<ls, mls>("LINESTRING(0 0,10 0)", "MULTILINESTRING((1 0,2 0),(1 1,2 1))", "101FF0102");
// linear ring disjoint
test_geometry<ls, mls>("LINESTRING(0 0,10 0)", "MULTILINESTRING((1 0,2 0),(1 1,2 1,2 2,1 1))", "101FF01F2");
// 2xLS forming non-simple linear ring disjoint
test_geometry<ls, mls>("LINESTRING(0 0,10 0)", "MULTILINESTRING((1 0,2 0),(1 1,2 1,2 2),(1 1,2 2))", "101FF01F2");
test_geometry<ls, mls>("LINESTRING(0 0,10 0)",
"MULTILINESTRING((1 0,9 0),(9 0,2 0))",
"101FF0FF2");
// rings
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))",
"1FFFFFFF2");
test_geometry<ls, mls>("LINESTRING(0 0,5 0,5 5,0 5,0 0)",
"MULTILINESTRING((5 5,5 0,0 0),(0 0,0 5,5 5))",
"1FFFFFFF2");
// overlapping rings
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,0 5))",
"10FFFFFF2");
test_geometry<ls, mls>("LINESTRING(0 0,5 0,5 5,0 5,0 0)",
"MULTILINESTRING((5 5,5 0,0 0),(0 0,0 5,5 5,5 0))",
"10FFFFFF2");
// INVALID LINESTRINGS
// 1-point LS (a Point) disjoint
//test_geometry<ls, mls>("LINESTRING(0 0,10 0)", "MULTILINESTRING((1 0,2 0),(1 1))", "101FF00F2");
//test_geometry<ls, mls>("LINESTRING(0 0,10 0)", "MULTILINESTRING((1 0,2 0),(1 1,1 1))", "101FF00F2");
//test_geometry<ls, mls>("LINESTRING(0 0,10 0)", "MULTILINESTRING((1 0,2 0),(1 1,1 1,1 1))", "101FF00F2");
// 1-point LS (a Point) NOT disjoint
//test_geometry<ls, mls>("LINESTRING(0 0,10 0)", "MULTILINESTRING((1 0,9 0),(2 0))", "101FF0FF2");
//test_geometry<ls, mls>("LINESTRING(0 0,10 0)", "MULTILINESTRING((1 0,9 0),(2 0,2 0))", "101FF0FF2");
//test_geometry<ls, mls>("LINESTRING(0 0,10 0)", "MULTILINESTRING((1 0,9 0),(2 0,2 0,2 0))", "101FF0FF2");
// point-like
test_geometry<ls, mls>("LINESTRING(0 0, 5 0)", // |--------------|
"MULTILINESTRING((0 0, 1 0),(2 0, 2 0))", // |------| *
"101F00FF2");
test_geometry<ls, mls>("LINESTRING(0 0, 5 0)", // |--------------|
"MULTILINESTRING((0 0, 1 0),(1 0, 1 0))", // |------*
"101F00FF2");
test_geometry<ls, mls>("LINESTRING(0 0, 5 0)", // |--------------|
"MULTILINESTRING((5 0, 1 0),(1 0, 1 0))", // *-------|
"101F00FF2");
test_geometry<ls, mls>("LINESTRING(0 0, 5 0)", // |--------------|
"MULTILINESTRING((0 0, 1 0),(5 0, 5 0))", // |------| *
"10100FFF2");
test_geometry<ls, mls>("LINESTRING(0 0, 5 0)", // |--------------|
"MULTILINESTRING((0 0, 1 0),(0 0, 0 0))", // *------|
"101000FF2");
test_geometry<ls, mls>("LINESTRING(0 0, 5 0)", // |--------------|
"MULTILINESTRING((4 0, 5 0),(5 0, 5 0))", // |------*
"101000FF2");
test_geometry<ls, mls>("LINESTRING(0 0, 5 0)", // |--------------|
"MULTILINESTRING((1 0, 2 0),(0 0, 0 0))", // * |------|
"1010F0FF2");
test_geometry<ls, mls>("LINESTRING(0 0, 5 0)", // |--------------|
"MULTILINESTRING((2 0, 2 0),(2 0, 2 2))", // *
"001FF0102"); // |
// for consistency
test_geometry<ls, mls>("LINESTRING(0 0, 5 0)", // |--------------|
"MULTILINESTRING((0 0, 5 0),(0 0, 2 0))", // |--------------|
"10F00FFF2"); // |------|
test_geometry<ls, mls>("LINESTRING(0 0, 5 0)", // |--------------|
"MULTILINESTRING((0 0, 5 0),(3 0, 5 0))", // |--------------|
"10F00FFF2"); // |------|
test_geometry<ls, mls>("LINESTRING(0 0, 5 0)", // |--------------|
"MULTILINESTRING((0 0, 5 0),(0 0, 6 0))", // |--------------|
"1FF00F102"); // |----------------|
test_geometry<ls, mls>("LINESTRING(0 0, 5 0)", // |--------------|
"MULTILINESTRING((0 0, 5 0),(-1 0, 5 0))", // |--------------|
"1FF00F102"); // |----------------|
test_geometry<ls, mls>("LINESTRING(0 0, 5 0)", // |--------------|
"MULTILINESTRING((0 0, 5 0),(-1 0, 6 0))", // |--------------|
"1FF00F102"); // |------------------|
test_geometry<ls, mls>("LINESTRING(0 0, 5 0)", // |--------------|
"MULTILINESTRING((0 0, 5 0),(-1 0, 2 0))", // |--------------|
"10F00F102"); // |-------|
test_geometry<ls, mls>("LINESTRING(0 0, 5 0)", // |--------------|
"MULTILINESTRING((0 0, 5 0),(2 0, 6 0))", // |--------------|
"10F00F102"); // |-------|
test_geometry<ls, mls>("LINESTRING(0 0, 5 0)", // |--------------|
"MULTILINESTRING((0 0, 5 0),(2 0, 2 2))", // |--------------|
"10FF0F102"); // |
// |
if ( BOOST_GEOMETRY_CONDITION(boost::is_floating_point<typename bg::coordinate_type<ls>::type>::value) )
{
// related to https://svn.boost.org/trac/boost/ticket/10904
test_geometry<ls, mls>("LINESTRING(-2305843009213693956 4611686018427387906, -33 -92, 78 83)",
"MULTILINESTRING((20 100, 31 -97, -46 57, -20 -4),(-71 -4))",
"*********"); // TODO: be more specific with the result
}
// 22.01.2015
// inspired by L/A and A/A
test_geometry<ls, mls>("LINESTRING(1 1.0012195839797347,2 2.0015234344160047)",
"MULTILINESTRING((0 0,1 1.0012195839797347),(1 1.0012195839797347,3 3))",
"1FF0FF102");
// for floats this is considered as collinear due to a special check in spherical intersection strategy
test_geometry<ls, mls>("LINESTRING(1 1,2 2)",
"MULTILINESTRING((0 0,1 1),(1 1,3 3))",
"FF10F0102", "1FF0FF102");
// 25.01.2015
test_geometry<ls, mls>("LINESTRING(1 1.0152687848942923, 5 5.0575148968282102, 4 4.0516408785782314)",
"MULTILINESTRING((2 5.1322576184978592, 7 5, 8 3, 6 3, 4 0),(0 0,10 10))",
"1FF0FF102");
test_geometry<ls, mls>("LINESTRING(4 1, 4 5, 4 4)",
"MULTILINESTRING((2 5.1322576184978592, 7 5, 8 3, 6 3, 4 0),(4 0, 4 8, 0 4))",
"1FF0FF102");
test_geometry<ls, mls>("LINESTRING(1 1.0152687848942923,5 5.0575148968282102,4 4.0516408785782314)",
"MULTILINESTRING((5 0,5 5.0575148968282102,5 10),(0 0,10 10))",
"1FF0FF102");
test_geometry<ls, mls>("LINESTRING(1 1.0036662021874625,5 5,1 0)",
"MULTILINESTRING((5 0,5 5,5 10),(0 0,5 5,1 0))",
"1FF00F102");
test_geometry<ls, mls>("LINESTRING(5 5.0575148968282102,4 4.0516408785782314)",
"MULTILINESTRING((5 0,5 5.0575148968282102,5 10),(0 0,10 10))",
"1FF0FF102");
test_geometry<ls, mls>("LINESTRING(6 6.0587459045645184,5 5.0575148968282102,4 4.0516408785782314)",
"MULTILINESTRING((5 0,5 5.0575148968282102,5 10),(0 0,10 10))",
"1FF0FF102");
test_geometry<ls, mls>("LINESTRING(5 5,4 4)",
"MULTILINESTRING((5 0,5 5,5 10))",
"FF10F0102");
}
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))",
"1F1F00102");
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),(1 10,1 10,1 0,1 0,1 -10),(2 0,2 0),(3 0,3 0,3 0),(0 0,0 0,0 10,0 10),(30 0,30 0,31 0,31 0))",
"MULTILINESTRING((0 10,5 0,20 0,20 0,30 0),(1 10,1 10,1 0,1 0,1 -10),(0 0,0 0,0 10,0 10),(30 0,30 0,31 0,31 0))",
"1F100F102");
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),(0 0,0 0,0 10,0 10))",
"1F1F0F1F2");
// point-like
test_geometry<mls, mls>("MULTILINESTRING((0 0, 0 0),(1 1, 1 1))",
"MULTILINESTRING((0 0, 0 0))",
"0F0FFFFF2");
test_geometry<mls, mls>("MULTILINESTRING((0 0, 0 0),(1 1, 1 1))",
"MULTILINESTRING((0 0, 0 0),(1 1, 1 1))",
"0FFFFFFF2");
test_geometry<mls, mls>("MULTILINESTRING((0 0, 0 0),(1 1, 1 1))",
"MULTILINESTRING((2 2, 2 2),(3 3, 3 3))",
"FF0FFF0F2");
test_geometry<mls, mls>("MULTILINESTRING((0 5,10 5,10 10,5 10),(5 10,5 0,5 2),(5 2,5 5.0190018174896416,0 5))",
"MULTILINESTRING((5 5.0190018174896416,0 5),(5 5.0190018174896416,5 0),(10 10,10 5,5 5.0190018174896416,5 10,10 10))",
"10FFFFFF2");
if ( BOOST_GEOMETRY_CONDITION((
boost::is_same<typename bg::coordinate_type<P>::type, double>::value )) )
{
// assertion failure in 1.57
test_geometry<mls, mls>("MULTILINESTRING((-0.59322033898305082 -8.0508474576271194,-2.882352941176471 -7.7647058823529411,-2.8823529411764706 -7.7647058823529411,-3.7361111111111112 -6.5694444444444446,-3.4404145077720205 -5.766839378238342,-4.1864406779661012 -3.6779661016949152,-7.5252525252525251 -5.5858585858585865,-7.5862068965517242 -5.1896551724137936,-4.47887323943662 -2.859154929577465,-4.5789473684210531 -2.5789473684210527,-3 -1,-2.9310344827586206 -0.86206896551724144,-3.1764705882352944 -0.70588235294117663,-4.7401960784313726 -2.1274509803921577,-5.3255813953488369 -0.48837209302325502,-4.7872340425531918 0.31914893617021284,-5.8571428571428577 1.0000000000000007,-5.3255813953488369 -0.48837209302325502,-5.9473684210526319 -1.4210526315789465,-8 2,-7.7333333333333334 2.1939393939393939,-8.8294573643410867 2.891472868217055,-8.8556701030927822 3.061855670103093,-7.5999999999999996 3.6000000000000001,-7.7999999999999998 3.7999999999999998,-7.75 3.7916666666666665,-7.5471698113207548 3.6226415094339623,-7.3200000000000003 3.7200000000000002,-3.473684210526315 3.0789473684210527,-3.2549019607843133 3.2156862745098036,-2.9999999999999982 3.1428571428571423,-3.1733333333333325 3.2666666666666666,-2.9180327868852456 3.4262295081967209,-2.8723404255319145 3.1063829787234041,-2.1111111111111112 2.8888888888888888,-2.1428571428571428 2.8571428571428572,-1.8433734939759043 2.8072289156626509,-1.8396226415094346 2.8113207547169816,-1.6486486486486487 2.756756756756757,-1.76510067114094 2.8926174496644301,-0.53846153846153855 4.2307692307692308,1.8148148148148147 5.4074074074074074,1.588235294117647 2.2352941176470589,1.819672131147541 2.1967213114754101,2 4,2 2.1666666666666665,2.3538461538461544 2.1076923076923078,2 1.6875000000000004,2 -2,1.2173913043478262 -3.8260869565217392,1.7375886524822697 1.3758865248226959,1.5073170731707317 1.1024390243902444,1.1428571428571428 -4,-0.59322033898305082 -8.0508474576271194),(1.666666666666667 1.5999999999999988,1.5675675675675675 1.8378378378378377,1.4374999999999991 1.8750000000000002,1.0487804878048776 2.3414634146341466,0.46666666666666712 2.6060606060606055,0.086956521739131043 2.2608695652173911,1.4374999999999991 1.8750000000000002,1.666666666666667 1.5999999999999988))",
"MULTILINESTRING((-2.333333333333333 -8.6666666666666661,-4.3253012048192767 -8.168674698795181,-4.1194968553459113 -7.6100628930817606,-2.8823529411764706 -7.7647058823529411,-2.882352941176471 -7.7647058823529411,-2.263157894736842 -8.6315789473684212,-2.333333333333333 -8.6666666666666661))",
"*********");
}
}
template <typename P>
void test_all()
{
test_linestring_linestring<P>();
test_linestring_multi_linestring<P>();
test_multi_linestring_multi_linestring<P>();
}
int test_main( int , char* [] )
{
typedef bg::cs::spherical_equatorial<bg::degree> cs_t;
test_all<bg::model::point<float, 2, cs_t> >();
test_all<bg::model::point<double, 2, cs_t> >();
#if defined(HAVE_TTMATH)
test_all<bg::model::point<ttmath_big, 2, cs_t> >();
#endif
return 0;
}

View File

@@ -0,0 +1,253 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands.
// This file was modified by Oracle on 2013, 2014, 2015, 2017.
// Modifications copyright (c) 2013-2017 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)
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
#include "test_relate.hpp"
#include "../nan_cases.hpp"
//TEST
//#include <to_svg.hpp>
template <typename P>
void test_point_point()
{
test_geometry<P, P>("POINT(0 0)", "POINT(0 0)", "0FFFFFFF2");
test_geometry<P, P>("POINT(1 0)", "POINT(0 0)", "FF0FFF0F2");
}
template <typename P>
void test_point_multipoint()
{
typedef bg::model::multi_point<P> mpt;
test_geometry<P, mpt>("POINT(0 0)", "MULTIPOINT(0 0)", "0FFFFFFF2");
test_geometry<P, mpt>("POINT(1 0)", "MULTIPOINT(0 0)", "FF0FFF0F2");
test_geometry<P, mpt>("POINT(0 0)", "MULTIPOINT(0 0, 1 0)", "0FFFFF0F2");
}
template <typename P>
void test_multipoint_multipoint()
{
typedef bg::model::multi_point<P> mpt;
test_geometry<mpt, mpt>("MULTIPOINT(0 0)", "MULTIPOINT(0 0)", "0FFFFFFF2");
test_geometry<mpt, mpt>("MULTIPOINT(1 0)", "MULTIPOINT(0 0)", "FF0FFF0F2");
test_geometry<mpt, mpt>("MULTIPOINT(0 0)", "MULTIPOINT(0 0, 1 0)", "0FFFFF0F2");
test_geometry<mpt, mpt>("MULTIPOINT(0 0, 1 0)", "MULTIPOINT(0 0)", "0F0FFFFF2");
test_geometry<mpt, mpt>("MULTIPOINT(0 0, 1 1)", "MULTIPOINT(0 0, 1 0)", "0F0FFF0F2");
//typedef bg::model::d2::point_xy<float> ptf;
//typedef bg::model::multi_point<ptf> mptf;
//test_geometry<mptf, mpt>("MULTIPOINT(0 0)", "MULTIPOINT(0 0)", "0FFFFFFF2");
// assertion failure in relate->boundary_checker->std::equal_range with msvc
if (BOOST_GEOMETRY_CONDITION(is_nan_case_supported<mpt>::value))
{
mpt g;
std::string wkt;
nan_case(g, wkt);
check_geometry(g, g, wkt, wkt, "*********");
}
}
template <typename P>
void test_point_linestring()
{
typedef bg::model::linestring<P> ls;
// degenerated
//test_geometry<P, ls>("POINT(0 0)", "LINESTRING(0 0)", "0FFFFFFF2");
test_geometry<P, ls>("POINT(0 0)", "LINESTRING(0 0, 2 2, 3 2)", "F0FFFF102");
test_geometry<P, ls>("POINT(1 1)", "LINESTRING(0 0, 2 2, 3 2)", "0FFFFF102");
test_geometry<P, ls>("POINT(3 2)", "LINESTRING(0 0, 2 2, 3 2)", "F0FFFF102");
test_geometry<P, ls>("POINT(1 0)", "LINESTRING(0 0, 2 2, 3 2)", "FF0FFF102");
test_geometry<P, ls>("POINT(0 0)", "LINESTRING(0 0, 2 2, 3 2, 0 0)", "0FFFFF1F2");
test_geometry<P, ls>("POINT(1 1)", "LINESTRING(0 0, 2 2, 3 2, 0 0)", "0FFFFF1F2");
test_geometry<P, ls>("POINT(3 2)", "LINESTRING(0 0, 2 2, 3 2, 0 0)", "0FFFFF1F2");
test_geometry<P, ls>("POINT(1 0)", "LINESTRING(0 0, 2 2, 3 2, 0 0)", "FF0FFF1F2");
}
template <typename P>
void test_point_multilinestring()
{
typedef bg::model::linestring<P> ls;
typedef bg::model::multi_linestring<ls> mls;
test_geometry<P, mls>("POINT(0 0)", "MULTILINESTRING((0 0, 2 0, 2 2),(0 0, 0 2))", "0FFFFF102");
test_geometry<P, mls>("POINT(0 0)", "MULTILINESTRING((0 0, 2 0, 2 2),(0 0, 0 2, 2 2))", "0FFFFF1F2");
test_geometry<P, mls>("POINT(0 0)", "MULTILINESTRING((0 0, 2 0, 2 2),(0 0, 0 2, 2 2),(0 0, 1 1))", "F0FFFF102");
test_geometry<P, mls>("POINT(0 0)", "MULTILINESTRING((0 0,5 0),(0 0,0 5,5 0),(0 0,-5 0),(0 0,0 -5,-5 0))", "0FFFFF1F2");
test_geometry<P, mls>("POINT(5 0)", "MULTILINESTRING((0 0,5 0),(0 0,0 5,5 0),(0 0,-5 0),(0 0,0 -5,-5 0))", "0FFFFF1F2");
test_geometry<P, mls>("POINT(1 0)", "MULTILINESTRING((0 0,5 0),(0 0,0 5,5 0),(0 0,-5 0),(0 0,0 -5,-5 0))", "0FFFFF1F2");
// assertion failure in relate->boundary_checker->std::equal_range with msvc
if (BOOST_GEOMETRY_CONDITION(is_nan_case_supported<mls>::value))
{
// on the boundary
std::string wkt0 = "POINT(3.1e+307 1)";
P g0;
bg::read_wkt(wkt0, g0);
// disjoint
std::string wkt1 = "POINT(1.1e+308 1.2e+308)";
P g1;
bg::read_wkt(wkt1, g1);
mls g2;
std::string wkt2;
nan_case(g2, wkt2);
check_geometry(g0, g2, wkt0, wkt2, "*********");
check_geometry(g1, g2, wkt1, wkt2, "*********");
}
}
template <typename P>
void test_multipoint_linestring()
{
typedef bg::model::multi_point<P> mpt;
typedef bg::model::linestring<P> ls;
// degenerated
//test_geometry<mpt, ls>("MULTIPOINT(0 0)", "LINESTRING(0 0)", "0FFFFFFF2");
test_geometry<mpt, ls>("MULTIPOINT(0 0)", "LINESTRING(0 0, 2 2, 3 2)", "F0FFFF102");
test_geometry<mpt, ls>("MULTIPOINT(0 0, 1 1)", "LINESTRING(0 0, 2 2, 3 2)", "00FFFF102");
test_geometry<mpt, ls>("MULTIPOINT(0 0, 1 1, 3 3)", "LINESTRING(0 0, 2 2, 3 2)", "000FFF102");
test_geometry<mpt, ls>("MULTIPOINT(0 0, 3 3)", "LINESTRING(0 0, 2 2, 3 2)", "F00FFF102");
test_geometry<mpt, ls>("MULTIPOINT(1 1, 3 3)", "LINESTRING(0 0, 2 2, 3 2)", "0F0FFF102");
test_geometry<mpt, ls>("MULTIPOINT(0 0, 1 1)", "LINESTRING(0 0, 2 2, 3 2, 0 0)", "0FFFFF1F2");
test_geometry<mpt, ls>("MULTIPOINT(0 0, 3 3)", "LINESTRING(0 0, 2 2, 3 2, 0 0)", "0F0FFF1F2");
test_geometry<mpt, ls>("MULTIPOINT(0 0)", "LINESTRING(0 0, 2 2)", "F0FFFF102");
test_geometry<mpt, ls>("MULTIPOINT(2 2)", "LINESTRING(0 0, 2 2)", "F0FFFF102");
test_geometry<mpt, ls>("MULTIPOINT(0 0, 2 2)", "LINESTRING(0 0, 2 2)", "F0FFFF1F2");
test_geometry<mpt, ls>("MULTIPOINT(0 0, 1 1, 0 1, 2 2)", "LINESTRING(0 0, 2 2)", "000FFF1F2");
}
template <typename P>
void test_multipoint_multilinestring()
{
typedef bg::model::multi_point<P> mpt;
typedef bg::model::linestring<P> ls;
typedef bg::model::multi_linestring<ls> mls;
test_geometry<mpt, mls>("MULTIPOINT(0 0)", "MULTILINESTRING((0 0, 2 2),(2 2, 3 2))", "F0FFFF102");
test_geometry<mpt, mls>("MULTIPOINT(0 0, 1 1)", "MULTILINESTRING((0 0, 2 2),(2 2, 3 2))", "00FFFF102");
test_geometry<mpt, mls>("MULTIPOINT(0 0, 1 1, 3 3)", "MULTILINESTRING((0 0, 2 2),(2 2, 3 2))", "000FFF102");
test_geometry<mpt, mls>("MULTIPOINT(0 0, 3 3)", "MULTILINESTRING((0 0, 2 2),(2 2, 3 2))", "F00FFF102");
test_geometry<mpt, mls>("MULTIPOINT(1 1, 3 3)", "MULTILINESTRING((0 0, 2 2),(2 2, 3 2))", "0F0FFF102");
test_geometry<mpt, mls>("MULTIPOINT(0 0, 1 1)", "MULTILINESTRING((0 0, 2 2),(2 2, 3 2, 0 0))", "0FFFFF1F2");
test_geometry<mpt, mls>("MULTIPOINT(0 0, 3 3)", "MULTILINESTRING((0 0, 2 2),(2 2, 3 2, 0 0))", "0F0FFF1F2");
test_geometry<mpt, mls>("MULTIPOINT(0 0,1 1)", "MULTILINESTRING((0 0,0 1,1 1),(1 1,1 0,0 0))", "0FFFFF1F2");
test_geometry<mpt, mls>("MULTIPOINT(0 0)", "MULTILINESTRING((0 0,1 1),(1 1,2 2))", "F0FFFF102");
test_geometry<mpt, mls>("MULTIPOINT(0 0, 1 1)", "MULTILINESTRING((0 0,1 1),(1 1,2 2))", "00FFFF102");
test_geometry<mpt, mls>("MULTIPOINT(0 0, 1 1, 2 2)", "MULTILINESTRING((0 0,1 1),(1 1,2 2))", "00FFFF1F2");
test_geometry<mpt, mls>("MULTIPOINT(0 0, 2 2)", "MULTILINESTRING((0 0,1 1),(1 1,2 2))", "F0FFFF1F2");
}
template <typename P>
void test_point_ring_polygon()
{
typedef bg::model::ring<P> ring;
typedef bg::model::polygon<P> poly;
test_geometry<P, ring>("POINT(0 0)", "POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))", "F0FFFF212");
test_geometry<P, poly>("POINT(1 1)", "POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))", "0FFFFF212");
test_geometry<P, poly>("POINT(1 3)", "POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))", "FF0FFF212");
}
template <typename P>
void test_point_multipolygon()
{
typedef bg::model::polygon<P> poly;
typedef bg::model::multi_polygon<poly> mpoly;
test_geometry<P, mpoly>("POINT(0 0)", "MULTIPOLYGON(((0 0, 0 5, 5 5, 5 0, 0 0)),((5 5, 5 9, 9 9, 9 5, 5 5)))", "F0FFFF212");
test_geometry<P, mpoly>("POINT(1 1)", "MULTIPOLYGON(((0 0, 0 5, 5 5, 5 0, 0 0)),((5 5, 5 9, 9 9, 9 5, 5 5)))", "0FFFFF212");
test_geometry<P, mpoly>("POINT(5 5)", "MULTIPOLYGON(((0 0, 0 5, 5 5, 5 0, 0 0)),((5 5, 5 9, 9 9, 9 5, 5 5)))", "F0FFFF212");
test_geometry<P, mpoly>("POINT(6 6)", "MULTIPOLYGON(((0 0, 0 5, 5 5, 5 0, 0 0)),((5 5, 5 9, 9 9, 9 5, 5 5)))", "0FFFFF212");
test_geometry<P, mpoly>("POINT(1 6)", "MULTIPOLYGON(((0 0, 0 5, 5 5, 5 0, 0 0)),((5 5, 5 9, 9 9, 9 5, 5 5)))", "FF0FFF212");
}
template <typename P>
void test_multipoint_ring_polygon()
{
typedef bg::model::multi_point<P> mpt;
typedef bg::model::ring<P> ring;
typedef bg::model::polygon<P> poly;
test_geometry<mpt, ring>("MULTIPOINT(0 0)", "POLYGON((0 0, 0 3, 3 3, 3 0, 0 0))", "F0FFFF212");
test_geometry<mpt, ring>("MULTIPOINT(0 0, 1 1)", "POLYGON((0 0, 0 3, 3 3, 3 0, 0 0))", "00FFFF212");
test_geometry<mpt, ring>("MULTIPOINT(0 0, 1 1, 4 4)", "POLYGON((0 0, 0 3, 3 3, 3 0, 0 0))", "000FFF212");
test_geometry<mpt, ring>("MULTIPOINT(1 1, 4 4)", "POLYGON((0 0, 0 3, 3 3, 3 0, 0 0))", "0F0FFF212");
test_geometry<mpt, poly>("MULTIPOINT(2 2)", "POLYGON((0 0, 0 4, 4 4, 4 0, 0 0),(1 1, 3 1, 3 3, 1 3, 1 1))", "FF0FFF212");
test_geometry<mpt, poly>("MULTIPOINT(0 0, 1 1)", "POLYGON((0 0, 0 4, 4 4, 4 0, 0 0),(1 1, 3 1, 3 3, 1 3, 1 1))", "F0FFFF212");
test_geometry<mpt, poly>("MULTIPOINT(0 0, 1 1, 2 2)", "POLYGON((0 0, 0 4, 4 4, 4 0, 0 0),(1 1, 3 1, 3 3, 1 3, 1 1))", "F00FFF212");
test_geometry<mpt, poly>("MULTIPOINT(2 2, 4 4)", "POLYGON((0 0, 0 5, 5 5, 5 0, 0 0),(1 1, 3 1, 3 3, 1 3, 1 1))", "0F0FFF212");
}
template <typename P>
void test_multipoint_multipolygon()
{
typedef bg::model::multi_point<P> mpt;
typedef bg::model::polygon<P> poly;
typedef bg::model::multi_polygon<poly> mpoly;
test_geometry<mpt, mpoly>("MULTIPOINT(0 0)", "MULTIPOLYGON(((0 0, 0 5, 5 5, 5 0, 0 0)),((5 5, 5 9, 9 9, 9 5, 5 5)))", "F0FFFF212");
test_geometry<mpt, mpoly>("MULTIPOINT(0 0, 1 1)", "MULTIPOLYGON(((0 0, 0 5, 5 5, 5 0, 0 0)),((5 5, 5 9, 9 9, 9 5, 5 5)))", "00FFFF212");
test_geometry<mpt, mpoly>("MULTIPOINT(1 1, 5 5)", "MULTIPOLYGON(((0 0, 0 5, 5 5, 5 0, 0 0)),((5 5, 5 9, 9 9, 9 5, 5 5)))", "00FFFF212");
test_geometry<mpt, mpoly>("MULTIPOINT(1 6, 6 6)", "MULTIPOLYGON(((0 0, 0 5, 5 5, 5 0, 0 0)),((5 5, 5 9, 9 9, 9 5, 5 5)))", "0F0FFF212");
test_geometry<mpt, mpoly>("MULTIPOINT(0 0, 1 6)", "MULTIPOLYGON(((0 0, 0 5, 5 5, 5 0, 0 0)),((5 5, 5 9, 9 9, 9 5, 5 5)))", "F00FFF212");
}
template <typename P>
void test_all()
{
test_point_point<P>();
test_point_multipoint<P>();
test_multipoint_multipoint<P>();
test_point_linestring<P>();
test_point_multilinestring<P>();
test_multipoint_linestring<P>();
test_multipoint_multilinestring<P>();
test_point_ring_polygon<P>();
test_point_multipolygon<P>();
test_multipoint_ring_polygon<P>();
test_multipoint_multipolygon<P>();
}
int test_main( int , char* [] )
{
check_mask();
test_all<bg::model::d2::point_xy<int> >();
test_all<bg::model::d2::point_xy<double> >();
#if defined(HAVE_TTMATH)
test_all<bg::model::d2::point_xy<ttmath_big> >();
#endif
return 0;
}

View File

@@ -0,0 +1,232 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
// This file was modified by Oracle on 2013, 2014, 2015, 2017.
// Modifications copyright (c) 2013-2017 Oracle and/or its affiliates.
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
// Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_GEOMETRY_TEST_RELATE_HPP
#define BOOST_GEOMETRY_TEST_RELATE_HPP
#include <geometry_test_common.hpp>
#include <boost/variant.hpp>
#include <boost/geometry/core/ring_type.hpp>
#include <boost/geometry/algorithms/relate.hpp>
#include <boost/geometry/algorithms/relation.hpp>
#include <boost/geometry/strategies/strategies.hpp>
#include <boost/geometry/geometries/geometries.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/io/wkt/read.hpp>
#include <boost/geometry/strategies/cartesian/point_in_box.hpp>
#include <boost/geometry/strategies/cartesian/box_in_box.hpp>
#include <boost/geometry/strategies/agnostic/point_in_box_by_side.hpp>
namespace bgdr = bg::detail::relate;
std::string transposed(std::string matrix)
{
if ( !matrix.empty() )
{
std::swap(matrix[1], matrix[3]);
std::swap(matrix[2], matrix[6]);
std::swap(matrix[5], matrix[7]);
}
return matrix;
}
bool matrix_compare(std::string const& m1, std::string const& m2)
{
BOOST_ASSERT(m1.size() == 9 && m2.size() == 9);
for ( size_t i = 0 ; i < 9 ; ++i )
{
if ( m1[i] == '*' || m2[i] == '*' )
continue;
if ( m1[i] != m2[i] )
return false;
}
return true;
}
bool matrix_compare(std::string const& m, std::string const& res1, std::string const& res2)
{
return matrix_compare(m, res1)
|| ( !res2.empty() ? matrix_compare(m, res2) : false );
}
std::string matrix_format(std::string const& matrix1, std::string const& matrix2)
{
return matrix1
+ ( !matrix2.empty() ? " || " : "" ) + matrix2;
}
template <typename M>
char get_ii(M const& m)
{
using bg::detail::relate::interior;
return m.template get<interior, interior>();
}
template <typename M>
char get_ee(M const& m)
{
using bg::detail::relate::exterior;
return m.template get<exterior, exterior>();
}
void check_mask()
{
bg::de9im::mask m1("");
bg::de9im::mask m2("TTT");
bg::de9im::mask m3("000111222");
bg::de9im::mask m4("000111222FFFF");
bg::de9im::mask m5(std::string(""));
bg::de9im::mask m6(std::string("TTT"));
bg::de9im::mask m7(std::string("000111222"));
bg::de9im::mask m8(std::string("000111222FFFF"));
using bg::detail::relate::interior;
using bg::detail::relate::exterior;
BOOST_CHECK(get_ii(m1) == '*' && get_ee(m1) == '*');
BOOST_CHECK(get_ii(m2) == 'T' && get_ee(m2) == '*');
BOOST_CHECK(get_ii(m3) == '0' && get_ee(m3) == '2');
BOOST_CHECK(get_ii(m4) == '0' && get_ee(m4) == '2');
BOOST_CHECK(get_ii(m5) == '*' && get_ee(m5) == '*');
BOOST_CHECK(get_ii(m6) == 'T' && get_ee(m6) == '*');
BOOST_CHECK(get_ii(m7) == '0' && get_ee(m7) == '2');
BOOST_CHECK(get_ii(m8) == '0' && get_ee(m8) == '2');
}
template <typename Geometry1, typename Geometry2>
void check_geometry(Geometry1 const& geometry1,
Geometry2 const& geometry2,
std::string const& wkt1,
std::string const& wkt2,
std::string const& expected1,
std::string const& expected2 = std::string())
{
boost::variant<Geometry1> variant1 = geometry1;
boost::variant<Geometry2> variant2 = geometry2;
{
std::string res_str = bg::relation(geometry1, geometry2).str();
bool ok = matrix_compare(res_str, expected1, expected2);
BOOST_CHECK_MESSAGE(ok,
"relate: " << wkt1
<< " and " << wkt2
<< " -> Expected: " << matrix_format(expected1, expected2)
<< " detected: " << res_str);
typedef typename bg::strategy::relate::services::default_strategy
<
Geometry1, Geometry2
>::type strategy_type;
std::string res_str0 = bg::relation(geometry1, geometry2, strategy_type()).str();
BOOST_CHECK(res_str == res_str0);
// test variants
boost::variant<Geometry1> v1 = geometry1;
boost::variant<Geometry2> v2 = geometry2;
std::string res_str1 = bg::relation(geometry1, variant2).str();
std::string res_str2 = bg::relation(variant1, geometry2).str();
std::string res_str3 = bg::relation(variant1, variant2).str();
BOOST_CHECK(res_str == res_str1);
BOOST_CHECK(res_str == res_str2);
BOOST_CHECK(res_str == res_str3);
}
// changed sequence of geometries - transposed result
{
std::string res_str = bg::relation(geometry2, geometry1).str();
std::string expected1_tr = transposed(expected1);
std::string expected2_tr = transposed(expected2);
bool ok = matrix_compare(res_str, expected1_tr, expected2_tr);
BOOST_CHECK_MESSAGE(ok,
"relate: " << wkt2
<< " and " << wkt1
<< " -> Expected: " << matrix_format(expected1_tr, expected2_tr)
<< " detected: " << res_str);
}
if ( expected2.empty() )
{
{
bool result = bg::relate(geometry1, geometry2, bg::de9im::mask(expected1));
// TODO: SHOULD BE !interrupted - CHECK THIS!
BOOST_CHECK_MESSAGE(result,
"relate: " << wkt1
<< " and " << wkt2
<< " -> Expected: " << expected1);
typedef typename bg::strategy::relate::services::default_strategy
<
Geometry1, Geometry2
>::type strategy_type;
bool result0 = bg::relate(geometry1, geometry2, bg::de9im::mask(expected1), strategy_type());
BOOST_CHECK(result == result0);
// test variants
bool result1 = bg::relate(geometry1, variant2, bg::de9im::mask(expected1));
bool result2 = bg::relate(variant1, geometry2, bg::de9im::mask(expected1));
bool result3 = bg::relate(variant1, variant2, bg::de9im::mask(expected1));
BOOST_CHECK(result == result1);
BOOST_CHECK(result == result2);
BOOST_CHECK(result == result3);
}
if ( BOOST_GEOMETRY_CONDITION((
bg::detail::relate::interruption_enabled<Geometry1, Geometry2>::value )) )
{
// brake the expected output
std::string expected_interrupt = expected1;
bool changed = false;
BOOST_FOREACH(char & c, expected_interrupt)
{
if ( c >= '0' && c <= '9' )
{
if ( c == '0' )
c = 'F';
else
--c;
changed = true;
}
}
if ( changed )
{
bool result = bg::relate(geometry1, geometry2, bg::de9im::mask(expected_interrupt));
// TODO: SHOULD BE interrupted - CHECK THIS!
BOOST_CHECK_MESSAGE(!result,
"relate: " << wkt1
<< " and " << wkt2
<< " -> Expected interrupt for:" << expected_interrupt);
}
}
}
}
template <typename Geometry1, typename Geometry2>
void test_geometry(std::string const& wkt1,
std::string const& wkt2,
std::string const& expected1,
std::string const& expected2 = std::string())
{
Geometry1 geometry1;
Geometry2 geometry2;
bg::read_wkt(wkt1, geometry1);
bg::read_wkt(wkt2, geometry2);
check_geometry(geometry1, geometry2, wkt1, wkt2, expected1, expected2);
}
#endif // BOOST_GEOMETRY_TEST_RELATE_HPP

View 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, 2016.
# Modifications copyright (c) 2014-2016, 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-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 ]
[ run touches_sph.cpp : : : : algorithms_touches_sph ]
;

View File

@@ -0,0 +1,142 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// Unit Test
// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands.
// This file was modified by Oracle on 2013, 2015, 2016, 2017.
// Modifications copyright (c) 2013-2017 Oracle and/or its affiliates.
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
// Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_GEOMETRY_TEST_TOUCHES_HPP
#define BOOST_GEOMETRY_TEST_TOUCHES_HPP
#include <geometry_test_common.hpp>
#include <boost/geometry/core/ring_type.hpp>
#include <boost/geometry/algorithms/touches.hpp>
#include <boost/geometry/strategies/strategies.hpp>
#include <boost/geometry/geometries/geometries.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/io/wkt/read.hpp>
#include <boost/variant/variant.hpp>
struct no_strategy {};
template <typename Geometry1, typename Geometry2, typename Strategy>
void check_touches(Geometry1 const& geometry1,
Geometry2 const& geometry2,
std::string const& wkt1,
std::string const& wkt2,
bool expected,
Strategy const& strategy)
{
bool detected = bg::touches(geometry1, geometry2, strategy);
BOOST_CHECK_MESSAGE(detected == expected,
"touches: " << wkt1
<< " with " << wkt2
<< " -> Expected: " << expected
<< " detected: " << detected);
detected = bg::touches(geometry2, geometry1, strategy);
BOOST_CHECK_MESSAGE(detected == expected,
"touches: " << wkt2
<< " with " << wkt1
<< " -> Expected: " << expected
<< " detected: " << detected);
}
template <typename Geometry1, typename Geometry2>
void check_touches(Geometry1 const& geometry1,
Geometry2 const& geometry2,
std::string const& wkt1,
std::string const& wkt2,
bool expected,
no_strategy = no_strategy())
{
bool detected = bg::touches(geometry1, geometry2);
BOOST_CHECK_MESSAGE(detected == expected,
"touches: " << wkt1
<< " with " << wkt2
<< " -> Expected: " << expected
<< " detected: " << detected);
detected = bg::touches(geometry2, geometry1);
BOOST_CHECK_MESSAGE(detected == expected,
"touches: " << wkt2
<< " with " << wkt1
<< " -> Expected: " << expected
<< " detected: " << detected);
}
template <typename Geometry1, typename Geometry2>
void test_touches(std::string const& wkt1,
std::string const& wkt2, bool expected)
{
Geometry1 geometry1;
Geometry2 geometry2;
bg::read_wkt(wkt1, geometry1);
bg::read_wkt(wkt2, geometry2);
boost::variant<Geometry1> v1(geometry1);
boost::variant<Geometry2> v2(geometry2);
typedef typename bg::strategy::relate::services::default_strategy
<
Geometry1, Geometry2
>::type strategy_type;
check_touches(geometry1, geometry2, wkt1, wkt2, expected, no_strategy());
check_touches(geometry1, geometry2, wkt1, wkt2, expected, strategy_type());
check_touches(v1, geometry2, wkt1, wkt2, expected, no_strategy());
check_touches(geometry1, v2, wkt1, wkt2, expected, no_strategy());
check_touches(v1, v2, wkt1, wkt2, expected, no_strategy());
}
template <typename Geometry1, typename Geometry2>
void test_geometry(std::string const& wkt1,
std::string const& wkt2,
bool expected)
{
test_touches<Geometry1, Geometry2>(wkt1, wkt2, expected);
}
template <typename Geometry>
void check_self_touches(Geometry const& geometry,
std::string const& wkt,
bool expected)
{
bool detected = bg::touches(geometry);
BOOST_CHECK_MESSAGE(detected == expected,
"touches: " << wkt
<< " -> Expected: " << expected
<< " detected: " << detected);
}
template <typename Geometry>
void test_self_touches(std::string const& wkt, bool expected)
{
Geometry geometry;
bg::read_wkt(wkt, geometry);
boost::variant<Geometry> v(geometry);
check_self_touches(geometry, wkt, expected);
check_self_touches(v, wkt, expected);
}
#endif

View File

@@ -0,0 +1,226 @@
// 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::multi_point<P> mpoint;
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;
// Touching at corner
test_touches<polygon, polygon>
(
"POLYGON((0 0,0 100,100 100,100 0,0 0))",
"POLYGON((100 100,100 200,200 200, 200 100,100 100))",
true
);
// Intersecting at corner
test_touches<polygon, polygon>
(
"POLYGON((0 0,0 100,101 101,100 0,0 0))",
"POLYGON((100 100,100 200,200 200, 200 100,100 100))",
false
);
// Touching at side (interior of a segment)
test_touches<polygon, polygon>
(
"POLYGON((0 0,0 100,100 100,100 0,0 0))",
"POLYGON((200 0,100 50,200 100,200 0))",
true
);
// Touching at side (partly collinear)
test_touches<polygon, polygon>
(
"POLYGON((0 0,0 100,100 100,100 0,0 0))",
"POLYGON((200 20,100 20,100 80,200 80,200 20))",
true
);
// Completely equal
test_touches<polygon, polygon>
(
"POLYGON((0 0,0 100,100 100,100 0,0 0))",
"POLYGON((0 0,0 100,100 100,100 0,0 0))",
false
);
// Spatially equal
test_touches<polygon, polygon>
(
"POLYGON((0 0,0 100,100 100,100 0,0 0))",
"POLYGON((0 0,0 100,100 100,100 80,100 20,100 0,0 0))",
false
);
// Spatially equal (without equal segments)
test_touches<polygon, polygon>
(
"POLYGON((0 0,0 100,100 100,100 0,0 0))",
"POLYGON((0 0,0 50,0 100,50 100,100 100,100 50,100 0,50 0,0 0))",
false
);
// Touching at side (opposite equal)
test_touches<polygon, polygon>
(
"POLYGON((0 0,0 100,100 100,100 0,0 0))",
"POLYGON((200 0,100 0,100 100,200 100,200 0))",
true
);
// Touching at side (opposite equal - but with real "equal" turning point)
test_touches<polygon, polygon>
(
"POLYGON((0 0,0 100,100 100,100 80,100 20,100 0,0 0))",
"POLYGON((200 0,100 0,100 20,100 80,100 100,200 100,200 0))",
true
);
// First partly collinear to side, than overlapping
test_touches<polygon, polygon>
(
"POLYGON((0 0,0 100,100 100,100 0,0 0))",
"POLYGON((200 20,100 20,100 50,50 50,50 80,100 80,200 80,200 20))",
false
);
// Touching interior (= no touch)
test_touches<polygon, polygon>
(
"POLYGON((0 0,0 100,100 100,100 0,0 0))",
"POLYGON((20 20,20 80,100 50,20 20))",
false
);
// Fitting in hole
test_touches<polygon, polygon>
(
"POLYGON((0 0,0 100,100 100,100 0,0 0),(40 40,60 40,60 60,40 60,40 40))",
"POLYGON((40 40,40 60,60 60,60 40,40 40))",
true
);
// mysql 21873343
test_touches<polygon, polygon>
(
"POLYGON((0 0,0 10,10 10,10 0,0 0), (0 8, 8 5, 8 8, 0 8))",
"POLYGON((0 8,-8 5,-8 8,0 8))",
true
);
test_touches<polygon, polygon>
(
"POLYGON((0 0,0 10,10 10,10 0,0 0), (0 6, 6 3, 6 6, 0 6))",
"POLYGON((0 6,-6 3,-6 6,0 6))",
true
);
// Point-Polygon
test_touches<P, ring>("POINT(40 50)", "POLYGON((40 40,40 60,60 60,60 40,40 40))", true);
test_touches<P, polygon>("POINT(40 50)", "POLYGON((40 40,40 60,60 60,60 40,40 40))", true);
test_touches<P, polygon>("POINT(60 60)", "POLYGON((40 40,40 60,60 60,60 40,40 40))", true);
test_touches<P, polygon>("POINT(50 50)", "POLYGON((40 40,40 60,60 60,60 40,40 40))", false);
test_touches<P, polygon>("POINT(30 50)", "POLYGON((40 40,40 60,60 60,60 40,40 40))", false);
// Point-MultiPolygon
test_touches<P, mpolygon>("POINT(40 50)", "MULTIPOLYGON(((40 40,40 60,60 60,60 40,40 40)),((0 0,0 10,10 10,10 0)))", true);
// Point-Linestring
test_touches<P, linestring>("POINT(0 0)", "LINESTRING(0 0, 2 2, 10 2)", true);
test_touches<P, linestring>("POINT(2 2)", "LINESTRING(0 0, 2 2, 10 2)", false);
test_touches<P, linestring>("POINT(1 1)", "LINESTRING(0 0, 2 2, 10 2)", false);
test_touches<P, linestring>("POINT(5 5)", "LINESTRING(0 0, 2 2, 10 2)", false);
// Point-MultiLinestring
test_touches<P, mlinestring>("POINT(0 0)", "MULTILINESTRING((0 0, 2 2, 10 2),(5 5, 6 6))", true);
test_touches<P, mlinestring>("POINT(0 0)", "MULTILINESTRING((0 0, 2 2, 10 2),(0 0, 6 6))", false);
// MultiPoint-Polygon
test_touches<mpoint, ring>("MULTIPOINT(40 50, 30 50)", "POLYGON((40 40,40 60,60 60,60 40,40 40))", true);
test_touches<mpoint, polygon>("MULTIPOINT(40 50, 50 50)", "POLYGON((40 40,40 60,60 60,60 40,40 40))", false);
// Linestring-Linestring
test_touches<linestring, linestring>("LINESTRING(0 0,2 0)", "LINESTRING(0 0,0 2)", true);
test_touches<linestring, linestring>("LINESTRING(0 0,2 0)", "LINESTRING(2 0,2 2)", true);
test_touches<linestring, linestring>("LINESTRING(0 0,2 0)", "LINESTRING(0 2,0 0)", true);
test_touches<linestring, linestring>("LINESTRING(0 0,2 0)", "LINESTRING(2 2,2 0)", true);
test_touches<linestring, linestring>("LINESTRING(2 0,0 0)", "LINESTRING(0 0,0 2)", true);
test_touches<linestring, linestring>("LINESTRING(2 0,0 0)", "LINESTRING(2 0,2 2)", true);
test_touches<linestring, linestring>("LINESTRING(2 0,0 0)", "LINESTRING(0 2,0 0)", true);
test_touches<linestring, linestring>("LINESTRING(2 0,0 0)", "LINESTRING(2 2,2 0)", true);
test_touches<linestring, linestring>("LINESTRING(0 0,2 0)", "LINESTRING(1 0,1 1)", true);
test_touches<linestring, linestring>("LINESTRING(0 0,2 0)", "LINESTRING(1 1,1 0)", true);
test_touches<linestring, linestring>("LINESTRING(2 0,0 0)", "LINESTRING(1 0,1 1)", true);
test_touches<linestring, linestring>("LINESTRING(2 0,0 0)", "LINESTRING(1 1,1 0)", true);
test_touches<linestring, linestring>("LINESTRING(0 0,10 0)", "LINESTRING(0 0,5 5,10 0)", true);
test_touches<linestring, linestring>("LINESTRING(0 0,10 10)", "LINESTRING(0 0,0 5,10 5)", false);
test_touches<linestring, linestring>("LINESTRING(0 5,5 6,10 5)", "LINESTRING(0 7,5 6,10 7)", false);
test_touches<linestring, linestring>("LINESTRING(0 5,5 6,10 5)", "LINESTRING(10 7,5 6,0 7)", false);
test_touches<linestring, linestring>("LINESTRING(10 5,5 6,0 5)", "LINESTRING(0 7,5 6,10 7)", false);
test_touches<linestring, linestring>("LINESTRING(10 5,5 6,0 5)", "LINESTRING(10 7,5 6,0 7)", false);
test_touches<linestring, linestring>("LINESTRING(0 0,1 1,2 2)", "LINESTRING(2 0,2 2,1 2,1 1)", true);
test_touches<linestring, linestring>("LINESTRING(2 2,1 1,0 0)", "LINESTRING(2 0,2 2,1 2,1 1)", true);
test_touches<linestring, linestring>("LINESTRING(0 0,1 1,2 2)", "LINESTRING(1 1,1 2,2 2,2 0)", true);
test_touches<linestring, linestring>("LINESTRING(2 2,1 1,0 0)", "LINESTRING(1 1,1 2,2 2,2 0)", true);
test_touches<linestring, linestring>("LINESTRING(0 0,1 1,0 1)", "LINESTRING(1 1,2 2,1 2,1 1)", false);
test_touches<linestring, mlinestring>("LINESTRING(0 0,1 1,0 1)", "MULTILINESTRING((1 1,2 2),(1 2,1 1))", false);
//Linestring-Polygon
test_touches<linestring, polygon>("LINESTRING(10 0,15 5,10 10,5 15,5 10,0 10,5 15,5 10)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", true);
test_touches<linestring, polygon>("LINESTRING(5 10,5 15,0 10,5 10,5 15,10 10,15 5,10 0)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", true);
test_touches<linestring, polygon>("LINESTRING(5 10,5 15,0 10,5 10,5 15,10 10,5 5,10 0)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", false);
test_touches<linestring, ring>("LINESTRING(0 15,5 5)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", false);
test_touches<linestring, polygon>("LINESTRING(0 15,5 5)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", false);
test_touches<linestring, polygon>("LINESTRING(0 15,5 10,5 5)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", false);
test_touches<linestring, polygon>("LINESTRING(10 15,5 10,0 5)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", false);
test_touches<linestring, polygon>("LINESTRING(0 0,3 3)", "POLYGON((0 0,0 10,10 10,10 0,0 0),(0 0,9 1,9 9,1 9,0 0))", true);
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);
}
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;
}
/*
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
*/

View File

@@ -0,0 +1,66 @@
// 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
*/

View File

@@ -0,0 +1,80 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
//
// Copyright (c) 2010-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_touches.hpp"
#include <boost/geometry/algorithms/area.hpp>
#include <boost/geometry/algorithms/num_geometries.hpp>
#include <boost/geometry/algorithms/within.hpp>
template <typename P>
void test_all()
{
typedef bg::model::polygon<P> polygon;
typedef bg::model::multi_polygon<polygon> mp;
typedef bg::model::linestring<P> linestring;
typedef bg::model::multi_linestring<linestring> ml;
test_self_touches<mp>("MULTIPOLYGON(((0 0,0 100,100 100,100 0,0 0)))",
false);
// Exactly equal
test_touches<mp, mp>("MULTIPOLYGON(((0 0,0 100,100 100,100 0,0 0)))",
"MULTIPOLYGON(((0 0,0 100,100 100,100 0,0 0)))",
false);
// Spatially equal
test_touches<mp, mp>("MULTIPOLYGON(((0 0,0 100,100 100,100 0,0 0)))",
"MULTIPOLYGON(((0 0,0 100,100 100,100 80,100 20,100 0,0 0)))",
false);
// One exactly equal, another pair touching
test_touches<mp, mp>("MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)),((20 0,20 10,30 10,30 0,20 0)))",
"MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)),((30 10,30 20,40 20,40 10,30 10)))",
false);
// One spatially equal (without equal segments), another pair touching
test_touches<mp, mp>("MULTIPOLYGON(((0 0,0 5,0 10,5 10,10 10,10 5,10 0,5 0,0 0)),((20 0,20 10,30 10,30 0,20 0)))",
"MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)),((30 10,30 20,40 20,40 10,30 10)))",
false);
// Alternate touches
test_touches<mp, mp>("MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)),((20 0,20 10,30 10,30 0,20 0)))",
"MULTIPOLYGON(((10 10,10 20,20 20,20 10,10 10)),((30 10,30 20,40 20,40 10,30 10)))",
true);
// Touch plus inside
test_touches<mp, mp>("MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)),((20 0,20 10,30 10,30 0,20 0)))",
"MULTIPOLYGON(((10 10,10 20,20 20,20 10,10 10)),((22 2,28 2,28 8,22 8,22 2)))",
false);
test_touches<mp, ml>("MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)),((20 0,20 10,30 10,30 0,20 0)))",
"MULTILINESTRING((10 10,10 20,20 20,20 10,10 10),(30 10,30 20,40 20,40 10,30 10))",
true);
test_touches<mp, ml>("MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)),((20 0,20 10,30 10,30 0,20 0)))",
"MULTILINESTRING((10 10,10 20,20 20,20 10,10 10),(22 2,28 2,28 8,22 8,22 2))",
false);
test_touches<mp, ml>("MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)),((20 0,20 10,30 10,30 0,20 0)))",
"MULTILINESTRING((10 10,10 20,20 20,20 10,10 10),(50 2,60 2,60 8,50 8,50 2))",
true);
}
int test_main( int , char* [] )
{
test_all<bg::model::d2::point_xy<double> >();
#ifdef HAVE_TTMATH
test_all<bg::model::d2::point_xy<ttmath_big> >();
#endif
return 0;
}

View File

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

View File

@@ -0,0 +1,239 @@
// Boost.Geometry
// Copyright (c) 2016 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"
#include <algorithms/overlay/overlay_cases.hpp>
#include <algorithms/overlay/multi_overlay_cases.hpp>
#include <boost/geometry/geometries/geometries.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],
true);
test_geometry<poly, poly>(case_8_sph[0], case_8_sph[1],
true);
test_geometry<poly, poly>(case_9_sph[0], case_9_sph[1],
true);
test_geometry<poly, poly>(case_10_sph[0], case_10_sph[1],
true);
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],
true);
test_geometry<poly, poly>(case_14_sph[0], case_14_sph[1],
true);
test_geometry<poly, poly>(case_15_sph[0], case_15_sph[1],
true);
test_geometry<poly, poly>(case_16_sph[0], case_16_sph[1],
true);
test_geometry<poly, poly>(case_17_sph[0], case_17_sph[1],
false);
test_geometry<poly, poly>(case_18_sph[0], case_18_sph[1],
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))", false);
test_geometry<ls, ring>("LINESTRING(11 0,11 10)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", false);
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))", false);
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))",
true);
}
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)))",
true);
}
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)))",
true);
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)))",
true);
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);
}
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_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>();
}
int test_main( int , char* [] )
{
test_all<bg::model::point<double, 2, bg::cs::spherical_equatorial<bg::degree> > >();
#if defined(HAVE_TTMATH)
test_cs<bg::model::point<ttmath_big, 2, bg::cs::spherical_equatorial<bg::degree> > >();
#endif
return 0;
}

View File

@@ -0,0 +1,27 @@
# 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.
# Modifications copyright (c) 2014-2016, 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-within
:
[ run within.cpp : : : : algorithms_within ]
[ run within_areal_areal.cpp : : : : algorithms_within_areal_areal ]
[ run within_linear_areal.cpp : : : : algorithms_within_linear_areal ]
[ run within_linear_linear.cpp : : : : algorithms_within_linear_linear ]
[ run within_multi.cpp : : : : algorithms_within_multi ]
[ run within_pointlike_geometry.cpp : : : : algorithms_within_pointlike_geometry ]
[ run within_sph.cpp : : : : algorithms_within_sph ]
[ run within_sph_geo.cpp : : : : algorithms_within_sph_geo ]
;

View File

@@ -0,0 +1,162 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// Unit Test
// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands.
// Copyright (c) 2013-2015 Adam Wulkiewicz, Lodz, Poland.
// This file was modified by Oracle on 2014, 2015, 2017.
// Modifications copyright (c) 2014-2017 Oracle and/or its affiliates.
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
// Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_GEOMETRY_TEST_WITHIN_HPP
#define BOOST_GEOMETRY_TEST_WITHIN_HPP
#include <boost/variant/variant.hpp>
#include <geometry_test_common.hpp>
#include <boost/geometry/algorithms/within.hpp>
#include <boost/geometry/core/ring_type.hpp>
#include <boost/geometry/geometries/ring.hpp>
#include <boost/geometry/geometries/polygon.hpp>
#include <boost/geometry/geometries/multi_linestring.hpp>
#include <boost/geometry/io/wkt/read.hpp>
#include <boost/geometry/strategies/strategies.hpp>
struct no_strategy {};
template <typename Geometry1, typename Geometry2, typename Strategy>
bool call_within(Geometry1 const& geometry1,
Geometry2 const& geometry2,
Strategy const& strategy)
{
return bg::within(geometry1, geometry2, strategy);
}
template <typename Geometry1, typename Geometry2>
bool call_within(Geometry1 const& geometry1,
Geometry2 const& geometry2,
no_strategy)
{
return bg::within(geometry1, geometry2);
}
template <typename Geometry1, typename Geometry2, typename Strategy>
void check_geometry(Geometry1 const& geometry1,
Geometry2 const& geometry2,
std::string const& wkt1,
std::string const& wkt2,
bool expected,
Strategy const& strategy)
{
bool detected = call_within(geometry1, geometry2, strategy);
BOOST_CHECK_MESSAGE(detected == expected,
"within: " << wkt1
<< " in " << wkt2
<< " -> Expected: " << expected
<< " detected: " << detected);
}
template <typename Geometry1, typename Geometry2>
void test_geometry(std::string const& wkt1,
std::string const& wkt2, bool expected)
{
Geometry1 geometry1;
Geometry2 geometry2;
bg::read_wkt(wkt1, geometry1);
bg::read_wkt(wkt2, geometry2);
boost::variant<Geometry1> v1(geometry1);
boost::variant<Geometry2> v2(geometry2);
typedef typename bg::strategy::within::services::default_strategy
<
Geometry1, Geometry2
>::type strategy_type;
check_geometry(geometry1, geometry2, wkt1, wkt2, expected, strategy_type());
check_geometry(geometry1, geometry2, wkt1, wkt2, expected, no_strategy());
check_geometry(v1, geometry2, wkt1, wkt2, expected, no_strategy());
check_geometry(geometry1, v2, wkt1, wkt2, expected, no_strategy());
check_geometry(v1, v2, wkt1, wkt2, expected, no_strategy());
}
template <typename Point, bool Clockwise, bool Closed>
void test_ordered_ring(std::string const& wkt_point,
std::string const& wkt_geometry, bool expected, bool on_border)
{
typedef bg::model::ring<Point, Clockwise, Closed> ring_type;
ring_type ring;
Point point;
bg::read_wkt(wkt_geometry, ring);
if ( BOOST_GEOMETRY_CONDITION(! Clockwise) )
{
std::reverse(boost::begin(ring), boost::end(ring));
}
bg::read_wkt(wkt_point, point);
bool detected = bg::within(point, ring);
BOOST_CHECK_MESSAGE(detected == expected,
"within: " << wkt_point
<< " in " << wkt_geometry
<< " -> Expected: " << expected
<< " detected: " << detected
<< " clockwise: " << int(Clockwise)
<< " closed: " << int(Closed)
);
// other strategy (note that this one cannot detect OnBorder
// (without modifications)
bg::strategy::within::franklin<Point> franklin;
detected = bg::within(point, ring, franklin);
if (! on_border)
{
BOOST_CHECK_MESSAGE(detected == expected,
"within: " << wkt_point
<< " in " << wkt_geometry
<< " -> Expected: " << expected
<< " detected: " << detected
<< " clockwise: " << int(Clockwise)
<< " closed: " << int(Closed)
);
}
bg::strategy::within::crossings_multiply<Point> cm;
detected = bg::within(point, ring, cm);
if (! on_border)
{
BOOST_CHECK_MESSAGE(detected == expected,
"within: " << wkt_point
<< " in " << wkt_geometry
<< " -> Expected: " << expected
<< " detected: " << detected
<< " clockwise: " << int(Clockwise)
<< " closed: " << int(Closed)
);
}
}
template <typename Point>
void test_ring(std::string const& wkt_point,
std::string const& wkt_geometry,
bool expected, bool on_border)
{
test_ordered_ring<Point, true, true>(wkt_point, wkt_geometry, expected, on_border);
test_ordered_ring<Point, false, true>(wkt_point, wkt_geometry, expected, on_border);
test_ordered_ring<Point, true, false>(wkt_point, wkt_geometry, expected, on_border);
test_ordered_ring<Point, false, false>(wkt_point, wkt_geometry, expected, on_border);
test_geometry<Point, bg::model::polygon<Point> >(wkt_point, wkt_geometry, expected);
}
#endif

View File

@@ -0,0 +1,152 @@
// 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 2014, 2015, 2016.
// Modifications copyright (c) 2014-2016 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_within.hpp"
#include <boost/geometry/geometries/geometries.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/geometries/multi_point.hpp>
#include <boost/geometry/geometries/multi_linestring.hpp>
#include <boost/geometry/geometries/multi_polygon.hpp>
template <typename P1, typename P2>
void test_point_box()
{
typedef bg::model::box<P1> box_type1;
typedef bg::model::box<P2> box_type2;
test_geometry<P1, box_type2>("POINT(1 1)", "BOX(0 0,2 2)", true);
test_geometry<P1, box_type2>("POINT(0 0)", "BOX(0 0,2 2)", false);
test_geometry<P1, box_type2>("POINT(2 2)", "BOX(0 0,2 2)", false);
test_geometry<P1, box_type2>("POINT(0 1)", "BOX(0 0,2 2)", false);
test_geometry<P1, box_type2>("POINT(1 0)", "BOX(0 0,2 2)", false);
test_geometry<P1, box_type2>("POINT(3 3)", "BOX(1 1,4 4)", true);
test_geometry<P2, box_type1>("POINT(3 3)", "BOX(0 0,5 5)", true);
test_geometry<box_type1, box_type2>("BOX(1 1,2 2)", "BOX(0 0,3 3)", true);
test_geometry<box_type1, box_type2>("BOX(0 0,3 3)", "BOX(1 1,2 2)", false);
test_geometry<box_type1, box_type2>("BOX(1 1,3 3)", "BOX(0 0,3 3)", true);
test_geometry<box_type1, box_type2>("BOX(3 1,3 3)", "BOX(0 0,3 3)", false);
test_geometry<box_type1, box_type2>("BOX(1 1,4 4)", "BOX(0 0,5 5)", true);
test_geometry<box_type2, box_type1>("BOX(0 0,5 5)", "BOX(1 1,4 4)", false);
/*
test_within_code<P, box_type>("POINT(1 1)", "BOX(0 0,2 2)", 1);
test_within_code<P, box_type>("POINT(1 0)", "BOX(0 0,2 2)", 0);
test_within_code<P, box_type>("POINT(0 1)", "BOX(0 0,2 2)", 0);
test_within_code<P, box_type>("POINT(0 3)", "BOX(0 0,2 2)", -1);
test_within_code<P, box_type>("POINT(3 3)", "BOX(0 0,2 2)", -1);
test_within_code<box_type, box_type>("BOX(1 1,2 2)", "BOX(0 0,3 3)", 1);
test_within_code<box_type, box_type>("BOX(0 1,2 2)", "BOX(0 0,3 3)", 0);
test_within_code<box_type, box_type>("BOX(1 0,2 2)", "BOX(0 0,3 3)", 0);
test_within_code<box_type, box_type>("BOX(1 1,2 3)", "BOX(0 0,3 3)", 0);
test_within_code<box_type, box_type>("BOX(1 1,3 2)", "BOX(0 0,3 3)", 0);
test_within_code<box_type, box_type>("BOX(1 1,3 4)", "BOX(0 0,3 3)", -1);
*/
}
void test_point_box_3d()
{
typedef boost::geometry::model::point<double, 3, boost::geometry::cs::cartesian> point_type;
typedef boost::geometry::model::box<point_type> box_type;
box_type box(point_type(0, 0, 0), point_type(4, 4, 4));
BOOST_CHECK_EQUAL(bg::within(point_type(2, 2, 2), box), true);
BOOST_CHECK_EQUAL(bg::within(point_type(2, 4, 2), box), false);
BOOST_CHECK_EQUAL(bg::within(point_type(2, 2, 4), box), false);
BOOST_CHECK_EQUAL(bg::within(point_type(2, 2, 5), box), false);
box_type box2(point_type(2, 2, 2), point_type(3, 3, 3));
BOOST_CHECK_EQUAL(bg::within(box2, box), true);
}
template <typename P1, typename P2>
void test_point_poly()
{
typedef boost::geometry::model::polygon<P1> poly1;
typedef boost::geometry::model::polygon<P2> poly2;
test_geometry<P1, poly2>("POINT(3 3)", "POLYGON((0 0,0 5,5 5,5 0,0 0))", true);
test_geometry<P2, poly1>("POINT(3 3)", "POLYGON((0 0,0 5,5 5,5 0,0 0))", true);
}
template <typename P1, typename P2>
void test_all()
{
test_point_box<P1, P2>();
test_point_poly<P1, P2>();
}
template <typename P>
void test_all()
{
test_all<P, P>();
}
void test_strategy()
{
// Test by explicitly specifying a strategy
typedef bg::model::d2::point_xy<double> point_type;
typedef bg::model::box<point_type> box_type;
point_type p(3, 3);
box_type b(point_type(0, 0), point_type(5, 5));
box_type b0(point_type(0, 0), point_type(5, 0));
bool r = bg::within(p, b,
bg::strategy::within::point_in_box<point_type, box_type>());
BOOST_CHECK_EQUAL(r, true);
r = bg::within(b, b,
bg::strategy::within::box_in_box<box_type, box_type>());
BOOST_CHECK_EQUAL(r, true);
r = bg::within(b0, b0,
bg::strategy::within::box_in_box<box_type, box_type>());
BOOST_CHECK_EQUAL(r, false);
r = bg::within(p, b,
bg::strategy::within::point_in_box_by_side<point_type, box_type>());
BOOST_CHECK_EQUAL(r, true);
}
int test_main( int , char* [] )
{
typedef boost::geometry::model::d2::point_xy<double> xyd;
typedef boost::geometry::model::d2::point_xy<float> xyf;
typedef boost::geometry::model::d2::point_xy<int> xyi;
typedef boost::geometry::model::point<double, 2, boost::geometry::cs::cartesian> p2d;
test_all<xyd, p2d>();
test_all<xyf, p2d>();
test_all<xyi, xyd>();
test_all<xyi>();
test_all<xyd>();
test_point_box_3d();
test_strategy();
#if defined(HAVE_TTMATH)
test_all<bg::model::d2::point_xy<ttmath_big> >();
#endif
return 0;
}

View File

@@ -0,0 +1,105 @@
// 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 2014, 2015, 2016.
// Modifications copyright (c) 2014-2016 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_within.hpp"
#include <boost/geometry/geometries/geometries.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/geometries/multi_polygon.hpp>
template <typename P1, typename P2>
void test_a_a()
{
typedef bg::model::polygon<P1> poly1;
typedef bg::model::ring<P1> ring1;
typedef bg::model::multi_polygon<poly1> mpoly1;
typedef bg::model::polygon<P2> poly2;
typedef bg::model::ring<P2> ring2;
typedef bg::model::multi_polygon<poly2> mpoly2;
test_geometry<ring1, ring2>("POLYGON((0 0,0 2,2 2,2 0,0 0))", "POLYGON((0 0,0 5,5 5,5 0,0 0))", true);
test_geometry<ring1, poly2>("POLYGON((0 0,0 5,5 5,5 0,0 0))", "POLYGON((0 0,0 5,5 5,5 0,0 0))", true);
test_geometry<poly1, ring2>("POLYGON((0 0,0 6,6 6,6 0,0 0))", "POLYGON((0 0,0 5,5 5,5 0,0 0))", false);
test_geometry<poly1, poly2>("POLYGON((0 0,0 9,9 9,9 0,0 0),(3 3,6 3,6 6,3 6,3 3))",
"POLYGON((0 0,0 9,9 9,9 0,0 0),(3 3,6 3,6 6,3 6,3 3))", true);
test_geometry<poly1, poly2>("POLYGON((0 0,0 9,9 9,9 0,0 0),(3 3,6 3,6 6,3 6,3 3))",
"POLYGON((0 0,0 9,9 9,9 0,0 0),(4 4,5 4,5 5,4 5,4 4))", true);
test_geometry<poly1, poly2>("POLYGON((1 1,1 8,8 8,8 1,1 1),(3 3,6 3,6 6,3 6,3 3))",
"POLYGON((0 0,0 9,9 9,9 0,0 0),(3 3,6 3,6 6,3 6,3 3))", true);
test_geometry<poly1, poly2>("POLYGON((1 1,1 8,8 8,8 1,1 1),(3 3,6 3,6 6,3 6,3 3))",
"POLYGON((0 0,0 9,9 9,9 0,0 0),(4 4,5 4,5 5,4 5,4 4))", true);
test_geometry<ring1, mpoly2>("POLYGON((0 0,0 2,2 2,2 0,0 0))",
"MULTIPOLYGON(((0 0,0 5,5 5,5 0,0 0)),((5 5,5 10,10 10,10 5,5 5)))", true);
test_geometry<poly1, mpoly2>("POLYGON((0 0,0 2,2 2,2 0,0 0))",
"MULTIPOLYGON(((0 0,0 5,5 5,5 0,0 0)),((5 5,5 10,10 10,10 5,5 5)))", true);
test_geometry<mpoly1, ring2>("MULTIPOLYGON(((0 0,0 5,5 5,5 0,0 0)),((5 5,5 10,10 10,10 5,5 5)))",
"POLYGON((0 0,0 10,10 10,10 0,0 0))", true);
test_geometry<mpoly1, poly2>("MULTIPOLYGON(((0 0,0 5,5 5,5 0,0 0)),((15 15,15 110,110 110,110 15,15 15)))",
"POLYGON((0 0,0 10,10 10,10 0,0 0))", false);
test_geometry<mpoly1, poly2>("MULTIPOLYGON(((0 0,0 1,1 0,0 0)),((3 3,3 4,4 3,3 3)))",
"POLYGON((0 0,0 10,10 10,10 0,0 0),(3 3,4 3,4 4,3 4,3 3))", false);
test_geometry<mpoly1, mpoly2>("MULTIPOLYGON(((0 0,0 1,1 0,0 0)),((3 3,3 4,4 3,3 3)))",
"MULTIPOLYGON(((0 0,0 1,1 0,0 0)),((3 3,3 4,4 3,3 3)))", true);
test_geometry<mpoly1, mpoly2>("MULTIPOLYGON(((0 0,0 1,1 0,0 0)),((3 3,3 4,4 3,3 3)))",
"MULTIPOLYGON(((0 0,0 5,5 5,5 0,0 0)),((5 5,5 10,10 10,10 5,5 5)))", true);
test_geometry<mpoly1, mpoly2>("MULTIPOLYGON(((0 0,0 5,5 5,5 0,0 0)),((5 5,5 10,10 10,10 5,5 5)))",
"MULTIPOLYGON(((0 0,0 1,1 0,0 0)),((3 3,3 4,4 3,3 3)))", false);
// https://svn.boost.org/trac/boost/ticket/10912
test_geometry<poly1, poly2>("POLYGON((0 0,0 5,5 5,5 0,0 0))",
"POLYGON((0 0,0 10,10 10,10 0,0 0),(2 2,4 2,4 4,2 4,2 2),(6 6,8 6,8 8,6 8,6 6))",
false);
test_geometry<poly1, poly2>("POLYGON((0 0,0 10,10 10,10 0,0 0))",
"POLYGON((0 0,0 10,10 10,10 0,0 0),(2 2,2 4,4 4,4 2,2 2))",
false);
test_geometry<poly1, mpoly2>("POLYGON((0 0,0 5,5 5,5 0,0 0))",
"MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)),((0 0,0 -10,-10 -10,-10 0,0 0)))",
true);
test_geometry<poly1, mpoly2>("POLYGON((0 0,0 10,10 10,10 0,0 0))",
"MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)),((0 0,0 -10,-10 -10,-10 0,0 0)))",
true);
}
template <typename P1, typename P2>
void test_all()
{
test_a_a<P1, P2>();
}
template <typename P>
void test_all()
{
test_a_a<P, P>();
}
int test_main( int , char* [] )
{
test_all<bg::model::d2::point_xy<int> >();
test_all<bg::model::d2::point_xy<double> >();
test_all<bg::model::d2::point_xy<double>, bg::model::point<double, 2, bg::cs::cartesian> >();
#if defined(HAVE_TTMATH)
test_all<bg::model::d2::point_xy<ttmath_big> >();
#endif
return 0;
}

View File

@@ -0,0 +1,127 @@
// 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 2014, 2015, 2016.
// Modifications copyright (c) 2014-2016 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_within.hpp"
#include <boost/geometry/geometries/geometries.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/geometries/multi_linestring.hpp>
#include <boost/geometry/geometries/multi_polygon.hpp>
template <typename P1, typename P2>
void test_l_a()
{
typedef bg::model::linestring<P1> ls;
typedef bg::model::multi_linestring<ls> mls;
typedef bg::model::polygon<P2> poly;
typedef bg::model::ring<P2> ring;
typedef bg::model::multi_polygon<poly> mpoly;
// B,I
test_geometry<ls, ring>("LINESTRING(0 0, 2 2)", "POLYGON((0 0,0 5,5 5,5 0,0 0))", true);
// B,I
test_geometry<ls, poly>("LINESTRING(0 0, 2 2)", "POLYGON((0 0,0 5,5 5,5 0,0 0))", true);
// I
test_geometry<ls, poly>("LINESTRING(1 1, 2 2)", "POLYGON((0 0,0 5,5 5,5 0,0 0))", true);
// I,E
test_geometry<ls, poly>("LINESTRING(1 1, 6 6)", "POLYGON((0 0,0 5,5 5,5 0,0 0))", false);
// B
test_geometry<ls, poly>("LINESTRING(0 0, 5 0)", "POLYGON((0 0,0 5,5 5,5 0,0 0))", false);
test_geometry<ls, poly>("LINESTRING(0 0, 0 5)", "POLYGON((0 0,0 5,5 5,5 0,0 0))", false);
// E
test_geometry<ls, poly>("LINESTRING(6 0, 6 5)", "POLYGON((0 0,0 5,5 5,5 0,0 0))", false);
// BIBIB
test_geometry<ls, mpoly>("LINESTRING(0 0, 10 10)", "MULTIPOLYGON(((0 0,0 5,5 5,5 0,0 0)),((5 5,5 10,10 10,10 5,5 5)))", true);
// BIBEBIB
test_geometry<ls, mpoly>("LINESTRING(0 0, 10 10)", "MULTIPOLYGON(((0 0,0 5,5 5,5 0,0 0)),((6 6,5 10,10 10,10 5,6 6)))", false);
// MySQL report 18.12.2014 (https://svn.boost.org/trac/boost/ticket/10887)
test_geometry<ls, mpoly>("LINESTRING(5 -2,5 2)",
"MULTIPOLYGON(((5 0,0 5,10 5,5 0)),((5 0,10 -5,0 -5,5 0)))",
true);
test_geometry<ls, mpoly>("LINESTRING(5 -2,5 5)",
"MULTIPOLYGON(((5 0,0 5,10 5,5 0)),((5 0,10 -5,0 -5,5 0)))",
true);
test_geometry<ls, mpoly>("LINESTRING(5 -2,5 0)",
"MULTIPOLYGON(((5 0,0 5,10 5,5 0)),((5 0,10 -5,0 -5,5 0)))",
true);
// MySQL report 18.12.2014 - extended
test_geometry<ls, mpoly>("LINESTRING(5 -2,5 0)",
"MULTIPOLYGON(((5 0,0 5,10 5,5 0)),((5 0,10 -5,0 -5,5 0)),((5 0,7 1,7 -1,5 0)))",
true);
test_geometry<ls, mpoly>("LINESTRING(0 0,5 0)",
"MULTIPOLYGON(((5 0,0 5,10 5,5 0)),((5 0,10 -5,0 -5,5 0)),((5 0,7 1,7 -1,5 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)))",
true);
test_geometry<mls, mpoly>("MULTILINESTRING((0 0,0 1,5 0),(0 0,0 -1,5 0))",
"MULTIPOLYGON(((5 0,0 5,10 5,5 0)),((5 0,10 -5,0 -5,5 0)))",
false);
test_geometry<mls, mpoly>("MULTILINESTRING((5 -2,4 -2,5 0),(6 -2,5 0))",
"MULTIPOLYGON(((5 0,0 5,10 5,5 0)),((5 0,10 -5,0 -5,5 0)))",
true);
test_geometry<mls, mpoly>("MULTILINESTRING((0 0,0 1,5 0),(0 -1,5 0))",
"MULTIPOLYGON(((5 0,0 5,10 5,5 0)),((5 0,10 -5,0 -5,5 0)))",
false);
test_geometry<mls, mpoly>("MULTILINESTRING((0 0,5 0),(5 -2,5 0))",
"MULTIPOLYGON(((5 0,0 5,10 5,5 0)),((5 0,10 -5,0 -5,5 0)))",
false);
test_geometry<mls, mpoly>("MULTILINESTRING((5 -2,5 0),(0 0,5 0))",
"MULTIPOLYGON(((5 0,0 5,10 5,5 0)),((5 0,10 -5,0 -5,5 0)))",
false);
// BI
test_geometry<mls, poly>("MULTILINESTRING((0 0,2 2),(2 2,3 3))", "POLYGON((0 0,0 5,5 5,5 0,0 0))", true);
// I E
test_geometry<mls, poly>("MULTILINESTRING((1 1,2 2),(6 6,7 7))", "POLYGON((0 0,0 5,5 5,5 0,0 0))", false);
// I I
test_geometry<mls, mpoly>("MULTILINESTRING((1 1,5 5),(6 6,7 7))",
"MULTIPOLYGON(((0 0,0 5,5 5,5 0,0 0)),((5 5,5 10,10 10,10 5,5 5)))",
true);
// I E
test_geometry<mls, mpoly>("MULTILINESTRING((1 1,5 5),(11 11,12 12))",
"MULTIPOLYGON(((0 0,0 5,5 5,5 0,0 0)),((5 5,5 10,10 10,10 5,5 5)))",
false);
}
template <typename P1, typename P2>
void test_all()
{
test_l_a<P1, P2>();
}
template <typename P>
void test_all()
{
test_l_a<P, P>();
}
int test_main( int , char* [] )
{
test_all<bg::model::d2::point_xy<int> >();
test_all<bg::model::d2::point_xy<double> >();
test_all<bg::model::d2::point_xy<double>, bg::model::point<double, 2, bg::cs::cartesian> >();
#if defined(HAVE_TTMATH)
test_all<bg::model::d2::point_xy<ttmath_big> >();
#endif
return 0;
}

View File

@@ -0,0 +1,108 @@
// 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 2014, 2015, 2016.
// Modifications copyright (c) 2014-2016 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_within.hpp"
#include <boost/geometry/geometries/geometries.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/geometries/multi_linestring.hpp>
template <typename P1, typename P2>
void test_l_l()
{
typedef bg::model::linestring<P1> ls1;
typedef bg::model::multi_linestring<ls1> mls1;
typedef bg::model::linestring<P2> ls2;
typedef bg::model::multi_linestring<ls2> mls2;
test_geometry<ls1, ls2>("LINESTRING(0 0, 2 2, 3 2)", "LINESTRING(0 0, 2 2, 3 2)", true);
test_geometry<ls1, ls2>("LINESTRING(0 0, 1 1, 2 2, 3 2)", "LINESTRING(0 0, 2 2, 3 2)", true);
test_geometry<ls1, ls2>("LINESTRING(3 2, 2 2, 1 1, 0 0)", "LINESTRING(0 0, 2 2, 3 2)", true);
test_geometry<ls1, ls2>("LINESTRING(0 0, 1 1, 2 2, 3 2)", "LINESTRING(3 2, 2 2, 0 0)", true);
test_geometry<ls1, ls2>("LINESTRING(3 2, 2 2, 1 1, 0 0)", "LINESTRING(3 2, 2 2, 0 0)", true);
test_geometry<ls1, ls2>("LINESTRING(1 1, 2 2, 3 2)", "LINESTRING(0 0, 2 2, 4 2)", true);
test_geometry<ls1, ls2>("LINESTRING(3 2, 2 2, 1 1)", "LINESTRING(0 0, 2 2, 4 2)", true);
test_geometry<ls1, ls2>("LINESTRING(1 1, 2 2, 3 2)", "LINESTRING(4 2, 2 2, 0 0)", true);
test_geometry<ls1, ls2>("LINESTRING(3 2, 2 2, 1 1)", "LINESTRING(4 2, 2 2, 0 0)", true);
test_geometry<ls1, ls2>("LINESTRING(1 1, 2 2, 3 3)", "LINESTRING(0 0, 2 2, 4 2)", false);
test_geometry<ls1, ls2>("LINESTRING(1 1, 2 2, 3 2, 3 3)", "LINESTRING(0 0, 2 2, 4 2)", false);
test_geometry<ls1, ls2>("LINESTRING(1 1, 2 2, 3 1)", "LINESTRING(0 0, 2 2, 4 2)", false);
test_geometry<ls1, ls2>("LINESTRING(1 1, 2 2, 3 2, 3 1)", "LINESTRING(0 0, 2 2, 4 2)", false);
test_geometry<ls1, ls2>("LINESTRING(0 1, 1 1, 2 2, 3 2)", "LINESTRING(0 0, 2 2, 4 2)", false);
test_geometry<ls1, ls2>("LINESTRING(0 1, 0 0, 2 2, 3 2)", "LINESTRING(0 0, 2 2, 4 2)", false);
test_geometry<ls1, ls2>("LINESTRING(1 0, 1 1, 2 2, 3 2)", "LINESTRING(0 0, 2 2, 4 2)", false);
test_geometry<ls1, ls2>("LINESTRING(1 0, 0 0, 2 2, 3 2)", "LINESTRING(0 0, 2 2, 4 2)", false);
// duplicated points
test_geometry<ls1, ls2>("LINESTRING(1 1, 2 2, 2 2)", "LINESTRING(0 0, 2 2, 4 2)", true);
test_geometry<ls1, ls2>("LINESTRING(1 1, 1 1, 2 2)", "LINESTRING(0 0, 2 2, 4 2)", true);
test_geometry<ls1, ls2>("LINESTRING(0 0, 0 0, 0 0, 1 1, 2 2, 2 2, 2 2, 2 2, 2 2, 2 2, 2 2, 2 2, 2 2, 2 2, 2 2, 2 2, 2 2, 2 2, 2 2, 2 2, 2 2, 2 2, 3 3)",
"LINESTRING(0 0, 2 2, 4 4)", true);
// invalid linestrings
// test_geometry<ls1, ls2>("LINESTRING(0 0)", "LINESTRING(0 0)", false);
// test_geometry<ls1, ls2>("LINESTRING(1 1)", "LINESTRING(0 0, 2 2)", true);
// test_geometry<ls1, ls2>("LINESTRING(0 0)", "LINESTRING(0 0, 2 2)", false);
// test_geometry<ls1, ls2>("LINESTRING(0 0, 1 1)", "LINESTRING(0 0)", false);
// spikes
// FOR NOW DISABLED
/*test_geometry<ls1, ls2>("LINESTRING(0 0,5 0,3 0,6 0)", "LINESTRING(0 0,6 0)", true);
test_geometry<ls1, ls2>("LINESTRING(0 0,2 2,3 3,1 1)", "LINESTRING(0 0,3 3,6 3)", true);
test_geometry<ls1, ls2>("LINESTRING(0 0,3 3,6 3)", "LINESTRING(0 0,2 2,3 3,1 1)", false);
test_geometry<ls1, ls2>("LINESTRING(0 0,2 2,3 3,1 1)", "LINESTRING(0 0,4 4,6 3)", true);
test_geometry<ls1, ls2>("LINESTRING(0 0,4 4,6 3)", "LINESTRING(0 0,2 2,3 3,1 1)", false);
test_geometry<ls1, ls2>("LINESTRING(0 0,2 2,3 3,1 1,5 3)", "LINESTRING(0 0,3 3,6 3)", false);*/
test_geometry<ls1, mls2>("LINESTRING(1 1, 2 2)", "MULTILINESTRING((0 0, 2 2),(3 3, 4 4))", true);
test_geometry<mls1, ls2>("MULTILINESTRING((0 0, 2 2),(3 3, 4 4))", "LINESTRING(0 0, 5 5)", true);
test_geometry<mls1, mls2>("MULTILINESTRING((1 1, 2 2),(3 3, 4 4))", "MULTILINESTRING((1 1, 2 2),(2 2, 5 5))", true);
}
template <typename P1, typename P2>
void test_all()
{
test_l_l<P1, P2>();
}
template <typename P>
void test_all()
{
test_l_l<P, P>();
}
int test_main( int , char* [] )
{
test_all<bg::model::d2::point_xy<int> >();
test_all<bg::model::d2::point_xy<double> >();
test_all<bg::model::d2::point_xy<double>, bg::model::point<double, 2, bg::cs::cartesian> >();
#if defined(HAVE_TTMATH)
test_all<bg::model::d2::point_xy<ttmath_big> >();
#endif
return 0;
}

View File

@@ -0,0 +1,54 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
//
// Copyright (c) 2007-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 <geometry_test_common.hpp>
#include <boost/geometry/io/wkt/wkt.hpp>
#include <boost/geometry/algorithms/correct.hpp>
#include <boost/geometry/algorithms/within.hpp>
#include <boost/geometry/geometries/box.hpp>
#include <boost/geometry/geometries/polygon.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/geometries/multi_polygon.hpp>
#include "test_within.hpp"
template <typename P>
void test_all()
{
typedef bg::model::multi_polygon<bg::model::polygon<P> > mp;
// test multi-with-one-polygon (trivial case)
test_geometry<P, mp>("POINT(1 1)", "MULTIPOLYGON(((0 0,0 2,2 2,2 0,0 0)))", true);
test_geometry<P, mp>("POINT(3 3)", "MULTIPOLYGON(((0 0,0 2,2 2,2 0,0 0)))", false);
test_geometry<P, mp>("POINT(0 1)", "MULTIPOLYGON(((0 0,0 2,2 2,2 0,0 0)))", false);
test_geometry<P, mp>("POINT(4 4)", "MULTIPOLYGON(((0 0,0 2,2 2,2 0,0 0)))", false);
// test if it is in one of them
std::string multi("MULTIPOLYGON("
"((0 0,0 2,2 2,2 0,0 0))"
"((3 3,3 6,6 6,6 3,3 3))"
")");
test_geometry<P, mp>("POINT(4 4)", multi, true);
test_geometry<P, mp>("POINT(1 1)", multi, true);
test_geometry<P, mp>("POINT(0 1)", multi, false);
}
int test_main( int , char* [] )
{
//test_all<bg::model::d2::point_xy<int> >();
test_all<bg::model::d2::point_xy<double> >();
#if defined(HAVE_TTMATH)
test_all<bg::model::d2::point_xy<ttmath_big> >();
#endif
return 0;
}

View File

@@ -0,0 +1,462 @@
// 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 2014, 2015, 2016, 2017.
// Modifications copyright (c) 2014-2017 Oracle and/or its affiliates.
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
// Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include "test_within.hpp"
#include <boost/geometry/geometries/geometries.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/geometries/multi_point.hpp>
#include <boost/geometry/geometries/multi_linestring.hpp>
#include <boost/geometry/geometries/multi_polygon.hpp>
template <typename P>
void test_p_p()
{
typedef bg::model::multi_point<P> mpt;
test_geometry<P, P>("POINT(0 0)", "POINT(0 0)", true);
test_geometry<P, P>("POINT(0 0)", "POINT(1 1)", false);
test_geometry<P, mpt>("POINT(0 0)", "MULTIPOINT(0 0, 1 1)", true);
test_geometry<P, mpt>("POINT(0 0)", "MULTIPOINT(1 1, 2 2)", false);
test_geometry<mpt, P>("MULTIPOINT(0 0)", "POINT(0 0)", true);
test_geometry<mpt, P>("MULTIPOINT(0 0, 1 1)", "POINT(0 0)", false);
test_geometry<mpt, P>("MULTIPOINT(0 0, 1 1)", "POINT(2 2)", false);
test_geometry<mpt, mpt>("MULTIPOINT(0 0)", "MULTIPOINT(0 0, 1 1)", true);
test_geometry<mpt, mpt>("MULTIPOINT(0 0, 1 1)", "MULTIPOINT(0 0, 1 1)", true);
test_geometry<mpt, mpt>("MULTIPOINT(0 0, 1 1)", "MULTIPOINT(0 0)", false);
test_geometry<mpt, mpt>("MULTIPOINT(0 0, 1 1)", "MULTIPOINT(1 1, 2 2)", false);
test_geometry<mpt, mpt>("MULTIPOINT(0 0, 1 1)", "MULTIPOINT(2 2, 3 4)", false);
}
template <typename P>
void test_p_l()
{
typedef bg::model::multi_point<P> mpt;
typedef bg::model::segment<P> seg;
typedef bg::model::linestring<P> ls;
typedef bg::model::multi_linestring<ls> mls;
test_geometry<P, seg>("POINT(1 1)", "LINESTRING(0 0, 2 2)", true);
test_geometry<P, seg>("POINT(0 0)", "LINESTRING(0 0, 1 1)", false);
test_geometry<P, seg>("POINT(1 0)", "LINESTRING(0 0, 1 1)", false);
test_geometry<P, ls>("POINT(0 0)", "LINESTRING(0 0,1 1,2 2)", false);
test_geometry<P, ls>("POINT(3 3)", "LINESTRING(0 0,1 1,2 2)", false);
test_geometry<P, ls>("POINT(1 1)", "LINESTRING(0 0,2 2,3 3)", true);
test_geometry<P, ls>("POINT(1 1)", "LINESTRING(0 0, 2 2)", true);
test_geometry<P, ls>("POINT(0 0)", "LINESTRING(0 0, 1 1)", false);
test_geometry<P, mls>("POINT(0 0)", "MULTILINESTRING((0 0,1 1,2 2),(0 0,0 1))", true);
test_geometry<P, mls>("POINT(0 0)", "MULTILINESTRING((0 0,1 1,2 2),(0 0,0 1),(0 0,1 0))", false);
test_geometry<P, mls>("POINT(1 1)", "MULTILINESTRING((0 0, 1 1),(1 1, 2 2))", true);
test_geometry<P, mls>("POINT(1 1)", "MULTILINESTRING((0 0, 1 1),(2 2, 3 3))", false);
test_geometry<mpt, seg>("MULTIPOINT(0 0, 1 1)", "LINESTRING(0 0, 2 2)", true);
test_geometry<mpt, ls>("MULTIPOINT(0 0, 2 2)", "LINESTRING(0 0, 2 2)", false);
test_geometry<mpt, ls>("MULTIPOINT(1 1, 3 3)", "LINESTRING(0 0, 2 2)", false);
test_geometry<mpt, mls>("MULTIPOINT(0 0, 1 1)", "MULTILINESTRING((0 0, 2 2),(2 2, 3 3))", true);
test_geometry<mpt, mls>("MULTIPOINT(0 0, 2 2)", "MULTILINESTRING((0 0, 2 2),(2 2, 3 3))", true);
test_geometry<mpt, mls>("MULTIPOINT(0 0, 3 3)", "MULTILINESTRING((0 0, 2 2),(2 2, 3 3))", false);
test_geometry<mpt, mls>("MULTIPOINT(1 1, 4 4)", "MULTILINESTRING((0 0, 2 2),(2 2, 3 3))", false);
}
template <typename P>
void test_p_a()
{
typedef bg::model::multi_point<P> mpt;
typedef bg::model::ring<P> ring;
typedef bg::model::polygon<P> poly;
typedef bg::model::multi_polygon<poly> mpoly;
// trivial case
test_ring<P>("POINT(1 1)", "POLYGON((0 0,0 2,2 2,2 0,0 0))", true, false);
// on border/corner
test_ring<P>("POINT(0 0)", "POLYGON((0 0,0 2,2 2,2 0,0 0))", false, true);
test_ring<P>("POINT(0 1)", "POLYGON((0 0,0 2,2 2,2 0,0 0))", false, true);
// aligned to segment/vertex
test_ring<P>("POINT(1 1)", "POLYGON((0 0,0 3,3 3,3 1,2 1,2 0,0 0))", true, false);
test_ring<P>("POINT(1 1)", "POLYGON((0 0,0 3,4 3,3 1,2 2,2 0,0 0))", true, false);
// same polygon, but point on border
test_ring<P>("POINT(3 3)", "POLYGON((0 0,0 3,3 3,3 1,2 1,2 0,0 0))", false, true);
test_ring<P>("POINT(3 3)", "POLYGON((0 0,0 3,4 3,3 1,2 2,2 0,0 0))", false, true);
// holes
test_geometry<P, poly>("POINT(2 2)",
"POLYGON((0 0,0 4,4 4,4 0,0 0),(1 1,3 1,3 3,1 3,1 1))", false);
// Real-life problem (solved now), point is in the middle, 409623 is also a coordinate
// on the border, has been wrong in the past (2009)
test_ring<P>("POINT(146383 409623)",
"POLYGON((146351 410597,146521 410659,147906 410363,148088 410420"
",148175 410296,148281 409750,148215 409623,148154 409666,148154 409666"
",148130 409625,148035 409626,148035 409626,148008 409544,147963 409510"
",147993 409457,147961 409352,147261 408687,147008 408586,145714 408840"
",145001 409033,144486 409066,144616 409308,145023 410286,145254 410488"
",145618 410612,145618 410612,146015 410565,146190 410545,146351 410597))",
true, false);
test_geometry<P, mpoly>("POINT(2 2)",
"MULTIPOLYGON(((0 0,0 4,4 4,4 0,0 0),(1 1,3 1,3 3,1 3,1 1)),((5 5,5 9,9 9,9 5,5 5)))", false);
test_geometry<P, mpoly>("POINT(1 1)",
"MULTIPOLYGON(((0 0,0 4,4 4,4 0,0 0),(1 1,3 1,3 3,1 3,1 1)),((5 5,5 9,9 9,9 5,5 5)))", false);
test_geometry<P, mpoly>("POINT(1 1)",
"MULTIPOLYGON(((0 0,0 5,5 5,5 0,0 0),(2 2,4 2,4 4,2 4,2 2)),((5 5,5 9,9 9,9 5,5 5)))", true);
test_geometry<P, mpoly>("POINT(6 6)",
"MULTIPOLYGON(((0 0,0 4,4 4,4 0,0 0),(1 1,3 1,3 3,1 3,1 1)),((5 5,5 9,9 9,9 5,5 5)))", true);
test_geometry<P, poly>("POINT(6 4)",
"POLYGON((0 5, 5 0, 6 1, 5 2, 8 4, 5 6, 6 7, 5 8, 6 9, 5 10, 0 5))", true);
test_geometry<P, poly>("POINT(4 6)",
"POLYGON((5 0, 0 5, 1 6, 2 5, 4 8, 6 5, 7 6, 8 5, 9 6, 10 5, 5 0))", true);
test_geometry<mpt, ring>("MULTIPOINT(0 0, 1 1)", "POLYGON((0 0,0 2,2 2,2 0,0 0))", true);
test_geometry<mpt, poly>("MULTIPOINT(0 0, 2 2)", "POLYGON((0 0,0 2,2 2,2 0,0 0))", false);
test_geometry<mpt, poly>("MULTIPOINT(1 1, 3 3)", "POLYGON((0 0,0 2,2 2,2 0,0 0))", false);
test_geometry<mpt, mpoly>("MULTIPOINT(0 0, 1 1)", "MULTIPOLYGON(((0 0,0 2,2 2,2 0,0 0)),((2 2,2 3,3 3,3 2,2 2)))", true);
test_geometry<mpt, mpoly>("MULTIPOINT(0 0, 2 2)", "MULTIPOLYGON(((0 0,0 2,2 2,2 0,0 0)),((2 2,2 3,3 3,3 2,2 2)))", false);
test_geometry<mpt, mpoly>("MULTIPOINT(0 0, 3 3)", "MULTIPOLYGON(((0 0,0 2,2 2,2 0,0 0)),((2 2,2 3,3 3,3 2,2 2)))", false);
test_geometry<mpt, mpoly>("MULTIPOINT(1 1, 4 4)", "MULTIPOLYGON(((0 0,0 2,2 2,2 0,0 0)),((2 2,2 3,3 3,3 2,2 2)))", false);
}
template <typename P>
void test_all()
{
test_p_p<P>();
test_p_l<P>();
test_p_a<P>();
}
template <typename Point>
void test_spherical_geographic()
{
bg::model::polygon<Point> wrangel;
typename boost::mpl::if_
<
boost::is_same<typename bg::cs_tag<Point>::type, bg::geographic_tag>,
bg::strategy::within::geographic_winding<Point>,
bg::strategy::within::spherical_winding<Point>
>::type ws;
typename boost::mpl::if_
<
boost::is_same<typename bg::cs_tag<Point>::type, bg::geographic_tag>,
bg::strategy::side::geographic<>,
bg::strategy::side::spherical_side_formula<>
>::type ss;
boost::ignore_unused(ws, ss);
// SQL Server check (no geography::STWithin, so check with intersection trick)
/*
with q as (
select geography::STGeomFromText('POLYGON((-178.569 71.5641,-179.034 71.5977,-179.305 71.5514,-179.629 71.5772,-180 71.5358,179.53 71.4383,178.872 71.2175,178.618 71.0355,178.791 70.7964,179.273 70.8886,179.678 70.8955,-180 70.9972,-179.274 70.9078,-178.819 70.98,-177.939 71.0375,-177.62 71.1166,-177.439 71.2269,-177.503 71.2775,-177.833 71.3461,-178.018 71.4497,-178.569 71.5641))',4326) as wrangel
)
select wrangel.STArea()/1000000.0
,geography::STGeomFromText('POINT(-179.3 71.27)',4326).STIntersection(wrangel).STAsText() as workaround_within_1
,geography::STGeomFromText('POINT(-179.9 70.95)',4326).STIntersection(wrangel).STAsText() as workaround_within_2
,geography::STGeomFromText('POINT(179.9 70.95)',4326).STIntersection(wrangel).STAsText() as workaround_within_3
from q
-> 7669.10402181435 POINT (-179.3 71.27) GEOMETRYCOLLECTION EMPTY GEOMETRYCOLLECTION EMPTY
PostGIS knows Within for Geography neither, and the intersection trick gives the same result
*/
bg::read_wkt("POLYGON((-178.568604 71.564148,-178.017548 71.449692,-177.833313 71.3461,-177.502838 71.277466 ,-177.439453 71.226929,-177.620026 71.116638,-177.9389 71.037491,-178.8186 70.979965,-179.274445 70.907761,-180 70.9972,179.678314 70.895538,179.272766 70.888596,178.791016 70.7964,178.617737 71.035538,178.872192 71.217484,179.530273 71.4383 ,-180 71.535843 ,-179.628601 71.577194,-179.305298 71.551361,-179.03421 71.597748,-178.568604 71.564148))", wrangel);
bool within = bg::within(Point(-179.3, 71.27), wrangel);
BOOST_CHECK_EQUAL(within, true);
within = bg::within(Point(-179.9, 70.95), wrangel);
BOOST_CHECK_EQUAL(within, false);
within = bg::within(Point(179.9, 70.95), wrangel);
BOOST_CHECK_EQUAL(within, false);
// Test using great circle mapper
// http://www.gcmap.com/mapui?P=5E52N-9E53N-7E50N-5E52N,7E52.5N,8E51.5N,6E51N
bg::model::polygon<Point> triangle;
bg::read_wkt("POLYGON((5 52,9 53,7 50,5 52))", triangle);
BOOST_CHECK_EQUAL(bg::within(Point(7, 52.5), triangle, ws), true);
BOOST_CHECK_EQUAL(bg::within(Point(8.0, 51.5), triangle, ws), false);
BOOST_CHECK_EQUAL(bg::within(Point(6.0, 51.0), triangle, ws), false);
// northern hemisphere
{
bg::model::polygon<Point> poly_n;
bg::read_wkt("POLYGON((10 50,30 50,30 40,10 40, 10 50))", poly_n);
Point pt_n1(20, 50.00001);
Point pt_n2(20, 40.00001);
BOOST_CHECK_EQUAL(ss.apply(poly_n.outer()[0], poly_n.outer()[1], pt_n1), -1); // right of segment
BOOST_CHECK_EQUAL(ss.apply(poly_n.outer()[2], poly_n.outer()[3], pt_n2), 1); // left of segment
BOOST_CHECK_EQUAL(bg::within(pt_n1, poly_n, ws), true);
BOOST_CHECK_EQUAL(bg::within(pt_n2, poly_n, ws), false);
}
// southern hemisphere
{
bg::model::polygon<Point> poly_s;
bg::read_wkt("POLYGON((10 -40,30 -40,30 -50,10 -50, 10 -40))", poly_s);
Point pt_s1(20, -40.00001);
Point pt_s2(20, -50.00001);
BOOST_CHECK_EQUAL(ss.apply(poly_s.outer()[0], poly_s.outer()[1], pt_s1), 1); // left of segment
BOOST_CHECK_EQUAL(ss.apply(poly_s.outer()[2], poly_s.outer()[3], pt_s2), -1); // right of segment
BOOST_CHECK_EQUAL(bg::within(pt_s1, poly_s, ws), false);
BOOST_CHECK_EQUAL(bg::within(pt_s2, poly_s, ws), true);
}
// crossing antimeridian, northern hemisphere
{
bg::model::polygon<Point> poly_n;
bg::read_wkt("POLYGON((170 50,-170 50,-170 40,170 40, 170 50))", poly_n);
Point pt_n11(180, 50.00001);
Point pt_n12(-180, 50.00001);
Point pt_n13(179, 50.00001);
Point pt_n14(-179, 50.00001);
Point pt_n21(180, 40.00001);
Point pt_n22(-180, 40.00001);
Point pt_n23(179, 40.00001);
Point pt_n24(-179, 40.00001);
BOOST_CHECK_EQUAL(bg::within(pt_n11, poly_n, ws), true);
BOOST_CHECK_EQUAL(bg::within(pt_n12, poly_n, ws), true);
BOOST_CHECK_EQUAL(bg::within(pt_n13, poly_n, ws), true);
BOOST_CHECK_EQUAL(bg::within(pt_n14, poly_n, ws), true);
BOOST_CHECK_EQUAL(bg::within(pt_n21, poly_n, ws), false);
BOOST_CHECK_EQUAL(bg::within(pt_n22, poly_n, ws), false);
BOOST_CHECK_EQUAL(bg::within(pt_n23, poly_n, ws), false);
BOOST_CHECK_EQUAL(bg::within(pt_n24, poly_n, ws), false);
}
// TODO: Move to covered_by tests
// Segment going through pole
{
bg::model::polygon<Point> poly_n1;
bg::read_wkt("POLYGON((-90 80,90 80,90 70,-90 70, -90 80))", poly_n1);
// Points on segment
BOOST_CHECK_EQUAL(bg::covered_by(Point(-90, 85), poly_n1, ws), true);
BOOST_CHECK_EQUAL(bg::covered_by(Point(90, 85), poly_n1, ws), true);
// Points on pole
BOOST_CHECK_EQUAL(bg::covered_by(Point(90, 90), poly_n1, ws), true);
BOOST_CHECK_EQUAL(bg::covered_by(Point(0, 90), poly_n1, ws), true);
BOOST_CHECK_EQUAL(bg::covered_by(Point(45, 90), poly_n1, ws), true);
}
// Segment going through pole
{
bg::model::polygon<Point> poly_n2;
bg::read_wkt("POLYGON((-90 80,90 70,0 70,-90 80))", poly_n2);
// Points on segment
BOOST_CHECK_EQUAL(bg::covered_by(Point(-90, 85), poly_n2, ws), true);
BOOST_CHECK_EQUAL(bg::covered_by(Point(90, 75), poly_n2, ws), true);
// Points outside but on the same level as segment
BOOST_CHECK_EQUAL(bg::covered_by(Point(-90, 75), poly_n2, ws), false);
}
// Possibly invalid, 2-segment polygon with segment going through pole
/*{
bg::model::polygon<Point> poly_n;
bg::read_wkt("POLYGON((-90 80,90 70,-90 80))", poly_n);
// Point within
BOOST_CHECK_EQUAL(bg::within(Point(0, 89), poly_n), true);
// Points on segment
BOOST_CHECK_EQUAL(bg::covered_by(Point(-90, 85), poly_n), true);
BOOST_CHECK_EQUAL(bg::covered_by(Point(90, 75), poly_n), true);
// Points outside but on the same level as segment
BOOST_CHECK_EQUAL(bg::covered_by(Point(-90, 75), poly_n), false);
}*/
// Segment endpoints on pole with arbitrary longitudes
{
bg::model::polygon<Point> poly_n3;
bg::read_wkt("POLYGON((45 90,45 80,0 80,45 90))", poly_n3);
BOOST_CHECK_EQUAL(bg::covered_by(Point(0, 85), poly_n3, ws), true);
BOOST_CHECK_EQUAL(bg::covered_by(Point(45, 85), poly_n3, ws), true);
}
// Segment going through pole
{
bg::model::polygon<Point> poly_s1;
bg::read_wkt("POLYGON((-90 -80,-90 -70,90 -70,90 -80,-90 -80))", poly_s1);
// Points on segment
BOOST_CHECK_EQUAL(bg::covered_by(Point(-90, -85), poly_s1, ws), true);
BOOST_CHECK_EQUAL(bg::covered_by(Point(90, -85), poly_s1, ws), true);
// Points on pole
BOOST_CHECK_EQUAL(bg::covered_by(Point(90, -90), poly_s1, ws), true);
BOOST_CHECK_EQUAL(bg::covered_by(Point(0, -90), poly_s1, ws), true);
BOOST_CHECK_EQUAL(bg::covered_by(Point(45, -90), poly_s1, ws), true);
}
// Segment endpoints on pole with arbitrary longitudes
{
bg::model::polygon<Point> poly_s2;
bg::read_wkt("POLYGON((45 -90,0 -80,45 -80,45 -90))", poly_s2);
BOOST_CHECK_EQUAL(bg::covered_by(Point(0, -85), poly_s2, ws), true);
BOOST_CHECK_EQUAL(bg::covered_by(Point(45, -85), poly_s2, ws), true);
}
// Polygon covering nearly half of the globe but no poles
{
bg::model::polygon<Point> poly_h1;
bg::read_wkt("POLYGON((170 0, 170 -80,10 -80,0 -80,0 -20,10 -20,10 20,0 20,0 80,10 80,170 80,170 0))", poly_h1);
BOOST_CHECK_EQUAL(bg::covered_by(Point(5, 90), poly_h1, ws), false);
BOOST_CHECK_EQUAL(bg::covered_by(Point(5, 85), poly_h1, ws), false);
BOOST_CHECK_EQUAL(bg::covered_by(Point(5, 50), poly_h1, ws), true);
BOOST_CHECK_EQUAL(bg::covered_by(Point(5, 0), poly_h1, ws), false);
BOOST_CHECK_EQUAL(bg::covered_by(Point(5, -50), poly_h1, ws), true);
BOOST_CHECK_EQUAL(bg::covered_by(Point(5, -85), poly_h1, ws), false);
BOOST_CHECK_EQUAL(bg::covered_by(Point(5, -90), poly_h1, ws), false);
}
// Polygon covering more than half of the globe with both holes
{
bg::model::polygon<Point> poly_h2;
bg::read_wkt("POLYGON((180 0, 180 -80,0 -80,10 -80,10 -20,0 -20,0 20,10 20,10 80,0 80,180 80,180 0))", poly_h2);
BOOST_CHECK_EQUAL(bg::covered_by(Point(5, 90), poly_h2, ws), true);
BOOST_CHECK_EQUAL(bg::covered_by(Point(5, 85), poly_h2, ws), true);
BOOST_CHECK_EQUAL(bg::covered_by(Point(5, 50), poly_h2, ws), false);
BOOST_CHECK_EQUAL(bg::covered_by(Point(5, 0), poly_h2, ws), true);
BOOST_CHECK_EQUAL(bg::covered_by(Point(5, -50), poly_h2, ws), false);
BOOST_CHECK_EQUAL(bg::covered_by(Point(5, -85), poly_h2, ws), true);
BOOST_CHECK_EQUAL(bg::covered_by(Point(5, -90), poly_h2, ws), true);
}
// Polygon covering around half of the globe covering south pole
{
bg::model::polygon<Point> poly_h3;
bg::read_wkt("POLYGON((180 0, 180 -80,0 -80,0 -20,10 -20,10 20,0 20,0 80,10 80,170 80,180 0))", poly_h3);
BOOST_CHECK_EQUAL(bg::covered_by(Point(5, 90), poly_h3, ws), false);
BOOST_CHECK_EQUAL(bg::covered_by(Point(5, 85), poly_h3, ws), false);
BOOST_CHECK_EQUAL(bg::covered_by(Point(5, 50), poly_h3, ws), true);
BOOST_CHECK_EQUAL(bg::covered_by(Point(5, 0), poly_h3, ws), false);
BOOST_CHECK_EQUAL(bg::covered_by(Point(5, -50), poly_h3, ws), true);
BOOST_CHECK_EQUAL(bg::covered_by(Point(5, -85), poly_h3, ws), true);
BOOST_CHECK_EQUAL(bg::covered_by(Point(5, -90), poly_h3, ws), true);
}
// Polygon covering around half of the globe covering north pole
{
bg::model::polygon<Point> poly_h4;
bg::read_wkt("POLYGON((180 0, 170 -80,10 -80,10 -20,0 -20,0 20,10 20,10 80,0 80,180 80,180 0))", poly_h4);
BOOST_CHECK_EQUAL(bg::covered_by(Point(5, 90), poly_h4, ws), true);
BOOST_CHECK_EQUAL(bg::covered_by(Point(5, 85), poly_h4, ws), true);
BOOST_CHECK_EQUAL(bg::covered_by(Point(5, 50), poly_h4, ws), false);
BOOST_CHECK_EQUAL(bg::covered_by(Point(5, 0), poly_h4, ws), true);
BOOST_CHECK_EQUAL(bg::covered_by(Point(5, -50), poly_h4, ws), false);
BOOST_CHECK_EQUAL(bg::covered_by(Point(5, -85), poly_h4, ws), false);
BOOST_CHECK_EQUAL(bg::covered_by(Point(5, -90), poly_h4, ws), false);
}
}
void test_large_integers()
{
typedef bg::model::point<int, 2, bg::cs::cartesian> int_point_type;
typedef bg::model::point<double, 2, bg::cs::cartesian> double_point_type;
std::string const polygon_li = "POLYGON((1872000 528000,1872000 192000,1536119 192000,1536000 528000,1200000 528000,1200000 863880,1536000 863880,1872000 863880,1872000 528000))";
bg::model::polygon<int_point_type> int_poly;
bg::model::polygon<double_point_type> double_poly;
bg::read_wkt(polygon_li, int_poly);
bg::read_wkt(polygon_li, double_poly);
std::string const point_li = "POINT(1592000 583950)";
int_point_type int_point;
double_point_type double_point;
bg::read_wkt(point_li, int_point);
bg::read_wkt(point_li, double_point);
bool wi = bg::within(int_point, int_poly);
bool wd = bg::within(double_point, double_poly);
BOOST_CHECK_MESSAGE(wi == wd, "within<a double> different from within<an int>");
}
void test_tickets()
{
typedef boost::geometry::model::d2::point_xy<double> pt;
typedef boost::geometry::model::ring<pt> ring;
// https://svn.boost.org/trac/boost/ticket/9628
{
ring r;
r.push_back(pt(-19155.669324773193,54820.312032458620));
r.push_back(pt(-13826.169324773080,54820.312032458627));
r.push_back(pt(-13826.169324773078,52720.312032458663));
r.push_back(pt(-12755.169324773129,52720.312032458663));
r.push_back(pt(-12755.169324773129,51087.312032458671));
r.push_back(pt(-12760.669324773080,51087.312032458671));
r.push_back(pt(-12760.669324773082,51070.312032458627));
r.push_back(pt(-19155.669324779392,51070.312032458620));
r.push_back(pt(-19155.669324773193,54820.312032458620));
pt p( -12260.669324773118, 54820.312032458634 );
//boost::geometry::correct(r);
bool within = boost::geometry::within(p, r);
BOOST_CHECK_EQUAL(within, false);
}
// similar
{
ring r;
r.push_back(pt(-14155.6,54820.312032458620));
r.push_back(pt(-13826.1,54820.312032458625));
r.push_back(pt(-12155.6,53720.3));
r.push_back(pt(-14155.6,54820.312032458620));
pt p( -13826.0, 54820.312032458634 );
bool within = boost::geometry::within(p, r);
BOOST_CHECK_EQUAL(within, false);
}
// https://svn.boost.org/trac/boost/ticket/10234
{
pt p;
ring r;
bg::read_wkt("POINT(0.1377 5.00)", p);
bg::read_wkt("POLYGON((0.1277 4.97, 0.1277 5.00, 0.1278 4.9999999999999982, 0.1278 4.97, 0.1277 4.97))", r);
bool within = boost::geometry::within(p, r);
BOOST_CHECK_EQUAL(within, false);
bool covered_by = boost::geometry::covered_by(p, r);
BOOST_CHECK_EQUAL(covered_by, false);
}
}
int test_main( int , char* [] )
{
test_large_integers();
test_all<bg::model::d2::point_xy<int> >();
test_all<bg::model::d2::point_xy<double> >();
test_spherical_geographic<bg::model::point<double, 2, bg::cs::spherical_equatorial<bg::degree> > >();
test_spherical_geographic<bg::model::point<double, 2, bg::cs::geographic<bg::degree> > >();
#if defined(HAVE_TTMATH)
test_all<bg::model::d2::point_xy<ttmath_big> >();
test_spherical_geographic<bg::model::point<ttmath_big, 2, bg::cs::spherical_equatorial<bg::degree> > >();
test_spherical_geographic<bg::model::point<ttmath_big, 2, bg::cs::geographic<bg::degree> > >();
#endif
test_tickets();
return 0;
}

View File

@@ -0,0 +1,273 @@
// Boost.Geometry
// Copyright (c) 2016 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_within.hpp"
#include <algorithms/overlay/overlay_cases.hpp>
#include <algorithms/overlay/multi_overlay_cases.hpp>
#include <boost/geometry/geometries/geometries.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],
true);
test_geometry<poly, poly>(case_3_2_sph[0], case_3_2_sph[1],
true);
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_6_sph[1], case_6_sph[0],
true);
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_11_sph[1], case_11_sph[0],
true);
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],
true);
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],
true);
}
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))", false);
test_geometry<ls, ring>("LINESTRING(11 0,11 10)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", false);
test_geometry<ls, poly>("LINESTRING(0 0,10 10)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", true);
test_geometry<ls, poly>("LINESTRING(5 0,5 5,10 5)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", true);
test_geometry<ls, poly>("LINESTRING(5 1,5 5,9 5)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", true);
test_geometry<ls, poly>("LINESTRING(11 1,11 5)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", false);
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))",
true);
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))",
true);
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::multi_linestring<ls> mls;
typedef bg::model::polygon<P> poly;
typedef bg::model::ring<P> ring;
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))",
true);
}
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)))",
true);
}
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)", true);
test_geometry<ls, ls>("LINESTRING(1 0,2 2,2 3)", "LINESTRING(0 0, 2 2, 3 2)", 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))",
true);
}
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))",
true);
test_geometry<P, poly>("POINT(-120 21)",
"POLYGON((30 0,30 30,90 30, 90 0, 30 0))",
false);
// extended
test_geometry<P, poly>("POINT(0 -90)",
"POLYGON((0 -80,90 -80, -180 -80, -90 -80, 0 -80))",
true);
test_geometry<P, poly>("POINT(0 89)",
"POLYGON((0 80,-90 80, -180 80, 90 80, 0 80))",
true);
test_geometry<P, poly>("POINT(-180 89)",
"POLYGON((0 80,-90 80, -180 80, 90 80, 0 80))",
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>();
}
int test_main( int , char* [] )
{
test_all<bg::model::point<double, 2, bg::cs::spherical_equatorial<bg::degree> > >();
#if defined(HAVE_TTMATH)
test_cs<bg::model::point<ttmath_big, 2, bg::cs::spherical_equatorial<bg::degree> > >();
#endif
return 0;
}

View File

@@ -0,0 +1,129 @@
// Boost.Geometry
// Copyright (c) 2016 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_within.hpp"
#include <boost/geometry/geometries/geometries.hpp>
template <typename Point>
void test_point_box_by_side()
{
// Test spherical boxes
// See also http://www.gcmap.com/mapui?P=1E45N-19E45N-19E55N-1E55N-1E45N,10E55.1N,10E45.1N
typedef bg::model::box<Point> box_t;
bg::strategy::within::point_in_box_by_side<Point, box_t> by_side;
box_t box;
bg::read_wkt("POLYGON((1 45,19 55))", box);
BOOST_CHECK_EQUAL(bg::within(Point(10, 55.1), box, by_side), true);
BOOST_CHECK_EQUAL(bg::within(Point(10, 55.2), box, by_side), true);
BOOST_CHECK_EQUAL(bg::within(Point(10, 55.3), box, by_side), true);
BOOST_CHECK_EQUAL(bg::within(Point(10, 55.4), box, by_side), false);
BOOST_CHECK_EQUAL(bg::within(Point(10, 45.1), box, by_side), false);
BOOST_CHECK_EQUAL(bg::within(Point(10, 45.2), box, by_side), false);
BOOST_CHECK_EQUAL(bg::within(Point(10, 45.3), box, by_side), false);
BOOST_CHECK_EQUAL(bg::within(Point(10, 45.4), box, by_side), true);
// By default Box is not a polygon in spherical CS, edges are defined by small circles
BOOST_CHECK_EQUAL(bg::within(Point(10, 45.1), box), true);
BOOST_CHECK_EQUAL(bg::within(Point(10, 54.9), box), true);
BOOST_CHECK_EQUAL(bg::within(Point(10, 55), box), false);
BOOST_CHECK_EQUAL(bg::within(Point(10, 45), box), false);
// Crossing the dateline (Near Tuvalu)
// http://www.gcmap.com/mapui?P=178E10S-178W10S-178W6S-178E6S-178E10S,180W5.999S,180E9.999S
// http://en.wikipedia.org/wiki/Tuvalu
box_t tuvalu(Point(178, -10), Point(-178, -6));
BOOST_CHECK_EQUAL(bg::within(Point(180, -8), tuvalu, by_side), true);
BOOST_CHECK_EQUAL(bg::within(Point(-180, -8), tuvalu, by_side), true);
BOOST_CHECK_EQUAL(bg::within(Point(180, -5.999), tuvalu, by_side), false);
BOOST_CHECK_EQUAL(bg::within(Point(180, -10.001), tuvalu, by_side), true);
// The above definition of a Box is not valid
// min should be lesser than max
// By default Box is not a polygon in spherical CS, edges are defined by small circles
box_t tuvalu2(Point(178, -10), Point(182, -6));
BOOST_CHECK_EQUAL(bg::within(Point(180, -8), tuvalu2), true);
BOOST_CHECK_EQUAL(bg::within(Point(-180, -8), tuvalu2), true);
BOOST_CHECK_EQUAL(bg::within(Point(180, -6.001), tuvalu2), true);
BOOST_CHECK_EQUAL(bg::within(Point(180, -5.999), tuvalu2), false);
BOOST_CHECK_EQUAL(bg::within(Point(180, -9.999), tuvalu2), true);
BOOST_CHECK_EQUAL(bg::within(Point(180, -10.001), tuvalu2), false);
}
template <typename P>
void test_point_box()
{
typedef bg::model::box<P> box_t;
test_geometry<P, box_t>("POINT(0 0)", "BOX(0 0, 1 1)", false);
test_geometry<P, box_t>("POINT(1 1)", "BOX(0 0, 2 2)", true);
test_geometry<P, box_t>("POINT(180 1)", "BOX(170 0, 190 2)", true);
test_geometry<P, box_t>("POINT(-180 1)", "BOX(170 0, 190 2)", true);
test_geometry<P, box_t>("POINT(180 1)", "BOX(170 0, 180 2)", false);
test_geometry<P, box_t>("POINT(-180 1)", "BOX(170 0, 180 2)", false);
test_geometry<P, box_t>("POINT(179 1)", "BOX(170 0, 190 2)", true);
test_geometry<P, box_t>("POINT(-179 1)", "BOX(170 0, 190 2)", true);
test_geometry<P, box_t>("POINT(179 1)", "BOX(170 0, 180 2)", true);
test_geometry<P, box_t>("POINT(-179 1)", "BOX(170 0, 180 2)", false);
test_geometry<P, box_t>("POINT(169 1)", "BOX(170 0, 180 2)", false);
test_point_box_by_side<P>();
}
template <typename P>
void test_box_box()
{
typedef bg::model::box<P> box_t;
test_geometry<box_t, box_t>("BOX(0 0, 1 1)", "BOX(0 0, 1 1)", true);
test_geometry<box_t, box_t>("BOX(-170 0,-160 1)", "BOX(-180 0, 180 1)", true);
test_geometry<box_t, box_t>("BOX(-170 0,-160 1)", "BOX(170 0, 200 1)", true);
test_geometry<box_t, box_t>("BOX(-170 0,-150 1)", "BOX(170 0, 200 1)", false);
test_geometry<box_t, box_t>("BOX(0 0,1 1)", "BOX(170 0, 370 1)", true);
test_geometry<box_t, box_t>("BOX(0 0,10 1)", "BOX(170 0, 370 1)", true);
test_geometry<box_t, box_t>("BOX(-180 0,10 1)", "BOX(170 0, 370 1)", true);
test_geometry<box_t, box_t>("BOX(-180 0,20 1)", "BOX(170 0, 370 1)", false);
test_geometry<box_t, box_t>("BOX(10 0,20 1)", "BOX(170 0, 370 1)", false);
test_geometry<box_t, box_t>("BOX(160 0,180 1)", "BOX(170 0, 370 1)", false);
test_geometry<box_t, box_t>("BOX(-180 0,-170 1)", "BOX(180 0, 190 1)", true); // invalid?
test_geometry<box_t, box_t>("BOX(-180 0,-170 1)", "BOX(180 0, 191 1)", true); // invalid?
test_geometry<box_t, box_t>("BOX(-180 0,-170 1)", "BOX(179 0, 190 1)", true);
test_geometry<box_t, box_t>("BOX(-180 0,-170 1)", "BOX(181 0, 190 1)", false); // invalid?
test_geometry<box_t, box_t>("BOX(-180 0,-170 1)", "BOX(180 0, 189 1)", false); // invalid?
}
template <typename P>
void test_cs()
{
test_point_box<P>();
test_box_box<P>();
}
int test_main( int , char* [] )
{
test_cs<bg::model::point<double, 2, bg::cs::spherical_equatorial<bg::degree> > >();
test_cs<bg::model::point<double, 2, bg::cs::geographic<bg::degree> > >();
#if defined(HAVE_TTMATH)
test_cs<bg::model::point<ttmath_big, 2, bg::cs::spherical_equatorial<bg::degree> > >();
test_cs<bg::model::point<ttmath_big, 2, bg::cs::geographic<bg::degree> > >();
#endif
return 0;
}