[GRASS-SVN] r53401 - grass/trunk/vector/v.distance

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Oct 15 07:14:42 PDT 2012


Author: mmetz
Date: 2012-10-15 07:14:42 -0700 (Mon, 15 Oct 2012)
New Revision: 53401

Modified:
   grass/trunk/vector/v.distance/distance.c
   grass/trunk/vector/v.distance/main.c
Log:
v.distance update

Modified: grass/trunk/vector/v.distance/distance.c
===================================================================
--- grass/trunk/vector/v.distance/distance.c	2012-10-15 14:13:35 UTC (rev 53400)
+++ grass/trunk/vector/v.distance/distance.c	2012-10-15 14:14:42 UTC (rev 53401)
@@ -96,6 +96,9 @@
 					 &tmp_dist, NULL, &tmp_along);
 	    if (*dist > tmp_dist) {
 		*dist = tmp_dist;
+		*fx = FPoints->x[i];
+		*fy = FPoints->y[i];
+		*fz = FPoints->z[i];
 		*tx = tmp_x;
 		*ty = tmp_y;
 		*tz = tmp_z;
@@ -126,6 +129,11 @@
 		*fy = tmp_y;
 		*fz = tmp_z;
 		*falong = tmp_along;
+		*tx = TPoints->x[i];
+		*ty = TPoints->y[i];
+		*tz = TPoints->z[i];
+		*talong = 0.;
+		*tangle = -9.;
 		fseg = tmp_seg;
 	    }
 	}

Modified: grass/trunk/vector/v.distance/main.c
===================================================================
--- grass/trunk/vector/v.distance/main.c	2012-10-15 14:13:35 UTC (rev 53400)
+++ grass/trunk/vector/v.distance/main.c	2012-10-15 14:14:42 UTC (rev 53401)
@@ -988,17 +988,28 @@
 			    if (FPoints->n_points == 0)
 				Vect_get_area_points(&From, area, FPoints);
 			    for (j = 0; j < FPoints->n_points; j++) {
-				poly = Vect_point_in_poly(FPoints->x[0], FPoints->y[0], TPoints);
+				poly = Vect_point_in_poly(FPoints->x[j], FPoints->y[j], TPoints);
 				if (poly)
 				    break;
 			    }
 			}
 			if (poly) {
+			    /* 'from' area is (partially) inside 'to' area,
+			     * get distance to 'to' area */
+			    poly = line2area(&To, FPoints, ttype, tarea, &aList->box[i],
+				      &tmp_fx, &tmp_fy, &tmp_fz, &tmp_falong, &tmp_fangle,
+				      &tmp_tx, &tmp_ty, &tmp_tz, &tmp_talong, &tmp_tangle,
+				      &tmp_dist, with_z, 0);
+
+			    /* inside isle ? */
+			    poly = poly == 2;
+			}
+			if (poly) {
 			    double tmp2_tx, tmp2_ty, tmp2_tz, tmp2_talong, tmp2_tangle;
 			    double tmp2_fx, tmp2_fy, tmp2_fz, tmp2_falong, tmp2_fangle;
 			    double tmp2_dist;
 
-			    /* 'from' area is inside 'to' area,
+			    /* 'from' area is (partially) inside 'to' area,
 			     * get distance to 'to' isles */
 			    nisles = Vect_get_area_num_isles(&To, tarea);
 			    for (j = 0; j < nisles; j++) {



More information about the grass-commit mailing list