[mapserver-commits] r8420 - in trunk/mapserver: . mapscript/php3
svn at osgeo.org
svn at osgeo.org
Fri Jan 9 09:05:47 EST 2009
Author: aboudreault
Date: 2009-01-09 09:05:46 -0500 (Fri, 09 Jan 2009)
New Revision: 8420
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:
Added ms_newMapObjFromString mapObj constructor in PHP/Mapscript
Modified: trunk/mapserver/HISTORY.TXT
===================================================================
--- trunk/mapserver/HISTORY.TXT 2009-01-09 12:44:21 UTC (rev 8419)
+++ trunk/mapserver/HISTORY.TXT 2009-01-09 14:05:46 UTC (rev 8420)
@@ -12,6 +12,8 @@
Current Version (5.3-dev, SVN trunk):
------------------------------------
+- Added ms_newMapObjFromString mapObj constructor in PHP/Mapscript (#2399)
+
- Add support to compile mssql2008 when SDE or ORACLE is not compiled (#2851)
- Add support for creating debug builds for the plugins on Windows
Modified: trunk/mapserver/mapscript/php3/mapscript_i.c
===================================================================
--- trunk/mapserver/mapscript/php3/mapscript_i.c 2009-01-09 12:44:21 UTC (rev 8419)
+++ trunk/mapserver/mapscript/php3/mapscript_i.c 2009-01-09 14:05:46 UTC (rev 8420)
@@ -52,6 +52,15 @@
}
}
+mapObj *mapObj_newFromString(char *map_text, char *new_path) {
+
+ if(map_text && strlen(map_text))
+ return msLoadMapFromString(map_text, new_path);
+ else { /* create an empty map, no layers etc... */
+ return msNewMapObj();
+ }
+}
+
void mapObj_destroy(mapObj* self) {
msFreeMap(self);
}
Modified: trunk/mapserver/mapscript/php3/php_mapscript.c
===================================================================
--- trunk/mapserver/mapscript/php3/php_mapscript.c 2009-01-09 12:44:21 UTC (rev 8419)
+++ trunk/mapserver/mapscript/php3/php_mapscript.c 2009-01-09 14:05:46 UTC (rev 8420)
@@ -92,6 +92,7 @@
DLEXPORT void php3_ms_tokenizeMap(INTERNAL_FUNCTION_PARAMETERS);
DLEXPORT void php3_ms_map_new(INTERNAL_FUNCTION_PARAMETERS);
+DLEXPORT void php3_ms_map_new_from_string(INTERNAL_FUNCTION_PARAMETERS);
DLEXPORT void php3_ms_map_clone(INTERNAL_FUNCTION_PARAMETERS);
DLEXPORT void php3_ms_map_setProperty(INTERNAL_FUNCTION_PARAMETERS);
DLEXPORT void php3_ms_map_setProjection(INTERNAL_FUNCTION_PARAMETERS);
@@ -593,6 +594,7 @@
{"ms_getversion", php3_ms_getversion, NULL},
{"ms_getversionint",php3_ms_getversionint, NULL},
{"ms_newmapobj", php3_ms_map_new, NULL},
+ {"ms_newmapobjfromstring", php3_ms_map_new_from_string, NULL},
{"ms_newlayerobj", php3_ms_lyr_new, two_args_first_arg_force_ref},
{"ms_newclassobj", php3_ms_class_new, one_arg_force_ref},
{"ms_newpointobj", php3_ms_point_new, NULL},
@@ -1701,6 +1703,72 @@
/**********************************************************************
+ * ms_newMapObjFromString()
+ **********************************************************************/
+
+/* {{{ proto mapObj ms_newMapObjFromString(string mapfileString)
+ Returns a new object to deal with a MapServer map file. */
+
+DLEXPORT void php3_ms_map_new_from_string(INTERNAL_FUNCTION_PARAMETERS)
+{
+ pval *pMapText, *pNewPath;
+ mapObj *pNewMap = NULL;
+ int nArgs;
+ char *pszNewPath = NULL;
+ HashTable *list=NULL;
+
+#if defined(WIN32)
+ char szPath[MS_MAXPATHLEN], szMapText[MS_MAXPATHLEN];
+ char szNewPath[MS_MAXPATHLEN];
+#endif
+
+ nArgs = ARG_COUNT(ht);
+ if ((nArgs != 1 && nArgs != 2) ||
+ getParameters(ht, nArgs, &pMapText, &pNewPath) != SUCCESS)
+ {
+ WRONG_PARAM_COUNT;
+ }
+
+ convert_to_string(pMapText);
+
+ if (nArgs >= 2)
+ {
+ convert_to_string(pNewPath);
+ pszNewPath = pNewPath->value.str.val;
+ }
+
+ /* Attempt to open the MAP file
+ */
+
+#if defined(WIN32)
+
+ if (pszNewPath)
+ {
+ msBuildPath(szNewPath, NULL, pszNewPath);
+ pNewMap = mapObj_newFromString(szMapText, szNewPath);
+ }
+ else
+ pNewMap = mapObj_newFromString(szMapText, pszNewPath);
+
+#else
+ pNewMap = mapObj_newFromString(pMapText->value.str.val, pszNewPath);
+#endif
+ if (pNewMap == NULL)
+ {
+ _phpms_report_mapserver_error(E_WARNING);
+ php3_error(E_WARNING, "Failed to open map file %s",
+ pMapText->value.str.val);
+ RETURN_FALSE;
+ }
+
+ /* Return map object */
+ _phpms_build_map_object(pNewMap, list, return_value TSRMLS_CC);
+
+}
+/* }}} */
+
+
+/**********************************************************************
* map->clone()
**********************************************************************/
Modified: trunk/mapserver/mapscript/php3/php_mapscript.h
===================================================================
--- trunk/mapserver/mapscript/php3/php_mapscript.h 2009-01-09 12:44:21 UTC (rev 8419)
+++ trunk/mapserver/mapscript/php3/php_mapscript.h 2009-01-09 14:05:46 UTC (rev 8420)
@@ -59,6 +59,7 @@
*====================================================================*/
mapObj *mapObj_new(char *filename, char *new_path);
+mapObj *mapObj_newFromString(char *map_text, char *new_path);
void mapObj_destroy(mapObj* self);
mapObj *mapObj_clone(mapObj* self);
int mapObj_setRotation(mapObj* self, double rotation_angle );
More information about the mapserver-commits
mailing list