Giter VIP home page Giter VIP logo

query-fis-broker-wfs's Introduction

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.

query-fis-broker-wfs's People

Contributors

derhuerst avatar greenkeeper[bot] avatar snyk-bot avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

query-fis-broker-wfs's Issues

Clarify `bbox` param

It would be great if the docs helped to understand the bbox param (const bbox = [387000, 5812000, 386000, 5813000]).

My first error was to give it a "regular" bbox like [ [13.088398, 52.33832], [13.76116, 52.33832], [13.76116, 52.675454], [13.088398, 52.675454], [13.088398, 52.33832], ] which resulted in a empty error message.

56 | 		const err = new Error(res.statusText)
57 | 		err.statusCode = res.status
         ^
error: Error
 url: "https://gdi.berlin.de/services/wfs/fussgaengernetz?service=WFS&version=2.0.0&request=GetFeature&typeNames=fussgaengernetz%3Ab_strassenelemente&bbox=13.088398%2C52.33832%2C13.76116%2C52.33832%2C13.76116%2C52.675454%2C13.088398%2C52.675454%2C13.088398%2C52.33832"

      at /Users/…/datenabgleich/node_modules/query-fis-broker-wfs/lib/request.js:57:6

The generated URL was talking about " No authority was defined for code … AUTHORITY:NUMBER"


My suggested change is: Update the readme to explain the format of the bbox and how to get it. For example, how can I use something like https://hanshack.com/geotools/gimmegeodata/ to get the right format? Or, how can I just say "give me the min/max bounds for this service".

`TypeError: undefined is not an object (evaluating 'state.buffer[0].length')`

I was trying to run the package with bun.sh and got this error. When I remove the fetch overwrite import _createFetch from 'fetch-ponyfill' const {fetch} = _createFetch() the error disappears but a new error shows up related to the XML package.

The code I ran is at osmberlin/datenabgleich@6255462

% bun run data/Fußgängernetz/pull.ts
11 |     // Since node 6.3.0 state.buffer is a BufferList not an array
12 |     if (state.buffer.head) {
13 |       return state.buffer.head.data.length
14 |     }
15 |
16 |     return state.buffer[0].length
               ^
TypeError: undefined is not an object (evaluating 'state.buffer[0].length')
      at getStateLength (/Users/fmc/Development/OSM/datenabgleich/node_modules/stream-shift/index.js:16:11)
      at shift (/Users/fmc/Development/OSM/datenabgleich/node_modules/stream-shift/index.js:6:98)
      at /Users/fmc/Development/OSM/datenabgleich/node_modules/duplexify/index.js:168:34
      at onreadable (/Users/fmc/Development/OSM/datenabgleich/node_modules/duplexify/index.js:134:4)
      at processTicksAndRejections (:55:76)


Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.