Browse Source

v.distance: manual update, bug fix

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@53459 15284696-431f-4ddb-bdfa-cd5b030d7da7
Markus Metz 12 years ago
parent
commit
478682ae17
2 changed files with 20 additions and 4 deletions
  1. 13 2
      vector/v.distance/main.c
  2. 7 2
      vector/v.distance/v.distance.html

+ 13 - 2
vector/v.distance/main.c

@@ -308,7 +308,7 @@ int main(int argc, char *argv[])
     Vect_set_open_level(2);
     Vect_open_old2(&To, opt.to->answer, "", opt.to_field->answer);
 
-    ntolines = Vect_get_num_primitives(&To, from_type);
+    ntolines = Vect_get_num_primitives(&To, to_type);
     ntoareas = 0;
     if (to_type & GV_AREA)
 	ntoareas = Vect_get_num_areas(&To);
@@ -714,6 +714,10 @@ int main(int argc, char *argv[])
 		G_debug(3, "  %d areas in box", aList->n_values);
 
 		for (i = 0; i < aList->n_values; i++) {
+		    /* ignore isles OK ? */
+		    if (Vect_get_area_centroid(&To, aList->id[i]) == 0)
+			continue;
+
 		    tmp_tcat = -1;
 
 		    line2area(&To, FPoints, ftype, aList->id[i], &aList->box[i],
@@ -832,7 +836,10 @@ int main(int argc, char *argv[])
 	    G_debug(3, "farea = %d", area);
 	    G_percent(area, nfromareas, 2);
 
-	    Vect_get_area_cats(&From, area, FCats);
+	    if (Vect_get_area_cats(&From, area, FCats) == 1)
+		/* ignore isles OK ? */
+		continue;
+
 	    Vect_cat_get(FCats, from_field, &fcat);
 	    if (fcat < 0 && !do_all)
 		continue;
@@ -970,6 +977,10 @@ int main(int argc, char *argv[])
 		    tarea = aList->id[i];
 		    G_debug(4, "%d: 'to' area id %d", i, tarea);
 
+		    /* ignore isles OK ? */
+		    if (Vect_get_area_centroid(&To, tarea) == 0)
+			continue;
+
 		    Vect_get_area_points(&To, tarea, TPoints);
 		    
 		    ttype = GV_BOUNDARY;

+ 7 - 2
vector/v.distance/v.distance.html

@@ -37,7 +37,12 @@ For anything else than points to lines, there can be several common
 locations with zero distance, and the common location would then be the 
 result of an overlay consisting of several points, lines, or areas.
 <em>v.distance</em> selects in these cases a single point, and does not 
-create an overlay like <em>v.overlay</em>.
+create an overlay like <em>v.overlay</em>. In this implementation, any 
+shared point is as good as any other. Calculating an intersection is 
+costlier than to check if a vertex is inside a polygon. For example, if 
+a vertex of the boundary of the 'to' area is inside the 'from' area, it 
+is a common location. For speed reasons, the distance is then set to 
+zero and no further tests are done.
 
 
 <h2>NOTES</h2>
@@ -49,7 +54,7 @@ updated to <em>null</em>.
 
 <!-- needs Vect_line_geodesic_distance()
 <p>In lat-long locations <em>v.distance</em> gives distances 
-(<em>dist</em> and <em>to_along</em>) in meters not in degrees 
+(<em>dist</em> and <em>to_along</em>) not in degrees but in meters  
 calculated as geodesic distances on a sphere.
 -->