Open Raruto opened 1 year ago
Personally I think I'd prefer a separate method, like toGeoJSON.gpxMetadata() -> metadata object
rather than putting properties on FeatureCollection. I still think that putting properties on a FeatureCollection is technically allowed but practically dangerous: as soon as you send that GeoJSON through a transformation step like Turf.js, the extra properties will be removed. They won't be accessible via most GeoJSON editors or through map libraries.
I think it just makes more sense to have a separate process to get metadata, and if people strongly want to combine that metadata with their FeatureCollection object, they can do so with { ...featureCollection, ...metadata }
.
Based on: https://gis.stackexchange.com/a/415412
You can insert a Polygon feature without any coordinates and set your properties as you like:
{ "type": "FeatureCollection", "features": [ { "type": "Feature", "geometry": { "type": "Polygon", "coordinates": [ ] }, "properties": { "description": "This is the geometry for..." } }, { // Other features } ] }
Maybe something like this would be even more easier to store and therefore portable (also when it comes to snapshot testing):
{
"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
}
]
}
Not really sure if these property names make sense:
"_gpxType": "metadata"
--> similarly to what was already done to distinguish <rte>
and <trk>
tags"extensions": ??
--> probably a more complex structure (right now, I don't remember what's the current gpx extensions specfication..)but that's just to give you a quick idea.
👋 Raruto
A vote in favor of the gpxMetadata()
route (instead of using a foreign member). Attached is a sample file with a custom namespace in the metadata extensions for testing.
<gpx version="1.1" creator="deepzoom"
xmlns="http://www.topografix.com/GPX/1/1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd"
xmlns:gpxx="http://www.garmin.com/xmlschemas/GpxExtensions/v3"
xmlns:opencpn="http://www.opencpn.org"
xmlns:deepzoom="http://www.deepzoom.com">
<metadata>
<name>A DeepZoom Trip</name>
<time>2024-11-24T07:59:30Z</time>
<extensions>
<deepzoom:trip>A DeepZoom Trip Alt</deepzoom:trip>
</extensions>
</metadata>
<rte>
<name>Route 1</name>
...
Hi Tom,
over years I come back to ask myself this question: Is it valid to have a properties element in an geoJSON featureCollection?
So first of all here's just a friendly reminder:
• RFC 7946 - Extending GeoJSON
• GPX 1.1 Schema Documentation - metadataType
Motivation
Mainly, make it easier to access the root gpx file
<name>
.Right now, others can achieve this more or less by doing like so:
Draft implementation
Essentially, augmenting the
FeatureCollection
interface by providing a new property:metadata
• lib/gpx.ts#L181-L197
•
lib/gpx/metadata.ts
Almost the same as: lib/gpx/properties.ts#L1-L36
NB some functions parameters types invoked in here must be double-checked (ref: Element and Document interfaces)
lib/index.d.ts
I'm not very knowledgeable about typescript, anyway I think it could result in something like this:
I'm really sorry, but at the moment I can't say how much additional re-work might be needed to integrate it in the generation of current
dist/index.d.ts
file.Hoping that somehow these notes can be useful
👋 Raruto