static inline void apply(Polygon1 const& source, Polygon2& destination) { // Clearing managed per ring, and in the resizing of interior rings per_ring::apply(geometry::exterior_ring(source), geometry::exterior_ring(destination)); // Container should be resizeable traits::resize < typename pdalboost::remove_reference < typename traits::interior_mutable_type<Polygon2>::type >::type >::apply(interior_rings(destination), num_interior_rings(source)); typename interior_return_type<Polygon1 const>::type rings_source = interior_rings(source); typename interior_return_type<Polygon2>::type rings_dest = interior_rings(destination); BOOST_AUTO_TPL(it_source, pdalboost::begin(rings_source)); BOOST_AUTO_TPL(it_dest, pdalboost::begin(rings_dest)); for ( ; it_source != pdalboost::end(rings_source); ++it_source, ++it_dest) { per_ring::apply(*it_source, *it_dest); } }
static inline void apply(Polygon const& polygon_in, ring_identifier id, Polygon& polygon_out, MarkMap const& mark_map) { typedef typename geometry::ring_type<Polygon>::type ring_type; typedef range_remove_marked<ring_type, MarkMap> per_range; id.ring_index = -1; per_range::apply(exterior_ring(polygon_in), id, exterior_ring(polygon_out), mark_map); typename interior_return_type<Polygon const>::type rings_in = interior_rings(polygon_in); typename interior_return_type<Polygon>::type rings_out = interior_rings(polygon_out); rings_out.resize(boost::size(interior_rings(polygon_in))); BOOST_AUTO_TPL(out, boost::begin(rings_out)); for (BOOST_AUTO_TPL(it, boost::begin(rings_in)); it != boost::end(rings_in); ++it, ++out) { id.ring_index++; per_range::apply(*it, id, *out, mark_map); } }
static inline void apply(PolygonInput const& polygon, PolygonOutput& buffered, typename coordinate_type<PolygonOutput>::type distance, JoinStrategy const& join_strategy #ifdef BOOST_GEOMETRY_DEBUG_WITH_MAPPER , Mapper& mapper #endif ) { geometry::clear(buffered); typedef typename ring_type<PolygonInput>::type input_ring_type; typedef typename ring_type<PolygonOutput>::type output_ring_type; typedef ring_buffer<input_ring_type, output_ring_type, JoinStrategy> policy; policy::apply(exterior_ring(polygon), exterior_ring(buffered), distance, join_strategy #ifdef BOOST_GEOMETRY_DEBUG_WITH_MAPPER , mapper #endif ); typename interior_return_type<PolygonInput const>::type rings = interior_rings(polygon); for (BOOST_AUTO_TPL(it, boost::begin(rings)); it != boost::end(rings); ++it) { output_ring_type ring; policy::apply(*it, ring, distance, join_strategy #ifdef BOOST_GEOMETRY_DEBUG_WITH_MAPPER , mapper #endif ); interior_rings(buffered).push_back(ring); } }
static inline void apply(Destination& destination, Source const& source, bool append, bool reverse) { if (! append) { geometry::convert(source, exterior_ring(destination)); if (reverse) { boost::reverse(exterior_ring(destination)); } } else { // Avoid adding interior rings which are invalid // because of its number of points: std::size_t const min_num_points = core_detail::closure::minimum_ring_size < geometry::closure<Destination>::value >::value; if (geometry::num_points(source) >= min_num_points) { interior_rings(destination).resize( interior_rings(destination).size() + 1); geometry::convert(source, interior_rings(destination).back()); if (reverse) { boost::reverse(interior_rings(destination).back()); } } } }
static inline void apply(P& polygon, R const& range, int ring_index, int multi_index) { if (ring_index == -1) { append_range<ring_type, R, Std>::apply(exterior_ring(polygon), range, -1, -1); } else if (ring_index < boost::size(interior_rings(polygon))) { append_range<ring_type, R, Std>::apply(interior_rings(polygon)[ring_index], range, -1, -1); } }
static inline void apply(P& polygon, T const& point, int ring_index, int multi_index) { boost::ignore_unused_variable_warning(multi_index); if (ring_index == -1) { append_point<range_type, T, Std>::apply(exterior_ring(polygon), point, -1, -1); } else if (ring_index < boost::size(interior_rings(polygon))) { append_point<range_type, T, Std>::apply(interior_rings(polygon)[ring_index], point, -1, -1); } }
static inline typename ring_return_type<Polygon const>::type const apply( ring_identifier const& id, Polygon const& polygon) { BOOST_ASSERT ( id.ring_index >= -1 && id.ring_index < boost::size(interior_rings(polygon)) ); return id.ring_index < 0 ? exterior_ring(polygon) : interior_rings(polygon)[id.ring_index]; }
static inline double apply(Polygon const& poly, S const& strategy) { typedef typename ring_type<Polygon>::type ring_type; typedef typename boost::range_const_iterator < typename interior_type<Polygon>::type >::type iterator_type; double sum = std::abs(range_perimeter<ring_type, S>::apply(exterior_ring(poly), strategy)); for (iterator_type it = boost::begin(interior_rings(poly)); it != boost::end(interior_rings(poly)); it++) { sum += std::abs(range_perimeter<ring_type, S>::apply(*it, strategy)); } return sum; }
static inline void apply(Polygon& poly, Predicate const& predicate) { typename interior_type<Polygon>::type& rings = interior_rings(poly); // Remove rings using erase-remove-idiom // http://en.wikipedia.org/wiki/Erase-remove_idiom rings.erase( std::remove_if(boost::begin(rings), boost::end(rings), predicate), boost::end(rings)); }
static inline void apply(Polygon& polygon, Geometry const& input, T const& distance) { interior_rings(polygon).erase ( std::remove_if ( boost::begin(interior_rings(polygon)), boost::end(interior_rings(polygon)), remove_false_ring_predicate < typename ring_type<Polygon>::type, Geometry, T >(input, distance) ), boost::end(interior_rings(polygon)) ); }
static inline void apply(std::basic_ostream<Char, Traits>& os, Polygon const& poly) { typedef typename ring_type<Polygon>::type ring; typedef typename boost::range_const_iterator< typename interior_type<Polygon>::type>::type iterator; os << PrefixPolicy::apply(); // TODO: check EMPTY here os << "("; wkt_sequence<ring>::apply(os, exterior_ring(poly)); for (iterator it = boost::begin(interior_rings(poly)); it != boost::end(interior_rings(poly)); ++it) { os << ","; wkt_sequence<ring>::apply(os, *it); } os << ")"; }
static inline void apply(Polygon& poly, Functor& f) { fe_range_per_segment::apply(exterior_ring(poly), f); typename interior_return_type<Polygon>::type rings = interior_rings(poly); for (BOOST_AUTO_TPL(it, boost::begin(rings)); it != boost::end(rings); ++it) { fe_range_per_segment::apply(*it, f); } }
static inline void apply(Polygon& poly, Predicate const& predicate) { // TODO: evaluate this behaviour w.r.t. writable concepts typename interior_return_type<Polygon>::type rings = interior_rings(poly); // Remove rings using erase-remove-idiom // http://en.wikipedia.org/wiki/Erase-remove_idiom rings.erase( std::remove_if(boost::begin(rings), boost::end(rings), predicate), boost::end(rings)); }
static inline bool apply(Polygon1 const& poly1, Polygon2& poly2, Strategy const& strategy) { typedef typename ring_type<Polygon1>::type ring1_type; typedef typename ring_type<Polygon2>::type ring2_type; typedef typename point_type<Polygon2>::type point2_type; geometry::clear(poly2); if (!transform_range_out<point2_type>(exterior_ring(poly1), std::back_inserter(exterior_ring(poly2)), strategy)) { return false; } // Note: here a resizeable container is assumed. traits::resize < typename boost::remove_reference < typename traits::interior_mutable_type<Polygon2>::type >::type >::apply(interior_rings(poly2), num_interior_rings(poly1)); typename interior_return_type<Polygon1 const>::type rings1 = interior_rings(poly1); typename interior_return_type<Polygon2>::type rings2 = interior_rings(poly2); BOOST_AUTO_TPL(it1, boost::begin(rings1)); BOOST_AUTO_TPL(it2, boost::begin(rings2)); for ( ; it1 != boost::end(interior_rings(poly1)); ++it1, ++it2) { if (!transform_range_out<point2_type>(*it1, std::back_inserter(*it2), strategy)) { return false; } } return true; }
static inline void apply(Polygon const& poly, Strategy const& strategy, typename Strategy::state_type& state) { typedef centroid_ring_state < typename ring_type<Polygon>::type, Strategy > per_ring; per_ring::apply(exterior_ring(poly), strategy, state); for (typename boost::range_const_iterator < typename interior_type<Polygon>::type >::type it = boost::begin(interior_rings(poly)); it != boost::end(interior_rings(poly)); ++it) { per_ring::apply(*it, strategy, state); } }
static inline void apply(Polygon& polygon, ComparePolicy const& policy) { range_unique::apply(exterior_ring(polygon), policy); typename interior_return_type<Polygon>::type rings = interior_rings(polygon); for (typename detail::interior_iterator<Polygon>::type it = boost::begin(rings); it != boost::end(rings); ++it) { range_unique::apply(*it, policy); } }
static inline void apply(Destination& destination, Source const& source, bool append, bool reverse) { if (! append) { geometry::convert(source, exterior_ring(destination)); if (reverse) { boost::reverse(exterior_ring(destination)); } } else { interior_rings(destination).resize( interior_rings(destination).size() + 1); geometry::convert(source, interior_rings(destination).back()); if (reverse) { boost::reverse(interior_rings(destination).back()); } } }
static inline void apply(Polygon& poly, Functor& f) { fe_range_per_segment::apply(exterior_ring(poly), f); typename interior_return_type<Polygon>::type rings = interior_rings(poly); for (typename detail::interior_iterator<Polygon>::type it = boost::begin(rings); it != boost::end(rings); ++it) { fe_range_per_segment::apply(*it, f); } }
static inline void apply(Polygon& polygon, ComparePolicy const& policy) { typedef typename geometry::ring_type<Polygon>::type ring_type; range_unique::apply(exterior_ring(polygon), policy); typename interior_return_type<Polygon>::type rings = interior_rings(polygon); for (BOOST_AUTO_TPL(it, boost::begin(rings)); it != boost::end(rings); ++it) { range_unique::apply(*it, policy); } }
static inline void apply(Polygon const& poly_in, Polygon& poly_out, Distance const& max_distance, Strategy const& strategy) { typedef typename ring_type<Polygon>::type ring_type; int const Minimum = core_detail::closure::minimum_ring_size < geometry::closure<Polygon>::value >::value; // Note that if there are inner rings, and distance is too large, // they might intersect with the outer ring in the output, // while it didn't in the input. simplify_range<ring_type, Strategy, Minimum>::apply(exterior_ring(poly_in), exterior_ring(poly_out), max_distance, strategy); traits::resize < typename boost::remove_reference < typename traits::interior_mutable_type<Polygon>::type >::type >::apply(interior_rings(poly_out), num_interior_rings(poly_in)); typename interior_return_type<Polygon const>::type rings_in = interior_rings(poly_in); typename interior_return_type<Polygon>::type rings_out = interior_rings(poly_out); BOOST_AUTO_TPL(it_out, boost::begin(rings_out)); for (BOOST_AUTO_TPL(it_in, boost::begin(rings_in)); it_in != boost::end(rings_in); ++it_in, ++it_out) { simplify_range<ring_type, Strategy, Minimum>::apply(*it_in, *it_out, max_distance, strategy); } }
static inline void apply(Polygon& polygon, Point const& point, int ring_index, int = 0) { if (ring_index == -1) { append_point<ring_type, Point>::apply( exterior_ring(polygon), point); } else if (ring_index < int(num_interior_rings(polygon))) { append_point<ring_type, Point>::apply( range::at(interior_rings(polygon), ring_index), point); } }
static inline void apply(Polygon& polygon, Range const& range, int ring_index, int = 0) { if (ring_index == -1) { append_range<ring_type, Range>::apply( exterior_ring(polygon), range); } else if (ring_index < int(num_interior_rings(polygon))) { append_range<ring_type, Range>::apply( range::at(interior_rings(polygon), ring_index), range); } }
static inline void apply(Collection& collection, Polygon const& polygon) { typedef typename geometry::ring_type<Polygon>::type ring_type; typedef range_collect_vectors<ring_type, Collection> per_range; per_range::apply(collection, exterior_ring(polygon)); typename interior_return_type<Polygon const>::type rings = interior_rings(polygon); for (BOOST_AUTO_TPL(it, boost::begin(rings)); it != boost::end(rings); ++it) { per_range::apply(collection, *it); } }
static inline void apply(Polygon& polygon) { typedef typename geometry::ring_type<Polygon>::type ring_type; typedef range_remove_spikes<ring_type> per_range; per_range::apply(exterior_ring(polygon)); typename interior_return_type<Polygon>::type rings = interior_rings(polygon); for (BOOST_AUTO_TPL(it, boost::begin(rings)); it != boost::end(rings); ++it) { per_range::apply(*it); } }
static inline std::size_t apply(Polygon const& poly) { std::size_t n = RangeCount::apply(exterior_ring(poly)); typename interior_return_type<Polygon const>::type rings = interior_rings(poly); for (typename detail::interior_iterator<Polygon const>::type it = geofeatures_boost::begin(rings); it != geofeatures_boost::end(rings); ++it) { n += RangeCount::apply(*it); } return n; }
static inline void process_polygon(Polygon const& polygon, double* xp, double* yp, int* parts, int& offset, int& ring) { parts[ring++] = offset; offset = range_to_part(geometry::exterior_ring(polygon), xp, yp, offset); typename interior_return_type<Polygon const>::type rings = interior_rings(polygon); for (BOOST_AUTO_TPL(it, boost::begin(rings)); it != boost::end(rings); ++it) { parts[ring++] = offset; offset = range_to_part(*it, xp, yp, offset); } }
static inline void apply(Polygon const& poly, Strategy const& strategy, typename Strategy::state_type& state) { typedef typename ring_type<Polygon>::type ring_type; typedef centroid_range_state<geometry::closure<ring_type>::value> per_ring; per_ring::apply(exterior_ring(poly), strategy, state); typename interior_return_type<Polygon const>::type rings = interior_rings(poly); for (BOOST_AUTO_TPL(it, boost::begin(rings)); it != boost::end(rings); ++it) { per_ring::apply(*it, strategy, state); } }
static inline std::size_t apply(Polygon const& poly, bool add_for_open) { typedef typename geometry::ring_type<Polygon>::type ring_type; std::size_t n = range_count::apply( exterior_ring(poly), add_for_open); typename interior_return_type<Polygon const>::type rings = interior_rings(poly); for (BOOST_AUTO_TPL(it, boost::begin(rings)); it != boost::end(rings); ++it) { n += range_count::apply(*it, add_for_open); } return n; }
static inline void apply(Polygon const& polygon, ring_identifier id, RingPropertyMap& ring_properties) { typedef typename geometry::ring_type<Polygon>::type ring_type; typedef select_rings<ring_tag, ring_type> per_ring; per_ring::apply(exterior_ring(polygon), id, ring_properties); typename interior_return_type<Polygon const>::type rings = interior_rings(polygon); for (typename detail::interior_iterator<Polygon const>::type it = boost::begin(rings); it != boost::end(rings); ++it) { id.ring_index++; per_ring::apply(*it, id, ring_properties); } }
static inline void apply(Polygon& polygon) { traits::clear < typename boost::remove_reference < typename traits::interior_mutable_type<Polygon>::type >::type >::apply(interior_rings(polygon)); traits::clear < typename boost::remove_reference < typename traits::ring_mutable_type<Polygon>::type >::type >::apply(exterior_ring(polygon)); }