mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-02-07 12:05:14 +01:00
Using a more human-readable online maps bounds definition
This commit is contained in:
parent
66f0f6a202
commit
04a145a2e7
@ -18,7 +18,7 @@ EmptyMap::EmptyMap(QObject *parent) : Map(parent)
|
|||||||
|
|
||||||
QRectF EmptyMap::bounds() const
|
QRectF EmptyMap::bounds() const
|
||||||
{
|
{
|
||||||
return scaled(QRectF(QPointF(-180, -180), QSizeF(360, 360)), 1.0/_scale);
|
return QRectF(ll2xy(Coordinates(-180, 85)), ll2xy(Coordinates(180, -85)));
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal EmptyMap::zoomFit(const QSize &size, const RectC &br)
|
qreal EmptyMap::zoomFit(const QSize &size, const RectC &br)
|
||||||
@ -72,13 +72,13 @@ void EmptyMap::draw(QPainter *painter, const QRectF &rect)
|
|||||||
painter->fillRect(rect, _backgroundColor);
|
painter->fillRect(rect, _backgroundColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
QPointF EmptyMap::ll2xy(const Coordinates &c)
|
QPointF EmptyMap::ll2xy(const Coordinates &c) const
|
||||||
{
|
{
|
||||||
QPointF m = Mercator().ll2xy(c);
|
QPointF m = Mercator().ll2xy(c);
|
||||||
return QPointF(m.x() / _scale, m.y() / -_scale);
|
return QPointF(m.x() / _scale, m.y() / -_scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
Coordinates EmptyMap::xy2ll(const QPointF &p)
|
Coordinates EmptyMap::xy2ll(const QPointF &p) const
|
||||||
{
|
{
|
||||||
QPointF m(p.x() * _scale, -p.y() * _scale);
|
QPointF m(p.x() * _scale, -p.y() * _scale);
|
||||||
return Mercator().xy2ll(m);
|
return Mercator().xy2ll(m);
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#ifndef EMPTYMAP_H
|
#ifndef EMPTYMAP_H
|
||||||
#define EMPTYMAP_H
|
#define EMPTYMAP_H
|
||||||
|
|
||||||
|
#include "common/coordinates.h"
|
||||||
#include "map.h"
|
#include "map.h"
|
||||||
|
|
||||||
class EmptyMap : public Map
|
class EmptyMap : public Map
|
||||||
@ -21,12 +22,17 @@ public:
|
|||||||
qreal zoomIn();
|
qreal zoomIn();
|
||||||
qreal zoomOut();
|
qreal zoomOut();
|
||||||
|
|
||||||
QPointF ll2xy(const Coordinates &c);
|
QPointF ll2xy(const Coordinates &c)
|
||||||
Coordinates xy2ll(const QPointF &p);
|
{return static_cast<const EmptyMap &>(*this).ll2xy(c);}
|
||||||
|
Coordinates xy2ll(const QPointF &p)
|
||||||
|
{return static_cast<const EmptyMap &>(*this).xy2ll(p);}
|
||||||
|
|
||||||
void draw(QPainter *painter, const QRectF &rect);
|
void draw(QPainter *painter, const QRectF &rect);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
QPointF ll2xy(const Coordinates &c) const;
|
||||||
|
Coordinates xy2ll(const QPointF &p) const;
|
||||||
|
|
||||||
QString _name;
|
QString _name;
|
||||||
qreal _scale;
|
qreal _scale;
|
||||||
};
|
};
|
||||||
|
@ -1,7 +0,0 @@
|
|||||||
#include <QRectF>
|
|
||||||
|
|
||||||
inline QRectF scaled(const QRectF &rect, qreal factor)
|
|
||||||
{
|
|
||||||
return QRectF(QPointF(rect.left() * factor, rect.top() * factor),
|
|
||||||
QSizeF(rect.width() * factor, rect.height() * factor));
|
|
||||||
}
|
|
@ -168,8 +168,7 @@ void OnlineMap::clearCache()
|
|||||||
|
|
||||||
QRectF OnlineMap::bounds() const
|
QRectF OnlineMap::bounds() const
|
||||||
{
|
{
|
||||||
return scaled(QRectF(QPointF(-180, -180), QSizeF(360, 360)),
|
return QRectF(ll2xy(Coordinates(-180, 85)), ll2xy(Coordinates(180, -85)));
|
||||||
1.0/zoom2scale(_zoom));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int OnlineMap::limitZoom(int zoom) const
|
int OnlineMap::limitZoom(int zoom) const
|
||||||
@ -253,14 +252,14 @@ void OnlineMap::draw(QPainter *painter, const QRectF &rect)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QPointF OnlineMap::ll2xy(const Coordinates &c)
|
QPointF OnlineMap::ll2xy(const Coordinates &c) const
|
||||||
{
|
{
|
||||||
qreal scale = zoom2scale(_zoom);
|
qreal scale = zoom2scale(_zoom);
|
||||||
QPointF m = Mercator().ll2xy(c);
|
QPointF m = Mercator().ll2xy(c);
|
||||||
return QPointF(m.x() / scale, m.y() / -scale);
|
return QPointF(m.x() / scale, m.y() / -scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
Coordinates OnlineMap::xy2ll(const QPointF &p)
|
Coordinates OnlineMap::xy2ll(const QPointF &p) const
|
||||||
{
|
{
|
||||||
qreal scale = zoom2scale(_zoom);
|
qreal scale = zoom2scale(_zoom);
|
||||||
QPointF m(p.x() * scale, -p.y() * scale);
|
QPointF m(p.x() * scale, -p.y() * scale);
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#ifndef ONLINEMAP_H
|
#ifndef ONLINEMAP_H
|
||||||
#define ONLINEMAP_H
|
#define ONLINEMAP_H
|
||||||
|
|
||||||
|
#include "common/coordinates.h"
|
||||||
#include "common/range.h"
|
#include "common/range.h"
|
||||||
#include "map.h"
|
#include "map.h"
|
||||||
#include "tile.h"
|
#include "tile.h"
|
||||||
@ -26,8 +27,10 @@ public:
|
|||||||
qreal zoomIn();
|
qreal zoomIn();
|
||||||
qreal zoomOut();
|
qreal zoomOut();
|
||||||
|
|
||||||
QPointF ll2xy(const Coordinates &c);
|
QPointF ll2xy(const Coordinates &c)
|
||||||
Coordinates xy2ll(const QPointF &p);
|
{return static_cast<const OnlineMap &>(*this).ll2xy(c);}
|
||||||
|
Coordinates xy2ll(const QPointF &p)
|
||||||
|
{return static_cast<const OnlineMap &>(*this).xy2ll(p);}
|
||||||
|
|
||||||
void draw(QPainter *painter, const QRectF &rect);
|
void draw(QPainter *painter, const QRectF &rect);
|
||||||
|
|
||||||
@ -44,6 +47,9 @@ private slots:
|
|||||||
void emitLoaded();
|
void emitLoaded();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
QPointF ll2xy(const Coordinates &c) const;
|
||||||
|
Coordinates xy2ll(const QPointF &p) const;
|
||||||
|
|
||||||
void fillTile(Tile &tile);
|
void fillTile(Tile &tile);
|
||||||
QString tileUrl(const Tile &tile) const;
|
QString tileUrl(const Tile &tile) const;
|
||||||
QString tileFile(const Tile &tile) const;
|
QString tileFile(const Tile &tile) const;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user