mirror of
https://github.com/tumic0/GPXSee.git
synced 2024-11-28 05:34:47 +01:00
Properly handle skewed charts
This commit is contained in:
parent
8423fc1230
commit
df3ee11f42
@ -157,6 +157,11 @@ bool BSBMap::parseKNP(const QByteArray &line, QString &datum, QString &proj,
|
|||||||
_errorString = "Invalid KNP PP field";
|
_errorString = "Invalid KNP PP field";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
_skew = parameter(map.value("SK"), &ok);
|
||||||
|
if (!ok) {
|
||||||
|
_errorString = "Invalid KNP SK field";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -253,8 +258,16 @@ bool BSBMap::readHeader(QFile &file)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BSBMap::createTransform(const QList<ReferencePoint> &points)
|
bool BSBMap::createTransform(QList<ReferencePoint> &points)
|
||||||
{
|
{
|
||||||
|
if (_skew > 0.0 && _skew < 360.0) {
|
||||||
|
QTransform matrix;
|
||||||
|
matrix.rotate(-_skew);
|
||||||
|
QTransform t(QImage::trueMatrix(matrix, _size.width(), _size.height()));
|
||||||
|
for (int i = 0; i < points.size(); i++)
|
||||||
|
points[i].setXY(t.map(points.at(i).xy().toPointF()));
|
||||||
|
}
|
||||||
|
|
||||||
_transform = Transform(points);
|
_transform = Transform(points);
|
||||||
if (!_transform.isValid()) {
|
if (!_transform.isValid()) {
|
||||||
_errorString = _transform.errorString();
|
_errorString = _transform.errorString();
|
||||||
@ -400,7 +413,9 @@ Coordinates BSBMap::xy2ll(const QPointF &p)
|
|||||||
|
|
||||||
QRectF BSBMap::bounds()
|
QRectF BSBMap::bounds()
|
||||||
{
|
{
|
||||||
return QRectF(QPointF(0, 0), _size / _ratio);
|
return _skewSize.isValid()
|
||||||
|
? QRectF(QPointF(0, 0), _skewSize / _ratio)
|
||||||
|
: QRectF(QPointF(0, 0), _size / _ratio);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BSBMap::draw(QPainter *painter, const QRectF &rect, Flags flags)
|
void BSBMap::draw(QPainter *painter, const QRectF &rect, Flags flags)
|
||||||
@ -420,8 +435,16 @@ void BSBMap::setDevicePixelRatio(qreal deviceRatio, qreal mapRatio)
|
|||||||
|
|
||||||
void BSBMap::load()
|
void BSBMap::load()
|
||||||
{
|
{
|
||||||
if (!_img)
|
if (!_img) {
|
||||||
|
if (_skew > 0.0 && _skew < 360.0) {
|
||||||
|
QTransform matrix;
|
||||||
|
matrix.rotate(-_skew);
|
||||||
|
QImage img(readImage().transformed(matrix));
|
||||||
|
_skewSize = img.size();
|
||||||
|
_img = new Image(img);
|
||||||
|
} else
|
||||||
_img = new Image(readImage());
|
_img = new Image(readImage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BSBMap::unload()
|
void BSBMap::unload()
|
||||||
|
@ -42,7 +42,7 @@ private:
|
|||||||
bool readHeader(QFile &file);
|
bool readHeader(QFile &file);
|
||||||
bool createProjection(const QString &datum, const QString &proj,
|
bool createProjection(const QString &datum, const QString &proj,
|
||||||
double params[9]);
|
double params[9]);
|
||||||
bool createTransform(const QList<ReferencePoint> &points);
|
bool createTransform(QList<ReferencePoint> &points);
|
||||||
QImage readImage();
|
QImage readImage();
|
||||||
bool readRow(QFile &file, char bits, uchar *buf);
|
bool readRow(QFile &file, char bits, uchar *buf);
|
||||||
|
|
||||||
@ -50,8 +50,10 @@ private:
|
|||||||
QString _name;
|
QString _name;
|
||||||
Projection _projection;
|
Projection _projection;
|
||||||
Transform _transform;
|
Transform _transform;
|
||||||
|
qreal _skew;
|
||||||
Image *_img;
|
Image *_img;
|
||||||
QSize _size;
|
QSize _size;
|
||||||
|
QSize _skewSize;
|
||||||
qreal _ratio;
|
qreal _ratio;
|
||||||
qint64 _dataOffset;
|
qint64 _dataOffset;
|
||||||
QVector<QRgb> _palette;
|
QVector<QRgb> _palette;
|
||||||
|
Loading…
Reference in New Issue
Block a user