Skip to content
Permalink
Browse files

Fix use of deprecated/removed coordinate transform constructor

  • Loading branch information
nyalldawson committed Apr 17, 2019
1 parent b6bc1ee commit bfe92c463273c03959644b66564539d776b2d93f
@@ -27,7 +27,7 @@ QgsDemTerrainGenerator::~QgsDemTerrainGenerator()
void QgsDemTerrainGenerator::setLayer( QgsRasterLayer *layer )
{
mLayer = QgsMapLayerRef( layer );
updateGenerator();
updateGenerator( mTransformContext );
}

QgsRasterLayer *QgsDemTerrainGenerator::layer() const
@@ -39,7 +39,7 @@ void QgsDemTerrainGenerator::setCrs( const QgsCoordinateReferenceSystem &crs, co
{
mCrs = crs;
mTransformContext = context;
updateGenerator();
updateGenerator( context );
}

QgsTerrainGenerator *QgsDemTerrainGenerator::clone() const
@@ -49,7 +49,7 @@ QgsTerrainGenerator *QgsDemTerrainGenerator::clone() const
cloned->mLayer = mLayer;
cloned->mResolution = mResolution;
cloned->mSkirtHeight = mSkirtHeight;
cloned->updateGenerator();
cloned->updateGenerator( mTransformContext );
return cloned;
}

@@ -93,15 +93,15 @@ void QgsDemTerrainGenerator::readXml( const QDomElement &elem )
void QgsDemTerrainGenerator::resolveReferences( const QgsProject &project )
{
mLayer = QgsMapLayerRef( project.mapLayer( mLayer.layerId ) );
updateGenerator();
updateGenerator( project.transformContext() );
}

QgsChunkLoader *QgsDemTerrainGenerator::createChunkLoader( QgsChunkNode *node ) const
{
return new QgsDemTerrainTileLoader( mTerrain, node );
}

void QgsDemTerrainGenerator::updateGenerator()
void QgsDemTerrainGenerator::updateGenerator( const QgsCoordinateTransformContext &transformContext )
{
QgsRasterLayer *dem = layer();
if ( dem )
@@ -112,7 +112,7 @@ void QgsDemTerrainGenerator::updateGenerator()

mTerrainTilingScheme = QgsTilingScheme( te, mCrs );
delete mHeightMapGenerator;
mHeightMapGenerator = new QgsDemHeightMapGenerator( dem, mTerrainTilingScheme, mResolution );
mHeightMapGenerator = new QgsDemHeightMapGenerator( dem, mTerrainTilingScheme, mResolution, transformContext );
}
else
{
@@ -72,7 +72,7 @@ class _3D_EXPORT QgsDemTerrainGenerator : public QgsTerrainGenerator
QgsChunkLoader *createChunkLoader( QgsChunkNode *node ) const override SIP_FACTORY;

private:
void updateGenerator();
void updateGenerator( const QgsCoordinateTransformContext &transformContext );

QgsDemHeightMapGenerator *mHeightMapGenerator = nullptr;

@@ -148,13 +148,13 @@ void QgsDemTerrainTileLoader::onHeightMapReady( int jobId, const QByteArray &hei
#include <QFutureWatcher>
#include "qgsterraindownloader.h"

QgsDemHeightMapGenerator::QgsDemHeightMapGenerator( QgsRasterLayer *dtm, const QgsTilingScheme &tilingScheme, int resolution )
QgsDemHeightMapGenerator::QgsDemHeightMapGenerator( QgsRasterLayer *dtm, const QgsTilingScheme &tilingScheme, int resolution, const QgsCoordinateTransformContext &transformContext )
: mDtm( dtm )
, mClonedProvider( dtm ? ( QgsRasterDataProvider * )dtm->dataProvider()->clone() : nullptr )
, mTilingScheme( tilingScheme )
, mResolution( resolution )
, mLastJobId( 0 )
, mDownloader( dtm ? nullptr : new QgsTerrainDownloader )
, mDownloader( dtm ? nullptr : new QgsTerrainDownloader( transformContext ) )
{
}

@@ -37,6 +37,7 @@

class QgsRasterDataProvider;
class QgsRasterLayer;
class QgsCoordinateTransformContext;

/**
* \ingroup 3d
@@ -80,7 +81,7 @@ class QgsDemHeightMapGenerator : public QObject
* Constructs height map generator based on a raster layer with elevation model,
* terrain's tiling scheme and height map resolution (number of height values on each side of tile)
*/
QgsDemHeightMapGenerator( QgsRasterLayer *dtm, const QgsTilingScheme &tilingScheme, int resolution );
QgsDemHeightMapGenerator( QgsRasterLayer *dtm, const QgsTilingScheme &tilingScheme, int resolution, const QgsCoordinateTransformContext &transformContext );
~QgsDemHeightMapGenerator() override;

//! asynchronous terrain read for a tile (array of floats)
@@ -21,16 +21,14 @@
#include "qgsgdalutils.h"


QgsTerrainDownloader::QgsTerrainDownloader()
QgsTerrainDownloader::QgsTerrainDownloader( const QgsCoordinateTransformContext &transformContext )
{
setDataSource( defaultDataSource() );

// the whole world is projected to a square:
// X going from 180 W to 180 E
// Y going from ~85 N to ~85 S (=atan(sinh(pi)) ... to get a square)
Q_NOWARN_DEPRECATED_PUSH
QgsCoordinateTransform ct( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:4326" ) ), QgsCoordinateReferenceSystem( "EPSG:3857" ) );
Q_NOWARN_DEPRECATED_POP
QgsCoordinateTransform ct( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:4326" ) ), QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3857" ) ), transformContext );
QgsPointXY topLeftLonLat( -180, 180.0 / M_PI * std::atan( std::sinh( M_PI ) ) );
QgsPointXY bottomRightLonLat( 180, 180.0 / M_PI * std::atan( std::sinh( -M_PI ) ) );
QgsPointXY topLeft = ct.transform( topLeftLonLat );
@@ -27,6 +27,7 @@
class QgsRectangle;
class QgsCoordinateReferenceSystem;
class QgsRasterLayer;
class QgsCoordinateTransformContext;

/**
* \ingroup 3d
@@ -43,7 +44,7 @@ class _3D_EXPORT QgsTerrainDownloader
{

public:
QgsTerrainDownloader();
QgsTerrainDownloader( const QgsCoordinateTransformContext &transformContext );
~QgsTerrainDownloader();

//! Definition of data source for terrain tiles (assuming "terrarium" data encoding with usual XYZ tiling scheme)

0 comments on commit bfe92c4

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