mirror of
https://github.com/tumic0/GPXSee.git
synced 2024-11-28 05:34:47 +01:00
Refactoring
This commit is contained in:
parent
b8eede21c0
commit
60d9a172b6
@ -80,7 +80,7 @@ HEADERS += src/config.h \
|
|||||||
src/opengl.h \
|
src/opengl.h \
|
||||||
src/timetype.h \
|
src/timetype.h \
|
||||||
src/emptymap.h \
|
src/emptymap.h \
|
||||||
src/ozimap.h \
|
src/offlinemap.h \
|
||||||
src/mapdir.h \
|
src/mapdir.h \
|
||||||
src/matrix.h \
|
src/matrix.h \
|
||||||
src/tar.h
|
src/tar.h
|
||||||
@ -139,7 +139,7 @@ SOURCES += src/main.cpp \
|
|||||||
src/colorbox.cpp \
|
src/colorbox.cpp \
|
||||||
src/stylecombobox.cpp \
|
src/stylecombobox.cpp \
|
||||||
src/emptymap.cpp \
|
src/emptymap.cpp \
|
||||||
src/ozimap.cpp \
|
src/offlinemap.cpp \
|
||||||
src/mapdir.cpp \
|
src/mapdir.cpp \
|
||||||
src/matrix.cpp \
|
src/matrix.cpp \
|
||||||
src/tar.cpp
|
src/tar.cpp
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#include "mapdir.h"
|
#include "mapdir.h"
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include "ozimap.h"
|
#include "offlinemap.h"
|
||||||
|
|
||||||
QList<Map*> MapDir::load(const QString &path, QObject *parent)
|
QList<Map*> MapDir::load(const QString &path, QObject *parent)
|
||||||
{
|
{
|
||||||
@ -21,7 +21,7 @@ QList<Map*> MapDir::load(const QString &path, QObject *parent)
|
|||||||
QFileInfoList list = dir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot);
|
QFileInfoList list = dir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot);
|
||||||
for (int i = 0; i < list.size(); i++) {
|
for (int i = 0; i < list.size(); i++) {
|
||||||
QFileInfo fileInfo = list.at(i);
|
QFileInfo fileInfo = list.at(i);
|
||||||
OziMap *map = new OziMap(fileInfo.absoluteFilePath(), parent);
|
OfflineMap *map = new OfflineMap(fileInfo.absoluteFilePath(), parent);
|
||||||
if (map->isValid())
|
if (map->isValid())
|
||||||
maps.append(map);
|
maps.append(map);
|
||||||
else
|
else
|
||||||
|
@ -10,10 +10,10 @@
|
|||||||
#include "wgs84.h"
|
#include "wgs84.h"
|
||||||
#include "coordinates.h"
|
#include "coordinates.h"
|
||||||
#include "matrix.h"
|
#include "matrix.h"
|
||||||
#include "ozimap.h"
|
#include "offlinemap.h"
|
||||||
|
|
||||||
|
|
||||||
int OziMap::parseMapFile(QIODevice &device, QList<ReferencePoint> &points)
|
int OfflineMap::parseMapFile(QIODevice &device, QList<ReferencePoint> &points)
|
||||||
{
|
{
|
||||||
bool res;
|
bool res;
|
||||||
int ln = 1;
|
int ln = 1;
|
||||||
@ -78,7 +78,7 @@ int OziMap::parseMapFile(QIODevice &device, QList<ReferencePoint> &points)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OziMap::computeTransformation(const QList<ReferencePoint> &points)
|
bool OfflineMap::computeTransformation(const QList<ReferencePoint> &points)
|
||||||
{
|
{
|
||||||
if (points.count() < 2)
|
if (points.count() < 2)
|
||||||
return false;
|
return false;
|
||||||
@ -125,7 +125,7 @@ bool OziMap::computeTransformation(const QList<ReferencePoint> &points)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OziMap::computeResolution(QList<ReferencePoint> &points)
|
bool OfflineMap::computeResolution(QList<ReferencePoint> &points)
|
||||||
{
|
{
|
||||||
if (points.count() < 2)
|
if (points.count() < 2)
|
||||||
return false;
|
return false;
|
||||||
@ -154,7 +154,7 @@ bool OziMap::computeResolution(QList<ReferencePoint> &points)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OziMap::getTileName(const QStringList &tiles)
|
bool OfflineMap::getTileName(const QStringList &tiles)
|
||||||
{
|
{
|
||||||
if (tiles.isEmpty()) {
|
if (tiles.isEmpty()) {
|
||||||
qWarning("%s: empty tile set", qPrintable(_name));
|
qWarning("%s: empty tile set", qPrintable(_name));
|
||||||
@ -175,7 +175,7 @@ bool OziMap::getTileName(const QStringList &tiles)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OziMap::getTileSize()
|
bool OfflineMap::getTileSize()
|
||||||
{
|
{
|
||||||
QString tileName(_tileName.arg(QString::number(0), QString::number(0)));
|
QString tileName(_tileName.arg(QString::number(0), QString::number(0)));
|
||||||
QImage tile;
|
QImage tile;
|
||||||
@ -197,7 +197,7 @@ bool OziMap::getTileSize()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
OziMap::OziMap(const QString &path, QObject *parent) : Map(parent)
|
OfflineMap::OfflineMap(const QString &path, QObject *parent) : Map(parent)
|
||||||
{
|
{
|
||||||
int errorLine = -2;
|
int errorLine = -2;
|
||||||
QList<ReferencePoint> points;
|
QList<ReferencePoint> points;
|
||||||
@ -286,7 +286,7 @@ OziMap::OziMap(const QString &path, QObject *parent) : Map(parent)
|
|||||||
_valid = true;
|
_valid = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OziMap::load()
|
void OfflineMap::load()
|
||||||
{
|
{
|
||||||
if (_tileSize.isValid())
|
if (_tileSize.isValid())
|
||||||
return;
|
return;
|
||||||
@ -296,18 +296,18 @@ void OziMap::load()
|
|||||||
qWarning("%s: error loading map image", qPrintable(_name));
|
qWarning("%s: error loading map image", qPrintable(_name));
|
||||||
}
|
}
|
||||||
|
|
||||||
void OziMap::unload()
|
void OfflineMap::unload()
|
||||||
{
|
{
|
||||||
if (_img)
|
if (_img)
|
||||||
delete _img;
|
delete _img;
|
||||||
}
|
}
|
||||||
|
|
||||||
QRectF OziMap::bounds() const
|
QRectF OfflineMap::bounds() const
|
||||||
{
|
{
|
||||||
return QRectF(QPointF(0, 0), _size);
|
return QRectF(QPointF(0, 0), _size);
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal OziMap::zoomFit(const QSize &size, const QRectF &br)
|
qreal OfflineMap::zoomFit(const QSize &size, const QRectF &br)
|
||||||
{
|
{
|
||||||
Q_UNUSED(size);
|
Q_UNUSED(size);
|
||||||
Q_UNUSED(br);
|
Q_UNUSED(br);
|
||||||
@ -315,24 +315,24 @@ qreal OziMap::zoomFit(const QSize &size, const QRectF &br)
|
|||||||
return 1.0;
|
return 1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal OziMap::resolution(const QPointF &p) const
|
qreal OfflineMap::resolution(const QPointF &p) const
|
||||||
{
|
{
|
||||||
Q_UNUSED(p);
|
Q_UNUSED(p);
|
||||||
|
|
||||||
return _resolution;
|
return _resolution;
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal OziMap::zoomIn()
|
qreal OfflineMap::zoomIn()
|
||||||
{
|
{
|
||||||
return 1.0;
|
return 1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal OziMap::zoomOut()
|
qreal OfflineMap::zoomOut()
|
||||||
{
|
{
|
||||||
return 1.0;
|
return 1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OziMap::draw(QPainter *painter, const QRectF &rect)
|
void OfflineMap::draw(QPainter *painter, const QRectF &rect)
|
||||||
{
|
{
|
||||||
if (_tileSize.isValid()) {
|
if (_tileSize.isValid()) {
|
||||||
QPoint tl = QPoint((int)floor(rect.left() / (qreal)_tileSize.width())
|
QPoint tl = QPoint((int)floor(rect.left() / (qreal)_tileSize.width())
|
||||||
@ -378,12 +378,12 @@ void OziMap::draw(QPainter *painter, const QRectF &rect)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QPointF OziMap::ll2xy(const Coordinates &c) const
|
QPointF OfflineMap::ll2xy(const Coordinates &c) const
|
||||||
{
|
{
|
||||||
return _transform.map(c.toMercator());
|
return _transform.map(c.toMercator());
|
||||||
}
|
}
|
||||||
|
|
||||||
Coordinates OziMap::xy2ll(const QPointF &p) const
|
Coordinates OfflineMap::xy2ll(const QPointF &p) const
|
||||||
{
|
{
|
||||||
return Coordinates::fromMercator(_transform.inverted().map(p));
|
return Coordinates::fromMercator(_transform.inverted().map(p));
|
||||||
}
|
}
|
@ -1,5 +1,5 @@
|
|||||||
#ifndef OZIMAP_H
|
#ifndef OFFLINEMAP_H
|
||||||
#define OZIMAP_H
|
#define OFFLINEMAP_H
|
||||||
|
|
||||||
#include <QImage>
|
#include <QImage>
|
||||||
#include <QTransform>
|
#include <QTransform>
|
||||||
@ -10,12 +10,12 @@
|
|||||||
class QIODevice;
|
class QIODevice;
|
||||||
class QDir;
|
class QDir;
|
||||||
|
|
||||||
class OziMap : public Map
|
class OfflineMap : public Map
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
OziMap(const QString &path, QObject *parent = 0);
|
OfflineMap(const QString &path, QObject *parent = 0);
|
||||||
|
|
||||||
const QString &name() const {return _name;}
|
const QString &name() const {return _name;}
|
||||||
|
|
||||||
@ -47,17 +47,17 @@ private:
|
|||||||
bool getTileSize();
|
bool getTileSize();
|
||||||
|
|
||||||
QString _name;
|
QString _name;
|
||||||
QString _imgPath;
|
|
||||||
QSize _size;
|
QSize _size;
|
||||||
QTransform _transform;
|
QTransform _transform;
|
||||||
qreal _resolution;
|
qreal _resolution;
|
||||||
|
|
||||||
Tar _tar;
|
Tar _tar;
|
||||||
QImage *_img;
|
QImage *_img;
|
||||||
|
QString _imgPath;
|
||||||
QSize _tileSize;
|
QSize _tileSize;
|
||||||
QString _tileName;
|
QString _tileName;
|
||||||
|
|
||||||
bool _valid;
|
bool _valid;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // OZIMAP_H
|
#endif // OFFLINEMAP_H
|
Loading…
Reference in New Issue
Block a user