[GRASS-SVN] r69647 - grass/trunk/vector/v.what
svn_grass at osgeo.org
svn_grass at osgeo.org
Sun Oct 2 18:50:33 PDT 2016
Author: annakrat
Date: 2016-10-02 18:50:33 -0700 (Sun, 02 Oct 2016)
New Revision: 69647
Modified:
grass/trunk/vector/v.what/what.c
Log:
v.what: use layer information (by mlennert), see #3172
Modified: grass/trunk/vector/v.what/what.c
===================================================================
--- grass/trunk/vector/v.what/what.c 2016-10-03 01:33:42 UTC (rev 69646)
+++ grass/trunk/vector/v.what/what.c 2016-10-03 01:50:33 UTC (rev 69647)
@@ -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