Skip to content
Permalink
Browse files

[Server] Update deprecated QgsCoordinateTransform instance creation

Using the project as the context for QgsCoordinateTransform instance creation
  • Loading branch information
rldhont committed Aug 7, 2018
1 parent 2075141 commit 29d280f1ea1aa3ecb9942e42fb946bb49031d0a4
@@ -120,7 +120,7 @@ namespace QgsWcs
if ( coveNameList.size() == 0 || coveNameList.contains( name ) )
{
QgsRasterLayer *rLayer = qobject_cast<QgsRasterLayer *>( layer );
coveDescElement.appendChild( getCoverageOffering( doc, const_cast<QgsRasterLayer *>( rLayer ) ) );
coveDescElement.appendChild( getCoverageOffering( doc, const_cast<QgsRasterLayer *>( rLayer ), project ) );
}
}
return doc;
@@ -323,7 +323,7 @@ namespace QgsWcs
#endif

QgsRasterLayer *rLayer = qobject_cast<QgsRasterLayer *>( layer );
QDomElement layerElem = getCoverageOffering( doc, const_cast<QgsRasterLayer *>( rLayer ), true );
QDomElement layerElem = getCoverageOffering( doc, const_cast<QgsRasterLayer *>( rLayer ), project, true );

contentMetadataElement.appendChild( layerElem );
}
@@ -165,9 +165,7 @@ namespace QgsWcs
// transform rect
if ( requestCRS != rLayer->crs() )
{
Q_NOWARN_DEPRECATED_PUSH
QgsCoordinateTransform t( requestCRS, rLayer->crs() );
Q_NOWARN_DEPRECATED_POP
QgsCoordinateTransform t( requestCRS, rLayer->crs(), project );
rect = t.transformBoundingBox( rect );
}

@@ -32,7 +32,7 @@ namespace QgsWcs
return QStringLiteral( "1.0.0" );
}

