kml-parse

0.0.2 • Public • Published

Introduction

This lib is modified from @mapbox/togeojson, enhanced with folder parse capability

Install

npm i --save kml-parse

Usage

const kmlParse = require('kml-parse')
const fs = require('fs-extra')
const DOMParser = require('xmldom').DOMParser
const kmlDom = new DOMParser().parseFromString(fs.readFileSync('demo.kml', 'utf8'))
 
/**
 * returns folder tree and feature collection
 * return { folder: [], geoJSON: [] }
 */
kmlParse.parse(kmlDom)
 
/**
 * returns feature collection
 * This function is ported from @mapbox/togeojson, `tj.kml(kmlDom)`
 * 
 * feature.properties.folder = <folderKey>
 */
kmlParse.parseGeoJSON(kmlDom)
 
/**
 * returns folder tree
 * folder: [{ key: <folderKey>, parent: <parentFolderKey>, name: <folderName>, children: [] }]
 */
kmlParse.parseFolder(kmlDom)

Dependencies (0)

    Dev Dependencies (7)

    Package Sidebar

    Install

    npm i kml-parse

    Weekly Downloads

    21

    Version

    0.0.2

    License

    MIT

    Unpacked Size

    50.1 kB

    Total Files

    7

    Last publish

    Collaborators

    • ygjack