[GRASS-user] problem in v.drape command

Dylan Beaudette dylan.beaudette at gmail.com
Tue Jul 10 00:33:14 EDT 2007


On Monday 09 July 2007 20:07, Hamish wrote:
> Dylan Beaudette wrote:
> > The v.drape module was created by suggestion of Radim, and implemented
> > by an  amateur (me). This bug is one of the last remaining issues in
> > the code.  Although it is mentioned in the manual page, it would be
> > good to do a simple  test of
> >
> > if vector %in% current region or vector %in% raster bbox
> > then run else error and exit
> >
> > I am not sure how to implement this check, but if I get some feedback
> > I will  submit a patch!
>
> I think the libgis error is appropriate, but that v.drape should not be
> trying to load a raster array i,j which is out of range. Perhaps in
> these cases the Z value should be set to NULL (nan), or if that is
> illegal either set to 0 (with warning) or G_fatal_error() out.
>
> You can check in map is contained within the current region by reading
> the map header info and the current region settings,
>
> e.g. read current region into "window":
>
> struct Cell_head window;
> G_get_window(&window);
>
> then you have doubles: window.north, .south, .east, .west, .top, .bottom
>
>
>
> To read vector bounds:
>
> struct Map_info Map;
> BOUND_BOX box;
>
> Vect_open_old_head (&Map, input->answer, mapset);
> Vect_get_map_box (&Map, &box);
>
> then you have doubles: box.N, box.S, box.E, box.W, box.T, box.B
>
>
>
> compare:
>
> if ( (box.N > window.north) || (box.S < window.south) ||
>      (box.E > window.east) || (box.W < window.west) )
>     G_warning("Vector exists outside of raster region");
>
> ...
>
>
> Hamish

Ok I will give it a shot, and post the patch when it is working!

cheers,

Dylan

PS: do you think that we should exit after issuing the warning? If so, is 
there a G_ function to do that cleanly?










More information about the grass-user mailing list