QDomElement getCoverageOffering( QDomDocument &doc, const QgsRasterLayer *layer, bool brief )
QDomElement getCoverageOffering( QDomDocument &doc, const QgsRasterLayer *layer, const QgsProject *project, bool brief )
{
QDomElement layerElem;
if ( brief )
@@ -73,9 +73,7 @@ namespace QgsWcs

//lonLatEnvelope
QgsCoordinateReferenceSystem layerCrs = layer->crs();
Q_NOWARN_DEPRECATED_PUSH
QgsCoordinateTransform t( layerCrs, QgsCoordinateReferenceSystem( 4326 ) );
Q_NOWARN_DEPRECATED_POP
QgsCoordinateTransform t( layerCrs, QgsCoordinateReferenceSystem( 4326 ), project );
//transform
QgsRectangle BBox;
try
@@ -45,7 +45,7 @@ namespace QgsWcs
/**
* CoverageOffering or CoverageOfferingBrief element
*/
QDomElement getCoverageOffering( QDomDocument &doc, const QgsRasterLayer *layer, bool brief = false );
QDomElement getCoverageOffering( QDomDocument &doc, const QgsRasterLayer *layer, const QgsProject *project, bool brief = false );

/**
* Service URL string
@@ -559,9 +559,7 @@ namespace QgsWfs
QgsRectangle wgs84BoundingRect;
if ( !layerExtent.isNull() )
{
Q_NOWARN_DEPRECATED_PUSH
QgsCoordinateTransform exGeoTransform( layer->crs(), wgs84 );
Q_NOWARN_DEPRECATED_POP
QgsCoordinateTransform exGeoTransform( layer->crs(), wgs84, project );
try
{
wgs84BoundingRect = exGeoTransform.transformBoundingBox( layerExtent );
@@ -62,9 +62,9 @@ namespace QgsWfs

QString createFeatureGeoJSON( QgsFeature *feat, const createFeatureParams &params );

QDomElement createFeatureGML2( QgsFeature *feat, QDomDocument &doc, const createFeatureParams &params );
QDomElement createFeatureGML2( QgsFeature *feat, QDomDocument &doc, const createFeatureParams &params, const QgsProject *project );

QDomElement createFeatureGML3( QgsFeature *feat, QDomDocument &doc, const createFeatureParams &params );
QDomElement createFeatureGML3( QgsFeature *feat, QDomDocument &doc, const createFeatureParams &params, const QgsProject *project );

void hitGetFeature( const QgsServerRequest &request, QgsServerResponse &response, const QgsProject *project,
QgsWfsParameters::Format format, int numberOfFeatures, const QStringList &typeNames );
@@ -74,7 +74,7 @@ namespace QgsWfs
QgsRectangle *rect, const QStringList &typeNames );

void setGetFeature( QgsServerResponse &response, QgsWfsParameters::Format format, QgsFeature *feat, int featIdx,
const createFeatureParams &params );
const createFeatureParams &params, const QgsProject *project );

void endGetFeature( QgsServerResponse &response, QgsWfsParameters::Format format );

@@ -155,9 +155,7 @@ namespace QgsWfs
}
else
{
Q_NOWARN_DEPRECATED_PUSH
QgsCoordinateTransform transform( layer->crs(), requestCrs );
Q_NOWARN_DEPRECATED_POP
QgsCoordinateTransform transform( layer->crs(), requestCrs, project );
try
{
if ( requestRect.isEmpty() )
@@ -357,9 +355,7 @@ namespace QgsWfs

if ( !featureRequest.filterRect().isEmpty() )
{
Q_NOWARN_DEPRECATED_PUSH
QgsCoordinateTransform transform( outputCrs, vlayer->crs() );
Q_NOWARN_DEPRECATED_POP
QgsCoordinateTransform transform( outputCrs, vlayer->crs(), project );
try
{
featureRequest.setFilterRect( transform.transform( featureRequest.filterRect() ) );
@@ -405,7 +401,7 @@ namespace QgsWfs

if ( iteratedFeatures >= aRequest.startIndex )
{
setGetFeature( response, aRequest.outputFormat, &feature, sentFeatures, cfp );
setGetFeature( response, aRequest.outputFormat, &feature, sentFeatures, cfp, project );
++sentFeatures;
}
++iteratedFeatures;
@@ -1169,7 +1165,7 @@ namespace QgsWfs
}

void setGetFeature( QgsServerResponse &response, QgsWfsParameters::Format format, QgsFeature *feat, int featIdx,
const createFeatureParams &params )
const createFeatureParams &params, const QgsProject *project )
{
if ( !feat->isValid() )
return;
@@ -1196,12 +1192,12 @@ namespace QgsWfs
QDomElement featureElement;
if ( format == QgsWfsParameters::Format::GML3 )
{
featureElement = createFeatureGML3( feat, gmlDoc, params );
featureElement = createFeatureGML3( feat, gmlDoc, params, project );
gmlDoc.appendChild( featureElement );
}
else
{
featureElement = createFeatureGML2( feat, gmlDoc, params );
featureElement = createFeatureGML2( feat, gmlDoc, params, project );
gmlDoc.appendChild( featureElement );
}
response.write( gmlDoc.toByteArray() );
@@ -1255,7 +1251,7 @@ namespace QgsWfs
}


QDomElement createFeatureGML2( QgsFeature *feat, QDomDocument &doc, const createFeatureParams &params )
QDomElement createFeatureGML2( QgsFeature *feat, QDomDocument &doc, const createFeatureParams &params, const QgsProject *project )
{
//gml:FeatureMember
QDomElement featureElement = doc.createElement( QStringLiteral( "gml:featureMember" )/*wfs:FeatureMember*/ );
@@ -1271,9 +1267,7 @@ namespace QgsWfs
{
int prec = params.precision;
QgsCoordinateReferenceSystem crs = params.crs;
Q_NOWARN_DEPRECATED_PUSH
QgsCoordinateTransform mTransform( crs, params.outputCrs );
Q_NOWARN_DEPRECATED_POP
QgsCoordinateTransform mTransform( crs, params.outputCrs, project );
try
{
QgsGeometry transformed = geom;
@@ -1352,7 +1346,7 @@ namespace QgsWfs
return featureElement;
}

QDomElement createFeatureGML3( QgsFeature *feat, QDomDocument &doc, const createFeatureParams &params )
QDomElement createFeatureGML3( QgsFeature *feat, QDomDocument &doc, const createFeatureParams &params, const QgsProject *project )
{
//gml:FeatureMember
QDomElement featureElement = doc.createElement( QStringLiteral( "gml:featureMember" )/*wfs:FeatureMember*/ );
@@ -1368,9 +1362,7 @@ namespace QgsWfs
{
int prec = params.precision;
QgsCoordinateReferenceSystem crs = params.crs;
Q_NOWARN_DEPRECATED_PUSH
QgsCoordinateTransform mTransform( crs, params.outputCrs );
Q_NOWARN_DEPRECATED_POP
QgsCoordinateTransform mTransform( crs, params.outputCrs, project );
try
{
QgsGeometry transformed = geom;
@@ -61,11 +61,12 @@ namespace QgsWms
const QgsProject *project );

void appendLayerBoundingBox( QDomDocument &doc, QDomElement &layerElem, const QgsRectangle &layerExtent,
const QgsCoordinateReferenceSystem &layerCRS, const QString &crsText );
const QgsCoordinateReferenceSystem &layerCRS, const QString &crsText,
const QgsProject *project );

void appendLayerBoundingBoxes( QDomDocument &doc, QDomElement &layerElem, const QgsRectangle &lExtent,
const QgsCoordinateReferenceSystem &layerCRS, const QStringList &crsList,
const QStringList &constrainedCrsList );
const QStringList &constrainedCrsList, const QgsProject *project );

void appendCrsElementToLayer( QDomDocument &doc, QDomElement &layerElement, const QDomElement &precedingElement,
const QString &crsText );
@@ -1037,7 +1038,7 @@ namespace QgsWms
appendCrsElementsToLayer( doc, layerElem, crsList, outputCrsList );

//Ex_GeographicBoundingBox
appendLayerBoundingBoxes( doc, layerElem, l->extent(), l->crs(), crsList, outputCrsList );
appendLayerBoundingBoxes( doc, layerElem, l->extent(), l->crs(), crsList, outputCrsList, project );
}

