123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- /****************************************************************************
- *
- * MODULE: r.describe
- *
- * AUTHOR(S): Michael Shapiro - CERL
- *
- * PURPOSE: Prints terse list of category values found in a raster
- * map layer.
- *
- * COPYRIGHT: (C) 2006 by the GRASS Development Team
- *
- * This program is free software under the GNU General Public
- * License (>=v2). Read the file COPYING that comes with GRASS
- * for details.
- *
- ***************************************************************************/
- #include <stdlib.h>
- #include <string.h>
- #include <stdio.h>
- #include <grass/gis.h>
- #include "local_proto.h"
- #include <grass/glocale.h>
- int main(int argc, char *argv[])
- {
- int as_int;
- int compact;
- int range;
- int windowed;
- int nsteps;
- char *no_data_str;
- struct GModule *module;
- struct
- {
- struct Flag *one;
- struct Flag *r;
- struct Flag *d;
- struct Flag *i;
- struct Flag *n;
- } flag;
- struct
- {
- struct Option *map;
- struct Option *nv;
- struct Option *nsteps;
- } option;
- G_gisinit(argv[0]);
- module = G_define_module();
- G_add_keyword(_("raster"));
- G_add_keyword(_("metadata"));
- module->description =
- _("Prints terse list of category values found in a raster map layer.");
- /* define different options */
- option.map = G_define_standard_option(G_OPT_R_MAP);
- option.nv = G_define_option();
- option.nv->key = "nv";
- option.nv->type = TYPE_STRING;
- option.nv->required = NO;
- option.nv->multiple = NO;
- option.nv->answer = "*";
- option.nv->description = _("String representing no data cell value");
- option.nsteps = G_define_option();
- option.nsteps->key = "nsteps";
- option.nsteps->type = TYPE_INTEGER;
- option.nsteps->required = NO;
- option.nsteps->multiple = NO;
- option.nsteps->answer = "255";
- option.nsteps->description = _("Number of quantization steps");
- /*define the different flags */
- flag.one = G_define_flag();
- flag.one->key = '1';
- flag.one->description = _("Print the output one value per line");
- flag.r = G_define_flag();
- flag.r->key = 'r';
- flag.r->description = _("Only print the range of the data");
- flag.n = G_define_flag();
- flag.n->key = 'n';
- flag.n->description = _("Suppress reporting of any NULLs");
- flag.d = G_define_flag();
- flag.d->key = 'd';
- flag.d->description = _("Use the current region");
- flag.i = G_define_flag();
- flag.i->key = 'i';
- flag.i->description = _("Read fp map as integer");
- if (0 > G_parser(argc, argv))
- exit(EXIT_FAILURE);
- compact = (!flag.one->answer);
- range = flag.r->answer;
- windowed = flag.d->answer;
- as_int = flag.i->answer;
- no_data_str = option.nv->answer;
- if (sscanf(option.nsteps->answer, "%d", &nsteps) != 1 || nsteps < 1)
- G_fatal_error(_("%s = %s -- must be greater than zero"),
- option.nsteps->key, option.nsteps->answer);
- describe(option.map->answer, compact, no_data_str,
- range, windowed, nsteps, as_int, flag.n->answer);
- return EXIT_SUCCESS;
- }
|