Пример #1
0
    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(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);
        }
    }
Пример #3
0
    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 bool apply(Point& point, Polygon const& polygon)
 {
     return point_on_range
         <
             Midpoint
         >::apply(point, exterior_ring(polygon));
 }
Пример #5
0
    static inline void apply(Polygon & polygon, Actor & actor)
    {
        actor.apply(exterior_ring(polygon));

        // TODO: If some flag says true, also do the inner rings.
        // for convex hull, it's not necessary
    }
Пример #6
0
 static inline bool apply(Point& point, Polygon const& polygon, bool midpoint)
 {
     return point_on_range
         <
             Point,
             typename ring_type<Polygon>::type
         >::apply(point, exterior_ring(polygon), midpoint);
 }
Пример #7
0
    static inline void apply(
                    typename add_const_if_c<IsConst, Polygon>::type& polygon,
                    Actor& actor)
    {
        actor.apply(exterior_ring(polygon));

        // TODO: If some flag says true, also do the inner rings.
        // for convex hull, it's not necessary
    }
Пример #8
0
 static inline void apply(Ring const& ring, Polygon& polygon)
 {
     typedef typename ring_type<Polygon>::type ring_type;
     convert
         <
             ring_tag, ring_tag, DimensionCount,
             Ring, ring_type
         >::apply(ring, exterior_ring(polygon));
 }
Пример #9
0
 static inline bool apply(Polygon const& polygon)
 {
     return
         is_simple_ring
             <
                 typename ring_type<Polygon>::type
             >::apply(exterior_ring(polygon))
         &&
         are_simple_interior_rings(geometry::interior_rings(polygon));
 }
Пример #10
0
    static inline void apply(Polygon const& polygon, Ring& ring)
    {
        typedef typename ring_type<Polygon>::type ring_type;

        convert
            <
                ring_tag, ring_tag, DimensionCount,
                ring_type, Ring
            >::apply(exterior_ring(polygon), ring);
    }
Пример #11
0
 static inline void apply(Polygon const& poly, Point& centroid,
         Strategy const& strategy)
 {
     if (range_ok(exterior_ring(poly), centroid))
     {
         typename Strategy::state_type state;
         centroid_polygon_state::apply(poly, strategy, state);
         strategy.result(state, centroid);
     }
 }
Пример #12
0
    static inline void apply(Box const& box, Polygon& polygon)
    {
        typedef typename ring_type<Polygon>::type ring_type;

        convert
            <
                box_tag, ring_tag,
                2, Box, ring_type
            >::apply(box, exterior_ring(polygon));
    }
Пример #13
0
 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);
     }
 }
Пример #14
0
 static inline void apply(MultiPolygon const& mp, Box& mbr)
 {
     assign_inverse(mbr);
     for (typename boost::range_const_iterator<MultiPolygon>::type
                 it = mp.begin();
         it != mp.end();
         ++it)
     {
         envelope_range_additional(exterior_ring(*it), mbr);
     }
 }
Пример #15
0
    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);
        }
    }
Пример #16
0
    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& 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);
        }
    }
Пример #18
0
    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);
        }
    }
Пример #19
0
    static inline bool apply(Polygon const& poly, Point& centroid,
                             Strategy const& strategy)
    {
        if (range_ok(exterior_ring(poly), centroid))
        {
            // prepare translation transformer
            translating_transformer<Polygon>
                transformer(*boost::begin(exterior_ring(poly)));
            
            typename Strategy::state_type state;
            centroid_polygon_state::apply(poly, transformer, strategy, state);
            
            if ( strategy.result(state, centroid) )
            {
                // translate the result back
                transformer.apply_reverse(centroid);
                return true;
            }
        }

        return false;
    }
Пример #20
0
    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);
        }
    }
Пример #21
0
 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);
        }
    }
Пример #23
0
 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];
 }
Пример #24
0
    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);
        }
    }
Пример #25
0
    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);
        }
    }
Пример #26
0
 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);
     }
 }
Пример #27
0
    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;
    }
Пример #28
0
 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);
     }
 }
Пример #29
0
    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);
        }
    }
Пример #30
0
    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);
        }
    }