mirror of
https://github.com/tumic0/GPXSee.git
synced 2024-11-24 11:45:53 +01:00
Map API cleanup
This commit is contained in:
parent
5547cf668e
commit
262ee5bb5f
@ -22,12 +22,12 @@ static bool resCmp(OfflineMap *m1, OfflineMap *m2)
|
|||||||
return r1 > r2;
|
return r1 > r2;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool xCmp(const OfflineMap *m1, const OfflineMap *m2)
|
static bool xCmp(OfflineMap *m1, OfflineMap *m2)
|
||||||
{
|
{
|
||||||
return TL(m1).x() < TL(m2).x();
|
return TL(m1).x() < TL(m2).x();
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool yCmp(const OfflineMap *m1, const OfflineMap *m2)
|
static bool yCmp(OfflineMap *m1, OfflineMap *m2)
|
||||||
{
|
{
|
||||||
return TL(m1).y() > TL(m2).y();
|
return TL(m1).y() > TL(m2).y();
|
||||||
}
|
}
|
||||||
@ -147,7 +147,7 @@ Atlas::Atlas(const QString &fileName, QObject *parent)
|
|||||||
_valid = true;
|
_valid = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QRectF Atlas::bounds() const
|
QRectF Atlas::bounds()
|
||||||
{
|
{
|
||||||
QSizeF s(0, 0);
|
QSizeF s(0, 0);
|
||||||
|
|
||||||
|
@ -13,9 +13,9 @@ class Atlas : public Map
|
|||||||
public:
|
public:
|
||||||
Atlas(const QString &fileName, QObject *parent = 0);
|
Atlas(const QString &fileName, QObject *parent = 0);
|
||||||
|
|
||||||
const QString &name() const {return _name;}
|
QString name() const {return _name;}
|
||||||
|
|
||||||
QRectF bounds() const;
|
QRectF bounds();
|
||||||
|
|
||||||
int zoom() const {return _zoom;}
|
int zoom() const {return _zoom;}
|
||||||
void setZoom(int zoom);
|
void setZoom(int zoom);
|
||||||
|
@ -46,7 +46,7 @@ EmptyMap::EmptyMap(QObject *parent) : Map(parent)
|
|||||||
_zoom = ZOOM_MAX;
|
_zoom = ZOOM_MAX;
|
||||||
}
|
}
|
||||||
|
|
||||||
QRectF EmptyMap::bounds() const
|
QRectF EmptyMap::bounds()
|
||||||
{
|
{
|
||||||
return QRectF(ll2xy(Coordinates(-180, 85)), ll2xy(Coordinates(180, -85)));
|
return QRectF(ll2xy(Coordinates(-180, 85)), ll2xy(Coordinates(180, -85)));
|
||||||
}
|
}
|
||||||
@ -92,14 +92,14 @@ void EmptyMap::draw(QPainter *painter, const QRectF &rect, bool block)
|
|||||||
Q_UNUSED(block);
|
Q_UNUSED(block);
|
||||||
}
|
}
|
||||||
|
|
||||||
QPointF EmptyMap::ll2xy(const Coordinates &c) const
|
QPointF EmptyMap::ll2xy(const Coordinates &c)
|
||||||
{
|
{
|
||||||
qreal scale = zoom2scale(_zoom);
|
qreal scale = zoom2scale(_zoom);
|
||||||
QPointF m = ll2m(c);
|
QPointF m = ll2m(c);
|
||||||
return QPointF(m.x() / scale, m.y() / -scale);
|
return QPointF(m.x() / scale, m.y() / -scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
Coordinates EmptyMap::xy2ll(const QPointF &p) const
|
Coordinates EmptyMap::xy2ll(const QPointF &p)
|
||||||
{
|
{
|
||||||
qreal scale = zoom2scale(_zoom);
|
qreal scale = zoom2scale(_zoom);
|
||||||
return m2ll(QPointF(p.x() * scale, -p.y() * scale));
|
return m2ll(QPointF(p.x() * scale, -p.y() * scale));
|
||||||
|
@ -10,9 +10,9 @@ class EmptyMap : public Map
|
|||||||
public:
|
public:
|
||||||
EmptyMap(QObject *parent = 0);
|
EmptyMap(QObject *parent = 0);
|
||||||
|
|
||||||
const QString &name() const {return _name;}
|
QString name() const {return QString();}
|
||||||
|
|
||||||
QRectF bounds() const;
|
QRectF bounds();
|
||||||
qreal resolution(const QRectF &rect);
|
qreal resolution(const QRectF &rect);
|
||||||
|
|
||||||
int zoom() const {return _zoom;}
|
int zoom() const {return _zoom;}
|
||||||
@ -21,18 +21,12 @@ public:
|
|||||||
int zoomIn();
|
int zoomIn();
|
||||||
int zoomOut();
|
int zoomOut();
|
||||||
|
|
||||||
QPointF ll2xy(const Coordinates &c)
|
QPointF ll2xy(const Coordinates &c);
|
||||||
{return static_cast<const EmptyMap &>(*this).ll2xy(c);}
|
Coordinates xy2ll(const QPointF &p);
|
||||||
Coordinates xy2ll(const QPointF &p)
|
|
||||||
{return static_cast<const EmptyMap &>(*this).xy2ll(p);}
|
|
||||||
|
|
||||||
void draw(QPainter *painter, const QRectF &rect, bool block);
|
void draw(QPainter *painter, const QRectF &rect, bool block);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QPointF ll2xy(const Coordinates &c) const;
|
|
||||||
Coordinates xy2ll(const QPointF &p) const;
|
|
||||||
|
|
||||||
QString _name;
|
|
||||||
int _zoom;
|
int _zoom;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -158,7 +158,7 @@ Coordinates JNXMap::xy2ll(const QPointF &p)
|
|||||||
return Coordinates(pp.x(), pp.y());
|
return Coordinates(pp.x(), pp.y());
|
||||||
}
|
}
|
||||||
|
|
||||||
QRectF JNXMap::bounds() const
|
QRectF JNXMap::bounds()
|
||||||
{
|
{
|
||||||
const Transform &t = _zooms.at(_zoom).transform;
|
const Transform &t = _zooms.at(_zoom).transform;
|
||||||
|
|
||||||
|
@ -16,9 +16,9 @@ public:
|
|||||||
public:
|
public:
|
||||||
JNXMap(const QString &fileName, QObject *parent = 0);
|
JNXMap(const QString &fileName, QObject *parent = 0);
|
||||||
|
|
||||||
const QString &name() const {return _name;}
|
QString name() const {return _name;}
|
||||||
|
|
||||||
QRectF bounds() const;
|
QRectF bounds();
|
||||||
|
|
||||||
int zoom() const {return _zoom;}
|
int zoom() const {return _zoom;}
|
||||||
void setZoom(int zoom) {_zoom = zoom;}
|
void setZoom(int zoom) {_zoom = zoom;}
|
||||||
|
@ -18,9 +18,9 @@ public:
|
|||||||
Map(QObject *parent = 0) : QObject(parent) {}
|
Map(QObject *parent = 0) : QObject(parent) {}
|
||||||
virtual ~Map() {}
|
virtual ~Map() {}
|
||||||
|
|
||||||
virtual const QString &name() const = 0;
|
virtual QString name() const = 0;
|
||||||
|
|
||||||
virtual QRectF bounds() const = 0;
|
virtual QRectF bounds() = 0;
|
||||||
virtual qreal resolution(const QRectF &rect);
|
virtual qreal resolution(const QRectF &rect);
|
||||||
|
|
||||||
virtual int zoom() const = 0;
|
virtual int zoom() const = 0;
|
||||||
|
@ -333,7 +333,7 @@ Coordinates OfflineMap::xy2ll(const QPointF &p)
|
|||||||
: _projection.xy2ll(_transform.img2proj(p));
|
: _projection.xy2ll(_transform.img2proj(p));
|
||||||
}
|
}
|
||||||
|
|
||||||
QRectF OfflineMap::bounds() const
|
QRectF OfflineMap::bounds()
|
||||||
{
|
{
|
||||||
return _ozf
|
return _ozf
|
||||||
? QRectF(QPointF(0, 0), _ozf->size(_zoom))
|
? QRectF(QPointF(0, 0), _ozf->size(_zoom))
|
||||||
|
@ -18,9 +18,9 @@ public:
|
|||||||
OfflineMap(const QString &fileName, Tar &tar, QObject *parent = 0);
|
OfflineMap(const QString &fileName, Tar &tar, QObject *parent = 0);
|
||||||
~OfflineMap();
|
~OfflineMap();
|
||||||
|
|
||||||
const QString &name() const {return _name;}
|
QString name() const {return _name;}
|
||||||
|
|
||||||
QRectF bounds() const;
|
QRectF bounds();
|
||||||
|
|
||||||
int zoom() const {return _zoom;}
|
int zoom() const {return _zoom;}
|
||||||
void setZoom(int zoom) {_zoom = zoom;}
|
void setZoom(int zoom) {_zoom = zoom;}
|
||||||
|
@ -64,7 +64,7 @@ OnlineMap::OnlineMap(const QString &name, const QString &url,
|
|||||||
_valid = true;
|
_valid = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QRectF OnlineMap::bounds() const
|
QRectF OnlineMap::bounds()
|
||||||
{
|
{
|
||||||
return QRectF(ll2xy(_bounds.topLeft()), ll2xy(_bounds.bottomRight()));
|
return QRectF(ll2xy(_bounds.topLeft()), ll2xy(_bounds.bottomRight()));
|
||||||
}
|
}
|
||||||
@ -141,14 +141,14 @@ void OnlineMap::draw(QPainter *painter, const QRectF &rect, bool block)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QPointF OnlineMap::ll2xy(const Coordinates &c) const
|
QPointF OnlineMap::ll2xy(const Coordinates &c)
|
||||||
{
|
{
|
||||||
qreal scale = zoom2scale(_zoom);
|
qreal scale = zoom2scale(_zoom);
|
||||||
QPointF m = ll2m(c);
|
QPointF m = ll2m(c);
|
||||||
return QPointF(m.x() / scale, m.y() / -scale);
|
return QPointF(m.x() / scale, m.y() / -scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
Coordinates OnlineMap::xy2ll(const QPointF &p) const
|
Coordinates OnlineMap::xy2ll(const QPointF &p)
|
||||||
{
|
{
|
||||||
qreal scale = zoom2scale(_zoom);
|
qreal scale = zoom2scale(_zoom);
|
||||||
return m2ll(QPointF(p.x() * scale, -p.y() * scale));
|
return m2ll(QPointF(p.x() * scale, -p.y() * scale));
|
||||||
|
@ -15,9 +15,9 @@ public:
|
|||||||
const RectC &bounds, const Authorization &authorization,
|
const RectC &bounds, const Authorization &authorization,
|
||||||
QObject *parent = 0);
|
QObject *parent = 0);
|
||||||
|
|
||||||
const QString &name() const {return _name;}
|
QString name() const {return _name;}
|
||||||
|
|
||||||
QRectF bounds() const;
|
QRectF bounds();
|
||||||
qreal resolution(const QRectF &rect);
|
qreal resolution(const QRectF &rect);
|
||||||
|
|
||||||
int zoom() const {return _zoom;}
|
int zoom() const {return _zoom;}
|
||||||
@ -26,10 +26,8 @@ public:
|
|||||||
int zoomIn();
|
int zoomIn();
|
||||||
int zoomOut();
|
int zoomOut();
|
||||||
|
|
||||||
QPointF ll2xy(const Coordinates &c)
|
QPointF ll2xy(const Coordinates &c);
|
||||||
{return static_cast<const OnlineMap &>(*this).ll2xy(c);}
|
Coordinates xy2ll(const QPointF &p);
|
||||||
Coordinates xy2ll(const QPointF &p)
|
|
||||||
{return static_cast<const OnlineMap &>(*this).xy2ll(p);}
|
|
||||||
|
|
||||||
void draw(QPainter *painter, const QRectF &rect, bool block);
|
void draw(QPainter *painter, const QRectF &rect, bool block);
|
||||||
|
|
||||||
@ -39,8 +37,6 @@ public:
|
|||||||
QString errorString() const {return _errorString;}
|
QString errorString() const {return _errorString;}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QPointF ll2xy(const Coordinates &c) const;
|
|
||||||
Coordinates xy2ll(const QPointF &p) const;
|
|
||||||
int limitZoom(int zoom) const;
|
int limitZoom(int zoom) const;
|
||||||
|
|
||||||
TileLoader *_tileLoader;
|
TileLoader *_tileLoader;
|
||||||
|
@ -127,7 +127,7 @@ void WMSMap::clearCache()
|
|||||||
qWarning("%s: %s\n", qPrintable(_name), qPrintable(_errorString));
|
qWarning("%s: %s\n", qPrintable(_name), qPrintable(_errorString));
|
||||||
}
|
}
|
||||||
|
|
||||||
QRectF WMSMap::bounds() const
|
QRectF WMSMap::bounds()
|
||||||
{
|
{
|
||||||
return QRectF(_transform.proj2img(_bbox.topLeft()),
|
return QRectF(_transform.proj2img(_bbox.topLeft()),
|
||||||
_transform.proj2img(_bbox.bottomRight()));
|
_transform.proj2img(_bbox.bottomRight()));
|
||||||
|
@ -16,9 +16,9 @@ class WMSMap : public Map
|
|||||||
public:
|
public:
|
||||||
WMSMap(const QString &name, const WMS::Setup &setup, QObject *parent = 0);
|
WMSMap(const QString &name, const WMS::Setup &setup, QObject *parent = 0);
|
||||||
|
|
||||||
const QString &name() const {return _name;}
|
QString name() const {return _name;}
|
||||||
|
|
||||||
QRectF bounds() const;
|
QRectF bounds();
|
||||||
|
|
||||||
int zoom() const {return _zoom;}
|
int zoom() const {return _zoom;}
|
||||||
void setZoom(int zoom);
|
void setZoom(int zoom);
|
||||||
|
@ -91,7 +91,7 @@ void WMTSMap::updateTransform()
|
|||||||
_transform = Transform(tl, br);
|
_transform = Transform(tl, br);
|
||||||
}
|
}
|
||||||
|
|
||||||
QRectF WMTSMap::bounds() const
|
QRectF WMTSMap::bounds()
|
||||||
{
|
{
|
||||||
const WMTS::Zoom &z = _zooms.at(_zoom);
|
const WMTS::Zoom &z = _zooms.at(_zoom);
|
||||||
QRectF tileBounds, bounds;
|
QRectF tileBounds, bounds;
|
||||||
@ -179,12 +179,12 @@ void WMTSMap::draw(QPainter *painter, const QRectF &rect, bool block)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QPointF WMTSMap::ll2xy(const Coordinates &c) const
|
QPointF WMTSMap::ll2xy(const Coordinates &c)
|
||||||
{
|
{
|
||||||
return _transform.proj2img(_projection.ll2xy(c));
|
return _transform.proj2img(_projection.ll2xy(c));
|
||||||
}
|
}
|
||||||
|
|
||||||
Coordinates WMTSMap::xy2ll(const QPointF &p) const
|
Coordinates WMTSMap::xy2ll(const QPointF &p)
|
||||||
{
|
{
|
||||||
return _projection.xy2ll(_transform.img2proj(p));
|
return _projection.xy2ll(_transform.img2proj(p));
|
||||||
}
|
}
|
||||||
|
@ -15,9 +15,9 @@ class WMTSMap : public Map
|
|||||||
public:
|
public:
|
||||||
WMTSMap(const QString &name, const WMTS::Setup &setup, QObject *parent = 0);
|
WMTSMap(const QString &name, const WMTS::Setup &setup, QObject *parent = 0);
|
||||||
|
|
||||||
const QString &name() const {return _name;}
|
QString name() const {return _name;}
|
||||||
|
|
||||||
QRectF bounds() const;
|
QRectF bounds();
|
||||||
|
|
||||||
int zoom() const {return _zoom;}
|
int zoom() const {return _zoom;}
|
||||||
void setZoom(int zoom);
|
void setZoom(int zoom);
|
||||||
@ -25,10 +25,8 @@ public:
|
|||||||
int zoomIn();
|
int zoomIn();
|
||||||
int zoomOut();
|
int zoomOut();
|
||||||
|
|
||||||
QPointF ll2xy(const Coordinates &c)
|
QPointF ll2xy(const Coordinates &c);
|
||||||
{return static_cast<const WMTSMap &>(*this).ll2xy(c);}
|
Coordinates xy2ll(const QPointF &p);
|
||||||
Coordinates xy2ll(const QPointF &p)
|
|
||||||
{return static_cast<const WMTSMap &>(*this).xy2ll(p);}
|
|
||||||
|
|
||||||
void draw(QPainter *painter, const QRectF &rect, bool block);
|
void draw(QPainter *painter, const QRectF &rect, bool block);
|
||||||
|
|
||||||
@ -43,9 +41,6 @@ private:
|
|||||||
QString tilesDir() const;
|
QString tilesDir() const;
|
||||||
void updateTransform();
|
void updateTransform();
|
||||||
|
|
||||||
QPointF ll2xy(const Coordinates &c) const;
|
|
||||||
Coordinates xy2ll(const QPointF &p) const;
|
|
||||||
|
|
||||||
QString _name;
|
QString _name;
|
||||||
WMTS::Setup _setup;
|
WMTS::Setup _setup;
|
||||||
TileLoader *_tileLoader;
|
TileLoader *_tileLoader;
|
||||||
|
Loading…
Reference in New Issue
Block a user