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

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Sep 23 17:12:29 PDT 2014


Author: annakrat
Date: 2014-09-23 17:12:29 -0700 (Tue, 23 Sep 2014)
New Revision: 62060

Modified:
   grass/trunk/include/gis.h
   grass/trunk/lib/gis/proj2.c
   grass/trunk/lib/gis/proj3.c
   grass/trunk/lib/gis/units.c
Log:
add support for us survey foot, #2417

Modified: grass/trunk/include/gis.h
===================================================================
--- grass/trunk/include/gis.h	2014-09-23 18:44:32 UTC (rev 62059)
+++ grass/trunk/include/gis.h	2014-09-24 00:12:29 UTC (rev 62060)
@@ -74,6 +74,7 @@
 #define U_FEET		6
 #define U_RADIANS	7
 #define U_DEGREES	8
+#define U_USFEET	9
 /* Temporal units from the datetime library */
 #define U_YEARS         DATETIME_YEAR   
 #define U_MONTHS        DATETIME_MONTH  

Modified: grass/trunk/lib/gis/proj2.c
===================================================================
--- grass/trunk/lib/gis/proj2.c	2014-09-23 18:44:32 UTC (rev 62059)
+++ grass/trunk/lib/gis/proj2.c	2014-09-24 00:12:29 UTC (rev 62060)
@@ -23,6 +23,7 @@
    - U_UNKNOWN (XY)
    - U_METERS  (UTM)
    - U_FEET    (SP)
+   - U_USFEET (a few SP)
    - U_DEGREES (LL)
    
   \return units code (see gis.h)
@@ -36,7 +37,7 @@
     case PROJECTION_UTM:
 	return U_METERS;
     case PROJECTION_SP:
-	return U_FEET;
+	return U_FEET; /* TODO: what if U_USFEET as in CA and NC ? */
     case PROJECTION_LL:
 	return U_DEGREES;
     default:

Modified: grass/trunk/lib/gis/proj3.c
===================================================================
--- grass/trunk/lib/gis/proj3.c	2014-09-23 18:44:32 UTC (rev 62059)
+++ grass/trunk/lib/gis/proj3.c	2014-09-24 00:12:29 UTC (rev 62060)
@@ -73,6 +73,8 @@
 	    units = U_MILES;
 	else if (strcasecmp(name, "foot") == 0 || strcasecmp(name, "feet") == 0)
 	    units = U_FEET;
+	else if (strcasecmp(name, "foot_us") == 0 || strcasecmp(name, "foot_uss") == 0)
+	    units = U_USFEET;
 	else if (strcasecmp(name, "degree") == 0 || strcasecmp(name, "degrees") == 0)
 	    units = U_DEGREES;
 	else
@@ -127,7 +129,7 @@
     double factor;
     int n;
 
-    /* TODO: note the definitions in ../proj/units.table */
+    /* TODO: sync with definitions in ../proj/units.table */
     static const struct
     {
 	char *unit;
@@ -135,7 +137,8 @@
     } table[] = {
 	{"unit",  1.0},
 	{"meter", 1.0},
-	{"foot", .3048},
+	{"foot",  .3048},
+	{"foot_us", 1200/3937.},
 	{"inch", .0254},
 	{NULL, 0.0}
     };

Modified: grass/trunk/lib/gis/units.c
===================================================================
--- grass/trunk/lib/gis/units.c	2014-09-23 18:44:32 UTC (rev 62059)
+++ grass/trunk/lib/gis/units.c	2014-09-24 00:12:29 UTC (rev 62060)
@@ -26,6 +26,7 @@
    - U_KILOMETERS
    - U_MILES
    - U_FEET
+   - U_USFEET
 
   Returns a factor which converts meters to units (by multiplication).
  
@@ -52,6 +53,10 @@
 	return 3.28083989501312;	        /*  1 / (0.0254 * 12)    */
 	break;
 	
+    case U_USFEET:
+	return 3.28083333333333;       	        /*  1 / (1200/3937)    */
+	break;
+	
     default:
 	return 1.0;
 	break;
@@ -70,6 +75,7 @@
    - U_HECTARES
    - U_MILES
    - U_FEET
+   - U_USFEET
 
   Returns a factor which converts square meters to square units (by
   multiplication).
@@ -102,9 +108,13 @@
 	break;
 	
     case U_FEET:
-	return 10.7639104167097;	        /*  1 / (0.0254 * 12)^2  */
+	return 10.7639104167097;	/*  1 / (0.0254 * 12)^2  */
 	break;
 	
+    case U_USFEET:
+	return 10.7638673611111;       	/*  1 / (1200/3937)^2    */
+	break;
+	
     default:
 	return 1.0;
 	break;
@@ -135,6 +145,8 @@
         return 1;
     case U_FEET:
         return 1;
+    case U_USFEET:
+        return 1;
     case U_RADIANS:
         return 1;
     case U_DEGREES:
@@ -179,6 +191,7 @@
    - U_HECTARES
    - U_MILES
    - U_FEET
+   - U_USFEET
 
   \param units units code
   \param plural plural form if true
@@ -241,6 +254,13 @@
 	    return plural ? _("feet") : _("foot");
 	break;
 
+    case U_USFEET:
+	if (square)
+	    return plural ? _("square US feet") : _("square US foot");
+	else
+	    return plural ? _("US feet") : _("US foot");
+	break;
+
     case U_DEGREES:
 	if (square)
 	    return plural ? _("square degrees") : _("square degree");
@@ -286,6 +306,7 @@
    - U_HECTARES
    - U_MILES
    - U_FEET
+   - U_USFEET
    - ...
    - U_YEARS
    - ...
@@ -319,11 +340,14 @@
     else if (strcasecmp(units_name, "foot") == 0 ||
 	     strcasecmp(units_name, "feet") == 0)
 	return U_FEET;
+    else if (strcasecmp(units_name, "foot_us") == 0 ||
+	     strcasecmp(units_name, "foot_uss") == 0)
+	return U_USFEET;
     else if (strcasecmp(units_name, "degree") == 0 ||
 	     strcasecmp(units_name, "degrees") == 0)
 	return U_DEGREES;
     else if (strcasecmp(units_name, "year") == 0 ||
-	strcasecmp(units_name, "years") == 0)
+	     strcasecmp(units_name, "years") == 0)
 	return U_YEARS;
     else if (strcasecmp(units_name, "month") == 0 ||
 	     strcasecmp(units_name, "months") == 0)



More information about the grass-commit mailing list