int QgsAlignRaster::suggestedReferenceLayer() const { int bestIndex = -1; double bestCellArea = qInf(); QSizeF cs; int i = 0; // using WGS84 as a destination CRS... but maybe some projected CRS // would be a better a choice to more accurately compute areas? // (Why earth is not flat???) QgsCoordinateReferenceSystem destCRS( "EPSG:4326" ); QString destWkt = destCRS.toWkt(); foreach ( const Item& raster, mRasters ) { if ( !suggestedWarpOutput( RasterInfo( raster.inputFilename ), destWkt, &cs ) ) return false; double cellArea = cs.width() * cs.height(); if ( cellArea < bestCellArea ) { bestCellArea = cellArea; bestIndex = i; } ++i; } return bestIndex; }
QgsCoordinateTransform* QgsCoordinateTransform::clone() const { QgsCoordinateTransform* tr = new QgsCoordinateTransform( sourceCrs(), destCRS() ); tr->setSourceDatumTransform( sourceDatumTransform() ); tr->setDestinationDatumTransform( destinationDatumTransform() ); tr->initialise(); return tr; }
QgsPointLocator* QgsSnappingUtils::temporaryLocatorForLayer( QgsVectorLayer* vl, const QgsPoint& pointMap, double tolerance ) { if ( mTemporaryLocators.contains( vl ) ) delete mTemporaryLocators.take( vl ); QgsRectangle rect( pointMap.x() - tolerance, pointMap.y() - tolerance, pointMap.x() + tolerance, pointMap.y() + tolerance ); QgsPointLocator* vlpl = new QgsPointLocator( vl, destCRS(), &rect ); mTemporaryLocators.insert( vl, vlpl ); return mTemporaryLocators.value( vl ); }
QgsPointLocator* QgsSnappingUtils::locatorForLayer( QgsVectorLayer* vl ) { if ( !vl ) return nullptr; if ( !mLocators.contains( vl ) ) { QgsPointLocator* vlpl = new QgsPointLocator( vl, destCRS() ); mLocators.insert( vl, vlpl ); } return mLocators.value( vl ); }