-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
31 lines (23 loc) · 870 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import {getFeatures} from 'query-fis-broker-wfs/get-features.js'
import {createParseStructure} from './lib/parse-structure.js'
const endpoint = 'https://fbinter.stadt-berlin.de/fb/wfs/data/senstadt/s_wfs_alkis_gebaeudeflaechen'
const isObj = (v) => 'object' === typeof v && !Array.isArray(v)
const getItems = async function* (layer, bbox, opt = {}) {
if ('string' !== typeof layer) throw new Error('layer must be a string')
if (!Array.isArray(bbox)) throw new Error('bbox must be an array')
if (('fields' in opt) && !isObj(opt.fields)) {
throw new Error('opt.fields must be an object')
}
const parse = createParseStructure(opt.fields)
const features = getFeatures(endpoint, layer, {
bbox,
crs: 'urn:ogc:def:crs:EPSG:6.9:25833'
})
for await (const feature of features) {
yield parse(feature)
}
}
// todo: getItem, bbox, etc
export {
getItems,
}