Skip to content
Permalink
Browse files

Remove a bunch of disabled code

  • Loading branch information
nyalldawson committed Jun 15, 2018
1 parent ac17d30 commit eabd5c3b3dda0dd8032ef7e1bafb51d0ce2c8515
@@ -723,55 +723,6 @@ void QgsDiagramProperties::apply()
Qgis::Warning );
}

#if 0
bool scaleAttributeValueOk = false;
// Check if a (usable) scale attribute value is inserted
mValueLineEdit->text().toDouble( &scaleAttributeValueOk );

if ( !mFixedSizeRadio->isChecked() && !scaleAttributeValueOk )
{
double maxVal = DBL_MIN;
QgsVectorDataProvider *provider = mLayer->dataProvider();

if ( provider )
{
if ( diagramType == DIAGRAM_NAME_HISTOGRAM )
{
// Find maximum value
for ( int i = 0; i < mDiagramAttributesTreeWidget->topLevelItemCount(); ++i )
{
QString fldName = mDiagramAttributesTreeWidget->topLevelItem( i )->data( 0, Qt::UserRole ).toString();
if ( fldName.count() >= 2 && fldName.at( 0 ) == '"' && fldName.at( fldName.count() - 1 ) == '"' )
fldName = fldName.mid( 1, fldName.count() - 2 ); // remove enclosing double quotes
int fld = provider->fieldNameIndex( fldName );
if ( fld != -1 )
{
bool ok = false;
double val = provider->maximumValue( fld ).toDouble( &ok );
if ( ok )
maxVal = std::max( maxVal, val );
}
}
}
else
{
maxVal = provider->maximumValue( mSizeAttributeComboBox->currentData().toInt() ).toDouble();
}
}

if ( diagramsEnabled && maxVal != DBL_MIN )
{
QgisApp::instance()->messageBar()->pushMessage(
tr( "Interpolation value" ),
tr( "You did not specify an interpolation value. A default value of %1 has been set." ).arg( QString::number( maxVal ) ),
Qgis::Info,
5 );

mMaxValueSpinBox->setValue( maxVal );
}
}
#endif

