Segment Transformation

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Segment Transformation

Bernhard
Hi & thanks again for answering my last question.

I'm trying to transform segments, but it doesn't work. Is this a bug, or am I doing something wrong?
Slightly changed transformation example:

#include <boost/geometry.hpp>
int main()
{
    namespace trans = boost::geometry::strategy::transform;
    using boost::geometry::dsv;
   
    typedef boost::geometry::model::point<double, 2, boost::geometry::cs::cartesian> point_type;
    typedef boost::geometry::model::segment<point_type> segment_type;

    point_type p1(1.0, 1.0);
    point_type p2(2.0, 2.0);
    segment_type s1(p1, p2);
    segment_type s2;

    // Translate over (1.5, 1.5)
    trans::translate_transformer<segment_type, segment_type> translate(1.5, 1.5);
    //trans::rotate_transformer<segment_type, segment_type, boost::geometry::degree> rot(90);
    boost::geometry::transform(s1, s2, translate);

    return 0;
}

The error happens for both rotation and translation:
1>c:\libs\boost_1_47_0\boost/geometry/algorithms/transform.hpp(108): error C2664: 'boost::geometry::strategy::transform::ublas_transformer<P1,P2,Dimension1,Dimension2>::apply' : cannot convert parameter 1 from 'point_type1' to 'const segment_type &'

Now if I understand that correct (not an experienced template programmer), transform_box_or_segment tries to apply the strategy I defined (for segments) to the points of the segment, and that doesn't work.

Thanks in Advance,
Bernhard
Reply | Threaded
Open this post in threaded view
|

Re: Segment Transformation

Barend
Hi Bernhard,



>
> I'm trying to transform segments, but it doesn't work. Is this a bug, or am
> I doing something wrong?
> Slightly changed transformation example:
>
> #include&lt;boost/geometry.hpp&gt;
> int main()
> {
>      namespace trans = boost::geometry::strategy::transform;
>      using boost::geometry::dsv;
>
>      typedef boost::geometry::model::point&lt;double, 2,
> boost::geometry::cs::cartesian&gt; point_type;
>      typedef boost::geometry::model::segment<point_type>  segment_type;
>
>      point_type p1(1.0, 1.0);
>      point_type p2(2.0, 2.0);
>      segment_type s1(p1, p2);
>      segment_type s2;
>
>      // Translate over (1.5, 1.5)
>      trans::translate_transformer&lt;segment_type, segment_type&gt;
> translate(1.5, 1.5);
>      //trans::rotate_transformer&lt;segment_type, segment_type,
> boost::geometry::degree&gt; rot(90);
>      boost::geometry::transform(s1, s2, translate);
>
>      return 0;
> }
>


The transformers should be declared like this:

trans::translate_transformer<point_type, point_type>  translate(1.5, 1.5);

It then works perfectly.

So the rationale is that this strategy (most, nearly all) are declared
using a point-type as a template parameter. The free functions then work
on any parameter type.

Regards, Barend


_______________________________________________
ggl mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/ggl