[QGIS Commit] r15070 - trunk/qgis/src/mapserver

svn_qgis at osgeo.org svn_qgis at osgeo.org
Mon Jan 24 10:50:52 EST 2011


Author: mhugent
Date: 2011-01-24 07:50:52 -0800 (Mon, 24 Jan 2011)
New Revision: 15070

Modified:
   trunk/qgis/src/mapserver/qgsprojectparser.cpp
Log:
Different format for embedded wms service metadata

Modified: trunk/qgis/src/mapserver/qgsprojectparser.cpp
===================================================================
--- trunk/qgis/src/mapserver/qgsprojectparser.cpp	2011-01-24 14:05:05 UTC (rev 15069)
+++ trunk/qgis/src/mapserver/qgsprojectparser.cpp	2011-01-24 15:50:52 UTC (rev 15070)
@@ -1033,18 +1033,101 @@
 
 void QgsProjectParser::serviceCapabilities( QDomElement& parentElement, QDomDocument& doc ) const
 {
-  QDomElement qgisElem = mXMLDoc->documentElement();
-  QDomNodeList serviceCapabilitiesList = qgisElem.elementsByTagName( "WMSServiceCapabilities" );
-  if ( serviceCapabilitiesList.size() < 1 ) //service capabilities not embedded in the project file. Use wms_metadata.xml as fallback
+  QDomElement propertiesElem = mXMLDoc->documentElement().firstChildElement( "properties" );
+  if ( propertiesElem.isNull() )
   {
     QgsConfigParser::serviceCapabilities( parentElement, doc );
     return;
   }
 
-  QDomElement serviceElem = serviceCapabilitiesList.at( 0 ).firstChildElement( "Service" );
-  if ( !serviceElem.isNull() )
+  QDomElement serviceCapabilityElem = propertiesElem.firstChildElement( "WMSServiceCapabilities" );
+  if ( serviceCapabilityElem.isNull() || serviceCapabilityElem.text().compare( "true", Qt::CaseInsensitive ) != 0 )
   {
-    parentElement.appendChild( doc.importNode( serviceElem, true ) );
+    QgsConfigParser::serviceCapabilities( parentElement, doc );
+    return;
   }
+
+  //Service name is always WMS
+  QDomElement wmsNameElem = doc.createElement( "Name" );
+  QDomText wmsNameText = doc.createTextNode( "WMS" );
+  wmsNameElem.appendChild( wmsNameText );
+  parentElement.appendChild( wmsNameElem );
+
+  //WMS title
+  QDomElement titleElem = propertiesElem.firstChildElement( "WMSServiceTitle" );
+  if ( !titleElem.isNull() )
+  {
+    QDomElement wmsTitleElem = doc.createElement( "Title" );
+    QDomText wmsTitleText = doc.createTextNode( titleElem.text() );
+    wmsTitleElem.appendChild( wmsTitleText );
+    parentElement.appendChild( wmsTitleElem );
+  }
+
+  //WMS abstract
+  QDomElement abstractElem = propertiesElem.firstChildElement( "WMSServiceAbstract" );
+  if ( !abstractElem.isNull() )
+  {
+    QDomElement wmsAbstractElem = doc.createElement( "Abstract" );
+    QDomText wmsAbstractText = doc.createTextNode( abstractElem.text() );
+    wmsAbstractElem.appendChild( wmsAbstractText );
+    parentElement.appendChild( wmsAbstractElem );
+  }
+
+  //Contact information
+  QDomElement contactInfoElem = doc.createElement( "ContactInformation" );
+
+  //Contact person primary
+  QDomElement contactPersonPrimaryElem = doc.createElement( "ContactPersonPrimary" );
+
+  //Contact person
+  QDomElement contactPersonElem = propertiesElem.firstChildElement( "WMSContactPerson" );
+  if ( !contactPersonElem.isNull() )
+  {
+    QDomElement wmsContactPersonElem = doc.createElement( "ContactPerson" );
+    QDomText contactPersonText = doc.createTextNode( contactPersonElem.text() );
+    wmsContactPersonElem.appendChild( contactPersonText );
+    contactPersonPrimaryElem.appendChild( wmsContactPersonElem );
+  }
+
+  //Contact organisation
+  QDomElement contactOrganisationElem = propertiesElem.firstChildElement( "WMSContactOrganisation" );
+  if ( !contactOrganisationElem.isNull() )
+  {
+    QDomElement wmsContactOrganisationElem = doc.createElement( "ContactOrganization" );
+    QDomText contactOrganisationText = doc.createTextNode( contactOrganisationElem.text() );
+    wmsContactOrganisationElem.appendChild( contactOrganisationText );
+    contactPersonPrimaryElem.appendChild( wmsContactOrganisationElem );
+  }
+
+  contactInfoElem.appendChild( contactPersonPrimaryElem );
+
+  //Contact address
+  QDomElement contactAddressElem = doc.createElement( "ContactAddress" );
+
+  //
+
+  contactInfoElem.appendChild( contactAddressElem );
+
+  //phone
+  QDomElement phoneElem = propertiesElem.firstChildElement( "WMSContactPhone" );
+  if ( !phoneElem.isNull() )
+  {
+    QDomElement wmsPhoneElem = doc.createElement( "ContactVoiceTelephone" );
+    QDomText wmsPhoneText = doc.createTextNode( phoneElem.text() );
+    wmsPhoneElem.appendChild( wmsPhoneText );
+    contactInfoElem.appendChild( wmsPhoneElem );
+  }
+
+  //mail
+  QDomElement mailElem = propertiesElem.firstChildElement( "WMSContactMail" );
+  if ( !mailElem.isNull() )
+  {
+    QDomElement wmsMailElem = doc.createElement( "ContactElectronicMailAddress" );
+    QDomText wmsMailText = doc.createTextNode( mailElem.text() );
+    wmsMailElem.appendChild( wmsMailText );
+    contactInfoElem.appendChild( wmsMailElem );
+  }
+
+  parentElement.appendChild( contactInfoElem );
 }
 



More information about the QGIS-commit mailing list