1 |
|
/* **************************************************************************
|
|
1 |
/***************************************************************************
|
2 |
2 |
qgsrasterlayer.cpp - description
|
3 |
3 |
-------------------
|
4 |
4 |
begin : Sat Jun 22 2002
|
... | ... | |
89 |
89 |
mHeight( std::numeric_limits<int>::max() ),
|
90 |
90 |
mInvertColor( false )
|
91 |
91 |
{
|
|
92 |
mIgnoreGeoTransform = false;
|
|
93 |
mIgnoreGCPs = false;
|
92 |
94 |
|
|
95 |
constructRasterLayer(path, baseName, loadDefaultStyleFlag);
|
|
96 |
}
|
|
97 |
|
|
98 |
QgsRasterLayer::QgsRasterLayer(
|
|
99 |
QString const & path,
|
|
100 |
QString const & baseName,
|
|
101 |
bool loadDefaultStyleFlag,
|
|
102 |
bool ignoreGeoTransform,
|
|
103 |
bool ignoreGCPs )
|
|
104 |
: QgsMapLayer( RasterLayer, baseName, path ),
|
|
105 |
// Constant that signals property not used.
|
|
106 |
QSTRING_NOT_SET( "Not Set" ),
|
|
107 |
TRSTRING_NOT_SET( tr( "Not Set" ) ),
|
|
108 |
mStandardDeviations( 0 ),
|
|
109 |
mDataProvider( 0 ),
|
|
110 |
mWidth( std::numeric_limits<int>::max() ),
|
|
111 |
mHeight( std::numeric_limits<int>::max() ),
|
|
112 |
mInvertColor( false )
|
|
113 |
{
|
|
114 |
mIgnoreGeoTransform = ignoreGeoTransform;
|
|
115 |
mIgnoreGCPs = ignoreGCPs;
|
|
116 |
|
|
117 |
constructRasterLayer(path, baseName, loadDefaultStyleFlag);
|
|
118 |
}
|
|
119 |
|
|
120 |
void QgsRasterLayer::constructRasterLayer( QString const & path, QString const & baseName, bool loadDefaultStyleFlag )
|
|
121 |
{
|
93 |
122 |
mRasterType = QgsRasterLayer::GrayOrUndefined;
|
94 |
123 |
|
95 |
124 |
mRedBandName = TRSTRING_NOT_SET;
|
... | ... | |
208 |
237 |
{
|
209 |
238 |
setDataProvider( providerKey, layers, styles, format, crs );
|
210 |
239 |
}
|
|
240 |
|
|
241 |
mIgnoreGeoTransform = false;
|
|
242 |
mIgnoreGCPs = false;
|
211 |
243 |
|
212 |
244 |
// Default for the popup menu
|
213 |
245 |
// TODO: popMenu = 0;
|
... | ... | |
2723 |
2755 |
|
2724 |
2756 |
if ( mProviderKey.isEmpty() )
|
2725 |
2757 |
{
|
2726 |
|
if ( GDALGetGeoTransform( mGdalDataset, mGeoTransform ) != CE_None )
|
|
2758 |
if ( getGeoTransform( mGdalDataset, mGeoTransform) )
|
2727 |
2759 |
{
|
2728 |
|
// if the raster does not have a valid transform we need to use
|
2729 |
|
// a pixel size of (1,-1), but GDAL returns (1,1)
|
2730 |
|
mGeoTransform[5] = -1;
|
2731 |
|
}
|
2732 |
|
else
|
2733 |
|
{
|
2734 |
2760 |
myMetadata += "<p class=\"glossy\">";
|
2735 |
2761 |
myMetadata += tr( "Origin:" );
|
2736 |
2762 |
myMetadata += "</p>\n";
|
... | ... | |
5173 |
5199 |
mLastModified = lastModified( theFilename );
|
5174 |
5200 |
|
5175 |
5201 |
// Check if we need a warped VRT for this file.
|
5176 |
|
if (( GDALGetGeoTransform( mGdalBaseDataset, mGeoTransform ) == CE_None
|
5177 |
|
&& ( mGeoTransform[1] < 0.0
|
5178 |
|
|| mGeoTransform[2] != 0.0
|
5179 |
|
|| mGeoTransform[4] != 0.0
|
5180 |
|
|| mGeoTransform[5] > 0.0 ) )
|
5181 |
|
|| GDALGetGCPCount( mGdalBaseDataset ) > 0 )
|
|
5202 |
if ( ( getGeoTransform( mGdalBaseDataset, mGeoTransform )
|
|
5203 |
&& ( mGeoTransform[1] < 0.0
|
|
5204 |
|| mGeoTransform[2] != 0.0
|
|
5205 |
|| mGeoTransform[4] != 0.0
|
|
5206 |
|| mGeoTransform[5] > 0.0 ) )
|
|
5207 |
|| ( !mIgnoreGCPs && GDALGetGCPCount( mGdalBaseDataset ) > 0 ) )
|
5182 |
5208 |
{
|
5183 |
5209 |
QgsLogger::warning( "Creating Warped VRT." );
|
5184 |
5210 |
|
... | ... | |
5198 |
5224 |
GDALReferenceDataset( mGdalDataset );
|
5199 |
5225 |
}
|
5200 |
5226 |
|
5201 |
|
//check f this file has pyramids
|
|
5227 |
//check if this file has pyramids
|
5202 |
5228 |
GDALRasterBandH myGDALBand = GDALGetRasterBand( mGdalDataset, 1 ); //just use the first band
|
5203 |
5229 |
if ( myGDALBand == NULL )
|
5204 |
5230 |
{
|
... | ... | |
5813 |
5839 |
}
|
5814 |
5840 |
}
|
5815 |
5841 |
}
|
|
5842 |
|
|
5843 |
|
|
5844 |
bool QgsRasterLayer::getGeoTransform(GDALDatasetH theDataset, double theGeoTransform[6]) const
|
|
5845 |
{
|
|
5846 |
if ( theDataset == NULL )
|
|
5847 |
{
|
|
5848 |
return false;
|
|
5849 |
}
|
|
5850 |
|
|
5851 |
if ( mIgnoreGeoTransform || (CE_None != GDALGetGeoTransform( theDataset, theGeoTransform )) )
|
|
5852 |
{
|
|
5853 |
// if the raster does not have a valid transform we need to use
|
|
5854 |
// a pixel size of (1,-1), but GDAL returns (1,1)
|
|
5855 |
theGeoTransform[0] = 0;
|
|
5856 |
theGeoTransform[1] = 1;
|
|
5857 |
theGeoTransform[2] = 0;
|
|
5858 |
theGeoTransform[3] = 0;
|
|
5859 |
theGeoTransform[4] = 0;
|
|
5860 |
theGeoTransform[5] = -1;
|
|
5861 |
return false;
|
|
5862 |
}
|
|
5863 |
|
|
5864 |
return true;
|
|
5865 |
}
|