[GRASS-SVN] r47994 - in grass/trunk/vector: . v.vect.stats

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Aug 31 06:46:29 EDT 2011


Author: mmetz
Date: 2011-08-31 03:46:29 -0700 (Wed, 31 Aug 2011)
New Revision: 47994

Added:
   grass/trunk/vector/v.vect.stats/
   grass/trunk/vector/v.vect.stats/v.vect.stats.html
Removed:
   grass/trunk/vector/v.vect.stats/description.html
   grass/trunk/vector/v.vect.stats/grass65.patch
   grass/trunk/vector/v.vect.stats/grass7.patch
Modified:
   grass/trunk/vector/v.vect.stats/Makefile
   grass/trunk/vector/v.vect.stats/main.c
Log:
include v.vect.stats in trunk because it covers basic vector functionality

Modified: grass/trunk/vector/v.vect.stats/Makefile
===================================================================
--- grass-addons/vector/v.vect.stats/Makefile	2011-08-31 08:12:23 UTC (rev 47992)
+++ grass/trunk/vector/v.vect.stats/Makefile	2011-08-31 10:46:29 UTC (rev 47994)
@@ -3,7 +3,7 @@
 
 PGM=v.vect.stats
 
-LIBES     = $(VECTLIB) $(VECTLIB_REAL) $(STATSLIB) $(GISLIB)
+LIBES = $(VECTLIB) $(VECTLIB_REAL) $(STATSLIB) $(GISLIB)
 DEPENDENCIES= $(VECTDEP) $(STATSDEP) $(GISDEP)
 
 EXTRA_INC = $(VECT_INC)

Deleted: grass/trunk/vector/v.vect.stats/description.html
===================================================================
--- grass-addons/vector/v.vect.stats/description.html	2011-08-31 08:12:23 UTC (rev 47992)
+++ grass/trunk/vector/v.vect.stats/description.html	2011-08-31 10:46:29 UTC (rev 47994)
@@ -1,95 +0,0 @@
-<H2>DESCRIPTION</H2>
-
-<EM>v.vect.stats</EM> counts the number of points in vector map
-<em>points</em> falling into each area in vector map <em>areas</em>.
-Optionally statistics on point attributes in <em>points</em> are
-calculated for each area. The results are either uploaded to the
-attribute table of the vector map <em>areas</em> or printed to stdout.
-
-<h3>OPTIONS</h3>
-
-<em>Statistical Methods:</em>
-Using numeric attribute values of all points falling into a given area,
-a new value is detmined with the selected method.
-<em>v.vect.stats</em> can perform the following operations:
-
-<p>
-<dl>
-
-<dt><b>sum</b> 
-
-<dd>The sum of values.
-
-<dt><b>average</b> 
-
-<dd>The average value of all point attributes (sum / count).
-
-<dt><b>median</b> 
-
-<dd>The value found half-way through a list of the
-attribute values, when these are ranged in numerical order.
-
-<dt><b>mode</b> 
-
-<dd>The most frequently occurring value.
-
-<dt><b>minimum</b> 
-
-<dd>The minimum observed value.
-
-<dt><b>min_cat</b> 
-
-<dd>The point category corresponding to the minimum observed value.
-
-<dt><b>maximum</b> 
-
-<dd>The maximum observed value.
-
-<dt><b>max_cat</b> 
-
-<dd>The point category corresponding to the maximum observed value.
-
-<dt><b>range</b> 
-
-<dd>The range of the observed values.
-
-<dt><b>stddev</b> 
-
-<dd>The statistical standard deviation of the attribute values.
-
-<dt><b>variance</b> 
-
-<dd>The statistical variance of the attribute values.
-
-<dt><b>diversity</b> 
-
-<dd>The number of different attribute values.
-
-</dl>
-
-
-<H2>NOTES</H2>
-
-Points not falling into any area are ignored. Areas without category
-(no centroid attached or centroid without category) are ignored. 
-If no points are falling into a given area, the point count is set to 0
-(zero) and the statistics result to "null".
-<p>
-The columns <em>count_column</em> and <em>stats_column</em> are created if not
-existing. If they do already exist, the <em>count_column</em> must be of
-type integer and the <em>stats_column</em> of type double.
-
-<H2>SEE ALSO</H2>
-
-<EM>
-<a href="v.distance.html">v.distance</a>,
-<a href="r.distance.html">r.distance</a>,
-<a href="v.what.vect.html">v.what.vect</a>
-</EM>
-
-
-<H2>AUTHOR</H2>
-
-Markus Metz
-
-<p><i>Last changed: $Date: 2008-08-13 21:52:37 +0200 (Wed, 13 Aug 2008) $</i>

