static inline bool apply(MultiLinestring const& multilinestring) { typedef typename boost::range_value<MultiLinestring>::type linestring; typedef typename point_type<MultiLinestring>::type point_type; typedef point_type point; // check each of the linestrings for simplicity if ( !detail::check_iterator_range < is_simple_linestring<linestring>, false // do not allow empty multilinestring >::apply(boost::begin(multilinestring), boost::end(multilinestring)) ) { return false; } // compute self turns typedef detail::overlay::turn_info < point_type, geometry::segment_ratio < typename geometry::coordinate_type<point>::type > > turn_info; std::deque<turn_info> turns; typedef detail::overlay::get_turn_info < detail::disjoint::assign_disjoint_policy > turn_policy; is_acceptable_turn predicate(multilinestring); detail::overlay::predicate_based_interrupt_policy < is_acceptable_turn > interrupt_policy(predicate); detail::self_get_turn_points::get_turns < turn_policy >::apply(multilinestring, detail::no_rescale_policy(), turns, interrupt_policy); detail::is_valid::debug_print_turns(turns.begin(), turns.end()); debug_print_boundary_points(multilinestring); return !interrupt_policy.has_intersections; }
inline bool has_self_intersections(Linear const& linear) { typedef typename point_type<Linear>::type point_type; // compute self turns typedef detail::overlay::turn_info < point_type, geometry::segment_ratio < typename geometry::coordinate_type<point_type>::type > > turn_info; std::deque<turn_info> turns; typedef detail::overlay::get_turn_info < detail::disjoint::assign_disjoint_policy > turn_policy; is_acceptable_turn<Linear> predicate(linear); detail::overlay::predicate_based_interrupt_policy < is_acceptable_turn<Linear> > interrupt_policy(predicate); detail::self_get_turn_points::get_turns < turn_policy >::apply(linear, detail::no_rescale_policy(), turns, interrupt_policy); detail::is_valid::debug_print_turns(turns.begin(), turns.end()); debug_print_boundary_points(linear); return interrupt_policy.has_intersections; }