GithubHelp home page GithubHelp logo

Comments (2)

KennethEvans avatar KennethEvans commented on July 1, 2024

Yes, it is definitely not handling the case where the default namespace is not http://www.topografix.com/GPX/1/1. That seems to be a bug to me. In fact, even ElementTree by default will use ns0 for http://www.topografix.com/GPX/1/1 and no default namespace. It is valid.

I fixed it by using ElementTree to parse the file after setting the default namespace to be http://www.topografix.com/GPX/1/1 and then passing the resulting XML to gpxpy.parse.

import xml.etree.ElementTree as ET

        # Ensure GPX/1/1 is the default namespace
        ET.register_namespace('', "http://www.topografix.com/GPX/1/1")
        tree = ET.parse(file_name)
        root = tree.getroot();
        xml = ET.tostring(root, encoding='unicode');
        # Parse the xml string
        gpx = gpxpy.parse(xml)

from gpxpy.

tve avatar tve commented on July 1, 2024

I'm having a perhaps similar problem. Converting garmin fit files to gpx results in:

<gpx version="1.1" creator="GPSBabel - https://www.gpsbabel.org" xmlns="http://www.topografix.com/GP
X/1/1" xmlns:gpxx="http://www.garmin.com/xmlschemas/GpxExtensions/v3" xmlns:gpxtpx="http://www.garmi
n.com/xmlschemas/TrackPointExtension/v1">

and have trkpt looking like

      <trkpt lat="34.405181017" lon="-119.842143841">
        <ele>-4.200</ele>
        <time>2022-02-15T22:12:26Z</time>
        <extensions>
          <gpxtpx:TrackPointExtension>
            <gpxtpx:atemp>20.000000</gpxtpx:atemp>
            <gpxtpx:hr>153</gpxtpx:hr>
          </gpxtpx:TrackPointExtension>
        </extensions>
      </trkpt>

and after parsing segment points have an empty extensions field.

from gpxpy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.