[GRASS-SVN] r69003 - in grass/trunk: include/defs lib/gis

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Jul 18 08:10:15 PDT 2016


Author: annakrat
Date: 2016-07-18 08:10:15 -0700 (Mon, 18 Jul 2016)
New Revision: 69003

Modified:
   grass/trunk/include/defs/gis.h
   grass/trunk/lib/gis/proj3.c
Log:
gislib: add G_database_unit function which returns id of currently used units in location - G_projection_units is not enough

Modified: grass/trunk/include/defs/gis.h
===================================================================
--- grass/trunk/include/defs/gis.h	2016-07-18 14:56:37 UTC (rev 69002)
+++ grass/trunk/include/defs/gis.h	2016-07-18 15:10:15 UTC (rev 69003)
@@ -626,6 +626,7 @@
 
 /* proj3.c */
 const char *G_database_unit_name(int);
+int G_database_unit();
 const char *G_database_projection_name(void);
 const char *G_database_datum_name(void);
 const char *G_database_ellipse_name(void);

Modified: grass/trunk/lib/gis/proj3.c
===================================================================
--- grass/trunk/lib/gis/proj3.c	2016-07-18 14:56:37 UTC (rev 69002)
+++ grass/trunk/lib/gis/proj3.c	2016-07-18 15:10:15 UTC (rev 69003)
@@ -50,14 +50,26 @@
 const char *G_database_unit_name(int plural)
 {
     int units;
+    units = G_database_unit();
+    return G_get_units_name(units, plural, FALSE);
+}
+
+/*!
+  \brief Get units id for the current location
+  
+  \return units id
+*/
+int G_database_unit()
+{
+    int units;
     const char *name;
     
     units = G_projection_units(G_projection());
     
     if (units == U_UNDEFINED) {
-	name = lookup_units(plural ? "units" : "unit");
+	name = lookup_units("unit");
 	if (!name)
-	    return plural ? _("units") : _("unit");
+	    return U_UNKNOWN;
 	
 	if (strcasecmp(name, "meter") == 0 || strcasecmp(name, "metre") == 0 
             || strcasecmp(name, "meters") == 0 || strcasecmp(name, "metres") == 0)
@@ -80,8 +92,7 @@
 	else
 	    units = U_UNKNOWN;
     }
-    
-    return G_get_units_name(units, plural, FALSE);
+    return units;
 }
 
 /*!



More information about the grass-commit mailing list