mirror of
https://github.com/tumic0/GPXSee.git
synced 2024-11-30 22:51:16 +01:00
Only allow one map per file
This commit is contained in:
parent
aa07b20aa4
commit
fbc0fd86cf
@ -40,7 +40,7 @@ build_script:
|
|||||||
|
|
||||||
copy pkg\pcs.csv installer
|
copy pkg\pcs.csv installer
|
||||||
|
|
||||||
copy pkg\maps.xml installer
|
xcopy pkg\maps installer /s/h/e/k/f/c
|
||||||
|
|
||||||
copy licence.txt installer
|
copy licence.txt installer
|
||||||
|
|
||||||
|
@ -116,7 +116,7 @@ HEADERS += src/config.h \
|
|||||||
src/map/primemeridian.h \
|
src/map/primemeridian.h \
|
||||||
src/map/linearunits.h \
|
src/map/linearunits.h \
|
||||||
src/map/ct.h \
|
src/map/ct.h \
|
||||||
src/map/omd.h
|
src/map/mapsource.h
|
||||||
SOURCES += src/main.cpp \
|
SOURCES += src/main.cpp \
|
||||||
src/common/coordinates.cpp \
|
src/common/coordinates.cpp \
|
||||||
src/common/rectc.cpp \
|
src/common/rectc.cpp \
|
||||||
@ -202,7 +202,7 @@ SOURCES += src/main.cpp \
|
|||||||
src/map/angularunits.cpp \
|
src/map/angularunits.cpp \
|
||||||
src/map/primemeridian.cpp \
|
src/map/primemeridian.cpp \
|
||||||
src/map/linearunits.cpp \
|
src/map/linearunits.cpp \
|
||||||
src/map/omd.cpp
|
src/map/mapsource.cpp
|
||||||
RESOURCES += gpxsee.qrc
|
RESOURCES += gpxsee.qrc
|
||||||
TRANSLATIONS = lang/gpxsee_cs.ts \
|
TRANSLATIONS = lang/gpxsee_cs.ts \
|
||||||
lang/gpxsee_sv.ts \
|
lang/gpxsee_sv.ts \
|
||||||
@ -218,7 +218,7 @@ macx {
|
|||||||
icons/fit.icns \
|
icons/fit.icns \
|
||||||
icons/igc.icns \
|
icons/igc.icns \
|
||||||
icons/nmea.icns \
|
icons/nmea.icns \
|
||||||
pkg/maps.xml \
|
pkg/maps \
|
||||||
pkg/ellipsoids.csv \
|
pkg/ellipsoids.csv \
|
||||||
pkg/gcs.csv \
|
pkg/gcs.csv \
|
||||||
pkg/pcs.csv
|
pkg/pcs.csv
|
||||||
|
@ -83,7 +83,7 @@ Section "GPXSee" SEC_APP
|
|||||||
|
|
||||||
; Put the files there
|
; Put the files there
|
||||||
File "gpxsee.exe"
|
File "gpxsee.exe"
|
||||||
File "maps.xml"
|
File /r "maps"
|
||||||
File "ellipsoids.csv"
|
File "ellipsoids.csv"
|
||||||
File "gcs.csv"
|
File "gcs.csv"
|
||||||
File "pcs.csv"
|
File "pcs.csv"
|
||||||
|
@ -90,7 +90,7 @@ Section "GPXSee" SEC_APP
|
|||||||
|
|
||||||
; Put the files there
|
; Put the files there
|
||||||
File "gpxsee.exe"
|
File "gpxsee.exe"
|
||||||
File "maps.xml"
|
File /r "maps"
|
||||||
File "ellipsoids.csv"
|
File "ellipsoids.csv"
|
||||||
File "gcs.csv"
|
File "gcs.csv"
|
||||||
File "pcs.csv"
|
File "pcs.csv"
|
||||||
|
28
pkg/maps.xml
28
pkg/maps.xml
@ -1,28 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<omd>
|
|
||||||
<map>
|
|
||||||
<name>Open Topo Map</name>
|
|
||||||
<url>https://a.tile.opentopomap.org/$z/$x/$y.png</url>
|
|
||||||
<zoom max="17"/>
|
|
||||||
</map>
|
|
||||||
<map>
|
|
||||||
<name>4UMaps</name>
|
|
||||||
<url>http://4umaps.eu/$z/$x/$y.png</url>
|
|
||||||
<zoom min="2" max="15"/>
|
|
||||||
<bounds bottom="-65"/>
|
|
||||||
</map>
|
|
||||||
<map>
|
|
||||||
<name>Open Street Map</name>
|
|
||||||
<url>http://tile.openstreetmap.org/$z/$x/$y.png</url>
|
|
||||||
</map>
|
|
||||||
<map>
|
|
||||||
<name>USGS Topo</name>
|
|
||||||
<url>https://navigator.er.usgs.gov/tiles/tcr.cgi/$z/$x/$y.png</url>
|
|
||||||
<zoom min="2" max="15"/>
|
|
||||||
</map>
|
|
||||||
<map>
|
|
||||||
<name>USGS Imagery</name>
|
|
||||||
<url>https://navigator.er.usgs.gov/tiles/aerial_Imagery.cgi/$z/$x/$y</url>
|
|
||||||
<zoom min="2" max="15"/>
|
|
||||||
</map>
|
|
||||||
</omd>
|
|
7
pkg/maps/4UMaps.xml
Normal file
7
pkg/maps/4UMaps.xml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<map>
|
||||||
|
<name>4UMaps</name>
|
||||||
|
<url>http://4umaps.eu/$z/$x/$y.png</url>
|
||||||
|
<zoom min="2" max="15"/>
|
||||||
|
<bounds bottom="-65"/>
|
||||||
|
</map>
|
5
pkg/maps/OpenStreetMap.xml
Normal file
5
pkg/maps/OpenStreetMap.xml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<map>
|
||||||
|
<name>Open Street Map</name>
|
||||||
|
<url>http://tile.openstreetmap.org/$z/$x/$y.png</url>
|
||||||
|
</map>
|
6
pkg/maps/OpenTopoMap.xml
Normal file
6
pkg/maps/OpenTopoMap.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<map>
|
||||||
|
<name>Open Topo Map</name>
|
||||||
|
<url>https://a.tile.opentopomap.org/$z/$x/$y.png</url>
|
||||||
|
<zoom max="17"/>
|
||||||
|
</map>
|
6
pkg/maps/USGS-imagery.xml
Normal file
6
pkg/maps/USGS-imagery.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<map>
|
||||||
|
<name>USGS Imagery</name>
|
||||||
|
<url>https://navigator.er.usgs.gov/tiles/aerial_Imagery.cgi/$z/$x/$y</url>
|
||||||
|
<zoom min="2" max="15"/>
|
||||||
|
</map>
|
6
pkg/maps/USGS-topo.xml
Normal file
6
pkg/maps/USGS-topo.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<map>
|
||||||
|
<name>USGS Topo</name>
|
||||||
|
<url>https://navigator.er.usgs.gov/tiles/tcr.cgi/$z/$x/$y.png</url>
|
||||||
|
<zoom min="2" max="15"/>
|
||||||
|
</map>
|
@ -4,25 +4,26 @@
|
|||||||
#include "atlas.h"
|
#include "atlas.h"
|
||||||
#include "offlinemap.h"
|
#include "offlinemap.h"
|
||||||
#include "onlinemap.h"
|
#include "onlinemap.h"
|
||||||
#include "omd.h"
|
#include "mapsource.h"
|
||||||
#include "maplist.h"
|
#include "maplist.h"
|
||||||
|
|
||||||
|
|
||||||
bool MapList::loadList(const QString &path, bool dir)
|
bool MapList::loadSource(const QString &path, bool dir)
|
||||||
{
|
{
|
||||||
OMD omd;
|
MapSource ms;
|
||||||
|
Map *map;
|
||||||
|
|
||||||
if (!omd.loadFile(path)) {
|
if (!ms.loadFile(path)) {
|
||||||
if (dir)
|
if (dir)
|
||||||
_errorString += path + ": " + omd.errorString() + "\n";
|
_errorString += path + ": " + ms.errorString() + "\n";
|
||||||
else
|
else
|
||||||
_errorString = omd.errorString();
|
_errorString = ms.errorString();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
_maps += omd.maps();
|
map = ms.map();
|
||||||
for (int i = 0; i < omd.maps().size(); i++)
|
map->setParent(this);
|
||||||
omd.maps()[i]->setParent(this);
|
_maps.append(map);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -71,7 +72,7 @@ bool MapList::loadFile(const QString &path, bool *atlas, bool dir)
|
|||||||
return loadAtlas(path, dir);
|
return loadAtlas(path, dir);
|
||||||
} else if (suffix == "xml") {
|
} else if (suffix == "xml") {
|
||||||
*atlas = false;
|
*atlas = false;
|
||||||
return loadList(path, dir);
|
return loadSource(path, dir);
|
||||||
} else {
|
} else {
|
||||||
*atlas = false;
|
*atlas = false;
|
||||||
return loadMap(path, dir);
|
return loadMap(path, dir);
|
||||||
@ -123,7 +124,7 @@ QString MapList::formats()
|
|||||||
+ tr("OziExplorer maps (*.map)") + ";;"
|
+ tr("OziExplorer maps (*.map)") + ";;"
|
||||||
+ tr("TrekBuddy maps/atlases (*.tar *.tba)") + ";;"
|
+ tr("TrekBuddy maps/atlases (*.tar *.tba)") + ";;"
|
||||||
+ tr("GeoTIFF images (*.tif *.tiff)") + ";;"
|
+ tr("GeoTIFF images (*.tif *.tiff)") + ";;"
|
||||||
+ tr("Online map definitions (*.xml)");
|
+ tr("Online map sources (*.xml)");
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList MapList::filter()
|
QStringList MapList::filter()
|
||||||
|
@ -29,7 +29,7 @@ private:
|
|||||||
|
|
||||||
Map *loadListEntry(const QByteArray &line);
|
Map *loadListEntry(const QByteArray &line);
|
||||||
|
|
||||||
bool loadList(const QString &path, bool dir);
|
bool loadSource(const QString &path, bool dir);
|
||||||
bool loadMap(const QString &path, bool dir);
|
bool loadMap(const QString &path, bool dir);
|
||||||
bool loadAtlas(const QString &path, bool dir);
|
bool loadAtlas(const QString &path, bool dir);
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QXmlStreamReader>
|
#include <QXmlStreamReader>
|
||||||
#include "onlinemap.h"
|
#include "onlinemap.h"
|
||||||
#include "omd.h"
|
#include "mapsource.h"
|
||||||
|
|
||||||
|
|
||||||
#define ZOOM_MAX 19
|
#define ZOOM_MAX 19
|
||||||
@ -11,7 +11,7 @@
|
|||||||
#define BOUNDS_RIGHT 180
|
#define BOUNDS_RIGHT 180
|
||||||
#define BOUNDS_BOTTOM -85.0511
|
#define BOUNDS_BOTTOM -85.0511
|
||||||
|
|
||||||
Range OMD::zooms(QXmlStreamReader &reader)
|
Range MapSource::zooms(QXmlStreamReader &reader)
|
||||||
{
|
{
|
||||||
const QXmlStreamAttributes &attr = reader.attributes();
|
const QXmlStreamAttributes &attr = reader.attributes();
|
||||||
int min, max;
|
int min, max;
|
||||||
@ -51,7 +51,7 @@ Range OMD::zooms(QXmlStreamReader &reader)
|
|||||||
return Range(min, max);
|
return Range(min, max);
|
||||||
}
|
}
|
||||||
|
|
||||||
RectC OMD::bounds(QXmlStreamReader &reader)
|
RectC MapSource::bounds(QXmlStreamReader &reader)
|
||||||
{
|
{
|
||||||
const QXmlStreamAttributes &attr = reader.attributes();
|
const QXmlStreamAttributes &attr = reader.attributes();
|
||||||
double top, left, bottom, right;
|
double top, left, bottom, right;
|
||||||
@ -121,7 +121,7 @@ RectC OMD::bounds(QXmlStreamReader &reader)
|
|||||||
return RectC(Coordinates(left, top), Coordinates(right, bottom));
|
return RectC(Coordinates(left, top), Coordinates(right, bottom));
|
||||||
}
|
}
|
||||||
|
|
||||||
void OMD::map(QXmlStreamReader &reader)
|
void MapSource::map(QXmlStreamReader &reader)
|
||||||
{
|
{
|
||||||
QString name, url;
|
QString name, url;
|
||||||
Range z(ZOOM_MIN, ZOOM_MAX);
|
Range z(ZOOM_MIN, ZOOM_MAX);
|
||||||
@ -143,20 +143,10 @@ void OMD::map(QXmlStreamReader &reader)
|
|||||||
reader.skipCurrentElement();
|
reader.skipCurrentElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
_maps.append(new OnlineMap(name, url, z, b));
|
_map = new OnlineMap(name, url, z, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OMD::omd(QXmlStreamReader &reader)
|
bool MapSource::loadFile(const QString &path)
|
||||||
{
|
|
||||||
while (reader.readNextStartElement()) {
|
|
||||||
if (reader.name() == "map")
|
|
||||||
map(reader);
|
|
||||||
else
|
|
||||||
reader.skipCurrentElement();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool OMD::loadFile(const QString &path)
|
|
||||||
{
|
{
|
||||||
QFile file(path);
|
QFile file(path);
|
||||||
QXmlStreamReader reader;
|
QXmlStreamReader reader;
|
||||||
@ -169,10 +159,10 @@ bool OMD::loadFile(const QString &path)
|
|||||||
reader.setDevice(&file);
|
reader.setDevice(&file);
|
||||||
|
|
||||||
if (reader.readNextStartElement()) {
|
if (reader.readNextStartElement()) {
|
||||||
if (reader.name() == "omd")
|
if (reader.name() == "map")
|
||||||
omd(reader);
|
map(reader);
|
||||||
else
|
else
|
||||||
reader.raiseError("Not an online map definitions file");
|
reader.raiseError("Not an online map source file");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reader.error())
|
if (reader.error())
|
||||||
@ -182,9 +172,8 @@ bool OMD::loadFile(const QString &path)
|
|||||||
return !reader.error();
|
return !reader.error();
|
||||||
}
|
}
|
||||||
|
|
||||||
OMD::~OMD()
|
MapSource::~MapSource()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < _maps.size(); i++)
|
if (_map && !_map->parent())
|
||||||
if (!_maps.at(i)->parent())
|
delete _map;
|
||||||
delete _maps.at(i);
|
|
||||||
}
|
}
|
@ -1,5 +1,5 @@
|
|||||||
#ifndef OMD_H
|
#ifndef MAPSOURCE_H
|
||||||
#define OMD_H
|
#define MAPSOURCE_H
|
||||||
|
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include "common/range.h"
|
#include "common/range.h"
|
||||||
@ -8,24 +8,24 @@
|
|||||||
class Map;
|
class Map;
|
||||||
class QXmlStreamReader;
|
class QXmlStreamReader;
|
||||||
|
|
||||||
class OMD
|
class MapSource
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
~OMD();
|
MapSource() : _map(0) {}
|
||||||
|
~MapSource();
|
||||||
|
|
||||||
bool loadFile(const QString &path);
|
bool loadFile(const QString &path);
|
||||||
const QString &errorString() const {return _errorString;}
|
const QString &errorString() const {return _errorString;}
|
||||||
|
|
||||||
const QList<Map*> &maps() const {return _maps;}
|
Map* map() const {return _map;}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
RectC bounds(QXmlStreamReader &reader);
|
RectC bounds(QXmlStreamReader &reader);
|
||||||
Range zooms(QXmlStreamReader &reader);
|
Range zooms(QXmlStreamReader &reader);
|
||||||
void map(QXmlStreamReader &reader);
|
void map(QXmlStreamReader &reader);
|
||||||
void omd(QXmlStreamReader &reader);
|
|
||||||
|
|
||||||
QString _errorString;
|
QString _errorString;
|
||||||
QList<Map*> _maps;
|
Map* _map;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // OMD_H
|
#endif // MAPSOURCE_H
|
Loading…
Reference in New Issue
Block a user