// add details about supported styles of the layer
@@ -1291,7 +1292,7 @@ namespace QgsWms

void appendLayerBoundingBoxes( QDomDocument &doc, QDomElement &layerElem, const QgsRectangle &lExtent,
const QgsCoordinateReferenceSystem &layerCRS, const QStringList &crsList,
const QStringList &constrainedCrsList )
const QStringList &constrainedCrsList, const QgsProject *project )
{
if ( layerElem.isNull() )
{
@@ -1315,9 +1316,7 @@ namespace QgsWms
QgsRectangle wgs84BoundingRect;
if ( !layerExtent.isNull() )
{
Q_NOWARN_DEPRECATED_PUSH
QgsCoordinateTransform exGeoTransform( layerCRS, wgs84 );
Q_NOWARN_DEPRECATED_POP
QgsCoordinateTransform exGeoTransform( layerCRS, wgs84, project );
try
{
wgs84BoundingRect = exGeoTransform.transformBoundingBox( layerExtent );
@@ -1375,21 +1374,22 @@ namespace QgsWms
{
for ( int i = constrainedCrsList.size() - 1; i >= 0; --i )
{
appendLayerBoundingBox( doc, layerElem, layerExtent, layerCRS, constrainedCrsList.at( i ) );
appendLayerBoundingBox( doc, layerElem, layerExtent, layerCRS, constrainedCrsList.at( i ), project );
}
}
else //no crs constraint
{
Q_FOREACH ( const QString &crs, crsList )
{
appendLayerBoundingBox( doc, layerElem, layerExtent, layerCRS, crs );
appendLayerBoundingBox( doc, layerElem, layerExtent, layerCRS, crs, project );
}
}
}


void appendLayerBoundingBox( QDomDocument &doc, QDomElement &layerElem, const QgsRectangle &layerExtent,
const QgsCoordinateReferenceSystem &layerCRS, const QString &crsText )
const QgsCoordinateReferenceSystem &layerCRS, const QString &crsText,
const QgsProject *project )
{
if ( layerElem.isNull() )
{
@@ -1409,9 +1409,7 @@ namespace QgsWms
QgsRectangle crsExtent;
if ( !layerExtent.isNull() )
{
Q_NOWARN_DEPRECATED_PUSH
QgsCoordinateTransform crsTransform( layerCRS, crs );
Q_NOWARN_DEPRECATED_POP
QgsCoordinateTransform crsTransform( layerCRS, crs, project );
try
{
crsExtent = crsTransform.transformBoundingBox( layerExtent );
@@ -1524,9 +1522,7 @@ namespace QgsWms
}

//get project crs
Q_NOWARN_DEPRECATED_PUSH
QgsCoordinateTransform t( layerCrs, project->crs() );
Q_NOWARN_DEPRECATED_POP
QgsCoordinateTransform t( layerCrs, project->crs(), project );

//transform
try
@@ -1629,7 +1625,7 @@ namespace QgsWms
combinedBBox = mapRect;
}
}
appendLayerBoundingBoxes( doc, groupElem, combinedBBox, groupCRS, combinedCRSSet.toList(), outputCrsList );
appendLayerBoundingBoxes( doc, groupElem, combinedBBox, groupCRS, combinedCRSSet.toList(), outputCrsList, project );

}

@@ -405,9 +405,7 @@ namespace QgsWms
// update combineBBox
try
{
Q_NOWARN_DEPRECATED_PUSH
QgsCoordinateTransform t( l->crs(), project->crs() );
Q_NOWARN_DEPRECATED_POP
QgsCoordinateTransform t( l->crs(), project->crs(), project );
QgsRectangle BBox = t.transformBoundingBox( l->extent() );
if ( combinedBBox.isEmpty() )
{

0 comments on commit 29d280f

Please sign in to comment.
You can’t perform that action at this time.