[GRASS-SVN] r32688 - in grass/trunk: display/d.thematic.area lib/arraystats vector/v.class

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Aug 11 11:59:06 EDT 2008


Author: mlennert
Date: 2008-08-11 11:59:04 -0400 (Mon, 11 Aug 2008)
New Revision: 32688

Modified:
   grass/trunk/display/d.thematic.area/area.c
   grass/trunk/display/d.thematic.area/main.c
   grass/trunk/lib/arraystats/class.c
   grass/trunk/vector/v.class/main.c
Log:
fix small bugs in d.thematic.area and disable discont algorithm until we fix it


Modified: grass/trunk/display/d.thematic.area/area.c
===================================================================
--- grass/trunk/display/d.thematic.area/area.c	2008-08-11 15:05:56 UTC (rev 32687)
+++ grass/trunk/display/d.thematic.area/area.c	2008-08-11 15:59:04 UTC (rev 32688)
@@ -33,11 +33,6 @@
     IPoints = Vect_new_line_struct();
     Cats = Vect_new_cats_struct();
 
-    /* We need to sort the CatValArray by cat for the bsearch in 
-     * db_CatValArray_get_value 
-     */
-    db_CatValArray_sort(cvarr);
-
     num = Vect_get_num_areas(Map);
     G_debug(2, "n_areas = %d", num);
 
@@ -151,6 +146,13 @@
 	    }
 	}
 
+        /* find out into which class breakval falls */
+        i = 0;
+        while (breakval > breaks[i] && i < nbreaks)
+        i++;
+
+
+
 	/* plot polygon in class color */
 	R_RGB_color(colors[i].r, colors[i].g, colors[i].b);
 	plot_polygon(Points->x, Points->y, Points->n_points);

Modified: grass/trunk/display/d.thematic.area/main.c
===================================================================
--- grass/trunk/display/d.thematic.area/main.c	2008-08-11 15:05:56 UTC (rev 32687)
+++ grass/trunk/display/d.thematic.area/main.c	2008-08-11 15:59:04 UTC (rev 32688)
@@ -107,8 +107,8 @@
     algo_opt->descriptions = _("int;simple intervals;"
 			       "std;standard deviations;"
 			       "qua;quantiles;"
-			       "equ;equiprobable (normal distribution);"
-			       "dis;discontinuities");
+			       "equ;equiprobable (normal distribution);");
+/*currently disabled because of bugs       "dis;discontinuities");*/
 
     nbclass_opt = G_define_option();
     nbclass_opt->key = "nbclasses";
@@ -354,6 +354,8 @@
 		max = cvarr.value[cvarr.n_values - 1].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 */
@@ -455,11 +457,13 @@
 	frequencies[i] = 0.0;
     class_frequencies(data, nrec, nbreaks, breakpoints, frequencies);
 
+    /*Get basic statistics about the data*/
+    basic_stats(data, nrec, &stats);
+
     if (legend_flag->answer) {
 
 	if (algoinfo_flag->answer) {
 
-	    basic_stats(data, nrec, &stats);
 
 	    fprintf(stdout, _("\nTotal number of records: %.0f\n"),
 		    stats.count);
@@ -481,7 +485,7 @@
 	}
 
 	fprintf(stdout, "%f|%f|%i|%d:%d:%d\n",
-		min, breakpoints[0], frequencies[0], colors[0].r, colors[0].g,
+		stats.min, breakpoints[0], frequencies[0], colors[0].r, colors[0].g,
 		colors[0].b);
 
 	for (i = 1; i < nbreaks; i++) {
@@ -490,7 +494,7 @@
 		    colors[i].r, colors[i].g, colors[i].b);
 	}
 	fprintf(stdout, "%f|%f|%i|%d:%d:%d\n",
-		breakpoints[nbreaks - 1], max, frequencies[nbreaks],
+		breakpoints[nbreaks - 1], stats.max, frequencies[nbreaks],
 		colors[nbreaks].r, colors[nbreaks].g, colors[nbreaks].b);
     }
 

Modified: grass/trunk/lib/arraystats/class.c
===================================================================
--- grass/trunk/lib/arraystats/class.c	2008-08-11 15:05:56 UTC (rev 32687)
+++ grass/trunk/lib/arraystats/class.c	2008-08-11 15:59:04 UTC (rev 32688)
@@ -17,7 +17,8 @@
     else if (G_strcasecmp(algo, "equ") == 0)
 	finfo = class_equiprob(data, nrec, nbreaks, classbreaks);
     else if (G_strcasecmp(algo, "dis") == 0)
-	finfo = class_discont(data, nrec, *nbreaks, classbreaks);
+	    /*	finfo = class_discont(data, nrec, *nbreaks, classbreaks); disabled because of bugs */
+        G_fatal_error(_("Discont algorithm currently not available because of bugs"));
     else
 	G_fatal_error(_("%s: Unknown algorithm"), algo);
 
@@ -239,7 +240,7 @@
     return (1);
 }
 
-
+/* FixMe: there seems to a problem with array overflow, probably due to the fact that the code was ported from fortran which has 1-based arrays*/
 double class_discont(double *data, int count, int nbreaks,
 		     double *classbreaks)
 {

Modified: grass/trunk/vector/v.class/main.c
===================================================================
--- grass/trunk/vector/v.class/main.c	2008-08-11 15:05:56 UTC (rev 32687)
+++ grass/trunk/vector/v.class/main.c	2008-08-11 15:59:04 UTC (rev 32688)
@@ -69,8 +69,8 @@
     algo_opt->descriptions = _("int;simple intervals;"
 			       "std;standard deviations;"
 			       "qua;quantiles;"
-			       "equ;equiprobable (normal distribution);"
-			       "dis;discontinuities");
+			       "equ;equiprobable (normal distribution);");
+/*			       "dis;discontinuities"); currently disabled because of bugs*/
 
     nbclass_opt = G_define_option();
     nbclass_opt->key = "nbclasses";



More information about the grass-commit mailing list