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 6e9631e commit 7ae6269
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 @@ -1216,6 +1216,22 @@ void QgsWfsServer::startGetFeature( QgsRequestHandler& request, const QString& f
QString fcString;
if ( format == QLatin1String( "GeoJSON" ) )
{
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 = QStringLiteral( "{\"type\": \"FeatureCollection\",\n" );
fcString += " \"bbox\": [ " + qgsDoubleToString( rect->xMinimum(), prec ) + ", " + qgsDoubleToString( rect->yMinimum(), prec ) + ", " + qgsDoubleToString( rect->xMaximum(), prec ) + ", " + qgsDoubleToString( rect->yMaximum(), prec ) + "],\n";
fcString += QLatin1String( " \"features\": [\n" );
Expand Down

3 comments on commit 7ae6269

@3nids
Copy link
Member

@3nids 3nids commented on 7ae6269 Nov 14, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rldhont Build is broken since that commit

@rldhont
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@3nids the earlier commit 6e9631e has also a build broken

@rldhont
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll take a look at the compilation error http://tinyurl.com/jf4wobz

Please sign in to comment.