2018-01-08 23:47:45 +01:00
|
|
|
#ifndef GEOTIFF_H
|
|
|
|
#define GEOTIFF_H
|
|
|
|
|
|
|
|
#include <QMap>
|
2018-03-06 19:28:07 +01:00
|
|
|
#include <QList>
|
2018-01-08 23:47:45 +01:00
|
|
|
#include "transform.h"
|
2018-03-06 19:28:07 +01:00
|
|
|
#include "projection.h"
|
|
|
|
|
|
|
|
class TIFFFile;
|
|
|
|
class GCS;
|
2018-01-08 23:47:45 +01:00
|
|
|
|
|
|
|
class GeoTIFF
|
|
|
|
{
|
|
|
|
public:
|
2018-03-22 20:00:30 +01:00
|
|
|
GeoTIFF(const QString &path);
|
|
|
|
|
|
|
|
bool isValid() const {return _projection.isValid() && _transform.isValid();}
|
2018-01-25 00:19:11 +01:00
|
|
|
const QString &errorString() const {return _errorString;}
|
2018-01-08 23:47:45 +01:00
|
|
|
|
2018-01-25 00:19:11 +01:00
|
|
|
const Projection &projection() const {return _projection;}
|
2018-03-22 20:00:30 +01:00
|
|
|
const Transform &transform() const {return _transform;}
|
2018-01-08 23:47:45 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
union Value {
|
|
|
|
quint16 SHORT;
|
|
|
|
double DOUBLE;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Ctx {
|
|
|
|
quint32 scale;
|
|
|
|
quint32 tiepoints;
|
|
|
|
quint32 tiepointCount;
|
|
|
|
quint32 matrix;
|
|
|
|
quint32 keys;
|
|
|
|
quint32 values;
|
|
|
|
|
|
|
|
Ctx() : scale(0), tiepoints(0), tiepointCount(0), matrix(0), keys(0),
|
|
|
|
values(0) {}
|
|
|
|
};
|
|
|
|
|
2018-01-10 01:28:40 +01:00
|
|
|
bool readEntry(TIFFFile &file, Ctx &ctx) const;
|
2019-03-13 00:25:46 +01:00
|
|
|
bool readIFD(TIFFFile &file, quint32 offset, Ctx &ctx) const;
|
2018-04-15 16:27:47 +02:00
|
|
|
bool readScale(TIFFFile &file, quint32 offset, PointD &scale) const;
|
2018-01-08 23:47:45 +01:00
|
|
|
bool readTiepoints(TIFFFile &file, quint32 offset, quint32 count,
|
2018-01-10 01:28:40 +01:00
|
|
|
QList<ReferencePoint> &points) const;
|
|
|
|
bool readMatrix(TIFFFile &file, quint32 offset, double matrix[16]) const;
|
|
|
|
bool readKeys(TIFFFile &file, Ctx &ctx, QMap<quint16, Value> &kv) const;
|
2018-01-08 23:47:45 +01:00
|
|
|
bool readGeoValue(TIFFFile &file, quint32 offset, quint16 index,
|
2018-01-10 01:28:40 +01:00
|
|
|
double &val) const;
|
2018-01-08 23:47:45 +01:00
|
|
|
|
2018-01-20 20:13:56 +01:00
|
|
|
const GCS *gcs(QMap<quint16, Value> &kv);
|
2018-01-08 23:47:45 +01:00
|
|
|
Projection::Method method(QMap<quint16, Value> &kv);
|
|
|
|
bool geographicModel(QMap<quint16, Value> &kv);
|
|
|
|
bool projectedModel(QMap<quint16, Value> &kv);
|
|
|
|
|
2018-03-22 20:00:30 +01:00
|
|
|
Transform _transform;
|
2018-01-25 00:19:11 +01:00
|
|
|
Projection _projection;
|
2018-01-08 23:47:45 +01:00
|
|
|
|
|
|
|
QString _errorString;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // GEOTIFF_H
|