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

Added support for TomTom ITN files

This commit is contained in:
Martin Tůma 2021-05-12 07:44:25 +02:00
parent 5efd3d1e33
commit 86e8ac71ee
4 changed files with 73 additions and 0 deletions

View File

@ -90,6 +90,7 @@ HEADERS += src/common/config.h \
src/GUI/mapview.h \
src/GUI/font.h \
src/GUI/areaitem.h \
src/data/itnparser.h \
src/data/link.h \
src/data/ov2parser.h \
src/map/IMG/bitmapline.h \
@ -278,6 +279,7 @@ SOURCES += src/main.cpp \
src/GUI/gearratiographitem.cpp \
src/GUI/mapview.cpp \
src/GUI/areaitem.cpp \
src/data/itnparser.cpp \
src/data/ov2parser.cpp \
src/data/waypoint.cpp \
src/map/IMG/bitmapline.cpp \

View File

@ -18,6 +18,7 @@
#include "gpiparser.h"
#include "smlparser.h"
#include "ov2parser.h"
#include "itnparser.h"
#include "data.h"
@ -39,6 +40,7 @@ static CUPParser cup;
static GPIParser gpi;
static SMLParser sml;
static OV2Parser ov2;
static ITNParser itn;
static QMap<QString, Parser*> parsers()
{
@ -64,6 +66,7 @@ static QMap<QString, Parser*> parsers()
map.insert("gpi", &gpi);
map.insert("sml", &sml);
map.insert("ov2", &ov2);
map.insert("itn", &itn);
return map;
}
@ -136,6 +139,7 @@ QString Data::formats()
+ qApp->translate("Data", "GPI files") + " (*.gpi);;"
+ qApp->translate("Data", "GPX files") + " (*.gpx);;"
+ qApp->translate("Data", "IGC files") + " (*.igc);;"
+ qApp->translate("Data", "ITN files") + " (*.itn);;"
+ qApp->translate("Data", "JPEG images") + " (*.jpg *.jpeg);;"
+ qApp->translate("Data", "KML files") + " (*.kml);;"
+ qApp->translate("Data", "LOC files") + " (*.loc);;"

46
src/data/itnparser.cpp Normal file
View File

@ -0,0 +1,46 @@
#include <QByteArray>
#include "common/textcodec.h"
#include "itnparser.h"
bool ITNParser::parse(QFile *file, QList<TrackData> &tracks,
QList<RouteData> &routes, QList<Area> &polygons, QVector<Waypoint> &waypoints)
{
Q_UNUSED(tracks);
Q_UNUSED(waypoints);
Q_UNUSED(polygons);
RouteData rd;
QByteArray ba;
TextCodec codec(1252);
int lat, lon;
bool ok1, ok2;
_errorLine = 1;
_errorString.clear();
while (!file->atEnd()) {
ba = file->readLine();
QList<QByteArray> fields(ba.split('|'));
if (fields.size() != 5) {
_errorString = "File format error";
return false;
}
lon = fields.at(0).toInt(&ok1);
lat = fields.at(1).toInt(&ok2);
if (!ok1 || !ok2 || lon < -18000000 || lon > 18000000
|| lat < -9000000 || lat > 9000000) {
_errorString = "Invalid coordinates";
return false;
}
Waypoint wp(Coordinates(lon/1e5, lat/1e5));
wp.setName(codec.toString(fields.at(2)));
rd.append(wp);
_errorLine++;
}
routes.append(rd);
return true;
}

21
src/data/itnparser.h Normal file
View File

@ -0,0 +1,21 @@
#ifndef ITNPARSER_H
#define ITNPARSER_H
#include "parser.h"
class ITNParser : public Parser
{
public:
ITNParser() : _errorLine(0) {}
bool parse(QFile *file, QList<TrackData> &tracks, QList<RouteData> &routes,
QList<Area> &polygons, QVector<Waypoint> &waypoints);
QString errorString() const {return _errorString;}
int errorLine() const {return _errorLine;}
private:
QString _errorString;
int _errorLine;
};
#endif // ITNPARSER_H