From 7446dfe47d2fe79f88f491a30303fead7a645808 Mon Sep 17 00:00:00 2001 From: bvn13 Date: Wed, 1 Mar 2023 23:17:48 +0300 Subject: [PATCH] fixed reading camelCase extensions --- .../me/bvn13/sdk/android/gpx/GpxReader.kt | 4 +- .../me/bvn13/sdk/android/gpx/GpxReaderTest.kt | 10 +- .../resources/track-2023-03-01--21-21-54.gpx | 221 ++++++++++++++++++ 3 files changed, 232 insertions(+), 3 deletions(-) create mode 100644 src/test/resources/track-2023-03-01--21-21-54.gpx diff --git a/src/main/kotlin/me/bvn13/sdk/android/gpx/GpxReader.kt b/src/main/kotlin/me/bvn13/sdk/android/gpx/GpxReader.kt index 1687ca6..dca424c 100644 --- a/src/main/kotlin/me/bvn13/sdk/android/gpx/GpxReader.kt +++ b/src/main/kotlin/me/bvn13/sdk/android/gpx/GpxReader.kt @@ -199,7 +199,7 @@ class GpxReader { throw IllegalArgumentException("Not a tag at position ${buffer.position}") } var container = readUntil(dis, buffer, setOf(' ', '\n', '>')) - val tagName = container.buffer.asString().substring(1, container.buffer.size - 1).lowercase() + val tagName = container.buffer.asString().substring(1, container.buffer.size - 1) checker?.invoke(container) val xmlObject = XmlObject(tagName) if (container.byte!!.toInt() != '>'.code) { @@ -406,7 +406,7 @@ class GpxReader { var value: String? = null init { - this.type = type.lowercase() + this.type = type } } diff --git a/src/test/kotlin/me/bvn13/sdk/android/gpx/GpxReaderTest.kt b/src/test/kotlin/me/bvn13/sdk/android/gpx/GpxReaderTest.kt index 6c253f9..ec1829b 100644 --- a/src/test/kotlin/me/bvn13/sdk/android/gpx/GpxReaderTest.kt +++ b/src/test/kotlin/me/bvn13/sdk/android/gpx/GpxReaderTest.kt @@ -411,7 +411,7 @@ class GpxReaderTest { assertEquals(gpxType, gpx) } - @DisplayName("Read test.gpx (generated in OsmAnd Android application") + @DisplayName("Read test.gpx (generated in OsmAnd Android application)") @Test fun readTestGpx() { val gpxType = GpxType.read(javaClass.classLoader.getResource("test.gpx").openStream()) @@ -422,4 +422,12 @@ class GpxReaderTest { Assertions.assertEquals(159, gpxType.trk?.get(0)?.trkseg?.get(0)?.extensions?.nested?.get(1)?.nested?.size ?: 0) Assertions.assertEquals(1, gpxType.extensions?.nested?.size ?: 0) } + + @DisplayName("Read track-2023-03-01--21-21-54.gpx") + @Test + fun readTestGpx_v_1_9() { + val gpxType = GpxType.read(javaClass.classLoader.getResource("track-2023-03-01--21-21-54.gpx").openStream()) + Assertions.assertEquals(20, gpxType.trk?.get(0)?.trkseg?.get(0)?.trkpt?.size ?: 0) + Assertions.assertEquals(4, gpxType.trk?.get(0)?.trkseg?.get(0)?.trkpt?.get(0)?.extensions?.size ?: 0) + } } \ No newline at end of file diff --git a/src/test/resources/track-2023-03-01--21-21-54.gpx b/src/test/resources/track-2023-03-01--21-21-54.gpx new file mode 100644 index 0000000..3e8fc54 --- /dev/null +++ b/src/test/resources/track-2023-03-01--21-21-54.gpx @@ -0,0 +1,221 @@ + + + + +2023-03-01T21:22:02.89 + + + + + + +Track 1 + + +169.1999969482422 + + +1.0133984 +177426232867134 +0.15 +5.0 + + + +169.1999969482422 + + +1.0133984 +177426232867134 +0.15 +5.0 + + + +169.1999969482422 + + +1.0133984 +177426232867134 +0.15 +5.0 + + + +169.1999969482422 + + +1.0133984 +177426232867134 +0.15 +5.0 + + + +169.1999969482422 + + +1.0133984 +177426232867134 +0.15 +5.0 + + + +170.39999389648438 + + +1.0500889 +177443237154632 +0.15 +5.0 + + + +170.39999389648438 + + +1.0500889 +177443237154632 +0.15 +5.0 + + + +170.39999389648438 + + +1.0500889 +177443237154632 +0.15 +5.0 + + + +170.39999389648438 + + +1.0500889 +177443237154632 +0.15 +5.0 + + + +170.39999389648438 + + +1.0500889 +177443237154632 +0.15 +5.0 + + + +170.39999389648438 + + +1.0334443 +177476234577543 +0.15 +5.0 + + + +170.39999389648438 + + +1.0334443 +177476234577543 +0.15 +5.0 + + + +170.39999389648438 + + +1.0334443 +177476234577543 +0.15 +5.0 + + + +170.39999389648438 + + +1.0334443 +177476234577543 +0.15 +5.0 + + + +170.39999389648438 + + +1.0334443 +177476234577543 +0.15 +5.0 + + + +170.6999969482422 + + +0.123607546 +177494226488478 +0.15 +5.0 + + + +170.6999969482422 + + +0.123607546 +177494226488478 +0.15 +5.0 + + + +170.6999969482422 + + +0.123607546 +177494226488478 +0.15 +5.0 + + + +170.6999969482422 + + +0.123607546 +177494226488478 +0.15 +5.0 + + + +170.6999969482422 + + +0.123607546 +177494226488478 +0.15 +5.0 + + + + + \ No newline at end of file