mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-01-31 09:05:14 +01:00
Added workaround for broken nakarte.tk maps
This commit is contained in:
parent
d794ee4b22
commit
5706cdcfa1
@ -3,6 +3,8 @@
|
|||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QPixmapCache>
|
#include <QPixmapCache>
|
||||||
#include "rectd.h"
|
#include "rectd.h"
|
||||||
|
#include "gcs.h"
|
||||||
|
#include "pcs.h"
|
||||||
#include "jnxmap.h"
|
#include "jnxmap.h"
|
||||||
|
|
||||||
|
|
||||||
@ -82,6 +84,15 @@ bool JNXMap::readTiles()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QByteArray guid;
|
||||||
|
if (!(readValue(dummy) && readString(guid)))
|
||||||
|
return false;
|
||||||
|
/* Use WebMercator projection for nakarte.tk maps */
|
||||||
|
if (guid == "12345678-1234-1234-1234-123456789ABC")
|
||||||
|
_projection = Projection(PCS::pcs(3857));
|
||||||
|
else
|
||||||
|
_projection = Projection(GCS::gcs(4326));
|
||||||
|
|
||||||
_zooms = QVector<Zoom>(lh.size());
|
_zooms = QVector<Zoom>(lh.size());
|
||||||
for (int i = 0; i < lh.count(); i++) {
|
for (int i = 0; i < lh.count(); i++) {
|
||||||
Zoom &z = _zooms[i];
|
Zoom &z = _zooms[i];
|
||||||
@ -102,8 +113,8 @@ bool JNXMap::readTiles()
|
|||||||
&& readValue(tile.offset)))
|
&& readValue(tile.offset)))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
RectD rect(PointD(ic2dc(left), ic2dc(top)), PointD(ic2dc(right),
|
RectD rect(_projection.ll2xy(Coordinates(ic2dc(left), ic2dc(top))),
|
||||||
ic2dc(bottom)));
|
_projection.ll2xy(Coordinates(ic2dc(right), ic2dc(bottom))));
|
||||||
|
|
||||||
if (j == 0) {
|
if (j == 0) {
|
||||||
ReferencePoint tl(PointD(0, 0), rect.topLeft());
|
ReferencePoint tl(PointD(0, 0), rect.topLeft());
|
||||||
@ -147,24 +158,19 @@ JNXMap::JNXMap(const QString &fileName, QObject *parent)
|
|||||||
|
|
||||||
QPointF JNXMap::ll2xy(const Coordinates &c)
|
QPointF JNXMap::ll2xy(const Coordinates &c)
|
||||||
{
|
{
|
||||||
const Transform &t = _zooms.at(_zoom).transform;
|
const Zoom &z = _zooms.at(_zoom);
|
||||||
return t.proj2img(PointD(c.lon(), c.lat()));
|
return z.transform.proj2img(_projection.ll2xy(c));
|
||||||
}
|
}
|
||||||
|
|
||||||
Coordinates JNXMap::xy2ll(const QPointF &p)
|
Coordinates JNXMap::xy2ll(const QPointF &p)
|
||||||
{
|
{
|
||||||
const Transform &t = _zooms.at(_zoom).transform;
|
const Zoom &z = _zooms.at(_zoom);
|
||||||
PointD pp(t.img2proj(p));
|
return _projection.xy2ll(z.transform.img2proj(p));
|
||||||
return Coordinates(pp.x(), pp.y());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QRectF JNXMap::bounds()
|
QRectF JNXMap::bounds()
|
||||||
{
|
{
|
||||||
const Transform &t = _zooms.at(_zoom).transform;
|
return QRectF(ll2xy(_bounds.topLeft()), ll2xy(_bounds.bottomRight()));
|
||||||
|
|
||||||
return QRectF(t.proj2img(PointD(_bounds.topLeft().lon(),
|
|
||||||
_bounds.topLeft().lat())), t.proj2img(PointD(_bounds.bottomRight().lon(),
|
|
||||||
_bounds.bottomRight().lat())));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int JNXMap::zoomFit(const QSize &size, const RectC &rect)
|
int JNXMap::zoomFit(const QSize &size, const RectC &rect)
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include "common/rtree.h"
|
#include "common/rtree.h"
|
||||||
#include "common/rectc.h"
|
#include "common/rectc.h"
|
||||||
#include "transform.h"
|
#include "transform.h"
|
||||||
|
#include "projection.h"
|
||||||
#include "map.h"
|
#include "map.h"
|
||||||
|
|
||||||
class JNXMap : public Map
|
class JNXMap : public Map
|
||||||
@ -59,6 +60,7 @@ private:
|
|||||||
QVector<Zoom> _zooms;
|
QVector<Zoom> _zooms;
|
||||||
int _zoom;
|
int _zoom;
|
||||||
RectC _bounds;
|
RectC _bounds;
|
||||||
|
Projection _projection;
|
||||||
|
|
||||||
bool _valid;
|
bool _valid;
|
||||||
QString _errorString;
|
QString _errorString;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user