Options
All
  • Public
  • Public/Protected
  • All
Menu

@tmcw/togeojson

Index

Type Aliases

F: Feature<Geometry | null>

Functions

  • gpx(node: Document): FeatureCollection
  • 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.

    Parameters

    • node: Document

    Returns FeatureCollection

  • gpxGen(node: Document): Generator<Feature>
  • Convert GPX to GeoJSON incrementally, returning a Generator that yields output feature by feature.

    Parameters

    • node: Document

    Returns Generator<Feature>

  • kml(node: Document, options?: KMLOptions): FeatureCollection<Geometry | null>
  • Convert a KML document to GeoJSON. The first argument, doc, must be a KML 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. You can convert it to a string with JSON.stringify or use it directly in libraries.

    Parameters

    Returns FeatureCollection<Geometry | null>

  • kmlGen(node: Document, options?: KMLOptions): Generator<F>
  • Convert KML to GeoJSON incrementally, returning a Generator that yields output feature by feature.

    Parameters

    Returns Generator<F>

  • Yield a nested tree with KML folder structure

    This generates a tree with the given structure:

    {
    "type": "root",
    "children": [
    {
    "type": "folder",
    "meta": {
    "name": "Test"
    },
    "children": [
    // ...features and folders
    ]
    }
    // ...features
    ]
    }

    GroundOverlay

    GroundOverlay elements are converted into Feature objects with Polygon geometries, a property like:

    {
    "@geometry-type": "groundoverlay"
    }

    And the ground overlay's image URL in the href property. Ground overlays will need to be displayed with a separate method to other features, depending on which map framework you're using.

    Parameters

    Returns Root

  • tcx(node: Document): FeatureCollection
  • Convert a TCX document to GeoJSON. The first argument, doc, must be a TCX document as an XML DOM - not as a string.

    Parameters

    • node: Document

    Returns FeatureCollection

  • tcxGen(node: Document): Generator<Feature>
  • Incrementally convert a TCX document to GeoJSON. The first argument, doc, must be a TCX document as an XML DOM - not as a string.

    Parameters

    • node: Document

    Returns Generator<Feature>

Generated using TypeDoc