On 28/08/14 16:02, Alessandro Samuel Rosa wrote:
I will follow your suggestion as far such functionality is not
implemented in v.perturb.
Attached a very crude and untested attempt at a region check. If you can
compile GRASS, you could try to see if it works. It should probably be
made conditional on a flag as most people would not expect a vector
module to take region settings into account.
You can also file an enhancement request in the GRASS Trac.
Moritz
Index: main.c
===================================================================
--- main.c (révision 61745)
+++ main.c (copie de travail)
@@ -37,6 +37,7 @@
double p1, p2, numbers[1000], numbers2[1000];
int (*rng) ();
int i;
+ int pointinregion;
int line, nlines, ttype, n, ret, seed, field;
struct field_info *Fi, *Fin;
double min = 0.;
@@ -48,6 +49,7 @@
struct line_cats *Cats;
struct Cell_head window;
+ struct bound_box Box;
struct GModule *module;
struct
{
@@ -138,6 +140,7 @@
}
G_get_window(&window);
+ Vect_region_box(&window, &Box);
/* Open input */
Vect_set_open_level(2);
@@ -183,7 +186,10 @@
}
G_percent(line++, nlines, 4);
+ pointinregion=1;
+
if (type & GV_POINT) {
+ while (pointinregion) {
if (field != -1 && !Vect_cat_get(Cats, field, NULL))
continue;
@@ -224,6 +230,13 @@
G_debug(debuglevel, "x_pert: %f y_pert: %f", Points->x[0],
Points->y[0]);
+
+ /*Check that point falls into current region*/
+ if (!Vect_point_in_box(Points->x[0], Points->y[0], 0.0, &Box))
+ pointinregion=0;
+ else
+ pointinregion=1;
+ }
}
Vect_write_line(&Out, type, Points, Cats);
_______________________________________________
grass-dev mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/grass-dev