[mapguide-commits] r5371 - in trunk/MgDev:
Server/src/Services/Feature Web/src/HttpHandler
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Fri Nov 5 02:16:09 EDT 2010
Author: liuar
Date: 2010-11-04 23:16:09 -0700 (Thu, 04 Nov 2010)
New Revision: 5371
Modified:
trunk/MgDev/Server/src/Services/Feature/ServerFeatureService.cpp
trunk/MgDev/Web/src/HttpHandler/HttpWfsGetFeature.cpp
trunk/MgDev/Web/src/HttpHandler/WfsFeatureDefinitions.cpp
trunk/MgDev/Web/src/HttpHandler/WfsFeatureDefinitions.h
Log:
Ticket #1421: OGC WFS 1.1.0 Support
18. In order to pass the WFS certification, Mapguide should provide a way to customize the namespaceURL and namespacePrefix to the response document for GetFeature and DescribeFeatureType.
FDO provided following 2 APIs to set the namespaceURL and namespacePrefix.
/// \brief
/// Sets the default namespace which defines all feature/object types found in the input
/// feature reader which is to be serialized. The user is also supposed to set the schema
/// location for this namespace.
///
/// \param defaultNamespace
/// Default namespace.
///
FDO_API virtual void SetDefaultNamespace(FdoString* defaultNamespace);
/// \brief
/// Sets the default namespace prefix
/// If the prefix is not set then it could be defaulted to the schema name.
///
///
/// \param defaultNamespace
/// Default namespace prefix.
///
FDO_API virtual void SetDefaultNamespacePrefix(FdoString* prefix);
MapGuide set thte namespaceURL and namesapcePrefix for the GetFeature response GML based on above FDO API
Modified: trunk/MgDev/Server/src/Services/Feature/ServerFeatureService.cpp
===================================================================
--- trunk/MgDev/Server/src/Services/Feature/ServerFeatureService.cpp 2010-11-04 22:02:19 UTC (rev 5370)
+++ trunk/MgDev/Server/src/Services/Feature/ServerFeatureService.cpp 2010-11-05 06:16:09 UTC (rev 5371)
@@ -1830,8 +1830,6 @@
if (fc == NULL)
return NULL;
- STRING geomPropName = fc->GetDefaultGeometryPropertyName();
-
//execute the spatial query
Ptr<MgFeatureQueryOptions> options = new MgFeatureQueryOptions();
@@ -1919,8 +1917,6 @@
flags->SetMemberName(L"featureMember");
flags->SetMemberUri(L"http://www.opengis.net/gml");
- // set schemaLocations
-
// gml schema location and version
if(L"text/xml; subtype=gml/2.1.2" == outputFormat)
{
@@ -1938,6 +1934,30 @@
__LINE__, __WFILE__, NULL, L"", NULL);
}
+ // For WFS CITE certification
+ // gml_id, gml_name and gml_description properties must be serialized with gml namespace.
+ Ptr<MgPropertyDefinitionCollection> properties = fc->GetProperties();
+ for(int i = 0; i<properties->GetCount(); i++)
+ {
+ Ptr<MgPropertyDefinition> prop = properties->GetItem(i);
+ STRING propName = prop->GetName();
+
+ if(L"GML_ID" == MgUtil::ToUpper(propName))
+ {
+ FdoPtr<FdoStringCollection> gmlIDRelatePropertyNames = FdoStringCollection::Create();
+ gmlIDRelatePropertyNames->Add(propName.c_str());
+ flags->SetGmlIDRelatePropertyNames(gmlIDRelatePropertyNames);
+ }
+ else if(L"GML_NAME" == MgUtil::ToUpper(propName))
+ {
+ flags->SetGmlNameRelatePropertyName(propName.c_str());
+ }
+ else if(L"GML_DESCRIPTION" == MgUtil::ToUpper(propName))
+ {
+ flags->SetGmlDescriptionRelatePropertyName(propName.c_str());
+ }
+ }
+
// wfs schema location
if(L"1.0.0" == wfsVersion)
{
@@ -1953,20 +1973,22 @@
__LINE__, __WFILE__, NULL, L"", NULL);
}
- // default namespace schema location
- flags->SetSchemaLocation(L"http://www.mynamespace.com/myns", L"http://www.mynamespace.com/myns/myns.xsd");
+ // set the default namespace prefix
+ if(!namespacePrefix.empty())
+ {
+ flags->SetDefaultNamespacePrefix(namespacePrefix.c_str());
+ }
// set the default namespace
- if(!namespacePrefix.empty())
+ if(!namespaceUrl.empty())
{
- STRING defaultNamespace(L"http://fdo.osgeo.org/schemas/feature/");
- defaultNamespace += namespacePrefix;
-
- flags->SetDefaultNamespace(defaultNamespace.c_str());
+ flags->SetDefaultNamespace(namespaceUrl.c_str());
}
else
{
- flags->SetDefaultNamespace(L"http://www.mynamespace.com/myns");
+ STRING defaultNamespace(L"http://fdo.osgeo.org/schemas/feature/");
+ defaultNamespace += schemaName;
+ flags->SetDefaultNamespace(defaultNamespace.c_str());
}
//create the FDO xml serializer stack and write out the features
Modified: trunk/MgDev/Web/src/HttpHandler/HttpWfsGetFeature.cpp
===================================================================
--- trunk/MgDev/Web/src/HttpHandler/HttpWfsGetFeature.cpp 2010-11-04 22:02:19 UTC (rev 5370)
+++ trunk/MgDev/Web/src/HttpHandler/HttpWfsGetFeature.cpp 2010-11-05 06:16:09 UTC (rev 5371)
@@ -271,7 +271,7 @@
// Call the C++ API
Ptr<MgByteReader> resultReader = featureService->GetWfsFeature(featureSourceId, ((sSchemaHash.size()==0) ? sClass : sSchemaHash + _(":") + sClass),
- requiredProperties, m_getFeatureParams->GetSrs(), filter, numFeaturesToRetrieve, sVersion, sOutputFormat, sSortCriteria, sPrefix, L"");
+ requiredProperties, m_getFeatureParams->GetSrs(), filter, numFeaturesToRetrieve, sVersion, sOutputFormat, sSortCriteria, sPrefix, oFeatureTypes.GetNamespaceUrl());
// TODO How to determine number of features retrieved...?
// Note: for now, maxFeatures is managed by the MgWfsFeatures object. - TMT 2006-3-20
Modified: trunk/MgDev/Web/src/HttpHandler/WfsFeatureDefinitions.cpp
===================================================================
--- trunk/MgDev/Web/src/HttpHandler/WfsFeatureDefinitions.cpp 2010-11-04 22:02:19 UTC (rev 5370)
+++ trunk/MgDev/Web/src/HttpHandler/WfsFeatureDefinitions.cpp 2010-11-05 06:16:09 UTC (rev 5371)
@@ -183,7 +183,7 @@
}
-bool MgWfsFeatureDefinitions::GetMetadataDefinitions(MgXmlParser& Input,CStream& oStream, bool& isPublished)
+bool MgWfsFeatureDefinitions::GetMetadataDefinitions(MgXmlParser& Input,CStream& oStream, bool& isPublished, STRING& prefix)
{
STRING sDebug = Input.Current().Contents();
MgXmlSynchronizeOnElement ElementResourceDocumentHeader(Input,_("ResourceDocumentHeader"));
@@ -243,6 +243,11 @@
{
isPublished = true;
}
+ // If user defined a customized prefix, it will replace the auto generated one.
+ else if(SZ_EQ(sDefinitionName.c_str(), _("Feature.Prefix")))
+ {
+ prefix = sValue;
+ }
// WFS 1.1.0 replaces PrimarySRS with DefaultSRS
else if(SZ_EQ(sDefinitionName.c_str(), _("Feature.PrimarySRS")))
{
@@ -332,6 +337,13 @@
STRING requiredPrefix = typeName.substr(0, separatorPos);
if(!requiredPrefix.empty())
{
+ // If there's a customized prefix, we should ignore the optimization.
+ if(requiredPrefix.find(_("ns")) != 0)
+ {
+ requiredPrefixList = NULL;
+ break;
+ }
+
requiredPrefixList->Add(requiredPrefix);
}
else
@@ -403,7 +415,7 @@
AddDefinition(oDefinitions,_("Feature.Prefix"),sPrefix.c_str());
AddDefinition(oDefinitions,_("Feature.Resource"),sResource.c_str());
}
- else if(GetMetadataDefinitions(Input,oDefinitions,required))
+ else if(GetMetadataDefinitions(Input,oDefinitions,required,sPrefix))
{
// Optimization: Stop processing if this feature source isn't published
if(!required)
@@ -635,6 +647,21 @@
}
+STRING MgWfsFeatureDefinitions::GetNamespaceUrl()
+{
+ STRING sKey = _("<Define item='Feature.Url'>");
+ STRING::size_type iPos = m_sSourcesAndClasses.find(sKey);
+ STRING url = _("");
+ if(iPos != STRING::npos)
+ {
+ iPos += sKey.length(); // advance us past the key
+ STRING::size_type iEnd = m_sSourcesAndClasses.find(_("</Define>"),iPos); // NOXLATE
+ url = m_sSourcesAndClasses.substr(iPos,iEnd-iPos);
+ }
+ return url;
+}
+
+
Modified: trunk/MgDev/Web/src/HttpHandler/WfsFeatureDefinitions.h
===================================================================
--- trunk/MgDev/Web/src/HttpHandler/WfsFeatureDefinitions.h 2010-11-04 22:02:19 UTC (rev 5370)
+++ trunk/MgDev/Web/src/HttpHandler/WfsFeatureDefinitions.h 2010-11-05 06:16:09 UTC (rev 5371)
@@ -54,10 +54,11 @@
// and DescribeFeatureType.)
bool PrefixToFeatureSource(STRING sPrefix, REFSTRING sFeatureSource, REFSTRING sSchemaName);
+ STRING GetNamespaceUrl();
private:
bool SkipElement(MgXmlParser& Input,CPSZ pszElementName);
bool GetElementContents(MgXmlParser& Input,CPSZ pszElementName,STRING& sValue);
- bool GetMetadataDefinitions(MgXmlParser& Input,CStream& oStream,bool& isPublished);
+ bool GetMetadataDefinitions(MgXmlParser& Input,CStream& oStream,bool& isPublished,STRING& prefix);
void AddDefinition(CStream& oStream,CPSZ pszPropertyName,CPSZ pszPropertyValue);
More information about the mapguide-commits
mailing list