Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/w8r/wms-capabilities
- Owner: w8r
- License: other
- Created: 2015-01-20T09:03:58.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2024-03-16T02:53:08.000Z (11 months ago)
- Last Synced: 2025-01-16T22:10:06.312Z (14 days ago)
- Topics: gis, javascript, json, parser, wms, xml
- Language: CSS
- Homepage: https://w8r.github.io/wms-capabilities
- Size: 1.78 MB
- Stars: 53
- Watchers: 7
- Forks: 9
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
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
```