[GRASS-SVN] r60564 - grass/trunk/raster/r.distance
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed May 28 14:34:52 PDT 2014
Author: hcho
Date: 2014-05-28 14:34:51 -0700 (Wed, 28 May 2014)
New Revision: 60564
Modified:
grass/trunk/raster/r.distance/parse.c
Log:
r.distance: sort -s/-r => sort=
Modified: grass/trunk/raster/r.distance/parse.c
===================================================================
--- grass/trunk/raster/r.distance/parse.c 2014-05-28 21:09:09 UTC (rev 60563)
+++ grass/trunk/raster/r.distance/parse.c 2014-05-28 21:34:51 UTC (rev 60564)
@@ -8,7 +8,7 @@
* PURPOSE: Locates the closest points between objects in two
* raster maps.
*
- * COPYRIGHT: (C) 2003 by the GRASS Development Team
+ * COPYRIGHT: (C) 2003-2014 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
@@ -18,14 +18,15 @@
#include <stdlib.h>
#include <stdio.h>
+#include <string.h>
#include "defs.h"
#include <grass/gis.h>
#include <grass/glocale.h>
void parse(int argc, char *argv[], struct Parms *parms)
{
- struct Option *maps, *fs;
- struct Flag *labels, *overlap, *null, *sort, *revsort;
+ struct Option *maps, *fs, *sort;
+ struct Flag *labels, *overlap, *null;
const char *name, *mapset;
maps = G_define_standard_option(G_OPT_R_MAPS);
@@ -35,6 +36,19 @@
fs = G_define_standard_option(G_OPT_F_SEP);
fs->answer = ":"; /* colon is default output fs */
+ sort = G_define_option();
+ sort->key = "sort";
+ sort->type = TYPE_STRING;
+ sort->required = NO;
+ sort->multiple = NO;
+ sort->label = _("Sort output by distance");
+ sort->description = _("Default: sorted by categories");
+ sort->options = "asc,desc";
+ G_asprintf((char **)&(sort->descriptions),
+ "asc;%s;desc;%s",
+ _("Sort by distance in ascending order"),
+ _("Sort by distance in descending order"));
+
labels = G_define_flag();
labels->key = 'l';
labels->description = _("Include category labels in the output");
@@ -48,21 +62,9 @@
null->key = 'n';
null->description = _("Report null objects as *");
- sort = G_define_flag();
- sort->key = 's';
- sort->description = _("Sort by distance in ascending order");
-
- revsort = G_define_flag();
- revsort->key = 'r';
- revsort->description = _("Sort by distance in descending order");
-
if (G_parser(argc, argv))
exit(EXIT_FAILURE);
- if (sort->answer && revsort->answer)
- G_fatal_error(_("-%c and -%c are mutually exclusive"),
- sort->key, revsort->key);
-
name = parms->map1.name = maps->answers[0];
mapset = parms->map1.mapset = G_find_raster2(name, "");
if (mapset == NULL)
@@ -85,5 +87,8 @@
parms->fs = fs->answer;
parms->overlap = overlap->answer ? 1 : 0;
parms->null = null->answer ? 1 : 0;
- parms->sort = sort->answer ? 1 : (revsort->answer ? 2 : 0);
+ if (sort->answer)
+ parms->sort = strcmp(sort->answer, "asc") == 0 ? 1 : 2;
+ else
+ parms->sort = 0;
}
More information about the grass-commit
mailing list