Permalink
Browse files

Implement MS RFC 88: Saving MapServer Objects to Strings (#4563)

  • Loading branch information...
1 parent 3da40ab commit ac1c47a368e0c80620b3d430daae75faa4e77957 @szekerest szekerest committed Mar 18, 2013
View
Oops, something went wrong.
View
@@ -365,6 +365,33 @@ PHP_METHOD(classObj, updateFromString)
}
/* }}} */
+/* {{{ proto string convertToString()
+ Convert the class object to string. */
+PHP_METHOD(classObj, convertToString)
+{
+ zval *zobj = getThis();
+ php_class_object *php_class;
+ char *value = NULL;
+
+ PHP_MAPSCRIPT_ERROR_HANDLING(TRUE);
+ if (zend_parse_parameters_none() == FAILURE) {
+ PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
+ return;
+ }
+ PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
+
+ php_class = (php_class_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+
+ value = classObj_convertToString(php_class->class);
+
+ if (value == NULL)
+ RETURN_STRING("", 1);
+
+ RETVAL_STRING(value, 1);
+ free(value);
+}
+/* }}} */
+
/* {{{ proto int setExpression(string exression)
Set the expression string for a class object. */
PHP_METHOD(classObj, setExpression)
@@ -855,6 +882,7 @@ zend_function_entry class_functions[] = {
PHP_ME(classObj, removeLabel, class_removeLabel_args, ZEND_ACC_PUBLIC)
PHP_ME(classObj, getLabel, class_getLabel_args, ZEND_ACC_PUBLIC)
PHP_ME(classObj, updateFromString, class_updateFromString_args, ZEND_ACC_PUBLIC)
+ PHP_ME(classObj, convertToString, NULL, ZEND_ACC_PUBLIC)
PHP_ME(classObj, setExpression, class_setExpression_args, ZEND_ACC_PUBLIC)
PHP_ME(classObj, getExpressionString, NULL, ZEND_ACC_PUBLIC)
PHP_ME(classObj, setText, class_setText_args, ZEND_ACC_PUBLIC)
@@ -146,6 +146,33 @@ PHP_METHOD(clusterObj, updateFromString)
}
/* }}} */
+/* {{{ proto string convertToString()
+ Convert the cluster object to string. */
+PHP_METHOD(clusterObj, convertToString)
+{
+ zval *zobj = getThis();
+ php_cluster_object *php_cluster;
+ char *value = NULL;
+
+ PHP_MAPSCRIPT_ERROR_HANDLING(TRUE);
+ if (zend_parse_parameters_none() == FAILURE) {
+ PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
+ return;
+ }
+ PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
+
+ php_cluster = (php_cluster_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+
+ value = classObj_convertToString(php_cluster->cluster);
+
+ if (value == NULL)
+ RETURN_STRING("", 1);
+
+ RETVAL_STRING(value, 1);
+ free(value);
+}
+/* }}} */
+
/* {{{ proto int setGroup(string group)
Set the group expression string. Returns MS_SUCCESS/MS_FAILURE */
PHP_METHOD(clusterObj, setGroup)
@@ -263,6 +290,7 @@ zend_function_entry cluster_functions[] = {
PHP_ME(clusterObj, __get, cluster___get_args, ZEND_ACC_PUBLIC)
PHP_ME(clusterObj, __set, cluster___set_args, ZEND_ACC_PUBLIC)
PHP_ME(clusterObj, updateFromString, cluster_updateFromString_args, ZEND_ACC_PUBLIC)
+ PHP_ME(clusterObj, convertToString, NULL, ZEND_ACC_PUBLIC)
PHP_ME(clusterObj, setGroup, cluster_setGroup_args, ZEND_ACC_PUBLIC)
PHP_ME(clusterObj, getGroupString, NULL, ZEND_ACC_PUBLIC)
PHP_ME(clusterObj, setFilter, cluster_setFilter_args, ZEND_ACC_PUBLIC)
View
@@ -254,6 +254,33 @@ PHP_METHOD(labelObj, updateFromString)
}
/* }}} */
+/* {{{ proto string convertToString()
+ Convert the label object to string. */
+PHP_METHOD(labelObj, convertToString)
+{
+ zval *zobj = getThis();
+ php_label_object *php_label;
+ char *value = NULL;
+
+ PHP_MAPSCRIPT_ERROR_HANDLING(TRUE);
+ if (zend_parse_parameters_none() == FAILURE) {
+ PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
+ return;
+ }
+ PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
+
+ php_label = (php_label_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+
+ value = labelObj_convertToString(php_label->label);
+
+ if (value == NULL)
+ RETURN_STRING("", 1);
+
+ RETVAL_STRING(value, 1);
+ free(value);
+}
+/* }}} */
+
/* {{{ proto int label.setbinding(const bindingid, string value)
Set the attribute binding for a specfiled label property. Returns MS_SUCCESS on success. */
PHP_METHOD(labelObj, setBinding)
@@ -552,6 +579,7 @@ zend_function_entry label_functions[] = {
PHP_ME(labelObj, __set, label___set_args, ZEND_ACC_PUBLIC)
PHP_MALIAS(labelObj, set, __set, NULL, ZEND_ACC_PUBLIC)
PHP_ME(labelObj, updateFromString, label_updateFromString_args, ZEND_ACC_PUBLIC)
+ PHP_ME(labelObj, convertToString, NULL, ZEND_ACC_PUBLIC)
PHP_ME(labelObj, setBinding, label_setBinding_args, ZEND_ACC_PUBLIC)
PHP_ME(labelObj, getBinding, label_getBinding_args, ZEND_ACC_PUBLIC)
PHP_ME(labelObj, removeBinding, label_removeBinding_args, ZEND_ACC_PUBLIC)
View
@@ -773,6 +773,33 @@ PHP_METHOD(layerObj, updateFromString)
}
/* }}} */
+/* {{{ proto string convertToString()
+ Convert the layer object to string. */
+PHP_METHOD(layerObj, convertToString)
+{
+ zval *zobj = getThis();
+ php_layer_object *php_layer;
+ char *value = NULL;
+
+ PHP_MAPSCRIPT_ERROR_HANDLING(TRUE);
+ if (zend_parse_parameters_none() == 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);
+
+ value = layerObj_convertToString(php_layer->layer);
+
+ if (value == NULL)
+ RETURN_STRING("", 1);
+
+ RETVAL_STRING(value, 1);
+ free(value);
+}
+/* }}} */
+
/* {{{ proto int layer.getClass(int i)
Returns a classObj from the layer given an index value (0=first class) */
PHP_METHOD(layerObj, getClass)
@@ -2110,6 +2137,7 @@ zend_function_entry layer_functions[] = {
PHP_ME(layerObj, draw, layer_draw_args, ZEND_ACC_PUBLIC)
PHP_ME(layerObj, drawQuery, layer_drawQuery_args, ZEND_ACC_PUBLIC)
PHP_ME(layerObj, updateFromString, layer_updateFromString_args, ZEND_ACC_PUBLIC)
+ PHP_ME(layerObj, convertToString, NULL, 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)
@@ -157,6 +157,33 @@ PHP_METHOD(legendObj, updateFromString)
}
/* }}} */
+/* {{{ proto string convertToString()
+ Convert the legend object to string. */
+PHP_METHOD(legendObj, convertToString)
+{
+ zval *zobj = getThis();
+ php_legend_object *php_legend;
+ char *value = NULL;
+
+ PHP_MAPSCRIPT_ERROR_HANDLING(TRUE);
+ if (zend_parse_parameters_none() == FAILURE) {
+ PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
+ return;
+ }
+ PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
+
+ php_legend = (php_legend_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+
+ value = legendObj_convertToString(php_legend->legend);
+
+ if (value == NULL)
+ RETURN_STRING("", 1);
+
+ RETVAL_STRING(value, 1);
+ free(value);
+}
+/* }}} */
+
/* {{{ proto int legend.free()
Free the object */
PHP_METHOD(legendObj, free)
@@ -184,6 +211,7 @@ zend_function_entry legend_functions[] = {
PHP_ME(legendObj, __get, legend___get_args, ZEND_ACC_PUBLIC)
PHP_ME(legendObj, __set, legend___set_args, ZEND_ACC_PUBLIC)
PHP_MALIAS(legendObj, set, __set, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(legendObj, convertToString, NULL, ZEND_ACC_PUBLIC)
PHP_ME(legendObj, updateFromString, legend_updateFromString_args, ZEND_ACC_PUBLIC) {
NULL, NULL, NULL
}
View
@@ -3295,6 +3295,33 @@ PHP_METHOD(mapObj, getLabel)
}
/* }}} */
+/* {{{ proto string convertToString()
+ Convert the map object to string. */
+PHP_METHOD(mapObj, convertToString)
+{
+ zval *zobj = getThis();
+ php_map_object *php_map;
+ char *value = NULL;
+
+ PHP_MAPSCRIPT_ERROR_HANDLING(TRUE);
+ if (zend_parse_parameters_none() == FAILURE) {
+ PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
+ return;
+ }
+ PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
+
+ php_map = (php_map_object *) zend_object_store_get_object(zobj TSRMLS_CC);
+
+ value = mapObj_convertToString(php_map->map);
+
+ if (value == NULL)
+ RETURN_STRING("", 1);
+
+ RETVAL_STRING(value, 1);
+ free(value);
+}
+/* }}} */
+
/************************************************************************/
/* php3_ms_map_getLatLongExtent() */
/* */
@@ -3448,6 +3475,7 @@ zend_function_entry map_functions[] = {
PHP_ME(mapObj, insertLayer, map_insertLayer_args, ZEND_ACC_PUBLIC)
PHP_ME(mapObj, removeLayer, map_removeLayer_args, ZEND_ACC_PUBLIC)
PHP_ME(mapObj, getLabel, map_getLabel_args, ZEND_ACC_PUBLIC)
+ PHP_ME(mapObj, convertToString, NULL, ZEND_ACC_PUBLIC)
PHP_ME(mapObj, getLatLongExtent, NULL, ZEND_ACC_PUBLIC)
PHP_ME(mapObj, free, NULL, ZEND_ACC_PUBLIC) {
NULL, NULL, NULL
@@ -459,6 +459,11 @@ int mapObj_scaleExtent(mapObj *self, double zoomfactor, double minscaledenom,
return msMapScaleExtent(self, zoomfactor, minscaledenom, maxscaledenom);
}
+char *mapObj_convertToString(mapObj *self)
+{
+ return msWriteMapToString(self);
+}
+
/**********************************************************************
* class extensions for layerObj, always within the context of a map
**********************************************************************/
@@ -508,6 +513,11 @@ int layerObj_updateFromString(layerObj *self, char *snippet)
return msUpdateLayerFromString(self, snippet, MS_FALSE);
}
+char *layerObj_convertToString(layerObj *self)
+{
+ return msWriteLayerToString(self);
+}
+
int layerObj_open(layerObj *self)
{
return msLayerOpen(self);
@@ -894,6 +904,11 @@ int labelObj_updateFromString(labelObj *self, char *snippet)
return msUpdateLabelFromString(self, snippet);
}
+char *labelObj_convertToString(labelObj *self)
+{
+ return msWriteLabelToString(self);
+}
+
int labelObj_moveStyleUp(labelObj *self, int index)
{
return msMoveLabelStyleUp(self, index);
@@ -917,6 +932,11 @@ int legendObj_updateFromString(legendObj *self, char *snippet)
return msUpdateLegendFromString(self, snippet, MS_FALSE);
}
+char *legendObj_convertToString(legendObj *self)
+{
+ return msWriteLegendToString(self);
+}
+
/**********************************************************************
* class extensions for queryMapObj
**********************************************************************/
@@ -925,6 +945,11 @@ int queryMapObj_updateFromString(queryMapObj *self, char *snippet)
return msUpdateQueryMapFromString(self, snippet, MS_FALSE);
}
+char *queryMapObj_convertToString(queryMapObj *self)
+{
+ return msWriteQueryMapToString(self);
+}
+
/**********************************************************************
* class extensions for referenceMapObj
**********************************************************************/
@@ -934,6 +959,11 @@ int referenceMapObj_updateFromString(referenceMapObj *self, char *snippet)
return msUpdateReferenceMapFromString(self, snippet, MS_FALSE);
}
+char *referenceMapObj_convertToString(referenceMapObj *self)
+{
+ return msWriteReferenceMapToString(self);
+}
+
/**********************************************************************
* class extensions for scaleBarObj
**********************************************************************/
@@ -943,6 +973,11 @@ int scalebarObj_updateFromString(scalebarObj *self, char *snippet)
return msUpdateScalebarFromString(self, snippet, MS_FALSE);
}
+char *scalebarObj_convertToString(scalebarObj *self)
+{
+ return msWriteScalebarToString(self);
+}
+
/**********************************************************************
* class extensions for webObj
**********************************************************************/
@@ -952,6 +987,11 @@ int webObj_updateFromString(webObj *self, char *snippet)
return msUpdateWebFromString(self, snippet, MS_FALSE);
}
+char *webObj_convertToString(webObj *self)
+{
+ return msWriteWebToString(self);
+}
+
/**********************************************************************
* class extensions for classObj, always within the context of a layer
**********************************************************************/
@@ -999,6 +1039,11 @@ int classObj_updateFromString(classObj *self, char *snippet)
return msUpdateClassFromString(self, snippet, MS_FALSE);
}
+char *classObj_convertToString(classObj *self)
+{
+ return msWriteClassToString(self);
+}
+
void classObj_destroy(classObj *self)
{
return; /* do nothing, map deconstrutor takes care of it all */
@@ -1698,6 +1743,11 @@ int styleObj_updateFromString(styleObj *self, char *snippet)
return msUpdateStyleFromString(self, snippet, MS_FALSE);
}
+char *styleObj_convertToString(styleObj *self)
+{
+ return msWriteStyleToString(self);
+}
+
int styleObj_setSymbolByName(styleObj *self, mapObj *map, char* pszSymbolName)
{
self->symbol = msGetSymbolIndex(&map->symbolset, pszSymbolName, MS_TRUE);
@@ -1874,6 +1924,11 @@ int clusterObj_updateFromString(clusterObj *self, char *snippet)
return msUpdateClusterFromString(self, snippet);
}
+char *clusterObj_convertToString(clusterObj *self)
+{
+ return msWriteClusterToString(self);
+}
+
int clusterObj_setGroup(clusterObj *self, char *string)
{
if (!string || strlen(string) == 0) {
Oops, something went wrong.

0 comments on commit ac1c47a

Please sign in to comment.