[GRASS-SVN] r41300 - grass/trunk/vector/v.to.db
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Mar 5 13:50:18 EST 2010
Author: martinl
Date: 2010-03-05 13:50:18 -0500 (Fri, 05 Mar 2010)
New Revision: 41300
Modified:
grass/trunk/vector/v.to.db/global.h
grass/trunk/vector/v.to.db/parse.c
grass/trunk/vector/v.to.db/units.c
Log:
v.to.db: use libgis fns (units)
Modified: grass/trunk/vector/v.to.db/global.h
===================================================================
--- grass/trunk/vector/v.to.db/global.h 2010-03-05 18:44:33 UTC (rev 41299)
+++ grass/trunk/vector/v.to.db/global.h 2010-03-05 18:50:18 UTC (rev 41300)
@@ -70,15 +70,6 @@
#define O_AZIMUTH 15 /* line azimuth */
-#define U_ACRES 1
-#define U_HECTARES 2
-#define U_KILOMETERS 3
-#define U_METERS 4
-#define U_MILES 5
-#define U_FEET 6
-#define U_RADIANS 7
-#define U_DEGREES 8
-
/* areas.c */
int read_areas(struct Map_info *);
Modified: grass/trunk/vector/v.to.db/parse.c
===================================================================
--- grass/trunk/vector/v.to.db/parse.c 2010-03-05 18:44:33 UTC (rev 41299)
+++ grass/trunk/vector/v.to.db/parse.c 2010-03-05 18:50:18 UTC (rev 41300)
@@ -75,17 +75,10 @@
"sinuous;line sinuousity, calculated as line length / distance between end points;"
"azimuth;line azimuth, calculated as angle between North direction and endnode direction at startnode";
- parms.units = G_define_option();
- parms.units->key = "units";
- parms.units->type = TYPE_STRING;
- parms.units->required = NO;
- parms.units->multiple = NO;
+ parms.units = G_define_standard_option(G_OPT_M_UNITS);
parms.units->options =
"miles,feet,meters,kilometers,acres,hectares,radians,degrees";
- parms.units->label = _("Units");
- parms.units->description =
- _("miles,feet,meters,kilometers,acres,hectares,radians,degrees");
-
+
parms.col = G_define_standard_option(G_OPT_DB_COLUMNS);
parms.qcol = G_define_standard_option(G_OPT_DB_COLUMN);
Modified: grass/trunk/vector/v.to.db/units.c
===================================================================
--- grass/trunk/vector/v.to.db/units.c 2010-03-05 18:44:33 UTC (rev 41299)
+++ grass/trunk/vector/v.to.db/units.c 2010-03-05 18:50:18 UTC (rev 41300)
@@ -3,44 +3,15 @@
int conv_units()
{
- int i, rad = 0;
- double f = 1.0, sq_f = 1.0;
+ int i, rad;
+ double f, sq_f;
- switch (options.units) {
- case U_METERS:
- f = 1.0;
- sq_f = 1.0;
- break;
+ rad = 0;
+ f = G_units_to_meters_factor(options.units);
+ sq_f = G_units_to_meters_factor_sq(options.units);
- case U_KILOMETERS:
- f = 1.0e-3;
- sq_f = 1.0e-6;
- break;
-
- case U_ACRES:
- sq_f = 2.47105381467165e-4; /* 640 acres in a sq mile */
- break;
-
- case U_HECTARES:
- sq_f = 1.0e-4;
- break;
-
- case U_MILES:
- f = 6.21371192237334e-4; /* 1 / (0.0254 * 12 * 5280) */
- sq_f = 3.86102158542446e-7; /* 1 / (0.0254 * 12 * 5280)^2 */
- break;
-
- case U_FEET:
- f = 3.28083989501312; /* 1 / (0.0254 * 12) */
- sq_f = 10.7639104167097; /* 1 / (0.0254 * 12)^2 */
- break;
- case U_RADIANS:
+ if (options.units == U_RADIANS)
rad = 1;
- break;
- case U_DEGREES:
- rad = 0;
- break;
- }
switch (options.option) {
case O_LENGTH:
More information about the grass-commit
mailing list