placemark / togeojson

convert KML, TCX, and GPX to GeoJSON, without the fuss
https://placemark.github.io/togeojson/
BSD 2-Clause "Simplified" License
401 stars 67 forks source link

Fix tests: `zero_elevation.gpx` and `extractStyle` #110

Closed Raruto closed 1 year ago

Raruto commented 1 year ago

Fixes a regression introduced within v4.8.0 refactoring.

Related to https://github.com/Raruto/leaflet-elevation/issues/259

Troublesome example

// <ele>0</ele> values shouldn't be interpreted as an empty ("false" or "undefined") value.

toGeoJSON.gpx(new DOMParser().parseFromString(
`<?xml version="1.0" encoding="UTF-8"?>
<gpx version="1.0" xmlns="http://www.topografix.com/GPX/1/0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <trk>
    <trkseg>
      <trkpt lat="45.763340000" lon="12.843770000">
        <ele>-1.000</ele>
      </trkpt>
      <trkpt lat="45.763240000" lon="12.847620000">
        <ele>0</ele>
      </trkpt>
    </trkseg>
  </trk>
</gpx>`, "text/xml"))

@tmcw/togeojson (v6.5.0)

{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "properties": {
        "_gpxType": "trk",
        "coordinateProperties": {}
      },
      "geometry": {
        "type": "LineString",
        "coordinates": [
          [
            12.84377,
            45.76334,
            -1
          ],
          [
            12.84762,
            45.76324
          ]
        ]
      }
    }
  ]
}

@tmcw/togeojson (v4.6.0)

{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "properties": {
        "_gpxType": "trk"
      },
      "geometry": {
        "type": "LineString",
        "coordinates": [
          [
            12.84377,
            45.76334,
            -1
          ],
          [
            12.84762,
            45.76324,
            0
          ]
        ]
      }
    }
  ]
}

👋 Raruto