mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-02-19 17:10:49 +01:00
Compare commits
3 Commits
ad2f108fa8
...
579d8a5c6e
Author | SHA1 | Date | |
---|---|---|---|
579d8a5c6e | |||
a019ff3930 | |||
05bcbddf77 |
@ -2,7 +2,7 @@
|
|||||||
<map xmlns="http://www.gpxsee.org/map/1.4">
|
<map xmlns="http://www.gpxsee.org/map/1.4">
|
||||||
<name>USGS Imagery</name>
|
<name>USGS Imagery</name>
|
||||||
<url>https://basemap.nationalmap.gov/ArcGIS/rest/services/USGSImageryOnly/MapServer/tile/$z/$y/$x</url>
|
<url>https://basemap.nationalmap.gov/ArcGIS/rest/services/USGSImageryOnly/MapServer/tile/$z/$y/$x</url>
|
||||||
<zoom min="2" max="15"/>
|
<zoom min="2" max="16"/>
|
||||||
<bounds bottom="0" top="74"/>
|
<bounds bottom="0" top="74"/>
|
||||||
<copyright>Map services and data available from U.S. Geological Survey, National Geospatial Program.</copyright>
|
<copyright>Map services and data available from U.S. Geological Survey, National Geospatial Program.</copyright>
|
||||||
</map>
|
</map>
|
||||||
|
@ -2,6 +2,6 @@
|
|||||||
<map xmlns="http://www.gpxsee.org/map/1.4">
|
<map xmlns="http://www.gpxsee.org/map/1.4">
|
||||||
<name>USGS Topo</name>
|
<name>USGS Topo</name>
|
||||||
<url>https://basemap.nationalmap.gov/arcgis/rest/services/USGSTopo/MapServer/tile/$z/$y/$x</url>
|
<url>https://basemap.nationalmap.gov/arcgis/rest/services/USGSTopo/MapServer/tile/$z/$y/$x</url>
|
||||||
<zoom min="2" max="15"/>
|
<zoom min="2" max="16"/>
|
||||||
<copyright>Map services and data available from U.S. Geological Survey, National Geospatial Program.</copyright>
|
<copyright>Map services and data available from U.S. Geological Survey, National Geospatial Program.</copyright>
|
||||||
</map>
|
</map>
|
||||||
|
@ -32,7 +32,12 @@ static bool isZIP(QFile *file)
|
|||||||
qreal KMLParser::number()
|
qreal KMLParser::number()
|
||||||
{
|
{
|
||||||
bool res;
|
bool res;
|
||||||
qreal ret = _reader.readElementText().toDouble(&res);
|
QString str(_reader.readElementText());
|
||||||
|
|
||||||
|
if (str.isEmpty())
|
||||||
|
return NAN;
|
||||||
|
|
||||||
|
qreal ret = str.toDouble(&res);
|
||||||
if (!res)
|
if (!res)
|
||||||
_reader.raiseError(QString("Invalid %1").arg(
|
_reader.raiseError(QString("Invalid %1").arg(
|
||||||
_reader.name().toString()));
|
_reader.name().toString()));
|
||||||
@ -59,6 +64,8 @@ bool KMLParser::coord(Trackpoint &trackpoint)
|
|||||||
qreal val[3];
|
qreal val[3];
|
||||||
bool res;
|
bool res;
|
||||||
|
|
||||||
|
if (data.isEmpty())
|
||||||
|
return true;
|
||||||
|
|
||||||
sp = data.constData();
|
sp = data.constData();
|
||||||
ep = sp + data.size();
|
ep = sp + data.size();
|
||||||
@ -331,9 +338,9 @@ void KMLParser::point(Waypoint &waypoint)
|
|||||||
_reader.raiseError("Missing Point coordinates");
|
_reader.raiseError("Missing Point coordinates");
|
||||||
}
|
}
|
||||||
|
|
||||||
void KMLParser::heartRate(SegmentData &segment, int start)
|
void KMLParser::heartRate(SegmentData &segment)
|
||||||
{
|
{
|
||||||
int i = start;
|
int i = 0;
|
||||||
const char error[] = "Heartrate data count mismatch";
|
const char error[] = "Heartrate data count mismatch";
|
||||||
|
|
||||||
while (_reader.readNextStartElement()) {
|
while (_reader.readNextStartElement()) {
|
||||||
@ -348,13 +355,13 @@ void KMLParser::heartRate(SegmentData &segment, int start)
|
|||||||
_reader.skipCurrentElement();
|
_reader.skipCurrentElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i != segment.size())
|
if (!_reader.error() && i != segment.size())
|
||||||
_reader.raiseError(error);
|
_reader.raiseError(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
void KMLParser::cadence(SegmentData &segment, int start)
|
void KMLParser::cadence(SegmentData &segment)
|
||||||
{
|
{
|
||||||
int i = start;
|
int i = 0;
|
||||||
const char error[] = "Cadence data count mismatch";
|
const char error[] = "Cadence data count mismatch";
|
||||||
|
|
||||||
while (_reader.readNextStartElement()) {
|
while (_reader.readNextStartElement()) {
|
||||||
@ -369,13 +376,13 @@ void KMLParser::cadence(SegmentData &segment, int start)
|
|||||||
_reader.skipCurrentElement();
|
_reader.skipCurrentElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i != segment.size())
|
if (!_reader.error() && i != segment.size())
|
||||||
_reader.raiseError(error);
|
_reader.raiseError(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
void KMLParser::speed(SegmentData &segment, int start)
|
void KMLParser::speed(SegmentData &segment)
|
||||||
{
|
{
|
||||||
int i = start;
|
int i = 0;
|
||||||
const char error[] = "Speed data count mismatch";
|
const char error[] = "Speed data count mismatch";
|
||||||
|
|
||||||
while (_reader.readNextStartElement()) {
|
while (_reader.readNextStartElement()) {
|
||||||
@ -390,13 +397,13 @@ void KMLParser::speed(SegmentData &segment, int start)
|
|||||||
_reader.skipCurrentElement();
|
_reader.skipCurrentElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i != segment.size())
|
if (!_reader.error() && i != segment.size())
|
||||||
_reader.raiseError(error);
|
_reader.raiseError(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
void KMLParser::temperature(SegmentData &segment, int start)
|
void KMLParser::temperature(SegmentData &segment)
|
||||||
{
|
{
|
||||||
int i = start;
|
int i = 0;
|
||||||
const char error[] = "Temperature data count mismatch";
|
const char error[] = "Temperature data count mismatch";
|
||||||
|
|
||||||
while (_reader.readNextStartElement()) {
|
while (_reader.readNextStartElement()) {
|
||||||
@ -411,25 +418,49 @@ void KMLParser::temperature(SegmentData &segment, int start)
|
|||||||
_reader.skipCurrentElement();
|
_reader.skipCurrentElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i != segment.size())
|
if (!_reader.error() && i != segment.size())
|
||||||
_reader.raiseError(error);
|
_reader.raiseError(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
void KMLParser::schemaData(SegmentData &segment, int start)
|
void KMLParser::power(SegmentData &segment)
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
const char error[] = "Power data count mismatch";
|
||||||
|
|
||||||
|
while (_reader.readNextStartElement()) {
|
||||||
|
if (_reader.name() == QLatin1String("value")) {
|
||||||
|
if (i < segment.size())
|
||||||
|
segment[i++].setPower(number());
|
||||||
|
else {
|
||||||
|
_reader.raiseError(error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
_reader.skipCurrentElement();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!_reader.error() && i != segment.size())
|
||||||
|
_reader.raiseError(error);
|
||||||
|
}
|
||||||
|
|
||||||
|
void KMLParser::schemaData(SegmentData &segment)
|
||||||
{
|
{
|
||||||
while (_reader.readNextStartElement()) {
|
while (_reader.readNextStartElement()) {
|
||||||
if (_reader.name() == QLatin1String("SimpleArrayData")) {
|
if (_reader.name() == QLatin1String("SimpleArrayData")) {
|
||||||
QXmlStreamAttributes attr = _reader.attributes();
|
QXmlStreamAttributes attr = _reader.attributes();
|
||||||
QString name(attr.value("name").toString());
|
// There are files using capitalized names in the wild!
|
||||||
|
QString name(attr.value("name").toString().toLower());
|
||||||
|
|
||||||
if (name == QLatin1String("Heartrate"))
|
if (name == QLatin1String("heartrate"))
|
||||||
heartRate(segment, start);
|
heartRate(segment);
|
||||||
else if (name == QLatin1String("Cadence"))
|
else if (name == QLatin1String("cadence"))
|
||||||
cadence(segment, start);
|
cadence(segment);
|
||||||
else if (name == QLatin1String("Speed"))
|
else if (name == QLatin1String("speed"))
|
||||||
speed(segment, start);
|
speed(segment);
|
||||||
else if (name == QLatin1String("Temperature"))
|
else if (name == QLatin1String("temperature"))
|
||||||
temperature(segment, start);
|
temperature(segment);
|
||||||
|
else if (name == QLatin1String("power"))
|
||||||
|
power(segment);
|
||||||
else
|
else
|
||||||
_reader.skipCurrentElement();
|
_reader.skipCurrentElement();
|
||||||
} else
|
} else
|
||||||
@ -437,11 +468,11 @@ void KMLParser::schemaData(SegmentData &segment, int start)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void KMLParser::extendedData(SegmentData &segment, int start)
|
void KMLParser::extendedData(SegmentData &segment)
|
||||||
{
|
{
|
||||||
while (_reader.readNextStartElement()) {
|
while (_reader.readNextStartElement()) {
|
||||||
if (_reader.name() == QLatin1String("SchemaData"))
|
if (_reader.name() == QLatin1String("SchemaData"))
|
||||||
schemaData(segment, start);
|
schemaData(segment);
|
||||||
else
|
else
|
||||||
_reader.skipCurrentElement();
|
_reader.skipCurrentElement();
|
||||||
}
|
}
|
||||||
@ -450,8 +481,7 @@ void KMLParser::extendedData(SegmentData &segment, int start)
|
|||||||
void KMLParser::track(SegmentData &segment)
|
void KMLParser::track(SegmentData &segment)
|
||||||
{
|
{
|
||||||
const char error[] = "gx:coord/when element count mismatch";
|
const char error[] = "gx:coord/when element count mismatch";
|
||||||
int first = segment.size();
|
int i = 0;
|
||||||
int i = first;
|
|
||||||
|
|
||||||
while (_reader.readNextStartElement()) {
|
while (_reader.readNextStartElement()) {
|
||||||
if (_reader.name() == QLatin1String("when")) {
|
if (_reader.name() == QLatin1String("when")) {
|
||||||
@ -467,13 +497,20 @@ void KMLParser::track(SegmentData &segment)
|
|||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
} else if (_reader.name() == QLatin1String("ExtendedData"))
|
} else if (_reader.name() == QLatin1String("ExtendedData"))
|
||||||
extendedData(segment, first);
|
extendedData(segment);
|
||||||
else
|
else
|
||||||
_reader.skipCurrentElement();
|
_reader.skipCurrentElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i != segment.size())
|
if (i != segment.size()) {
|
||||||
_reader.raiseError(error);
|
_reader.raiseError(error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// empty (invalid) coordinates are allowed per KML specification!
|
||||||
|
for (int i = 0; i < segment.size(); i++)
|
||||||
|
if (segment.at(i).coordinates().isNull())
|
||||||
|
segment.remove(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
void KMLParser::multiTrack(TrackData &t)
|
void KMLParser::multiTrack(TrackData &t)
|
||||||
|
@ -53,12 +53,13 @@ private:
|
|||||||
bool lineCoordinates(SegmentData &segment);
|
bool lineCoordinates(SegmentData &segment);
|
||||||
bool polygonCoordinates(QVector<Coordinates> &points);
|
bool polygonCoordinates(QVector<Coordinates> &points);
|
||||||
bool coord(Trackpoint &trackpoint);
|
bool coord(Trackpoint &trackpoint);
|
||||||
void extendedData(SegmentData &segment, int start);
|
void extendedData(SegmentData &segment);
|
||||||
void schemaData(SegmentData &segment, int start);
|
void schemaData(SegmentData &segment);
|
||||||
void heartRate(SegmentData &segment, int start);
|
void heartRate(SegmentData &segment);
|
||||||
void cadence(SegmentData &segment, int start);
|
void cadence(SegmentData &segment);
|
||||||
void speed(SegmentData &segment, int start);
|
void speed(SegmentData &segment);
|
||||||
void temperature(SegmentData &segment, int start);
|
void temperature(SegmentData &segment);
|
||||||
|
void power(SegmentData &segment);
|
||||||
QDateTime timeStamp();
|
QDateTime timeStamp();
|
||||||
qreal number();
|
qreal number();
|
||||||
QDateTime time();
|
QDateTime time();
|
||||||
|
@ -61,6 +61,9 @@ bool PLTParser::parse(QFile *file, QList<TrackData> &tracks,
|
|||||||
}
|
}
|
||||||
} else if (_errorLine == 5) {
|
} else if (_errorLine == 5) {
|
||||||
QList<QByteArray> list = line.split(',');
|
QList<QByteArray> list = line.split(',');
|
||||||
|
if (list.size() >= 3 && !list.at(2).isEmpty())
|
||||||
|
track.setStyle(LineStyle(QColor(list.at(2).toUInt()),
|
||||||
|
list.at(1).toUInt()));
|
||||||
if (list.size() >= 4)
|
if (list.size() >= 4)
|
||||||
track.setName(list.at(3));
|
track.setName(list.at(3));
|
||||||
} else if (_errorLine > 6) {
|
} else if (_errorLine > 6) {
|
||||||
@ -166,6 +169,9 @@ bool RTEParser::parse(QFile *file, QList<TrackData> &tracks,
|
|||||||
QByteArray description(list.at(3).trimmed());
|
QByteArray description(list.at(3).trimmed());
|
||||||
routes.last().setDescription(decode(description));
|
routes.last().setDescription(decode(description));
|
||||||
}
|
}
|
||||||
|
if (list.size() >= 5 && !list.at(4).isEmpty())
|
||||||
|
routes.last().setStyle(
|
||||||
|
LineStyle(QColor(list.at(4).toUInt())));
|
||||||
} else if (list.at(0).trimmed() == "W") {
|
} else if (list.at(0).trimmed() == "W") {
|
||||||
if (!record || list.size() < 7) {
|
if (!record || list.size() < 7) {
|
||||||
_errorString = "Parse error";
|
_errorString = "Parse error";
|
||||||
@ -282,6 +288,8 @@ bool WPTParser::parse(QFile *file, QList<TrackData> &tracks,
|
|||||||
delphi2unixMS(date)));
|
delphi2unixMS(date)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (list.size() >= 9 && !list.at(8).isEmpty())
|
||||||
|
wp.setStyle(PointStyle(QColor(list.at(8).toUInt())));
|
||||||
if (list.size() >= 11) {
|
if (list.size() >= 11) {
|
||||||
QByteArray description(list.at(10).trimmed());
|
QByteArray description(list.at(10).trimmed());
|
||||||
if (!description.isEmpty())
|
if (!description.isEmpty())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user