mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-02-26 04:00:49 +01:00
Added support for matrix-defined transformations
Fixed transformation matrix computation
This commit is contained in:
parent
bffd1d9172
commit
045cbe81bf
@ -58,7 +58,7 @@ typedef struct {
|
|||||||
} KeyEntry;
|
} KeyEntry;
|
||||||
|
|
||||||
|
|
||||||
bool GeoTIFF::readEntry(TIFFFile &file, Ctx &ctx)
|
bool GeoTIFF::readEntry(TIFFFile &file, Ctx &ctx) const
|
||||||
{
|
{
|
||||||
quint16 tag;
|
quint16 tag;
|
||||||
quint16 type;
|
quint16 type;
|
||||||
@ -105,7 +105,7 @@ bool GeoTIFF::readEntry(TIFFFile &file, Ctx &ctx)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GeoTIFF::readIFD(TIFFFile &file, quint32 &offset, Ctx &ctx)
|
bool GeoTIFF::readIFD(TIFFFile &file, quint32 &offset, Ctx &ctx) const
|
||||||
{
|
{
|
||||||
quint16 count;
|
quint16 count;
|
||||||
|
|
||||||
@ -124,7 +124,7 @@ bool GeoTIFF::readIFD(TIFFFile &file, quint32 &offset, Ctx &ctx)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GeoTIFF::readScale(TIFFFile &file, quint32 offset, QPointF &scale)
|
bool GeoTIFF::readScale(TIFFFile &file, quint32 offset, QPointF &scale) const
|
||||||
{
|
{
|
||||||
if (!file.seek(offset))
|
if (!file.seek(offset))
|
||||||
return false;
|
return false;
|
||||||
@ -138,7 +138,7 @@ bool GeoTIFF::readScale(TIFFFile &file, quint32 offset, QPointF &scale)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool GeoTIFF::readTiepoints(TIFFFile &file, quint32 offset, quint32 count,
|
bool GeoTIFF::readTiepoints(TIFFFile &file, quint32 offset, quint32 count,
|
||||||
QList<ReferencePoint> &points)
|
QList<ReferencePoint> &points) const
|
||||||
{
|
{
|
||||||
double z, pz;
|
double z, pz;
|
||||||
QPointF xy, pp;
|
QPointF xy, pp;
|
||||||
@ -170,7 +170,19 @@ bool GeoTIFF::readTiepoints(TIFFFile &file, quint32 offset, quint32 count,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GeoTIFF::readKeys(TIFFFile &file, Ctx &ctx, QMap<quint16, Value> &kv)
|
bool GeoTIFF::readMatrix(TIFFFile &file, quint32 offset, double matrix[16]) const
|
||||||
|
{
|
||||||
|
if (!file.seek(offset))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
for (int i = 0; i < 16; i++)
|
||||||
|
if (!file.readValue(matrix[i]))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GeoTIFF::readKeys(TIFFFile &file, Ctx &ctx, QMap<quint16, Value> &kv) const
|
||||||
{
|
{
|
||||||
Header header;
|
Header header;
|
||||||
KeyEntry entry;
|
KeyEntry entry;
|
||||||
@ -233,7 +245,7 @@ bool GeoTIFF::readKeys(TIFFFile &file, Ctx &ctx, QMap<quint16, Value> &kv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool GeoTIFF::readGeoValue(TIFFFile &file, quint32 offset, quint16 index,
|
bool GeoTIFF::readGeoValue(TIFFFile &file, quint32 offset, quint16 index,
|
||||||
double &val)
|
double &val) const
|
||||||
{
|
{
|
||||||
qint64 pos = file.pos();
|
qint64 pos = file.pos();
|
||||||
|
|
||||||
@ -419,17 +431,18 @@ bool GeoTIFF::load(const QString &path)
|
|||||||
return false;
|
return false;
|
||||||
break;
|
break;
|
||||||
case ModelTypeGeocentric:
|
case ModelTypeGeocentric:
|
||||||
_errorString = "TODO ModelTypeGeocentric";
|
_errorString = "Geocentric models are not supported";
|
||||||
return false;
|
return false;
|
||||||
default:
|
default:
|
||||||
_errorString = "Unknown/missing model type";
|
_errorString = "Unknown/missing model type";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctx.scale && ctx.tiepoints)
|
if (ctx.scale && ctx.tiepoints) {
|
||||||
_transform = QTransform(scale.x(), 0, 0, -scale.y(),
|
const ReferencePoint &p = points.first();
|
||||||
points.first().pp.x(), points.first().pp.y()).inverted();
|
_transform = QTransform(scale.x(), 0, 0, -scale.y(), p.pp.x() - p.xy.x()
|
||||||
else if (ctx.tiepointCount > 1) {
|
/ scale.x(), p.pp.y() + p.xy.x() / scale.y()).inverted();
|
||||||
|
} else if (ctx.tiepointCount > 1) {
|
||||||
Transform t(points);
|
Transform t(points);
|
||||||
if (t.isNull()) {
|
if (t.isNull()) {
|
||||||
_errorString = t.errorString();
|
_errorString = t.errorString();
|
||||||
@ -437,8 +450,16 @@ bool GeoTIFF::load(const QString &path)
|
|||||||
}
|
}
|
||||||
_transform = t.transform();
|
_transform = t.transform();
|
||||||
} else if (ctx.matrix) {
|
} else if (ctx.matrix) {
|
||||||
_errorString = "TODO ModelTransformationTag";
|
double m[16];
|
||||||
return false;
|
if (!readMatrix(file, ctx.matrix, m)) {
|
||||||
|
_errorString = "Error reading transformation matrix";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (m[2] != 0.0 || m[6] != 0.0 || m[8] != 0.0 || m[9] != 0.0
|
||||||
|
|| m[10] != 0.0 || m[11] != 0.0) {
|
||||||
|
_errorString = "Not a baseline transformation matrix";
|
||||||
|
}
|
||||||
|
_transform = QTransform(m[0], m[1], m[4], m[5], m[3], m[7]).inverted();
|
||||||
} else {
|
} else {
|
||||||
_errorString = "Incomplete/missing model transformation info";
|
_errorString = "Incomplete/missing model transformation info";
|
||||||
return false;
|
return false;
|
||||||
|
@ -40,14 +40,15 @@ private:
|
|||||||
values(0) {}
|
values(0) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
bool readEntry(TIFFFile &file, Ctx &ctx);
|
bool readEntry(TIFFFile &file, Ctx &ctx) const;
|
||||||
bool readIFD(TIFFFile &file, quint32 &offset, Ctx &ctx);
|
bool readIFD(TIFFFile &file, quint32 &offset, Ctx &ctx) const;
|
||||||
bool readScale(TIFFFile &file, quint32 offset, QPointF &scale);
|
bool readScale(TIFFFile &file, quint32 offset, QPointF &scale) const;
|
||||||
bool readTiepoints(TIFFFile &file, quint32 offset, quint32 count,
|
bool readTiepoints(TIFFFile &file, quint32 offset, quint32 count,
|
||||||
QList<ReferencePoint> &points);
|
QList<ReferencePoint> &points) const;
|
||||||
bool readKeys(TIFFFile &file, Ctx &ctx, QMap<quint16, Value> &kv);
|
bool readMatrix(TIFFFile &file, quint32 offset, double matrix[16]) const;
|
||||||
|
bool readKeys(TIFFFile &file, Ctx &ctx, QMap<quint16, Value> &kv) const;
|
||||||
bool readGeoValue(TIFFFile &file, quint32 offset, quint16 index,
|
bool readGeoValue(TIFFFile &file, quint32 offset, quint16 index,
|
||||||
double &val);
|
double &val) const;
|
||||||
|
|
||||||
Datum datum(QMap<quint16, Value> &kv);
|
Datum datum(QMap<quint16, Value> &kv);
|
||||||
Projection::Method method(QMap<quint16, Value> &kv);
|
Projection::Method method(QMap<quint16, Value> &kv);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user