[mapguide-commits] r5182 - in trunk/MgDev: Server/src/Wfs
Web/src/HttpHandler
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Thu Sep 23 05:13:47 EDT 2010
Author: liuar
Date: 2010-09-23 09:13:47 +0000 (Thu, 23 Sep 2010)
New Revision: 5182
Modified:
trunk/MgDev/Server/src/Wfs/1.1.0.xml.awd
trunk/MgDev/Server/src/Wfs/OgcWfsService.config.awd
trunk/MgDev/Web/src/HttpHandler/HttpWfsDescribeFeatureType.cpp
trunk/MgDev/Web/src/HttpHandler/HttpWfsGetFeature.cpp
trunk/MgDev/Web/src/HttpHandler/OgcWfsServer.cpp
trunk/MgDev/Web/src/HttpHandler/OgcWfsServer.h
Log:
ticket #1421 OGC WFS 1.1.0 Support
8. Test wfs:wfs-1.1.0-Basic-DescribeFeatureType-tc4.1 (s0001/d1e35137_1/d1e740_1/d1e25192_1/d1e3796_1)
Assertion: The following query parameters are required for all KVP-encoded service requests except !GetCapabilities: service, request, version.
For !DescribeFeatureType requests, if service or version parameter is not specified, MapGuide should response a WFS exception
9. Test wfs:wfs-1.1.0-Basic-GetFeature-tc23.3 (s0001/d1e35137_1/d1e740_1/d1e25217_1/d1e6193_1)
Assertion: The following query parameters are required for all KVP-encoded service requests except !GetCapabilities: service, request, version.
For !GetFeature requests, if service or version parameter is not specified, MapGuide should response a WFS exception
10. In the latest OGC CITE test engine, the default SRS for WFS should be urn:ogc:def:crs:EPSG::4326.
Modified: trunk/MgDev/Server/src/Wfs/1.1.0.xml.awd
===================================================================
--- trunk/MgDev/Server/src/Wfs/1.1.0.xml.awd 2010-09-23 03:48:27 UTC (rev 5181)
+++ trunk/MgDev/Server/src/Wfs/1.1.0.xml.awd 2010-09-23 09:13:47 UTC (rev 5182)
@@ -73,7 +73,7 @@
<Define item="Feature.namespace">http://fdo.osgeo.org/schemas</Define>
<Define item="Feature.Abstract">Abstract for this layer</Define>
<Define item="Feature.KeywordList"></Define>
- <Define item="Feature.DefaultSRS">urn:x-ogc:def:crs:EPSG:4326</Define>
+ <Define item="Feature.DefaultSRS">urn:ogc:def:crs:EPSG::4326</Define>
<!--Define item="Feature.OtherSRS"></Define-->
<Define item="Feature.Bounds.north">90</Define>
<Define item="Feature.Bounds.south">-90</Define>
Modified: trunk/MgDev/Server/src/Wfs/OgcWfsService.config.awd
===================================================================
--- trunk/MgDev/Server/src/Wfs/OgcWfsService.config.awd 2010-09-23 03:48:27 UTC (rev 5181)
+++ trunk/MgDev/Server/src/Wfs/OgcWfsService.config.awd 2010-09-23 09:13:47 UTC (rev 5182)
@@ -134,7 +134,9 @@
<!-- These are the supported DescribeFeatureType formats
Specific version templates can override these -->
<Define item="Formats.DescribeFeatureType">
+ <item>GML2</item>
<item>text/xml; subtype=gml/2.1.2</item>
+ <item>GML3</item>
<item>text/xml; subtype=gml/3.1.1</item>
</Define>
@@ -152,7 +154,9 @@
<!-- These are the supported GetFeature formats
Specific version templates can override these -->
<Define item="Formats.GetFeature">
+ <item>GML2</item>
<item>text/xml; subtype=gml/2.1.2</item>
+ <item>GML3</item>
<item>text/xml; subtype=gml/3.1.1</item>
</Define>
@@ -261,6 +265,15 @@
* &Enum.item;
</Define>
+ <!-- This definition allows a site to override the behavior of -->
+ <!-- the SRS= parameter of requests. -->
+ <!-- Add translate elements here to map any particularly -->
+ <!-- troublesome SRS to some appropriate WKT. -->
+ <Define item="SRS.WKT.map">
+ <translate from="urn:ogc:def:crs:EPSG::4326">GEOGCS["LL84",DATUM["WGS84",SPHEROID["WGS84",6378137.000,298.25722293]],PRIMEM["Greenwich",0],UNIT["Degree",0.01745329251994]]</translate>
+ <translate from="CRS:84">GEOGCS["LL84",DATUM["WGS84",SPHEROID["WGS84",6378137.000,298.25722293]],PRIMEM["Greenwich",0],UNIT["Degree",0.01745329251994]]</translate>
+ </Define>
+
</Definitions>
Modified: trunk/MgDev/Web/src/HttpHandler/HttpWfsDescribeFeatureType.cpp
===================================================================
--- trunk/MgDev/Web/src/HttpHandler/HttpWfsDescribeFeatureType.cpp 2010-09-23 03:48:27 UTC (rev 5181)
+++ trunk/MgDev/Web/src/HttpHandler/HttpWfsDescribeFeatureType.cpp 2010-09-23 09:13:47 UTC (rev 5182)
@@ -71,6 +71,17 @@
// Instance a server-lette
MgOgcWfsServer Wfs(Parms,Out);
+ // In order to validate request we have to invoke the ProcessRequest
+ if(!Wfs.ProcessRequest(this))
+ {
+ // Obtain the response byte reader
+ Ptr<MgByteReader> errorResponse = Out.Stream().GetReader();
+
+ // Set the result
+ hResult->SetResultObject(errorResponse, errorResponse->GetMimeType());
+ return;
+ }
+
// Determine required feature types
CPSZ pszFeatureTypes = Wfs.RequestParameter(MgHttpResourceStrings::reqWfsTypeName.c_str());
STRING sFeatureTypes = pszFeatureTypes? pszFeatureTypes : _("");
Modified: trunk/MgDev/Web/src/HttpHandler/HttpWfsGetFeature.cpp
===================================================================
--- trunk/MgDev/Web/src/HttpHandler/HttpWfsGetFeature.cpp 2010-09-23 03:48:27 UTC (rev 5181)
+++ trunk/MgDev/Web/src/HttpHandler/HttpWfsGetFeature.cpp 2010-09-23 09:13:47 UTC (rev 5182)
@@ -76,17 +76,19 @@
MG_HTTP_HANDLER_TRY()
+ Ptr<MgHttpRequestParam> origReqParams = m_hRequest->GetRequestParam();
+ // Comment out to pass the OGC CITE test
+ // We should find a proper way to handle POST requests rather than hard code.
// Make sure the REQUEST and SERVICE parameters are set, in case this came from
// a POST request.
- Ptr<MgHttpRequestParam> origReqParams = m_hRequest->GetRequestParam();
- if(!origReqParams->ContainsParameter(MgHttpResourceStrings::reqWmsRequest))
- {
- origReqParams->AddParameter(MgHttpResourceStrings::reqWmsRequest, L"GetFeature"); //NOXLATE
- }
- if(!origReqParams->ContainsParameter(MgHttpResourceStrings::reqWmsService))
- {
- origReqParams->AddParameter(MgHttpResourceStrings::reqWmsService, L"WFS"); //NOXLATE
- }
+ //if(!origReqParams->ContainsParameter(MgHttpResourceStrings::reqWmsRequest))
+ //{
+ // origReqParams->AddParameter(MgHttpResourceStrings::reqWmsRequest, L"GetFeature"); //NOXLATE
+ //}
+ //if(!origReqParams->ContainsParameter(MgHttpResourceStrings::reqWmsService))
+ //{
+ // origReqParams->AddParameter(MgHttpResourceStrings::reqWmsService, L"WFS"); //NOXLATE
+ //}
MgHttpRequestParameters requestParams(origReqParams);
MgHttpResponseStream responseStream;
@@ -154,7 +156,7 @@
if(sOutputFormat.empty())
{
// get the default output format
- sOutputFormat = wfsServer->GetDefaultOutputFormat(sVersion);
+ sOutputFormat = wfsServer->GetDefaultGetFeatureOutputFormat(sVersion);
}
for(int i = 0; i < featureTypeList->GetCount(); i++)
Modified: trunk/MgDev/Web/src/HttpHandler/OgcWfsServer.cpp
===================================================================
--- trunk/MgDev/Web/src/HttpHandler/OgcWfsServer.cpp 2010-09-23 03:48:27 UTC (rev 5181)
+++ trunk/MgDev/Web/src/HttpHandler/OgcWfsServer.cpp 2010-09-23 09:13:47 UTC (rev 5182)
@@ -26,7 +26,8 @@
CPSZ kpszQueryValueDescribeFeatureType = _("DescribeFeatureType");
CPSZ kpszQueryStringOutputFormat = _("OutputFormat");
-CPSZ kpszQueryStringOutputFormatDefault = _("Formats.DescribeFeatureType.default");
+CPSZ kpszQueryStringDescribeFeatureTypeOutputFormatDefault_1_0_0 = _("Formats.DescribeFeatureType.default.1.0.0");
+CPSZ kpszQueryStringDescribeFeatureTypeOutputFormatDefault_1_1_0 = _("Formats.DescribeFeatureType.default.1.1.0");
CPSZ kpszPiEnumFeatureTypes = _("EnumFeatureTypes");
CPSZ kpszPiEnumFeatures = _("EnumFeatures");
@@ -56,6 +57,7 @@
// Localize
CPSZ kpszExceptionMessageMissingServiceWfs = _("Expected required SERVICE=WFS argument."); // Localize
CPSZ kpszExceptionMessageWfsMissingRequest = _("Expected required REQUEST= argument."); // Localize
+CPSZ kpszExceptionMessageWfsMissingVersion = _("Expected required VERSION= argument."); // Localize
CPSZ kpszExceptionMessageWfsUnknownRequest = _("Expected valid REQUEST= argument, such as GetCapabilities. (Instead, found request='&Request.request;'.)"); // Localize
CPSZ kpszExceptionMessageUnknownOutputFormat = _("Expected valid outputFormat argument, as enumerated by GetCapabilities. (Instead, found outputFormat='&Request.OutputFormat;'.)"); // Localize
CPSZ kpszExceptionMessageUnknownTypeName = _("Expected valid typeName argument, as enumerated by GetCapabilities. (Instead, found typeName='&Request.TypeName;'.)"); // Localize
@@ -164,13 +166,12 @@
case WfsGetCapabilitiesType:
{
// Currently no validation is carried out
- //bValid = ValidateGetCapabilitiesParameters();
+ bValid = ValidateGetCapabilitiesRequest();
break;
}
case WfsDescribeFeatureTypeType:
{
- // Currently no validation is carried out
- //bValid = ValidateDescribeFeatureTypeParameters();
+ bValid = ValidateDescribeFeatureTypeRequest();
break;
}
case WfsGetFeatureType:
@@ -187,45 +188,6 @@
}
}
- if(bValid)
- {
- // Check that we have a acceptVersions parameter
- CPSZ pszAcceptVersions = RequestParameter(kpszQueryStringAcceptVersions);
- if(pszAcceptVersions != NULL)
- {
- STRING sAcceptVersions(pszAcceptVersions);
- CPSZ pszSupportedVersions = Definition(kpszDictionarySupportedVersions);
- // Pass out a NULL, which caller must use to tickle an exception.
- if(pszSupportedVersions == NULL)
- return false;
-
- MgXmlParser SupportedVersions(pszSupportedVersions);
-
- STRING sVersion;
- bool bSupported = false;
- while(SupportedVersions.Next()) {
- if(SupportedVersions.Current().Type() == keBeginElement)
- {
- MgXmlBeginElement& Begin = (MgXmlBeginElement&)SupportedVersions.Current();
- if(Begin.Name() == kpszElementVersion && Begin.GetAttribute(kpszAttributeNumber,sVersion))
- {
- if(sAcceptVersions.find(sVersion) != STRING::npos)
- {
- bSupported = true;
- }
- }
- }
- }
- if(!bSupported)
- {
- ServiceExceptionReportResponse(MgOgcWfsException(MgOgcWfsException::kpszVersionNegotiationFailed,
- kpszExceptionMessageWfsVersionNegotiationFailed,
- kpszQueryStringVersion));
- bValid = false;
- }
- }
- }
-
return bValid;
}
@@ -272,8 +234,72 @@
sMimeType = ms_sExceptionMimeType;
}
+bool MgOgcWfsServer::ValidateGetCapabilitiesRequest()
+{
+ // Check that we have a acceptVersions parameter
+ CPSZ pszAcceptVersions = RequestParameter(kpszQueryStringAcceptVersions);
+ if(pszAcceptVersions != NULL)
+ {
+ STRING sAcceptVersions(pszAcceptVersions);
+ CPSZ pszSupportedVersions = Definition(kpszDictionarySupportedVersions);
+ // Pass out a NULL, which caller must use to tickle an exception.
+ if(pszSupportedVersions == NULL)
+ return false;
+
+ MgXmlParser SupportedVersions(pszSupportedVersions);
+
+ STRING sVersion;
+ bool bSupported = false;
+ while(SupportedVersions.Next())
+ {
+ if(SupportedVersions.Current().Type() == keBeginElement)
+ {
+ MgXmlBeginElement& Begin = (MgXmlBeginElement&)SupportedVersions.Current();
+ if(Begin.Name() == kpszElementVersion && Begin.GetAttribute(kpszAttributeNumber,sVersion))
+ {
+ if(sAcceptVersions.find(sVersion) != STRING::npos)
+ {
+ return true;
+ }
+ }
+ }
+ }
+ if(!bSupported)
+ {
+ ServiceExceptionReportResponse(MgOgcWfsException(MgOgcWfsException::kpszVersionNegotiationFailed,
+ kpszExceptionMessageWfsVersionNegotiationFailed,
+ kpszQueryStringVersion));
+ return false;
+ }
+ }
+
+ return true;
+}
+bool MgOgcWfsServer::ValidateDescribeFeatureTypeRequest()
+{
+ CPSZ pVersion = RequestParameter(kpszQueryStringVersion);
+ if(pVersion == NULL)
+ {
+ ServiceExceptionReportResponse(MgOgcWfsException(MgOgcWfsException::kpszMissingRequestParameter,
+ kpszExceptionMessageWfsMissingVersion,
+ kpszQueryStringVersion));
+ return false;
+ }
+
+ return true;
+}
+
bool MgOgcWfsServer::ValidateGetFeatureRequest()
{
+ CPSZ pVersion = RequestParameter(kpszQueryStringVersion);
+ if(pVersion == NULL)
+ {
+ ServiceExceptionReportResponse(MgOgcWfsException(MgOgcWfsException::kpszMissingRequestParameter,
+ kpszExceptionMessageWfsMissingVersion,
+ kpszQueryStringVersion));
+ return false;
+ }
+
if(m_pGetFeatureParams == NULL)
{
// The request params are missing
@@ -306,7 +332,7 @@
if(pszFormat == NULL)
{
CPSZ pszVersion = RequestParameter(MgHttpResourceStrings::reqWfsVersion.c_str());
- sOutputFormat = this->GetDefaultOutputFormat(pszVersion);
+ sOutputFormat = this->GetDefaultGetFeatureOutputFormat(pszVersion);
pszFormat = sOutputFormat.c_str();
}
// Generate a response to the GetFeature request
@@ -358,8 +384,14 @@
{
// See what format they requested the GetCapy response in...
CPSZ pszFormat = RequestParameter(kpszQueryStringOutputFormat);
+ STRING sOutputFormat;
+
if(pszFormat == NULL)
- pszFormat = this->Definition(kpszQueryStringOutputFormatDefault);
+ {
+ CPSZ pszVersion = RequestParameter(MgHttpResourceStrings::reqWfsVersion.c_str());
+ sOutputFormat = this->GetDefaultDescribeFeatureTypeOutputFormat(pszVersion);
+ pszFormat = sOutputFormat.c_str();
+ }
if(pszFormat != NULL)
if(GenerateResponse(kpszQueryValueDescribeFeatureType,pszFormat))
@@ -526,11 +558,26 @@
}
}
-// Help method to get the default output format
-STRING MgOgcWfsServer::GetDefaultOutputFormat(CREFSTRING sVersion)
+// Help method to get the default DescribeFeatureType output format
+STRING MgOgcWfsServer::GetDefaultDescribeFeatureTypeOutputFormat(CREFSTRING sVersion)
{
if(_("1.0.0") == sVersion)
{
+ CPSZ psz = this->Definition(kpszQueryStringDescribeFeatureTypeOutputFormatDefault_1_0_0);
+ return STRING(psz? psz : _(""));
+ }
+ else
+ {
+ CPSZ psz = this->Definition(kpszQueryStringDescribeFeatureTypeOutputFormatDefault_1_1_0);
+ return STRING(psz? psz : _(""));
+ }
+}
+
+// Help method to get the default GetFeature output format
+STRING MgOgcWfsServer::GetDefaultGetFeatureOutputFormat(CREFSTRING sVersion)
+{
+ if(_("1.0.0") == sVersion)
+ {
CPSZ psz = this->Definition(kpszQueryStringGetFeatureOutputFormatDefault_1_0_0);
return STRING(psz? psz : _(""));
}
Modified: trunk/MgDev/Web/src/HttpHandler/OgcWfsServer.h
===================================================================
--- trunk/MgDev/Web/src/HttpHandler/OgcWfsServer.h 2010-09-23 03:48:27 UTC (rev 5181)
+++ trunk/MgDev/Web/src/HttpHandler/OgcWfsServer.h 2010-09-23 09:13:47 UTC (rev 5182)
@@ -36,7 +36,8 @@
// The the section which displays in the GetCapabilities response document
void SetGetCapabilitiesSection(CREFSTRING sSection);
- STRING GetDefaultOutputFormat(CREFSTRING sVersion);
+ STRING GetDefaultDescribeFeatureTypeOutputFormat(CREFSTRING sVersion);
+ STRING GetDefaultGetFeatureOutputFormat(CREFSTRING sVersion);
protected:
virtual void RespondToRequest();
@@ -46,6 +47,8 @@
void DescribeFeatureTypeResponse();
void GetFeatureResponse();
+ bool ValidateGetCapabilitiesRequest();
+ bool ValidateDescribeFeatureTypeRequest();
bool ValidateGetFeatureRequest();
enum WfsRequestType
More information about the mapguide-commits
mailing list