Skip to content

Commit

Permalink
[BUGFIX][QGIS Server] Transform feature collections bbox to ESPG:4326
Browse files Browse the repository at this point in the history
  • Loading branch information
rldhont committed Nov 14, 2016
1 parent 2eec236 commit fa88e6a
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/server/qgswfsserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1220,6 +1220,22 @@ void QgsWFSServer::startGetFeature( QgsRequestHandler& request, const QString& f
if ( format == "GeoJSON" )
{
fcString = "{\"type\": \"FeatureCollection\",\n";
if ( crs.isValid() )
{
QgsGeometry* exportGeom = QgsGeometry::fromRect( *rect );
QgsCoordinateTransform transform;
transform.setSourceCrs( crs );
transform.setDestCRS( QgsCoordinateReferenceSystem( 4326, QgsCoordinateReferenceSystem::EpsgCrsId ) );
try
{
if ( exportGeom->transform( transform ) == 0 )
rect = new QgsRectangle( exportGeom->boundingBox() );
}
catch ( QgsCsException &cse )
{
Q_UNUSED( cse );
}
}
fcString += " \"bbox\": [ " + qgsDoubleToString( rect->xMinimum(), prec ) + ", " + qgsDoubleToString( rect->yMinimum(), prec ) + ", " + qgsDoubleToString( rect->xMaximum(), prec ) + ", " + qgsDoubleToString( rect->yMaximum(), prec ) + "],\n";
fcString += " \"features\": [\n";
result = fcString.toUtf8();
Expand Down

0 comments on commit fa88e6a

Please sign in to comment.