[mapserver-commits] r8000 - in trunk/mapserver: . mapscript/php3
mapscript/python/tests/cases mapscript/swiginc
svn at osgeo.org
svn at osgeo.org
Fri Oct 24 11:42:15 EDT 2008
Author: aboudreault
Date: 2008-10-24 11:42:15 -0400 (Fri, 24 Oct 2008)
New Revision: 8000
Modified:
trunk/mapserver/HISTORY.TXT
trunk/mapserver/mapscript/php3/README
trunk/mapserver/mapscript/php3/php_mapscript.c
trunk/mapserver/mapscript/python/tests/cases/labeltest.py
trunk/mapserver/mapscript/python/tests/cases/styletest.py
trunk/mapserver/mapscript/swiginc/label.i
trunk/mapserver/mapscript/swiginc/style.i
Log:
MapScript: Added getBinding method to in label and style object (#2670)
Modified: trunk/mapserver/HISTORY.TXT
===================================================================
--- trunk/mapserver/HISTORY.TXT 2008-10-23 03:36:07 UTC (rev 7999)
+++ trunk/mapserver/HISTORY.TXT 2008-10-24 15:42:15 UTC (rev 8000)
@@ -12,6 +12,8 @@
Current Version (5.3-dev, SVN trunk):
------------------------------------
+- MapScript: Added getBinding method to label and style object (#2670)
+
- mapowscommon.c: use strcasecmp to check for language value
- raster query fix for tileindex with relative paths (#2722)
Modified: trunk/mapserver/mapscript/php3/README
===================================================================
--- trunk/mapserver/mapscript/php3/README 2008-10-23 03:36:07 UTC (rev 7999)
+++ trunk/mapserver/mapscript/php3/README 2008-10-24 15:42:15 UTC (rev 8000)
@@ -1116,6 +1116,14 @@
This would bind the color parameter with the data (ie will extract
the value of the color from the field called "FIELD_NAME_COLOR"
+ string getBinding(const labelbinding)
+ Get the attribute binding for a specfiled label property. Returns null if there
+ is no binding for this property.
+
+ Example:
+ $oLabel->setbinding(MS_LABEL_BINDING_COLOR, "FIELD_NAME_COLOR");
+ echo $oLabel->getbinding(MS_LABEL_BINDING_COLOR); // FIELD_NAME_COLOR
+
int removeBinding(const labelbinding)
Remove the attribute binding for a specfiled style property. Returns true on success.
Example:
@@ -1727,7 +1735,15 @@
$oStyle->setbinding(MS_STYLE_BINDING_COLOR, "FIELD_NAME_COLOR");
This would bind the color parameter with the data (ie will extract
the value of the color from the field called "FIELD_NAME_COLOR"
-
+
+ string getBinding(const stylebinding)
+ Get the attribute binding for a specfiled style property. Returns null if there
+ is no binding for this property.
+
+ Example:
+ $oStyle->setbinding(MS_STYLE_BINDING_COLOR, "FIELD_NAME_COLOR");
+ echo $oStyle->getbinding(MS_STYLE_BINDING_COLOR); // FIELD_NAME_COLOR
+
int removeBinding(const stylebinding)
Remove the attribute binding for a specfiled style property. Returns true on success.
Added in MapServer 5.0.
Modified: trunk/mapserver/mapscript/php3/php_mapscript.c
===================================================================
--- trunk/mapserver/mapscript/php3/php_mapscript.c 2008-10-23 03:36:07 UTC (rev 7999)
+++ trunk/mapserver/mapscript/php3/php_mapscript.c 2008-10-24 15:42:15 UTC (rev 8000)
@@ -239,6 +239,7 @@
DLEXPORT void php3_ms_label_setProperty(INTERNAL_FUNCTION_PARAMETERS);
DLEXPORT void php3_ms_label_setBinding(INTERNAL_FUNCTION_PARAMETERS);
+DLEXPORT void php3_ms_label_getBinding(INTERNAL_FUNCTION_PARAMETERS);
DLEXPORT void php3_ms_label_removeBinding(INTERNAL_FUNCTION_PARAMETERS);
DLEXPORT void php3_ms_color_setRGB(INTERNAL_FUNCTION_PARAMETERS);
@@ -332,6 +333,7 @@
DLEXPORT void php3_ms_style_setProperty(INTERNAL_FUNCTION_PARAMETERS);
DLEXPORT void php3_ms_style_clone(INTERNAL_FUNCTION_PARAMETERS);
DLEXPORT void php3_ms_style_setBinding(INTERNAL_FUNCTION_PARAMETERS);
+DLEXPORT void php3_ms_style_getBinding(INTERNAL_FUNCTION_PARAMETERS);
DLEXPORT void php3_ms_style_removeBinding(INTERNAL_FUNCTION_PARAMETERS);
DLEXPORT void php3_ms_grid_new(INTERNAL_FUNCTION_PARAMETERS);
@@ -801,6 +803,7 @@
function_entry php_label_class_functions[] = {
{"set", php3_ms_label_setProperty, NULL},
{"setbinding", php3_ms_label_setBinding, NULL},
+ {"getbinding", php3_ms_label_getBinding, NULL},
{"removebinding", php3_ms_label_removeBinding, NULL},
{NULL, NULL, NULL}
};
@@ -903,6 +906,7 @@
{"set", php3_ms_style_setProperty, NULL},
{"clone", php3_ms_style_clone, NULL},
{"setbinding", php3_ms_style_setBinding, NULL},
+ {"getbinding", php3_ms_style_getBinding, NULL},
{"removebinding", php3_ms_style_removeBinding, NULL},
{NULL, NULL, NULL}
};
@@ -8818,7 +8822,47 @@
RETURN_TRUE;
}
+/* {{{ proto int label.getbinding(const bindingid)
+ Get the value of a attribute binding for a specfiled label property.
+ Returns the string value if exist, else null. */
+DLEXPORT void php3_ms_label_getBinding(INTERNAL_FUNCTION_PARAMETERS)
+{
+ pval *pThis = NULL;
+ labelObj *self = NULL;
+ HashTable *list=NULL;
+ pval *pBindingId;
+ char *pszValue=NULL;
+
+ pThis = getThis();
+
+ if (pThis == NULL ||
+ getParameters(ht, 1, &pBindingId) != SUCCESS)
+ {
+ WRONG_PARAM_COUNT;
+ }
+
+ self = (labelObj *)_phpms_fetch_handle(pThis,
+ PHPMS_GLOBAL(le_mslabel),
+ list TSRMLS_CC);
+ if (self == NULL)
+ php3_error(E_ERROR, "Invalid label object.");
+
+ convert_to_long(pBindingId);
+
+ if (pBindingId->value.lval < 0 || pBindingId->value.lval > MS_LABEL_BINDING_LENGTH)
+ php3_error(E_ERROR, "Invalid binding id given for getbinding function.");
+
+
+ if( (pszValue = self->bindings[pBindingId->value.lval].item) != NULL)
+ {
+ RETURN_STRING(pszValue, 1);
+ }
+
+ return;
+}
+
+
/* {{{ proto int label.removebinding(const bindingid)
Remove attribute binding for a specfiled label property. Returns true on success. */
@@ -8846,7 +8890,7 @@
convert_to_long(pBindingId);
if (pBindingId->value.lval < 0 || pBindingId->value.lval > MS_LABEL_BINDING_LENGTH)
- php3_error(E_ERROR, "Invalid binding id given for setbinding function.");
+ php3_error(E_ERROR, "Invalid binding id given for removebinding function.");
if(self->bindings[pBindingId->value.lval].item)
@@ -14148,7 +14192,47 @@
RETURN_TRUE;
}
+/* {{{ proto int style.getbinding(const bindingid)
+ Get the value of a attribute binding for a specfiled style property.
+ Returns the string value if exist, else null. */
+DLEXPORT void php3_ms_style_getBinding(INTERNAL_FUNCTION_PARAMETERS)
+{
+ pval *pThis = NULL;
+ styleObj *self = NULL;
+ HashTable *list=NULL;
+ pval *pBindingId;
+ char *pszValue=NULL;
+
+ pThis = getThis();
+
+ if (pThis == NULL ||
+ getParameters(ht, 1, &pBindingId) != SUCCESS)
+ {
+ WRONG_PARAM_COUNT;
+ }
+
+ self = (styleObj *)_phpms_fetch_handle(pThis,
+ PHPMS_GLOBAL(le_msstyle),
+ list TSRMLS_CC);
+ if (self == NULL)
+ php3_error(E_ERROR, "Invalid style object.");
+
+ convert_to_long(pBindingId);
+
+ if (pBindingId->value.lval < 0 || pBindingId->value.lval > MS_STYLE_BINDING_LENGTH)
+ php3_error(E_ERROR, "Invalid binding id given for getbinding function.");
+
+
+ if( (pszValue = self->bindings[pBindingId->value.lval].item) != NULL)
+ {
+ RETURN_STRING(pszValue, 1);
+ }
+
+ return;
+}
+
+
/* {{{ proto int style.removebinding(const bindingid)
Remove attribute binding for a specfiled style property. Returns true on success. */
Modified: trunk/mapserver/mapscript/python/tests/cases/labeltest.py
===================================================================
--- trunk/mapserver/mapscript/python/tests/cases/labeltest.py 2008-10-23 03:36:07 UTC (rev 7999)
+++ trunk/mapserver/mapscript/python/tests/cases/labeltest.py 2008-10-24 15:42:15 UTC (rev 8000)
@@ -41,6 +41,15 @@
# ===========================================================================
# Test begins now
+class NewLabelsTestCase(MapTestCase):
+
+ def testLabelBinding(self):
+ """attribute binding can be set and get"""
+ new_label = mapscript.labelObj()
+ assert (not new_label.getBinding(mapscript.MS_LABEL_BINDING_COLOR))
+ new_label.setBinding(mapscript.MS_LABEL_BINDING_COLOR,"NEW_BINDING")
+ assert (new_label.getBinding(mapscript.MS_LABEL_BINDING_COLOR) == "NEW_BINDING")
+
class LabelCacheMemberTestCase(MapTestCase):
def testCacheMemberText(self):
Modified: trunk/mapserver/mapscript/python/tests/cases/styletest.py
===================================================================
--- trunk/mapserver/mapscript/python/tests/cases/styletest.py 2008-10-23 03:36:07 UTC (rev 7999)
+++ trunk/mapserver/mapscript/python/tests/cases/styletest.py 2008-10-24 15:42:15 UTC (rev 8000)
@@ -84,6 +84,13 @@
assert new_style.color.green == 2
assert new_style.color.blue == 3
+ def testStyleBinding(self):
+ """attribute binding can be set and get"""
+ new_style = mapscript.styleObj()
+ assert (not new_style.getBinding(mapscript.MS_STYLE_BINDING_COLOR))
+ new_style.setBinding(mapscript.MS_STYLE_BINDING_COLOR,"NEW_BINDING")
+ assert (new_style.getBinding(mapscript.MS_STYLE_BINDING_COLOR) == "NEW_BINDING")
+
def testAppendNewStyle(self):
"""a new style can be appended properly"""
p_layer = self.map.getLayerByName('POINT')
Modified: trunk/mapserver/mapscript/swiginc/label.i
===================================================================
--- trunk/mapserver/mapscript/swiginc/label.i 2008-10-23 03:36:07 UTC (rev 7999)
+++ trunk/mapserver/mapscript/swiginc/label.i 2008-10-24 15:42:15 UTC (rev 8000)
@@ -48,6 +48,13 @@
return MS_SUCCESS;
}
+ char *getBinding(int binding)
+ {
+ if(binding < 0 || binding >= MS_LABEL_BINDING_LENGTH) return NULL;
+
+ return self->bindings[binding].item;
+ }
+
int setBinding(int binding, char *item)
{
if(!item) return MS_FAILURE;
Modified: trunk/mapserver/mapscript/swiginc/style.i
===================================================================
--- trunk/mapserver/mapscript/swiginc/style.i 2008-10-23 03:36:07 UTC (rev 7999)
+++ trunk/mapserver/mapscript/swiginc/style.i 2008-10-24 15:42:15 UTC (rev 8000)
@@ -153,4 +153,11 @@
return MS_SUCCESS;
}
+
+ char *getBinding(int binding)
+ {
+ if(binding < 0 || binding >= MS_STYLE_BINDING_LENGTH) return NULL;
+
+ return self->bindings[binding].item;
+ }
}
More information about the mapserver-commits
mailing list