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

Look for opencpn extensions to GPX #129

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

Look for opencpn extensions to GPX #129

wants to merge 7 commits into from

Conversation

tmcw
Copy link
Collaborator

@tmcw tmcw commented Nov 19, 2024

The GPX extensions support is based on a known list of extensions, and it wasn't including this opencpn extension. This adds the OpenCPN extension namespace, which adds support for those rte extensions.

cc @jaybo

@tmcw tmcw mentioned this pull request Nov 19, 2024
@jaybo
Copy link

jaybo commented Nov 20, 2024

It seems wrong that every additional private extension namespace requires an update to this library. I'm planning to add yet another namespace since I don't control opencpn.

Wouldn't it be possible to just automatically add every xmlns entry within the <gpx> tag?

@tmcw
Copy link
Collaborator Author

tmcw commented Nov 20, 2024

Yeah, good point. Latest changes look for all possible xmlns: extensions, which picks up a lot more. We've got one example in test data of usage of gpxx with a local xmlns:

    <extensions>
      <gpxx:TrackExtension xmlns:gpxx="http://www.garmin.com/xmlschemas/GpxExtensions/v3">
        <gpxx:DisplayColor>Transparent</gpxx:DisplayColor>
      </gpxx:TrackExtension>
    </extensions>

So I'm adding the gpxx URL by default to the list of detected namespaces.

Thoughts - this seems more comprehensive?

@jaybo
Copy link

jaybo commented Nov 21, 2024

Can you have multiple namespaces simultaneously active? Like:

<?xml version="1.0"?>
<gpx version="1.1" creator="OpenCPN" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.topografix.com/GPX/1/1" xmlns:gpxx="http://www.garmin.com/xmlschemas/GpxExtensions/v3" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd http://www.garmin.com/xmlschemas/GpxExtensions/v3 http://www8.garmin.com/xmlschemas/GpxExtensionsv3.xsd" xmlns:opencpn="http://www.opencpn.org">
  <rte>
    <name>Around Orcas</name>
    <extensions>
       <gpxx:DisplayColor>Transparent</gpxx:DisplayColor>
       <opencpn:planned_speed>6.00</opencpn:planned_speed>
        ...

@tmcw
Copy link
Collaborator Author

tmcw commented Nov 21, 2024

Yes, this should handle as many namespaces as are defined in the gpx root tag.

@tmcw
Copy link
Collaborator Author

tmcw commented Nov 22, 2024

Does this seem doable for your usecase? I could merge, or release a prerelease tag if you want to try it out.

@jaybo
Copy link

jaybo commented Nov 22, 2024

Looks perfect. I was just trying to figure out how to build it for testing, but if you could either merge or pre-release, that would be great. A mention in the readme about supporting arbitrary namespaces might be a good idea too. Thanks for moving on this quickly!

@tmcw
Copy link
Collaborator Author

tmcw commented Nov 22, 2024

Great, pushed 6.0.0-0 to npm, try it out!

@jaybo
Copy link

jaybo commented Nov 22, 2024

I tried it with a bunch of .gpx files and it solves all of my main issues. Thanks!

The one remaining point is that I have a GPX file which has properties attached to route waypoints.
DavidAltRoute.txt

<rte>
    <name>Day 2</name>
    <desc>Through Deception Pass</desc>
    <rtept lat="48.041" lon="-122.403">
      <name>Langley</name>
      <time>2024-12-07T09:00</time>
    </rtept>
    ...

I don't know if this is legal or common, but would it be possible to add coordinateProperties to routes as well as tracks?

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

Successfully merging this pull request may close these issues.

2 participants