@gb-maps/parsers
TypeScript icon, indicating that this package has built-in type declarations

0.1.5 • Public • Published

@gb-maps/parsers

npm

Parsing library for KML and OSM.

Getting Started

npm install @gb-maps/parsers

import { convertKml, convertOsm } from '@gb-maps/parsers';

// some sample keyhold 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' />
</osm>`;
const kmlDoc = convertKml(kml);
const osmDoc = convertOsm(osm);
kmlDoc.Document.Folder.forEach((folder) => {
  console.log(folder.name);
  folder.Placemark?.forEach((place) => {
    console.log(place.name, place.Point);
  });
});

osmDoc.node.forEach((n, i) => console.log(i, n.aid));

You should probably be using the core library.

Readme

Keywords

Package Sidebar

Install

npm i @gb-maps/parsers

Weekly Downloads

1

Version

0.1.5

License

MIT

Unpacked Size

10.1 kB

Total Files

21

Last publish

Collaborators

  • garyb432