kml-parse
v0.0.2
Published
This lib is modified from @mapbox/togeojson, enhanced with folder parse capability
Downloads
161
Readme
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)