placemark/togeojson

feature request: add support for styles

hansemannn opened this issue · 4 comments

Hey there,

happy to see this project is still maintained - thank you for that!

One question I'd like to raise is if there are plans to map the .gpx styles to the .geojson format as well. The so-called "Geojson CSS" markup is used for that and could be applied from the gpxx:DisplayColor GPX attribute. I could contribute that change if the general idea is approved by you.

Thanks!

EDIT: It seems like basic styles are already supported here but it seems limited to certain styles. The latest Garmin routes have a format as following:

  <rte>
    <name>27.05.2020 Tour 5_357 km_zyanblau</name>
    <extensions>
      <gpxx:RouteExtension>
        <gpxx:IsAutoNamed>false</gpxx:IsAutoNamed>
        <gpxx:DisplayColor>Cyan</gpxx:DisplayColor>
      </gpxx:RouteExtension>
      <trp:Trip>
        <trp:TransportationMode>Motorcycling</trp:TransportationMode>
      </trp:Trip>
    </extensions>
    ...
  </rte>
tmcw commented

Hey Hans!

Sure thing, adding support for these Garmin extensions sounds like a good idea. I'd prefer not to implement GeoJSON CSS, though. I haven't seen any implementations of that in the wild, and the spec itself has some rather bad design decisions - for example, putting className on the Feature object rather than nesting it under properties. That kind of thing will just make compatibility with strict GeoJSON parsers and converters harder.

Instead, something like gpxx-isautonamed under the properties object seems fine to me, a more verbatim translation of what the GPX attribute is saying.

Interesting thought. Maybe even map them all automatically, e.g.:

{
  "properties": {
    "...": "...",
    "gpxx-isautonamed": false,
    "gpxx-displaycolor": "Cyan"
  }
}

By simply detecting the prefix and mapping the nodes to JSON keys. Or should we rather constraint it? Thanks for your feedback!

tmcw commented

Yep, I think automatically mapping values under RouteExtension would work!

tmcw commented

Fixed in #20!