mirror of
https://github.com/tumic0/GPXSee.git
synced 2024-11-30 22:51:16 +01:00
Fixed broken parsing of KML tracks with empty coordinates
This commit is contained in:
parent
2549204662
commit
51511a9bf9
@ -482,6 +482,7 @@ void KMLParser::track(SegmentData &segment)
|
|||||||
{
|
{
|
||||||
const char error[] = "gx:coord/when element count mismatch";
|
const char error[] = "gx:coord/when element count mismatch";
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
bool empty = false;
|
||||||
|
|
||||||
while (_reader.readNextStartElement()) {
|
while (_reader.readNextStartElement()) {
|
||||||
if (_reader.name() == QLatin1String("when")) {
|
if (_reader.name() == QLatin1String("when")) {
|
||||||
@ -495,6 +496,8 @@ void KMLParser::track(SegmentData &segment)
|
|||||||
_reader.raiseError("Invalid coordinates");
|
_reader.raiseError("Invalid coordinates");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (segment.at(i).coordinates().isNull())
|
||||||
|
empty = true;
|
||||||
i++;
|
i++;
|
||||||
} else if (_reader.name() == QLatin1String("ExtendedData"))
|
} else if (_reader.name() == QLatin1String("ExtendedData"))
|
||||||
extendedData(segment);
|
extendedData(segment);
|
||||||
@ -507,10 +510,15 @@ void KMLParser::track(SegmentData &segment)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// empty (invalid) coordinates are allowed per KML specification!
|
/* empty (invalid) coordinates are allowed per KML specification, but
|
||||||
|
invalid in our data representation so get rid of the segment entries */
|
||||||
|
if (empty) {
|
||||||
|
SegmentData filtered;
|
||||||
for (int i = 0; i < segment.size(); i++)
|
for (int i = 0; i < segment.size(); i++)
|
||||||
if (segment.at(i).coordinates().isNull())
|
if (!segment.at(i).coordinates().isNull())
|
||||||
segment.remove(i);
|
filtered.append(segment.at(i));
|
||||||
|
segment = filtered;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void KMLParser::multiTrack(TrackData &t)
|
void KMLParser::multiTrack(TrackData &t)
|
||||||
|
Loading…
Reference in New Issue
Block a user