relate() added has_disjoint_sub_geometries check - not working for all special cases, should be replaced with e.g. for_each_disjoint_sub_geometry

This commit is contained in:
Adam Wulkiewicz
2014-02-14 18:44:14 +01:00
parent 2437538ccd
commit 551069e555
2 changed files with 68 additions and 2 deletions

View File

@@ -51,12 +51,14 @@ public:
if ( BoundaryQuery == boundary_front_explicit )
{
BOOST_ASSERT(this->template is_boundary<boundary_front>(pt, sid));
// TODO: temporarily disable
//BOOST_ASSERT(this->template is_boundary<boundary_front>(pt, sid));
return true;
}
else if ( BoundaryQuery == boundary_back_explicit )
{
BOOST_ASSERT(this->template is_boundary<boundary_back>(pt, sid));
// TODO: temporarily disable
//BOOST_ASSERT(this->template is_boundary<boundary_back>(pt, sid));
return true;
}
else if ( BoundaryQuery == boundary_front )

View File

@@ -28,6 +28,52 @@ namespace boost { namespace geometry
#ifndef DOXYGEN_NO_DETAIL
namespace detail { namespace relate {
template <std::size_t OpId,
typename Geometry,
typename Tag = typename geometry::tag<Geometry>::type>
struct has_disjoint_sub_geometries {};
template <std::size_t OpId, typename Geometry>
struct has_disjoint_sub_geometries<OpId, Geometry, linestring_tag>
{
template <typename TurnIt>
static inline bool apply(TurnIt first, TurnIt last, Geometry const& /*geometry*/)
{
BOOST_ASSERT(first != last);
return false;
}
};
template <std::size_t OpId, typename Geometry>
struct has_disjoint_sub_geometries<OpId, Geometry, multi_linestring_tag>
{
template <typename TurnIt>
static inline bool apply(TurnIt first, TurnIt last, Geometry const& geometry)
{
BOOST_ASSERT(first != last);
std::size_t count = boost::size(geometry);
std::vector<bool> detected_intersections(count, false);
for ( TurnIt it = first ; it != last ; ++it )
{
int multi_index = it->operations[OpId].seg_id.multi_index;
BOOST_ASSERT(multi_index >= 0);
std::size_t index = static_cast<std::size_t>(multi_index);
BOOST_ASSERT(index < count);
detected_intersections[index] = true;
}
for ( std::vector<bool>::iterator it = detected_intersections.begin() ;
it != detected_intersections.end() ; ++it )
{
if ( *it == false )
return true;
}
return false;
}
};
// update_result
template <field F1, field F2, char D, bool Reverse>
@@ -114,6 +160,24 @@ struct linear_linear
return res;
}
// TODO: this works bout we don't know what should be set exactly
// replace it with something like: for_each_disjoint_subgeometry
if ( has_disjoint_sub_geometries<0, Geometry1>::apply(turns.begin(), turns.end(), geometry1) )
{
// TODO:
// check if there is an interior and/or boundary
res.template update<interior, exterior, '1'>();
res.template update<boundary, exterior, '0'>();
}
if ( has_disjoint_sub_geometries<1, Geometry2>::apply(turns.begin(), turns.end(), geometry2) )
{
// TODO:
// check if there is an interior and/or boundary
res.template update<exterior, interior, '1'>();
res.template update<exterior, boundary, '0'>();
}
boundary_checker<Geometry1> boundary_checker1(geometry1);
boundary_checker<Geometry2> boundary_checker2(geometry2);