[GRASS-user] problem in v.drape command
Dylan Beaudette
dylan.beaudette at gmail.com
Tue Jul 10 02:12:29 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
A patch based on this suggestion is attached. I have tested and it appears to
work.
Dylan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: v.drape-region-fix.patch
Type: text/x-diff
Size: 9521 bytes
Desc: not available
Url : http://lists.osgeo.org/pipermail/grass-user/attachments/20070709/8a95cddf/v.drape-region-fix.bin
More information about the grass-user
mailing list