mirror of
https://github.com/boostorg/geometry.git
synced 2025-05-09 23:24:02 +00:00
Merge pull request #1046 from vissarion/feature/covered_by_box_mpoly
Support covered_by() for box, geometry combinations
This commit is contained in:
commit
938f6f6bc1
@ -150,7 +150,7 @@
|
||||
</ul></div>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"><p><small>Last revised: December 02, 2021 at 14:43:30 GMT</small></p></td>
|
||||
<td align="left"><p><small>Last revised: July 28, 2022 at 11:11:09 GMT</small></p></td>
|
||||
<td align="right"><div class="copyright-footer"></div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
|
@ -2,13 +2,13 @@
|
||||
[table
|
||||
[[ ][Point][Segment][Box][Linestring][Ring][Polygon][MultiPoint][MultiLinestring][MultiPolygon][Variant]]
|
||||
[[Point][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]]
|
||||
[[Segment][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]]
|
||||
[[Box][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]]
|
||||
[[Linestring][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]]
|
||||
[[Ring][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ]]
|
||||
[[Polygon][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ]]
|
||||
[[MultiPoint][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]]
|
||||
[[MultiLinestring][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]]
|
||||
[[MultiPolygon][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ]]
|
||||
[[Segment][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]]
|
||||
[[Box][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ]]
|
||||
[[Linestring][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]]
|
||||
[[Ring][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ]]
|
||||
[[Polygon][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ]]
|
||||
[[MultiPoint][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]]
|
||||
[[MultiLinestring][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]]
|
||||
[[MultiPolygon][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ]]
|
||||
[[Variant][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]]
|
||||
]
|
||||
|
@ -7,6 +7,7 @@
|
||||
// This file was modified by Oracle on 2013-2022.
|
||||
// Modifications copyright (c) 2013-2022 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
|
||||
|
||||
// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
|
||||
@ -37,7 +38,8 @@ namespace detail { namespace covered_by {
|
||||
struct use_point_in_geometry
|
||||
{
|
||||
template <typename Geometry1, typename Geometry2, typename Strategy>
|
||||
static inline bool apply(Geometry1 const& geometry1, Geometry2 const& geometry2, Strategy const& strategy)
|
||||
static inline bool apply(Geometry1 const& geometry1, Geometry2 const& geometry2,
|
||||
Strategy const& strategy)
|
||||
{
|
||||
return detail::within::covered_by_point_geometry(geometry1, geometry2, strategy);
|
||||
}
|
||||
@ -46,7 +48,8 @@ struct use_point_in_geometry
|
||||
struct use_relate
|
||||
{
|
||||
template <typename Geometry1, typename Geometry2, typename Strategy>
|
||||
static inline bool apply(Geometry1 const& geometry1, Geometry2 const& geometry2, Strategy const& strategy)
|
||||
static inline bool apply(Geometry1 const& geometry1, Geometry2 const& geometry2,
|
||||
Strategy const& strategy)
|
||||
{
|
||||
return detail::relate::relate_impl
|
||||
<
|
||||
@ -57,6 +60,23 @@ struct use_relate
|
||||
}
|
||||
};
|
||||
|
||||
struct geometry_covered_by_box
|
||||
{
|
||||
template <typename Geometry, typename Box, typename Strategy>
|
||||
static inline bool apply(Geometry const& geometry, Box const& box, Strategy const& strategy)
|
||||
{
|
||||
using point_type = typename point_type<Geometry>::type;
|
||||
using mutable_point_type = typename helper_geometry<point_type>::type;
|
||||
using box_type = model::box<mutable_point_type>;
|
||||
|
||||
// TODO: this is not optimal since the process should be able to terminate if a point is found
|
||||
// outside of the box without computing the whole envelope
|
||||
box_type box_areal;
|
||||
geometry::envelope(geometry, box_areal, strategy);
|
||||
return strategy.covered_by(box_areal, box).apply(box_areal, box);
|
||||
}
|
||||
};
|
||||
|
||||
}} // namespace detail::covered_by
|
||||
#endif // DOXYGEN_NO_DETAIL
|
||||
|
||||
@ -64,28 +84,6 @@ struct use_relate
|
||||
namespace dispatch
|
||||
{
|
||||
|
||||
template <typename Point, typename Box>
|
||||
struct covered_by<Point, Box, point_tag, box_tag>
|
||||
{
|
||||
template <typename Strategy>
|
||||
static inline bool apply(Point const& point, Box const& box, Strategy const& strategy)
|
||||
{
|
||||
return strategy.covered_by(point, box).apply(point, box);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Box1, typename Box2>
|
||||
struct covered_by<Box1, Box2, box_tag, box_tag>
|
||||
{
|
||||
template <typename Strategy>
|
||||
static inline bool apply(Box1 const& box1, Box2 const& box2, Strategy const& strategy)
|
||||
{
|
||||
assert_dimension_equal<Box1, Box2>();
|
||||
return strategy.covered_by(box1, box2).apply(box1, box2);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// P/P
|
||||
|
||||
template <typename Point1, typename Point2>
|
||||
@ -273,6 +271,76 @@ struct covered_by<MultiPolygon1, MultiPolygon2, multi_polygon_tag, multi_polygon
|
||||
: public detail::covered_by::use_relate
|
||||
{};
|
||||
|
||||
// B/A
|
||||
|
||||
template <typename Box, typename Polygon>
|
||||
struct covered_by<Box, Polygon, box_tag, ring_tag>
|
||||
: public detail::covered_by::use_relate
|
||||
{};
|
||||
|
||||
template <typename Box, typename Polygon>
|
||||
struct covered_by<Box, Polygon, box_tag, polygon_tag>
|
||||
: public detail::covered_by::use_relate
|
||||
{};
|
||||
|
||||
template <typename Box, typename Polygon>
|
||||
struct covered_by<Box, Polygon, box_tag, multi_polygon_tag>
|
||||
: public detail::covered_by::use_relate
|
||||
{};
|
||||
|
||||
// Geometry/Box
|
||||
|
||||
template <typename Point, typename Box>
|
||||
struct covered_by<Point, Box, point_tag, box_tag>
|
||||
{
|
||||
template <typename Strategy>
|
||||
static inline bool apply(Point const& point, Box const& box, Strategy const& strategy)
|
||||
{
|
||||
return strategy.covered_by(point, box).apply(point, box);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename MultiPoint, typename Box>
|
||||
struct covered_by<MultiPoint, Box, multi_point_tag, box_tag>
|
||||
: public detail::covered_by::geometry_covered_by_box
|
||||
{};
|
||||
|
||||
template <typename Linestring, typename Box>
|
||||
struct covered_by<Linestring, Box, linestring_tag, box_tag>
|
||||
: public detail::covered_by::geometry_covered_by_box
|
||||
{};
|
||||
|
||||
template <typename MultiLinestring, typename Box>
|
||||
struct covered_by<MultiLinestring, Box, multi_linestring_tag, box_tag>
|
||||
: public detail::covered_by::geometry_covered_by_box
|
||||
{};
|
||||
|
||||
template <typename Ring, typename Box>
|
||||
struct covered_by<Ring, Box, ring_tag, box_tag>
|
||||
: public detail::covered_by::geometry_covered_by_box
|
||||
{};
|
||||
|
||||
template <typename Polygon, typename Box>
|
||||
struct covered_by<Polygon, Box, polygon_tag, box_tag>
|
||||
: public detail::covered_by::geometry_covered_by_box
|
||||
{};
|
||||
|
||||
template <typename MultiPolygon, typename Box>
|
||||
struct covered_by<MultiPolygon, Box, multi_polygon_tag, box_tag>
|
||||
: public detail::covered_by::geometry_covered_by_box
|
||||
{};
|
||||
|
||||
template <typename Box1, typename Box2>
|
||||
struct covered_by<Box1, Box2, box_tag, box_tag>
|
||||
{
|
||||
template <typename Strategy>
|
||||
static inline bool apply(Box1 const& box1, Box2 const& box2, Strategy const& strategy)
|
||||
{
|
||||
assert_dimension_equal<Box1, Box2>();
|
||||
return strategy.covered_by(box1, box2).apply(box1, box2);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace dispatch
|
||||
#endif // DOXYGEN_NO_DISPATCH
|
||||
|
||||
|
@ -0,0 +1,70 @@
|
||||
// Boost.Geometry
|
||||
|
||||
// Copyright (c) 2022, Oracle and/or its affiliates.
|
||||
|
||||
// Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
|
||||
|
||||
// Licensed under the Boost Software License version 1.0.
|
||||
// http://www.boost.org/users/license.html
|
||||
|
||||
#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_RELATE_BOX_AREAL_HPP
|
||||
#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_RELATE_BOX_AREAL_HPP
|
||||
|
||||
#include <boost/geometry/algorithms/detail/relate/areal_areal.hpp>
|
||||
#include <boost/geometry/views/box_view.hpp>
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail { namespace relate {
|
||||
|
||||
|
||||
// The implementation of an algorithm calculating relate() for B/A
|
||||
template <typename Box, typename Areal>
|
||||
struct box_areal
|
||||
{
|
||||
static const bool interruption_enabled = true;
|
||||
|
||||
template <typename Result, typename Strategy>
|
||||
static inline void apply(Box const& box, Areal const& areal,
|
||||
Result& result,
|
||||
Strategy const& strategy)
|
||||
{
|
||||
using is_cartesian = std::is_same
|
||||
<
|
||||
typename Strategy::cs_tag,
|
||||
cartesian_tag
|
||||
>;
|
||||
apply(box, areal, result, strategy, is_cartesian());
|
||||
}
|
||||
|
||||
template <typename Result, typename Strategy>
|
||||
static inline void apply(Box const& box, Areal const& areal,
|
||||
Result& result,
|
||||
Strategy const& strategy,
|
||||
std::true_type /*is_cartesian*/)
|
||||
{
|
||||
using box_view = boost::geometry::box_view<Box>;
|
||||
box_view view(box);
|
||||
areal_areal<box_view, Areal>::apply(view, areal, result, strategy);
|
||||
}
|
||||
|
||||
template <typename Result, typename Strategy>
|
||||
static inline void apply(Box const& box, Areal const& areal,
|
||||
Result& result,
|
||||
Strategy const& strategy,
|
||||
std::false_type /*is_cartesian*/)
|
||||
{
|
||||
BOOST_GEOMETRY_STATIC_ASSERT_FALSE(
|
||||
"Not implemented for this coordinate system.",
|
||||
typename Strategy::cs_tag());
|
||||
}
|
||||
};
|
||||
|
||||
}} // namespace detail::relate
|
||||
#endif // DOXYGEN_NO_DETAIL
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_RELATE_BOX_AREAL_HPP
|
@ -15,6 +15,7 @@
|
||||
|
||||
|
||||
#include <boost/geometry/algorithms/detail/relate/areal_areal.hpp>
|
||||
#include <boost/geometry/algorithms/detail/relate/box_areal.hpp>
|
||||
#include <boost/geometry/algorithms/detail/relate/interface.hpp>
|
||||
#include <boost/geometry/algorithms/detail/relate/linear_areal.hpp>
|
||||
#include <boost/geometry/algorithms/detail/relate/linear_linear.hpp>
|
||||
@ -115,6 +116,22 @@ struct relate<Areal1, Areal2, Tag1, Tag2, 2, 2, true>
|
||||
{};
|
||||
|
||||
|
||||
template <typename Box, typename Ring>
|
||||
struct relate<Box, Ring, box_tag, ring_tag, 2, 2, false>
|
||||
: detail::relate::box_areal<Box, Ring>
|
||||
{};
|
||||
|
||||
template <typename Box, typename Polygon>
|
||||
struct relate<Box, Polygon, box_tag, polygon_tag, 2, 2, false>
|
||||
: detail::relate::box_areal<Box, Polygon>
|
||||
{};
|
||||
|
||||
template <typename Box, typename MultiPolygon>
|
||||
struct relate<Box, MultiPolygon, box_tag, multi_polygon_tag, 2, 2, false>
|
||||
: detail::relate::box_areal<Box, MultiPolygon>
|
||||
{};
|
||||
|
||||
|
||||
} // namespace dispatch
|
||||
#endif // DOXYGEN_NO_DISPATCH
|
||||
|
||||
|
@ -18,7 +18,6 @@ test-suite boost-geometry-algorithms-covered_by
|
||||
:
|
||||
[ run covered_by.cpp : : : : algorithms_covered_by ]
|
||||
[ run covered_by_gc.cpp : : : : algorithms_covered_by_gc ]
|
||||
[ 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 ]
|
||||
;
|
||||
|
@ -3,9 +3,10 @@
|
||||
// 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.
|
||||
// This file was modified by Oracle on 2015, 2017, 2022.
|
||||
// Modifications copyright (c) 2017-2022 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,
|
||||
@ -22,106 +23,131 @@
|
||||
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);
|
||||
|
||||
*/
|
||||
using seg = bg::model::segment<P>;
|
||||
|
||||
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);
|
||||
test_geometry<P, mpt<P>>("POINT(0 0)", "MULTIPOINT(0 0, 1 1)", true);
|
||||
test_geometry<mpt<P>, P>("MULTIPOINT(0 0, 1 1)", "POINT(1 1)", false);
|
||||
test_geometry<mpt<P>, mpt<P>>("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);
|
||||
test_geometry<P, ls<P>>("POINT(0 0)", "LINESTRING(0 0,1 1,2 2)", true);
|
||||
test_geometry<P, ls<P>>("POINT(3 3)", "LINESTRING(0 0,1 1,2 2)", false);
|
||||
test_geometry<P, ls<P>>("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);
|
||||
test_geometry<P, mls<P>>("POINT(0 0)", "MULTILINESTRING((0 0,1 1,2 2),(0 0,0 1))", true);
|
||||
test_geometry<P, mls<P>>("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);
|
||||
test_geometry<mpt<P>, 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);
|
||||
test_geometry<mpt<P>, ls<P>>("MULTIPOINT(0 0, 2 2)", "LINESTRING(0 0, 2 2)", true);
|
||||
test_geometry<mpt<P>, ls<P>>("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);
|
||||
test_geometry<mpt<P>, mls<P>>("MULTIPOINT(0 0, 1 1)", "MULTILINESTRING((0 0, 2 2),(2 2, 3 3))", true);
|
||||
test_geometry<mpt<P>, mls<P>>("MULTIPOINT(0 0, 2 2)", "MULTILINESTRING((0 0, 2 2),(2 2, 3 3))", true);
|
||||
test_geometry<mpt<P>, mls<P>>("MULTIPOINT(0 0, 3 3)", "MULTILINESTRING((0 0, 2 2),(2 2, 3 3))", true);
|
||||
test_geometry<mpt<P>, mls<P>>("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);
|
||||
test_geometry<P, ring<P>>("POINT(1 1)", "POLYGON((0 0,0 2,2 2,2 0,0 0))", true);
|
||||
test_geometry<P, poly<P>>("POINT(1 1)", "POLYGON((0 0,0 2,2 2,2 0,0 0))", true);
|
||||
test_geometry<P, mpoly<P>>("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);
|
||||
|
||||
// on border/corner
|
||||
test_geometry<P, poly<P>>("POINT(0 0)", "POLYGON((0 0,0 2,2 2,2 0,0 0))", true);
|
||||
test_geometry<P, poly<P>>("POINT(0 1)", "POLYGON((0 0,0 2,2 2,2 0,0 0))", true);
|
||||
|
||||
// aligned to segment/vertex
|
||||
test_geometry<P, poly<P>>("POINT(1 1)", "POLYGON((0 0,0 3,3 3,3 1,2 1,2 0,0 0))", true);
|
||||
test_geometry<P, poly<P>>("POINT(1 1)", "POLYGON((0 0,0 3,4 3,3 1,2 2,2 0,0 0))", true);
|
||||
|
||||
// same polygon, but point on border
|
||||
test_geometry<P, poly<P>>("POINT(3 3)", "POLYGON((0 0,0 3,3 3,3 1,2 1,2 0,0 0))", true);
|
||||
test_geometry<P, poly<P>>("POINT(3 3)", "POLYGON((0 0,0 3,4 3,3 1,2 2,2 0,0 0))", 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 multi-with-one-polygon (trivial case)
|
||||
test_geometry<P, mpoly<P>>("POINT(1 1)", "MULTIPOLYGON(((0 0,0 2,2 2,2 0,0 0)))", true);
|
||||
test_geometry<P, mpoly<P>>("POINT(3 3)", "MULTIPOLYGON(((0 0,0 2,2 2,2 0,0 0)))", false);
|
||||
test_geometry<P, mpoly<P>>("POINT(0 1)", "MULTIPOLYGON(((0 0,0 2,2 2,2 0,0 0)))", true);
|
||||
test_geometry<P, mpoly<P>>("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, mpoly<P>>("POINT(4 4)", multi, true);
|
||||
test_geometry<P, mpoly<P>>("POINT(1 1)", multi, true);
|
||||
test_geometry<P, mpoly<P>>("POINT(0 1)", multi, 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);
|
||||
test_geometry<mpt<P>, ring<P>>("MULTIPOINT(0 0, 1 1)", "POLYGON((0 0,0 2,2 2,2 0,0 0))", true);
|
||||
test_geometry<mpt<P>, poly<P>>("MULTIPOINT(0 0, 2 2)", "POLYGON((0 0,0 2,2 2,2 0,0 0))", true);
|
||||
test_geometry<mpt<P>, poly<P>>("MULTIPOINT(1 1, 3 3)", "POLYGON((0 0,0 2,2 2,2 0,0 0))", false);
|
||||
test_geometry<mpt<P>, mpoly<P>>("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<P>, mpoly<P>>("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<P>, mpoly<P>>("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<P>, mpoly<P>>("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<P>>("POINT(1 1)", "BOX(0 0,2 2)", true);
|
||||
test_geometry<P, box<P>>("POINT(0 0)", "BOX(0 0,2 2)", true);
|
||||
test_geometry<P, box<P>>("POINT(2 2)", "BOX(0 0,2 2)", true);
|
||||
test_geometry<P, box<P>>("POINT(0 1)", "BOX(0 0,2 2)", true);
|
||||
test_geometry<P, box<P>>("POINT(1 0)", "BOX(0 0,2 2)", true);
|
||||
test_geometry<P, box<P>>("POINT(3 3)", "BOX(0 0,2 2)", false);
|
||||
|
||||
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<mpt<P>, box<P>>("MULTIPOINT(1 1, 2 1)", "BOX(0 0,3 3)", true);
|
||||
test_geometry<mpt<P>, box<P>>("MULTIPOINT(0 0, 1 1)", "BOX(0 0,2 2)", true);
|
||||
test_geometry<mpt<P>, box<P>>("MULTIPOINT(0 0, 3 4)", "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);
|
||||
test_geometry<ls<P>, box<P>>("LINESTRING(0 0,1 1,1 2)", "BOX(0 0,2 2)", true);
|
||||
test_geometry<ls<P>, box<P>>("LINESTRING(0 0,1 1,1 2,1 3)", "BOX(0 0,2 2)", false);
|
||||
test_geometry<mls<P>, box<P>>("MULTILINESTRING((0 0,1 1,1 2),(0 1,1 0))", "BOX(0 0,2 2)", true);
|
||||
test_geometry<mls<P>, box<P>>("MULTILINESTRING((0 0,1 1,1 2,1 3),(0 1,1 0))", "BOX(0 0,2 2)", false);
|
||||
|
||||
test_geometry<ring<P>, box<P>>("POLYGON((0 0,0 3,3 3,3 0,0 0))", "BOX(0 0,4 4)", true);
|
||||
test_geometry<ring<P>, box<P>>("POLYGON((0 0,0 3,3 3,5 0,0 0))", "BOX(0 0,4 4)", false);
|
||||
test_geometry<poly<P>, box<P>>("POLYGON((0 0,0 3,3 3,3 0,0 0))", "BOX(0 0,4 4)", true);
|
||||
test_geometry<poly<P>, box<P>>("POLYGON((0 0,0 3,3 3,5 0,0 0))", "BOX(0 0,4 4)", false);
|
||||
test_geometry<mpoly<P>, box<P>>("MULTIPOLYGON(((0 0,0 3,3 3,3 0,0 0)),((4 4,4 7,7 7,4 7,4 4)))", "BOX(0 0,7 7)", true);
|
||||
test_geometry<mpoly<P>, box<P>>("MULTIPOLYGON(((0 0,0 3,3 3,5 0,0 0)),((4 4,4 7,7 7,4 7,4 4)))", "BOX(0 0,4 4)", false);
|
||||
|
||||
test_geometry<box<P>, box<P>>("BOX(1 1,2 2)", "BOX(0 0,3 3)", true);
|
||||
test_geometry<box<P>, box<P>>("BOX(0 0,3 3)", "BOX(1 1,2 2)", false);
|
||||
test_geometry<box<P>, box<P>>("BOX(0 0,2 2)", "BOX(0 0,3 3)", true);
|
||||
test_geometry<box<P>, box<P>>("BOX(1 1,3 3)", "BOX(0 0,3 3)", true);
|
||||
test_geometry<box<P>, box<P>>("BOX(1 2,3 3)", "BOX(0 0,3 3)", true);
|
||||
test_geometry<box<P>, box<P>>("BOX(1 1,4 3)", "BOX(0 0,3 3)", false);
|
||||
|
||||
test_geometry<box<P>, ring<P>>("BOX(1 1,2 2)", "POLYGON((0 0,0 3,3 3,3 0,0 0))", true);
|
||||
test_geometry<box<P>, ring<P>>("BOX(1 1,2 2)", "POLYGON((0 0,0 3,3 1,1 0,0 0))", false);
|
||||
test_geometry<box<P>, poly<P>>("BOX(1 1,2 2)", "POLYGON((0 0,0 3,3 3,3 0,0 0))", true);
|
||||
test_geometry<box<P>, poly<P>>("BOX(1 1,2 2)", "POLYGON((0 0,0 3,3 1,1 0,0 0))", false);
|
||||
test_geometry<box<P>, mpoly<P>>("BOX(1 1,2 2)", "MULTIPOLYGON(((0 0,0 3,3 3,3 0,0 0)),((-1 -1,-3 -4,-7 -7,-4 -3,-1 -1)))", true);
|
||||
test_geometry<box<P>, mpoly<P>>("BOX(1 1,2 2)", "MULTIPOLYGON(((0 0,0 3,3 1,1 0,0 0)),((-1 -1,-3 -4,-7 -7,-4 -3,-1 -1)))", 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));
|
||||
using point_type = boost::geometry::model::point<double, 3, boost::geometry::cs::cartesian>;
|
||||
box<point_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);
|
||||
@ -131,18 +157,13 @@ void test_3d()
|
||||
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;
|
||||
poly<P1> poly1;
|
||||
poly<P2> 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));
|
||||
box<P1> box1(P1(1, 1), P1(4, 4));
|
||||
box<P2> box2(P2(0, 0), P2(5, 5));
|
||||
P1 p1(3, 3);
|
||||
P2 p2(3, 3);
|
||||
|
||||
@ -152,6 +173,12 @@ void test_mixed_of()
|
||||
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);
|
||||
|
||||
// TODO: the following does not compile due to incompatible coordinate types
|
||||
// (probably needed by overlay)
|
||||
//BOOST_CHECK_EQUAL(bg::covered_by(poly1, poly2), true);
|
||||
//BOOST_CHECK_EQUAL(bg::covered_by(box1, poly1), true);
|
||||
//BOOST_CHECK_EQUAL(bg::covered_by(box2, poly1), true);
|
||||
}
|
||||
|
||||
|
||||
@ -181,8 +208,6 @@ 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();
|
||||
|
||||
|
@ -1,52 +0,0 @@
|
||||
// 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> >();
|
||||
|
||||
return 0;
|
||||
}
|
@ -14,277 +14,210 @@
|
||||
|
||||
#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<P>, ring<P>>(case_1[0], case_1[1], false);
|
||||
test_geometry<ring<P>, poly<P>>(case_1[0], case_1[1], false);
|
||||
|
||||
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<P>, poly<P>>(case_1[0], case_1[1], false);
|
||||
test_geometry<poly<P>, poly<P>>(case_2[0], case_2[1], false);
|
||||
test_geometry<poly<P>, poly<P>>(case_3_sph[0], case_3_sph[1], true);
|
||||
test_geometry<poly<P>, poly<P>>(case_3_2_sph[0], case_3_2_sph[1], true);
|
||||
test_geometry<poly<P>, poly<P>>(case_4[0], case_4[1], false);
|
||||
test_geometry<poly<P>, poly<P>>(case_5[0], case_5[1], false);
|
||||
test_geometry<poly<P>, poly<P>>(case_6_sph[0], case_6_sph[1], false);
|
||||
test_geometry<poly<P>, poly<P>>(case_6_sph[1], case_6_sph[0], true);
|
||||
|
||||
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<P>, poly<P>>(case_7[0], case_7[1], false);
|
||||
test_geometry<poly<P>, poly<P>>(case_8_sph[0], case_8_sph[1], false);
|
||||
test_geometry<poly<P>, poly<P>>(case_9_sph[0], case_9_sph[1], false);
|
||||
test_geometry<poly<P>, poly<P>>(case_10_sph[0], case_10_sph[1], false);
|
||||
test_geometry<poly<P>, poly<P>>(case_11_sph[0], case_11_sph[1], false);
|
||||
test_geometry<poly<P>, poly<P>>(case_11_sph[1], case_11_sph[0], true);
|
||||
test_geometry<poly<P>, poly<P>>(case_12[0], case_12[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_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);
|
||||
test_geometry<poly<P>, poly<P>>(case_13_sph[0], case_13_sph[1], false);
|
||||
test_geometry<poly<P>, poly<P>>(case_14_sph[0], case_14_sph[1], false);
|
||||
test_geometry<poly<P>, poly<P>>(case_15_sph[0], case_15_sph[1], false);
|
||||
test_geometry<poly<P>, poly<P>>(case_16_sph[0], case_16_sph[1], false);
|
||||
test_geometry<poly<P>, poly<P>>(case_17_sph[0], case_17_sph[1], false);
|
||||
test_geometry<poly<P>, poly<P>>(case_17_sph[1], case_17_sph[0], true);
|
||||
test_geometry<poly<P>, poly<P>>(case_18_sph[0], case_18_sph[1], false);
|
||||
test_geometry<poly<P>, poly<P>>(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);
|
||||
test_geometry<ring<P>, mpoly<P>>(case_1[0], case_multi_2[0], false);
|
||||
test_geometry<poly<P>, mpoly<P>>(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);
|
||||
test_geometry<mpoly<P>, mpoly<P>>(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<P>, poly<P>>("LINESTRING(11 0,11 10)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", false);
|
||||
test_geometry<ls<P>, ring<P>>("LINESTRING(11 0,11 10)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", false);
|
||||
test_geometry<ls<P>, poly<P>>("LINESTRING(0 0,10 10)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", true);
|
||||
test_geometry<ls<P>, poly<P>>("LINESTRING(5 0,5 5,10 5)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", true);
|
||||
test_geometry<ls<P>, poly<P>>("LINESTRING(5 1,5 5,9 5)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", true);
|
||||
test_geometry<ls<P>, poly<P>>("LINESTRING(11 1,11 5)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", false);
|
||||
|
||||
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<P>, poly<P>>("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)",
|
||||
"POLYGON((0 0,0 10,10 10,10 0,0 0),(10 5,2 8,2 2,10 5))",
|
||||
true);
|
||||
test_geometry<ls<P>, poly<P>>("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(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);
|
||||
test_geometry<ls<P>, poly<P>>("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);
|
||||
test_geometry<ls<P>, mpoly<P>>("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<P>, poly<P>>("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, 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<P>, ring<P>>("MULTILINESTRING((6 6,15 15),(0 0, 7 7))",
|
||||
"POLYGON((5 5,5 15,15 15,15 5,5 5))",
|
||||
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);
|
||||
test_geometry<mls<P>, poly<P>>("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<P>, mpoly<P>>("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,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<P>, mpoly<P>>("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((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);
|
||||
test_geometry<mls<P>, mpoly<P>>("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<P>, ls<P>>("LINESTRING(0 0, 2 2, 3 2)", "LINESTRING(0 0, 2 2, 3 2)", true);
|
||||
|
||||
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);
|
||||
test_geometry<ls<P>, ls<P>>("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<P>, mls<P>>("LINESTRING(0 0,10 0)",
|
||||
"MULTILINESTRING((1 0,2 0),(1 1,2 1))",
|
||||
false);
|
||||
|
||||
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);
|
||||
test_geometry<ls<P>, mls<P>>("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);
|
||||
test_geometry<mls<P>, mls<P>>("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);
|
||||
test_geometry<P, poly<P>>("POINT(0 90)",
|
||||
"POLYGON((0 80,-90 80, -180 80, 90 80, 0 80))",
|
||||
true);
|
||||
test_geometry<P, poly<P>>("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);
|
||||
test_geometry<P, poly<P>>("POINT(0 90)",
|
||||
"POLYGON((0 80, 0 81, -90 80, -180 80, 90 80, 0 80))",
|
||||
true);
|
||||
test_geometry<P, poly<P>>("POINT(0 90)",
|
||||
"POLYGON((0 80, -90 80, -90 81, -180 80, 90 80, 0 80))",
|
||||
true);
|
||||
test_geometry<P, poly<P>>("POINT(0 89)",
|
||||
"POLYGON((0 80,-90 80, -180 80, 90 80, 0 80))",
|
||||
true);
|
||||
test_geometry<P, poly<P>>("POINT(-180 89)",
|
||||
"POLYGON((0 80,-90 80, -180 80, 90 80, 0 80))",
|
||||
true);
|
||||
test_geometry<P, poly<P>>("POINT(0 -90)",
|
||||
"POLYGON((0 -80,90 -80, -180 -80, -90 -80, 0 -80))",
|
||||
true);
|
||||
test_geometry<P, poly<P>>("POINT(0 -89)",
|
||||
"POLYGON((0 -80,90 -80, -180 -80, -90 -80, 0 -80))",
|
||||
true);
|
||||
test_geometry<P, poly<P>>("POINT(1 -90)",
|
||||
"POLYGON((0 -80,90 -80, -180 -80, -90 -80, 0 -80))",
|
||||
true);
|
||||
test_geometry<P, poly<P>>("POINT(1 -89)",
|
||||
"POLYGON((0 -80,90 -80, -180 -80, -90 -80, 0 -80))",
|
||||
true);
|
||||
test_geometry<P, poly<P>>("POINT(1 90)",
|
||||
"POLYGON((0 80,-90 80, -180 80, 90 80, 0 80))",
|
||||
true);
|
||||
test_geometry<P, poly<P>>("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);
|
||||
test_geometry<P, poly<P>>("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);
|
||||
test_geometry<P, poly<P>>("POINT(179 0)",
|
||||
"POLYGON((0 0, 0 2, 2 0, 0 -2, 0 0))",
|
||||
false);
|
||||
test_geometry<P, poly<P>>("POINT(180 0)",
|
||||
"POLYGON((0 0, 0 2, 2 0, 0 -2, 0 0))",
|
||||
false);
|
||||
test_geometry<P, poly<P>>("POINT(-179 0)",
|
||||
"POLYGON((-10 -10, -10 10, 10 10, 10 -10, -10 10))",
|
||||
false);
|
||||
test_geometry<P, poly<P>>("POINT(179 0)",
|
||||
"POLYGON((-10 -10, -10 10, 10 10, 10 -10, -10 10))",
|
||||
false);
|
||||
test_geometry<P, poly<P>>("POINT(-179 0)",
|
||||
"POLYGON((0 0, 0 1, 1 0, 0 -1, 0 0))",
|
||||
false);
|
||||
test_geometry<P, poly<P>>("POINT(179 0)",
|
||||
"POLYGON((0 0, 0 1, 1 0, 0 -1, 0 0))",
|
||||
false);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
// Boost.Geometry
|
||||
|
||||
// Copyright (c) 2016-2021 Oracle and/or its affiliates.
|
||||
// Copyright (c) 2016-2022 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,
|
||||
@ -16,67 +18,88 @@
|
||||
template <typename P>
|
||||
void test_point_box()
|
||||
{
|
||||
typedef bg::model::box<P> box_t;
|
||||
test_geometry<P, box<P>>("POINT(0 0)", "BOX(0 0, 1 1)", true);
|
||||
test_geometry<P, box<P>>("POINT(1 1)", "BOX(0 0, 2 2)", true);
|
||||
|
||||
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);
|
||||
test_geometry<P, box<P>>("POINT(180 1)", "BOX(170 0, 190 2)", true);
|
||||
test_geometry<P, box<P>>("POINT(-180 1)", "BOX(170 0, 190 2)", true);
|
||||
test_geometry<P, box<P>>("POINT(180 1)", "BOX(170 0, 180 2)", true);
|
||||
test_geometry<P, box<P>>("POINT(-180 1)", "BOX(170 0, 180 2)", true);
|
||||
test_geometry<P, box<P>>("POINT(179 1)", "BOX(170 0, 190 2)", true);
|
||||
test_geometry<P, box<P>>("POINT(-179 1)", "BOX(170 0, 190 2)", true);
|
||||
test_geometry<P, box<P>>("POINT(179 1)", "BOX(170 0, 180 2)", true);
|
||||
test_geometry<P, box<P>>("POINT(-179 1)", "BOX(170 0, 180 2)", false);
|
||||
test_geometry<P, box<P>>("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);
|
||||
test_geometry<P, box<P>>("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<P>>("POINT(-2.08882 51.7)", "BOX(-2.08882 51.5034, -0.127592 51.9074)", true);
|
||||
test_geometry<P, box<P>>("POINT(0.127592 51.7)", "BOX(0.127592 51.5034, 2.08882 51.9074)", true);
|
||||
test_geometry<P, box<P>>("POINT(2.08882 51.7)", "BOX(0.127592 51.5034, 2.08882 51.9074)", true);
|
||||
|
||||
test_geometry<P, box<P>>("POINT(179.08882 1)", "BOX(179.08882 0, 538.127592 2)", true);
|
||||
test_geometry<P, box<P>>("POINT(178.127592 1)", "BOX(179.08882 0, 538.127592 2)", true);
|
||||
test_geometry<P, box<P>>("POINT(179.08882 1)", "BOX(179.08882 0, 182.127592 2)", true);
|
||||
test_geometry<P, box<P>>("POINT(-177.872408 1)", "BOX(179.08882 0, 182.127592 2)", true);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
void test_multi_point_box()
|
||||
{
|
||||
test_geometry<mpt<P>, box<P>>("MULTIPOINT(0 0,1 1)", "BOX(0 0, 1 1)", true);
|
||||
test_geometry<mpt<P>, box<P>>("MULTIPOINT(1 1,3 3)", "BOX(0 0, 2 2)", false);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
void test_areal_box()
|
||||
{
|
||||
test_geometry<ring<P>, box<P>>("POLYGON((0 0,0 3,3 3,3 0,0 0))", "BOX(0 0,4 4)", true);
|
||||
test_geometry<ring<P>, box<P>>("POLYGON((0 0,0 3,3 3,5 0,0 0))", "BOX(0 0,4 4)", false);
|
||||
test_geometry<poly<P>, box<P>>("POLYGON((0 0,0 3,3 3,3 0,0 0))", "BOX(0 0,4 4)", true);
|
||||
test_geometry<poly<P>, box<P>>("POLYGON((0 0,0 3,3 3,5 0,0 0))", "BOX(0 0,4 4)", false);
|
||||
// the following is true for cartesian but not for spherical or geographic
|
||||
// because in non-cartesian boxes the horizontal edges are not geodesics
|
||||
test_geometry<mpoly<P>, box<P>>("MULTIPOLYGON(((0 0,0 3,3 3,3 0,0 0)),((4 4,4 7,7 7,4 7,4 4)))",
|
||||
"BOX(0 0,7 7)", false);
|
||||
test_geometry<mpoly<P>, box<P>>("MULTIPOLYGON(((0 0,0 3,3 3,3 0,0 0)),((4 4,4 6.5,6.5 6.5,4 6.5,4 4)))",
|
||||
"BOX(0 0,7 7)", true);
|
||||
test_geometry<mpoly<P>, box<P>>("MULTIPOLYGON(((0 0,0 3,3 3,5 0,0 0)),((4 4,4 7,7 7,4 7,4 4)))",
|
||||
"BOX(0 0,4 4)", false);
|
||||
|
||||
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<P>, box<P>>("BOX(0 0, 1 1)", "BOX(0 0, 1 1)", true);
|
||||
|
||||
test_geometry<box_t, box_t>("BOX(0 0, 1 1)", "BOX(0 0, 1 1)", true);
|
||||
test_geometry<box<P>, box<P>>("BOX(-170 0,-160 1)", "BOX(-180 0, 180 1)", true);
|
||||
test_geometry<box<P>, box<P>>("BOX(-170 0,-160 1)", "BOX(170 0, 200 1)", true);
|
||||
test_geometry<box<P>, box<P>>("BOX(-170 0,-150 1)", "BOX(170 0, 200 1)", false);
|
||||
test_geometry<box<P>, box<P>>("BOX(0 0,1 1)", "BOX(170 0, 370 1)", true);
|
||||
test_geometry<box<P>, box<P>>("BOX(0 0,10 1)", "BOX(170 0, 370 1)", true);
|
||||
test_geometry<box<P>, box<P>>("BOX(-180 0,10 1)", "BOX(170 0, 370 1)", true);
|
||||
test_geometry<box<P>, box<P>>("BOX(-180 0,20 1)", "BOX(170 0, 370 1)", false);
|
||||
test_geometry<box<P>, box<P>>("BOX(10 0,20 1)", "BOX(170 0, 370 1)", false);
|
||||
test_geometry<box<P>, box<P>>("BOX(160 0,180 1)", "BOX(170 0, 370 1)", false);
|
||||
|
||||
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?
|
||||
test_geometry<box<P>, box<P>>("BOX(-180 0,-170 1)", "BOX(180 0, 190 1)", true); // invalid?
|
||||
test_geometry<box<P>, box<P>>("BOX(-180 0,-170 1)", "BOX(180 0, 191 1)", true); // invalid?
|
||||
test_geometry<box<P>, box<P>>("BOX(-180 0,-170 1)", "BOX(179 0, 190 1)", true);
|
||||
test_geometry<box<P>, box<P>>("BOX(-180 0,-170 1)", "BOX(181 0, 190 1)", false); // invalid?
|
||||
test_geometry<box<P>, box<P>>("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<P>, box<P>>("BOX(-1.346346 51.6, -0.127592 51.7)", "BOX(-2.08882 51.5034, -0.127592 51.9074)", true);
|
||||
test_geometry<box<P>, box<P>>("BOX(-2.08882 51.6, -1.346346 51.7)", "BOX(-2.08882 51.5034, -0.127592 51.9074)", true);
|
||||
test_geometry<box<P>, box<P>>("BOX(0.127592 51.6, 1.346346 51.7)", "BOX(0.127592 51.5034, 2.08882 51.9074)", true);
|
||||
test_geometry<box<P>, box<P>>("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);
|
||||
test_geometry<box<P>, box<P>>("BOX(179.08882 1, 180.0 1)", "BOX(179.08882 0, 538.127592 2)", true);
|
||||
test_geometry<box<P>, box<P>>("BOX(177.0 1, 178.127592 1)", "BOX(179.08882 0, 538.127592 2)", true);
|
||||
test_geometry<box<P>, box<P>>("BOX(179.08882 1, 179.9 1)", "BOX(179.08882 0, 182.127592 2)", true);
|
||||
test_geometry<box<P>, box<P>>("BOX(-179.9 1, -177.872408 1)", "BOX(179.08882 0, 182.127592 2)", true);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
@ -89,7 +112,7 @@ void test_point_polygon()
|
||||
bg::strategy::within::spherical_winding<P>
|
||||
> s;
|
||||
|
||||
typedef bg::model::polygon<P> poly;
|
||||
using poly = bg::model::polygon<P>;
|
||||
|
||||
// MySQL report 08.2017
|
||||
test_geometry<P, poly>("POINT(-179 0)",
|
||||
@ -113,6 +136,8 @@ template <typename P>
|
||||
void test_cs()
|
||||
{
|
||||
test_point_box<P>();
|
||||
test_multi_point_box<P>();
|
||||
test_areal_box<P>();
|
||||
test_box_box<P>();
|
||||
test_point_polygon<P>();
|
||||
}
|
||||
|
@ -30,6 +30,28 @@
|
||||
#include <boost/geometry/io/wkt/read.hpp>
|
||||
#include <boost/geometry/strategies/strategies.hpp>
|
||||
|
||||
template <typename P>
|
||||
using ls = bg::model::linestring<P>;
|
||||
|
||||
template <typename P>
|
||||
using box = bg::model::box<P>;
|
||||
|
||||
template <typename P>
|
||||
using ring = bg::model::ring<P>;
|
||||
|
||||
template <typename P>
|
||||
using poly = bg::model::polygon<P>;
|
||||
|
||||
template <typename P>
|
||||
using mpt = bg::model::multi_point<P>;
|
||||
|
||||
template <typename P>
|
||||
using mls = bg::model::multi_linestring<ls<P>>;
|
||||
|
||||
template <typename P>
|
||||
using mpoly = bg::model::multi_polygon<poly<P>>;
|
||||
|
||||
|
||||
struct no_strategy {};
|
||||
|
||||
template <typename Geometry1, typename Geometry2, typename Strategy>
|
||||
|
Loading…
x
Reference in New Issue
Block a user