Skip to content
Permalink
Browse files
fix 3D mesh terrain when CRS are different from map
  • Loading branch information
vcloarec authored and nyalldawson committed Nov 1, 2021
1 parent 99e0efb commit 307943d0752b4af887dadb0a85392a3ec759024e
Showing with 3 additions and 21 deletions.
  1. +3 −21 src/3d/mesh/qgsmeshterraingenerator.cpp
@@ -72,7 +72,7 @@ float QgsMeshTerrainGenerator::rootChunkError( const Qgs3DMapSettings & ) const
void QgsMeshTerrainGenerator::rootChunkHeightRange( float &hMin, float &hMax ) const
{
float min = std::numeric_limits<float>::max();
float max = std::numeric_limits<float>::min();
float max = -std::numeric_limits<float>::max();

for ( int i = 0; i < mTriangularMesh.vertices().count(); ++i )
{
@@ -123,25 +123,7 @@ QgsTerrainGenerator::Type QgsMeshTerrainGenerator::type() const {return QgsTerra

QgsRectangle QgsMeshTerrainGenerator::extent() const
{
QgsRectangle layerextent;
if ( mLayer )
layerextent = mLayer->extent();
else
return QgsRectangle();

QgsCoordinateTransform terrainToMapTransform( mLayer->crs(), mCrs, mTransformContext );
QgsRectangle extentInMap;

try
{
extentInMap = terrainToMapTransform.transform( mLayer->extent() );
}
catch ( QgsCsException & )
{
extentInMap = mLayer->extent();
}

return extentInMap;
return mTriangularMesh.extent();
}

void QgsMeshTerrainGenerator::writeXml( QDomElement &elem ) const
@@ -182,7 +164,7 @@ void QgsMeshTerrainGenerator::updateTriangularMesh()
{
if ( meshLayer() )
{
QgsCoordinateTransform transform( mCrs, meshLayer()->crs(), mTransformContext );
const QgsCoordinateTransform transform( meshLayer()->crs(), mCrs, mTransformContext );
meshLayer()->updateTriangularMesh( transform );
mTriangularMesh = *meshLayer()->triangularMesh();
}

0 comments on commit 307943d

Please sign in to comment.