mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-02-07 12:05:14 +01:00
Refactoring
This commit is contained in:
parent
a54821863f
commit
35703e3363
@ -448,7 +448,7 @@ bool GeoTIFF::geographicModel(QMap<quint16, Value> &kv)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GeoTIFF::load(const QString &path)
|
GeoTIFF::GeoTIFF(const QString &path)
|
||||||
{
|
{
|
||||||
quint32 ifd;
|
quint32 ifd;
|
||||||
QList<ReferencePoint> points;
|
QList<ReferencePoint> points;
|
||||||
@ -462,86 +462,76 @@ bool GeoTIFF::load(const QString &path)
|
|||||||
if (!file.open(QIODevice::ReadOnly)) {
|
if (!file.open(QIODevice::ReadOnly)) {
|
||||||
_errorString = QString("Error opening TIFF file: %1")
|
_errorString = QString("Error opening TIFF file: %1")
|
||||||
.arg(file.errorString());
|
.arg(file.errorString());
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
if (!file.readHeader(ifd)) {
|
if (!file.readHeader(ifd)) {
|
||||||
_errorString = "Invalid TIFF header";
|
_errorString = "Invalid TIFF header";
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (ifd) {
|
while (ifd) {
|
||||||
if (!readIFD(file, ifd, ctx)) {
|
if (!readIFD(file, ifd, ctx)) {
|
||||||
_errorString = "Invalid IFD";
|
_errorString = "Invalid IFD";
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ctx.keys) {
|
if (!ctx.keys) {
|
||||||
_errorString = "Not a GeoTIFF file";
|
_errorString = "Not a GeoTIFF file";
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctx.scale) {
|
if (ctx.scale) {
|
||||||
if (!readScale(file, ctx.scale, scale)) {
|
if (!readScale(file, ctx.scale, scale)) {
|
||||||
_errorString = "Error reading model pixel scale";
|
_errorString = "Error reading model pixel scale";
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ctx.tiepoints) {
|
if (ctx.tiepoints) {
|
||||||
if (!readTiepoints(file, ctx.tiepoints, ctx.tiepointCount, points)) {
|
if (!readTiepoints(file, ctx.tiepoints, ctx.tiepointCount, points)) {
|
||||||
_errorString = "Error reading raster->model tiepoint pairs";
|
_errorString = "Error reading raster->model tiepoint pairs";
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!readKeys(file, ctx, kv)) {
|
if (!readKeys(file, ctx, kv)) {
|
||||||
_errorString = "Error reading Geo key/value";
|
_errorString = "Error reading Geo key/value";
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (kv.value(GTModelTypeGeoKey).SHORT) {
|
switch (kv.value(GTModelTypeGeoKey).SHORT) {
|
||||||
case ModelTypeProjected:
|
case ModelTypeProjected:
|
||||||
if (!projectedModel(kv))
|
if (!projectedModel(kv))
|
||||||
return false;
|
return;
|
||||||
break;
|
break;
|
||||||
case ModelTypeGeographic:
|
case ModelTypeGeographic:
|
||||||
if (!geographicModel(kv))
|
if (!geographicModel(kv))
|
||||||
return false;
|
return;
|
||||||
break;
|
break;
|
||||||
case ModelTypeGeocentric:
|
case ModelTypeGeocentric:
|
||||||
_errorString = "Geocentric models are not supported";
|
_errorString = "Geocentric models are not supported";
|
||||||
return false;
|
return;
|
||||||
default:
|
default:
|
||||||
_errorString = "Unknown/missing model type";
|
_errorString = "Unknown/missing model type";
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctx.scale && ctx.tiepoints) {
|
if (ctx.scale && ctx.tiepoints)
|
||||||
const ReferencePoint &p = points.first();
|
_transform = Transform(points.first(), scale);
|
||||||
_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();
|
_transform = Transform(points);
|
||||||
} else if (ctx.tiepointCount > 1) {
|
else if (ctx.matrix) {
|
||||||
Transform t(points);
|
|
||||||
if (t.isNull()) {
|
|
||||||
_errorString = t.errorString();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
_transform = t.transform();
|
|
||||||
} else if (ctx.matrix) {
|
|
||||||
double m[16];
|
double m[16];
|
||||||
if (!readMatrix(file, ctx.matrix, m)) {
|
if (!readMatrix(file, ctx.matrix, m)) {
|
||||||
_errorString = "Error reading transformation matrix";
|
_errorString = "Error reading transformation matrix";
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
if (m[2] != 0.0 || m[6] != 0.0 || m[8] != 0.0 || m[9] != 0.0
|
_transform = Transform(m);
|
||||||
|| 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
if (!_transform.isValid())
|
||||||
|
_errorString = _transform.errorString();
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QTransform>
|
|
||||||
#include "transform.h"
|
#include "transform.h"
|
||||||
#include "projection.h"
|
#include "projection.h"
|
||||||
|
|
||||||
@ -13,11 +12,13 @@ class GCS;
|
|||||||
class GeoTIFF
|
class GeoTIFF
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
bool load(const QString &path);
|
GeoTIFF(const QString &path);
|
||||||
|
|
||||||
|
bool isValid() const {return _projection.isValid() && _transform.isValid();}
|
||||||
const QString &errorString() const {return _errorString;}
|
const QString &errorString() const {return _errorString;}
|
||||||
|
|
||||||
const Projection &projection() const {return _projection;}
|
const Projection &projection() const {return _projection;}
|
||||||
const QTransform &transform() const {return _transform;}
|
const Transform &transform() const {return _transform;}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
union Value {
|
union Value {
|
||||||
@ -52,7 +53,7 @@ private:
|
|||||||
bool geographicModel(QMap<quint16, Value> &kv);
|
bool geographicModel(QMap<quint16, Value> &kv);
|
||||||
bool projectedModel(QMap<quint16, Value> &kv);
|
bool projectedModel(QMap<quint16, Value> &kv);
|
||||||
|
|
||||||
QTransform _transform;
|
Transform _transform;
|
||||||
Projection _projection;
|
Projection _projection;
|
||||||
|
|
||||||
QString _errorString;
|
QString _errorString;
|
||||||
|
@ -238,14 +238,12 @@ bool MapFile::computeTransformation(QList<CalibrationPoint> &points)
|
|||||||
rp.append(points.at(i).rp);
|
rp.append(points.at(i).rp);
|
||||||
}
|
}
|
||||||
|
|
||||||
Transform t(rp);
|
_transform = Transform(rp);
|
||||||
if (t.isNull()) {
|
if (!_transform.isValid()) {
|
||||||
_errorString = t.errorString();
|
_errorString = _transform.errorString();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
_transform = t.transform();
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -263,5 +261,5 @@ MapFile::MapFile(QIODevice &file)
|
|||||||
if (!createProjection(gcs, ct, setup, points))
|
if (!createProjection(gcs, ct, setup, points))
|
||||||
return;
|
return;
|
||||||
if (!computeTransformation(points))
|
if (!computeTransformation(points))
|
||||||
_image = QString();
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
#ifndef MAPFILE_H
|
#ifndef MAPFILE_H
|
||||||
#define MAPFILE_H
|
#define MAPFILE_H
|
||||||
|
|
||||||
#include <QTransform>
|
|
||||||
#include "transform.h"
|
#include "transform.h"
|
||||||
#include "projection.h"
|
#include "projection.h"
|
||||||
|
|
||||||
@ -13,11 +12,12 @@ class MapFile
|
|||||||
public:
|
public:
|
||||||
MapFile(QIODevice &file);
|
MapFile(QIODevice &file);
|
||||||
|
|
||||||
bool isValid() const {return !_image.isNull() && _projection.isValid();}
|
bool isValid() const
|
||||||
|
{return !_image.isNull() && _projection.isValid() && _transform.isValid();}
|
||||||
const QString &errorString() const {return _errorString;}
|
const QString &errorString() const {return _errorString;}
|
||||||
|
|
||||||
const Projection &projection() const {return _projection;}
|
const Projection &projection() const {return _projection;}
|
||||||
const QTransform &transform() const {return _transform;}
|
const Transform &transform() const {return _transform;}
|
||||||
|
|
||||||
const QString &name() const {return _name;}
|
const QString &name() const {return _name;}
|
||||||
const QString &image() const {return _image;}
|
const QString &image() const {return _image;}
|
||||||
@ -44,7 +44,7 @@ private:
|
|||||||
QSize _size;
|
QSize _size;
|
||||||
|
|
||||||
Projection _projection;
|
Projection _projection;
|
||||||
QTransform _transform;
|
Transform _transform;
|
||||||
|
|
||||||
QString _errorString;
|
QString _errorString;
|
||||||
};
|
};
|
||||||
|
@ -139,8 +139,8 @@ OfflineMap::OfflineMap(const QString &fileName, QObject *parent)
|
|||||||
_transform = mf.transform();
|
_transform = mf.transform();
|
||||||
}
|
}
|
||||||
} else if (suffix == "tif" || suffix == "tiff") {
|
} else if (suffix == "tif" || suffix == "tiff") {
|
||||||
GeoTIFF gt;
|
GeoTIFF gt(fileName);
|
||||||
if (!gt.load(fileName)) {
|
if (!gt.isValid()) {
|
||||||
_errorString = gt.errorString();
|
_errorString = gt.errorString();
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
@ -168,8 +168,6 @@ OfflineMap::OfflineMap(const QString &fileName, QObject *parent)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_inverted = _transform.inverted();
|
|
||||||
|
|
||||||
_valid = true;
|
_valid = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -198,7 +196,6 @@ OfflineMap::OfflineMap(const QString &fileName, Tar &tar, QObject *parent)
|
|||||||
_map.size = mf.size();
|
_map.size = mf.size();
|
||||||
_projection = mf.projection();
|
_projection = mf.projection();
|
||||||
_transform = mf.transform();
|
_transform = mf.transform();
|
||||||
_inverted = _transform.inverted();
|
|
||||||
_tar = new Tar(fi.absolutePath() + "/" + fi.completeBaseName() + ".tar");
|
_tar = new Tar(fi.absolutePath() + "/" + fi.completeBaseName() + ".tar");
|
||||||
|
|
||||||
_valid = true;
|
_valid = true;
|
||||||
@ -328,28 +325,23 @@ void OfflineMap::draw(QPainter *painter, const QRectF &rect)
|
|||||||
|
|
||||||
QPointF OfflineMap::ll2xy(const Coordinates &c) const
|
QPointF OfflineMap::ll2xy(const Coordinates &c) const
|
||||||
{
|
{
|
||||||
if (_ozf) {
|
QPointF p(_transform.proj2img(_projection.ll2xy(c)));
|
||||||
QPointF p(_transform.map(_projection.ll2xy(c)));
|
return _ozf ? QPointF(p.x() * _scale.x(), p.y() * _scale.y()) : p;
|
||||||
return QPointF(p.x() * _scale.x(), p.y() * _scale.y());
|
|
||||||
} else
|
|
||||||
return _transform.map(_projection.ll2xy(c));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Coordinates OfflineMap::xy2ll(const QPointF &p) const
|
Coordinates OfflineMap::xy2ll(const QPointF &p) const
|
||||||
{
|
{
|
||||||
if (_ozf) {
|
return _ozf
|
||||||
return _projection.xy2ll(_inverted.map(QPointF(p.x() / _scale.x(),
|
? _projection.xy2ll(_transform.img2proj(QPointF(p.x() / _scale.x(),
|
||||||
p.y() / _scale.y())));
|
p.y() / _scale.y())))
|
||||||
} else
|
: _projection.xy2ll(_transform.img2proj(p));
|
||||||
return _projection.xy2ll(_inverted.map(p));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QRectF OfflineMap::bounds() const
|
QRectF OfflineMap::bounds() const
|
||||||
{
|
{
|
||||||
if (_ozf)
|
return _ozf
|
||||||
return QRectF(QPointF(0, 0), _ozf->size(_zoom));
|
? QRectF(QPointF(0, 0), _ozf->size(_zoom))
|
||||||
else
|
: QRectF(QPointF(0, 0), _map.size);
|
||||||
return QRectF(QPointF(0, 0), _map.size);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal OfflineMap::resolution(const QRectF &rect) const
|
qreal OfflineMap::resolution(const QRectF &rect) const
|
||||||
@ -363,15 +355,17 @@ qreal OfflineMap::resolution(const QRectF &rect) const
|
|||||||
return ds/ps;
|
return ds/ps;
|
||||||
}
|
}
|
||||||
|
|
||||||
int OfflineMap::zoomFit(const QSize &size, const RectC &br)
|
int OfflineMap::zoomFit(const QSize &size, const RectC &rect)
|
||||||
{
|
{
|
||||||
if (_ozf) {
|
if (!_ozf)
|
||||||
if (!br.isValid())
|
return _zoom;
|
||||||
|
|
||||||
|
if (!rect.isValid())
|
||||||
rescale(0);
|
rescale(0);
|
||||||
else {
|
else {
|
||||||
QRect sbr(QRectF(_transform.map(_projection.ll2xy(br.topLeft())),
|
QPointF tl(_transform.proj2img(_projection.ll2xy(rect.topLeft())));
|
||||||
_transform.map(_projection.ll2xy(br.bottomRight())))
|
QPointF br(_transform.proj2img(_projection.ll2xy(rect.bottomRight())));
|
||||||
.toRect().normalized());
|
QRect sbr(QRectF(tl, br).toRect().normalized());
|
||||||
|
|
||||||
for (int i = 0; i < _ozf->zooms(); i++) {
|
for (int i = 0; i < _ozf->zooms(); i++) {
|
||||||
rescale(i);
|
rescale(i);
|
||||||
@ -380,7 +374,6 @@ int OfflineMap::zoomFit(const QSize &size, const RectC &br)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return _zoom;
|
return _zoom;
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#ifndef OFFLINEMAP_H
|
#ifndef OFFLINEMAP_H
|
||||||
#define OFFLINEMAP_H
|
#define OFFLINEMAP_H
|
||||||
|
|
||||||
#include <QTransform>
|
#include "transform.h"
|
||||||
#include "projection.h"
|
#include "projection.h"
|
||||||
#include "map.h"
|
#include "map.h"
|
||||||
|
|
||||||
@ -24,7 +24,7 @@ public:
|
|||||||
qreal resolution(const QRectF &rect) const;
|
qreal resolution(const QRectF &rect) const;
|
||||||
|
|
||||||
int zoom() const {return _zoom;}
|
int zoom() const {return _zoom;}
|
||||||
int zoomFit(const QSize &size, const RectC &br);
|
int zoomFit(const QSize &size, const RectC &rect);
|
||||||
int zoomIn();
|
int zoomIn();
|
||||||
int zoomOut();
|
int zoomOut();
|
||||||
|
|
||||||
@ -44,9 +44,9 @@ public:
|
|||||||
QPointF ll2pp(const Coordinates &c) const
|
QPointF ll2pp(const Coordinates &c) const
|
||||||
{return _projection.ll2xy(c);}
|
{return _projection.ll2xy(c);}
|
||||||
QPointF xy2pp(const QPointF &p) const
|
QPointF xy2pp(const QPointF &p) const
|
||||||
{return _inverted.map(p);}
|
{return _transform.img2proj(p);}
|
||||||
QPointF pp2xy(const QPointF &p) const
|
QPointF pp2xy(const QPointF &p) const
|
||||||
{return _transform.map(p);}
|
{return _transform.proj2img(p);}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct ImageInfo {
|
struct ImageInfo {
|
||||||
@ -69,15 +69,12 @@ private:
|
|||||||
void rescale(int zoom);
|
void rescale(int zoom);
|
||||||
|
|
||||||
QString _name;
|
QString _name;
|
||||||
|
|
||||||
Projection _projection;
|
Projection _projection;
|
||||||
QTransform _transform, _inverted;
|
Transform _transform;
|
||||||
|
|
||||||
QImage *_img;
|
QImage *_img;
|
||||||
Tar *_tar;
|
Tar *_tar;
|
||||||
OZF *_ozf;
|
OZF *_ozf;
|
||||||
ImageInfo _map, _tile;
|
ImageInfo _map, _tile;
|
||||||
|
|
||||||
int _zoom;
|
int _zoom;
|
||||||
QPointF _scale;
|
QPointF _scale;
|
||||||
|
|
||||||
|
@ -2,6 +2,9 @@
|
|||||||
#include "matrix.h"
|
#include "matrix.h"
|
||||||
#include "transform.h"
|
#include "transform.h"
|
||||||
|
|
||||||
|
|
||||||
|
#define NULL_QTRANSFORM 0,0,0,0,0,0,0,0,0
|
||||||
|
|
||||||
void Transform::simple(const QList<ReferencePoint> &points)
|
void Transform::simple(const QList<ReferencePoint> &points)
|
||||||
{
|
{
|
||||||
if (points.at(0).xy.x() == points.at(1).xy.x()
|
if (points.at(0).xy.x() == points.at(1).xy.x()
|
||||||
@ -18,7 +21,8 @@ void Transform::simple(const QList<ReferencePoint> &points)
|
|||||||
dX = points.at(1).xy.x() - points.at(1).pp.x() * sX;
|
dX = points.at(1).xy.x() - points.at(1).pp.x() * sX;
|
||||||
dY = points.at(0).xy.y() - points.at(0).pp.y() * sY;
|
dY = points.at(0).xy.y() - points.at(0).pp.y() * sY;
|
||||||
|
|
||||||
_transform = QTransform(sX, 0, 0, sY, dX, dY);
|
_proj2img = QTransform(sX, 0, 0, sY, dX, dY);
|
||||||
|
_img2proj = _proj2img.inverted();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Transform::affine(const QList<ReferencePoint> &points)
|
void Transform::affine(const QList<ReferencePoint> &points)
|
||||||
@ -59,8 +63,15 @@ void Transform::affine(const QList<ReferencePoint> &points)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_transform = QTransform(M.m(0,3), M.m(0,4), M.m(1,3), M.m(1,4), M.m(2,3),
|
_proj2img = QTransform(M.m(0,3), M.m(0,4), M.m(1,3), M.m(1,4), M.m(2,3),
|
||||||
M.m(2,4));
|
M.m(2,4));
|
||||||
|
_img2proj = _proj2img.inverted();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Transform::Transform()
|
||||||
|
: _proj2img(NULL_QTRANSFORM), _img2proj(NULL_QTRANSFORM)
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Transform::Transform(const QList<ReferencePoint> &points)
|
Transform::Transform(const QList<ReferencePoint> &points)
|
||||||
@ -73,6 +84,29 @@ Transform::Transform(const QList<ReferencePoint> &points)
|
|||||||
affine(points);
|
affine(points);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Transform::Transform(const ReferencePoint &p, const QPointF &scale)
|
||||||
|
: _proj2img(NULL_QTRANSFORM), _img2proj(NULL_QTRANSFORM)
|
||||||
|
{
|
||||||
|
if (scale.x() == 0.0 || scale.y() == 0.0) {
|
||||||
|
_errorString = "Invalid scale factor";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_img2proj = QTransform(scale.x(), 0, 0, -scale.y(), p.pp.x() - p.xy.x()
|
||||||
|
/ scale.x(), p.pp.y() + p.xy.x() / scale.y());
|
||||||
|
_proj2img = _img2proj.inverted();
|
||||||
|
}
|
||||||
|
|
||||||
|
Transform::Transform(double m[16])
|
||||||
|
: _proj2img(NULL_QTRANSFORM), _img2proj(NULL_QTRANSFORM)
|
||||||
|
{
|
||||||
|
_img2proj = QTransform(m[0], m[1], m[4], m[5], m[3], m[7]);
|
||||||
|
if (!_img2proj.isInvertible())
|
||||||
|
_errorString = "Singular transformation matrix";
|
||||||
|
else
|
||||||
|
_proj2img = _img2proj.inverted();
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef QT_NO_DEBUG
|
#ifndef QT_NO_DEBUG
|
||||||
QDebug operator<<(QDebug dbg, const ReferencePoint &p)
|
QDebug operator<<(QDebug dbg, const ReferencePoint &p)
|
||||||
{
|
{
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
#include <QTransform>
|
#include <QTransform>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include "common/coordinates.h"
|
#include <QDebug>
|
||||||
|
|
||||||
struct ReferencePoint {
|
struct ReferencePoint {
|
||||||
QPoint xy;
|
QPoint xy;
|
||||||
@ -13,17 +13,23 @@ struct ReferencePoint {
|
|||||||
class Transform
|
class Transform
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
Transform();
|
||||||
Transform(const QList<ReferencePoint> &points);
|
Transform(const QList<ReferencePoint> &points);
|
||||||
|
Transform(const ReferencePoint &p, const QPointF &scale);
|
||||||
|
Transform(double m[16]);
|
||||||
|
|
||||||
bool isNull() {return _transform.type() == QTransform::TxNone;}
|
QPointF proj2img(const QPointF &p) const {return _proj2img.map(p);}
|
||||||
|
QPointF img2proj(const QPointF &p) const {return _img2proj.map(p);}
|
||||||
|
|
||||||
|
bool isValid() const
|
||||||
|
{return _proj2img.isInvertible() && _img2proj.isInvertible();}
|
||||||
const QString &errorString() const {return _errorString;}
|
const QString &errorString() const {return _errorString;}
|
||||||
const QTransform &transform() const {return _transform;}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void simple(const QList<ReferencePoint> &points);
|
void simple(const QList<ReferencePoint> &points);
|
||||||
void affine(const QList<ReferencePoint> &points);
|
void affine(const QList<ReferencePoint> &points);
|
||||||
|
|
||||||
QTransform _transform;
|
QTransform _proj2img, _img2proj;
|
||||||
QString _errorString;
|
QString _errorString;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -61,9 +61,7 @@ void WMTSMap::updateTransform()
|
|||||||
|
|
||||||
QList<ReferencePoint> points;
|
QList<ReferencePoint> points;
|
||||||
points << tl << br;
|
points << tl << br;
|
||||||
Transform tr(points);
|
_transform = Transform(points);
|
||||||
_transform = tr.transform();
|
|
||||||
_inverted = _transform.inverted();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WMTSMap::load()
|
void WMTSMap::load()
|
||||||
@ -198,10 +196,10 @@ void WMTSMap::draw(QPainter *painter, const QRectF &rect)
|
|||||||
|
|
||||||
QPointF WMTSMap::ll2xy(const Coordinates &c) const
|
QPointF WMTSMap::ll2xy(const Coordinates &c) const
|
||||||
{
|
{
|
||||||
return _transform.map(_projection.ll2xy(c));
|
return _transform.proj2img(_projection.ll2xy(c));
|
||||||
}
|
}
|
||||||
|
|
||||||
Coordinates WMTSMap::xy2ll(const QPointF &p) const
|
Coordinates WMTSMap::xy2ll(const QPointF &p) const
|
||||||
{
|
{
|
||||||
return _projection.xy2ll(_inverted.map(p));
|
return _projection.xy2ll(_transform.img2proj(p));
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#ifndef WMTSMAP_H
|
#ifndef WMTSMAP_H
|
||||||
#define WMTSMAP_H
|
#define WMTSMAP_H
|
||||||
|
|
||||||
#include <QTransform>
|
#include "transform.h"
|
||||||
#include "projection.h"
|
#include "projection.h"
|
||||||
#include "map.h"
|
#include "map.h"
|
||||||
#include "wmts.h"
|
#include "wmts.h"
|
||||||
@ -57,7 +57,7 @@ private:
|
|||||||
RectC _bounds;
|
RectC _bounds;
|
||||||
QList<WMTS::Zoom> _zooms;
|
QList<WMTS::Zoom> _zooms;
|
||||||
Projection _projection;
|
Projection _projection;
|
||||||
QTransform _transform, _inverted;
|
Transform _transform;
|
||||||
int _zoom;
|
int _zoom;
|
||||||
bool _block;
|
bool _block;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user