1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-24 03:35:53 +01:00

Compare commits

..

No commits in common. "0121381d182b42bea6b1366cfbc6c6c4beca58e7" and "40febb8c0e4ecaf54b200b46b1925856ad1b2dde" have entirely different histories.

37 changed files with 102 additions and 229 deletions

View File

@ -1,5 +1,4 @@
version: 10.8
.{build}
version: 10.7.{build}
configuration:
- Release

View File

@ -3,7 +3,7 @@ unix:!macx {
} else {
TARGET = GPXSee
}
VERSION = 10.8
VERSION = 10.7
QT += core \
gui \

View File

@ -37,7 +37,7 @@ Unicode true
; The name of the installer
Name "GPXSee"
; Program version
!define VERSION "10.8"
!define VERSION "10.7"
; The file to write
OutFile "GPXSee-${VERSION}_x64.exe"

View File

@ -424,14 +424,6 @@ void AQMMap::drawTile(QPainter *painter, QPixmap &pixmap, QPointF &tp)
painter->drawPixmap(tp, pixmap);
}
Map *AQMMap::create(const QString &path, const Projection &, bool *isDir)
{
if (isDir)
*isDir = false;
return new AQMMap(path);
}
#ifndef QT_NO_DEBUG
QDebug operator<<(QDebug dbg, const AQMMap::File &file)
{

View File

@ -39,8 +39,6 @@ public:
bool isValid() const {return _valid;}
QString errorString() const {return _errorString;}
static Map *create(const QString &path, const Projection &, bool *isDir);
private:
struct File {
QByteArray name;

View File

@ -293,10 +293,19 @@ void Atlas::unload()
_maps.at(i)->unload();
}
Map *Atlas::create(const QString &path, const Projection &, bool *isDir)
bool Atlas::isAtlas(const QString &path)
{
if (isDir)
*isDir = true;
QFileInfo fi(path);
QString suffix = fi.suffix().toLower();
return new Atlas(path);
if (suffix == "tar") {
Tar tar(path);
if (!tar.open())
return false;
QString tbaFileName = fi.completeBaseName() + ".tba";
return tar.contains(tbaFileName);
} else if (suffix == "tba")
return true;
return false;
}

View File

@ -34,7 +34,7 @@ public:
bool isValid() const {return _valid;}
QString errorString() const {return _errorString;}
static Map *create(const QString &path, const Projection &, bool *isDir);
static bool isAtlas(const QString &path);
private:
struct Zoom {

View File

@ -461,11 +461,3 @@ void BSBMap::unload()
delete _img;
_img = 0;
}
Map *BSBMap::create(const QString &path, const Projection &, bool *isMap)
{
if (isMap)
*isMap = false;
return new BSBMap(path);
}

View File

@ -32,8 +32,6 @@ public:
bool isValid() const {return _valid;}
QString errorString() const {return _errorString;}
static Map *create(const QString &path, const Projection &, bool *isMap);
private:
bool parseBSB(const QByteArray &line);
bool parseKNP(const QByteArray &line, QString &datum, QString &proj,

View File

@ -74,11 +74,3 @@ void GeoTIFFMap::unload()
delete _img;
_img = 0;
}
Map *GeoTIFFMap::create(const QString &path, const Projection &, bool *isDir)
{
if (isDir)
*isDir = false;
return new GeoTIFFMap(path);
}

View File

@ -28,8 +28,6 @@ public:
bool isValid() const {return _valid;}
QString errorString() const {return _errorString;}
static Map *create(const QString &path, const Projection &, bool *isDir);
private:
Projection _projection;
Transform _transform;

View File

@ -222,11 +222,3 @@ void IMGMap::setOutputProjection(const Projection &projection)
updateTransform();
QPixmapCache::clear();
}
Map* IMGMap::create(const QString &path, const Projection &, bool *isDir)
{
if (isDir)
*isDir = GMAPData::isGMAP(path);
return new IMGMap(path);
}

View File

@ -41,8 +41,6 @@ public:
bool isValid() const {return _valid;}
QString errorString() const {return _errorString;}
static Map* create(const QString &path, const Projection &, bool *isDir);
private:
Transform transform(int zoom) const;
void updateTransform();

View File

@ -63,12 +63,9 @@ bool JNXMap::readTiles()
&& readValue(levels)))
return false;
if (version < 3 || version > 4)
return false;
_bounds = RectC(Coordinates(ic2dc(lon1), ic2dc(lat1)),
Coordinates(ic2dc(lon2), ic2dc(lat2)));
if (!levels || levels > 32 || !_bounds.isValid())
if (!levels || !_bounds.isValid())
return false;
if (!_file.seek(version > 3 ? 0x34 : 0x30))
@ -307,11 +304,3 @@ void JNXMap::setInputProjection(const Projection &projection)
}
}
}
Map *JNXMap::create(const QString &path, const Projection &proj, bool *isDir)
{
if (isDir)
*isDir = false;
return new JNXMap(path, proj);
}

