std::unique_ptr<QgsMeshCalculator> QgsMeshCalculatorDialog::calculator() const { std::unique_ptr<QgsMeshCalculator> calc; if ( useExtentCb->isChecked() ) { calc.reset( new QgsMeshCalculator( formulaString(), outputFile(), outputExtent(), startTime(), endTime(), meshLayer() ) ); } else { calc.reset( new QgsMeshCalculator( formulaString(), outputFile(), maskGeometry(), startTime(), endTime(), meshLayer() ) ); } return calc; }
void QgsExtentGroupBox::setOutputExtentFromLineEdit() { mExtentState = UserExtent; updateTitle(); emit extentChanged( outputExtent() ); }
void QgsExtentGroupBox::setOutputCrs( const QgsCoordinateReferenceSystem &outputCrs ) { if ( mOutputCrs != outputCrs ) { switch ( mExtentState ) { case CurrentExtent: mOutputCrs = outputCrs; setOutputExtentFromCurrent(); break; case OriginalExtent: mOutputCrs = outputCrs; setOutputExtentFromOriginal(); break; case ProjectLayerExtent: mOutputCrs = outputCrs; setOutputExtentFromLayer( mExtentLayer.data() ); break; case DrawOnCanvas: mOutputCrs = outputCrs; extentDrawn( outputExtent() ); break; case UserExtent: try { QgsCoordinateTransform ct( mOutputCrs, outputCrs ); QgsRectangle extent = ct.transformBoundingBox( outputExtent() ); mOutputCrs = outputCrs; setOutputExtentFromUser( extent, outputCrs ); } catch ( QgsCsException & ) { // can't reproject mOutputCrs = outputCrs; } break; } } }
void QgsExtentGroupBox::groupBoxClicked() { if ( !isCheckable() ) return; updateTitle(); // output extent just went from null to something (or vice versa) emit extentChanged( outputExtent() ); }
void TestQgsGdalUtils::testResampleSingleBandRaster() { QString inputFilename = QString( TEST_DATA_DIR ) + "/float1-16.tif"; gdal::dataset_unique_ptr srcDS( GDALOpen( inputFilename.toUtf8().constData(), GA_ReadOnly ) ); QVERIFY( srcDS ); QString outputFilename = QDir::tempPath() + "/qgis_test_float1-16_resampled.tif"; QgsRectangle outputExtent( 106.25, -6.75, 106.55, -6.45 ); gdal::dataset_unique_ptr dstDS = QgsGdalUtils::createSingleBandTiffDataset( outputFilename, GDT_Float32, outputExtent, 2, 2, QgsCoordinateReferenceSystem( "EPSG:4326" ) ); QVERIFY( dstDS ); QgsGdalUtils::resampleSingleBandRaster( srcDS.get(), dstDS.get(), GRA_NearestNeighbour ); dstDS.reset(); std::unique_ptr<QgsRasterLayer> layer( new QgsRasterLayer( outputFilename, "test", "gdal" ) ); QVERIFY( layer ); std::unique_ptr<QgsRasterBlock> block( layer->dataProvider()->block( 1, outputExtent, 2, 2 ) ); QVERIFY( block ); QCOMPARE( block->value( 0, 0 ), 6. ); QCOMPARE( block->value( 1, 1 ), 11. ); layer.reset(); QFile::remove( outputFilename ); }