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

Cannot read amazfit gpx track #170

Closed
Nymerea opened this issue Sep 19, 2023 · 5 comments
Closed

Cannot read amazfit gpx track #170

Nymerea opened this issue Sep 19, 2023 · 5 comments
Assignees
Milestone

Comments

@Nymerea
Copy link

Nymerea commented Sep 19, 2023

Hi,
I cannot parse a gpx file imported from my amazfit watch.
java.io.InvalidObjectException: Invalid GPX: Invalid value for 'version': Unknown version string: '7.7.5-play'.

here is an exemple of the gpx file :

<?xml version='1.0' encoding='UTF-8' standalone='yes' ?>
<gpx xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd" xmlns="http://www.topografix.com/GPX/1/1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns3="http://www.garmin.com/xmlschemas/TrackPointExtension/v1" xmlns:ns2="http://www.garmin.com/xmlschemas/GpxExtensions/v3" xmlns:ns1="http://www.cluetrust.com/XML/GPXDATA/1/0" creator="Zepp App" version="7.7.5-play">
	<trk>
		<name><![CDATA[20230507 mile iles]]></name>
		<trkseg>
			<trkpt lat="45.5898" lon="-73.67509">
				<ele>42.05</ele>
				<time>2023-05-07T18:34:59Z</time>
					<extensions>
						<ns3:TrackPointExtension>
							<ns3:speed>2.3255813</ns3:speed>
							<ns3:cad>0.0</ns3:cad>
							<ns3:hr>72</ns3:hr>
						</ns3:TrackPointExtension>
					</extensions>
			</trkpt>
			<trkpt lat="45.589817" lon="-73.67511">
				<ele>42.05</ele>
				<time>2023-05-07T18:34:59Z</time>
					<extensions>
						<ns3:TrackPointExtension>
							<ns3:speed>2.3255813</ns3:speed>
							<ns3:cad>0.0</ns3:cad>
							<ns3:hr>72</ns3:hr>
						</ns3:TrackPointExtension>
					</extensions>
			</trkpt>
		</trkseg>
	</trk>
</gpx>
@jenetics
Copy link
Owner

jenetics commented Sep 19, 2023

The version attribute determines the GPX version, which is either "1.0" or "1.1", according to the GPX-standard. The amazfit watch is creating an invalid GPX file.

You have to fix the version string to "1.1".

@Nymerea
Copy link
Author

Nymerea commented Sep 22, 2023

In this code

	public static Version of(final String version) {
			return switch (version) {
				case "1.0" -> V10;
				case "1.1" -> V11;
				default -> throw new IllegalArgumentException(format(
					"Unknown version string: '%s'.", version
				));
			};
		}

can't we make it return V11 by default ?

@jenetics
Copy link
Owner

Since the given GPX file is invalid, this is not my preferred fix. But I can imagine, that such files are readable with lenient mode.

final var gpx = GPX.Reader
    .of(Mode.LENIENT)
    .read("invalid.gpx");

@jenetics
Copy link
Owner

jenetics commented Nov 6, 2023

Merged into r3.1.0.

@jenetics jenetics closed this as completed Nov 6, 2023
@jenetics jenetics added this to the v3.1.0 milestone Nov 6, 2023
@Nymerea
Copy link
Author

Nymerea commented Nov 7, 2023

Thanks a million for the fix. I had to write my own parser with xstream.
I will happilly migrate to jpx :-)

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

No branches or pull requests

2 participants