1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2025-06-28 03:59:15 +02:00

Unified path -> name conversion

This commit is contained in:
2021-01-17 19:33:06 +01:00
parent 3033bc680d
commit 6d8ccd2216
18 changed files with 65 additions and 76 deletions

View File

@ -11,10 +11,10 @@ static double sDMS2deg(double val)
QByteArray ba = qstr.toLatin1();
const char *str = ba.constData();
decimal = strrchr(str, '.');
int deg = str2int(str, decimal - str);
int min = str2int(decimal + 1, 2);
int sec = str2int(decimal + 3, 2);
int f = str2int(decimal + 5, 3);
int deg = Util::str2int(str, decimal - str);
int min = Util::str2int(decimal + 1, 2);
int sec = Util::str2int(decimal + 3, 2);
int f = Util::str2int(decimal + 5, 3);
angle = deg + min/60.0 + sec/3600.0 + (f/1000.0)/3600.0;

View File

@ -1,6 +1,7 @@
#include <QFileInfo>
#include <QPainter>
#include <QImageReader>
#include "common/util.h"
#include "geotiff.h"
#include "image.h"
#include "geotiffmap.h"
@ -33,12 +34,6 @@ GeoTIFFMap::~GeoTIFFMap()
delete _img;
}
QString GeoTIFFMap::name() const
{
QFileInfo fi(path());
return fi.fileName();
}
QPointF GeoTIFFMap::ll2xy(const Coordinates &c)
{
return QPointF(_transform.proj2img(_projection.ll2xy(c))) / _ratio;

View File

@ -15,8 +15,6 @@ public:
GeoTIFFMap(const QString &fileName, QObject *parent = 0);
~GeoTIFFMap();
QString name() const;
QRectF bounds();
QPointF ll2xy(const Coordinates &c);
Coordinates xy2ll(const QPointF &p);

View File

@ -2,7 +2,7 @@
#include <QPainter>
#include <QFileInfo>
#include <QPixmapCache>
#include "common/config.h"
#include "common/util.h"
#include "rectd.h"
#include "gcs.h"
#include "pcs.h"
@ -134,7 +134,6 @@ JNXMap::JNXMap(const QString &fileName, QObject *parent)
: Map(fileName, parent), _file(fileName), _zoom(0), _mapRatio(1.0),
_valid(false)
{
_name = QFileInfo(fileName).fileName();
_projection = Projection(GCS::gcs(4326));
if (!_file.open(QIODevice::ReadOnly)) {

View File

@ -17,8 +17,6 @@ public:
public:
JNXMap(const QString &fileName, QObject *parent = 0);
QString name() const {return _name;}
QRectF bounds();
RectC llBounds() {return _bounds;}
@ -66,7 +64,6 @@ private:
static bool cb(Tile *tile, void *context);
static QPixmap pixmap(const Tile *tile, QFile *file);
QString _name;
QFile _file;
QVector<Zoom> _zooms;
int _zoom;

View File

@ -18,6 +18,7 @@
#include <QBuffer>
#include <QPainter>
#include <private/qzipreader_p.h>
#include"common/util.h"
#include "pcs.h"
#include "image.h"
#include "kmzmap.h"
@ -339,12 +340,6 @@ KMZMap::KMZMap(const QString &fileName, QObject *parent)
_valid = true;
}
QString KMZMap::name() const
{
QFileInfo fi(path());
return fi.fileName();
}
QRectF KMZMap::bounds()
{
QRectF rect;

View File

@ -17,8 +17,6 @@ class KMZMap : public Map
public:
KMZMap(const QString &fileName, QObject *parent = 0);
QString name() const;
QRectF bounds();
int zoom() const {return _zoom;}

View File

@ -6,6 +6,7 @@
#include <QRectF>
#include <QFlags>
#include "common/rectc.h"
#include "common/util.h"
class QPainter;
@ -28,7 +29,7 @@ public:
virtual ~Map() {}
const QString &path() const {return _path;}
virtual QString name() const = 0;
virtual QString name() const {return Util::file2name(path());}
virtual RectC llBounds();
virtual QRectF bounds() = 0;

View File

@ -8,7 +8,7 @@
#include <QBuffer>
#include <QtConcurrent>
#include "common/rectc.h"
#include "common/config.h"
#include "common/util.h"
#include "osm.h"
#include "mbtilesmap.h"
@ -147,7 +147,7 @@ MBTilesMap::MBTilesMap(const QString &fileName, QObject *parent)
_name = query.value(0).toString();
else {
qWarning("%s: missing map name", qPrintable(fileName));
_name = QFileInfo(fileName).fileName();
_name = Util::file2name(fileName);
}
}

View File

@ -256,12 +256,6 @@ RMap::RMap(const QString &fileName, QObject *parent)
_file.close();
}
QString RMap::name() const
{
QFileInfo fi(path());
return fi.baseName();
}
QRectF RMap::bounds()
{
return QRectF(QPointF(0, 0), _zooms.at(_zoom).size / _mapRatio);

View File

@ -14,8 +14,6 @@ class RMap : public Map
public:
RMap(const QString &fileName, QObject *parent = 0);
QString name() const;
QRectF bounds();
int zoom() const {return _zoom;}