View File

@ -42,8 +42,6 @@ public:
bool isValid() const {return _valid;}
QString errorString() const {return _errorString;}
static Map *create(const QString &path, const Projection &proj, bool *isDir);
private:
struct Tile {
qint32 top, right, bottom, left;

View File

@ -513,11 +513,3 @@ void KMZMap::draw(QPainter *painter, const QRectF &rect, int mapIndex,
map.draw(painter, pr, flags);
painter->restore();
}
Map *KMZMap::create(const QString &path, const Projection &proj, bool *isDir)
{
if (isDir)
*isDir = false;
return new KMZMap(path, proj);
}

View File

@ -39,8 +39,6 @@ public:
bool isValid() const {return _valid;}
QString errorString() const {return _errorString;}
static Map *create(const QString &path, const Projection &proj, bool *isDir);
private:
class Overlay {
public:

View File

@ -1,6 +1,7 @@
#include <QFileInfo>
#include <QDir>
#include <QApplication>
#include "IMG/gmapdata.h"
#include "atlas.h"
#include "ozimap.h"
#include "jnxmap.h"
@ -20,67 +21,54 @@
#include "maplist.h"
MapList::ParserMap MapList::parsers()
{
MapList::ParserMap map;
map.insert("tar", &Atlas::create);
map.insert("tar", &OziMap::create);
map.insert("tba", &Atlas::create);
map.insert("xml", &MapSource::create);
map.insert("xml", &IMGMap::create);
map.insert("img", &IMGMap::create);
map.insert("jnx", &JNXMap::create);
map.insert("tif", &GeoTIFFMap::create);
map.insert("tiff", &GeoTIFFMap::create);
map.insert("mbtiles", &MBTilesMap::create);
map.insert("rmap", &RMap::create);
map.insert("rtmap", &RMap::create);
map.insert("map", &MapsforgeMap::create);
map.insert("map", &OziMap::create);
map.insert("kap", &BSBMap::create);
map.insert("kmz", &KMZMap::create);
map.insert("aqm", &AQMMap::create);
map.insert("sqlitedb", &SqliteMap::create);
map.insert("wld", &WorldFileMap::create);
map.insert("jgw", &WorldFileMap::create);
map.insert("gfw", &WorldFileMap::create);
map.insert("pgw", &WorldFileMap::create);
map.insert("tfw", &WorldFileMap::create);
map.insert("qct", &QCTMap::create);
return map;
}
MapList::ParserMap MapList::_parsers = parsers();
Map *MapList::loadFile(const QString &path, const Projection &proj, bool *isDir)
{
ParserMap::iterator it;
QFileInfo fi(path);
QString suffix(fi.suffix().toLower());
QString suffix = fi.suffix().toLower();
Map *map = 0;
if ((it = _parsers.find(suffix)) != _parsers.end()) {
while (it != _parsers.end() && it.key() == suffix) {
delete map;
map = it.value()(path, proj, isDir);
if (map->isValid())
break;
++it;
if (Atlas::isAtlas(path)) {
if (isDir)
*isDir = true;
map = new Atlas(path);
} else if (suffix == "xml") {
if (MapSource::isMap(path)) {
map = MapSource::loadMap(path);
} else if (IMG::GMAPData::isGMAP(path)) {
map = new IMGMap(path);
if (isDir)
*isDir = true;
}
} else {
for (it = _parsers.begin(); it != _parsers.end(); it++) {
map = it.value()(path, proj, isDir);
if (map->isValid())
break;
else {
delete map;
map = 0;
}
}
}
} else if (suffix == "jnx")
map = new JNXMap(path, proj);
else if (suffix == "tif" || suffix == "tiff")
map = new GeoTIFFMap(path);
else if (suffix == "mbtiles")
map = new MBTilesMap(path);
else if (suffix == "rmap" || suffix == "rtmap")
map = new RMap(path);
else if (suffix == "img")
map = new IMGMap(path);
else if (suffix == "map") {
if (Mapsforge::MapData::isMapsforge(path))
map = new MapsforgeMap(path);
else
map = new OziMap(path);
} else if (suffix == "tar")
map = new OziMap(path);
else if (suffix == "kap")
map = new BSBMap(path);
else if (suffix == "kmz")
map = new KMZMap(path, proj);
else if (suffix == "aqm")
map = new AQMMap(path);
else if (suffix == "sqlitedb")
map = new SqliteMap(path);
else if (suffix == "wld" || suffix == "jgw" || suffix == "gfw"
|| suffix == "pgw" || suffix == "tfw")
map = new WorldFileMap(path, proj);
else if (suffix == "qct")
map = new QCTMap(path);
return map ? map : new InvalidMap(path, "Unknown file format");
}
@ -152,20 +140,15 @@ QString MapList::formats()
+ qApp->translate("MapList", "GeoTIFF images") + " (*.tif *.tiff);;"
+ qApp->translate("MapList", "World-file georeferenced images")
+ " (*.wld *.jgw *.gfw *.pgw *.tfw);;"
+ qApp->translate("MapList", "Online map sources") + " (*.xml);;"
+ qApp->translate("MapList", "All files") + " (*)";
+ qApp->translate("MapList", "Online map sources") + " (*.xml)";
}
QStringList MapList::filter()
{
QStringList filter;
QString last;
for (ParserMap::iterator it = _parsers.begin(); it != _parsers.end(); it++) {
if (it.key() != last)
filter << "*." + it.key();
last = it.key();
}
filter << "*.aqm" << "*.gfw" << "*.gmap" << "*.gmapi" << "*.img" << "*.jgw"
<< "*.jnx" << "*.kap" << "*.kmz" << "*.map" << "*.mbtiles" << "*.pgw"
<< "*.qct" << "*.rmap" << "*.rtmap" << "*.sqlitedb" << "*.tar" << "*.tba"
<< "*.tfw" << "*.tif" << "*.tiff" << "*.wld" << "*.xml";
return filter;
}

View File

@ -15,16 +15,10 @@ public:
static QStringList filter();
private:
typedef Map*(*ParserCb)(const QString &, const Projection &, bool *isDir);
typedef QMultiMap<QString, ParserCb> ParserMap;
static Map *loadFile(const QString &path, const Projection &proj,
bool *isDir = 0);
static TreeNode<Map*> loadDir(const QString &path, const Projection &proj,
TreeNode<Map *> *parent = 0);
static ParserMap parsers();
static ParserMap _parsers;
};
#endif // MAPLIST_H

View File

@ -382,7 +382,7 @@ bool MapData::readHeader()
return true;
}
MapData::MapData(const QString &fileName) : _file(fileName), _valid(false)
MapData::MapData(const QString &fileName) : _file(fileName)
{
if (!_file.open(QFile::ReadOnly | QIODevice::Unbuffered)) {
_errorString = _file.errorString();
@ -682,6 +682,19 @@ bool MapData::readPoints(const VectorTile *tile, int zoom, QList<Point> *list)
return true;
}
bool MapData::isMapsforge(const QString &path)
{
QFile file(path);
char magic[sizeof(MAGIC) - 1];
if (!file.open(QFile::ReadOnly))
return false;
if (file.read(magic, sizeof(magic)) < (qint64)sizeof(magic))
return false;
return !memcmp(magic, MAGIC, sizeof(magic));
}
#ifndef QT_NO_DEBUG
QDebug operator<<(QDebug dbg, const Mapsforge::MapData::Tag &tag)
{

View File

@ -81,6 +81,8 @@ public:
bool isValid() const {return _valid;}
QString errorString() const {return _errorString;}
static bool isMapsforge(const QString &path);
private:
struct SubFileInfo {
quint8 base;

View File

@ -23,10 +23,8 @@ MapsforgeMap::MapsforgeMap(const QString &fileName, QObject *parent)
: Map(fileName, parent), _data(fileName), _zoom(0),
_projection(PCS::pcs(3857)), _tileRatio(1.0)
{
if (_data.isValid()) {
_zoom = _data.zooms().min();
updateTransform();
}
_zoom = _data.zooms().min();
updateTransform();
}
void MapsforgeMap::load()
@ -235,11 +233,3 @@ void MapsforgeMap::setOutputProjection(const Projection &projection)
updateTransform();
QPixmapCache::clear();
}
Map *MapsforgeMap::create(const QString &path, const Projection &, bool *isMap)
{
if (isMap)
*isMap = false;
return new MapsforgeMap(path);
}

View File

@ -71,8 +71,6 @@ public:
bool isValid() const {return _data.isValid();}
QString errorString() const {return _data.errorString();}
static Map *create(const QString &path, const Projection &, bool *isMap);
private slots:
void jobFinished(MapsforgeMapJob *job);

View File

@ -206,16 +206,26 @@ void MapSource::map(QXmlStreamReader &reader, Config &config)
}
}
Map *MapSource::create(const QString &path, const Projection &proj, bool *isDir)
bool MapSource::isMap(const QString &path)
{
QFile file(path);
if (!file.open(QFile::ReadOnly | QFile::Text))
return false;
QXmlStreamReader reader(&file);
if (reader.readNextStartElement() && reader.name() == QLatin1String("map"))
return true;
return false;
}
Map *MapSource::loadMap(const QString &path)
{
Q_UNUSED(proj);
Config config;
QFile file(path);
if (isDir)
*isDir = false;
if (!file.open(QFile::ReadOnly | QFile::Text))
return new InvalidMap(path, file.errorString());

View File

@ -10,12 +10,12 @@
class Map;
class QXmlStreamReader;
class Projection;
class MapSource
{
public:
static Map *create(const QString &path, const Projection &proj, bool *isDir);
static Map *loadMap(const QString &path);
static bool isMap(const QString &path);
private:
enum Type {

View File

@ -332,11 +332,3 @@ Coordinates MBTilesMap::xy2ll(const QPointF &p)
return OSM::m2ll(QPointF(p.x() * scale, -p.y() * scale)
* coordinatesRatio());
}
Map *MBTilesMap::create(const QString &path, const Projection &, bool *isDir)
{
if (isDir)
*isDir = false;
return new MBTilesMap(path);
}

View File

@ -34,8 +34,6 @@ public:
bool isValid() const {return _valid;}
QString errorString() const {return _errorString;}
static Map *create(const QString &path, const Projection &, bool *isDir);
private:
qreal tileSize() const;
qreal coordinatesRatio() const;

View File

@ -379,11 +379,3 @@ void OziMap::setDevicePixelRatio(qreal deviceRatio, qreal mapRatio)
if (_img)
_img->setDevicePixelRatio(_mapRatio);
}
Map *OziMap::create(const QString &path, const Projection &, bool *isDir)
{
if (isDir)
*isDir = true;
return new OziMap(path);
}

View File

@ -47,8 +47,6 @@ public:
QPointF pp2xy(const PointD &p) const
{return _transform.proj2img(p) / _mapRatio;}
static Map *create(const QString &path, const Projection &, bool *isDir);
private:
struct ImageInfo {
QSize size;

View File

@ -485,11 +485,3 @@ void QCTMap::draw(QPainter *painter, const QRectF &rect, Flags flags)
}
}
}
Map *QCTMap::create(const QString &path, const Projection &, bool *isDir)
{
if (isDir)
*isDir = false;
return new QCTMap(path);
}

