jenetics / jpx

JPX - Java GPX library
Apache License 2.0
202 stars 30 forks source link

Double's being written as exponents in GPX file #151

Closed MCMaestro closed 2 years ago

MCMaestro commented 2 years ago

When a GPX file is created, because of Lat and Long values being stored as doubles, they are sometimes written as exponents EG -3.1E-4 instead of -0.00031 Not sure if there's a simple solution to this?

jenetics commented 2 years ago

The data type of the latitude and longitude value is xsd:decimal.

<xsd:simpleType name="latitudeType">
    <xsd:restriction base="xsd:decimal">
    <xsd:minInclusive value="-90.0"/>
    <xsd:maxInclusive value="90.0"/>
    </xsd:restriction>
</xsd:simpleType>

The library uses the Double::toString method for converting a double value to a string, which might produce an exponential representation of the double value. So in this sense, this is a bug, which should be fixed.

Can you attach an example file with this error? And which application has problems reading these values?

MCMaestro commented 2 years ago

test42.gpx.txt

GPX file attached (added .txt for GitHub to accept).

Only applications I've tried it with are Basecamp and Viewranger - both fail to parse the file, and don't import anything. I've manually altered the gpx to correct the exponent to a number, and then they are happy and parse the file.

jenetics commented 2 years ago

Merged into r3.0.0 branch.