Skip to content

Commit 3109508

Browse files
author
rblazek
committed
merged raster-providers branch r15390
git-svn-id: http://svn.osgeo.org/qgis/trunk@15392 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 5bae2ab commit 3109508

27 files changed

+4593
-2404
lines changed

python/core/qgscoordinatetransform.sip

+3-3
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class QgsCoordinateTransform : QObject
6464
* Set the source (layer) QgsCoordinateReferenceSystem
6565
* @param theCRS QgsCoordinateReferenceSystem representation of the layer's coordinate system
6666
*/
67-
void setSourceCrs(const QgsCoordinateReferenceSystem& theCRS);
67+
void setSourceCrs( const QgsCoordinateReferenceSystem& theCRS );
6868

6969
/*!
7070
* Mutator for dest QgsCoordinateReferenceSystem
@@ -76,13 +76,13 @@ class QgsCoordinateTransform : QObject
7676
* Get the QgsCoordinateReferenceSystem representation of the layer's coordinate system
7777
* @return QgsCoordinateReferenceSystem of the layer's coordinate system
7878
*/
79-
QgsCoordinateReferenceSystem& sourceCrs();
79+
const QgsCoordinateReferenceSystem& sourceCrs();
8080

8181
/*!
8282
* Get the QgsCoordinateReferenceSystem representation of the map canvas coordinate system
8383
* @return QgsCoordinateReferenceSystem of the map canvas coordinate system
8484
*/
85-
QgsCoordinateReferenceSystem& destCRS();
85+
const QgsCoordinateReferenceSystem& destCRS();
8686

8787
/*! Transform the point from Source Coordinate System to Destination Coordinate System
8888
* If the direction is ForwardTransform then coordinates are transformed from layer CS --> map canvas CS,

python/core/qgsrasterviewport.sip

+19-10
Original file line numberDiff line numberDiff line change
@@ -7,36 +7,36 @@ struct QgsRasterViewPort
77

88
/** \brief The offset from the left hand edge of the raster for the rectangle that will be drawn to screen.
99
* TODO Check this explanation is correc!*/
10-
int rectXOffset;
11-
float rectXOffsetFloat;
10+
//int rectXOffset;
11+
//float rectXOffsetFloat;
1212
/** \brief The offset from the bottom edge of the raster for the rectangle that will be drawn to screen.
1313
* TODO Check this explanation is correc!*/
14-
int rectYOffset;
15-
float rectYOffsetFloat;
14+
//int rectYOffset;
15+
//float rectYOffsetFloat;
1616
/** \brief Lower left X dimension of clipped raster image in raster pixel space.
1717
* RasterIO will do the scaling for us, so for example, if the user is zoomed in a long way, there may only
1818
* be e.g. 5x5 pixels retrieved from the raw raster data, but rasterio will seamlessly scale the up to
1919
* whatever the screen coordinates are (e.g. a 600x800 display window) */
20-
double clippedXMin;
20+
//double clippedXMin;
2121
/** \brief Top Right X dimension of clipped raster image in raster pixel space.
2222
* RasterIO will do the scaling for us, so for example, if the user is zoomed in a long way, there may only
2323
* be e.g. 5x5 pixels retrieved from the raw raster data, but rasterio will seamlessly scale the up to
2424
* whatever the screen coordinates are (e.g. a 600x800 display window) */
25-
double clippedXMax;
25+
//double clippedXMax;
2626
/** \brief Lower left Y dimension of clipped raster image in raster pixel space.
2727
* RasterIO will do the scaling for us, so for example, if the user is zoomed in a long way, there may only
2828
* be e.g. 5x5 pixels retrieved from the raw raster data, but rasterio will seamlessly scale the up to
2929
* whatever the screen coordinates are (e.g. a 600x800 display window) */
30-
double clippedYMin;
30+
//double clippedYMin;
3131
/** \brief Top Right X dimension of clipped raster image in raster pixel space.
3232
* RasterIO will do the scaling for us, so for example, if the user is zoomed in a long way, there may only
3333
* be e.g. 5x5 pixels retrieved from the raw raster data, but rasterio will seamlessly scale the up to
3434
* whatever the screen coordinates are (e.g. a 600x800 display window) */
35-
double clippedYMax;
35+
//double clippedYMax;
3636
/** \brief Distance in pixels from clippedXMin to clippedXMax. */
37-
int clippedWidth;
37+
//int clippedWidth;
3838
/** \brief Distance in pixels from clippedYMin to clippedYMax */
39-
int clippedHeight;
39+
//int clippedHeight;
4040
/** \brief Coordinate (in geographic coordinate system) of top left corner of the part of the raster that
4141
* is to be rendered.*/
4242
QgsPoint topLeftPoint;
@@ -49,5 +49,14 @@ struct QgsRasterViewPort
4949
/** \brief Distance in map units from bottom edge to top edge for the part of the raster that
5050
* is to be rendered.*/
5151
int drawableAreaYDim;
52+
53+
// intersection of current map extent and layer extent
54+
QgsRectangle mDrawnExtent;
55+
56+
// Source coordinate system
57+
QgsCoordinateReferenceSystem mSrcCRS;
58+
59+
// Target coordinate system
60+
QgsCoordinateReferenceSystem mDestCRS;
5261
};
5362

