Skip to content
Permalink
Browse files
First CITE compatibility
  • Loading branch information
rldhont committed Nov 29, 2012
1 parent 0239795 commit 769293b20cce9b9db5e438331002b06e599a0868
@@ -58,8 +58,10 @@ QMap<QString, QString> QgsPostRequestHandler::parseInput()
requestStringToParameterMap( queryString, parameters );

QDomElement docElem = doc.documentElement();
parameters.insert( "VERSION", docElem.attribute( "version" ) );
parameters.insert( "SERVICE", docElem.attribute( "service" ) );
if ( docElem.hasAttribute( "version" ) )
parameters.insert( "VERSION", docElem.attribute( "version" ) );
if ( docElem.hasAttribute( "service" ) )
parameters.insert( "SERVICE", docElem.attribute( "service" ) );
parameters.insert( "REQUEST", docElem.tagName() );
parameters.insert( "REQUEST_BODY", inputString );
}
@@ -196,14 +196,6 @@ void QgsProjectParser::featureTypeList( QDomElement& parentElement, QDomDocument
srsElem.appendChild( srsText );
layerElem.appendChild( srsElem );

QgsRectangle layerExtent = layer->extent();
QDomElement bBoxElement = doc.createElement( "LatLongBoundingBox" );
bBoxElement.setAttribute( "minx", QString::number( layerExtent.xMinimum() ) );
bBoxElement.setAttribute( "miny", QString::number( layerExtent.yMinimum() ) );
bBoxElement.setAttribute( "maxx", QString::number( layerExtent.xMaximum() ) );
bBoxElement.setAttribute( "maxy", QString::number( layerExtent.yMaximum() ) );
layerElem.appendChild( bBoxElement );

//wfs:Operations element
QDomElement operationsElement = doc.createElement( "Operations"/*wfs:Operations*/ );
//wfs:Query element
@@ -235,6 +227,14 @@ void QgsProjectParser::featureTypeList( QDomElement& parentElement, QDomDocument

layerElem.appendChild( operationsElement );

QgsRectangle layerExtent = layer->extent();
QDomElement bBoxElement = doc.createElement( "LatLongBoundingBox" );
bBoxElement.setAttribute( "minx", QString::number( layerExtent.xMinimum() ) );
bBoxElement.setAttribute( "miny", QString::number( layerExtent.yMinimum() ) );
bBoxElement.setAttribute( "maxx", QString::number( layerExtent.xMaximum() ) );
bBoxElement.setAttribute( "maxy", QString::number( layerExtent.yMaximum() ) );
layerElem.appendChild( bBoxElement );

parentElement.appendChild( layerElem );
}
}
@@ -1746,6 +1746,12 @@ QList<QDomElement> QgsProjectParser::publishedComposerElements() const

void QgsProjectParser::serviceCapabilities( QDomElement& parentElement, QDomDocument& doc ) const
{
if (doc.documentElement().tagName() == "WFS_Capabilities")
{
serviceWFSCapabilities( parentElement, doc );
return;
}

QDomElement serviceElem = doc.createElement( "Service" );

QDomElement propertiesElem = mXMLDoc->documentElement().firstChildElement( "properties" );
@@ -1923,6 +1929,110 @@ void QgsProjectParser::serviceCapabilities( QDomElement& parentElement, QDomDocu
parentElement.appendChild( serviceElem );
}

void QgsProjectParser::serviceWFSCapabilities( QDomElement& parentElement, QDomDocument& doc ) const
{
QDomElement serviceElem = doc.createElement( "Service" );

QDomElement propertiesElem = mXMLDoc->documentElement().firstChildElement( "properties" );
if ( propertiesElem.isNull() )
{
QgsConfigParser::serviceCapabilities( parentElement, doc );
return;
}

QDomElement serviceCapabilityElem = propertiesElem.firstChildElement( "WMSServiceCapabilities" );
if ( serviceCapabilityElem.isNull() || serviceCapabilityElem.text().compare( "true", Qt::CaseInsensitive ) != 0 )
{
QgsConfigParser::serviceCapabilities( parentElement, doc );
return;
}

//Service name is always WMS
QDomElement wmsNameElem = doc.createElement( "Name" );
QDomText wmsNameText = doc.createTextNode( "WFS" );
wmsNameElem.appendChild( wmsNameText );
serviceElem.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 );
serviceElem.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 );
serviceElem.appendChild( wmsAbstractElem );
}

