Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/w8r/wms-capabilities

WMS GetCapabilities to JSON
https://github.com/w8r/wms-capabilities

gis javascript json parser wms xml

Last synced: 6 days ago
JSON representation

WMS GetCapabilities to JSON

Awesome Lists containing this project

README

        

# WMS `GetCapabilities` parser
[![npm version](https://badge.fury.io/js/wms-capabilities.svg)](http://badge.fury.io/js/wms-capabilities)

Parses [WMS](http://en.wikipedia.org/wiki/Web_Map_Service) capabilities XML format to JSON. This is a simplified excerpt from [OpenLayers](https://github.com/openlayers/ol3) code to be used separately from its large codebase.

## [Demo](https://w8r.github.io/wms-capabilities)

## Usage

### ES
```
npm install wms-capabilities --save
```
```js
import WMSCapabilities from 'wms-capabilities';
...
new WMSCapabilities().parse(xmlString);
//or
new WMSCapabilities(xmlString).toJSON();
// or
new WMSCapabilities().readFromDocument(xmldoc);
```
### Browser
```html

...
new WMSCapabilities().parse(xmlString);
```

### Node

Requires `xmldom` to traverse XML
```sh
$npm install --save xmldom
```
then
```js
import xmldom from 'xmldom'; // 'xmldom' doesn't 'export' the DOMParser
import WMSCapabilities from 'wms-capabilities';
...
new WMSCapabilities(xmlString, xmldom.DOMParser).toJSON();
```

### Command-line

```sh
$ npm install -g wms-capabilities
$ cat capabilities.xml | wmscapabilities > out.json
$ # or
$ wmscapabilities capabilities.json > out.json
```