|
57 | 57 | import org.testng.annotations.DataProvider; |
58 | 58 | import org.testng.annotations.Test; |
59 | 59 | import org.w3c.dom.Document; |
| 60 | +import org.w3c.dom.NodeList; |
60 | 61 |
|
61 | 62 | import io.jenetics.jpx.GPX.Reader.Mode; |
62 | 63 | import io.jenetics.jpx.GPX.Version; |
@@ -960,4 +961,57 @@ public void issue170_InvalidGPXVersion() throws IOException { |
960 | 961 | assertThat(gpx.getTracks().get(0).getSegments().get(0)).hasSize(2); |
961 | 962 | } |
962 | 963 |
|
| 964 | + @Test |
| 965 | + public void issue_179() { |
| 966 | + final GPX gpx = GPX.Reader.of(Mode.LENIENT).fromString(""" |
| 967 | + <?xml version='1.0' encoding='UTF-8' standalone='yes' ?> |
| 968 | + <gpx xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd" |
| 969 | + xmlns="http://www.topografix.com/GPX/1/1" |
| 970 | + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
| 971 | + xmlns:ns3="http://www.garmin.com/xmlschemas/TrackPointExtension/v1" |
| 972 | + xmlns:ns2="http://www.garmin.com/xmlschemas/GpxExtensions/v3" |
| 973 | + xmlns:ns1="http://www.cluetrust.com/XML/GPXDATA/1/0" |
| 974 | + creator="Zepp App" |
| 975 | + version="8.0.2-play" |
| 976 | + > |
| 977 | + <trk> |
| 978 | + <name><![CDATA[20230811 splitvicte-national-parc]]></name> |
| 979 | + <trkseg> |
| 980 | + <trkpt lat="44.873146" lon="15.599844"> |
| 981 | + <ele>622.95</ele> |
| 982 | + <time>2023-08-11T10:25:52Z</time> |
| 983 | + <extensions> |
| 984 | + <ns3:TrackPointExtension> |
| 985 | + <ns3:speed>0.11750881</ns3:speed> |
| 986 | + <ns3:cad>0.0</ns3:cad> |
| 987 | + <ns3:hr>88</ns3:hr> |
| 988 | + </ns3:TrackPointExtension> |
| 989 | + </extensions> |
| 990 | + </trkpt> |
| 991 | + </trkseg> |
| 992 | + </trk> |
| 993 | + </gpx> |
| 994 | + """ |
| 995 | + ); |
| 996 | + |
| 997 | + final Document extensions = gpx |
| 998 | + .getTracks().get(0) |
| 999 | + .getSegments().get(0) |
| 1000 | + .getPoints().get(0) |
| 1001 | + .getExtensions().orElseThrow(); |
| 1002 | + |
| 1003 | + final NodeList trackPointExtension = extensions |
| 1004 | + .getDocumentElement() |
| 1005 | + .getFirstChild() |
| 1006 | + .getChildNodes(); |
| 1007 | + |
| 1008 | + final String speed = trackPointExtension.item(0).getTextContent(); |
| 1009 | + final String cad = trackPointExtension.item(1).getTextContent(); |
| 1010 | + final String hr = trackPointExtension.item(2).getTextContent(); |
| 1011 | + |
| 1012 | + assertThat(speed).isEqualTo("0.11750881"); |
| 1013 | + assertThat(cad).isEqualTo("0.0"); |
| 1014 | + assertThat(hr).isEqualTo("88"); |
| 1015 | + } |
| 1016 | + |
963 | 1017 | } |
0 commit comments