@gb-maps/core
v0.1.5
Published
core package for gb-maps
Downloads
1
Readme
@gb-maps/core
Parsing library for KML and OSM.
Getting Started
npm install @gb-maps/core
import { convert } from '@gb-maps/core';
// some sample keyhole markup data
const kml = `<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<Folder>
<name>Folder 1</name>
<Placemark>
<name>Place 1</name>
<Point>
<coordinates>-90.86,48.25,0</coordinates>
</Point>
</Placemark>
<Placemark>
<name>Place 2</name>
<Point>
<coordinates>-90.96,48.15,0</coordinates>
</Point>
</Placemark>
</Folder>
</Document>
</kml>`;
// some sample open street maps data
const osm = `<?xml version='1.0' encoding='UTF-8'?>
<osm version='0.6'>
<node id='300000001' visible='true' lat='34.07222' lon='-118.73425' />
<node id='300000002' visible='true' lat='34.07234' lon='-118.73222' />
<node id='300000003' visible='true' lat='34.06709' lon='-118.73467' />
<node id='300000004' visible='true' lat='34.07245' lon='-118.73425' />
<node id='300000005' visible='true' lat='34.06711' lon='-118.73647' />
<node id='300000006' visible='true' lat='34.07222' lon='-118.73232' />
<way id='way1'>
<nd ref='300000003' />
<nd ref='300000001' />
<nd ref='300000005' />
<tag k='name' v='Memorial Park' />
</way>
</osm>`;
const doc = convert(osm)[0];
for (const path of doc.paths.values()) {
for (const point of path.points.values()) {
console.log(point);
}
for (const [k, v] of path.tags) {
console.log(k, v);
}
}