mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-06-25 10:48:04 +02:00
Added support for vector maps projection setting
Removed obsolete "Always show the map" setting
This commit is contained in:
@ -369,3 +369,10 @@ void IMGMap::draw(QPainter *painter, const QRectF &rect, Flags flags)
|
||||
painter->drawPixmap(mt.xy(), pm);
|
||||
}
|
||||
}
|
||||
|
||||
void IMGMap::setProjection(const Projection &projection)
|
||||
{
|
||||
_projection = projection;
|
||||
updateTransform();
|
||||
QPixmapCache::clear();
|
||||
}
|
||||
|
@ -31,6 +31,8 @@ public:
|
||||
|
||||
void draw(QPainter *painter, const QRectF &rect, Flags flags);
|
||||
|
||||
void setProjection(const Projection &projection);
|
||||
|
||||
bool isValid() const {return _valid;}
|
||||
QString errorString() const {return _errorString;}
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include <QLineF>
|
||||
#include "map.h"
|
||||
#include "pcs.h"
|
||||
|
||||
qreal Map::resolution(const QRectF &rect)
|
||||
{
|
||||
|
@ -7,8 +7,10 @@
|
||||
#include <QFlags>
|
||||
#include "common/coordinates.h"
|
||||
|
||||
|
||||
class QPainter;
|
||||
class RectC;
|
||||
class Projection;
|
||||
|
||||
class Map : public QObject
|
||||
{
|
||||
@ -45,6 +47,7 @@ public:
|
||||
virtual void load() {}
|
||||
virtual void unload() {}
|
||||
virtual void setDevicePixelRatio(qreal, qreal) {}
|
||||
virtual void setProjection(const Projection &) {}
|
||||
|
||||
virtual bool isValid() const {return true;}
|
||||
virtual QString errorString() const {return QString();}
|
||||
|
@ -5,13 +5,16 @@
|
||||
|
||||
class PCS::Entry {
|
||||
public:
|
||||
Entry(int id, int proj, const PCS &pcs) : _id(id), _proj(proj), _pcs(pcs) {}
|
||||
Entry(const QString &name, int id, int proj, const PCS &pcs)
|
||||
: _name(name), _id(id), _proj(proj), _pcs(pcs) {}
|
||||
|
||||
const QString &name() const {return _name;}
|
||||
int id() const {return _id;}
|
||||
int proj() const {return _proj;}
|
||||
const PCS &pcs() const {return _pcs;}
|
||||
|
||||
private:
|
||||
QString _name;
|
||||
int _id, _proj;
|
||||
PCS _pcs;
|
||||
};
|
||||
@ -21,8 +24,9 @@ QList<PCS::Entry> PCS::_pcss = defaults();
|
||||
QList<PCS::Entry> PCS::defaults()
|
||||
{
|
||||
QList<PCS::Entry> list;
|
||||
list.append(PCS::Entry(3857, 3856, PCS(&GCS::WGS84(), 1024,
|
||||
Projection::Setup(0, 0, NAN, 0, 0, NAN, NAN), 9001, 4499)));
|
||||
list.append(PCS::Entry("WGS 84 / Pseudo-Mercator", 3857, 3856,
|
||||
PCS(&GCS::WGS84(), 1024, Projection::Setup(0, 0, NAN, 0, 0, NAN, NAN),
|
||||
9001, 4499)));
|
||||
return list;
|
||||
}
|
||||
|
||||
@ -154,27 +158,28 @@ void PCS::loadList(const QString &path)
|
||||
continue;
|
||||
}
|
||||
|
||||
int id = list[1].trimmed().toInt(&res);
|
||||
QString name(list.at(0).trimmed());
|
||||
int id = list.at(1).trimmed().toInt(&res);
|
||||
if (!res) {
|
||||
qWarning("%s:%d: Invalid PCS code", qPrintable(path), ln);
|
||||
continue;
|
||||
}
|
||||
int gcsid = list[2].trimmed().toInt(&res);
|
||||
int gcsid = list.at(2).trimmed().toInt(&res);
|
||||
if (!res) {
|
||||
qWarning("%s:%d: Invalid GCS code", qPrintable(path), ln);
|
||||
continue;
|
||||
}
|
||||
int proj = list[3].trimmed().toInt(&res);
|
||||
int proj = list.at(3).trimmed().toInt(&res);
|
||||
if (!res) {
|
||||
qWarning("%s:%d: Invalid projection code", qPrintable(path), ln);
|
||||
continue;
|
||||
}
|
||||
int units = list[4].trimmed().toInt(&res);
|
||||
int units = list.at(4).trimmed().toInt(&res);
|
||||
if (!res) {
|
||||
qWarning("%s:%d: Invalid linear units code", qPrintable(path), ln);
|
||||
continue;
|
||||
}
|
||||
int transform = list[5].trimmed().toInt(&res);
|
||||
int transform = list.at(5).trimmed().toInt(&res);
|
||||
if (!res) {
|
||||
qWarning("%s:%d: Invalid coordinate transformation code",
|
||||
qPrintable(path), ln);
|
||||
@ -214,10 +219,20 @@ void PCS::loadList(const QString &path)
|
||||
}
|
||||
|
||||
PCS pcs(gcs, transform, setup, units, cs);
|
||||
_pcss.append(Entry(id, proj, pcs));
|
||||
_pcss.append(Entry(name, id, proj, pcs));
|
||||
}
|
||||
}
|
||||
|
||||
QList<PCS::Info> PCS::pcsList()
|
||||
{
|
||||
QList<Info> list;
|
||||
|
||||
for (int i = 0; i < _pcss.size(); i++)
|
||||
list.append(Info(_pcss.at(i).id(), _pcss.at(i).name()));
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
QDebug operator<<(QDebug dbg, const PCS &pcs)
|
||||
{
|
||||
|
@ -11,6 +11,20 @@
|
||||
class PCS
|
||||
{
|
||||
public:
|
||||
class Info {
|
||||
public:
|
||||
Info(int id, const QString &name) : _id(id), _name(name) {}
|
||||
|
||||
int id() const {return _id;}
|
||||
const QString &name() const {return _name;}
|
||||
|
||||
bool operator<(const Info &other) const {return _id < other._id;}
|
||||
|
||||
private:
|
||||
int _id;
|
||||
QString _name;
|
||||
};
|
||||
|
||||
PCS() : _gcs(0) {}
|
||||
PCS(const GCS *gcs, const Projection::Method &method,
|
||||
const Projection::Setup &setup, const LinearUnits &units,
|
||||
@ -34,11 +48,12 @@ public:
|
||||
static void loadList(const QString &path);
|
||||
static const PCS *pcs(int id);
|
||||
static const PCS *pcs(const GCS *gcs, int proj);
|
||||
static QList<Info> pcsList();
|
||||
|
||||
private:
|
||||
class Entry;
|
||||
|
||||
static QList<PCS::Entry> defaults();
|
||||
static QList<Entry> defaults();
|
||||
|
||||
const GCS *_gcs;
|
||||
Projection::Method _method;
|
||||
|
Reference in New Issue
Block a user