mirror of
https://github.com/tumic0/GPXSee.git
synced 2024-11-27 21:24:47 +01:00
Added support for TomTom OV2 files
This commit is contained in:
parent
64aa44d09b
commit
6a941566cb
@ -91,6 +91,7 @@ HEADERS += src/common/config.h \
|
||||
src/GUI/font.h \
|
||||
src/GUI/areaitem.h \
|
||||
src/data/link.h \
|
||||
src/data/ov2parser.h \
|
||||
src/map/IMG/bitmapline.h \
|
||||
src/map/IMG/bitstream.h \
|
||||
src/map/IMG/deltastream.h \
|
||||
@ -277,6 +278,7 @@ SOURCES += src/main.cpp \
|
||||
src/GUI/gearratiographitem.cpp \
|
||||
src/GUI/mapview.cpp \
|
||||
src/GUI/areaitem.cpp \
|
||||
src/data/ov2parser.cpp \
|
||||
src/data/waypoint.cpp \
|
||||
src/map/IMG/bitmapline.cpp \
|
||||
src/map/IMG/bitstream.cpp \
|
||||
|
@ -91,5 +91,6 @@
|
||||
<mimetype>application/vnd.alpinequest.aqm</mimetype>
|
||||
<mimetype>application/vnd.rmaps.sqlite</mimetype>
|
||||
<mimetype>application/vnd.mapsforge.map</mimetype>
|
||||
<mimetype>application/vnd.tomtom.ov2</mimetype>
|
||||
</mimetypes>
|
||||
</component>
|
||||
|
@ -15,4 +15,4 @@ Icon=gpxsee
|
||||
Terminal=false
|
||||
Type=Application
|
||||
Categories=Graphics;Viewer;Education;Geography;Maps;Sports;Qt
|
||||
MimeType=application/gpx+xml;application/vnd.garmin.tcx+xml;application/vnd.ant.fit;application/vnd.google-earth.kml+xml;application/vnd.fai.igc;application/vnd.nmea.nmea;application/vnd.oziexplorer.plt;application/vnd.oziexplorer.rte;application/vnd.oziexplorer.wpt;application/vnd.groundspeak.loc+xml;application/vnd.sigma.slf+xml;application/geo+json;application/vnd.naviter.seeyou.cup;application/vnd.garmin.gpi;application/vnd.suunto.sml+xml;image/jpeg;text/csv;application/vnd.garmin.img;application/vnd.garmin.jnx;application/vnd.garmin.gmap+xml;image/vnd.maptech.kap;application/vnd.oziexplorer.map;application/vnd.mapbox.mbtiles;application/vnd.twonav.rmap;application/vnd.trekbuddy.tba;application/vnd.gpxsee.map+xml;application/x-tar;image/tiff;application/vnd.google-earth.kmz;application/vnd.alpinequest.aqm;application/vnd.rmaps.sqlite;application/vnd.mapsforge.map
|
||||
MimeType=application/gpx+xml;application/vnd.garmin.tcx+xml;application/vnd.ant.fit;application/vnd.google-earth.kml+xml;application/vnd.fai.igc;application/vnd.nmea.nmea;application/vnd.oziexplorer.plt;application/vnd.oziexplorer.rte;application/vnd.oziexplorer.wpt;application/vnd.groundspeak.loc+xml;application/vnd.sigma.slf+xml;application/geo+json;application/vnd.naviter.seeyou.cup;application/vnd.garmin.gpi;application/vnd.suunto.sml+xml;image/jpeg;text/csv;application/vnd.garmin.img;application/vnd.garmin.jnx;application/vnd.garmin.gmap+xml;image/vnd.maptech.kap;application/vnd.oziexplorer.map;application/vnd.mapbox.mbtiles;application/vnd.twonav.rmap;application/vnd.trekbuddy.tba;application/vnd.gpxsee.map+xml;application/x-tar;image/tiff;application/vnd.google-earth.kmz;application/vnd.alpinequest.aqm;application/vnd.rmaps.sqlite;application/vnd.mapsforge.map;application/vnd.tomtom.ov2
|
||||
|
@ -128,6 +128,12 @@
|
||||
<glob pattern="*.sml"/>
|
||||
</mime-type>
|
||||
|
||||
<mime-type type="application/vnd.tomtom.ov2">
|
||||
<comment>TomTom POI File</comment>
|
||||
<sub-class-of type="application/octet-stream"/>
|
||||
<generic-icon name="application/octet-stream"/>
|
||||
<glob pattern="*.ov2"/>
|
||||
</mime-type>
|
||||
|
||||
<!-- Maps -->
|
||||
|
||||
|
@ -17,7 +17,7 @@
|
||||
#include "cupparser.h"
|
||||
#include "gpiparser.h"
|
||||
#include "smlparser.h"
|
||||
#include "map/map.h"
|
||||
#include "ov2parser.h"
|
||||
#include "data.h"
|
||||
|
||||
|
||||
@ -38,6 +38,7 @@ static EXIFParser exif;
|
||||
static CUPParser cup;
|
||||
static GPIParser gpi;
|
||||
static SMLParser sml;
|
||||
static OV2Parser ov2;
|
||||
|
||||
static QMap<QString, Parser*> parsers()
|
||||
{
|
||||
@ -62,6 +63,7 @@ static QMap<QString, Parser*> parsers()
|
||||
map.insert("cup", &cup);
|
||||
map.insert("gpi", &gpi);
|
||||
map.insert("sml", &sml);
|
||||
map.insert("ov2", &ov2);
|
||||
|
||||
return map;
|
||||
}
|
||||
@ -138,6 +140,7 @@ QString Data::formats()
|
||||
+ qApp->translate("Data", "KML files") + " (*.kml);;"
|
||||
+ qApp->translate("Data", "LOC files") + " (*.loc);;"
|
||||
+ qApp->translate("Data", "NMEA files") + " (*.nmea);;"
|
||||
+ qApp->translate("Data", "OV2 files") + " (*.ov2);;"
|
||||
+ qApp->translate("Data", "OziExplorer files") + " (*.plt *.rte *.wpt);;"
|
||||
+ qApp->translate("Data", "SLF files") + " (*.slf);;"
|
||||
+ qApp->translate("Data", "SML files") + " (*.sml);;"
|
||||
|
71
src/data/ov2parser.cpp
Normal file
71
src/data/ov2parser.cpp
Normal file
@ -0,0 +1,71 @@
|
||||
#include <QDataStream>
|
||||
#include "common/textcodec.h"
|
||||
#include "ov2parser.h"
|
||||
|
||||
bool OV2Parser::parse(QFile *file, QList<TrackData> &tracks,
|
||||
QList<RouteData> &routes, QList<Area> &polygons, QVector<Waypoint> &waypoints)
|
||||
{
|
||||
Q_UNUSED(tracks);
|
||||
Q_UNUSED(routes);
|
||||
Q_UNUSED(polygons);
|
||||
QDataStream stream(file);
|
||||
quint8 type;
|
||||
quint32 len;
|
||||
qint32 lon, lat;
|
||||
QByteArray ba;
|
||||
TextCodec codec(1252);
|
||||
|
||||
stream.setByteOrder(QDataStream::LittleEndian);
|
||||
|
||||
while (!stream.atEnd()) {
|
||||
stream >> type;
|
||||
switch (type) {
|
||||
case 0:
|
||||
stream >> len;
|
||||
if (stream.status() != QDataStream::Ok || len < 5) {
|
||||
_errorString = "Corrupted deleted record";
|
||||
return false;
|
||||
}
|
||||
stream.skipRawData(len - 5);
|
||||
break;
|
||||
case 1:
|
||||
if (stream.skipRawData(20) < 20) {
|
||||
_errorString = "Corrupted skipper record";
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
case 3:
|
||||
{stream >> len >> lon >> lat;
|
||||
if (stream.status() != QDataStream::Ok || len < 13) {
|
||||
_errorString = "Corrupted POI record";
|
||||
return false;
|
||||
}
|
||||
ba.resize(len - 13);
|
||||
if (stream.readRawData(ba.data(), ba.size()) != ba.size()) {
|
||||
_errorString = "Corrupted POI record";
|
||||
return false;
|
||||
}
|
||||
if (lon < -18000000 || lon > 18000000
|
||||
|| lat < -9000000 || lat > 9000000) {
|
||||
_errorString = "Invalid POI coordinates";
|
||||
return false;
|
||||
}
|
||||
Waypoint wp(Coordinates(lon/1e5, lat/1e5));
|
||||
if (type == 2)
|
||||
wp.setName(codec.toString(ba));
|
||||
else {
|
||||
QList<QByteArray> parts(ba.split('\0'));
|
||||
wp.setName(codec.toString(parts.at(0)));
|
||||
}
|
||||
waypoints.append(wp);}
|
||||
break;
|
||||
default:
|
||||
_errorString = QString("%1: invalid/unknown record type")
|
||||
.arg(type);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
17
src/data/ov2parser.h
Normal file
17
src/data/ov2parser.h
Normal file
@ -0,0 +1,17 @@
|
||||
#ifndef OV2PARSER_H
|
||||
#define OV2PARSER_H
|
||||
|
||||
#include "parser.h"
|
||||
|
||||
class OV2Parser : public Parser
|
||||
{
|
||||
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 0;}
|
||||
|
||||
private:
|
||||
QString _errorString;
|
||||
};
|
||||
|
||||
#endif // OV2PARSER_H
|
Loading…
Reference in New Issue
Block a user