Elevation serialization for values > 1000m is incompatible with deserialization
raynigon opened this issue · 0 comments
raynigon commented
Issue description
I currently use the library to serialize and deserialize GPX for analysis.
Some files contain elevation values greater than 1000m.
For these files the elevation is serialized with a comma as "thousand separator".
When the serialized GPX data is deserialized, Double.parseDouble
is used,
which does not support the given Syntax.
Steps to reproduce the issue
- Generate a GPX object with at least one waypoint which has an elevation greater 1000m
- Serialze the object with the
GPX.Writer#write
method - Deserialize the object with the
GPX.Reader#read
method
What's the expected result?
- No exception is thrown
- The deserialized object contains exactly the same data
What's the actual result?
- A
java.io.InvalidObjectException
Exception is thrown
Additional details
Code
GPX gpx = GPX.builder()
.addWayPoint { wp ->
wp.ele(1234.5).build(1.2, 3.4)
}
.build()
String gpxString = GPX.Writer.DEFAULT.toString(gpx)
GPX result = GPX.Reader.DEFAULT.fromString(gpxString)
Stacktrace
java.io.InvalidObjectException: Invalid GPX: Invalid value for 'ele': For input string: "1,234.5"
at io.jenetics.jpx.GPX$Reader.read(GPX.java:1183)
at io.jenetics.jpx.GPX$Reader.read(GPX.java:1209)
at io.jenetics.jpx.GPX$Reader.fromString(GPX.java:1271)