0.0.1 • Published 1 year ago
@bioroxx/kmljs v0.0.1
kml.js
An Open Geospatial Consortium KML 2.2.0 reference implementation (Link)
NOTE: This library is currently under development and not thoroughly testet!
Installation
npm install @bioroxx/kmljs
Usage
Parsing
import {KMLParser} from '@bioroxx/kmljs';
import {readFileSync} from 'fs';
const kmlFileString = readFileSync('./my-kml-file.kml', 'utf-8');
const kmlParser = new KMLParser();
const kml = kmlParser.parse(kmlFileString);
Parsing with custom KMLFactory
Because kmljs is built with customization in mind, you can pass your own KMLFactory implementation
to the KMLParser
as a constructor argument. This especially makes sense, if you want the
KMLParser
to create your own KML objects.
import {KMLFactory, PlacemarkType, Placemark, KMLParser} from '@bioroxx/kmljs';
import {readFileSync} from 'fs';
class MyPlacemark extends Placemark {
constructor(placemarkType: PlacemarkType) {
super(placemarkType);
}
render(): void {
// Your rendering code...
}
}
class CustomKMLFactory extends KMLFactory {
override createPlacemark(placemarkType: PlacemarkType): PlacemarkType {
return new MyPlacemark(placemarkType);
}
}
const kmlFileString = readFileSync('./my-kml-file.kml', 'utf-8');
const customKMLFactory = new CustomKMLFactory();
const kmlParser = new KMLParser(customKMLFactory);
const kml = kmlParser.parse(kmlFileString);
Roadmap
- Parsing
kml
,atom
namespace elementsxal
namespace elements
- Parsing tests
- Serialization
- Serialization tests
0.0.1
1 year ago