[GRASS-SVN] r62749 - in grass/branches/releasebranch_7_0: . vector/v.neighbors

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Nov 15 12:44:27 PST 2014


Author: neteler
Date: 2014-11-15 12:44:27 -0800 (Sat, 15 Nov 2014)
New Revision: 62749

Modified:
   grass/branches/releasebranch_7_0/
   grass/branches/releasebranch_7_0/vector/v.neighbors/main.c
Log:
v.neighbors: add messages (backport trunk, r62746)


Property changes on: grass/branches/releasebranch_7_0
___________________________________________________________________
Modified: svn:mergeinfo
   - /grass/trunk:60817,61096,61141,62179-62180,62182,62403,62422,62424,62437,62466,62469,62487,62491,62494,62501,62506,62508-62509,62515,62518-62519,62521,62526,62533,62539,62541,62555,62562,62570,62573,62575,62585,62588,62597,62603,62606,62608-62609,62614,62618,62628,62632,62638,62642,62648-62649,62652,62654-62657,62666,62723,62730,62739,62741,62743
   + /grass/trunk:60817,61096,61141,62179-62180,62182,62403,62422,62424,62437,62466,62469,62487,62491,62494,62501,62506,62508-62509,62515,62518-62519,62521,62526,62533,62539,62541,62555,62562,62570,62573,62575,62585,62588,62597,62603,62606,62608-62609,62614,62618,62628,62632,62638,62642,62648-62649,62652,62654-62657,62666,62723,62730,62739,62741,62743,62746

Modified: grass/branches/releasebranch_7_0/vector/v.neighbors/main.c
===================================================================
--- grass/branches/releasebranch_7_0/vector/v.neighbors/main.c	2014-11-15 20:41:53 UTC (rev 62748)
+++ grass/branches/releasebranch_7_0/vector/v.neighbors/main.c	2014-11-15 20:44:27 UTC (rev 62749)
@@ -8,7 +8,7 @@
  *               
  * PURPOSE:      Category manipulations
  *               
- * COPYRIGHT:    (C) 2001-2009 by the GRASS Development Team
+ * COPYRIGHT:    (C) 2001-2014 by the GRASS Development Team
  *
  *               This program is free software under the GNU General
  *               Public License (>=v2).  Read the file COPYING that
@@ -19,6 +19,7 @@
 #include <string.h>
 #include <stdlib.h>
 #include <unistd.h>
+#include <math.h>
 
 #include <grass/gis.h>
 #include <grass/raster.h>
@@ -36,7 +37,7 @@
     struct Option *in_opt, *out_opt, *field_opt;
     struct Option *method_opt, *size_opt;
     struct Map_info In;
-    double radius;
+    double radius, dia;
     struct boxlist *List;
     struct Cell_head region;
     struct bound_box box;
@@ -87,6 +88,21 @@
     field = Vect_get_field_number(&In, field_opt->answer);
 
     G_get_set_window(&region);
+    Vect_get_map_box(&In, &box);
+    
+    if (box.N > region.north + radius || box.S < region.south - radius ||
+        box.E > region.east + radius || box.W < region.west - radius) {
+	Vect_close(&In);
+	G_fatal_error(_("Input vector and computational region do not overlap"));
+	exit(EXIT_FAILURE);
+    }
+
+    dia = sqrt(region.ns_res * region.ns_res + region.ew_res * region.ew_res);
+    if (radius * 2.0 < dia) {
+	G_warning(_("The search diameter %g is smaller than cell diagonal %g: some points could not be detected"),
+	          radius * 2, dia);
+    }
+
     nrows = Rast_window_rows();
     ncols = Rast_window_cols();
 
@@ -154,8 +170,8 @@
     Vect_close(&In);
     Rast_close(out_fd);
 
-    if (count_sum < 1)
-	G_warning(_("No points found"));
-    
+    if (count_sum < 1) 
+	G_warning(_("No points found")); 
+
     exit(EXIT_SUCCESS);
 }



More information about the grass-commit mailing list