//keyword list
QDomElement keywordListElem = propertiesElem.firstChildElement( "WMSKeywordList" );
if ( !keywordListElem.isNull() )
{
bool siaFormat = featureInfoFormatSIA2045();

QDomNodeList keywordList = keywordListElem.elementsByTagName( "value" );
QStringList keywords;
for ( int i = 0; i < keywordList.size(); ++i )
{
keywords << keywordList.at( i ).toElement().text();
}

if ( keywordList.size() > 0 )
{
QDomElement wfsKeywordElem = doc.createElement( "Keywords" );
QDomText keywordText = doc.createTextNode( keywords.join( ", " ) );
wfsKeywordElem.appendChild( keywordText );
if ( siaFormat )
{
wfsKeywordElem.setAttribute( "vocabulary", "SIA_Geo405" );
}
serviceElem.appendChild( wfsKeywordElem );
}
}

//OnlineResource element is mandatory according to the WMS specification
QDomElement wmsOnlineResourceElem = propertiesElem.firstChildElement( "WMSOnlineResource" );
QDomElement onlineResourceElem = doc.createElement( "OnlineResource" );
onlineResourceElem.setAttribute( "xmlns:xlink", "http://www.w3.org/1999/xlink" );
onlineResourceElem.setAttribute( "xlink:type", "simple" );
if ( !wmsOnlineResourceElem.isNull() )
{
onlineResourceElem.setAttribute( "xlink:href", wmsOnlineResourceElem.text() );
}

serviceElem.appendChild( onlineResourceElem );

//Fees
QDomElement feesElem = propertiesElem.firstChildElement( "WMSFees" );
if ( !feesElem.isNull() )
{
QDomElement wmsFeesElem = doc.createElement( "Fees" );
QDomText wmsFeesText = doc.createTextNode( feesElem.text() );
wmsFeesElem.appendChild( wmsFeesText );
serviceElem.appendChild( wmsFeesElem );
}

//AccessConstraints
QDomElement accessConstraintsElem = propertiesElem.firstChildElement( "WMSAccessConstraints" );
if ( !accessConstraintsElem.isNull() )
{
QDomElement wmsAccessConstraintsElem = doc.createElement( "AccessConstraints" );
QDomText wmsAccessConstraintsText = doc.createTextNode( accessConstraintsElem.text() );
wmsAccessConstraintsElem.appendChild( wmsAccessConstraintsText );
serviceElem.appendChild( wmsAccessConstraintsElem );
}
parentElement.appendChild( serviceElem );
}

QString QgsProjectParser::serviceUrl() const
{
QString url;
@@ -248,6 +248,11 @@ class QgsProjectParser: public QgsConfigParser
static void drawAnnotationRectangle( QPainter* p, const QDomElement& elem, double scaleFactor, double xPos, double yPos, int itemWidth, int itemHeight );

void addDrawingOrderEmbeddedGroup( const QDomElement& groupElem, QMap<int, QString>& orderedLayerList, bool useDrawingOrder ) const;

/**Reads service metadata from projectfile or falls back to parent class method if not there
* This is for WFS Services
**/
void serviceWFSCapabilities( QDomElement& parentElement, QDomDocument& doc ) const;
};

#endif // QGSPROJECTPARSER_H
@@ -112,10 +112,6 @@ QDomDocument QgsWFSServer::getCapabilities()
//wfs:GetCapabilities
QDomElement getCapabilitiesElement = doc.createElement( "GetCapabilities"/*wfs:GetCapabilities*/ );
requestElement.appendChild( getCapabilitiesElement );
QDomElement capabilitiesFormatElement = doc.createElement( "Format" );/*wfs:Format*/
getCapabilitiesElement.appendChild( capabilitiesFormatElement );
QDomText capabilitiesFormatText = doc.createTextNode( "text/xml" );
capabilitiesFormatElement.appendChild( capabilitiesFormatText );

QDomElement dcpTypeElement = doc.createElement( "DCPType"/*wfs:DCPType*/ );
getCapabilitiesElement.appendChild( dcpTypeElement );
@@ -181,6 +177,9 @@ QDomDocument QgsWFSServer::getCapabilities()
httpElement.appendChild( getElement );
requestUrl.truncate( requestUrl.indexOf( "?" ) + 1 );
getElement.setAttribute( "onlineResource", hrefString );
QDomElement getCapabilitiesDhcTypePostElement = dcpTypeElement.cloneNode().toElement();//this is the same as for 'GetCapabilities'
getCapabilitiesDhcTypePostElement.firstChild().firstChild().toElement().setTagName( "Post" );
getCapabilitiesElement.appendChild( getCapabilitiesDhcTypePostElement );

//wfs:DescribeFeatureType
QDomElement describeFeatureTypeElement = doc.createElement( "DescribeFeatureType"/*wfs:DescribeFeatureType*/ );

0 comments on commit 769293b

Please sign in to comment.