Merge branch 'release/1.10.1'

This commit is contained in:
bvn13 2023-03-02 17:43:07 +03:00
commit 9168ae9875
3 changed files with 28 additions and 7 deletions

5
.gitignore vendored
View File

@ -369,3 +369,8 @@ gradle-app.setting
# End of https://www.toptal.com/developers/gitignore/api/java,gradle,git,intellij,linux,windows,macos,node # End of https://www.toptal.com/developers/gitignore/api/java,gradle,git,intellij,linux,windows,macos,node
**/target/ **/target/
.idea/
.idea/**
GpxAndroidSdk.iml

View File

@ -6,7 +6,7 @@
<artifactId>GpxAndroidSdk</artifactId> <artifactId>GpxAndroidSdk</artifactId>
<groupId>me.bvn13.sdk.android.gpx</groupId> <groupId>me.bvn13.sdk.android.gpx</groupId>
<version>1.9</version> <version>1.10.1</version>
<packaging>jar</packaging> <packaging>jar</packaging>
@ -58,6 +58,11 @@
</repository> </repository>
</distributionManagement> </distributionManagement>
<dependencies> <dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>2.0.6</version>
</dependency>
<dependency> <dependency>
<groupId>org.jetbrains.kotlin</groupId> <groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-test-junit5</artifactId> <artifactId>kotlin-test-junit5</artifactId>
@ -234,7 +239,7 @@
<developmentBranch>develop</developmentBranch> <developmentBranch>develop</developmentBranch>
</gitFlowConfig> </gitFlowConfig>
<incrementVersionAtFinish>true</incrementVersionAtFinish> <incrementVersionAtFinish>true</incrementVersionAtFinish>
<versionDigitToIncrement>2</versionDigitToIncrement> <versionDigitToIncrement>3</versionDigitToIncrement>
</configuration> </configuration>
</plugin> </plugin>
</plugins> </plugins>

View File

@ -82,6 +82,9 @@ import me.bvn13.sdk.android.gpx.GpxConstant.Companion.HEADER
import me.bvn13.sdk.android.gpx.GpxWriter.Companion.SCHEMA_LOCATION import me.bvn13.sdk.android.gpx.GpxWriter.Companion.SCHEMA_LOCATION
import me.bvn13.sdk.android.gpx.GpxWriter.Companion.XMLNS import me.bvn13.sdk.android.gpx.GpxWriter.Companion.XMLNS
import me.bvn13.sdk.android.gpx.GpxWriter.Companion.XMLNS_XSI import me.bvn13.sdk.android.gpx.GpxWriter.Companion.XMLNS_XSI
import me.bvn13.sdk.android.gpx.GpxWriter.Companion.log
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import java.time.Clock import java.time.Clock
import java.time.OffsetDateTime import java.time.OffsetDateTime
@ -257,10 +260,17 @@ fun toXmlString(value: Double?, nodeName: String) = if (value != null) {
"" ""
} }
fun toXmlString(value: OffsetDateTime?, nodeName: String) = if (value != null) { fun toXmlString(value: OffsetDateTime?, nodeName: String): String {
"<${nodeName}>${value.format(DTF)}</${nodeName}>" if (value != null) {
} else { try {
"" return "<${nodeName}>${value.format(DTF)}</${nodeName}>"
} catch (e: Exception) {
log.warn(String.format("Unable to format datetime value %s in node %s", value, nodeName), e)
return ""
}
} else {
return ""
}
} }
fun toXmlString(value: Map<String, String>?) = value?.entries?.joinToString(separator = "") { fun toXmlString(value: Map<String, String>?) = value?.entries?.joinToString(separator = "") {
@ -280,5 +290,6 @@ class GpxWriter {
const val XMLNS = "http://www.topografix.com/GPX/1/1" const val XMLNS = "http://www.topografix.com/GPX/1/1"
const val XMLNS_XSI = "http://www.w3.org/2001/XMLSchema-instance" 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" const val SCHEMA_LOCATION = "http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd"
val log: Logger = LoggerFactory.getLogger(GpxWriter.javaClass)
} }
} }