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