[GRASS-SVN] r34808 - grass/trunk/vector/v.to.db
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue Dec 9 04:40:16 EST 2008
Author: martinl
Date: 2008-12-09 04:40:16 -0500 (Tue, 09 Dec 2008)
New Revision: 34808
Modified:
grass/trunk/vector/v.to.db/areas.c
grass/trunk/vector/v.to.db/find.c
grass/trunk/vector/v.to.db/global.h
grass/trunk/vector/v.to.db/lines.c
grass/trunk/vector/v.to.db/main.c
grass/trunk/vector/v.to.db/query.c
grass/trunk/vector/v.to.db/report.c
Log:
v.to.db: fix report (don't report features without category)
(merge from devbr6, r34807)
Modified: grass/trunk/vector/v.to.db/areas.c
===================================================================
--- grass/trunk/vector/v.to.db/areas.c 2008-12-09 09:15:33 UTC (rev 34807)
+++ grass/trunk/vector/v.to.db/areas.c 2008-12-09 09:40:16 UTC (rev 34808)
@@ -47,7 +47,7 @@
if (Vect_get_area_cats(Map, area_num, Cats) == 0) {
for (i = 0; i < Cats->n_cats; i++) {
if (Cats->field[i] == options.field) {
- idx = find_cat(Cats->cat[i]);
+ idx = find_cat(Cats->cat[i], 1);
switch (options.option) {
case O_AREA:
Values[idx].d1 += area;
@@ -68,7 +68,7 @@
}
/* why do we do this? */
if (!found) { /* no category found */
- idx = find_cat(0);
+ idx = find_cat(0, 1);
if (options.option == O_AREA) {
Values[idx].d1 += area;
}
Modified: grass/trunk/vector/v.to.db/find.c
===================================================================
--- grass/trunk/vector/v.to.db/find.c 2008-12-09 09:15:33 UTC (rev 34807)
+++ grass/trunk/vector/v.to.db/find.c 2008-12-09 09:40:16 UTC (rev 34808)
@@ -3,7 +3,7 @@
#include "global.h"
/* returns index to array of values, inserts new if necessary */
-int find_cat(int cat)
+int find_cat(int cat, int add)
{
int i;
@@ -11,6 +11,9 @@
if (Values[i].cat == cat)
return i;
+ if (!add)
+ return -1;
+
/* Not found -> add new */
Values[vstat.rcat].cat = cat;
Values[vstat.rcat].count1 = 0;
Modified: grass/trunk/vector/v.to.db/global.h
===================================================================
--- grass/trunk/vector/v.to.db/global.h 2008-12-09 09:15:33 UTC (rev 34807)
+++ grass/trunk/vector/v.to.db/global.h 2008-12-09 09:40:16 UTC (rev 34808)
@@ -82,7 +82,7 @@
double length(register int, register double *, register double *);
/* find.c */
-int find_cat(int);
+int find_cat(int, int);
/* line.c */
int read_lines(struct Map_info *);
Modified: grass/trunk/vector/v.to.db/lines.c
===================================================================
--- grass/trunk/vector/v.to.db/lines.c 2008-12-09 09:15:33 UTC (rev 34807)
+++ grass/trunk/vector/v.to.db/lines.c 2008-12-09 09:40:16 UTC (rev 34808)
@@ -115,7 +115,7 @@
for (i = 0; i < Cats->n_cats; i++) {
if (Cats->field[i] == options.field) {
- idx = find_cat(Cats->cat[i]);
+ idx = find_cat(Cats->cat[i], 1);
if (options.option == O_COUNT) {
Values[idx].count1++;
}
@@ -198,7 +198,7 @@
}
if (!found) { /* Values for no category (cat = -1) are reported at the end */
- idx = find_cat(-1);
+ idx = find_cat(-1, 1);
if (options.option == O_COUNT) {
Values[idx].count1++;
}
Modified: grass/trunk/vector/v.to.db/main.c
===================================================================
--- grass/trunk/vector/v.to.db/main.c 2008-12-09 09:15:33 UTC (rev 34807)
+++ grass/trunk/vector/v.to.db/main.c 2008-12-09 09:40:16 UTC (rev 34808)
@@ -91,12 +91,12 @@
Vect_close(&Map);
- /* free list */
- G_free(Values);
-
if (!(options.print && options.total)) {
print_stat();
}
+ /* free list */
+ G_free(Values);
+
exit(EXIT_SUCCESS);
}
Modified: grass/trunk/vector/v.to.db/query.c
===================================================================
--- grass/trunk/vector/v.to.db/query.c 2008-12-09 09:15:33 UTC (rev 34807)
+++ grass/trunk/vector/v.to.db/query.c 2008-12-09 09:40:16 UTC (rev 34808)
@@ -34,7 +34,7 @@
cat_no = Cats->cat[i];
- idx = find_cat(cat_no);
+ idx = find_cat(cat_no, 1);
for (j = 0; j < Cats->n_cats; j++) {
if (Cats->field[j] == options.qfield) { /* Add to list */
@@ -56,7 +56,7 @@
Vect_cat_get(Cats, options.field, &cat_no);
if (cat_no == -1) {
- idx = find_cat(cat_no);
+ idx = find_cat(cat_no, 1);
for (j = 0; j < Cats->n_cats; j++) {
if (Cats->field[j] == options.qfield) { /* Add to list */
Modified: grass/trunk/vector/v.to.db/report.c
===================================================================
--- grass/trunk/vector/v.to.db/report.c 2008-12-09 09:15:33 UTC (rev 34807)
+++ grass/trunk/vector/v.to.db/report.c 2008-12-09 09:40:16 UTC (rev 34808)
@@ -171,9 +171,16 @@
int print_stat(void)
{
- if (vstat.rcat > 0)
+ if (vstat.rcat > 0) {
+ int rcat_report;
+ if(find_cat(-1, 0) != -1)
+ rcat_report = vstat.rcat - 1;
+ else
+ rcat_report = vstat.rcat;
+
G_message(_("%d categories read from vector map (layer %d)"),
- vstat.rcat - 1, options.field); /* don't report cat -1 */
+ rcat_report, options.field); /* don't report cat -1 */
+ }
if (vstat.select > 0)
G_message(_("%d records selected from table (layer %d)"),
vstat.select, options.qfield);
More information about the grass-commit
mailing list