[mapserver-commits] r7853 - in trunk/mapserver/mapscript: php3 swiginc

svn at osgeo.org svn at osgeo.org
Thu Aug 14 14:16:17 EDT 2008


Author: dmorissette
Date: 2008-08-14 14:16:17 -0400 (Thu, 14 Aug 2008)
New Revision: 7853

Modified:
   trunk/mapserver/mapscript/php3/README
   trunk/mapserver/mapscript/php3/mapscript_i.c
   trunk/mapserver/mapscript/php3/php_mapscript.c
   trunk/mapserver/mapscript/php3/php_mapscript.h
   trunk/mapserver/mapscript/swiginc/layer.i
Log:
Ported layer->setConnectionType() to PHP MapScript (#2735)

Modified: trunk/mapserver/mapscript/php3/README
===================================================================
--- trunk/mapserver/mapscript/php3/README	2008-08-14 18:14:40 UTC (rev 7852)
+++ trunk/mapserver/mapscript/php3/README	2008-08-14 18:16:17 UTC (rev 7853)
@@ -637,7 +637,7 @@
    string header
    string footer
    string connection
-   int    connectiontype
+   int    connectiontype  (read-only, use setConnectionType() to set it)
    string filteritem
    string template
    int    opacity
@@ -893,7 +893,14 @@
        Returns MS_TRUE/MS_FALSE depending on whether the layer is 
        currently visible in the map (i.e. turned on, in scale, etc.). 
 
- 
+  int setConenctionType(int connectiontype [,string plugin_library])
+       Changes the connectiontype of the layer and recreates the vtable 
+       according to the new connection type. This method should be used 
+       instead of setting the connectiontype parameter directly. 
+       In case when the layer.connectiontype = MS_PLUGIN the plugin_library
+       parameter should also be specified so as to select the library to 
+       load by mapserver. For the other connection types this parameter 
+       is not used. 
 
  ClassObj Class:
  ---------------

Modified: trunk/mapserver/mapscript/php3/mapscript_i.c
===================================================================
--- trunk/mapserver/mapscript/php3/mapscript_i.c	2008-08-14 18:14:40 UTC (rev 7852)
+++ trunk/mapserver/mapscript/php3/mapscript_i.c	2008-08-14 18:16:17 UTC (rev 7853)
@@ -581,6 +581,18 @@
     return msRemoveClass(self, index);
 }
 
+int layerObj_setConnectionType(layerObj *self, int connectiontype, 
+                               const char *library_str) 
+{
+    /* Caller is responsible to close previous layer correctly before calling
+     * msConnectLayer() 
+     */
+    if (msLayerIsOpen(self))
+        msLayerClose(self);
+
+    return msConnectLayer(self, connectiontype, library_str);
+}
+
 /**********************************************************************
  * class extensions for classObj, always within the context of a layer
  **********************************************************************/

Modified: trunk/mapserver/mapscript/php3/php_mapscript.c
===================================================================
--- trunk/mapserver/mapscript/php3/php_mapscript.c	2008-08-14 18:14:40 UTC (rev 7852)
+++ trunk/mapserver/mapscript/php3/php_mapscript.c	2008-08-14 18:16:17 UTC (rev 7853)
@@ -217,6 +217,7 @@
 DLEXPORT void php3_ms_lyr_moveClassDown(INTERNAL_FUNCTION_PARAMETERS);
 DLEXPORT void php3_ms_lyr_removeClass(INTERNAL_FUNCTION_PARAMETERS);
 DLEXPORT void php3_ms_lyr_isVisible(INTERNAL_FUNCTION_PARAMETERS);
+DLEXPORT void php3_ms_lyr_setConnectionType(INTERNAL_FUNCTION_PARAMETERS);
 
 DLEXPORT void php3_ms_class_new(INTERNAL_FUNCTION_PARAMETERS);
 DLEXPORT void php3_ms_class_setProperty(INTERNAL_FUNCTION_PARAMETERS);
@@ -760,6 +761,7 @@
     {"setprojection",   php3_ms_lyr_setProjection,      NULL},
     {"getprojection",   php3_ms_lyr_getProjection,      NULL},
     {"setwktprojection",php3_ms_lyr_setWKTProjection,   NULL},
+    {"setconnectiontype",php3_ms_lyr_setConnectionType, NULL},
     {"addfeature",      php3_ms_lyr_addFeature,         NULL},
     {"getnumresults",   php3_ms_lyr_getNumResults,      NULL},
     {"getresult",       php3_ms_lyr_getResult,          NULL},
@@ -6693,7 +6695,6 @@
     else IF_SET_STRING("header",     self->header)
     else IF_SET_STRING("footer",     self->footer)
     else IF_SET_STRING("connection", self->connection)
