[mapserver-commits] r9157 - in trunk/mapserver: . mapscript/php3

svn at osgeo.org svn at osgeo.org
Thu Jul 9 14:34:37 EDT 2009


Author: aboudreault
Date: 2009-07-09 14:34:37 -0400 (Thu, 09 Jul 2009)
New Revision: 9157

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
Log:
Exposed msMapOffsetExtent, msMapScaleExtent and msMapSetCenter methods in PHP/Mapscript (#2460)

Modified: trunk/mapserver/HISTORY.TXT
===================================================================
--- trunk/mapserver/HISTORY.TXT	2009-07-09 13:14:50 UTC (rev 9156)
+++ trunk/mapserver/HISTORY.TXT	2009-07-09 18:34:37 UTC (rev 9157)
@@ -14,6 +14,8 @@
 Current Version (SVN trunk):
 ----------------------------
 
+- Exposed msMapOffsetExtent, msMapScaleExtent and msMapSetCenter methods in PHP/Mapscript (#2460)
+
 - Removed ZEND_DEBUG define in PHP/Mapscript (#2717)
 
 - Fixed PHP/Mapscript to support PHP 5.3 (#3065, #3066)

Modified: trunk/mapserver/mapscript/php3/mapscript_i.c
===================================================================
--- trunk/mapserver/mapscript/php3/mapscript_i.c	2009-07-09 13:14:50 UTC (rev 9156)
+++ trunk/mapserver/mapscript/php3/mapscript_i.c	2009-07-09 18:34:37 UTC (rev 9157)
@@ -358,6 +358,22 @@
     return msRemoveLayer(self, layerindex);
 }
 
+int mapObj_setCenter(mapObj *self, pointObj *center)
+{
+    return msMapSetCenter(self, center);    
+}
+
+int mapObj_offsetExtent(mapObj *self, double x, double y)
+{
+    return msMapOffsetExtent(self, x, y);    
+}
+
+int mapObj_scaleExtent(mapObj *self, double zoomfactor, double minscaledenom, 
+                       double maxscaledenom)
+{
+    return msMapScaleExtent(self, zoomfactor, minscaledenom, maxscaledenom);    
+}
+
 /**********************************************************************
  * class extensions for layerObj, always within the context of a map
  **********************************************************************/
@@ -403,7 +419,7 @@
 int layerObj_whichShapes(layerObj *self, rectObj *poRect) {
     int oldconnectiontype = self->connectiontype;
     self->connectiontype = MS_INLINE;
-
+    
     if(msLayerWhichItems(self, MS_FALSE, NULL) != MS_SUCCESS) {
         self->connectiontype = oldconnectiontype;
         return MS_FAILURE;

Modified: trunk/mapserver/mapscript/php3/php_mapscript.c
===================================================================
--- trunk/mapserver/mapscript/php3/php_mapscript.c	2009-07-09 13:14:50 UTC (rev 9156)
+++ trunk/mapserver/mapscript/php3/php_mapscript.c	2009-07-09 18:34:37 UTC (rev 9157)
@@ -169,6 +169,10 @@
 DLEXPORT void php3_ms_map_insertLayer(INTERNAL_FUNCTION_PARAMETERS);
 DLEXPORT void php3_ms_map_removeLayer(INTERNAL_FUNCTION_PARAMETERS);
 
+DLEXPORT void php3_ms_map_setcenter(INTERNAL_FUNCTION_PARAMETERS);
+DLEXPORT void php3_ms_map_offsetextent(INTERNAL_FUNCTION_PARAMETERS);
+DLEXPORT void php3_ms_map_scaleextent(INTERNAL_FUNCTION_PARAMETERS);
+
 DLEXPORT void php3_ms_img_saveImage(INTERNAL_FUNCTION_PARAMETERS);
 DLEXPORT void php3_ms_img_saveWebImage(INTERNAL_FUNCTION_PARAMETERS);
 DLEXPORT void php3_ms_img_pasteImage(INTERNAL_FUNCTION_PARAMETERS);
@@ -729,6 +733,9 @@
     {"owsdispatch",     php3_ms_map_OWSDispatch,        NULL},
     {"insertlayer",     php3_ms_map_insertLayer,        NULL},
     {"removelayer",     php3_ms_map_removeLayer,        NULL},
+    {"setcenter",       php3_ms_map_setcenter,          NULL},
+    {"offsetextent",    php3_ms_map_offsetextent,       NULL},
+    {"scaleextent",     php3_ms_map_scaleextent,       NULL},
     {NULL, NULL, NULL}
 };
 
@@ -6241,10 +6248,135 @@
 }
 /* }}} */
 
+/**********************************************************************
+ *                        map->setCenter()
+ *
+ * Set the map center to the given map point. 
+ **********************************************************************/
+
+/* {{{ proto int map.setCenter(pointObj center)
+   Returns MS_SUCCESS or MS_FAILURE */
+ 
+DLEXPORT void php3_ms_map_setcenter(INTERNAL_FUNCTION_PARAMETERS)
+{ 
+    pval  *pThis, *pPoint;
+    mapObj *self=NULL;
+    pointObj *poPoint;
+    HashTable   *list=NULL;
+    int nStatus = MS_FAILURE;
+
+    pThis = getThis();
+
+    if (pThis == NULL ||
+        (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &pPoint) 
+         == FAILURE))
+    {
+       return;
+    }
+
+    self = (mapObj *)_phpms_fetch_handle(pThis, PHPMS_GLOBAL(le_msmap), 
+                                         list TSRMLS_CC);
+
+    poPoint = (pointObj *)_phpms_fetch_handle2(pPoint,
+                                               PHPMS_GLOBAL(le_mspoint_ref),
+                                               PHPMS_GLOBAL(le_mspoint_new),
+                                               list TSRMLS_CC);
+
+    if (self && poPoint &&
+        (nStatus=mapObj_setCenter(self, poPoint) != MS_SUCCESS))
+    {
+        _phpms_report_mapserver_error(E_WARNING);
+    }
+
+    RETURN_LONG(nStatus);
+    
+}
 /* }}} */
 
+/**********************************************************************
+ *                        map->offsetExtent()
+ *
+ * Offset the map extent based on the given distances in map coordinates.
+ **********************************************************************/
 
+/* {{{ proto int map.offsetExtend(float x, float y)
+   Returns MS_SUCCESS or MS_FAILURE */
+ 
+DLEXPORT void php3_ms_map_offsetextent(INTERNAL_FUNCTION_PARAMETERS)
+{ 
+    pval  *pThis;
+    mapObj *self=NULL;
+    HashTable   *list=NULL;
+    int nStatus = MS_FAILURE;
+    double x, y;
 
+    pThis = getThis();
+
+    if (pThis == NULL ||
+        (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dd", &x, &y) 
+         == FAILURE))
+    {
+       return;
+    }
+
+    self = (mapObj *)_phpms_fetch_handle(pThis, PHPMS_GLOBAL(le_msmap), 
+                                         list TSRMLS_CC);
+
+    if (self &&
+        (nStatus=mapObj_offsetExtent(self, x, y) != MS_SUCCESS))
+    {
+        _phpms_report_mapserver_error(E_WARNING);
+    }
+
+    RETURN_LONG(nStatus);
+    
+}
+/* }}} */
+
+/**********************************************************************
+ *                        map->scaleExtent()
+ *
+ * Scale the map extent using the zoomfactor and ensure the extent within
+ * the minscaledenom and maxscaledenom domain. If minscaledenom and/or
+ * maxscaledenom is 0 then the parameter is not taken into account.
+ **********************************************************************/
+
+/* {{{ proto int map.scaleExtend(double zoomfactor, double minscaledenom,
+                                 double maxscaledenom) 
+   Returns MS_SUCCESS or MS_FAILURE */
+ 
+DLEXPORT void php3_ms_map_scaleextent(INTERNAL_FUNCTION_PARAMETERS)
+{ 
+    pval  *pThis;
+    mapObj *self=NULL;
+    HashTable   *list=NULL;
+    int nStatus = MS_FAILURE;
+    double zoomfactor, minscaledenom, maxscaledenom;
+
+    pThis = getThis();
+
+    if (pThis == NULL ||
+        (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ddd", &zoomfactor, &minscaledenom, &maxscaledenom) 
+         == FAILURE))
+    {
+       return;
+    }
+
+    self = (mapObj *)_phpms_fetch_handle(pThis, PHPMS_GLOBAL(le_msmap), 
+                                         list TSRMLS_CC);
+
+    if (self &&
+        (nStatus=mapObj_scaleExtent(self, zoomfactor, minscaledenom, maxscaledenom) != MS_SUCCESS))
+    {
+        _phpms_report_mapserver_error(E_WARNING);
+    }
+
+    RETURN_LONG(nStatus);
+    
+}
+/* }}} */
+
+
 /*=====================================================================
  *                 PHP function wrappers - image class
  *====================================================================*/

Modified: trunk/mapserver/mapscript/php3/php_mapscript.h
===================================================================
--- trunk/mapserver/mapscript/php3/php_mapscript.h	2009-07-09 13:14:50 UTC (rev 9156)
+++ trunk/mapserver/mapscript/php3/php_mapscript.h	2009-07-09 18:34:37 UTC (rev 9157)
@@ -130,6 +130,11 @@
 int             mapObj_insertLayer(mapObj *self, layerObj *layer, int index);
 layerObj        *mapObj_removeLayer(mapObj *self, int layerindex);
 
+int             mapObj_setCenter(mapObj *self, pointObj *center);
+int             mapObj_offsetExtent(mapObj *self, double x, double y);
+int             mapObj_scaleExtent(mapObj *self, double zoomfactor, double minscaledenom, 
+                                   double maxscaledenom);
+
 layerObj       *layerObj_new(mapObj *map);
 void            layerObj_destroy(layerObj* self);
 int             layerObj_updateFromString(layerObj *self, char *snippet);



More information about the mapserver-commits mailing list