Skip to content
Permalink
Browse files
[FEATURE][SERVER] GetFeature with an other Geometry
This commit completes 'GetFeature without geometry' e3a832c

The GeometryName parameter can be used to get the extent or the centroid as the geometry.
This Feature can be used to have a lighter gml document.

The extra parameter GeometryName can be:

* None
* Extent
* Centroid
  • Loading branch information
rldhont committed May 22, 2015
1 parent df7e07b commit 2c5c8662771c48c975b7c03a0dea1d8bb7922893
Showing with 20 additions and 3 deletions.
  1. +20 −3 src/server/qgswfsserver.cpp
@@ -1696,7 +1696,12 @@ QString QgsWFSServer::createFeatureGeoJSON( QgsFeature* feat, int prec, QgsCoord
fStr += " \"bbox\": [ " + qgsDoubleToString( box.xMinimum(), prec ) + ", " + qgsDoubleToString( box.yMinimum(), prec ) + ", " + qgsDoubleToString( box.xMaximum(), prec ) + ", " + qgsDoubleToString( box.yMaximum(), prec ) + "],\n";

fStr += " \"geometry\": ";
fStr += geom->exportToGeoJSON( prec );
if ( mGeometryName == "EXTENT" )
fStr += QgsGeometry::fromRect( box )->exportToGeoJSON( prec );
else if ( mGeometryName == "CENTROID" )
fStr += geom->centroid()->exportToGeoJSON( prec );
else
fStr += geom->exportToGeoJSON( prec );
fStr += ",\n";
}

@@ -1759,7 +1764,13 @@ QDomElement QgsWFSServer::createFeatureGML2( QgsFeature* feat, QDomDocument& doc
QgsGeometry* geom = feat->geometry();

QDomElement geomElem = doc.createElement( "qgs:geometry" );
QDomElement gmlElem = QgsOgcUtils::geometryToGML( geom, doc, prec );
QDomElement gmlElem;
if ( mGeometryName == "EXTENT" )
gmlElem = QgsOgcUtils::geometryToGML( QgsGeometry::fromRect( geom->boundingBox() ), doc, prec );
else if ( mGeometryName == "CENTROID" )
gmlElem = QgsOgcUtils::geometryToGML( geom->centroid(), doc, prec );
else
gmlElem = QgsOgcUtils::geometryToGML( geom, doc, prec );
if ( !gmlElem.isNull() )
{
QgsRectangle box = geom->boundingBox();
@@ -1818,7 +1829,13 @@ QDomElement QgsWFSServer::createFeatureGML3( QgsFeature* feat, QDomDocument& doc
QgsGeometry* geom = feat->geometry();

QDomElement geomElem = doc.createElement( "qgs:geometry" );
QDomElement gmlElem = QgsOgcUtils::geometryToGML( geom, doc, "GML3", prec );
QDomElement gmlElem;
if ( mGeometryName == "EXTENT" )
gmlElem = QgsOgcUtils::geometryToGML( QgsGeometry::fromRect( geom->boundingBox() ), doc, "GML3", prec );
else if ( mGeometryName == "CENTROID" )
gmlElem = QgsOgcUtils::geometryToGML( geom->centroid(), doc, "GML3", prec );
else
gmlElem = QgsOgcUtils::geometryToGML( geom, doc, "GML3", prec );
if ( !gmlElem.isNull() )
{
QgsRectangle box = geom->boundingBox();

0 comments on commit 2c5c866

Please sign in to comment.