-    else IF_SET_LONG(  "connectiontype", self->connectiontype)
     else IF_SET_STRING("filteritem", self->filteritem)
     else IF_SET_STRING("template",   self->template)
     else IF_SET_LONG(  "opacity", self->opacity)
@@ -6702,6 +6703,12 @@
     else IF_SET_STRING("styleitem",  self->styleitem)
     else IF_SET_STRING("requires",   self->requires)
     else IF_SET_STRING("labelrequires",   self->labelrequires)
+    else if (strcmp( "connectiontype", pPropertyName->value.str.val) == 0)
+    {
+        php3_error(E_ERROR, "Property 'connectiontype' must be set "
+                            "using setConnectionType().");
+        RETURN_LONG(-1);
+    }
     else if (strcmp( "numclasses", pPropertyName->value.str.val) == 0 ||
              strcmp( "index",      pPropertyName->value.str.val) == 0 )
     {
@@ -7372,6 +7379,59 @@
     }
 }
 
+
+/**********************************************************************
+ *                        layer->setConnectionType()
+ **********************************************************************/
+
+/* {{{ proto int layer.setConnectionType(int connectiontype, string library_str)
+   Set layer connectiontype.  Returns 0 on success, -1 in error. */
+
+DLEXPORT void php3_ms_lyr_setConnectionType(INTERNAL_FUNCTION_PARAMETERS)
+{
+    layerObj *self;
+    pval   *pConnectionType, *pLibrary;
+    pval   *pThis;
+    int     numArgs, nStatus = -1;
+    const char *pszLibrary = "";
+
+    HashTable   *list=NULL;
+    pThis = getThis();
+    numArgs = ARG_COUNT(ht);
+
+    if (pThis == NULL || (numArgs != 1 && numArgs != 2) ||
+        getParameters(ht, numArgs, &pConnectionType, &pLibrary) != SUCCESS)
+    {
+        WRONG_PARAM_COUNT;
+    }
+    convert_to_long(pConnectionType);
+
+    if (numArgs >= 2)
+    {
+        convert_to_string(pLibrary);
+        pszLibrary = pLibrary->value.str.val;
+    }
+
+    self = (layerObj *)_phpms_fetch_handle(pThis, PHPMS_GLOBAL(le_mslayer),
+                                           list TSRMLS_CC);
+    if (self == NULL || 
+        (nStatus = layerObj_setConnectionType(self, 
+                                              pConnectionType->value.lval,
+                                              pszLibrary)) != 0)
+    {
+        _phpms_report_mapserver_error(E_ERROR);
+    }
+    else
+    {
+        _phpms_set_property_long(pThis, "connectiontype", 
+                                 self->connectiontype, E_ERROR TSRMLS_CC);
+    }
+
+    RETURN_LONG(nStatus);
+}
+/* }}} */
+
+
 /************************************************************************/
 /*                        layer->addFeature                             */
 /*                                                                      */

Modified: trunk/mapserver/mapscript/php3/php_mapscript.h
===================================================================
--- trunk/mapserver/mapscript/php3/php_mapscript.h	2008-08-14 18:14:40 UTC (rev 7852)
+++ trunk/mapserver/mapscript/php3/php_mapscript.h	2008-08-14 18:16:17 UTC (rev 7853)
@@ -170,6 +170,8 @@
 int             layerObj_moveClassUp(layerObj *self, int index);
 int             layerObj_moveClassDown(layerObj *self, int index);
 classObj        *layerObj_removeClass(layerObj *self, int index);
+int             layerObj_setConnectionType(layerObj *self, int connectiontype, 
+                                           const char *library_str) ;
 
 
 classObj       *classObj_new(layerObj *layer, classObj *class);

Modified: trunk/mapserver/mapscript/swiginc/layer.i
===================================================================
--- trunk/mapserver/mapscript/swiginc/layer.i	2008-08-14 18:14:40 UTC (rev 7852)
+++ trunk/mapserver/mapscript/swiginc/layer.i	2008-08-14 18:16:17 UTC (rev 7853)
@@ -545,9 +545,13 @@
         return msLayerClearProcessing(self);
     }
     
-    int setConnectionType(int connectiontype,
-                            char *library_str) 
+    int setConnectionType(int connectiontype, const char *library_str) 
     {    
+        /* Caller is responsible to close previous layer correctly before
+         * calling msConnectLayer() 
+         */
+        if (msLayerIsOpen(self))
+          msLayerClose(self);
         return msConnectLayer(self, connectiontype, library_str);
     }
 }



More information about the mapserver-commits mailing list