Browse Source

v.distance update

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@53401 15284696-431f-4ddb-bdfa-cd5b030d7da7
Markus Metz 12 years ago
parent
commit
7718c2cb1d
2 changed files with 21 additions and 2 deletions
  1. 8 0
      vector/v.distance/distance.c
  2. 13 2
      vector/v.distance/main.c

+ 8 - 0
vector/v.distance/distance.c

@@ -96,6 +96,9 @@ int line2line(struct line_pnts *FPoints, int ftype,
 					 &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 @@ int line2line(struct line_pnts *FPoints, int ftype,
 		*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;
 	    }
 	}

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

@@ -988,17 +988,28 @@ int main(int argc, char *argv[])
 			    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++) {