mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-06-25 18:49:16 +02:00
Fixed broken radius-rect computation
Always use the double type for coordinate related data
This commit is contained in:
@ -54,13 +54,13 @@ int MapFile::parse(QIODevice &device, QList<CalibrationPoint> &points,
|
||||
int latd = list.at(6).trimmed().toInt(&res);
|
||||
if (!res)
|
||||
ll = false;
|
||||
qreal latm = list.at(7).trimmed().toFloat(&res);
|
||||
double latm = list.at(7).trimmed().toDouble(&res);
|
||||
if (!res)
|
||||
ll = false;
|
||||
int lond = list.at(9).trimmed().toInt(&res);
|
||||
if (!res)
|
||||
ll = false;
|
||||
qreal lonm = list.at(10).trimmed().toFloat(&res);
|
||||
double lonm = list.at(10).trimmed().toDouble(&res);
|
||||
if (!res)
|
||||
ll = false;
|
||||
if (ll && list.at(8).trimmed() == "S") {
|
||||
@ -75,10 +75,10 @@ int MapFile::parse(QIODevice &device, QList<CalibrationPoint> &points,
|
||||
p.zone = list.at(13).trimmed().toInt(&res);
|
||||
if (!res)
|
||||
p.zone = 0;
|
||||
qreal ppx = list.at(14).trimmed().toFloat(&res);
|
||||
double ppx = list.at(14).trimmed().toDouble(&res);
|
||||
if (!res)
|
||||
pp = false;
|
||||
qreal ppy = list.at(15).trimmed().toFloat(&res);
|
||||
double ppy = list.at(15).trimmed().toDouble(&res);
|
||||
if (!res)
|
||||
pp = false;
|
||||
if (list.at(16).trimmed() == "S")
|
||||
|
@ -63,7 +63,7 @@ QString WMS::style(QXmlStreamReader &reader)
|
||||
|
||||
RectC WMS::geographicBoundingBox(QXmlStreamReader &reader)
|
||||
{
|
||||
qreal left = NAN, top = NAN, right = NAN, bottom = NAN;
|
||||
double left = NAN, top = NAN, right = NAN, bottom = NAN;
|
||||
|
||||
while (reader.readNextStartElement()) {
|
||||
if (reader.name() == "westBoundLongitude")
|
||||
|
@ -10,7 +10,7 @@
|
||||
#define CAPABILITIES_FILE "capabilities.xml"
|
||||
#define TILE_SIZE 256
|
||||
|
||||
qreal WMSMap::sd2res(qreal scaleDenominator) const
|
||||
double WMSMap::sd2res(double scaleDenominator) const
|
||||
{
|
||||
return scaleDenominator * 0.28e-3 * _projection.units().fromMeters(1.0);
|
||||
}
|
||||
@ -48,9 +48,9 @@ void WMSMap::computeZooms(const RangeF &scaleDenominator)
|
||||
_zooms.clear();
|
||||
|
||||
if (scaleDenominator.size() > 0) {
|
||||
qreal ld = log2(scaleDenominator.max()) - log2(scaleDenominator.min());
|
||||
double ld = log2(scaleDenominator.max()) - log2(scaleDenominator.min());
|
||||
int cld = ceil(ld);
|
||||
qreal step = ld / (qreal)cld;
|
||||
double step = ld / (qreal)cld;
|
||||
qreal lmax = log2(scaleDenominator.max());
|
||||
for (int i = 0; i <= cld; i++)
|
||||
_zooms.append(pow(2.0, lmax - i * step));
|
||||
@ -60,10 +60,10 @@ void WMSMap::computeZooms(const RangeF &scaleDenominator)
|
||||
|
||||
void WMSMap::updateTransform()
|
||||
{
|
||||
qreal scaleDenominator = _zooms.at(_zoom);
|
||||
double scaleDenominator = _zooms.at(_zoom);
|
||||
ReferencePoint tl, br;
|
||||
|
||||
qreal pixelSpan = sd2res(scaleDenominator);
|
||||
double pixelSpan = sd2res(scaleDenominator);
|
||||
if (_projection.isGeographic())
|
||||
pixelSpan /= deg2rad(WGS84_RADIUS);
|
||||
|
||||
@ -150,7 +150,7 @@ void WMSMap::emitLoaded()
|
||||
|
||||
QRectF WMSMap::bounds() const
|
||||
{
|
||||
qreal pixelSpan = sd2res(_zooms.at(_zoom));
|
||||
double pixelSpan = sd2res(_zooms.at(_zoom));
|
||||
if (_projection.isGeographic())
|
||||
pixelSpan /= deg2rad(WGS84_RADIUS);
|
||||
QSizeF size(_boundingBox.width() / pixelSpan, -_boundingBox.height()
|
||||
@ -176,7 +176,7 @@ int WMSMap::zoomFit(const QSize &size, const RectC &br)
|
||||
QRectF tbr(_projection.ll2xy(br.topLeft()),
|
||||
_projection.ll2xy(br.bottomRight()));
|
||||
QPointF sc(tbr.width() / size.width(), tbr.height() / size.height());
|
||||
qreal resolution = qMax(qAbs(sc.x()), qAbs(sc.y()));
|
||||
double resolution = qMax(qAbs(sc.x()), qAbs(sc.y()));
|
||||
if (_projection.isGeographic())
|
||||
resolution *= deg2rad(WGS84_RADIUS);
|
||||
|
||||
|
@ -46,7 +46,7 @@ private slots:
|
||||
|
||||
private:
|
||||
QString tileUrl(const QString &version) const;
|
||||
qreal sd2res(qreal scaleDenominator) const;
|
||||
double sd2res(double scaleDenominator) const;
|
||||
QString tilesDir() const;
|
||||
void computeZooms(const RangeF &scaleDenominator);
|
||||
void updateTransform();
|
||||
@ -62,7 +62,7 @@ private:
|
||||
Projection _projection;
|
||||
Transform _transform;
|
||||
CoordinateSystem _cs;
|
||||
QVector<qreal> _zooms;
|
||||
QVector<double> _zooms;
|
||||
QRectF _boundingBox;
|
||||
int _zoom;
|
||||
bool _block;
|
||||
|
@ -54,7 +54,7 @@ public:
|
||||
class Zoom
|
||||
{
|
||||
public:
|
||||
Zoom(const QString &id, qreal scaleDenominator, const QPointF &topLeft,
|
||||
Zoom(const QString &id, double scaleDenominator, const QPointF &topLeft,
|
||||
const QSize &tile, const QSize &matrix, const QRect &limits) :
|
||||
_id(id), _scaleDenominator(scaleDenominator), _topLeft(topLeft),
|
||||
_tile(tile), _matrix(matrix), _limits(limits) {}
|
||||
@ -62,7 +62,7 @@ public:
|
||||
{return _scaleDenominator > other._scaleDenominator;}
|
||||
|
||||
const QString &id() const {return _id;}
|
||||
qreal scaleDenominator() const {return _scaleDenominator;}
|
||||
double scaleDenominator() const {return _scaleDenominator;}
|
||||
const QPointF &topLeft() const {return _topLeft;}
|
||||
const QSize &tile() const {return _tile;}
|
||||
const QSize &matrix() const {return _matrix;}
|
||||
@ -70,7 +70,7 @@ public:
|
||||
|
||||
private:
|
||||
QString _id;
|
||||
qreal _scaleDenominator;
|
||||
double _scaleDenominator;
|
||||
QPointF _topLeft;
|
||||
QSize _tile;
|
||||
QSize _matrix;
|
||||
@ -94,7 +94,7 @@ public:
|
||||
private:
|
||||
struct TileMatrix {
|
||||
QString id;
|
||||
qreal scaleDenominator;
|
||||
double scaleDenominator;
|
||||
QPointF topLeft;
|
||||
QSize tile;
|
||||
QSize matrix;
|
||||
|
@ -62,7 +62,7 @@ QString WMTSMap::tilesDir() const
|
||||
return QString(TILES_DIR + "/" + _name);
|
||||
}
|
||||
|
||||
qreal WMTSMap::sd2res(qreal scaleDenominator) const
|
||||
double WMTSMap::sd2res(double scaleDenominator) const
|
||||
{
|
||||
return scaleDenominator * 0.28e-3 * _projection.units().fromMeters(1.0);
|
||||
}
|
||||
@ -75,7 +75,7 @@ void WMTSMap::updateTransform()
|
||||
QPointF topLeft = (_cs.axisOrder() == CoordinateSystem::YX)
|
||||
? QPointF(z.topLeft().y(), z.topLeft().x()) : z.topLeft();
|
||||
|
||||
qreal pixelSpan = sd2res(z.scaleDenominator());
|
||||
double pixelSpan = sd2res(z.scaleDenominator());
|
||||
if (_projection.isGeographic())
|
||||
pixelSpan /= deg2rad(WGS84_RADIUS);
|
||||
QPointF tileSpan(z.tile().width() * pixelSpan, z.tile().height() * pixelSpan);
|
||||
|
@ -46,7 +46,7 @@ private slots:
|
||||
|
||||
private:
|
||||
bool loadWMTS();
|
||||
qreal sd2res(qreal scaleDenominator) const;
|
||||
double sd2res(double scaleDenominator) const;
|
||||
QString tilesDir() const;
|
||||
void updateTransform();
|
||||
|
||||
|
Reference in New Issue
Block a user