Skip to content
Permalink
Browse files
[QGIS-Server][WCS] Add RESPONSE_CRS param
  • Loading branch information
rldhont committed Feb 7, 2014
1 parent 408e2b7 commit da8ca460aa6b35880c2ae8ad0ae601ef83d3af7a
Showing with 28 additions and 7 deletions.
  1. +28 −7 src/mapserver/qgswcsserver.cpp
@@ -260,14 +260,16 @@ QByteArray* QgsWCSServer::getCoverage()
{
mErrors << QString( "The CRS is mandatory" );
}
QgsCoordinateReferenceSystem outputCRS = QgsCRSCache::instance()->crsByAuthId( crs );
if ( !outputCRS.isValid() )

if ( mErrors.count() != 0 )
{
mErrors << QString( "Could not create output CRS" );
throw QgsMapServiceException( "RequestNotWellFormed", mErrors.join( ". " ) );
}

if ( mErrors.count() != 0 )
QgsCoordinateReferenceSystem requestCRS = QgsCRSCache::instance()->crsByAuthId( crs );
if ( !requestCRS.isValid() )
{
mErrors << QString( "Could not create request CRS" );
throw QgsMapServiceException( "RequestNotWellFormed", mErrors.join( ". " ) );
}

@@ -277,6 +279,25 @@ QByteArray* QgsWCSServer::getCoverage()
QgsRasterLayer* rLayer = dynamic_cast<QgsRasterLayer*>( layer );
if ( rLayer && wcsLayersId.contains( rLayer->id() ) )
{
// RESPONSE_CRS
QgsCoordinateReferenceSystem responseCRS = rLayer->crs();
crs = mParameterMap.value( "RESPONSE_CRS", "" );
if ( crs != "" )
{
responseCRS = QgsCRSCache::instance()->crsByAuthId( crs );
if ( !responseCRS.isValid() )
{
responseCRS = rLayer->crs();
}
}

// transform rect
if ( requestCRS != rLayer->crs() )
{
QgsCoordinateTransform t( requestCRS, rLayer->crs() );
rect = t.transformBoundingBox( rect );
}

QTemporaryFile tempFile;
tempFile.open();
QgsRasterFileWriter fileWriter( tempFile.fileName() );
@@ -290,18 +311,18 @@ QByteArray* QgsWCSServer::getCoverage()
}

// add projector if necessary
if ( outputCRS != rLayer->crs() )
if ( responseCRS != rLayer->crs() )
{
QgsRasterProjector * projector = new QgsRasterProjector;
projector->setCRS( rLayer->crs(), outputCRS );
projector->setCRS( rLayer->crs(), responseCRS );
if ( !pipe->insert( 2, projector ) )
{
mErrors << QString( "Cannot set pipe projector" );
throw QgsMapServiceException( "RequestNotWellFormed", mErrors.join( ". " ) );
}
}

QgsRasterFileWriter::WriterError err = fileWriter.writeRaster( pipe, width, height, rect, outputCRS );
QgsRasterFileWriter::WriterError err = fileWriter.writeRaster( pipe, width, height, rect, responseCRS );
if ( err != QgsRasterFileWriter::NoError )
{
mErrors << QString( "Cannot write raster error code: %1" ).arg( err );

0 comments on commit da8ca46

Please sign in to comment.