Skip to content

Commit ff23fcb

Browse files
author
mhugent
committedJan 24, 2011
Different format for embedded wms service metadata
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@15070 c8812cc2-4d05-0410-92ff-de0c093fc19c

File tree

1 file changed

+89
-6
lines changed

1 file changed

+89
-6
lines changed
 

‎src/mapserver/qgsprojectparser.cpp

Lines changed: 89 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,18 +1033,101 @@ QDomElement QgsProjectParser::composerByName( const QString& composerName ) cons
10331033

10341034
void QgsProjectParser::serviceCapabilities( QDomElement& parentElement, QDomDocument& doc ) const
10351035
{
1036-
QDomElement qgisElem = mXMLDoc->documentElement();
1037-
QDomNodeList serviceCapabilitiesList = qgisElem.elementsByTagName( "WMSServiceCapabilities" );
1038-
if ( serviceCapabilitiesList.size() < 1 ) //service capabilities not embedded in the project file. Use wms_metadata.xml as fallback
1036+
QDomElement propertiesElem = mXMLDoc->documentElement().firstChildElement( "properties" );
1037+
if ( propertiesElem.isNull() )
1038+
{
1039+
QgsConfigParser::serviceCapabilities( parentElement, doc );
1040+
return;
1041+
}
1042+
1043+
QDomElement serviceCapabilityElem = propertiesElem.firstChildElement( "WMSServiceCapabilities" );
1044+
if ( serviceCapabilityElem.isNull() || serviceCapabilityElem.text().compare( "true", Qt::CaseInsensitive ) != 0 )
10391045
{
10401046
QgsConfigParser::serviceCapabilities( parentElement, doc );
10411047
return;
10421048
}
10431049

1044-
QDomElement serviceElem = serviceCapabilitiesList.at( 0 ).firstChildElement( "Service" );
1045-
if ( !serviceElem.isNull() )
1050+
//Service name is always WMS
1051+
QDomElement wmsNameElem = doc.createElement( "Name" );
1052+
QDomText wmsNameText = doc.createTextNode( "WMS" );
1053+
wmsNameElem.appendChild( wmsNameText );
1054+
parentElement.appendChild( wmsNameElem );
1055+
1056+
//WMS title
1057+
QDomElement titleElem = propertiesElem.firstChildElement( "WMSServiceTitle" );
1058+
if ( !titleElem.isNull() )
1059+
{
1060+
QDomElement wmsTitleElem = doc.createElement( "Title" );
1061+
QDomText wmsTitleText = doc.createTextNode( titleElem.text() );
1062+
wmsTitleElem.appendChild( wmsTitleText );
1063+
parentElement.appendChild( wmsTitleElem );
1064+
}
1065+
1066+
//WMS abstract
1067+
QDomElement abstractElem = propertiesElem.firstChildElement( "WMSServiceAbstract" );
1068+
if ( !abstractElem.isNull() )
1069+
{
1070+
QDomElement wmsAbstractElem = doc.createElement( "Abstract" );
1071+
QDomText wmsAbstractText = doc.createTextNode( abstractElem.text() );
1072+
wmsAbstractElem.appendChild( wmsAbstractText );
1073+
parentElement.appendChild( wmsAbstractElem );
1074+
}
1075+
1076+
//Contact information
1077+
QDomElement contactInfoElem = doc.createElement( "ContactInformation" );
1078+
1079+
//Contact person primary
1080+
QDomElement contactPersonPrimaryElem = doc.createElement( "ContactPersonPrimary" );
1081+
1082+
//Contact person
1083+
QDomElement contactPersonElem = propertiesElem.firstChildElement( "WMSContactPerson" );
1084+
if ( !contactPersonElem.isNull() )
1085+
{
1086+
QDomElement wmsContactPersonElem = doc.createElement( "ContactPerson" );
1087+
QDomText contactPersonText = doc.createTextNode( contactPersonElem.text() );
1088+
wmsContactPersonElem.appendChild( contactPersonText );
1089+
contactPersonPrimaryElem.appendChild( wmsContactPersonElem );
1090+
}
1091+
1092+
//Contact organisation
1093+
QDomElement contactOrganisationElem = propertiesElem.firstChildElement( "WMSContactOrganisation" );
1094+
if ( !contactOrganisationElem.isNull() )
10461095
{
1047-
parentElement.appendChild( doc.importNode( serviceElem, true ) );
1096+
QDomElement wmsContactOrganisationElem = doc.createElement( "ContactOrganization" );
1097+
QDomText contactOrganisationText = doc.createTextNode( contactOrganisationElem.text() );
1098+
wmsContactOrganisationElem.appendChild( contactOrganisationText );
1099+
contactPersonPrimaryElem.appendChild( wmsContactOrganisationElem );
10481100
}
1101+
1102+
contactInfoElem.appendChild( contactPersonPrimaryElem );
1103+
1104+
//Contact address
1105+
QDomElement contactAddressElem = doc.createElement( "ContactAddress" );
1106+
1107+
//
1108+
1109+
contactInfoElem.appendChild( contactAddressElem );
1110+
1111+
//phone
1112+
QDomElement phoneElem = propertiesElem.firstChildElement( "WMSContactPhone" );
1113+
if ( !phoneElem.isNull() )
1114+
{
1115+
QDomElement wmsPhoneElem = doc.createElement( "ContactVoiceTelephone" );
1116+
QDomText wmsPhoneText = doc.createTextNode( phoneElem.text() );
1117+
wmsPhoneElem.appendChild( wmsPhoneText );
1118+
contactInfoElem.appendChild( wmsPhoneElem );
1119+
}
1120+
1121+
//mail
1122+
QDomElement mailElem = propertiesElem.firstChildElement( "WMSContactMail" );
1123+
if ( !mailElem.isNull() )
1124+
{
1125+
QDomElement wmsMailElem = doc.createElement( "ContactElectronicMailAddress" );
1126+
QDomText wmsMailText = doc.createTextNode( mailElem.text() );
1127+
wmsMailElem.appendChild( wmsMailText );
1128+
contactInfoElem.appendChild( wmsMailElem );
1129+
}
1130+
1131+
parentElement.appendChild( contactInfoElem );
10491132
}
10501133

0 commit comments

Comments
 (0)
Please sign in to comment.