Deleted: grass/trunk/vector/v.vect.stats/grass65.patch
===================================================================
--- grass-addons/vector/v.vect.stats/grass65.patch	2011-08-31 08:12:23 UTC (rev 47992)
+++ grass/trunk/vector/v.vect.stats/grass65.patch	2011-08-31 10:46:29 UTC (rev 47994)
@@ -1,14 +0,0 @@
-Index: main.c
-===================================================================
---- main.c	(revision 44581)
-+++ main.c	(working copy)
-@@ -656,7 +656,8 @@
- 
- 	if (Area_cat[i].count > 0 && method_opt->answer) {
- 	    /* get stats */
--	    statsvalue(&result, Area_cat[i].values, Area_cat[i].nvalues);
-+	    statsvalue(&result, Area_cat[i].values, Area_cat[i].nvalues,
-+			NULL);
- 
- 	    if (half)
- 		result += 0.5;

Deleted: grass/trunk/vector/v.vect.stats/grass7.patch
===================================================================
--- grass-addons/vector/v.vect.stats/grass7.patch	2011-08-31 08:12:23 UTC (rev 47992)
+++ grass/trunk/vector/v.vect.stats/grass7.patch	2011-08-31 10:46:29 UTC (rev 47994)
@@ -1,63 +0,0 @@
-Index: main.c
-===================================================================
---- main.c	(revision 44581)
-+++ main.c	(working copy)
-@@ -24,7 +24,7 @@
- #include <grass/glocale.h>
- #include <grass/stats.h>
- #include <grass/dbmi.h>
--#include <grass/Vect.h>
-+#include <grass/vector.h>
- 
- struct menu
- {
-@@ -108,7 +108,7 @@
-     char buf[2000];
-     int update_ok, update_err;
-     struct ilist *List;
--    BOUND_BOX box;
-+    struct bound_box box;
-     dbCatValArray cvarr;
-     dbColumn *column;
-     struct pvalcat
-@@ -125,7 +125,9 @@
-     G_gisinit(argv[0]);
- 
-     module = G_define_module();
--    module->keywords = _("vector, database, attribute table");
-+    G_add_keyword(_("vector"));
-+    G_add_keyword(_("database"));
-+    G_add_keyword(_("attribute table"));
-     module->description = _("Count points in areas, calculate statistics.");
- 
-     point_opt = G_define_standard_option(G_OPT_V_INPUT);
-@@ -169,7 +171,7 @@
-     method_opt->options = p;
-     method_opt->description = _("Method for aggregate statistics");
- 
--    point_column_opt = G_define_standard_option(G_OPT_COLUMN);
-+    point_column_opt = G_define_standard_option(G_OPT_DB_COLUMN);
-     point_column_opt->key = "pcolumn";
-     point_column_opt->required = NO;
-     point_column_opt->multiple = NO;
-@@ -477,10 +479,6 @@
-     pvalcats =
- 	(struct pvalcat *)G_calloc(npvalcatsalloc, sizeof(struct pvalcat));
- 
--    /* remove for GRASS 7 */
--    G_verbose_message(_("creating spatial index"));
--    Vect_build_spatial_index(&PIn);
--
-     G_message(_("Selecting points for each area..."));
-     count = 0;
-     for (area = 1; area <= nareas; area++) {
-@@ -656,7 +654,8 @@
- 
- 	if (Area_cat[i].count > 0 && method_opt->answer) {
- 	    /* get stats */
--	    statsvalue(&result, Area_cat[i].values, Area_cat[i].nvalues);
-+	    statsvalue(&result, Area_cat[i].values, Area_cat[i].nvalues,
-+			NULL);
- 
- 	    if (half)
- 		result += 0.5;

Modified: grass/trunk/vector/v.vect.stats/main.c
===================================================================
--- grass-addons/vector/v.vect.stats/main.c	2011-08-31 08:12:23 UTC (rev 47992)
+++ grass/trunk/vector/v.vect.stats/main.c	2011-08-31 10:46:29 UTC (rev 47994)
@@ -24,7 +24,7 @@
 #include <grass/glocale.h>
 #include <grass/stats.h>
 #include <grass/dbmi.h>
-#include <grass/Vect.h>
+#include <grass/vector.h>
 
 struct menu
 {
@@ -80,7 +80,7 @@
     char *p;
     int i, j, k;
     int method, half, use_catno;
-    char *mapset;
+    const char *mapset;
     struct GModule *module;
     struct Option *point_opt,	/* point vector */
      *area_opt,			/* area vector */
@@ -107,8 +107,8 @@
     dbDriver *Pdriver, *Adriver;
     char buf[2000];
     int update_ok, update_err;
-    struct ilist *List;
-    BOUND_BOX box;
+    struct boxlist *List;
+    struct bound_box box;
     dbCatValArray cvarr;
     dbColumn *column;
     struct pvalcat
@@ -125,7 +125,9 @@
     G_gisinit(argv[0]);
 
     module = G_define_module();
-    module->keywords = _("vector, database, attribute table");
+    G_add_keyword(_("vector"));
+    G_add_keyword(_("database"));
+    G_add_keyword(_("attribute table"));
     module->description = _("Count points in areas, calculate statistics.");
 
     point_opt = G_define_standard_option(G_OPT_V_INPUT);
@@ -169,7 +171,7 @@
     method_opt->options = p;
     method_opt->description = _("Method for aggregate statistics");
 
-    point_column_opt = G_define_standard_option(G_OPT_COLUMN);
+    point_column_opt = G_define_standard_option(G_OPT_DB_COLUMN);
     point_column_opt->key = "pcolumn";
     point_column_opt->required = NO;
     point_column_opt->multiple = NO;
@@ -416,7 +418,7 @@
     Points = Vect_new_line_struct();
     ACats = Vect_new_cats_struct();
     PCats = Vect_new_cats_struct();
-    List = Vect_new_list();
+    List = Vect_new_boxlist(0);
 
     /* Allocate space ( may be more than needed (duplicate cats and elements without cats) ) */
     if ((nareas = Vect_get_num_areas(&AIn)) <= 0)
@@ -477,10 +479,6 @@
     pvalcats =
 	(struct pvalcat *)G_calloc(npvalcatsalloc, sizeof(struct pvalcat));
 
-    /* remove for GRASS 7 */
-    G_verbose_message(_("creating spatial index"));
-    Vect_build_spatial_index(&PIn);
-
     G_message(_("Selecting points for each area..."));
     count = 0;
     for (area = 1; area <= nareas; area++) {
@@ -505,7 +503,7 @@
 	/* For each point in box check if it is in the area */
 	for (i = 0; i < List->n_values; i++) {
 
-	    pline = List->value[i];
+	    pline = List->id[i];
 	    G_debug(4, "%d: point %d", i, pline);
 
 	    ptype = Vect_read_line(&PIn, Points, PCats, pline);
@@ -513,7 +511,7 @@
 		continue;
 
 	    /* point in area */
-	    if (Vect_point_in_area(&AIn, area, Points->x[0], Points->y[0])) {
+	    if (Vect_point_in_area(Points->x[0], Points->y[0], &AIn, area, box)) {
 		AREA_CAT *area_info, search_ai;
 
 		int tmp_cat;
@@ -656,7 +654,8 @@
 
 	if (Area_cat[i].count > 0 && method_opt->answer) {
 	    /* get stats */
-	    statsvalue(&result, Area_cat[i].values, Area_cat[i].nvalues);
+	    statsvalue(&result, Area_cat[i].values, Area_cat[i].nvalues,
+			NULL);
 
 	    if (half)
 		result += 0.5;

Copied: grass/trunk/vector/v.vect.stats/v.vect.stats.html (from rev 47992, grass-addons/vector/v.vect.stats/description.html)
===================================================================
--- grass/trunk/vector/v.vect.stats/v.vect.stats.html	                        (rev 0)
+++ grass/trunk/vector/v.vect.stats/v.vect.stats.html	2011-08-31 10:46:29 UTC (rev 47994)
@@ -0,0 +1,95 @@
+<H2>DESCRIPTION</H2>
+
+<EM>v.vect.stats</EM> counts the number of points in vector map
+<em>points</em> falling into each area in vector map <em>areas</em>.
+Optionally statistics on point attributes in <em>points</em> are
+calculated for each area. The results are either uploaded to the
+attribute table of the vector map <em>areas</em> or printed to stdout.
+
+<h3>OPTIONS</h3>
+
+<em>Statistical Methods:</em>
+Using numeric attribute values of all points falling into a given area,
+a new value is detmined with the selected method.
+<em>v.vect.stats</em> can perform the following operations:
+
+<p>
+<dl>
+
+<dt><b>sum</b> 
+
+<dd>The sum of values.
+
+<dt><b>average</b> 
+
+<dd>The average value of all point attributes (sum / count).
+
+<dt><b>median</b> 
+
+<dd>The value found half-way through a list of the
+attribute values, when these are ranged in numerical order.
+
+<dt><b>mode</b> 
+
+<dd>The most frequently occurring value.
+
+<dt><b>minimum</b> 
+
+<dd>The minimum observed value.
+
+<dt><b>min_cat</b> 
+
+<dd>The point category corresponding to the minimum observed value.
+
+<dt><b>maximum</b> 
+
+<dd>The maximum observed value.
+
+<dt><b>max_cat</b> 
+
+<dd>The point category corresponding to the maximum observed value.
+
+<dt><b>range</b> 
+
+<dd>The range of the observed values.
+
+<dt><b>stddev</b> 
+
+<dd>The statistical standard deviation of the attribute values.
+
+<dt><b>variance</b> 
+
+<dd>The statistical variance of the attribute values.
+
+<dt><b>diversity</b> 
+
+<dd>The number of different attribute values.
+
+</dl>
+
+
+<H2>NOTES</H2>
+
+Points not falling into any area are ignored. Areas without category
+(no centroid attached or centroid without category) are ignored. 
+If no points are falling into a given area, the point count is set to 0
+(zero) and the statistics result to "null".
+<p>
+The columns <em>count_column</em> and <em>stats_column</em> are created if not
+existing. If they do already exist, the <em>count_column</em> must be of
+type integer and the <em>stats_column</em> of type double.
+
+<H2>SEE ALSO</H2>
+
+<EM>
+<a href="v.distance.html">v.distance</a>,
+<a href="r.distance.html">r.distance</a>,
+<a href="v.what.vect.html">v.what.vect</a>
+</EM>
+
+
+<H2>AUTHOR</H2>
+
+Markus Metz
+
+<p><i>Last changed: $Date: 2008-08-13 21:52:37 +0200 (Wed, 13 Aug 2008) $</i>



More information about the grass-commit mailing list