if ( mDiagramType == DIAGRAM_NAME_TEXT )
{
diagram = new QgsTextDiagram();
@@ -1245,7 +1245,7 @@ double QgsGraduatedSymbolRenderer::minSymbolSize() const

double QgsGraduatedSymbolRenderer::maxSymbolSize() const
{
double max = DBL_MIN;
double max = std::numeric_limits<double>::min();
for ( int i = 0; i < mRanges.count(); i++ )
{
double sz = 0;
@@ -885,210 +885,6 @@ void QgsGdalProvider::readBlock( int bandNo, QgsRectangle const &extent, int pi
qgsFree( tmpBlock );
}

//void * QgsGdalProvider::readBlock( int bandNo, QgsRectangle const & extent, int width, int height )
//{
// return 0;
//}

// this is old version which was using GDALWarpOperation, unfortunately
// it may be very slow on large datasets
#if 0
void QgsGdalProvider::readBlock( int bandNo, QgsRectangle const &extent, int pixelWidth, int pixelHeight, void *block )
{
QgsDebugMsg( "thePixelWidth = " + QString::number( pixelWidth ) );
QgsDebugMsg( "thePixelHeight = " + QString::number( pixelHeight ) );
QgsDebugMsg( "theExtent: " + extent.toString() );

QString myMemDsn;
myMemDsn.sprintf( "DATAPOINTER = %p", block );
QgsDebugMsg( myMemDsn );

//myMemDsn.sprintf( "MEM:::DATAPOINTER=%lu,PIXELS=%d,LINES=%d,BANDS=1,DATATYPE=%s,PIXELOFFSET=0,LINEOFFSET=0,BANDOFFSET=0", ( long )block, pixelWidth, pixelHeight, GDALGetDataTypeName(( GDALDataType )mGdalDataType[bandNo-1] ) );
char szPointer[64];
memset( szPointer, 0, sizeof( szPointer ) );
CPLPrintPointer( szPointer, block, sizeof( szPointer ) );

myMemDsn.sprintf( "MEM:::DATAPOINTER=%s,PIXELS=%d,LINES=%d,BANDS=1,DATATYPE=%s,PIXELOFFSET=0,LINEOFFSET=0,BANDOFFSET=0", szPointer, pixelWidth, pixelHeight, GDALGetDataTypeName( ( GDALDataType )mGdalDataType[bandNo - 1] ) );

QgsDebugMsg( "Open GDAL MEM : " + myMemDsn );

CPLErrorReset();
GDALDatasetH myGdalMemDataset = GDALOpen( TO8F( myMemDsn ), GA_Update );

if ( !myGdalMemDataset )
{
QMessageBox::warning( 0, QObject::tr( "Warning" ),
QObject::tr( "Cannot open GDAL MEM dataset %1: %2" ).arg( myMemDsn ).arg( QString::fromUtf8( CPLGetLastErrorMsg() ) ) );
return;
}

//GDALSetProjection( myGdalMemDataset, destCRS.toWkt().toLatin1().constData() );

double myMemGeoTransform[6];
myMemGeoTransform[0] = extent.xMinimum(); // top left x
myMemGeoTransform[1] = extent.width() / pixelWidth; // w-e pixel resolution
myMemGeoTransform[2] = 0; // rotation, 0 if image is "north up"
myMemGeoTransform[3] = extent.yMaximum(); // top left y
myMemGeoTransform[4] = 0; // rotation, 0 if image is "north up"
myMemGeoTransform[5] = -1. * extent.height() / pixelHeight; // n-s pixel resolution

double myGeoTransform[6];
GDALGetGeoTransform( mGdalDataset, myGeoTransform );
// TODO:
// Attention: GDALCreateGenImgProjTransformer failes if source data source
// is not georeferenced, e.g. matrix 0,1,0,0,0,1/-1
// as a workaround in such case we have to set some different value - really ugly
myGeoTransform[0] = DBL_MIN;
GDALSetGeoTransform( mGdalDataset, myGeoTransform );

GDALSetGeoTransform( myGdalMemDataset, myMemGeoTransform );

for ( int i = 0; i < 6; i++ )
{
QgsDebugMsg( QString( "transform : %1 %2" ).arg( myGeoTransform[i] ).arg( myMemGeoTransform[i] ) );
}

GDALWarpOptions *myWarpOptions = GDALCreateWarpOptions();

myWarpOptions->hSrcDS = mGdalDataset;
myWarpOptions->hDstDS = myGdalMemDataset;

myWarpOptions->nBandCount = 1;
myWarpOptions->panSrcBands =
( int * ) qgsMalloc( sizeof( int ) * myWarpOptions->nBandCount );
myWarpOptions->panSrcBands[0] = bandNo;
myWarpOptions->panDstBands =
( int * ) qgsMalloc( sizeof( int ) * myWarpOptions->nBandCount );
myWarpOptions->panDstBands[0] = 1;

// TODO move here progressCallback and use it
myWarpOptions->pfnProgress = GDALTermProgress;

QgsDebugMsg( "src wkt: " + QString( GDALGetProjectionRef( mGdalDataset ) ) );
QgsDebugMsg( "dst wkt: " + QString( GDALGetProjectionRef( myGdalMemDataset ) ) );
myWarpOptions->pTransformerArg =
GDALCreateGenImgProjTransformer(
mGdalDataset,
nullptr,
myGdalMemDataset,
nullptr,
false, 0.0, 1
);
#if 0
myWarpOptions->pTransformerArg =
GDALCreateGenImgProjTransformer2(
mGdalDataset,
myGdalMemDataset,
nullptr
);
#endif
if ( !myWarpOptions->pTransformerArg )
{
QMessageBox::warning( 0, QObject::tr( "Warning" ),
QObject::tr( "Cannot GDALCreateGenImgProjTransformer: %1" ).arg( QString::fromUtf8( CPLGetLastErrorMsg() ) ); // missing word?
return;

}

//CPLAssert( myWarpOptions->pTransformerArg );
myWarpOptions->pfnTransformer = GDALGenImgProjTransform;

myWarpOptions->padfDstNoDataReal = ( double * ) qgsMalloc( myWarpOptions->nBandCount * sizeof( double ) );
myWarpOptions->padfDstNoDataImag = ( double * ) qgsMalloc( myWarpOptions->nBandCount * sizeof( double ) );

myWarpOptions->padfDstNoDataReal[0] = mNoDataValue[bandNo - 1];
myWarpOptions->padfDstNoDataImag[0] = 0.0;

GDALSetRasterNoDataValue( GDALGetRasterBand( myGdalMemDataset,
myWarpOptions->panDstBands[0] ),
myWarpOptions->padfDstNoDataReal[0] );

// TODO optimize somehow to avoid no data init if not necessary
// i.e. no projection, but there is also the problem with margine
myWarpOptions->papszWarpOptions =
CSLSetNameValue( myWarpOptions->papszWarpOptions, "INIT_DEST", "NO_DATA" );

myWarpOptions->eResampleAlg = GRA_NearestNeighbour;

GDALWarpOperation myOperation;

if ( myOperation.Initialize( myWarpOptions ) != CE_None )
{
QMessageBox::warning( 0, QObject::tr( "Warning" ),
QObject::tr( "Cannot initialize GDAL Warp operation : %1" ).arg( QString::fromUtf8( CPLGetLastErrorMsg() ) );
return;

}
CPLErrorReset();
CPLErr myErr;
myErr = myOperation.ChunkAndWarpImage( 0, 0, pixelWidth, pixelHeight );
if ( myErr != CPLE_None )
{
QMessageBox::warning( 0, QObject::tr( "Warning" ),
QObject::tr( "Cannot chunk and warp image: %1" ).arg( QString::fromUtf8( CPLGetLastErrorMsg() ) ) );
return;
}

GDALDestroyGenImgProjTransformer( myWarpOptions->pTransformerArg );
GDALDestroyWarpOptions( myWarpOptions );

// flush should not be necessary
//GDALFlushCache ( myGdalMemDataset );
// this was causing crash ???
// The MEM driver does not free() the memory passed as DATAPOINTER so we can closee the dataset
GDALClose( myGdalMemDataset );

}
#endif

#if 0
bool QgsGdalProvider::srcHasNoDataValue( int bandNo ) const
{
if ( mGdalDataset )
{
GDALRasterBandH myGdalBand = GDALGetRasterBand( mGdalDataset, bandNo );
if ( myGdalBand )
{
int ok;
GDALGetRasterNoDataValue( myGdalBand, &ok );
return ok;
}
}
return false;
}

double QgsGdalProvider::noDataValue() const
{
if ( !mNoDataValue.isEmpty() )
{
return mNoDataValue[0];
}
return std::numeric_limits<int>::max(); // should not happen or be used
}
#endif

#if 0
void QgsGdalProvider::computeMinMax( int bandNo ) const
{
QgsDebugMsg( QString( "theBandNo = %1 mMinMaxComputed = %2" ).arg( bandNo ).arg( mMinMaxComputed[bandNo - 1] ) );
if ( mMinMaxComputed[bandNo - 1] )
{
return;
}
GDALRasterBandH myGdalBand = GDALGetRasterBand( mGdalDataset, bandNo );
int bGotMin, bGotMax;
double adfMinMax[2];
adfMinMax[0] = GDALGetRasterMinimum( myGdalBand, &bGotMin );
adfMinMax[1] = GDALGetRasterMaximum( myGdalBand, &bGotMax );
if ( !( bGotMin && bGotMax ) )
{
GDALComputeRasterMinMax( myGdalBand, true, adfMinMax );
}
mMinimum[bandNo - 1] = adfMinMax[0];
mMaximum[bandNo - 1] = adfMinMax[1];
}
#endif

/**
* \param bandNumber the number of the band for which you want a color table
* \param list a pointer the object that will hold the color table

0 comments on commit eabd5c3

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