[GRASS-SVN] r33272 - grass/trunk/display/d.thematic.area

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Sep 5 06:21:18 EDT 2008


Author: mlennert
Date: 2008-09-05 06:21:18 -0400 (Fri, 05 Sep 2008)
New Revision: 33272

Modified:
   grass/trunk/display/d.thematic.area/main.c
Log:
we need the data array in any case, not only when algo= is used


Modified: grass/trunk/display/d.thematic.area/main.c
===================================================================
--- grass/trunk/display/d.thematic.area/main.c	2008-09-05 08:26:32 UTC (rev 33271)
+++ grass/trunk/display/d.thematic.area/main.c	2008-09-05 10:21:18 UTC (rev 33272)
@@ -230,6 +230,28 @@
 		 val.d));
     }
 
+    /*Get the sorted data */
+    ret = db_CatValArray_sort_by_value(&cvarr);
+    if (ret == DB_FAILED)
+	G_fatal_error("Could not sort array of values..");
+
+
+    data = (double *)G_malloc((nrec) * sizeof(double));
+    for (i = 0; i < nrec; i++)
+	data[i] = 0.0;
+
+    ctype = cvarr.ctype;
+    if (ctype == DB_C_TYPE_INT) {
+	for (i = 0; i < nrec; i++)
+	    data[i] = cvarr.value[i].val.i;
+    }
+    else {
+	for (i = 0; i < nrec; i++)
+	    data[i] = cvarr.value[i].val.d;
+    }
+    db_CatValArray_sort(&cvarr);
+
+
     /*Get the list of relevant cats if where option is given */
     if (where_opt->answer) {
 	ncat = db_select_int(driver, fi->table, fi->key, where_opt->answer,
@@ -290,27 +312,7 @@
 
 	if (algo_opt->answer && nbclass_opt->answer) {
 
-	    ret = db_CatValArray_sort_by_value(&cvarr);
-	    if (ret == DB_FAILED)
-		G_fatal_error("Could not sort array of values..");
 
-
-	    data = (double *)G_malloc((nrec) * sizeof(double));
-	    for (i = 0; i < nrec; i++)
-		data[i] = 0.0;
-
-	    ctype = cvarr.ctype;
-	    if (ctype == DB_C_TYPE_INT) {
-		for (i = 0; i < nrec; i++)
-		    data[i] = cvarr.value[i].val.i;
-	    }
-	    else {
-		for (i = 0; i < nrec; i++)
-		    data[i] = cvarr.value[i].val.d;
-	    }
-
-	    db_CatValArray_sort(&cvarr);
-
 	    nclass = atoi(nbclass_opt->answer);
 	    nbreaks = nclass - 1;	/* we need one less classbreaks (min and 
 					 * max exluded) than classes */



More information about the grass-commit mailing list