-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCInputFile.h
More file actions
121 lines (94 loc) · 3.9 KB
/
CInputFile.h
File metadata and controls
121 lines (94 loc) · 3.9 KB
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
/**********************************************************************************************
Copyright (C) 2012 Oliver Eichler oliver.eichler@gmx.de
2015 Adrian Hänsler
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 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
**********************************************************************************************/
#include <string>
#include <vector>
#include <iostream>
#include <fstream>
#include <gdal_priv.h>
#include <proj_api.h>
#include <ogr_spatialref.h>
#include <sqlite3.h>
#define TILESIZE 512
extern void printProgress(int current, int total);
class CInputFile
{
public:
CInputFile(const std::string& filename, uint32_t tileSize, const std::string mapname, GDALRIOResampleAlg resampling_alg);
virtual ~CInputFile();
void summarize();
double getXScale(){return xscale;}
double getYScale(){return yscale;}
void getRefP0(double& lon, double& lat);
void getRefP1(double& lon, double& lat);
void getRefP2(double& lon, double& lat);
void getRefP3(double& lon, double& lat);
int32_t getWidth(){return width;}
int32_t getHeight(){return height;}
std::string getProjection(){return compeProj;}
std::string getDatum(){return compeDatum;}
void crop_to(CInputFile& base);
uint32_t calcLevels(double scaleLimit, double& globXScale, double& globYScale);
void writeLevels(sqlite3 *db, std::ofstream& xmlstream, int quality, int subsampling);
static uint32_t getTilesTotal(){return nTilesTotal;}
std::string mapname;
OGRSpatialReference oSRS;
double xscale;
double yscale;
double xref1;
double yref1;
double xref2;
double yref2;
double x1, y1;
double x2, y2;
uint32_t cropped_width;
uint32_t cropped_height;
private:
std::string proj4;
void writeLevelXml(std::ofstream& xmlstream, int level);
void writeLevel(sqlite3 *db, int level, int quality, int subsampling);
bool readTile(int32_t xoff, int32_t yoff, int32_t w1, int32_t h1, int32_t w2, int32_t h2, uint32_t *output);
uint32_t compressTile(uint32_t xsize, uint32_t ysize, uint32_t * raw_image, int quality, int subsampling);
std::string filename;
uint32_t tileSize;
struct level_t
{
level_t(): number(0), width(0), height(0), xTiles(0), yTiles(0), xscale(0), yscale(0), xCorrectionScale(0), yCorrectionScale(0){}
int32_t number;
int32_t width;
int32_t height;
int32_t xTiles;
int32_t yTiles;
//QVector<quint64> offsetJpegs;
double xscale;
double yscale;
double xCorrectionScale;
double yCorrectionScale;
};
projPJ pj;
GDALDataset * dataset;
std::string compeProj;
std::string compeDatum;
int32_t width;
int32_t height;
uint32_t nTiles;
static uint32_t nTilesTotal;
static uint32_t nTilesProcessed;
std::vector<level_t> levels;
char tileBuf08Bit[TILESIZE * TILESIZE];
char tileBuf24Bit[TILESIZE * TILESIZE * 3];
uint32_t tileBuf32Bit[512*512];
uint32_t colortable[256];
GDALRasterIOExtraArg rasterio_args;
};