placemark / togeojson

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

Gpx metadata type #123

Open Raruto opened 11 months ago

Raruto commented 11 months ago

Hi Tom,

here's a draft based on: https://github.com/placemark/togeojson/issues/111#issuecomment-1577380801, that is, add a dedicated "empty" feature identified by the "_gpxType": "metadata" property:

{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "geometry": {
        "type": "Polygon",
        "coordinates": [ ]     // eventually populated by https://www.topografix.com/GPX/1/1/#type_boundsType
      },
      "properties": {
        "_gpxType": "metadata" // everything else related to https://www.topografix.com/GPX/1/1/#type_metadataType
        "name": "...",
        "desc": "...",
        "author": {
            "name": "...",
            "email": "",
            "link": {
               "href": "...",
               "text": "...",
               "type": "...",
            }
        },
        "copyright": {
          "author": "...",
          "year": "...",
          "license": "..."
        },
        "time": "...",
        "keywords": "...",
        "extensions": ??
    },
    {
      // Other features
    }
  ]
}

Let me know, so I'll eventually update the tests accordingly.

👋 Raruto

tmcw commented 11 months ago

Thanks! I'd really much rather expose a method like getGpxData rather than having a feature with magical meaning, would that be possible?

Raruto commented 11 months ago

expose a method like getGpxData rather than having a feature with magical meaning

I was trying to keep it simple (and quickly testable)

From my point of view rte features are quite similar:

https://github.com/placemark/togeojson/blob/71b38c6ffaf016b2040225004b3a7ab122d2ed2a/lib/__snapshots__/index.test.ts.snap#L12808-L12812

Also regarding data portability I'd rather prefer find a fairly common way of handling this.

It's already quite easy to build an out-of-spec geojson (or at least without relying on other external libraries).

If implemented here (as a static information) you'd at least be pretty sure that it's a quite valid thing

Anyway, i think the final decision is up to you..

👋 Raruto