Giter Club home page Giter Club logo

Comments (2)

tmcw avatar tmcw commented on June 26, 2024

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 }.

from togeojson.

Raruto avatar Raruto commented on June 26, 2024

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.

Related info:

  • exports[`toGeoJSON > ground_overlay.kml 1`] = `
    {
    "features": [
    {
    "geometry": {
    "coordinates": [
    [
    [
    14.600668902543442,
    37.91801270483731,
    ],
    [
    15.35770894852841,
    37.92006947469352,
    ],
    [
    15.358941332345658,
    37.466463107960706,
    ],
    [
    14.60190128636069,
    37.464406338104496,
    ],
    [
    14.600668902543442,
    37.91801270483731,
    ],
    ],
    ],
    "type": "Polygon",
    },
    "properties": {
    "@geometry-type": "groundoverlay",
    "description": "Overlay shows Mount Etna erupting
    on July 13th, 2001.",
    "icon": "https://developers.google.com/kml/documentation/images/etna.jpg",
    "name": "Large-scale overlay on terrain",
    },
    "type": "Feature",
    },
    ],
    "type": "FeatureCollection",
    }
    `;
  • togeojson/lib/gpx.ts

    Lines 181 to 191 in d395dde

    /**
    *
    * Convert a GPX document to GeoJSON. The first argument, `doc`, must be a GPX
    * document as an XML DOM - not as a string. You can get this using jQuery's default
    * `.ajax` function or using a bare XMLHttpRequest with the `.response` property
    * holding an XML DOM.
    *
    * The output is a JavaScript object of GeoJSON data, same as `.kml` outputs, with the
    * addition of a `_gpxType` property on each `LineString` feature that indicates whether
    * the feature was encoded as a route (`rte`) or track (`trk`) in the GPX document.
    */

👋 Raruto

from togeojson.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.