annotate DEPENDENCIES/generic/include/boost/geometry/algorithms/covered_by.hpp @ 125:34e428693f5d vext

Vext -> Repoint
author Chris Cannam
date Thu, 14 Jun 2018 11:15:39 +0100
parents c530137014c0
children
rev   line source
Chris@16 1 // Boost.Geometry (aka GGL, Generic Geometry Library)
Chris@16 2
Chris@16 3 // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
Chris@16 4 // Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
Chris@16 5 // Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
Chris@16 6
Chris@101 7 // This file was modified by Oracle on 2013, 2014.
Chris@101 8 // Modifications copyright (c) 2013, 2014 Oracle and/or its affiliates.
Chris@101 9
Chris@16 10 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
Chris@16 11 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
Chris@16 12
Chris@16 13 // Use, modification and distribution is subject to the Boost Software License,
Chris@16 14 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
Chris@16 15 // http://www.boost.org/LICENSE_1_0.txt)
Chris@16 16
Chris@101 17 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
Chris@101 18
Chris@16 19 #ifndef BOOST_GEOMETRY_ALGORITHMS_COVERED_BY_HPP
Chris@16 20 #define BOOST_GEOMETRY_ALGORITHMS_COVERED_BY_HPP
Chris@16 21
Chris@16 22
Chris@16 23 #include <cstddef>
Chris@16 24
Chris@101 25 #include <boost/variant/apply_visitor.hpp>
Chris@101 26 #include <boost/variant/static_visitor.hpp>
Chris@101 27 #include <boost/variant/variant_fwd.hpp>
Chris@101 28
Chris@16 29 #include <boost/geometry/algorithms/not_implemented.hpp>
Chris@16 30 #include <boost/geometry/algorithms/within.hpp>
Chris@16 31
Chris@16 32 #include <boost/geometry/strategies/cartesian/point_in_box.hpp>
Chris@16 33 #include <boost/geometry/strategies/cartesian/box_in_box.hpp>
Chris@101 34 #include <boost/geometry/strategies/default_strategy.hpp>
Chris@16 35
Chris@16 36 namespace boost { namespace geometry
Chris@16 37 {
Chris@16 38
Chris@101 39 #ifndef DOXYGEN_NO_DETAIL
Chris@101 40 namespace detail { namespace covered_by {
Chris@101 41
Chris@101 42 struct use_point_in_geometry
Chris@101 43 {
Chris@101 44 template <typename Geometry1, typename Geometry2, typename Strategy>
Chris@101 45 static inline bool apply(Geometry1 const& geometry1, Geometry2 const& geometry2, Strategy const& strategy)
Chris@101 46 {
Chris@101 47 return detail::within::point_in_geometry(geometry1, geometry2, strategy) >= 0;
Chris@101 48 }
Chris@101 49 };
Chris@101 50
Chris@101 51 struct use_relate
Chris@101 52 {
Chris@101 53 template <typename Geometry1, typename Geometry2, typename Strategy>
Chris@101 54 static inline bool apply(Geometry1 const& geometry1, Geometry2 const& geometry2, Strategy const& /*strategy*/)
Chris@101 55 {
Chris@101 56 return Strategy::apply(geometry1, geometry2);
Chris@101 57 }
Chris@101 58 };
Chris@101 59
Chris@101 60 }} // namespace detail::covered_by
Chris@101 61 #endif // DOXYGEN_NO_DETAIL
Chris@101 62
Chris@16 63 #ifndef DOXYGEN_NO_DISPATCH
Chris@16 64 namespace dispatch
Chris@16 65 {
Chris@16 66
Chris@16 67 template
Chris@16 68 <
Chris@16 69 typename Geometry1,
Chris@16 70 typename Geometry2,
Chris@16 71 typename Tag1 = typename tag<Geometry1>::type,
Chris@16 72 typename Tag2 = typename tag<Geometry2>::type
Chris@16 73 >
Chris@101 74 struct covered_by
Chris@101 75 : not_implemented<Tag1, Tag2>
Chris@16 76 {};
Chris@16 77
Chris@16 78
Chris@16 79 template <typename Point, typename Box>
Chris@16 80 struct covered_by<Point, Box, point_tag, box_tag>
Chris@16 81 {
Chris@16 82 template <typename Strategy>
Chris@16 83 static inline bool apply(Point const& point, Box const& box, Strategy const& strategy)
Chris@16 84 {
Chris@16 85 ::boost::ignore_unused_variable_warning(strategy);
Chris@16 86 return strategy.apply(point, box);
Chris@16 87 }
Chris@16 88 };
Chris@16 89
Chris@16 90 template <typename Box1, typename Box2>
Chris@16 91 struct covered_by<Box1, Box2, box_tag, box_tag>
Chris@16 92 {
Chris@16 93 template <typename Strategy>
Chris@16 94 static inline bool apply(Box1 const& box1, Box2 const& box2, Strategy const& strategy)
Chris@16 95 {
Chris@16 96 assert_dimension_equal<Box1, Box2>();
Chris@16 97 ::boost::ignore_unused_variable_warning(strategy);
Chris@16 98 return strategy.apply(box1, box2);
Chris@16 99 }
Chris@16 100 };
Chris@16 101
Chris@16 102
Chris@101 103 // P/P
Chris@101 104
Chris@101 105 template <typename Point1, typename Point2>
Chris@101 106 struct covered_by<Point1, Point2, point_tag, point_tag>
Chris@101 107 : public detail::covered_by::use_point_in_geometry
Chris@101 108 {};
Chris@101 109
Chris@101 110 template <typename Point, typename MultiPoint>
Chris@101 111 struct covered_by<Point, MultiPoint, point_tag, multi_point_tag>
Chris@101 112 : public detail::covered_by::use_point_in_geometry
Chris@101 113 {};
Chris@101 114
Chris@101 115 // P/L
Chris@101 116
Chris@101 117 template <typename Point, typename Segment>
Chris@101 118 struct covered_by<Point, Segment, point_tag, segment_tag>
Chris@101 119 : public detail::covered_by::use_point_in_geometry
Chris@101 120 {};
Chris@101 121
Chris@101 122 template <typename Point, typename Linestring>
Chris@101 123 struct covered_by<Point, Linestring, point_tag, linestring_tag>
Chris@101 124 : public detail::covered_by::use_point_in_geometry
Chris@101 125 {};
Chris@101 126
Chris@101 127 template <typename Point, typename MultiLinestring>
Chris@101 128 struct covered_by<Point, MultiLinestring, point_tag, multi_linestring_tag>
Chris@101 129 : public detail::covered_by::use_point_in_geometry
Chris@101 130 {};
Chris@101 131
Chris@101 132 // P/A
Chris@16 133
Chris@16 134 template <typename Point, typename Ring>
Chris@16 135 struct covered_by<Point, Ring, point_tag, ring_tag>
Chris@101 136 : public detail::covered_by::use_point_in_geometry
Chris@101 137 {};
Chris@101 138
Chris@101 139 template <typename Point, typename Polygon>
Chris@101 140 struct covered_by<Point, Polygon, point_tag, polygon_tag>
Chris@101 141 : public detail::covered_by::use_point_in_geometry
Chris@101 142 {};
Chris@101 143
Chris@101 144 template <typename Point, typename MultiPolygon>
Chris@101 145 struct covered_by<Point, MultiPolygon, point_tag, multi_polygon_tag>
Chris@101 146 : public detail::covered_by::use_point_in_geometry
Chris@101 147 {};
Chris@101 148
Chris@101 149 // L/L
Chris@101 150
Chris@101 151 template <typename Linestring1, typename Linestring2>
Chris@101 152 struct covered_by<Linestring1, Linestring2, linestring_tag, linestring_tag>
Chris@101 153 : public detail::covered_by::use_relate
Chris@101 154 {};
Chris@101 155
Chris@101 156 template <typename Linestring, typename MultiLinestring>
Chris@101 157 struct covered_by<Linestring, MultiLinestring, linestring_tag, multi_linestring_tag>
Chris@101 158 : public detail::covered_by::use_relate
Chris@101 159 {};
Chris@101 160
Chris@101 161 template <typename MultiLinestring, typename Linestring>
Chris@101 162 struct covered_by<MultiLinestring, Linestring, multi_linestring_tag, linestring_tag>
Chris@101 163 : public detail::covered_by::use_relate
Chris@101 164 {};
Chris@101 165
Chris@101 166 template <typename MultiLinestring1, typename MultiLinestring2>
Chris@101 167 struct covered_by<MultiLinestring1, MultiLinestring2, multi_linestring_tag, multi_linestring_tag>
Chris@101 168 : public detail::covered_by::use_relate
Chris@101 169 {};
Chris@101 170
Chris@101 171 // L/A
Chris@101 172
Chris@101 173 template <typename Linestring, typename Ring>
Chris@101 174 struct covered_by<Linestring, Ring, linestring_tag, ring_tag>
Chris@101 175 : public detail::covered_by::use_relate
Chris@101 176 {};
Chris@101 177
Chris@101 178 template <typename MultiLinestring, typename Ring>
Chris@101 179 struct covered_by<MultiLinestring, Ring, multi_linestring_tag, ring_tag>
Chris@101 180 : public detail::covered_by::use_relate
Chris@101 181 {};
Chris@101 182
Chris@101 183 template <typename Linestring, typename Polygon>
Chris@101 184 struct covered_by<Linestring, Polygon, linestring_tag, polygon_tag>
Chris@101 185 : public detail::covered_by::use_relate
Chris@101 186 {};
Chris@101 187
Chris@101 188 template <typename MultiLinestring, typename Polygon>
Chris@101 189 struct covered_by<MultiLinestring, Polygon, multi_linestring_tag, polygon_tag>
Chris@101 190 : public detail::covered_by::use_relate
Chris@101 191 {};
Chris@101 192
Chris@101 193 template <typename Linestring, typename MultiPolygon>
Chris@101 194 struct covered_by<Linestring, MultiPolygon, linestring_tag, multi_polygon_tag>
Chris@101 195 : public detail::covered_by::use_relate
Chris@101 196 {};
Chris@101 197
Chris@101 198 template <typename MultiLinestring, typename MultiPolygon>
Chris@101 199 struct covered_by<MultiLinestring, MultiPolygon, multi_linestring_tag, multi_polygon_tag>
Chris@101 200 : public detail::covered_by::use_relate
Chris@101 201 {};
Chris@101 202
Chris@101 203 // A/A
Chris@101 204
Chris@101 205 template <typename Ring1, typename Ring2>
Chris@101 206 struct covered_by<Ring1, Ring2, ring_tag, ring_tag>
Chris@101 207 : public detail::covered_by::use_relate
Chris@101 208 {};
Chris@101 209
Chris@101 210 template <typename Ring, typename Polygon>
Chris@101 211 struct covered_by<Ring, Polygon, ring_tag, polygon_tag>
Chris@101 212 : public detail::covered_by::use_relate
Chris@101 213 {};
Chris@101 214
Chris@101 215 template <typename Polygon, typename Ring>
Chris@101 216 struct covered_by<Polygon, Ring, polygon_tag, ring_tag>
Chris@101 217 : public detail::covered_by::use_relate
Chris@101 218 {};
Chris@101 219
Chris@101 220 template <typename Polygon1, typename Polygon2>
Chris@101 221 struct covered_by<Polygon1, Polygon2, polygon_tag, polygon_tag>
Chris@101 222 : public detail::covered_by::use_relate
Chris@101 223 {};
Chris@101 224
Chris@101 225 template <typename Ring, typename MultiPolygon>
Chris@101 226 struct covered_by<Ring, MultiPolygon, ring_tag, multi_polygon_tag>
Chris@101 227 : public detail::covered_by::use_relate
Chris@101 228 {};
Chris@101 229
Chris@101 230 template <typename MultiPolygon, typename Ring>
Chris@101 231 struct covered_by<MultiPolygon, Ring, multi_polygon_tag, ring_tag>
Chris@101 232 : public detail::covered_by::use_relate
Chris@101 233 {};
Chris@101 234
Chris@101 235 template <typename Polygon, typename MultiPolygon>
Chris@101 236 struct covered_by<Polygon, MultiPolygon, polygon_tag, multi_polygon_tag>
Chris@101 237 : public detail::covered_by::use_relate
Chris@101 238 {};
Chris@101 239
Chris@101 240 template <typename MultiPolygon, typename Polygon>
Chris@101 241 struct covered_by<MultiPolygon, Polygon, multi_polygon_tag, polygon_tag>
Chris@101 242 : public detail::covered_by::use_relate
Chris@101 243 {};
Chris@101 244
Chris@101 245 template <typename MultiPolygon1, typename MultiPolygon2>
Chris@101 246 struct covered_by<MultiPolygon1, MultiPolygon2, multi_polygon_tag, multi_polygon_tag>
Chris@101 247 : public detail::covered_by::use_relate
Chris@101 248 {};
Chris@101 249
Chris@101 250 } // namespace dispatch
Chris@101 251 #endif // DOXYGEN_NO_DISPATCH
Chris@101 252
Chris@101 253
Chris@101 254 namespace resolve_strategy {
Chris@101 255
Chris@101 256 struct covered_by
Chris@16 257 {
Chris@101 258 template <typename Geometry1, typename Geometry2, typename Strategy>
Chris@101 259 static inline bool apply(Geometry1 const& geometry1,
Chris@101 260 Geometry2 const& geometry2,
Chris@101 261 Strategy const& strategy)
Chris@16 262 {
Chris@101 263 concept::within::check
Chris@16 264 <
Chris@101 265 typename tag<Geometry1>::type,
Chris@101 266 typename tag<Geometry2>::type,
Chris@101 267 typename tag_cast<typename tag<Geometry2>::type, areal_tag>::type,
Chris@16 268 Strategy
Chris@101 269 >();
Chris@101 270 concept::check<Geometry1 const>();
Chris@101 271 concept::check<Geometry2 const>();
Chris@101 272 assert_dimension_equal<Geometry1, Geometry2>();
Chris@101 273
Chris@101 274 return dispatch::covered_by<Geometry1, Geometry2>::apply(geometry1,
Chris@101 275 geometry2,
Chris@101 276 strategy);
Chris@101 277 }
Chris@101 278
Chris@101 279 template <typename Geometry1, typename Geometry2>
Chris@101 280 static inline bool apply(Geometry1 const& geometry1,
Chris@101 281 Geometry2 const& geometry2,
Chris@101 282 default_strategy)
Chris@101 283 {
Chris@101 284 typedef typename point_type<Geometry1>::type point_type1;
Chris@101 285 typedef typename point_type<Geometry2>::type point_type2;
Chris@101 286
Chris@101 287 typedef typename strategy::covered_by::services::default_strategy
Chris@101 288 <
Chris@101 289 typename tag<Geometry1>::type,
Chris@101 290 typename tag<Geometry2>::type,
Chris@101 291 typename tag<Geometry1>::type,
Chris@101 292 typename tag_cast<typename tag<Geometry2>::type, areal_tag>::type,
Chris@101 293 typename tag_cast
Chris@101 294 <
Chris@101 295 typename cs_tag<point_type1>::type, spherical_tag
Chris@101 296 >::type,
Chris@101 297 typename tag_cast
Chris@101 298 <
Chris@101 299 typename cs_tag<point_type2>::type, spherical_tag
Chris@101 300 >::type,
Chris@101 301 Geometry1,
Chris@101 302 Geometry2
Chris@101 303 >::type strategy_type;
Chris@101 304
Chris@101 305 return covered_by::apply(geometry1, geometry2, strategy_type());
Chris@16 306 }
Chris@16 307 };
Chris@16 308
Chris@101 309 } // namespace resolve_strategy
Chris@101 310
Chris@101 311
Chris@101 312 namespace resolve_variant {
Chris@101 313
Chris@101 314 template <typename Geometry1, typename Geometry2>
Chris@101 315 struct covered_by
Chris@16 316 {
Chris@16 317 template <typename Strategy>
Chris@101 318 static inline bool apply(Geometry1 const& geometry1,
Chris@101 319 Geometry2 const& geometry2,
Chris@101 320 Strategy const& strategy)
Chris@16 321 {
Chris@101 322 return resolve_strategy::covered_by
Chris@101 323 ::apply(geometry1, geometry2, strategy);
Chris@16 324 }
Chris@16 325 };
Chris@16 326
Chris@101 327 template <BOOST_VARIANT_ENUM_PARAMS(typename T), typename Geometry2>
Chris@101 328 struct covered_by<boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>, Geometry2>
Chris@101 329 {
Chris@101 330 template <typename Strategy>
Chris@101 331 struct visitor: boost::static_visitor<bool>
Chris@101 332 {
Chris@101 333 Geometry2 const& m_geometry2;
Chris@101 334 Strategy const& m_strategy;
Chris@101 335
Chris@101 336 visitor(Geometry2 const& geometry2, Strategy const& strategy)
Chris@101 337 : m_geometry2(geometry2), m_strategy(strategy) {}
Chris@101 338
Chris@101 339 template <typename Geometry1>
Chris@101 340 bool operator()(Geometry1 const& geometry1) const
Chris@101 341 {
Chris@101 342 return covered_by<Geometry1, Geometry2>
Chris@101 343 ::apply(geometry1, m_geometry2, m_strategy);
Chris@101 344 }
Chris@101 345 };
Chris@101 346
Chris@101 347 template <typename Strategy>
Chris@101 348 static inline bool
Chris@101 349 apply(boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> const& geometry1,
Chris@101 350 Geometry2 const& geometry2,
Chris@101 351 Strategy const& strategy)
Chris@101 352 {
Chris@101 353 return boost::apply_visitor(visitor<Strategy>(geometry2, strategy), geometry1);
Chris@101 354 }
Chris@101 355 };
Chris@101 356
Chris@101 357 template <typename Geometry1, BOOST_VARIANT_ENUM_PARAMS(typename T)>
Chris@101 358 struct covered_by<Geometry1, boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> >
Chris@101 359 {
Chris@101 360 template <typename Strategy>
Chris@101 361 struct visitor: boost::static_visitor<bool>
Chris@101 362 {
Chris@101 363 Geometry1 const& m_geometry1;
Chris@101 364 Strategy const& m_strategy;
Chris@101 365
Chris@101 366 visitor(Geometry1 const& geometry1, Strategy const& strategy)
Chris@101 367 : m_geometry1(geometry1), m_strategy(strategy) {}
Chris@101 368
Chris@101 369 template <typename Geometry2>
Chris@101 370 bool operator()(Geometry2 const& geometry2) const
Chris@101 371 {
Chris@101 372 return covered_by<Geometry1, Geometry2>
Chris@101 373 ::apply(m_geometry1, geometry2, m_strategy);
Chris@101 374 }
Chris@101 375 };
Chris@101 376
Chris@101 377 template <typename Strategy>
Chris@101 378 static inline bool
Chris@101 379 apply(Geometry1 const& geometry1,
Chris@101 380 boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> const& geometry2,
Chris@101 381 Strategy const& strategy)
Chris@101 382 {
Chris@101 383 return boost::apply_visitor(visitor<Strategy>(geometry1, strategy), geometry2);
Chris@101 384 }
Chris@101 385 };
Chris@101 386
Chris@101 387 template <
Chris@101 388 BOOST_VARIANT_ENUM_PARAMS(typename T1),
Chris@101 389 BOOST_VARIANT_ENUM_PARAMS(typename T2)
Chris@101 390 >
Chris@101 391 struct covered_by<
Chris@101 392 boost::variant<BOOST_VARIANT_ENUM_PARAMS(T1)>,
Chris@101 393 boost::variant<BOOST_VARIANT_ENUM_PARAMS(T2)>
Chris@101 394 >
Chris@101 395 {
Chris@101 396 template <typename Strategy>
Chris@101 397 struct visitor: boost::static_visitor<bool>
Chris@101 398 {
Chris@101 399 Strategy const& m_strategy;
Chris@101 400
Chris@101 401 visitor(Strategy const& strategy): m_strategy(strategy) {}
Chris@101 402
Chris@101 403 template <typename Geometry1, typename Geometry2>
Chris@101 404 bool operator()(Geometry1 const& geometry1,
Chris@101 405 Geometry2 const& geometry2) const
Chris@101 406 {
Chris@101 407 return covered_by<Geometry1, Geometry2>
Chris@101 408 ::apply(geometry1, geometry2, m_strategy);
Chris@101 409 }
Chris@101 410 };
Chris@101 411
Chris@101 412 template <typename Strategy>
Chris@101 413 static inline bool
Chris@101 414 apply(boost::variant<BOOST_VARIANT_ENUM_PARAMS(T1)> const& geometry1,
Chris@101 415 boost::variant<BOOST_VARIANT_ENUM_PARAMS(T2)> const& geometry2,
Chris@101 416 Strategy const& strategy)
Chris@101 417 {
Chris@101 418 return boost::apply_visitor(visitor<Strategy>(strategy), geometry1, geometry2);
Chris@101 419 }
Chris@101 420 };
Chris@101 421
Chris@101 422 } // namespace resolve_variant
Chris@16 423
Chris@16 424
Chris@16 425 /*!
Chris@16 426 \brief \brief_check12{is inside or on border}
Chris@16 427 \ingroup covered_by
Chris@16 428 \details \details_check12{covered_by, is inside or on border}.
Chris@16 429 \tparam Geometry1 \tparam_geometry
Chris@16 430 \tparam Geometry2 \tparam_geometry
Chris@16 431 \param geometry1 \param_geometry which might be inside or on the border of the second geometry
Chris@16 432 \param geometry2 \param_geometry which might cover the first geometry
Chris@16 433 \return true if geometry1 is inside of or on the border of geometry2,
Chris@16 434 else false
Chris@16 435 \note The default strategy is used for covered_by detection
Chris@16 436
Chris@16 437 \qbk{[include reference/algorithms/covered_by.qbk]}
Chris@16 438
Chris@16 439 */
Chris@16 440 template<typename Geometry1, typename Geometry2>
Chris@16 441 inline bool covered_by(Geometry1 const& geometry1, Geometry2 const& geometry2)
Chris@16 442 {
Chris@101 443 return resolve_variant::covered_by<Geometry1, Geometry2>
Chris@101 444 ::apply(geometry1, geometry2, default_strategy());
Chris@16 445 }
Chris@16 446
Chris@16 447 /*!
Chris@16 448 \brief \brief_check12{is inside or on border} \brief_strategy
Chris@16 449 \ingroup covered_by
Chris@16 450 \details \details_check12{covered_by, is inside or on border}, \brief_strategy. \details_strategy_reasons
Chris@16 451 \tparam Geometry1 \tparam_geometry
Chris@16 452 \tparam Geometry2 \tparam_geometry
Chris@16 453 \param geometry1 \param_geometry which might be inside or on the border of the second geometry
Chris@16 454 \param geometry2 \param_geometry which might cover the first geometry
Chris@16 455 \param strategy strategy to be used
Chris@16 456 \return true if geometry1 is inside of or on the border of geometry2,
Chris@16 457 else false
Chris@16 458
Chris@16 459 \qbk{distinguish,with strategy}
Chris@16 460 \qbk{[include reference/algorithms/covered_by.qbk]}
Chris@16 461
Chris@16 462 */
Chris@16 463 template<typename Geometry1, typename Geometry2, typename Strategy>
Chris@16 464 inline bool covered_by(Geometry1 const& geometry1, Geometry2 const& geometry2,
Chris@16 465 Strategy const& strategy)
Chris@16 466 {
Chris@101 467 return resolve_variant::covered_by<Geometry1, Geometry2>
Chris@101 468 ::apply(geometry1, geometry2, strategy);
Chris@16 469 }
Chris@16 470
Chris@16 471 }} // namespace boost::geometry
Chris@16 472
Chris@16 473 #endif // BOOST_GEOMETRY_ALGORITHMS_COVERED_BY_HPP