Skip to content

Commit

Permalink
fix dxf export for espg's with reverse axes
Browse files Browse the repository at this point in the history
The dxf export didn't work for reverse axis projections (north, east)
as the BBOX for WMS 1.3.0 comes in South, West, North, East and the
dxf export treated it like West, South, East, North.

The logic is taken from the normal GetMap, GetPrint requests.
  • Loading branch information
tudorbarascu committed Jan 25, 2021
1 parent fba5093 commit e55fdf4
Showing 1 changed file with 47 additions and 1 deletion.
48 changes: 47 additions & 1 deletion src/server/services/wms/qgswmsrenderer.cpp
Expand Up @@ -865,9 +865,55 @@ namespace QgsWms
dxfLayers.append( QgsDxfExport::DxfLayer( vlayer, layerAttribute ) );
}

//map extent
QgsRectangle mapExtent = mWmsParameters.bboxAsRectangle();

QString crs = mWmsParameters.crs();
if ( crs.compare( "CRS:84", Qt::CaseInsensitive ) == 0 )
{
crs = QString( "EPSG:4326" );
mapExtent.invert();
}
else if ( crs.isEmpty() )
{
crs = QString( "EPSG:4326" );
}

QgsCoordinateReferenceSystem outputCRS;

outputCRS = QgsCoordinateReferenceSystem::fromOgcWmsCrs( crs );
if ( !outputCRS.isValid() )
{
QgsServiceException::ExceptionCode code;
QgsWmsParameter parameter;

if ( mWmsParameters.versionAsNumber() >= QgsProjectVersion( 1, 3, 0 ) )
{
code = QgsServiceException::OGC_InvalidCRS;
parameter = mWmsParameters[ QgsWmsParameter::CRS ];
}
else
{
code = QgsServiceException::OGC_InvalidSRS;
parameter = mWmsParameters[ QgsWmsParameter::SRS ];
}

throw QgsBadRequestException( code, parameter );
}

//then set destinationCrs

// Change x- and y- of BBOX for WMS 1.3.0 if axis inverted
if ( mWmsParameters.versionAsNumber() >= QgsProjectVersion( 1, 3, 0 ) && outputCRS.hasAxisInverted() )
{
mapExtent.invert();
}


// add layers to dxf
std::unique_ptr<QgsDxfExport> dxf = qgis::make_unique<QgsDxfExport>();
dxf->setExtent( mWmsParameters.bboxAsRectangle() );
dxf->setExtent( mapExtent );
dxf->setDestinationCrs( outputCRS );
dxf->addLayers( dxfLayers );
dxf->setLayerTitleAsName( mWmsParameters.dxfUseLayerTitleAsName() );
dxf->setSymbologyExport( mWmsParameters.dxfMode() );
Expand Down

0 comments on commit e55fdf4

Please sign in to comment.