mirror of
https://github.com/boostorg/geometry.git
synced 2026-02-01 20:42:10 +00:00
[geometry] recently added detail::XXX::YYY_dispatch structs moved/renamed to detail_dispatch::XXX::YYY
This commit is contained in:
@@ -36,15 +36,19 @@ struct index_type
|
||||
}
|
||||
};
|
||||
|
||||
}} // namespace detail::sub_geometry
|
||||
|
||||
namespace detail_dispatch { namespace sub_geometry {
|
||||
|
||||
// TODO: later remove IsMulti and move to multi directory
|
||||
template <typename Geometry,
|
||||
typename Tag = typename geometry::tag<Geometry>::type,
|
||||
bool IsMulti = boost::is_base_of<multi_tag, Tag>::value>
|
||||
struct get_dispatch : not_implemented<Tag>
|
||||
struct get : not_implemented<Tag>
|
||||
{};
|
||||
|
||||
template <typename Geometry, typename Tag>
|
||||
struct get_dispatch<Geometry, Tag, false>
|
||||
struct get<Geometry, Tag, false>
|
||||
{
|
||||
typedef Geometry & result_type;
|
||||
|
||||
@@ -56,7 +60,7 @@ struct get_dispatch<Geometry, Tag, false>
|
||||
};
|
||||
|
||||
template <typename Geometry>
|
||||
struct get_dispatch<Geometry, polygon_tag, false>
|
||||
struct get<Geometry, polygon_tag, false>
|
||||
{
|
||||
typedef typename geometry::ring_type<Geometry>::type & result_type;
|
||||
|
||||
@@ -75,50 +79,40 @@ struct get_dispatch<Geometry, polygon_tag, false>
|
||||
};
|
||||
|
||||
template <typename Geometry, typename Tag>
|
||||
struct get_dispatch<Geometry, Tag, true>
|
||||
struct get<Geometry, Tag, true>
|
||||
{
|
||||
typedef typename boost::range_value<Geometry>::type sub_type;
|
||||
typedef typename get_dispatch<sub_type>::result_type result_type;
|
||||
typedef detail_dispatch::sub_geometry::get<sub_type> get_type;
|
||||
typedef typename get_type::result_type result_type;
|
||||
|
||||
template <typename Id> static inline
|
||||
result_type apply(Geometry & geometry, Id const& id)
|
||||
{
|
||||
BOOST_ASSERT(0 <= id.multi_index);
|
||||
return get_dispatch<sub_type>::apply(*(boost::begin(geometry) + id.multi_index), id);
|
||||
return get_type::apply(*(boost::begin(geometry) + id.multi_index), id);
|
||||
}
|
||||
};
|
||||
|
||||
}} // namespace detail_dispatch::sub_geometry
|
||||
|
||||
namespace detail { namespace sub_geometry {
|
||||
|
||||
template <typename Geometry>
|
||||
struct result_type
|
||||
{
|
||||
typedef typename get_dispatch<Geometry>::result_type type;
|
||||
typedef typename detail_dispatch::sub_geometry::get<Geometry>::result_type type;
|
||||
};
|
||||
|
||||
//template <typename Geometry>
|
||||
//struct result_type<Geometry const>
|
||||
//{
|
||||
// typedef typename get_dispatch<Geometry const>::result_type type;
|
||||
//};
|
||||
|
||||
// This function also works for geometry::segment_identifier
|
||||
|
||||
template <typename Geometry, typename Id> inline
|
||||
typename get_dispatch<Geometry>::result_type
|
||||
get(Geometry & g, Id const& id)
|
||||
typename detail_dispatch::sub_geometry::get<Geometry>::result_type
|
||||
get(Geometry & geometry, Id const& id)
|
||||
{
|
||||
return get_dispatch<Geometry>::apply(g, id);
|
||||
return detail_dispatch::sub_geometry::get<Geometry>::apply(geometry, id);
|
||||
};
|
||||
|
||||
//template <typename Geometry, typename Id> inline
|
||||
//typename get_dispatch<Geometry>::result_type
|
||||
//get(Geometry const& g, Id const& id)
|
||||
//{
|
||||
// return get_dispatch<Geometry const>::apply(g, id);
|
||||
//};
|
||||
|
||||
} // namespace sub_geometry
|
||||
|
||||
} // namespace detail
|
||||
}} // namespace detail::sub_geometry
|
||||
#endif
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
@@ -51,6 +51,10 @@ int point_in_range(Point const& point, Range const& range, Strategy const& strat
|
||||
return strategy.result(state);
|
||||
}
|
||||
|
||||
}} // namespace detail::within
|
||||
|
||||
namespace detail_dispatch { namespace within {
|
||||
|
||||
// checks the relation between a point P and geometry G
|
||||
// returns 1 if P is in the interior of G
|
||||
// returns 0 if P is on the boundry of G
|
||||
@@ -58,11 +62,11 @@ int point_in_range(Point const& point, Range const& range, Strategy const& strat
|
||||
|
||||
template <typename Geometry,
|
||||
typename Tag = typename geometry::tag<Geometry>::type>
|
||||
struct point_in_geometry_dispatch : not_implemented<Tag>
|
||||
struct point_in_geometry : not_implemented<Tag>
|
||||
{};
|
||||
|
||||
template <typename Box>
|
||||
struct point_in_geometry_dispatch<Box, box_tag>
|
||||
struct point_in_geometry<Box, box_tag>
|
||||
{
|
||||
template <typename Point, typename Strategy> static inline
|
||||
int apply(Point const& point, Box const& box, Strategy const& strategy)
|
||||
@@ -73,7 +77,7 @@ struct point_in_geometry_dispatch<Box, box_tag>
|
||||
};
|
||||
|
||||
template <typename Linestring>
|
||||
struct point_in_geometry_dispatch<Linestring, linestring_tag>
|
||||
struct point_in_geometry<Linestring, linestring_tag>
|
||||
{
|
||||
template <typename Point, typename Strategy> static inline
|
||||
int apply(Point const& point, Linestring const& linestring, Strategy const& strategy)
|
||||
@@ -103,7 +107,7 @@ struct point_in_geometry_dispatch<Linestring, linestring_tag>
|
||||
};
|
||||
|
||||
template <typename Ring>
|
||||
struct point_in_geometry_dispatch<Ring, ring_tag>
|
||||
struct point_in_geometry<Ring, ring_tag>
|
||||
{
|
||||
template <typename Point, typename Strategy> static inline
|
||||
int apply(Point const& point, Ring const& ring, Strategy const& strategy)
|
||||
@@ -127,19 +131,19 @@ struct point_in_geometry_dispatch<Ring, ring_tag>
|
||||
rev_view_type rev_view(ring);
|
||||
cl_view_type view(rev_view);
|
||||
|
||||
return point_in_range(point, view, strategy);
|
||||
return detail::within::point_in_range(point, view, strategy);
|
||||
}
|
||||
};
|
||||
|
||||
//// Polygon: in exterior ring, and if so, not within interior ring(s)
|
||||
template <typename Polygon>
|
||||
struct point_in_geometry_dispatch<Polygon, polygon_tag>
|
||||
struct point_in_geometry<Polygon, polygon_tag>
|
||||
{
|
||||
template <typename Point, typename Strategy>
|
||||
static inline int apply(Point const& point, Polygon const& polygon,
|
||||
Strategy const& strategy)
|
||||
{
|
||||
int const code = point_in_geometry_dispatch
|
||||
int const code = point_in_geometry
|
||||
<
|
||||
typename ring_type<Polygon>::type
|
||||
>::apply(point, exterior_ring(polygon), strategy);
|
||||
@@ -152,7 +156,7 @@ struct point_in_geometry_dispatch<Polygon, polygon_tag>
|
||||
it != boost::end(rings);
|
||||
++it)
|
||||
{
|
||||
int const interior_code = point_in_geometry_dispatch
|
||||
int const interior_code = point_in_geometry
|
||||
<
|
||||
typename ring_type<Polygon>::type
|
||||
>::apply(point, *it, strategy);
|
||||
@@ -170,6 +174,10 @@ struct point_in_geometry_dispatch<Polygon, polygon_tag>
|
||||
}
|
||||
};
|
||||
|
||||
}} // namespace detail_dispatch::within
|
||||
|
||||
namespace detail { namespace within {
|
||||
|
||||
// 1 - in the interior
|
||||
// 0 - in the boundry
|
||||
// -1 - in the exterior
|
||||
@@ -178,7 +186,7 @@ int point_in_geometry(Point const& point, Geometry const& geometry, Strategy con
|
||||
{
|
||||
BOOST_CONCEPT_ASSERT( (geometry::concept::WithinStrategyPolygonal<Strategy>) );
|
||||
|
||||
return point_in_geometry_dispatch<Geometry>::apply(point, geometry, strategy);
|
||||
return detail_dispatch::within::point_in_geometry<Geometry>::apply(point, geometry, strategy);
|
||||
}
|
||||
|
||||
template <typename Point, typename Geometry> inline
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
namespace boost { namespace geometry {
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail { namespace within {
|
||||
namespace detail_dispatch { namespace within {
|
||||
|
||||
// returns true if G1 is within G2
|
||||
// this function should be called only if there are no intersection points
|
||||
@@ -34,7 +34,7 @@ template <typename Geometry1,
|
||||
typename Geometry2,
|
||||
typename Tag1 = typename geometry::tag<Geometry1>::type,
|
||||
typename Tag2 = typename geometry::tag<Geometry2>::type>
|
||||
struct within_no_turns_dispatch
|
||||
struct within_no_turns
|
||||
{
|
||||
template <typename Strategy> static inline
|
||||
bool apply(Geometry1 const& geometry1, Geometry2 const& geometry2, Strategy const& strategy)
|
||||
@@ -44,12 +44,12 @@ struct within_no_turns_dispatch
|
||||
if ( !geometry::point_on_border(p, geometry1) )
|
||||
return false;
|
||||
|
||||
return point_in_geometry(p, geometry2, strategy) >= 0;
|
||||
return detail::within::point_in_geometry(p, geometry2, strategy) >= 0;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Geometry1, typename Geometry2>
|
||||
struct within_no_turns_dispatch<Geometry1, Geometry2, ring_tag, polygon_tag>
|
||||
struct within_no_turns<Geometry1, Geometry2, ring_tag, polygon_tag>
|
||||
{
|
||||
template <typename Strategy> static inline
|
||||
bool apply(Geometry1 const& geometry1, Geometry2 const& geometry2, Strategy const& strategy)
|
||||
@@ -60,7 +60,7 @@ struct within_no_turns_dispatch<Geometry1, Geometry2, ring_tag, polygon_tag>
|
||||
if ( !geometry::point_on_border(p, geometry1) )
|
||||
return false;
|
||||
// check if one of ring points is outside the polygon
|
||||
if ( point_in_geometry(p, geometry2, strategy) < 0 )
|
||||
if ( detail::within::point_in_geometry(p, geometry2, strategy) < 0 )
|
||||
return false;
|
||||
// Now check if holes of G2 aren't inside G1
|
||||
typedef typename boost::range_const_iterator
|
||||
@@ -74,7 +74,7 @@ struct within_no_turns_dispatch<Geometry1, Geometry2, ring_tag, polygon_tag>
|
||||
point2_type p;
|
||||
if ( !geometry::point_on_border(p, *it) )
|
||||
return false;
|
||||
if ( point_in_geometry(p, geometry1, strategy) > 0 )
|
||||
if ( detail::within::point_in_geometry(p, geometry1, strategy) > 0 )
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -82,7 +82,7 @@ struct within_no_turns_dispatch<Geometry1, Geometry2, ring_tag, polygon_tag>
|
||||
};
|
||||
|
||||
template <typename Geometry1, typename Geometry2>
|
||||
struct within_no_turns_dispatch<Geometry1, Geometry2, polygon_tag, polygon_tag>
|
||||
struct within_no_turns<Geometry1, Geometry2, polygon_tag, polygon_tag>
|
||||
{
|
||||
template <typename Strategy> static inline
|
||||
bool apply(Geometry1 const& geometry1, Geometry2 const& geometry2, Strategy const& strategy)
|
||||
@@ -93,7 +93,7 @@ struct within_no_turns_dispatch<Geometry1, Geometry2, polygon_tag, polygon_tag>
|
||||
if ( !geometry::point_on_border(p, geometry1) )
|
||||
return false;
|
||||
// check if one of ring points is outside the polygon
|
||||
if ( point_in_geometry(p, geometry2, strategy) < 0 )
|
||||
if ( detail::within::point_in_geometry(p, geometry2, strategy) < 0 )
|
||||
return false;
|
||||
// Now check if holes of G2 aren't inside G1
|
||||
typedef typename boost::range_const_iterator
|
||||
@@ -108,7 +108,7 @@ struct within_no_turns_dispatch<Geometry1, Geometry2, polygon_tag, polygon_tag>
|
||||
if ( !geometry::point_on_border(p2, *it) )
|
||||
return false;
|
||||
// if the hole of G2 is inside G1
|
||||
if ( point_in_geometry(p2, geometry1, strategy) > 0 )
|
||||
if ( detail::within::point_in_geometry(p2, geometry1, strategy) > 0 )
|
||||
{
|
||||
// if it's also inside one of the G1 holes, it's ok
|
||||
bool ok = false;
|
||||
@@ -120,7 +120,7 @@ struct within_no_turns_dispatch<Geometry1, Geometry2, polygon_tag, polygon_tag>
|
||||
it1 != boost::end(geometry::interior_rings(geometry1)) ;
|
||||
++it1 )
|
||||
{
|
||||
if ( point_in_geometry(p2, *it1, strategy) < 0 )
|
||||
if ( detail::within::point_in_geometry(p2, *it1, strategy) < 0 )
|
||||
{
|
||||
ok = true;
|
||||
break;
|
||||
@@ -142,17 +142,17 @@ template <typename Geometry1,
|
||||
typename Tag2 = typename geometry::tag<Geometry2>::type,
|
||||
bool IsMulti1 = boost::is_base_of<geometry::multi_tag, Tag1>::value,
|
||||
bool IsMulti2 = boost::is_base_of<geometry::multi_tag, Tag2>::value>
|
||||
struct within_no_turns_multi_dispatch
|
||||
struct within_no_turns_multi
|
||||
{
|
||||
template <typename Strategy> static inline
|
||||
bool apply(Geometry1 const& geometry1, Geometry2 const& geometry2, Strategy const& strategy)
|
||||
{
|
||||
return within_no_turns_dispatch<Geometry1, Geometry2>::apply(geometry1, geometry2, strategy);
|
||||
return within_no_turns<Geometry1, Geometry2>::apply(geometry1, geometry2, strategy);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Geometry1, typename Geometry2, typename Tag1, typename Tag2>
|
||||
struct within_no_turns_multi_dispatch<Geometry1, Geometry2, Tag1, Tag2, true, false>
|
||||
struct within_no_turns_multi<Geometry1, Geometry2, Tag1, Tag2, true, false>
|
||||
{
|
||||
template <typename Strategy> static inline
|
||||
bool apply(Geometry1 const& geometry1, Geometry2 const& geometry2, Strategy const& strategy)
|
||||
@@ -162,7 +162,7 @@ struct within_no_turns_multi_dispatch<Geometry1, Geometry2, Tag1, Tag2, true, fa
|
||||
typedef typename boost::range_const_iterator<Geometry1>::type iterator;
|
||||
for ( iterator it = boost::begin(geometry1) ; it != boost::end(geometry1) ; ++it )
|
||||
{
|
||||
if ( !within_no_turns_dispatch<subgeometry1, Geometry2>::apply(*it, geometry2, strategy) )
|
||||
if ( !within_no_turns<subgeometry1, Geometry2>::apply(*it, geometry2, strategy) )
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -170,7 +170,7 @@ struct within_no_turns_multi_dispatch<Geometry1, Geometry2, Tag1, Tag2, true, fa
|
||||
};
|
||||
|
||||
template <typename Geometry1, typename Geometry2, typename Tag1, typename Tag2>
|
||||
struct within_no_turns_multi_dispatch<Geometry1, Geometry2, Tag1, Tag2, false, true>
|
||||
struct within_no_turns_multi<Geometry1, Geometry2, Tag1, Tag2, false, true>
|
||||
{
|
||||
template <typename Strategy> static inline
|
||||
bool apply(Geometry1 const& geometry1, Geometry2 const& geometry2, Strategy const& strategy)
|
||||
@@ -180,7 +180,7 @@ struct within_no_turns_multi_dispatch<Geometry1, Geometry2, Tag1, Tag2, false, t
|
||||
typedef typename boost::range_const_iterator<Geometry2>::type iterator;
|
||||
for ( iterator it = boost::begin(geometry2) ; it != boost::end(geometry2) ; ++it )
|
||||
{
|
||||
if ( within_no_turns_dispatch<Geometry1, subgeometry2>::apply(geometry1, *it, strategy) )
|
||||
if ( within_no_turns<Geometry1, subgeometry2>::apply(geometry1, *it, strategy) )
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -188,7 +188,7 @@ struct within_no_turns_multi_dispatch<Geometry1, Geometry2, Tag1, Tag2, false, t
|
||||
};
|
||||
|
||||
template <typename Geometry1, typename Geometry2, typename Tag1, typename Tag2>
|
||||
struct within_no_turns_multi_dispatch<Geometry1, Geometry2, Tag1, Tag2, true, true>
|
||||
struct within_no_turns_multi<Geometry1, Geometry2, Tag1, Tag2, true, true>
|
||||
{
|
||||
template <typename Strategy> static inline
|
||||
bool apply(Geometry1 const& geometry1, Geometry2 const& geometry2, Strategy const& strategy)
|
||||
@@ -198,17 +198,21 @@ struct within_no_turns_multi_dispatch<Geometry1, Geometry2, Tag1, Tag2, true, tr
|
||||
typedef typename boost::range_const_iterator<Geometry1>::type iterator;
|
||||
for ( iterator it = boost::begin(geometry1) ; it != boost::end(geometry1) ; ++it )
|
||||
{
|
||||
if ( !within_no_turns_multi_dispatch<subgeometry1, Geometry2>::apply(*it, geometry2, strategy) )
|
||||
if ( !within_no_turns_multi<subgeometry1, Geometry2>::apply(*it, geometry2, strategy) )
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
}} // namespace detail_dispatch::within
|
||||
|
||||
namespace detail { namespace within {
|
||||
|
||||
template <typename Geometry1, typename Geometry2, typename Strategy> inline
|
||||
bool within_no_turns(Geometry1 const& geometry1, Geometry2 const& geometry2, Strategy const& strategy)
|
||||
{
|
||||
return within_no_turns_multi_dispatch<Geometry1, Geometry2>::apply(geometry1, geometry2, strategy);
|
||||
return detail_dispatch::within::within_no_turns_multi<Geometry1, Geometry2>::apply(geometry1, geometry2, strategy);
|
||||
}
|
||||
|
||||
}} // namespace detail::within
|
||||
|
||||
@@ -23,10 +23,10 @@
|
||||
namespace boost { namespace geometry {
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail { namespace within {
|
||||
namespace detail_dispatch { namespace within {
|
||||
|
||||
template <typename Geometry>
|
||||
struct point_in_geometry_dispatch<Geometry, multi_polygon_tag>
|
||||
struct point_in_geometry<Geometry, multi_polygon_tag>
|
||||
{
|
||||
template <typename Point, typename Strategy> static inline
|
||||
int apply(Point const& point, Geometry const& geometry, Strategy const& strategy)
|
||||
@@ -38,7 +38,7 @@ struct point_in_geometry_dispatch<Geometry, multi_polygon_tag>
|
||||
typedef typename boost::range_const_iterator<Geometry>::type iterator;
|
||||
for ( iterator it = boost::begin(geometry) ; it != boost::end(geometry) ; ++it )
|
||||
{
|
||||
int pip = detail::within::point_in_geometry_dispatch<polygon_type>::apply(point, *it, strategy);
|
||||
int pip = point_in_geometry<polygon_type>::apply(point, *it, strategy);
|
||||
|
||||
if ( 1 == pip ) // inside polygon
|
||||
return 1;
|
||||
@@ -56,7 +56,7 @@ struct point_in_geometry_dispatch<Geometry, multi_polygon_tag>
|
||||
};
|
||||
|
||||
template <typename Geometry>
|
||||
struct point_in_geometry_dispatch<Geometry, multi_linestring_tag>
|
||||
struct point_in_geometry<Geometry, multi_linestring_tag>
|
||||
{
|
||||
template <typename Point, typename Strategy> static inline
|
||||
int apply(Point const& point, Geometry const& geometry, Strategy const& strategy)
|
||||
@@ -69,7 +69,7 @@ struct point_in_geometry_dispatch<Geometry, multi_linestring_tag>
|
||||
iterator it = boost::begin(geometry);
|
||||
for ( ; it != boost::end(geometry) ; ++it )
|
||||
{
|
||||
pip = detail::within::point_in_geometry_dispatch<linestring_type>::apply(point, *it, strategy);
|
||||
pip = point_in_geometry<linestring_type>::apply(point, *it, strategy);
|
||||
|
||||
if ( 0 <= pip )
|
||||
{
|
||||
@@ -104,7 +104,7 @@ struct point_in_geometry_dispatch<Geometry, multi_linestring_tag>
|
||||
}
|
||||
};
|
||||
|
||||
}} // namespace detail::within
|
||||
}} // namespace detail_dispatch::within
|
||||
#endif // DOXYGEN_NO_DETAIL
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
Reference in New Issue
Block a user