Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TrkSeg can be empty on GPX 1.1 #23

Closed
alex-piccione opened this issue Apr 9, 2016 · 2 comments
Closed

TrkSeg can be empty on GPX 1.1 #23

alex-piccione opened this issue Apr 9, 2016 · 2 comments

Comments

@alex-piccione
Copy link

With a GPX 1.1 you have this error parsing a GPX file:
NullReferenceException
if the file contains an empty trkseg element ()

trkseg can be an empty element: http://www.topografix.com/GPX/1/1/#type_trksegType
(it is a complex element and contains a sequence of [0..*] trkpt elements)

The problem is in Gps\Serialization\Gpx11Serializer.cs

private static void ParseTracks(GpxFile xml, GpsData data)
[...]
foreach (var wptType in trksegType.trkpt)

trksegType.trkpt is null if trkseg element doesn't contain any point.

(problem exists in version 0.13 and 0.14)

Alessandro

@alex-piccione
Copy link
Author

A segment is added in track only for adding points, so it can be ignored if it hasn't points.
Proposed solution.
from:
foreach (var trksegType in trkType.trkseg)
to:
foreach (var trksegType in trkType.trkseg.Where(seg => seg.trkpt != null))

@sibartlett
Copy link
Owner

0.14.1 pushed to NuGet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants