[mapserver-commits] r10031 - in trunk/mapserver: . mapscript/php mapscript/swiginc

svn at osgeo.org svn at osgeo.org
Tue Mar 30 15:15:12 EDT 2010


Author: aboudreault
Date: 2010-03-30 15:15:11 -0400 (Tue, 30 Mar 2010)
New Revision: 10031

Modified:
   trunk/mapserver/HISTORY.TXT
   trunk/mapserver/mapscript/php/layer.c
   trunk/mapserver/mapscript/php/mapscript_i.c
   trunk/mapserver/mapscript/php/php_mapscript.h
   trunk/mapserver/mapscript/swiginc/layer.i
Log:
Fixed MapScript shape->classindex is always 0 (#3406)

Modified: trunk/mapserver/HISTORY.TXT
===================================================================
--- trunk/mapserver/HISTORY.TXT	2010-03-30 16:07:48 UTC (rev 10030)
+++ trunk/mapserver/HISTORY.TXT	2010-03-30 19:15:11 UTC (rev 10031)
@@ -14,6 +14,8 @@
 Current Version (SVN trunk):
 ----------------------------
 
+- Fixed MapScript shape->classindex is always 0 (#3406)
+
 - Fixed PHP MapScript integer passing broken on 64bit systems (#3412)
 
 - Fix MS_NONSQUARE to work in mode=map (#3413)

Modified: trunk/mapserver/mapscript/php/layer.c
===================================================================
--- trunk/mapserver/mapscript/php/layer.c	2010-03-30 16:07:48 UTC (rev 10030)
+++ trunk/mapserver/mapscript/php/layer.c	2010-03-30 19:15:11 UTC (rev 10031)
@@ -55,6 +55,13 @@
   ZEND_ARG_INFO(0, index)
 ZEND_END_ARG_INFO()
 
+ZEND_BEGIN_ARG_INFO_EX(layer_getClassIndex_args, 0, 0, 2)
+  ZEND_ARG_OBJ_INFO(0, shape, shapeObj, 0)
+  ZEND_ARG_INFO(0, scaledenom)
+  ZEND_ARG_INFO(0, classGroup)
+  ZEND_ARG_INFO(0, numClasses)
+ZEND_END_ARG_INFO()
+
 ZEND_BEGIN_ARG_INFO_EX(layer_setFilter_args, 0, 0, 1)
   ZEND_ARG_INFO(0, expression)
 ZEND_END_ARG_INFO()
@@ -698,7 +705,58 @@
 }
 /* }}} */
 
+/* {{{ proto int layer.getClassIndex(shapeObj shape, int scaledenom [, string classGroup, int numClasses])
+   Returns the class index for the shape */
+PHP_METHOD(layerObj, getClassIndex)
+{
+    zval *zobj = getThis();
+    zval *zshape, **ppzval, *zclassgroup = NULL;
+    int numElements, *classGroups = NULL;
+    int retval = -1, i = 0;
+    long numClasses = 0;
+    double scaledenom;
+    HashTable *classgroup_hash = NULL;
+    php_shape_object *php_shape;
+    php_layer_object *php_layer;
 
+    PHP_MAPSCRIPT_ERROR_HANDLING(TRUE);
+    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Od|a!l",
+                              &zshape, mapscript_ce_shape,
+                              &scaledenom, &zclassgroup,
+                              &numClasses) == FAILURE) {
+        PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
+        return;
+    }
+    PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
+    
+    php_layer = (php_layer_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+    php_shape = (php_shape_object *) zend_object_store_get_object(zshape TSRMLS_CC);
+
+    if (zclassgroup)
+    {
+        classgroup_hash = Z_ARRVAL_P(zclassgroup);
+        numElements = zend_hash_num_elements(classgroup_hash);
+        classGroups = (int*)malloc(sizeof(int)*numElements);
+        
+        for(zend_hash_internal_pointer_reset(classgroup_hash); 
+            zend_hash_has_more_elements(classgroup_hash) == SUCCESS; 
+            zend_hash_move_forward(classgroup_hash), ++i)
+        {     
+            zend_hash_get_current_data(classgroup_hash, (void **)&ppzval);
+            classGroups[i] = Z_LVAL_PP(ppzval);
+        }
+    }
+    
+    retval = layerObj_getClassIndex(php_layer->layer, php_shape->shape, scaledenom, classGroups, numClasses);
+  
+    if (zclassgroup)
+        free(classGroups);
+
+    RETURN_LONG(retval);
+}
+/* }}} */
+
+
 /* {{{ proto int layer.setFilter(string filter)
    Set layer filter expression.  Returns 0 on success, -1 in error. */
 PHP_METHOD(layerObj, setFilter)
@@ -1848,6 +1906,7 @@
     PHP_ME(layerObj, drawQuery, layer_drawQuery_args, ZEND_ACC_PUBLIC)
     PHP_ME(layerObj, updateFromString, layer_updateFromString_args, ZEND_ACC_PUBLIC)
     PHP_ME(layerObj, getClass, layer_getClass_args, ZEND_ACC_PUBLIC)
+    PHP_ME(layerObj, getClassIndex, layer_getClassIndex_args, ZEND_ACC_PUBLIC)
     PHP_ME(layerObj, queryByPoint, layer_queryByPoint_args, ZEND_ACC_PUBLIC)
     PHP_ME(layerObj, queryByRect, layer_queryByRect_args, ZEND_ACC_PUBLIC)
     PHP_ME(layerObj, queryByShape, layer_queryByShape_args, ZEND_ACC_PUBLIC)

Modified: trunk/mapserver/mapscript/php/mapscript_i.c
===================================================================
--- trunk/mapserver/mapscript/php/mapscript_i.c	2010-03-30 16:07:48 UTC (rev 10030)
+++ trunk/mapserver/mapscript/php/mapscript_i.c	2010-03-30 19:15:11 UTC (rev 10031)
@@ -503,6 +503,11 @@
       return(NULL);
   }
 
+int layerObj_getClassIndex(layerObj *self, shapeObj *shape, double scaledenom, 
+                           int *classgroup, int numclasses) {
+    return msShapeGetClass(self, shape, scaledenom, classgroup, numclasses);
+}
+
 int layerObj_draw(layerObj *self, mapObj *map, imageObj *img) {
     return msDrawLayer(map, self, img);
   }

Modified: trunk/mapserver/mapscript/php/php_mapscript.h
===================================================================
--- trunk/mapserver/mapscript/php/php_mapscript.h	2010-03-30 16:07:48 UTC (rev 10030)
+++ trunk/mapserver/mapscript/php/php_mapscript.h	2010-03-30 19:15:11 UTC (rev 10031)
@@ -553,6 +553,7 @@
                                   int tileindex, int shapeindex);
 resultCacheMemberObj *layerObj_getResult(layerObj *self, int i);
 classObj       *layerObj_getClass(layerObj *self, int i);
+int             layerObj_getClassIndex(layerObj *self, shapeObj *shape, double scaledenom, int *classgroup, int numclasses);
 int             layerObj_draw(layerObj *self, mapObj *map, imageObj *img);
 int             layerObj_drawQuery(layerObj *self, mapObj *map, imageObj *img);
 int             layerObj_queryByAttributes(layerObj *self, mapObj *map, 

Modified: trunk/mapserver/mapscript/swiginc/layer.i
===================================================================
--- trunk/mapserver/mapscript/swiginc/layer.i	2010-03-30 16:07:48 UTC (rev 10030)
+++ trunk/mapserver/mapscript/swiginc/layer.i	2010-03-30 19:15:11 UTC (rev 10031)
@@ -608,4 +608,9 @@
           msLayerClose(self);
         return msConnectLayer(self, connectiontype, library_str);
     }
+
+    int getClassIndex(shapeObj *shape, double scaledenom, int *classgroup=NULL, int numclasses=0) {
+        return msShapeGetClass(self, shape, scaledenom, classgroup, numclasses);
+    }
+
 }



More information about the mapserver-commits mailing list