[GRASS-SVN] r64671 - grass/trunk/vector/v.to.db

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Feb 17 14:43:13 PST 2015


Author: mmetz
Date: 2015-02-17 14:43:13 -0800 (Tue, 17 Feb 2015)
New Revision: 64671

Modified:
   grass/trunk/vector/v.to.db/areas.c
Log:
v.to.db: fix area options

Modified: grass/trunk/vector/v.to.db/areas.c
===================================================================
--- grass/trunk/vector/v.to.db/areas.c	2015-02-17 22:08:44 UTC (rev 64670)
+++ grass/trunk/vector/v.to.db/areas.c	2015-02-17 22:43:13 UTC (rev 64671)
@@ -19,7 +19,6 @@
     int i, idx, found;
     int area_num, nareas;
     struct line_cats *Cats;
-    struct line_pnts *Ppoints;
     double area, perimeter;
 
     Cats = Vect_new_cats_struct();
@@ -29,7 +28,6 @@
 
     /* Cycle through all areas */
     for (area_num = 1; area_num <= nareas; area_num++) {
-	Ppoints = Vect_new_line_struct();
 	area = 0;
 	perimeter = 0;
 
@@ -65,15 +63,24 @@
 		    found = 1;
 		}
 	    }
-	    /* why do we do this? */
-	    if (!found) {	/* no category found */
-		idx = find_cat(0, 1);
-		if (options.option == O_AREA) {
+
+	    if (!found) {	/* Values for no category (cat = -1) are reported at the end */
+		idx = find_cat(-1, 1);
+		switch (options.option) {
+		case O_AREA:
 		    Values[idx].d1 += area;
+		    break;
+		case O_PERIMETER:
+		    Values[idx].d1 += perimeter;
+		    break;
+		case O_COMPACT:
+		    Values[idx].d1 =
+			perimeter / (2.0 * sqrt(M_PI * area));
+		    break;
+		case O_FD:
+		    Values[idx].d1 = 2.0 * log(perimeter) / log(area);
+		    break;
 		}
-		else if (options.option == O_PERIMETER) {
-		    Values[idx].d1 += area;
-		}
 	    }
 	}
 	G_percent(area_num, nareas, 2);



More information about the grass-commit mailing list