|
@@ -11,7 +11,7 @@
|
|
|
* Jan-Oliver Wagner <jan intevation.de>
|
|
|
* PURPOSE: displays a geodesic line in the active frame on the user's
|
|
|
* graphics monitor
|
|
|
- * COPYRIGHT: (C) 1999-2006 by the GRASS Development Team
|
|
|
+ * COPYRIGHT: (C) 1999-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
|
|
@@ -31,10 +31,13 @@ int main(int argc, char *argv[])
|
|
|
int text_color;
|
|
|
double lon1, lat1, lon2, lat2;
|
|
|
char *deftcolor;
|
|
|
+ const char *unit;
|
|
|
+ int unit_id;
|
|
|
+ double factor;
|
|
|
struct GModule *module;
|
|
|
struct
|
|
|
{
|
|
|
- struct Option *lcolor, *tcolor, *coor;
|
|
|
+ struct Option *lcolor, *tcolor, *coor, *units;
|
|
|
} parm;
|
|
|
|
|
|
G_gisinit(argv[0]);
|
|
@@ -42,6 +45,8 @@ int main(int argc, char *argv[])
|
|
|
module = G_define_module();
|
|
|
G_add_keyword(_("display"));
|
|
|
G_add_keyword(_("distance"));
|
|
|
+ G_add_keyword(_("great circle"));
|
|
|
+ G_add_keyword(_("shortest path"));
|
|
|
module->description =
|
|
|
_("Displays a geodesic line, tracing the shortest distance "
|
|
|
"between two geographic points along a great circle, in "
|
|
@@ -60,13 +65,23 @@ int main(int argc, char *argv[])
|
|
|
parm.tcolor->key = "text_color";
|
|
|
parm.tcolor->label = _("Text color");
|
|
|
parm.tcolor->answer = NULL;
|
|
|
-
|
|
|
+
|
|
|
+ parm.units = G_define_standard_option(G_OPT_M_UNITS);
|
|
|
+ parm.units->options = "meters,kilometers,feet,miles";
|
|
|
+ parm.units->label = parm.units->description;
|
|
|
+ parm.units->answer = "meters";
|
|
|
+
|
|
|
if (G_parser(argc, argv))
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
|
|
-
|
|
|
if (G_projection() != PROJECTION_LL)
|
|
|
- G_fatal_error(_("Location is not %s"), G__projection_name(PROJECTION_LL));
|
|
|
+ G_fatal_error(_("Location is not %s"),
|
|
|
+ G__projection_name(PROJECTION_LL));
|
|
|
+
|
|
|
+ /* get conversion factor and unit name */
|
|
|
+ unit_id = G_units(parm.units->answer);
|
|
|
+ factor = 1. / G_meters_to_units_factor(unit_id);
|
|
|
+ unit = G_get_units_name(unit_id, 1, 0);
|
|
|
|
|
|
if (parm.coor->answers[0] == NULL)
|
|
|
G_fatal_error(_("No coordinates given"));
|
|
@@ -103,8 +118,8 @@ int main(int argc, char *argv[])
|
|
|
else
|
|
|
text_color = D_translate_color(parm.tcolor->answer);
|
|
|
|
|
|
- plot(lon1, lat1, lon2, lat2, line_color, text_color);
|
|
|
-
|
|
|
+ plot(lon1, lat1, lon2, lat2, line_color, text_color, factor, unit);
|
|
|
+
|
|
|
D_save_command(G_recreate_command());
|
|
|
D_close_driver();
|
|
|
|