[GRASS-SVN] r43315 - grass/branches/releasebranch_6_4/vector/v.in.ogr

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Aug 27 14:53:36 EDT 2010


Author: mmetz
Date: 2010-08-27 18:53:36 +0000 (Fri, 27 Aug 2010)
New Revision: 43315

Modified:
   grass/branches/releasebranch_6_4/vector/v.in.ogr/geom.c
Log:
fix bug for min_area

Modified: grass/branches/releasebranch_6_4/vector/v.in.ogr/geom.c
===================================================================
--- grass/branches/releasebranch_6_4/vector/v.in.ogr/geom.c	2010-08-27 18:30:11 UTC (rev 43314)
+++ grass/branches/releasebranch_6_4/vector/v.in.ogr/geom.c	2010-08-27 18:53:36 UTC (rev 43315)
@@ -97,10 +97,19 @@
 	    if ((np = OGR_G_GetPointCount(hRing)) > 0) {
 		IPoints[valid_isles] = Vect_new_line_struct();
 		for (j = 0; j < np; j++) {
-		    Vect_append_point(IPoints[valid_isles], OGR_G_GetX(hRing, j),
-				      OGR_G_GetY(hRing, j), OGR_G_GetZ(hRing, j));
+		    Vect_append_point(IPoints[valid_isles],
+				      OGR_G_GetX(hRing, j),
+				      OGR_G_GetY(hRing, j),
+				      OGR_G_GetZ(hRing, j));
 		}
-		valid_isles++;
+		size =
+		    G_area_of_polygon(IPoints[valid_isles]->x,
+				      IPoints[valid_isles]->y,
+				      IPoints[valid_isles]->n_points);
+		if (size < min_area)
+		    Vect_destroy_line_struct(IPoints[valid_isles]);
+		else
+		    valid_isles++;
 	    }
 	}
 
@@ -274,17 +283,23 @@
 		IPoints[valid_isles] = Vect_new_line_struct();
 
 		for (j = 0; j < np; j++) {
-		    Vect_append_point(IPoints[valid_isles], OGR_G_GetX(hRing, j),
-				      OGR_G_GetY(hRing, j), OGR_G_GetZ(hRing, j));
+		    Vect_append_point(IPoints[valid_isles],
+				      OGR_G_GetX(hRing, j),
+				      OGR_G_GetY(hRing, j),
+				      OGR_G_GetZ(hRing, j));
 		}
 
 		if (IPoints[valid_isles]->n_points < 4)
 		    G_warning(_("Degenerate island ([%d] vertices)"),
 			      IPoints[i - 1]->n_points);
 
-		size = G_area_of_polygon(Points->x, Points->y, Points->n_points);
+		size =
+		    G_area_of_polygon(IPoints[valid_isles]->x,
+				      IPoints[valid_isles]->y,
+				      IPoints[valid_isles]->n_points);
 		if (size < min_area) {
-		    G_warning(_("Island size [%.1e], island not imported"), size);
+		    G_warning(_("Island size [%.1e], island not imported"),
+			      size);
 		}
 		else {
 		    if (type & GV_LINE)
@@ -295,15 +310,15 @@
 		}
 		valid_isles++;
 	    }
-	}	/* inner rings done */
+	}			/* inner rings done */
 
 	/* Centroid */
 	/* Vect_get_point_in_poly_isl() would fail for degenerate polygon */
 	if (mk_centr) {
 	    if (Points->n_points >= 4) {
 		ret =
-		    Vect_get_point_in_poly_isl(Points, IPoints, valid_isles, &x,
-					       &y);
+		    Vect_get_point_in_poly_isl(Points, IPoints, valid_isles,
+					       &x, &y);
 		if (ret == -1) {
 		    G_warning(_("Cannot calculate centroid"));
 		}



More information about the grass-commit mailing list