Skip to content
New issue

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

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

Already on GitHub? # to your account

Ignore empty segments #29

Merged
merged 1 commit into from
Mar 6, 2018
Merged

Conversation

nathanvda
Copy link
Contributor

I am using this library with pleasure in our software. Unfortunately a user of ours turned up with a gpx which contained empty segments at the end which caused an error.

E.g. something like

<gpx>
    <trk>
       [one or more correct segments]
        <trkseg>
        </trkseg>
        <trkseg>
        </trkseg>
    </trk>
</gpx>

When adding the segment to the track, the update_meta_data function barfed. My first solution was to only try to update the meta data if the segment actually contained points, but then the track also had empty segments, and not sure what the effects might be later on, so upon adding the segment I check if the segment actually contains points and only add in that case.

I added an example-file + test-case. This should have no effect imho for anybody else, it would just handle ill-formed gpx files better (well maybe ill-formed is worded too strong: but gpx files with empty segments).

@andrewhao
Copy link
Collaborator

Thanks for your contribution, @nathanvda!

@andrewhao andrewhao merged commit 250e39c into dougfales:master Mar 6, 2018
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants