-
-
Notifications
You must be signed in to change notification settings - Fork 3k
/
qgsrasterfilewriter.h
122 lines (100 loc) · 5.1 KB
/
qgsrasterfilewriter.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/***************************************************************************
qgsrasterfilewriter.h
---------------------
begin : July 2012
copyright : (C) 2012 by Marco Hugentobler
email : marco dot hugentobler at sourcepole dot ch
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSRASTERFILEWRITER_H
#define QGSRASTERFILEWRITER_H
#include "qgscoordinatereferencesystem.h"
#include "qgsrasterdataprovider.h"
#include "qgsrectangle.h"
#include <QDomDocument>
#include <QDomElement>
#include <QString>
class QProgressDialog;
class QgsRasterIterator;
class CORE_EXPORT QgsRasterFileWriter
{
public:
enum WriterError
{
NoError = 0,
SourceProviderError = 1,
DestProviderError = 2,
CreateDatasourceError = 3,
WriteError = 4
};
QgsRasterFileWriter( const QString& outputUrl );
~QgsRasterFileWriter();
/**Write raster file
@param iter raster iterator
@param nCols number of output columns
@param nRows number of output rows (or -1 to automatically calculate row number to have square pixels)
@param outputExtent extent to output
@param crs crs to reproject to
@param p dialog to show progress in */
WriterError writeRaster( QgsRasterIterator* iter, int nCols, int nRows, QgsRectangle outputExtent,
const QgsCoordinateReferenceSystem& crs, QProgressDialog* p = 0 );
void setOutputFormat( const QString& format ) { mOutputFormat = format; }
QString outputFormat() const { return mOutputFormat; }
void setOutputProviderKey( const QString& key ) { mOutputProviderKey = key; }
QString outputProviderKey() const { return mOutputProviderKey; }
void setTiledMode( bool t ) { mTiledMode = t; }
bool tiledMode() const { return mTiledMode; }
void setMaxTileWidth( int w ) { mMaxTileWidth = w; }
int maxTileWidth() const { return mMaxTileWidth; }
void setMaxTileHeight( int h ) { mMaxTileHeight = h; }
int maxTileHeight() const { return mMaxTileHeight; }
// for now not putting createOptions in all methods, use createOptions()
void setCreateOptions( const QStringList& list ) { mCreateOptions = list; }
QStringList createOptions() const { return mCreateOptions; }
private:
QgsRasterFileWriter(); //forbidden
WriterError writeDataRaster( QgsRasterIterator* iter, int nCols, int nRows, const QgsRectangle& outputExtent,
const QgsCoordinateReferenceSystem& crs );
WriterError writeImageRaster( QgsRasterIterator* iter, int nCols, int nRows, const QgsRectangle& outputExtent,
const QgsCoordinateReferenceSystem& crs );
//initialize vrt member variables
void createVRT( int xSize, int ySize, const QgsCoordinateReferenceSystem& crs, double* geoTransform );
//write vrt document to disk
bool writeVRT( const QString& file );
//add file entry to vrt
void addToVRT( const QString& filename, int band, int xSize, int ySize, int xOffset, int yOffset );
void buildPyramids( const QString& filename );
static int pyramidsProgress( double dfComplete, const char *pszMessage, void* pData );
/**Create provider and datasource for a part image (vrt mode)*/
QgsRasterDataProvider* createPartProvider( const QgsRectangle& extent, int nCols, int iterCols, int iterRows,
int iterLeft, int iterTop,
const QString& outputUrl, int fileIndex, int nBands, QgsRasterInterface::DataType type,
const QgsCoordinateReferenceSystem& crs );
/**Init VRT (for tiled mode) or create global output provider (single-file mode)*/
QgsRasterDataProvider* initOutput( int nCols, int nRows, const QgsCoordinateReferenceSystem& crs, double* geoTransform, int nBands,
QgsRasterInterface::DataType type );
/**Calculate nRows, geotransform and pixel size for output*/
void globalOutputParameters( const QgsRectangle& extent, int nCols, int& nRows, double* geoTransform, double& pixelSize );
QString mOutputUrl;
QString mOutputProviderKey;
QString mOutputFormat;
QStringList mCreateOptions;
QgsCoordinateReferenceSystem mOutputCRS;
/**False: Write one file, true: create a directory and add the files numbered*/
bool mTiledMode;
double mMaxTileWidth;
double mMaxTileHeight;
QDomDocument mVRTDocument;
QDomElement mVRTRedBand;
QDomElement mVRTGreenBand;
QDomElement mVRTBlueBand;
QDomElement mVRTAlphaBand;
QProgressDialog* mProgressDialog;
};
#endif // QGSRASTERFILEWRITER_H