[GRASS-SVN] r53459 - grass/trunk/vector/v.distance
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Oct 17 23:50:52 PDT 2012
Author: mmetz
Date: 2012-10-17 23:50:52 -0700 (Wed, 17 Oct 2012)
New Revision: 53459
Modified:
grass/trunk/vector/v.distance/main.c
grass/trunk/vector/v.distance/v.distance.html
Log:
v.distance: manual update, bug fix
Modified: grass/trunk/vector/v.distance/main.c
===================================================================
--- grass/trunk/vector/v.distance/main.c 2012-10-17 21:46:27 UTC (rev 53458)
+++ grass/trunk/vector/v.distance/main.c 2012-10-18 06:50:52 UTC (rev 53459)
@@ -308,7 +308,7 @@
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 @@
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 @@
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 @@
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;
Modified: grass/trunk/vector/v.distance/v.distance.html
===================================================================
--- grass/trunk/vector/v.distance/v.distance.html 2012-10-17 21:46:27 UTC (rev 53458)
+++ grass/trunk/vector/v.distance/v.distance.html 2012-10-18 06:50:52 UTC (rev 53459)
@@ -37,7 +37,12 @@
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 @@
<!-- 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.
-->
More information about the grass-commit
mailing list