Пример #1
0
    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);
        }
    }
Пример #2
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);
     }
 }
Пример #3
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);
     }
 }
Пример #4
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;
    }
Пример #5
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);
        }
    }