On 11/08/08 17:02, Markus Neteler wrote:
On Mon, Aug 11, 2008 at 12:02 PM, G. Allegri <[EMAIL PROTECTED]> wrote:
Hi list.
I need to evaluate the shortest distance between the points of the same layer .
v.distance fails as to_map and from_map overlap (every shortest
distance is obviously 0: from point to itself). I was considering the
use of network analysis tools... but I don't see a straigthforward way
with them.

The best would be to have v.univar calculate these values.
Min and max algorithms are already built-in, it "just" needs
to be extended to consider not only attributes but also geometry.
(maybe with a flag to consider geometry instead of attributes?)

IIUC, Giovanni is not looking for one number, i.e. minimum of all the distances between points in a map, but rather for the distance from each point in a map to the closest other point in the same map. Please correct me if I'm wrong.

The attached diff seems to work, but needs testing. I also filed this as an enhancement wish in the tracker.

Moritz
Index: main.c
===================================================================
--- main.c	(révision 32687)
+++ main.c	(copie de travail)
@@ -78,12 +78,12 @@
     struct GModule *module;
     struct Option *from_opt, *to_opt, *from_type_opt, *to_type_opt,
 	*from_field_opt, *to_field_opt;
-    struct Option *out_opt, *max_opt, *table_opt;
+    struct Option *out_opt, *max_opt, *min_opt, *table_opt;
     struct Option *upload_opt, *column_opt, *to_column_opt;
     struct Flag *print_flag, *all_flag;
     struct Map_info From, To, Out, *Outp;
     int from_type, to_type, from_field, to_field;
-    double max;
+    double max, min;
     struct line_pnts *FPoints, *TPoints;
     struct line_cats *FCats, *TCats;
     NEAR *Near, *near;
@@ -164,6 +164,13 @@
     max_opt->answer = "-1";
     max_opt->description = _("Maximum distance or -1 for no limit");
 
+    min_opt = G_define_option();
+    min_opt->key = "dmin";
+    min_opt->type = TYPE_DOUBLE;
+    min_opt->required = NO;
+    min_opt->answer = "-1";
+    min_opt->description = _("Minimum distance or -1 for no limit");
+
     upload_opt = G_define_option();
     upload_opt->key = "upload";
     upload_opt->type = TYPE_STRING;
@@ -230,6 +237,7 @@
     to_field = atoi(to_field_opt->answer);
 
     max = atof(max_opt->answer);
+    min = atof(min_opt->answer);
 
     if (all_flag->answer)
 	all = 1;
@@ -543,7 +551,7 @@
 		Vect_point_on_line(TPoints, tmp_talong, NULL, NULL, NULL,
 				   &tmp_tangle, NULL);
 
-		if (tmp_dist > max)
+		if (tmp_dist > max || tmp_dist < min)
 		    continue;	/* not in threshold */
 
 		/* TODO: more cats of the same field */
_______________________________________________
grass-user mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/grass-user

Reply via email to