[GRASS-dev] small patch for lib/vector/transform/

Dylan Beaudette dylan.beaudette at gmail.com
Sat Jun 2 18:22:23 EDT 2007


Hi Glynn, thanks for the pointers. Still a relatively new user of the 
conventional dev tools...

On Saturday 02 June 2007 04:35, Glynn Clements wrote:
> Dylan Beaudette wrote:
> > I needed some functionality to print the transformation matrix, very
> > simple patch - it might be useful to others.
> >
> > It prints out the matrix along with a small note:
> >
> > Transformation Matrix
> > ---------------------
> > 28155.882288 0.013530 1.002469
> > -5301.399323 0.997547 -0.009172
> > ---------------------
> >
> > the patch is attached.
> >
> > Perhaps diagnostics like this might be a general use.
> >
> >
> > --
> > Dylan Beaudette
> > Soils and Biogeochemistry Graduate Group
> > University of California at Davis
> > 530.754.7341
> > Index: lib/vector/transform/transform.c
> > ===================================================================
> > RCS file:
> > /home/grass/grassrepository/grass6/lib/vector/transform/transform.c,v
> > retrieving revision 1.2
> > diff -r1.2 transform.c
> > 146a147,152
> >
> > > printf("Transformation Matrix\n");
> > > printf("------------------------------------------\n");
> > > printf("%f %f %f \n", B0, B1, B2);
> > > printf("%f %f %f \n", B3, B4, B5);
> > > printf("------------------------------------------\n");
>
> First, patches should use either unified or context format (preferably
> unified). However ...

ok, I will read up on how to do this.

> Library code shouldn't be unconditionally printing diagnostic
> information (especially not to stdout); use G_debug() instead.

good call, that was definitely bad style on my part. Instead of debug, a flag 
might be a good option?

> If you need to print this information in normal use (without debugging
> enabled), add a separate get_transformation_matrix() function to that
> file.

This sounds reasonable. If possible it might be nice as a flag to v.transform. 

> Alternatively, you can implement it within your module using
> transform_b_into_a(), i.e.:
>
> 	double B0, B1, B2, B3, B4, B5;
>
> 	transform_b_into_a(0, 0, &B0, &B3);
> 	transform_b_into_a(1, 0, &B1, &B4);
> 	B1 -= B0; B4 -= B3;
> 	transform_b_into_a(0, 1, &B2, &B5);
> 	B2 -= B0; B5 -= B3;

I will submit the new patch to the tracker.

thanks!


-- 
Dylan Beaudette
Soils and Biogeochemistry Graduate Group
University of California at Davis
530.754.7341




More information about the grass-dev mailing list