[GRASS-dev] [GRASS-SVN] r72590 - grass/trunk/general/g.region
Martin Landa
landa.martin at gmail.com
Thu Apr 5 04:01:04 PDT 2018
Hi,
2018-04-05 12:16 GMT+02:00 <svn_grass at osgeo.org>:
> Author: jachym
> Date: 2018-04-05 03:16:14 -0700 (Thu, 05 Apr 2018)
> New Revision: 72590
>
> Modified:
> grass/trunk/general/g.region/local_proto.h
> grass/trunk/general/g.region/main.c
> Log:
> Adding -L flag to g.region for getting list of regions
1) upper-case flags should not be used
2) this functionality is already available as `g.list type=region` if
I understand well
3) I would prefer to see ticket with related discussion before
committing change into trunk
Consider reverting this change. g.list functionality is not suitable
for your need?
Thanks for clarification, Martin
>
> Modified: grass/trunk/general/g.region/local_proto.h
> ===================================================================
> --- grass/trunk/general/g.region/local_proto.h 2018-04-03 10:43:37 UTC (rev 72589)
> +++ grass/trunk/general/g.region/local_proto.h 2018-04-05 10:16:14 UTC (rev 72590)
> @@ -12,6 +12,7 @@
> #define PRINT_NANGLE 0x100
> #define PRINT_GMT 0x200
> #define PRINT_WMS 0x400
> +#define PRINT_WF 0x800
>
> /* zoom.c */
> int zoom(struct Cell_head *, const char *, const char *);
>
> Modified: grass/trunk/general/g.region/main.c
> ===================================================================
> --- grass/trunk/general/g.region/main.c 2018-04-03 10:43:37 UTC (rev 72589)
> +++ grass/trunk/general/g.region/main.c 2018-04-05 10:16:14 UTC (rev 72590)
> @@ -13,6 +13,7 @@
> * Read the file COPYING that comes with GRASS for details.
> ****************************************************************************/
>
> +#include <dirent.h>
> #include <string.h>
> #include <stdlib.h>
> #include <math.h>
> @@ -39,8 +40,11 @@
> const char *value;
> const char *name;
> const char *mapset;
> + char *windows_path = G_malloc(1024);
> char **rast_ptr, **vect_ptr;
> int pix;
> + DIR *d;
> + struct dirent *dir;
>
> struct GModule *module;
> struct
> @@ -48,7 +52,7 @@
> struct Flag
> *update, *print, *gprint, *flprint, *lprint, *eprint, *nangle,
> *center, *res_set, *dist_res, *dflt, *z, *savedefault,
> - *bbox, *gmt_style, *wms_style;
> + *bbox, *gmt_style, *wms_style, *list;
> } flag;
> struct
> {
> @@ -165,6 +169,11 @@
> flag.update->description = _("Do not update the current region");
> flag.update->guisection = _("Effects");
>
> + flag.list = G_define_flag();
> + flag.list->key = 'L';
> + flag.list->description = _("List available regions");
> + flag.list->guisection = _("Print");
> +
> /* parameters */
>
> parm.region = G_define_standard_option(G_OPT_M_REGION);
> @@ -362,7 +371,7 @@
> G_option_required(flag.dflt, flag.savedefault, flag.print, flag.lprint,
> flag.eprint, flag.center, flag.gmt_style, flag.wms_style,
> flag.dist_res, flag.nangle, flag. z, flag.bbox, flag.gprint,
> - flag.res_set, flag.update, parm.region, parm.raster,
> + flag.res_set, flag.update, flag.list, parm.region, parm.raster,
> parm.raster3d, parm.vect, parm.north, parm.south, parm.east,
> parm.west, parm.top, parm.bottom, parm.rows, parm.cols,
> parm.res, parm.res3, parm.nsres, parm.ewres, parm.tbres,
> @@ -850,6 +859,21 @@
> if (print_flag)
> print_window(&window, print_flag, flat_flag);
>
> + if (flag.list->answer) {
> + mapset = G_mapset_path();
> + sprintf(windows_path, "%s/%s", mapset, "windows");
> + d = opendir(windows_path);
> +
> + if (d) {
> + while ((dir = readdir(d)) != NULL) {
> + if (dir->d_type == DT_REG) {
> + printf("%s\n", dir->d_name);
> + }
> + }
> + closedir(d);
> + }
> + }
> +
> exit(EXIT_SUCCESS);
> }
>
>
> _______________________________________________
> grass-commit mailing list
> grass-commit at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/grass-commit
--
Martin Landa
http://geo.fsv.cvut.cz/gwiki/Landa
http://gismentors.cz/mentors/landa
More information about the grass-dev
mailing list