[mapserver-commits] r8389 - in trunk/mapserver: . mapscript/php3 mapscript/python/tests/cases mapscript/swiginc

svn at osgeo.org svn at osgeo.org
Tue Jan 6 10:27:12 EST 2009


Author: aboudreault
Date: 2009-01-06 10:27:12 -0500 (Tue, 06 Jan 2009)
New Revision: 8389

Modified:
   trunk/mapserver/HISTORY.TXT
   trunk/mapserver/mapscript/php3/mapscript_i.c
   trunk/mapserver/mapscript/php3/php_mapscript.c
   trunk/mapserver/mapscript/php3/php_mapscript.h
   trunk/mapserver/mapscript/python/tests/cases/maptest.py
   trunk/mapserver/mapscript/swiginc/projection.i
Log:
Added getUnits() methods to projectionObj in Mapscript (#2798)


Modified: trunk/mapserver/HISTORY.TXT
===================================================================
--- trunk/mapserver/HISTORY.TXT	2009-01-05 18:36:43 UTC (rev 8388)
+++ trunk/mapserver/HISTORY.TXT	2009-01-06 15:27:12 UTC (rev 8389)
@@ -12,6 +12,8 @@
 Current Version (5.3-dev, SVN trunk):
 ------------------------------------
 
+- Added getUnits() methods to projectionObj in Mapscript (#2798)
+
 - Improved Tag parsing in template code. (#2781)
 
 - Added hashtable object and metadata methods for php-mapscript (#2773)

Modified: trunk/mapserver/mapscript/php3/mapscript_i.c
===================================================================
--- trunk/mapserver/mapscript/php3/mapscript_i.c	2009-01-05 18:36:43 UTC (rev 8388)
+++ trunk/mapserver/mapscript/php3/mapscript_i.c	2009-01-06 15:27:12 UTC (rev 8389)
@@ -1169,6 +1169,10 @@
     return proj;
   }
 
+int projectionObj_getUnits(projectionObj *self)
+{
+   return GetMapserverUnitUsingProj(self);
+}
 
 void projectionObj_destroy(projectionObj *self) {
     msFreeProjection(self);

Modified: trunk/mapserver/mapscript/php3/php_mapscript.c
===================================================================
--- trunk/mapserver/mapscript/php3/php_mapscript.c	2009-01-05 18:36:43 UTC (rev 8388)
+++ trunk/mapserver/mapscript/php3/php_mapscript.c	2009-01-06 15:27:12 UTC (rev 8389)
@@ -324,6 +324,7 @@
 DLEXPORT void php3_ms_referenceMap_setProperty(INTERNAL_FUNCTION_PARAMETERS);
 
 DLEXPORT void php3_ms_projection_new(INTERNAL_FUNCTION_PARAMETERS);
+DLEXPORT void php3_ms_projection_getunits(INTERNAL_FUNCTION_PARAMETERS);
 DLEXPORT void php3_ms_projection_free(INTERNAL_FUNCTION_PARAMETERS);
 
 DLEXPORT void php3_ms_scalebar_setProperty(INTERNAL_FUNCTION_PARAMETERS);
@@ -912,6 +913,7 @@
 };
 
 function_entry php_projection_class_functions[] = {
+    {"getunits",        php3_ms_projection_getunits,    NULL},
     {"free",            php3_ms_projection_free,        NULL},    
     {NULL, NULL, NULL}
 };
@@ -13624,6 +13626,45 @@
 /* }}} */
 
 /**********************************************************************
+ *                        projection->getunits()
+ **********************************************************************/
+
+/* {{{ proto int projection.getunits()
+   Returns the units of a projection object */
+DLEXPORT void php3_ms_projection_getunits(INTERNAL_FUNCTION_PARAMETERS)
+{
+    pval *pThis;
+    projectionObj *self;
+    long lValue = -1;
+
+    HashTable   *list=NULL;
+
+    pThis = getThis();
+
+
+    if (pThis == NULL ||
+        ARG_COUNT(ht) > 0)
+    {
+        WRONG_PARAM_COUNT;
+    }
+
+    self = (projectionObj *)_phpms_fetch_handle2(pThis, 
+                                                 PHPMS_GLOBAL(le_msprojection_new), 
+                                                 PHPMS_GLOBAL(le_msprojection_ref),
+                                                 list TSRMLS_CC);
+
+    if (self)
+    {
+       lValue = projectionObj_getUnits(self);
+    } else {
+       php3_error(E_ERROR, "Invalid projection object.");
+    }
+
+    RETURN_LONG(lValue);
+}
+/* }}} */
+
+/**********************************************************************
  *                        projection->free()
  **********************************************************************/
 

Modified: trunk/mapserver/mapscript/php3/php_mapscript.h
===================================================================
--- trunk/mapserver/mapscript/php3/php_mapscript.h	2009-01-05 18:36:43 UTC (rev 8388)
+++ trunk/mapserver/mapscript/php3/php_mapscript.h	2009-01-06 15:27:12 UTC (rev 8389)
@@ -281,6 +281,7 @@
 int             shapefileObj_addPoint(shapefileObj *self, pointObj *point);
 
 projectionObj   *projectionObj_new(char *string);
+int             projectionObj_getUnits(projectionObj *self);
 void            projectionObj_destroy(projectionObj *self);
 
 void            labelCacheObj_freeCache(labelCacheObj *self);

Modified: trunk/mapserver/mapscript/python/tests/cases/maptest.py
===================================================================
--- trunk/mapserver/mapscript/python/tests/cases/maptest.py	2009-01-05 18:36:43 UTC (rev 8388)
+++ trunk/mapserver/mapscript/python/tests/cases/maptest.py	2009-01-06 15:27:12 UTC (rev 8389)
@@ -287,6 +287,7 @@
 
         assert proj4.find( '+proj=aea' ) != -1
         assert proj4.find( '+ellps=WGS84' ) != -1
+        assert (mapscript.projectionObj(proj4)).getUnits() != mapscript.MS_DD
 
     def testESRIWKT(self):
         self.map.setWKTProjection('ESRI::PROJCS["Pulkovo_1995_GK_Zone_2",GEOGCS["GCS_Pulkovo_1995",DATUM["D_Pulkovo_1995",SPHEROID["Krasovsky_1940",6378245,298.3]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]],PROJECTION["Gauss_Kruger"],PARAMETER["False_Easting",2500000],PARAMETER["False_Northing",0],PARAMETER["Central_Meridian",9],PARAMETER["Scale_Factor",1],PARAMETER["Latitude_Of_Origin",0],UNIT["Meter",1]]')
@@ -294,14 +295,15 @@
 
         assert proj4.find( '+proj=tmerc' ) != -1
         assert proj4.find( '+ellps=krass' ) != -1
+        assert (mapscript.projectionObj(proj4)).getUnits() != mapscript.MS_DD
 
     def testWellKnownGEOGCS(self):
         self.map.setWKTProjection('WGS84')
         proj4 = self.map.getProjection()
         assert proj4.find( '+proj=longlat' ) != -1, proj4
         assert proj4.find( '+ellps=WGS84' ) != -1, proj4
+        assert (mapscript.projectionObj(proj4)).getUnits() != mapscript.MS_METERS
 
-
 # ===========================================================================
 # Run the tests outside of the main suite
 

Modified: trunk/mapserver/mapscript/swiginc/projection.i
===================================================================
--- trunk/mapserver/mapscript/swiginc/projection.i	2009-01-05 18:36:43 UTC (rev 8388)
+++ trunk/mapserver/mapscript/swiginc/projection.i	2009-01-06 15:27:12 UTC (rev 8389)
@@ -61,6 +61,10 @@
         /* no debug output here */
         return msOGCWKT2ProjectionObj(wkt, self, MS_FALSE);
     }
+
+    int getUnits() {
+      return GetMapserverUnitUsingProj(self);
+    }
 }
 
 



More information about the mapserver-commits mailing list