src/app/qgsrasterlayerproperties.cpp

+75-63
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,6 @@ QgsRasterLayerProperties::QgsRasterLayerProperties( QgsMapLayer* lyr, QgsMapCanv
7171
mGrayMinimumMaximumEstimated = true;
7272
mRGBMinimumMaximumEstimated = true;
7373

74-
mRasterLayerIsInternal = mRasterLayer->dataProvider() == 0;
75-
7674
setupUi( this );
7775
connect( buttonBox, SIGNAL( accepted() ), this, SLOT( accept() ) );
7876
connect( this, SIGNAL( accepted() ), this, SLOT( apply() ) );
@@ -218,7 +216,7 @@ QgsRasterLayerProperties::QgsRasterLayerProperties( QgsMapLayer* lyr, QgsMapCanv
218216

219217

220218
// Only do pyramids if dealing directly with GDAL.
221-
if ( mRasterLayerIsInternal )
219+
if ( mRasterLayer->dataProvider()->capabilities() & QgsRasterDataProvider::BuildPyramids )
222220
{
223221
QgsRasterLayer::RasterPyramidList myPyramidList = mRasterLayer->buildPyramidList();
224222
QgsRasterLayer::RasterPyramidList::iterator myRasterPyramidIterator;
@@ -518,19 +516,25 @@ void QgsRasterLayerProperties::sync()
518516
break;
519517
}
520518

521-
if ( !mRasterLayerIsInternal )
519+
if ( mRasterLayer->dataProvider()->dataType(1) == QgsRasterDataProvider::ARGBDataType )
522520
{
523521
delete tabPageSymbology;
524522
delete tabPageColormap;
525-
delete tabPagePyramids;
526-
delete tabPageHistogram;
527-
528523
gboxNoDataValue->setEnabled( false );
529524
gboxCustomTransparency->setEnabled( false );
530-
531525
tabBar->setCurrentWidget( tabPageMetadata );
532526
}
533527

528+
if ( ! ( mRasterLayer->dataProvider()->capabilities() & QgsRasterDataProvider::BuildPyramids ) )
529+
{
530+
delete tabPagePyramids;
531+
}
532+
533+
if ( ! ( mRasterLayer->dataProvider()->capabilities() & QgsRasterDataProvider::Histogram ) )
534+
{
535+
delete tabPageHistogram;
536+
}
537+
534538
#if 0
535539
if ( mRasterLayer->rasterType() == QgsRasterLayer::Multiband )
536540
{
@@ -558,35 +562,38 @@ void QgsRasterLayerProperties::sync()
558562
//
559563
// Populate the various controls on the form
560564
//
561-
QgsDebugMsg( "colorShadingAlgorithm = " + QString::number( mRasterLayer->colorShadingAlgorithm() ) );
562-
if ( mRasterLayer->drawingStyle() == QgsRasterLayer::SingleBandPseudoColor ||
563-
mRasterLayer->drawingStyle() == QgsRasterLayer::PalettedColor ||
564-
mRasterLayer->drawingStyle() == QgsRasterLayer::PalettedSingleBandPseudoColor ||
565-
mRasterLayer->drawingStyle() == QgsRasterLayer::MultiBandSingleBandPseudoColor )
566-
{
567-
if ( mRasterLayer->colorShadingAlgorithm() == QgsRasterLayer::PseudoColorShader )
568-
{
569-
cboxColorMap->setCurrentIndex( cboxColorMap->findText( tr( "Pseudocolor" ) ) );
570-
}
571-
else if ( mRasterLayer->colorShadingAlgorithm() == QgsRasterLayer::FreakOutShader )
572-
{
573-
cboxColorMap->setCurrentIndex( cboxColorMap->findText( tr( "Freak Out" ) ) );
574-
}
575-
else if ( mRasterLayer->colorShadingAlgorithm() == QgsRasterLayer::ColorRampShader )
576-
{
577-
cboxColorMap->setCurrentIndex( cboxColorMap->findText( tr( "Colormap" ) ) );
565+
if ( mRasterLayer->dataProvider()->dataType(1) != QgsRasterDataProvider::ARGBDataType )
566+
{
567+
QgsDebugMsg( "colorShadingAlgorithm = " + QString::number( mRasterLayer->colorShadingAlgorithm() ) );
568+
if ( mRasterLayer->drawingStyle() == QgsRasterLayer::SingleBandPseudoColor ||
569+
mRasterLayer->drawingStyle() == QgsRasterLayer::PalettedColor ||
570+
mRasterLayer->drawingStyle() == QgsRasterLayer::PalettedSingleBandPseudoColor ||
571+
mRasterLayer->drawingStyle() == QgsRasterLayer::MultiBandSingleBandPseudoColor )
572+
{
573+
if ( mRasterLayer->colorShadingAlgorithm() == QgsRasterLayer::PseudoColorShader )
574+
{
575+
cboxColorMap->setCurrentIndex( cboxColorMap->findText( tr( "Pseudocolor" ) ) );
576+
}
577+
else if ( mRasterLayer->colorShadingAlgorithm() == QgsRasterLayer::FreakOutShader )
578+
{
579+
cboxColorMap->setCurrentIndex( cboxColorMap->findText( tr( "Freak Out" ) ) );
580+
}
581+
else if ( mRasterLayer->colorShadingAlgorithm() == QgsRasterLayer::ColorRampShader )
582+
{
583+
cboxColorMap->setCurrentIndex( cboxColorMap->findText( tr( "Colormap" ) ) );
584+
}
585+
else if ( mRasterLayer->colorShadingAlgorithm() == QgsRasterLayer::UserDefinedShader )
586+
{
587+
cboxColorMap->setCurrentIndex( cboxColorMap->findText( tr( "User Defined" ) ) );
588+
}
578589
}
579-
else if ( mRasterLayer->colorShadingAlgorithm() == QgsRasterLayer::UserDefinedShader )
590+
else
580591
{
581-
cboxColorMap->setCurrentIndex( cboxColorMap->findText( tr( "User Defined" ) ) );
592+
cboxColorMap->setCurrentIndex( cboxColorMap->findText( tr( "Grayscale" ) ) );
582593
}
583594
}
584-
else if ( mRasterLayerIsInternal )
585-
{
586-
cboxColorMap->setCurrentIndex( cboxColorMap->findText( tr( "Grayscale" ) ) );
587-
}
588595

589-
if ( mRasterLayerIsInternal )
596+
if ( mRasterLayer->dataProvider()->dataType(1) != QgsRasterDataProvider::ARGBDataType )
590597
{
591598
if ( rbtnThreeBand->isChecked() )
592599
{
@@ -774,10 +781,24 @@ void QgsRasterLayerProperties::sync()
774781
leDisplayName->setText( mRasterLayer->name() );
775782

776783
//display the raster dimensions and no data value
777-
if ( mRasterLayerIsInternal )
778-
{
784+
if ( mRasterLayer->dataProvider()->capabilities() & QgsRasterDataProvider::Size )
785+
{
779786
lblColumns->setText( tr( "Columns: %1" ).arg( mRasterLayer->width() ) );
780787
lblRows->setText( tr( "Rows: %1" ).arg( mRasterLayer->height() ) );
788+
}
789+
else
790+
{
791+
// TODO: Account for fixedWidth and fixedHeight WMS layers
792+
lblColumns->setText( tr( "Columns: " ) + tr( "n/a" ) );
793+
lblRows->setText( tr( "Rows: " ) + tr( "n/a" ) );
794+
}
795+
796+
if ( mRasterLayer->dataProvider()->dataType(1) == QgsRasterDataProvider::ARGBDataType )
797+
{
798+
lblNoData->setText( tr( "No-Data Value: " ) + tr( "n/a" ) );
799+
}
800+
else
801+
{
781802
if ( mRasterLayer->isNoDataValueValid() )
782803
{
783804
lblNoData->setText( tr( "No-Data Value: %1" ).arg( mRasterLayer->noDataValue() ) );
@@ -787,13 +808,6 @@ void QgsRasterLayerProperties::sync()
787808
lblNoData->setText( tr( "No-Data Value: Not Set" ) );
788809
}
789810
}
790-
else
791-
{
792-
// TODO: Account for fixedWidth and fixedHeight WMS layers
793-
lblColumns->setText( tr( "Columns: " ) + tr( "n/a" ) );
794-
lblRows->setText( tr( "Rows: " ) + tr( "n/a" ) );
795-
lblNoData->setText( tr( "No-Data Value: " ) + tr( "n/a" ) );
796-
}
797811

798812
//get the thumbnail for the layer
799813
QPixmap myQPixmap = QPixmap( pixmapThumbnail->width(), pixmapThumbnail->height() );
@@ -824,12 +838,12 @@ void QgsRasterLayerProperties::sync()
824838
void QgsRasterLayerProperties::syncColormapTab()
825839
{
826840
QgsDebugMsg( "populate color ramp tab" );
827-
if ( !mRasterLayerIsInternal )
841+
if ( !mRasterLayer || !mRasterLayer->dataProvider() )
828842
{
829843
return;
830844
}
831845

832-
if ( !mRasterLayer )
846+
if ( mRasterLayer->dataProvider()->dataType(1) == QgsRasterDataProvider::ARGBDataType )
833847
{
834848
return;
835849
}
@@ -921,7 +935,7 @@ bool QgsRasterLayerProperties::validUserDefinedMinMax()
921935
*/
922936
void QgsRasterLayerProperties::apply()
923937
{
924-
if ( mRasterLayerIsInternal )
938+
if ( mRasterLayer->dataProvider()->dataType(1) != QgsRasterDataProvider::ARGBDataType )
925939
{
926940
QgsDebugMsg( "apply processing symbology tab" );
927941
/*
@@ -1411,7 +1425,7 @@ void QgsRasterLayerProperties::apply()
14111425
mRasterLayer->triggerRepaint();
14121426

14131427
//Because Min Max values can be set during the redraw if a strech is requested we need to resync after apply
1414-
if ( mRasterLayerIsInternal )
1428+
if ( mRasterLayer->dataProvider()->dataType(1) != QgsRasterDataProvider::ARGBDataType )
14151429
{
14161430
if ( QgsContrastEnhancement::NoEnhancement != mRasterLayer->contrastEnhancementAlgorithm() )
14171431
{
@@ -1581,7 +1595,7 @@ void QgsRasterLayerProperties::on_buttonBuildPyramids_clicked()
15811595

15821596
void QgsRasterLayerProperties::on_cboBlue_currentIndexChanged( const QString& theText )
15831597
{
1584-
if ( mRasterLayerIsInternal && TRSTRING_NOT_SET != theText )
1598+
if ( TRSTRING_NOT_SET != theText )
15851599
{
15861600
leBlueMin->setText( QString::number( mRasterLayer->minimumValue( theText ) ) );
15871601
leBlueMax->setText( QString::number( mRasterLayer->maximumValue( theText ) ) );
@@ -1590,7 +1604,7 @@ void QgsRasterLayerProperties::on_cboBlue_currentIndexChanged( const QString& th
15901604

15911605
void QgsRasterLayerProperties::on_cboGray_currentIndexChanged( const QString& theText )
15921606
{
1593-
if ( mRasterLayerIsInternal && TRSTRING_NOT_SET != theText )
1607+
if ( TRSTRING_NOT_SET != theText )
15941608
{
15951609
leGrayMin->setText( QString::number( mRasterLayer->minimumValue( theText ) ) );
15961610
leGrayMax->setText( QString::number( mRasterLayer->maximumValue( theText ) ) );
@@ -1599,7 +1613,7 @@ void QgsRasterLayerProperties::on_cboGray_currentIndexChanged( const QString& th
15991613

16001614
void QgsRasterLayerProperties::on_cboGreen_currentIndexChanged( const QString& theText )
16011615
{
1602-
if ( mRasterLayerIsInternal && TRSTRING_NOT_SET != theText )
1616+
if ( TRSTRING_NOT_SET != theText )
16031617
{
16041618
leGreenMin->setText( QString::number( mRasterLayer->minimumValue( theText ) ) );
16051619
leGreenMax->setText( QString::number( mRasterLayer->maximumValue( theText ) ) );
@@ -1608,7 +1622,7 @@ void QgsRasterLayerProperties::on_cboGreen_currentIndexChanged( const QString& t
16081622

16091623
void QgsRasterLayerProperties::on_cboRed_currentIndexChanged( const QString& theText )
16101624
{
1611-
if ( mRasterLayerIsInternal && TRSTRING_NOT_SET != theText )
1625+
if ( TRSTRING_NOT_SET != theText )
16121626
{
16131627
leRedMin->setText( QString::number( mRasterLayer->minimumValue( theText ) ) );
16141628
leRedMax->setText( QString::number( mRasterLayer->maximumValue( theText ) ) );
@@ -1654,8 +1668,10 @@ void QgsRasterLayerProperties::on_pbnChangeSpatialRefSys_clicked()
16541668

16551669
void QgsRasterLayerProperties::on_cboxColorMap_currentIndexChanged( const QString& theText )
16561670
{
1657-
if ( !mRasterLayerIsInternal )
1671+
if ( mRasterLayer->dataProvider()->dataType(1) == QgsRasterDataProvider::ARGBDataType )
1672+
{
16581673
return;
1674+
}
16591675

16601676
if ( theText == tr( "Pseudocolor" ) || theText == tr( "Freak Out" ) )
16611677
{
@@ -2570,10 +2586,9 @@ void QgsRasterLayerProperties::on_pbtnLoadColorMapFromFile_clicked()
25702586

25712587
void QgsRasterLayerProperties::on_pbtnLoadMinMax_clicked()
25722588
{
2573-
if ( mRasterLayerIsInternal &&
2574-
( mRasterLayer->drawingStyle() == QgsRasterLayer::SingleBandGray
2589+
if ( mRasterLayer->drawingStyle() == QgsRasterLayer::SingleBandGray
25752590
|| mRasterLayer->drawingStyle() == QgsRasterLayer::MultiBandSingleBandGray
2576-
|| mRasterLayer->drawingStyle() == QgsRasterLayer::MultiBandColor ) )
2591+
|| mRasterLayer->drawingStyle() == QgsRasterLayer::MultiBandColor )
25772592
{
25782593
QgsRasterBandStats myRasterBandStats;
25792594
double myMinimumMaximum[2];
@@ -2994,16 +3009,13 @@ void QgsPixelSelectorTool::canvasReleaseEvent( QMouseEvent* theMouseEvent )
29943009
void QgsRasterLayerProperties::on_btnResetNull_clicked( )
29953010
{
29963011
//If reset NoDataValue is checked do this first, will ignore what ever is in the LineEdit
2997-
if ( mRasterLayerIsInternal )
3012+
mRasterLayer->resetNoDataValue();
3013+
if ( mRasterLayer->isNoDataValueValid() )
29983014
{
2999-
mRasterLayer->resetNoDataValue();
3000-
if ( mRasterLayer->isNoDataValueValid() )
3001-
{
3002-
leNoDataValue->setText( QString::number( mRasterLayer->noDataValue(), 'f' ) );
3003-
}
3004-
else
3005-
{
3006-
leNoDataValue->clear();
3007-
}
3015+
leNoDataValue->setText( QString::number( mRasterLayer->noDataValue(), 'f' ) );
3016+
}
3017+
else
3018+
{
3019+
leNoDataValue->clear();
30083020
}
30093021
}

src/app/qgsrasterlayerproperties.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ class QgsRasterLayerProperties : public QDialog, private Ui::QgsRasterLayerPrope
185185
This variable is used to determine if various parts of the Properties UI are
186186
included or not
187187
*/
188-
bool mRasterLayerIsInternal;
188+
//bool mRasterLayerIsInternal;
189189

190190
/** \brief Clear current color map table and population with values from new list */
191191
void populateColorMapTable( const QList<QgsColorRampShader::ColorRampItem>& );

src/core/CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ SET(QGIS_CORE_SRCS
7676
qgsproviderextentcalcevent.cpp
7777
qgsprovidermetadata.cpp
7878
qgsproviderregistry.cpp
79+
qgsrasterprojector.cpp
7980
qgsrasterdataprovider.cpp
8081
qgsrendercontext.cpp
8182
qgsrectangle.cpp
@@ -408,6 +409,7 @@ SET(QGIS_CORE_HDRS
408409
qgsproviderextentcalcevent.h
409410
qgsprovidermetadata.h
410411
qgsproviderregistry.h
412+
qgsrasterprojector.h
411413
qgsrasterdataprovider.h
412414
qgsrectangle.h
413415
qgsrendercontext.h

src/core/qgscoordinatetransform.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,13 @@ class CORE_EXPORT QgsCoordinateTransform: public QObject
111111
* Get the QgsCoordinateReferenceSystem representation of the layer's coordinate system
112112
* @return QgsCoordinateReferenceSystem of the layer's coordinate system
113113
*/
114-
QgsCoordinateReferenceSystem& sourceCrs() { return mSourceCRS; }
114+
const QgsCoordinateReferenceSystem& sourceCrs() const { return mSourceCRS; }
115115

116116
/*!
117117
* Get the QgsCoordinateReferenceSystem representation of the map canvas coordinate system
118118
* @return QgsCoordinateReferenceSystem of the map canvas coordinate system
119119
*/
120-
QgsCoordinateReferenceSystem& destCRS() { return mDestCRS; }
120+
const QgsCoordinateReferenceSystem& destCRS() const { return mDestCRS; }
121121

122122
/*! Transform the point from Source Coordinate System to Destination Coordinate System
123123
* If the direction is ForwardTransform then coordinates are transformed from layer CS --> map canvas CS,

0 commit comments

Comments
 (0)