[GRASS-SVN] r69757 - grass/branches/releasebranch_7_0/vector/v.what
svn_grass at osgeo.org
svn_grass at osgeo.org
Sun Oct 30 11:19:06 PDT 2016
Author: annakrat
Date: 2016-10-30 11:19:06 -0700 (Sun, 30 Oct 2016)
New Revision: 69757
Modified:
grass/branches/releasebranch_7_0/vector/v.what/what.c
Log:
v.what: use layer information (by mlennert), see #3172 (merge from trunk, r69647)
Modified: grass/branches/releasebranch_7_0/vector/v.what/what.c
===================================================================
--- grass/branches/releasebranch_7_0/vector/v.what/what.c 2016-10-30 18:05:17 UTC (rev 69756)
+++ grass/branches/releasebranch_7_0/vector/v.what/what.c 2016-10-30 18:19:06 UTC (rev 69757)
@@ -538,13 +538,16 @@
} /* if area > 0 */
if (Cats->n_cats > 0) {
- int j;
+ int j, k;
char *formbuf1;
char *formbuf2;
if (json) {
fprintf(stdout, ",\n\"Categories\": [");
}
+ k = 0;
for (j = 0; j < Cats->n_cats; j++) {
+ if (field[i] == -1 || Cats->field[j] == field[i]) {
+ k++;
G_debug(2, "field = %d category = %d\n", Cats->field[j],
Cats->cat[j]);
if (script) {
@@ -552,7 +555,7 @@
Cats->cat[j]);
}
else if (json) {
- fprintf(stdout, "%s\n{\"Layer\": %d, \"Category\": %d", j == 0 ? "": ",",
+ fprintf(stdout, "%s\n{\"Layer\": %d, \"Category\": %d", k == 1 ? "": ",",
Cats->field[j], Cats->cat[j]);
}
else {
@@ -597,6 +600,7 @@
if (json) {
fprintf(stdout, "}"); /* for cat */
}
+ }
}
if (json) {
fprintf(stdout, "]"); /* for list of cats */
More information about the grass-commit
mailing list