View File

@ -30,8 +30,6 @@ public:
bool isValid() const {return _valid;}
QString errorString() const {return _errorString;}
static Map *create(const QString &path, const Projection &, bool *isDir);
private:
bool readName(QDataStream &stream);
bool readSize(QDataStream &stream);

View File

@ -458,11 +458,3 @@ void RMap::setDevicePixelRatio(qreal deviceRatio, qreal mapRatio)
Q_UNUSED(deviceRatio);
_mapRatio = mapRatio;
}
Map *RMap::create(const QString &path, const Projection &, bool *isDir)
{
if (isDir)
*isDir = false;
return new RMap(path);
}

View File

@ -34,8 +34,6 @@ public:
bool isValid() const {return _valid;}
QString errorString() const {return _errorString;}
static Map *create(const QString &path, const Projection &, bool *isDir);
private:
struct Header {
quint32 type;

View File

@ -271,11 +271,3 @@ Coordinates SqliteMap::xy2ll(const QPointF &p)
qreal scale = OSM::zoom2scale(_zoom, _tileSize);
return OSM::m2ll(QPointF(p.x() * scale, -p.y() * scale) * _mapRatio);
}
Map *SqliteMap::create(const QString &path, const Projection &, bool *isDir)
{
if (isDir)
*isDir = false;
return new SqliteMap(path);
}

View File

@ -32,8 +32,6 @@ public:
bool isValid() const {return _valid;}
QString errorString() const {return _errorString;}
static Map *create(const QString &path, const Projection &, bool *isDir);
private:
int limitZoom(int zoom) const;
qreal tileSize() const;

View File

@ -121,12 +121,3 @@ void WorldFileMap::setInputProjection(const Projection &projection)
_projection = projection;
}
Map *WorldFileMap::create(const QString &path, const Projection &proj,
bool *isDir)
{
if (isDir)
*isDir = false;
return new WorldFileMap(path, proj);
}

View File

@ -12,8 +12,7 @@ class WorldFileMap : public Map
Q_OBJECT
public:
WorldFileMap(const QString &fileName, const Projection &proj,
QObject *parent = 0);
WorldFileMap(const QString &fileName, const Projection &proj, QObject *parent = 0);
~WorldFileMap();
QRectF bounds();
@ -30,8 +29,6 @@ public:
bool isValid() const {return _valid;}
QString errorString() const {return _errorString;}
static Map *create(const QString &path, const Projection &proj, bool *isDir);
private:
Projection _projection;
Transform _transform;