Compare commits

...

5 Commits

Author SHA1 Message Date
bvn13 af129685c3 Merge branch 'release/1.2' 2022-09-29 19:36:29 +03:00
bvn13 2beef609c1 Update versions for release 2022-09-29 19:36:03 +03:00
bvn13 6589c3321b fixed line formatting 2022-09-29 19:34:37 +03:00
bvn13 5b7fdcd6a9 Update for next development version 2022-09-29 15:32:40 +03:00
bvn13 aae754f47f Merge tag '1.1' into develop
Tag release
2022-09-29 15:32:37 +03:00
3 changed files with 467 additions and 422 deletions

14
pom.xml
View File

@ -6,7 +6,7 @@
<artifactId>GpxAndroidSdk</artifactId>
<groupId>me.bvn13.sdk.android.gpx</groupId>
<version>1.1</version>
<version>1.2</version>
<packaging>jar</packaging>
@ -82,15 +82,9 @@
<version>${kotlin-junit.version}</version>
</dependency>
<dependency>
<groupId>io.kotest</groupId>
<artifactId>kotest-runner-junit5-jvm</artifactId>
<version>${kotest.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.kotest</groupId>
<artifactId>kotest-assertions-core-jvm</artifactId>
<version>${kotest.version}</version>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>${jupiter.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

View File

@ -99,11 +99,11 @@ fun GpxType.toXmlString(clock: Clock?): String = """
xsi:schemaLocation="$SCHEMA_LOCATION">
<time>${now(clock)}</time>
${this.metadata.toXmlString()}
${this.wpt?.toXmlString()}
${this.rte?.toXmlString()}
${this.trk?.toXmlString()}
${this.wpt?.toXmlString() ?: ""}
${this.rte?.toXmlString() ?: ""}
${this.trk?.toXmlString() ?: ""}
</gpx>
""".trim()
""".trim().removeEmptyStrings()
fun MetadataType.toXmlString(): String = """
<metadata>
@ -113,16 +113,13 @@ fun MetadataType.toXmlString(): String = """
<name>${this.authorName}</name>
</author>
</metadata>
""".trim()
""".trim().removeEmptyStrings()
private fun now(clock: Clock?) = OffsetDateTime.now(clock ?: Clock.systemDefaultZone()).format(DTF)
fun WptType.toXmlString(nodeName: String? = null) =
if (nodeName != null) {
this.toXmlString(nodeName)
} else {
this.toXmlString("wpt")
}
fun WptType.toXmlString(nodeName: String? = null) = if (nodeName != null) {
this.toXmlString(nodeName)
} else {
this.toXmlString("wpt")
}
@JvmName("toXmlStringNamed")
fun WptType.toXmlString(nodeName: String) = """
@ -135,19 +132,19 @@ fun WptType.toXmlString(nodeName: String) = """
${toXmlString(cmt, "cmt")}
${toXmlString(desc, "desc")}
${toXmlString(src, "src")}
${link?.toXmlString()}
${link?.toXmlString() ?: ""}
${toXmlString(sym, "sym")}
${toXmlString(type, "type")}
${fix?.toXmlString()}
${fix?.toXmlString() ?: ""}
${toXmlString(sat, "sat")}
${toXmlString(hdop, "hdop")}
${toXmlString(vdop, "vdop")}
${toXmlString(pdop, "pdop")}
${toXmlString(ageofgpsdata, "ageofgpsdata")}
${toXmlString(dgpsid, "dgpsid")}
${extensions?.toXmlString()}
${extensions?.toXmlString() ?: ""}
</${nodeName}>
""".trim()
""".trim().removeEmptyStrings()
fun RteType.toXmlString() = """
<rte>
@ -155,13 +152,13 @@ fun RteType.toXmlString() = """
${toXmlString(this.cmt, "cmt")}
${toXmlString(this.desc, "desc")}
${toXmlString(this.src, "src")}
${this.link?.toXmlString()}
${this.link?.toXmlString() ?: ""}
${toXmlString(this.number, "number")}
${toXmlString(this.type, "type")}
${this.extensions?.toXmlString()}
${this.rtept?.toXmlString()}
${this.extensions?.toXmlString() ?: ""}
${this.rtept?.toXmlString() ?: ""}
</rte>
""".trim()
""".trim().removeEmptyStrings()
fun TrkType.toXmlString() = """
<trk>
@ -169,24 +166,47 @@ fun TrkType.toXmlString() = """
${toXmlString(this.cmt, "cmt")}
${toXmlString(this.desc, "desc")}
${toXmlString(this.src, "src")}
${this.link?.toXmlString()}
${this.link?.toXmlString() ?: ""}
${toXmlString(this.number, "number")}
${toXmlString(this.type, "type")}
${this.extensions?.toXmlString()}
${this.trkseg?.toXmlString()}
${this.extensions?.toXmlString() ?: ""}
${this.trkseg?.toXmlString() ?: ""}
</trk>
""".trim()
""".trim().removeEmptyStrings()
fun List<WptType>.toXmlString(nodeName: String?) =
this.joinToString(prefix = "", postfix = "", separator = "") {
it.toXmlString(nodeName)
}
fun LinkType.toXmlString() = """
<link href="${this.href}">
<text>${this.text}</text>
<type>${this.type}</type>
</link>
""".trim().removeEmptyStrings()
fun FixType.toXmlString() = """
<fix>${this.value}</fix>
""".trim().removeEmptyStrings()
fun ExtensionType.toXmlString() = """
<${this.nodeName}${toXmlString(this.parameters)}>${this.value ?: ""}</${this.nodeName}>
""".trim().removeEmptyStrings()
fun TrksegType.toXmlString() = """
<trkseg>
${this.trkpt?.toXmlString("trkpt") ?: ""}
</trkseg>
""".trim().removeEmptyStrings()
fun List<WptType>.toXmlString(nodeName: String?) = this.joinToString(prefix = "\n", postfix = "", separator = "") {
it.toXmlString(nodeName)
}
fun List<ExtensionType>.toXmlString() = this.joinToString(
prefix = "<extensions>\n", postfix = "\n</extensions>", separator = "\n", transform = ExtensionType::toXmlString
)
@JvmName("toXmlStringWptType")
fun List<WptType>.toXmlString() =
this.joinToString(prefix = "", postfix = "", separator = "") {
it.toXmlString()
}
fun List<WptType>.toXmlString() = this.joinToString(prefix = "", postfix = "", separator = "") {
it.toXmlString()
}
@JvmName("toXmlStringLinkType")
fun List<LinkType>.toXmlString() =
@ -204,75 +224,41 @@ fun List<TrkType>.toXmlString() =
fun List<TrksegType>.toXmlString() =
this.joinToString(prefix = "", postfix = "", separator = "", transform = TrksegType::toXmlString)
fun List<ExtensionType>.toXmlString() =
this.joinToString(
prefix = "<extensions>\n",
postfix = "\n</extensions>",
separator = "\n",
transform = ExtensionType::toXmlString
)
fun toXmlString(value: String?, nodeName: String) = if (value != null) {
"<${nodeName}>${value}</${nodeName}>"
} else {
""
}
fun LinkType.toXmlString() = """
<link href="${this.href}">
<text>${this.text}</text>
<type>${this.type}</type>
</link>
""".trim()
fun toXmlString(value: Int?, nodeName: String) = if (value != null) {
"<${nodeName}>${value}</${nodeName}>"
} else {
""
}
fun FixType.toXmlString() = """
<fix>${this.value}</fix>
""".trim()
fun toXmlString(value: Double?, nodeName: String) = if (value != null) {
"<${nodeName}>${value}</${nodeName}>"
} else {
""
}
fun ExtensionType.toXmlString() = """
<${this.nodeName}${toXmlString(this.parameters)}>${this.value ?: ""}</${this.nodeName}>
""".trim()
fun toXmlString(value: OffsetDateTime?, nodeName: String) = if (value != null) {
"<${nodeName}>${value.format(DTF)}</${nodeName}>"
} else {
""
}
fun TrksegType.toXmlString() = """
<trkseg>
${this.trkpt?.toXmlString("trkpt")}
</trkseg>
""".trim()
fun toXmlString(value: Map<String, String>?) = value?.entries?.joinToString(separator = "") {
" ${it.key}=\"${it.value}\""
} ?: ""
fun toXmlString(value: String?, nodeName: String) =
if (value != null) {
"""
<${nodeName}>${value}</${nodeName}>
""".trim()
} else {
""
}
private fun now(clock: Clock?) = OffsetDateTime.now(clock ?: Clock.systemDefaultZone()).format(DTF)
fun toXmlString(value: Int?, nodeName: String) =
if (value != null) {
"""
<${nodeName}>${value}</${nodeName}>
""".trim()
} else {
""
}
fun toXmlString(value: Double?, nodeName: String) =
if (value != null) {
"""
<${nodeName}>${value}</${nodeName}>
""".trim()
} else {
""
}
fun toXmlString(value: OffsetDateTime?, nodeName: String) =
if (value != null) {
"""
<${nodeName}>${value.format(DTF)}</${nodeName}>
""".trim()
} else {
""
}
fun toXmlString(value: Map<String, String>?) =
value?.entries?.joinToString(separator = "") {
" ${it.key}=\"${it.value}\""
} ?: ""
private fun String.removeEmptyStrings() = this.lineSequence().map {
it.trim()
}.filter {
it != ""
}.joinToString("\n")
class GpxWriter {
companion object {
@ -281,9 +267,9 @@ class GpxWriter {
const val XMLNS_XSI = "http://www.w3.org/2001/XMLSchema-instance"
const val SCHEMA_LOCATION = "http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd"
internal val DTF = DateTimeFormatterBuilder()
.append(ISO_LOCAL_DATE_TIME) // use the existing formatter for date time
.appendOffset("+HH:MM", "+00:00") // set 'noOffsetText' to desired '+00:00'
.toFormatter()
internal val DTF =
DateTimeFormatterBuilder().append(ISO_LOCAL_DATE_TIME) // use the existing formatter for date time
.appendOffset("+HH:MM", "+00:00") // set 'noOffsetText' to desired '+00:00'
.toFormatter()
}
}

View File

@ -59,7 +59,7 @@ APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Copyright bvn13, 2022
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -77,184 +77,246 @@ limitations under the License.
package me.bvn13.sdk.android.gpx
import io.kotest.core.spec.style.FunSpec
import org.junit.jupiter.api.DisplayName
import org.junit.jupiter.api.Test
import java.time.*
import kotlin.test.assertEquals
class GpxWriterTest : FunSpec() {
init {
test("first test") {
val clock = Clock.fixed(
LocalDateTime.of(2022, 9, 24, 15, 4, 0, 0).toInstant(ZoneOffset.ofHours(3)), ZoneId.of("Europe/Moscow")
)
class GpxWriterTest {
@DisplayName("test minimum")
@Test
fun testMinimum() {
val clock = Clock.fixed(
LocalDateTime.of(2022, 9, 24, 15, 4, 0, 0).toInstant(ZoneOffset.ofHours(3)), ZoneId.of("Europe/Moscow")
)
val gpxType = GpxType(
MetadataType("test name", description = "test description", authorName = "bvn13"),
wpt = listOf(
WptType(
lat = 14.64736838389662,
lon = 7.93212890625,
ele = 10.toDouble(),
time = OffsetDateTime.now(clock),
magvar = 3.toDouble(),
geoidheight = 45.toDouble(),
name = "test point 1",
cmt = "comment 1",
desc = "description of point 1",
link = listOf(
LinkType(
href = "http://link-to.site.href",
text = "text",
type = "hyperlink"
),
LinkType(
href = "http://link2-to.site.href",
text = "text2",
type = "hyperlink2"
)
),
src = "source 1",
sym = "sym 1",
type = "type 1",
fix = FixType.DGPS,
sat = 1,
hdop = 55.toDouble(),
vdop = 66.toDouble(),
pdop = 77.toDouble(),
ageofgpsdata = 44,
dgpsid = 88,
extensions = listOf(
ExtensionType(
"extension1",
parameters = mapOf(Pair("first", "second"), Pair("third", "fours"))
),
ExtensionType(
"extension2",
parameters = mapOf(Pair("aa", "bb"), Pair("cc", "dd"))
)
)
)
),
rte = listOf(
RteType(
name = "rte name",
cmt = "cmt",
desc = "desc",
src = "src",
link = listOf(
LinkType(
href = "https://new.link.rte",
text = "new text rte",
type = "hyperlink"
)
),
number = 1234,
type = "route",
extensions = listOf(
ExtensionType(
"ext-1",
value = "value1"
)
),
rtept = listOf(
WptType(
lat = 14.64736838389662,
lon = 7.93212890625,
ele = 10.toDouble(),
time = OffsetDateTime.now(clock),
magvar = 3.toDouble(),
geoidheight = 45.toDouble(),
name = "test point 1",
cmt = "comment 1",
desc = "description of point 1",
link = listOf(
LinkType(
href = "http://link-to.site.href",
text = "text",
type = "hyperlink"
),
LinkType(
href = "http://link2-to.site.href",
text = "text2",
type = "hyperlink2"
)
),
src = "source 1",
sym = "sym 1",
type = "type 1",
fix = FixType.DGPS,
sat = 1,
hdop = 55.toDouble(),
vdop = 66.toDouble(),
pdop = 77.toDouble(),
ageofgpsdata = 44,
dgpsid = 88,
extensions = listOf(
ExtensionType(
"extension1",
parameters = mapOf(Pair("first", "second"), Pair("third", "fours"))
),
ExtensionType(
"extension2",
parameters = mapOf(Pair("aa", "bb"), Pair("cc", "dd"))
)
val gpxType = GpxType(
MetadataType("test name"),
trk = listOf(
TrkType(
name = "track1",
trkseg = listOf(
TrksegType(
listOf(
WptType(
lat = 123.toDouble(),
lon = 321.toDouble()
)
)
)
)
),
trk = listOf(
TrkType(
name = "track 1",
cmt = "comment track 1",
desc = "desc track 1",
src = "src track 1",
number = 1234,
type = "type 1",
trkseg = listOf(
TrksegType(
listOf(
WptType(
lat = 14.64736838389662,
lon = 7.93212890625,
ele = 10.toDouble(),
time = OffsetDateTime.now(clock),
magvar = 3.toDouble(),
geoidheight = 45.toDouble(),
name = "test point 1",
cmt = "comment 1",
desc = "description of point 1",
link = listOf(
LinkType(
href = "http://link-to.site.href",
text = "text",
type = "hyperlink"
),
LinkType(
href = "http://link2-to.site.href",
text = "text2",
type = "hyperlink2"
)
)
)
)
assertEquals(
"""
<?xml version="1.0" encoding="UTF-8"?>
<gpx
xmlns="http://www.topografix.com/GPX/1/1"
version="1.1"
creator="me.bvn13.sdk.android.gpx"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd">
<time>2022-09-24T15:04:00+03:00</time>
<metadata>
<name>test name</name>
<desc></desc>
<author>
<name></name>
</author>
</metadata>
<trk>
<name>track1</name>
<trkseg>
<trkpt lat="123.0" lon="321.0">
</trkpt>
</trkseg>
</trk>
</gpx>
""".trim()
.lineSequence()
.map {
it.trim()
}
.joinToString("\n"),
gpxType.toXmlString(clock)
)
}
@DisplayName("test maximum")
@Test
fun maximumTest() {
val clock = Clock.fixed(
LocalDateTime.of(2022, 9, 24, 15, 4, 0, 0).toInstant(ZoneOffset.ofHours(3)), ZoneId.of("Europe/Moscow")
)
val gpxType = GpxType(
MetadataType("test name", description = "test description", authorName = "bvn13"),
wpt = listOf(
WptType(
lat = 14.64736838389662,
lon = 7.93212890625,
ele = 10.toDouble(),
time = OffsetDateTime.now(clock),
magvar = 3.toDouble(),
geoidheight = 45.toDouble(),
name = "test point 1",
cmt = "comment 1",
desc = "description of point 1",
link = listOf(
LinkType(
href = "http://link-to.site.href",
text = "text",
type = "hyperlink"
),
LinkType(
href = "http://link2-to.site.href",
text = "text2",
type = "hyperlink2"
)
),
src = "source 1",
sym = "sym 1",
type = "type 1",
fix = FixType.DGPS,
sat = 1,
hdop = 55.toDouble(),
vdop = 66.toDouble(),
pdop = 77.toDouble(),
ageofgpsdata = 44,
dgpsid = 88,
extensions = listOf(
ExtensionType(
"extension1",
parameters = mapOf(Pair("first", "second"), Pair("third", "fours"))
),
ExtensionType(
"extension2",
parameters = mapOf(Pair("aa", "bb"), Pair("cc", "dd"))
)
)
)
),
rte = listOf(
RteType(
name = "rte name",
cmt = "cmt",
desc = "desc",
src = "src",
link = listOf(
LinkType(
href = "https://new.link.rte",
text = "new text rte",
type = "hyperlink"
)
),
number = 1234,
type = "route",
extensions = listOf(
ExtensionType(
"ext-1",
value = "value1"
)
),
rtept = listOf(
WptType(
lat = 14.64736838389662,
lon = 7.93212890625,
ele = 10.toDouble(),
time = OffsetDateTime.now(clock),
magvar = 3.toDouble(),
geoidheight = 45.toDouble(),
name = "test point 1",
cmt = "comment 1",
desc = "description of point 1",
link = listOf(
LinkType(
href = "http://link-to.site.href",
text = "text",
type = "hyperlink"
),
LinkType(
href = "http://link2-to.site.href",
text = "text2",
type = "hyperlink2"
)
),
src = "source 1",
sym = "sym 1",
type = "type 1",
fix = FixType.DGPS,
sat = 1,
hdop = 55.toDouble(),
vdop = 66.toDouble(),
pdop = 77.toDouble(),
ageofgpsdata = 44,
dgpsid = 88,
extensions = listOf(
ExtensionType(
"extension1",
parameters = mapOf(Pair("first", "second"), Pair("third", "fours"))
),
ExtensionType(
"extension2",
parameters = mapOf(Pair("aa", "bb"), Pair("cc", "dd"))
)
)
)
)
)
),
trk = listOf(
TrkType(
name = "track 1",
cmt = "comment track 1",
desc = "desc track 1",
src = "src track 1",
number = 1234,
type = "type 1",
trkseg = listOf(
TrksegType(
listOf(
WptType(
lat = 14.64736838389662,
lon = 7.93212890625,
ele = 10.toDouble(),
time = OffsetDateTime.now(clock),
magvar = 3.toDouble(),
geoidheight = 45.toDouble(),
name = "test point 1",
cmt = "comment 1",
desc = "description of point 1",
link = listOf(
LinkType(
href = "http://link-to.site.href",
text = "text",
type = "hyperlink"
),
src = "source 1",
sym = "sym 1",
type = "type 1",
fix = FixType.DGPS,
sat = 1,
hdop = 55.toDouble(),
vdop = 66.toDouble(),
pdop = 77.toDouble(),
ageofgpsdata = 44,
dgpsid = 88,
extensions = listOf(
ExtensionType(
"extension1",
parameters = mapOf(Pair("first", "second"), Pair("third", "fours"))
),
ExtensionType(
"extension2",
parameters = mapOf(Pair("aa", "bb"), Pair("cc", "dd"))
)
LinkType(
href = "http://link2-to.site.href",
text = "text2",
type = "hyperlink2"
)
),
src = "source 1",
sym = "sym 1",
type = "type 1",
fix = FixType.DGPS,
sat = 1,
hdop = 55.toDouble(),
vdop = 66.toDouble(),
pdop = 77.toDouble(),
ageofgpsdata = 44,
dgpsid = 88,
extensions = listOf(
ExtensionType(
"extension1",
parameters = mapOf(Pair("first", "second"), Pair("third", "fours"))
),
ExtensionType(
"extension2",
parameters = mapOf(Pair("aa", "bb"), Pair("cc", "dd"))
)
)
)
@ -263,148 +325,151 @@ class GpxWriterTest : FunSpec() {
)
)
)
)
assertEquals(
"""
<?xml version="1.0" encoding="UTF-8"?>
<gpx
xmlns="http://www.topografix.com/GPX/1/1"
version="1.1"
creator="me.bvn13.sdk.android.gpx"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd">
<time>2022-09-24T15:04:00+03:00</time>
<metadata>
<name>test name</name>
<desc>test description</desc>
<author>
<name>bvn13</name>
</author>
</metadata>
<wpt lat="14.64736838389662" lon="7.93212890625">
<ele>10.0</ele>
<time>2022-09-24T15:04:00+03:00</time>
<magvar>3.0</magvar>
<geoidheight>45.0</geoidheight>
<name>test point 1</name>
<cmt>comment 1</cmt>
<desc>description of point 1</desc>
<src>source 1</src>
<link href="http://link-to.site.href">
<text>text</text>
<type>hyperlink</type>
</link>
<link href="http://link2-to.site.href">
<text>text2</text>
<type>hyperlink2</type>
</link>
<sym>sym 1</sym>
<type>type 1</type>
<fix>dgps</fix>
<sat>1</sat>
<hdop>55.0</hdop>
<vdop>66.0</vdop>
<pdop>77.0</pdop>
<ageofgpsdata>44</ageofgpsdata>
<dgpsid>88</dgpsid>
<extensions>
<extension1 first="second" third="fours"></extension1>
<extension2 aa="bb" cc="dd"></extension2>
</extensions>
</wpt>
<rte>
<name>rte name</name>
<cmt>cmt</cmt>
<desc>desc</desc>
<src>src</src>
<link href="https://new.link.rte">
<text>new text rte</text>
<type>hyperlink</type>
</link>
<number>1234</number>
<type>route</type>
<extensions>
<ext-1>value1</ext-1>
</extensions>
<wpt lat="14.64736838389662" lon="7.93212890625">
<ele>10.0</ele>
<time>2022-09-24T15:04:00+03:00</time>
<magvar>3.0</magvar>
<geoidheight>45.0</geoidheight>
<name>test point 1</name>
<cmt>comment 1</cmt>
<desc>description of point 1</desc>
<src>source 1</src>
<link href="http://link-to.site.href">
<text>text</text>
<type>hyperlink</type>
</link>
<link href="http://link2-to.site.href">
<text>text2</text>
<type>hyperlink2</type>
</link>
<sym>sym 1</sym>
<type>type 1</type>
<fix>dgps</fix>
<sat>1</sat>
<hdop>55.0</hdop>
<vdop>66.0</vdop>
<pdop>77.0</pdop>
<ageofgpsdata>44</ageofgpsdata>
<dgpsid>88</dgpsid>
<extensions>
<extension1 first="second" third="fours"></extension1>
<extension2 aa="bb" cc="dd"></extension2>
</extensions>
</wpt>
</rte>
<trk>
<name>track 1</name>
<cmt>comment track 1</cmt>
<desc>desc track 1</desc>
<src>src track 1</src>
null
<number>1234</number>
<type>type 1</type>
null
<trkseg>
<trkpt lat="14.64736838389662" lon="7.93212890625">
<ele>10.0</ele>
<time>2022-09-24T15:04:00+03:00</time>
<magvar>3.0</magvar>
<geoidheight>45.0</geoidheight>
<name>test point 1</name>
<cmt>comment 1</cmt>
<desc>description of point 1</desc>
<src>source 1</src>
<link href="http://link-to.site.href">
<text>text</text>
<type>hyperlink</type>
</link>
<link href="http://link2-to.site.href">
<text>text2</text>
<type>hyperlink2</type>
</link>
<sym>sym 1</sym>
<type>type 1</type>
<fix>dgps</fix>
<sat>1</sat>
<hdop>55.0</hdop>
<vdop>66.0</vdop>
<pdop>77.0</pdop>
<ageofgpsdata>44</ageofgpsdata>
<dgpsid>88</dgpsid>
<extensions>
<extension1 first="second" third="fours"></extension1>
<extension2 aa="bb" cc="dd"></extension2>
</extensions>
</trkpt>
</trkseg>
</trk>
</gpx>
""".trim(),
gpxType.toXmlString(clock)
)
}
assertEquals(
"""
<?xml version="1.0" encoding="UTF-8"?>
<gpx
xmlns="http://www.topografix.com/GPX/1/1"
version="1.1"
creator="me.bvn13.sdk.android.gpx"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd">
<time>2022-09-24T15:04:00+03:00</time>
<metadata>
<name>test name</name>
<desc>test description</desc>
<author>
<name>bvn13</name>
</author>
</metadata>
<wpt lat="14.64736838389662" lon="7.93212890625">
<ele>10.0</ele>
<time>2022-09-24T15:04:00+03:00</time>
<magvar>3.0</magvar>
<geoidheight>45.0</geoidheight>
<name>test point 1</name>
<cmt>comment 1</cmt>
<desc>description of point 1</desc>
<src>source 1</src>
<link href="http://link-to.site.href">
<text>text</text>
<type>hyperlink</type>
</link>
<link href="http://link2-to.site.href">
<text>text2</text>
<type>hyperlink2</type>
</link>
<sym>sym 1</sym>
<type>type 1</type>
<fix>dgps</fix>
<sat>1</sat>
<hdop>55.0</hdop>
<vdop>66.0</vdop>
<pdop>77.0</pdop>
<ageofgpsdata>44</ageofgpsdata>
<dgpsid>88</dgpsid>
<extensions>
<extension1 first="second" third="fours"></extension1>
<extension2 aa="bb" cc="dd"></extension2>
</extensions>
</wpt>
<rte>
<name>rte name</name>
<cmt>cmt</cmt>
<desc>desc</desc>
<src>src</src>
<link href="https://new.link.rte">
<text>new text rte</text>
<type>hyperlink</type>
</link>
<number>1234</number>
<type>route</type>
<extensions>
<ext-1>value1</ext-1>
</extensions>
<wpt lat="14.64736838389662" lon="7.93212890625">
<ele>10.0</ele>
<time>2022-09-24T15:04:00+03:00</time>
<magvar>3.0</magvar>
<geoidheight>45.0</geoidheight>
<name>test point 1</name>
<cmt>comment 1</cmt>
<desc>description of point 1</desc>
<src>source 1</src>
<link href="http://link-to.site.href">
<text>text</text>
<type>hyperlink</type>
</link>
<link href="http://link2-to.site.href">
<text>text2</text>
<type>hyperlink2</type>
</link>
<sym>sym 1</sym>
<type>type 1</type>
<fix>dgps</fix>
<sat>1</sat>
<hdop>55.0</hdop>
<vdop>66.0</vdop>
<pdop>77.0</pdop>
<ageofgpsdata>44</ageofgpsdata>
<dgpsid>88</dgpsid>
<extensions>
<extension1 first="second" third="fours"></extension1>
<extension2 aa="bb" cc="dd"></extension2>
</extensions>
</wpt>
</rte>
<trk>
<name>track 1</name>
<cmt>comment track 1</cmt>
<desc>desc track 1</desc>
<src>src track 1</src>
<number>1234</number>
<type>type 1</type>
<trkseg>
<trkpt lat="14.64736838389662" lon="7.93212890625">
<ele>10.0</ele>
<time>2022-09-24T15:04:00+03:00</time>
<magvar>3.0</magvar>
<geoidheight>45.0</geoidheight>
<name>test point 1</name>
<cmt>comment 1</cmt>
<desc>description of point 1</desc>
<src>source 1</src>
<link href="http://link-to.site.href">
<text>text</text>
<type>hyperlink</type>
</link>
<link href="http://link2-to.site.href">
<text>text2</text>
<type>hyperlink2</type>
</link>
<sym>sym 1</sym>
<type>type 1</type>
<fix>dgps</fix>
<sat>1</sat>
<hdop>55.0</hdop>
<vdop>66.0</vdop>
<pdop>77.0</pdop>
<ageofgpsdata>44</ageofgpsdata>
<dgpsid>88</dgpsid>
<extensions>
<extension1 first="second" third="fours"></extension1>
<extension2 aa="bb" cc="dd"></extension2>
</extensions>
</trkpt>
</trkseg>
</trk>
</gpx>
""".trim()
.lineSequence()
.map {
it.trim()
}
.joinToString("\n"),
gpxType.toXmlString(clock)
)
}
}