[mapserver-commits] r9942 - trunk/mapserver
svn at osgeo.org
svn at osgeo.org
Mon Mar 15 15:38:38 EDT 2010
Author: assefa
Date: 2010-03-15 15:38:38 -0400 (Mon, 15 Mar 2010)
New Revision: 9942
Modified:
trunk/mapserver/mapows.c
trunk/mapserver/mapows.h
trunk/mapserver/mapserv.c
trunk/mapserver/mapserv.h
trunk/mapserver/maptemplate.h
trunk/mapserver/mapwfs.c
trunk/mapserver/mapwms.c
Log:
Add support for mode=wfs (#2531)
Modified: trunk/mapserver/mapows.c
===================================================================
--- trunk/mapserver/mapows.c 2010-03-15 14:36:43 UTC (rev 9941)
+++ trunk/mapserver/mapows.c 2010-03-15 19:38:38 UTC (rev 9942)
@@ -29,6 +29,7 @@
#include "mapserver.h"
#include "maptime.h"
+#include "maptemplate.h"
#include <ctype.h> /* isalnum() */
#include <stdarg.h>
@@ -46,14 +47,19 @@
** request then MS_DONE is returned and MapServer is expected to process
** this as a regular MapServer (traditional CGI) request.
*/
-int msOWSDispatch(mapObj *map, cgiRequestObj *request, int force_ows_mode)
+int msOWSDispatch(mapObj *map, cgiRequestObj *request, int ows_mode)
{
int i, status = MS_DONE;
const char *service=NULL;
+ int force_ows_mode = 0;
+
if (!request)
return status;
+ if (ows_mode == OWS || ows_mode == WFS)
+ force_ows_mode = 1;
+
for( i=0; i<request->NumParams; i++ )
{
if(strcasecmp(request->ParamNames[i], "SERVICE") == 0)
@@ -64,7 +70,7 @@
/* Note: SERVICE param did not exist in WMS 1.0.0, it was added only in WMS 1.1.0,
* so we need to let msWMSDispatch check for known REQUESTs even if SERVICE is not set.
*/
- if ((status = msWMSDispatch(map, request)) != MS_DONE )
+ if ((status = msWMSDispatch(map, request, MS_FALSE)) != MS_DONE )
return status;
#else
if( service != NULL && strcasecmp(service,"WMS") == 0 )
@@ -77,7 +83,7 @@
/* Note: WFS supports POST requests, so the SERVICE param may only be in the post data
* and not be present in the GET URL
*/
- if ((status = msWFSDispatch(map, request)) != MS_DONE )
+ if ((status = msWFSDispatch(map, request, (ows_mode == WFS))) != MS_DONE )
return status;
#else
if( service != NULL && strcasecmp(service,"WFS") == 0 )
Modified: trunk/mapserver/mapows.h
===================================================================
--- trunk/mapserver/mapows.h 2010-03-15 14:36:43 UTC (rev 9941)
+++ trunk/mapserver/mapows.h 2010-03-15 19:38:38 UTC (rev 9942)
@@ -167,7 +167,7 @@
/*====================================================================
* mapows.c
*====================================================================*/
-MS_DLL_EXPORT int msOWSDispatch(mapObj *map, cgiRequestObj *request, int force_ows_mode);
+MS_DLL_EXPORT int msOWSDispatch(mapObj *map, cgiRequestObj *request, int ows_mode);
MS_DLL_EXPORT const char * msOWSLookupMetadata(hashTableObj *metadata,
const char *namespaces, const char *name);
@@ -410,7 +410,7 @@
/*====================================================================
* mapwms.c
*====================================================================*/
-int msWMSDispatch(mapObj *map, cgiRequestObj *req);
+int msWMSDispatch(mapObj *map, cgiRequestObj *req, int force_wms_mode);
MS_DLL_EXPORT int msWMSLoadGetMapParams(mapObj *map, int nVersion,
char **names, char **values, int numentries);
@@ -444,7 +444,7 @@
#define OWS_DEFAULT_SCHEMA 0 /* basically a GML 2.1 schema */
#define OWS_SFE_SCHEMA 1 /* GML for simple feature exchange (formerly GML3L0) */
-int msWFSDispatch(mapObj *map, cgiRequestObj *requestobj);
+MS_DLL_EXPORT int msWFSDispatch(mapObj *map, cgiRequestObj *requestobj, int force_wfs_mode);
void msWFSParseRequest(cgiRequestObj *, wfsParamsObj *);
wfsParamsObj *msWFSCreateParamsObj(void);
void msWFSFreeParamsObj(wfsParamsObj *wfsparams);
Modified: trunk/mapserver/mapserv.c
===================================================================
--- trunk/mapserver/mapserv.c 2010-03-15 14:36:43 UTC (rev 9941)
+++ trunk/mapserver/mapserv.c 2010-03-15 19:38:38 UTC (rev 9942)
@@ -1259,9 +1259,9 @@
** Start by calling the WMS/WFS/WCS Dispatchers. If they fail then we'll
** process this as a regular MapServer request.
*/
- if((mapserv->Mode == -1 || mapserv->Mode == OWS) &&
- (status = msOWSDispatch(mapserv->map, mapserv->request,
- (mapserv->Mode == OWS))) != MS_DONE ) {
+ if((mapserv->Mode == -1 || mapserv->Mode == OWS || mapserv->Mode == WFS) &&
+ (status = msOWSDispatch(mapserv->map, mapserv->request,
+ mapserv->Mode)) != MS_DONE ) {
/*
** OWSDispatch returned either MS_SUCCESS or MS_FAILURE
**
Modified: trunk/mapserver/mapserv.h
===================================================================
--- trunk/mapserver/mapserv.h 2010-03-15 14:36:43 UTC (rev 9941)
+++ trunk/mapserver/mapserv.h 2010-03-15 19:38:38 UTC (rev 9942)
@@ -57,13 +57,13 @@
/*
** Enumerated types, keep the query modes in sequence and at the end of the enumeration (mode enumeration is in maptemplate.h).
*/
-int numModes = 29;
-static char *modeStrings[29] = {"BROWSE","ZOOMIN","ZOOMOUT","MAP","LEGEND","LEGENDICON","REFERENCE","SCALEBAR","COORDINATE",
+int numModes = 30;
+static char *modeStrings[30] = {"BROWSE","ZOOMIN","ZOOMOUT","MAP","LEGEND","LEGENDICON","REFERENCE","SCALEBAR","COORDINATE",
"QUERY","QUERYMAP","NQUERY","NQUERYMAP",
"ITEMQUERY","ITEMQUERYMAP","ITEMNQUERY","ITEMNQUERYMAP",
"FEATUREQUERY","FEATUREQUERYMAP","FEATURENQUERY","FEATURENQUERYMAP",
"ITEMFEATUREQUERY","ITEMFEATUREQUERYMAP","ITEMFEATURENQUERY","ITEMFEATURENQUERYMAP",
- "INDEXQUERY","INDEXQUERYMAP","TILE","OWS"};
+ "INDEXQUERY","INDEXQUERYMAP","TILE","OWS", "WFS"};
/*
** Global variables
Modified: trunk/mapserver/maptemplate.h
===================================================================
--- trunk/mapserver/maptemplate.h 2010-03-15 14:36:43 UTC (rev 9941)
+++ trunk/mapserver/maptemplate.h 2010-03-15 19:38:38 UTC (rev 9942)
@@ -46,7 +46,7 @@
ITEMQUERY, ITEMQUERYMAP, ITEMNQUERY, ITEMNQUERYMAP,
FEATUREQUERY, FEATUREQUERYMAP, FEATURENQUERY, FEATURENQUERYMAP,
ITEMFEATUREQUERY, ITEMFEATUREQUERYMAP, ITEMFEATURENQUERY, ITEMFEATURENQUERYMAP,
- INDEXQUERY, INDEXQUERYMAP, TILE, OWS};
+ INDEXQUERY, INDEXQUERYMAP, TILE, OWS, WFS};
/* struct mapservObj
Modified: trunk/mapserver/mapwfs.c
===================================================================
--- trunk/mapserver/mapwfs.c 2010-03-15 14:36:43 UTC (rev 9941)
+++ trunk/mapserver/mapwfs.c 2010-03-15 19:38:38 UTC (rev 9942)
@@ -52,7 +52,7 @@
*/
if( version == NULL )
- version = "1.0.0";
+ version = "1.1.0";
if( msOWSParseVersionString(version) >= OWS_1_1_0 )
return msWFSException11( map, locator, code, version );
@@ -2059,7 +2059,7 @@
** is returned and MapServer is expected to process this as a regular
** MapServer request.
*/
-int msWFSDispatch(mapObj *map, cgiRequestObj *requestobj)
+int msWFSDispatch(mapObj *map, cgiRequestObj *requestobj, int force_wfs_mode)
{
#ifdef USE_WFS_SVR
int status;
@@ -2075,6 +2075,86 @@
/* into the paramsObj. */
msWFSParseRequest(requestobj, paramsObj);
+ if (force_wfs_mode)
+ {
+ /*request is always required*/
+ if (paramsObj->pszRequest==NULL || strlen(paramsObj->pszRequest)<=0)
+ {
+ msSetError(MS_WFSERR,
+ "Incomplete WFS request: REQUEST parameter missing",
+ "msWFSDispatch()");
+ returnvalue = msWFSException(map, "request", "MissingParameterValue", paramsObj->pszVersion);
+ msWFSFreeParamsObj(paramsObj);
+ free(paramsObj);
+ paramsObj = NULL;
+ return returnvalue;
+ }
+
+ /*version:
+ wfs 1.0 and 1.1.0 POST request: optional
+ wfs 1.0 and 1.1.0 GET request: optional for getcapabilities and required for describefeatute and getfeature
+ */
+ if (paramsObj->pszVersion == NULL && requestobj && requestobj->postrequest == MS_FALSE &&
+ strcasecmp(paramsObj->pszRequest, "GetCapabilities") != 0)
+ {
+ msSetError(MS_WFSERR,
+ "Invalid WFS request: VERSION parameter missing",
+ "msWFSDispatch()");
+ returnvalue = msWFSException(map, "version", "MissingParameterValue", paramsObj->pszVersion);
+ msWFSFreeParamsObj(paramsObj);
+ free(paramsObj);
+ paramsObj = NULL;
+ return returnvalue;
+ }
+
+ if (paramsObj->pszVersion == NULL || strlen(paramsObj->pszVersion) <=0)
+ paramsObj->pszVersion = strdup("1.1.0");
+
+ /*service
+ wfs 1.0 and 1.1.0 GET: required and should be set to WFS
+ wfs 1.0 POST: required
+ wfs 1.1.1 POST: optional
+ */
+ if ((paramsObj->pszService == NULL || strlen(paramsObj->pszService) == 0) &&
+ ((requestobj && requestobj->postrequest == MS_FALSE) || strcasecmp(paramsObj->pszVersion,"1.0") ==0))
+ {
+ msSetError(MS_WFSERR,
+ "Invalid WFS request: Missing SERVICE parameter",
+ "msWFSDispatch()");
+ returnvalue = msWFSException(map, "service", "MissingParameterValue", paramsObj->pszVersion);
+ msWFSFreeParamsObj(paramsObj);
+ free(paramsObj);
+ paramsObj = NULL;
+ return returnvalue;
+ }
+
+ if (paramsObj->pszService == NULL || strlen(paramsObj->pszService) == 0)
+ paramsObj->pszService = strdup("WFS");
+
+ if (paramsObj->pszService!=NULL && strcasecmp(paramsObj->pszService, "WFS") != 0)
+ {
+ msSetError(MS_WFSERR,
+ "Invalid WFS request: SERVICE parameter must be set to WFS",
+ "msWFSDispatch()");
+ returnvalue = msWFSException(map, "service", "InvalidParameterValue", paramsObj->pszVersion);
+ msWFSFreeParamsObj(paramsObj);
+ free(paramsObj);
+ paramsObj = NULL;
+ return returnvalue;
+ }
+ if (paramsObj->pszService == NULL && strcasecmp(paramsObj->pszVersion, "1.0") == 0)
+ {
+ msSetError(MS_WFSERR,
+ "Invalid WFS request: SERVICE parameter missing",
+ "msWFSDispatch()");
+ returnvalue = msWFSException(map, "service", "MissingParameterValue", paramsObj->pszVersion);
+ msWFSFreeParamsObj(paramsObj);
+ free(paramsObj);
+ paramsObj = NULL;
+ return returnvalue;
+ }
+
+ }
/* If SERVICE is specified then it MUST be "WFS" */
if (paramsObj->pszService != NULL &&
strcasecmp(paramsObj->pszService, "WFS") != 0)
Modified: trunk/mapserver/mapwms.c
===================================================================
--- trunk/mapserver/mapwms.c 2010-03-15 14:36:43 UTC (rev 9941)
+++ trunk/mapserver/mapwms.c 2010-03-15 19:38:38 UTC (rev 9942)
@@ -3770,7 +3770,7 @@
** is returned and MapServer is expected to process this as a regular
** MapServer request.
*/
-int msWMSDispatch(mapObj *map, cgiRequestObj *req)
+int msWMSDispatch(mapObj *map, cgiRequestObj *req, int force_wms_mode)
{
#ifdef USE_WMS_SVR
int i, status, nVersion=OWS_VERSION_NOTSET;
@@ -3822,8 +3822,13 @@
strcasecmp(request, "GetCapabilities") == 0) &&
(nVersion >= OWS_1_0_7 || nVersion == OWS_VERSION_NOTSET))
{
- msSetError(MS_WMSERR, "Required SERVICE parameter missing.", "msWMSDispatch");
- return msWMSException(map, nVersion, "ServiceNotDefined");
+ if (force_wms_mode)
+ {
+ msSetError(MS_WMSERR, "Required SERVICE parameter missing.", "msWMSDispatch");
+ return msWMSException(map, nVersion, "ServiceNotDefined");
+ }
+ else
+ return MS_DONE;
}
/*
More information about the mapserver-commits
mailing list