1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165
|
// 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> >();
test_all<bg::model::d2::point_xy<boost::rational<int> > >();
return 0;
}
|