Skip to content
Permalink
Browse files

Copy things from WFS server to WMS server

  • Loading branch information
Stéphane Brunner authored and mhugent committed Sep 8, 2013
1 parent bd62f30 commit 44aef479a95fc8fa0af72815d060d8da48de6a85
Showing with 125 additions and 0 deletions.
  1. +119 −0 src/mapserver/qgswmsserver.cpp
  2. +6 −0 src/mapserver/qgswmsserver.h
@@ -2342,3 +2342,122 @@ void QgsWMSServer::convertFeatureInfoToSIA2045( QDomDocument& doc )
}
doc = SIAInfoDoc;
}

/* get from qgswfsserver.cpp */
QDomElement QgsWMSServer::createFeatureGML2( QgsFeature* feat, QDomDocument& doc, QgsCoordinateReferenceSystem& crs, QgsAttributeList attrIndexes, QSet<QString> excludedAttributes ) /*const*/
{
//gml:FeatureMember
QDomElement featureElement = doc.createElement( "gml:featureMember"/*wfs:FeatureMember*/ );

//qgs:%TYPENAME%
QDomElement typeNameElement = doc.createElement( "qgs:" + mTypeName /*qgs:%TYPENAME%*/ );
typeNameElement.setAttribute( "fid", mTypeName + "." + QString::number( feat->id() ) );
featureElement.appendChild( typeNameElement );

if ( mWithGeom )
{
//add geometry column (as gml)
QgsGeometry* geom = feat->geometry();

QDomElement geomElem = doc.createElement( "qgs:geometry" );
QDomElement gmlElem = QgsOgcUtils::geometryToGML( geom, doc );
if ( !gmlElem.isNull() )
{
QgsRectangle box = geom->boundingBox();
QDomElement bbElem = doc.createElement( "gml:boundedBy" );
QDomElement boxElem = QgsOgcUtils::rectangleToGMLBox( &box, doc );

if ( crs.isValid() )
{
boxElem.setAttribute( "srsName", crs.authid() );
gmlElem.setAttribute( "srsName", crs.authid() );
}

bbElem.appendChild( boxElem );
typeNameElement.appendChild( bbElem );

geomElem.appendChild( gmlElem );
typeNameElement.appendChild( geomElem );
}
}

//read all attribute values from the feature
QgsAttributes featureAttributes = feat->attributes();
const QgsFields* fields = feat->fields();
for ( int i = 0; i < attrIndexes.count(); ++i )
{
int idx = attrIndexes[i];
QString attributeName = fields->at( idx ).name();
//skip attribute if it is excluded from WFS publication
if ( excludedAttributes.contains( attributeName ) )
{
continue;
}

QDomElement fieldElem = doc.createElement( "qgs:" + attributeName.replace( QString( " " ), QString( "_" ) ) );
QDomText fieldText = doc.createTextNode( featureAttributes[idx].toString() );
fieldElem.appendChild( fieldText );
typeNameElement.appendChild( fieldElem );
}

return featureElement;
}

QDomElement QgsWMSServer::createFeatureGML3( QgsFeature* feat, QDomDocument& doc, QgsCoordinateReferenceSystem& crs, QgsAttributeList attrIndexes, QSet<QString> excludedAttributes ) /*const*/
{
//gml:FeatureMember
QDomElement featureElement = doc.createElement( "gml:featureMember"/*wfs:FeatureMember*/ );

//qgs:%TYPENAME%
QDomElement typeNameElement = doc.createElement( "qgs:" + mTypeName /*qgs:%TYPENAME%*/ );
typeNameElement.setAttribute( "gml:id", mTypeName + "." + QString::number( feat->id() ) );
featureElement.appendChild( typeNameElement );

if ( mWithGeom )
{
//add geometry column (as gml)
QgsGeometry* geom = feat->geometry();

QDomElement geomElem = doc.createElement( "qgs:geometry" );
QDomElement gmlElem = QgsOgcUtils::geometryToGML( geom, doc, "GML3" );
if ( !gmlElem.isNull() )
{
QgsRectangle box = geom->boundingBox();
QDomElement bbElem = doc.createElement( "gml:boundedBy" );
QDomElement boxElem = QgsOgcUtils::rectangleToGMLEnvelope( &box, doc );

if ( crs.isValid() )
{
boxElem.setAttribute( "srsName", crs.authid() );
gmlElem.setAttribute( "srsName", crs.authid() );
}

bbElem.appendChild( boxElem );
typeNameElement.appendChild( bbElem );

geomElem.appendChild( gmlElem );
typeNameElement.appendChild( geomElem );
}
}

//read all attribute values from the feature
QgsAttributes featureAttributes = feat->attributes();
const QgsFields* fields = feat->fields();
for ( int i = 0; i < attrIndexes.count(); ++i )
{
int idx = attrIndexes[i];
QString attributeName = fields->at( idx ).name();
//skip attribute if it is excluded from WFS publication
if ( excludedAttributes.contains( attributeName ) )
{
continue;
}

QDomElement fieldElem = doc.createElement( "qgs:" + attributeName.replace( QString( " " ), QString( "_" ) ) );
QDomText fieldText = doc.createTextNode( featureAttributes[idx].toString() );
fieldElem.appendChild( fieldText );
typeNameElement.appendChild( fieldElem );
}

return featureElement;
}
@@ -205,6 +205,12 @@ class QgsWMSServer
QMap<QString, QString> mParameterMap;
QgsConfigParser* mConfigParser;
QgsMapRenderer* mMapRenderer;

/* get from qgswfsserver.h */
//methods to write GML2
QDomElement createFeatureGML2( QgsFeature* feat, QDomDocument& doc, QgsCoordinateReferenceSystem& crs ) /*const*/;
//methods to write GML3
QDomElement createFeatureGML3( QgsFeature* feat, QDomDocument& doc, QgsCoordinateReferenceSystem& crs ) /*const*/;
};

#endif

0 comments on commit 44aef47

Please sign in to comment.
You can’t perform that action at this time.