2.1.0 • Published 6 months ago

query-fis-broker-wfs v2.1.0

Weekly downloads
5
License
ISC
Repository
github
Last release
6 months ago

query-fis-broker-wfs

Query WFS sources in the Berlin geodata portal FIS-Broker.

npm version ISC-licensed minimum Node.js version support me via GitHub Sponsors chat with me on Twitter

Installing

npm install query-fis-broker-wfs

Usage

import {getFeatures} from 'query-fis-broker-wfs/get-features.js'

const endpoint = 'https://fbinter.stadt-berlin.de/fb/wfs/data/senstadt/s_plz'
const layer = 'fis:s_plz'
// senstadt/s_plz uses the ETRS89 (EPSG:25833) coordinate reference system (CRS).
// see also https://epsg.io/25833 & http://www.opengis.net/def/crs/EPSG/0/25833
const bbox = [387000, 5812000, 386000, 5813000]

const features = getFeatures(endpoint, layer, {bbox}
for await (const feature of features) {
	console.log(feature)
}

Note: You can obtain the WFS layer's native coordinate reference system (CRS) from the layers[…].crs field of a getCapabilities() response.

The call above will return data in the xml-reader shape:

{
	name: 'fis:s_plz',
	type: 'element',
	value: '',
	parent: {
		name: 'wfs:member',
		type: 'element',
		value: '',
		parent: { /* … */ },
		attributes: {},
		children: [ /* … */ ]
	},
	attributes: {
		'gml:id': 's_plz.12165'
	},
	children: [{
		name: 'fis:plz',
		type: 'element',
		value: '',
		parent: [ /* … */ ],
		attributes: {},
		children: [{
			name: '',
			type: 'text',
			value: '12165',
			parent: [ /* … */ ],
			attributes: {},
			children: [],
		}]
	}, {
		name: 'fis:finhalt',
		type: 'element',
		value: '',
		parent: [ /* … */ ],
		attributes: {},
		children: [{
			name: '',
			type: 'text',
			value: '945018.6987053645',
			parent: [ /* … */ ],
			attributes: {},
			children: [],
		}]
	}, {
		name: 'fis:geom',
		type: 'element',
		value: '',
		parent: [ /* … */ ],
		attributes: {},
		children: [{
			name: 'gml:Polygon',
			type: 'element',
			value: '',
			parent: [ /* … */ ],
			attributes: { 'gml:id': 'P1' },
			children: [ /* … */ ],
		}]
	}]
}

You can use parse-gml-polygon to convert the gml:* elements (gml:Polygon etc.) within fis:geom to GeoJSON; example.js demonstrates how to do this.

API

getCapabilities(endpoint) -> Promise

Uses the GetCapabilities method, returns data that looks like this:

{
	operations: [ {
		name: 'GetCapabilities',
		params: [ {
			name: 'AcceptVersions',
			defaultValue: '2.0.0',
			allowedValues: ['1.0.0', '1.1.0', '2.0.0']
		}, {
			name: 'AcceptFormats',
			defaultValue: 'text/xml',
			allowedValues: ['text/xml']
		} ]
	}, {
		name: 'GetFeature',
		params: [ {
			name: 'resultType',
			defaultValue: null,
			allowedValues: ['results', 'hits']
		}, {
			name: 'outputFormat',
			defaultValue: 'application/gml+xml; version=3.2',
			allowedValues: [
				'text/xml; subtype=gml/2.1.2',
				'text/xml; subtype=gml/3.1.1',
				'text/xml; subtype=gml/3.2.1'
				// …
			]
		} ]
	} ],
	defaultVersion: '2.0.0',
	allowedVersions: ['1.0.0', '1.1.0', '2.0.0'],
	featureTypes: [ {
		name: 'fis:s_plz',
		title: 'Postleitzahlen',
		description: 'PLZ - Postleitzahlgebiete Berlins',
		crs: 'urn:ogc:def:crs:EPSG:6.9:25833',
		outputFormats: [
			'text/xml; subtype=gml/2.1.2',
			'text/xml; subtype=gml/3.1.1',
			'text/xml; subtype=gml/3.2.1'
			// …
		],
		bbox: {
			minLat: 52.3284,
			minLon: 13.079,
			maxLat: 52.6877,
			maxLon: 13.7701
		}
	} ],
	spatialCapabilities: [
		'BBOX',
		'Equals',
		'Disjoint'
		// …
	]
}

getFeatures(endpoint, layer, [opt]) -> Readable stream

Uses the GetFeature method.

You may optionally pass the options bbox, crs, results, sortBy, props.

Related

Contributing

If you have a question or have difficulties using query-fis-broker-wfs, please double-check your code and setup first. If you think you have found a bug or want to propose a feature, refer to the issues page.