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

extensions with complex children are not parsed #73

Closed
tstanis opened this issue Aug 22, 2016 · 1 comment
Closed

extensions with complex children are not parsed #73

tstanis opened this issue Aug 22, 2016 · 1 comment

Comments

@tstanis
Copy link

tstanis commented Aug 22, 2016

For example, consider these extensions:

<extensions>
  <gpxtpx:TrackPointExtension>
    <gpxtpx:atemp>29</gpxtpx:atemp>
    <gpxtpx:hr>89</gpxtpx:hr>
    <gpxtpx:cad>83</gpxtpx:cad>
  </gpxtpx:TrackPointExtension>
</extensions>

The problem is that GPXExtensionField assumes that all extensions are simple values, and doesn't parse the children:

https://github.com/tkrajina/gpxpy/blob/master/gpxpy/gpxfield.py#L254

I think the fix is to make the extensions into objects, but this breaks API compatibility as some users are expecting that extensions['myextension'] returns a string value, not an object. One way to deal with this would be to have extensions have a new field called subExtensions that contains the children.

What do you think?

@tkrajina
Copy link
Owner

I'll quote from README.md:

WARNING: The only part of the GPX standard which is not completely implemented are GPX extensions. The API for GPX extensions will change in future versions!!!

I was thinking on a customizable extensions helper which need to specify a serializer and underializer functions to user's own custom object. Then, those will be executed during parsing or .to_xml().

Everything not (de)serialized with this serialized will be in the existing extensions map. This will not break the existing versions.

Unfortunately, at the moment I don't have the time to implement that :( But, if somebody is willing to implement this, I'm willing to help/discuss/merge.

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