raster.diff
src/core/raster/qgsrasterlayer.cpp (working copy) | ||
---|---|---|
2732 | 2732 | |
2733 | 2733 |
void QgsRasterLayer::setMinimumMaximumUsingDataset() |
2734 | 2734 |
{ |
2735 |
double myMinMax[2]; |
|
2736 | 2735 |
if ( rasterType() == QgsRasterLayer::GrayOrUndefined || drawingStyle() == QgsRasterLayer::SingleBandGray || drawingStyle() == QgsRasterLayer::MultiBandSingleBandGray ) |
2737 | 2736 |
{ |
2738 | 2737 |
QgsRasterBandStats myRasterBandStats = bandStatistics( bandNumber( mGrayBandName ) ); |
... | ... | |
3182 | 3181 | |
3183 | 3182 |
if ( pkeyNode.isNull() ) |
3184 | 3183 |
{ |
3185 |
mProviderKey = ""; |
|
3184 |
mProviderKey = "gdal";
|
|
3186 | 3185 |
} |
3187 | 3186 |
else |
3188 | 3187 |
{ |
3189 | 3188 |
QDomElement pkeyElt = pkeyNode.toElement(); |
3190 | 3189 |
mProviderKey = pkeyElt.text(); |
3190 |
if ( mProviderKey.isEmpty() ) |
|
3191 |
{ |
|
3192 |
mProviderKey = "gdal"; |
|
3193 |
} |
|
3191 | 3194 |
} |
3192 | 3195 | |
3193 | 3196 |
// Open the raster source based on provider and datasource |
3194 | 3197 | |
3195 |
if ( !mProviderKey.isEmpty() ) |
|
3196 |
{ |
|
3197 |
// Go down the raster-data-provider paradigm |
|
3198 |
// Go down the raster-data-provider paradigm |
|
3198 | 3199 | |
3199 |
// Collect provider-specific information
|
|
3200 |
// Collect provider-specific information |
|
3200 | 3201 | |
3201 |
QDomNode rpNode = layer_node.namedItem( "rasterproperties" );
|
|
3202 |
QDomNode rpNode = layer_node.namedItem( "rasterproperties" ); |
|
3202 | 3203 | |
3203 |
// Collect sublayer names and styles |
|
3204 |
QStringList layers; |
|
3205 |
QStringList styles; |
|
3204 |
// Collect sublayer names and styles |
|
3205 |
QStringList layers; |
|
3206 |
QStringList styles; |
|
3207 |
QString format; |
|
3208 | ||
3209 |
if ( mProviderKey == "wms" ) |
|
3210 |
{ |
|
3206 | 3211 |
QDomElement layerElement = rpNode.firstChildElement( "wmsSublayer" ); |
3207 | 3212 |
while ( !layerElement.isNull() ) |
3208 | 3213 |
{ |
... | ... | |
3218 | 3223 |
} |
3219 | 3224 | |
3220 | 3225 |
// Collect format |
3221 |
QString format = rpNode.namedItem( "wmsFormat" ).toElement().text(); |
|
3222 | ||
3223 |
// Collect CRS |
|
3224 |
setDataProvider( mProviderKey, layers, styles, format, crs().authid() ); |
|
3226 |
format = rpNode.namedItem( "wmsFormat" ).toElement().text(); |
|
3225 | 3227 |
} |
3226 |
else |
|
3227 |
{ |
|
3228 |
// Go down the monolithic-gdal-provider paradigm |
|
3229 | 3228 | |
3230 |
if ( !readFile( source() ) ) // Data source name set in |
|
3231 |
// QgsMapLayer::readXML() |
|
3232 |
{ |
|
3233 |
QgsLogger::warning( QString( __FILE__ ) + ":" + QString( __LINE__ ) + |
|
3234 |
" unable to read from raster file " + source() ); |
|
3235 |
return false; |
|
3236 |
} |
|
3229 |
// Collect CRS |
|
3230 |
setDataProvider( mProviderKey, layers, styles, format, crs().authid() ); |
|
3237 | 3231 | |
3232 |
QString theError; |
|
3233 |
bool res = readSymbology( layer_node, theError ); |
|
3234 | ||
3235 |
// old wms settings we need to correct |
|
3236 |
if ( res && |
|
3237 |
mProviderKey == "wms" && |
|
3238 |
mDrawingStyle == MultiBandColor && |
|
3239 |
mRedBandName == TRSTRING_NOT_SET && |
|
3240 |
mGreenBandName == TRSTRING_NOT_SET && |
|
3241 |
mBlueBandName == TRSTRING_NOT_SET ) |
|
3242 |
{ |
|
3243 |
mDrawingStyle = SingleBandColorDataStyle; |
|
3244 |
mGrayBandName = bandName( 1 ); |
|
3238 | 3245 |
} |
3239 | 3246 | |
3240 |
QString theError; |
|
3241 |
return readSymbology( layer_node, theError ); |
|
3242 | ||
3247 |
return res; |
|
3243 | 3248 |
} // QgsRasterLayer::readXml( QDomNode & layer_node ) |
3244 | 3249 | |
3245 | 3250 |
/* |
... | ... | |
3254 | 3259 |
QDomElement rasterPropertiesElement = document.createElement( "rasterproperties" ); |
3255 | 3260 |
layer_node.appendChild( rasterPropertiesElement ); |
3256 | 3261 | |
3257 |
if ( !mProviderKey.isEmpty() ) |
|
3258 |
{ |
|
3259 |
QStringList sl = subLayers(); |
|
3260 |
QStringList sls = mDataProvider->subLayerStyles(); |
|
3262 |
QStringList sl = subLayers(); |
|
3263 |
QStringList sls = mDataProvider->subLayerStyles(); |
|
3261 | 3264 | |
3262 |
QStringList::const_iterator layerStyle = sls.begin();
|
|
3265 |
QStringList::const_iterator layerStyle = sls.begin(); |
|
3263 | 3266 | |
3267 |
if ( mProviderKey == "wms" ) |
|
3268 |
{ |
|
3264 | 3269 |
// <rasterproperties><wmsSublayer> |
3265 | 3270 |
for ( QStringList::const_iterator layerName = sl.begin(); |
3266 | 3271 |
layerName != sl.end(); |
... | ... | |
3297 | 3302 |
document.createTextNode( mDataProvider->imageEncoding() ); |
3298 | 3303 |
formatElement.appendChild( formatText ); |
3299 | 3304 |
rasterPropertiesElement.appendChild( formatElement ); |
3300 | ||
3301 | 3305 |
} |
3302 | 3306 | |
3303 | 3307 |
// <mDrawingStyle> |
src/core/qgsproject.cpp (working copy) | ||
---|---|---|
715 | 715 |
} |
716 | 716 | |
717 | 717 |
// have the layer restore state that is stored in Dom node |
718 |
if ( mapLayer->readXML( node ) ) |
|
718 |
if ( mapLayer->readXML( node ) && mapLayer->isValid() )
|
|
719 | 719 |
{ |
720 | 720 |
mapLayer = QgsMapLayerRegistry::instance()->addMapLayer( mapLayer ); |
721 | 721 |
QgsVectorLayer* vLayer = qobject_cast<QgsVectorLayer*>( mapLayer ); |
... | ... | |
746 | 746 |
vIt->first->createJoinCaches(); |
747 | 747 |
vIt->first->updateFieldMap(); |
748 | 748 |
//for old symbology, it is necessary to read the symbology again after having the complete field map |
749 |
if( !vIt->first->isUsingRendererV2() ) |
|
749 |
if ( !vIt->first->isUsingRendererV2() )
|
|
750 | 750 |
{ |
751 | 751 |
vIt->first->readSymbology( vIt->second, errorMessage ); |
752 | 752 |
} |
src/providers/gdal/qgsgdalprovider.cpp (working copy) | ||
---|---|---|
131 | 131 |
CPLErrorReset(); |
132 | 132 |
if ( mGdalBaseDataset == NULL ) |
133 | 133 |
{ |
134 |
QMessageBox::warning( 0, QObject::tr( "Warning" ), |
|
135 |
QObject::tr( "Cannot open GDAL dataset %1: %2" ).arg( uri ).arg( QString::fromUtf8( CPLGetLastErrorMsg() ) ) ); |
|
134 |
QgsDebugMsg( QString( "Cannot open GDAL dataset %1: %2" ).arg( uri ).arg( QString::fromUtf8( CPLGetLastErrorMsg() ) ) ); |
|
136 | 135 |
return; |
137 | 136 |
} |
138 | 137 | |
... | ... | |
301 | 300 |
//ifdefs below to remove compiler warning about unused vars |
302 | 301 |
#ifdef QGISDEBUG |
303 | 302 |
#if 0 |
304 |
int success;
|
|
305 |
double GDALminimum = GDALGetRasterMinimum( myGdalBand, &success );
|
|
303 |
int success; |
|
304 |
double GDALminimum = GDALGetRasterMinimum( myGdalBand, &success ); |
|
306 | 305 | |
307 |
if ( ! success )
|
|
308 |
{
|
|
309 |
QgsDebugMsg( "myGdalBand->GetMinimum() failed" );
|
|
310 |
}
|
|
306 |
if ( ! success ) |
|
307 |
{ |
|
308 |
QgsDebugMsg( "myGdalBand->GetMinimum() failed" ); |
|
309 |
} |
|
311 | 310 | |
312 |
double GDALmaximum = GDALGetRasterMaximum( myGdalBand, &success );
|
|
311 |
double GDALmaximum = GDALGetRasterMaximum( myGdalBand, &success ); |
|
313 | 312 | |
314 |
if ( ! success )
|
|
315 |
{
|
|
316 |
QgsDebugMsg( "myGdalBand->GetMaximum() failed" );
|
|
317 |
}
|
|
313 |
if ( ! success ) |
|
314 |
{ |
|
315 |
QgsDebugMsg( "myGdalBand->GetMaximum() failed" ); |
|
316 |
} |
|
318 | 317 | |
319 |
double GDALnodata = GDALGetRasterNoDataValue( myGdalBand, &success );
|
|
318 |
double GDALnodata = GDALGetRasterNoDataValue( myGdalBand, &success ); |
|
320 | 319 | |
321 |
if ( ! success )
|
|
322 |
{
|
|
323 |
QgsDebugMsg( "myGdalBand->GetNoDataValue() failed" );
|
|
324 |
}
|
|
320 |
if ( ! success ) |
|
321 |
{ |
|
322 |
QgsDebugMsg( "myGdalBand->GetNoDataValue() failed" ); |
|
323 |
} |
|
325 | 324 | |
326 |
QgsLogger::debug( "GDALminium: ", GDALminimum, __FILE__, __FUNCTION__, __LINE__ );
|
|
327 |
QgsLogger::debug( "GDALmaximum: ", GDALmaximum, __FILE__, __FUNCTION__, __LINE__ );
|
|
328 |
QgsLogger::debug( "GDALnodata: ", GDALnodata, __FILE__, __FUNCTION__, __LINE__ );
|
|
325 |
QgsLogger::debug( "GDALminium: ", GDALminimum, __FILE__, __FUNCTION__, __LINE__ ); |
|
326 |
QgsLogger::debug( "GDALmaximum: ", GDALmaximum, __FILE__, __FUNCTION__, __LINE__ ); |
|
327 |
QgsLogger::debug( "GDALnodata: ", GDALnodata, __FILE__, __FUNCTION__, __LINE__ ); |
|
329 | 328 | |
330 |
double GDALrange[2]; // calculated min/max, as opposed to the
|
|
331 |
// dataset provided
|
|
329 |
double GDALrange[2]; // calculated min/max, as opposed to the |
|
330 |
// dataset provided |
|
332 | 331 | |
333 |
GDALComputeRasterMinMax( myGdalBand, 1, GDALrange );
|
|
334 |
QgsLogger::debug( "approximate computed GDALminium:", GDALrange[0], __FILE__, __FUNCTION__, __LINE__, 1 );
|
|
335 |
QgsLogger::debug( "approximate computed GDALmaximum:", GDALrange[1], __FILE__, __FUNCTION__, __LINE__, 1 );
|
|
332 |
GDALComputeRasterMinMax( myGdalBand, 1, GDALrange ); |
|
333 |
QgsLogger::debug( "approximate computed GDALminium:", GDALrange[0], __FILE__, __FUNCTION__, __LINE__, 1 ); |
|
334 |
QgsLogger::debug( "approximate computed GDALmaximum:", GDALrange[1], __FILE__, __FUNCTION__, __LINE__, 1 ); |
|
336 | 335 | |
337 |
GDALComputeRasterMinMax( myGdalBand, 0, GDALrange );
|
|
338 |
QgsLogger::debug( "exactly computed GDALminium:", GDALrange[0] );
|
|
339 |
QgsLogger::debug( "exactly computed GDALmaximum:", GDALrange[1] );
|
|
336 |
GDALComputeRasterMinMax( myGdalBand, 0, GDALrange ); |
|
337 |
QgsLogger::debug( "exactly computed GDALminium:", GDALrange[0] ); |
|
338 |
QgsLogger::debug( "exactly computed GDALmaximum:", GDALrange[1] ); |
|
340 | 339 | |
341 |
QgsDebugMsg( "starting manual stat computation" );
|
|
340 |
QgsDebugMsg( "starting manual stat computation" ); |
|
342 | 341 |
#endif |
343 | 342 |
#endif |
344 | 343 | |
... | ... | |
1184 | 1183 | |
1185 | 1184 |
int QgsGdalProvider::bandCount() const |
1186 | 1185 |
{ |
1187 |
return GDALGetRasterCount( mGdalDataset ); |
|
1186 |
if ( mGdalDataset ) |
|
1187 |
return GDALGetRasterCount( mGdalDataset ); |
|
1188 |
else |
|
1189 |
return 1; |
|
1188 | 1190 |
} |
1189 | 1191 | |
1190 | 1192 |
int QgsGdalProvider::colorInterpretation( int theBandNo ) const |