UNPKG

@geogirafe/lib-geoportal

Version:

GeoGirafe is a flexible application to build online geoportals.

31 lines (30 loc) 1.21 kB
// SPDX-License-Identifier: Apache-2.0 import OgcApiFeaturesClient from './ogcapifeaturesclient.js'; export default class OgcApiFeaturesClientGmf extends OgcApiFeaturesClient { constructor(serverConfig, opt, context) { super(serverConfig, opt, context); } /** * POC overwrite: The demo server does not support schema requests. We therefore create a very simple schema based on * the first item of the collection. */ async getSchema(collectionId) { const items = await this.getItems(collectionId, undefined, undefined, 1); const item = items[0]; const properties = Object.fromEntries(Object.entries(item.getProperties()).map(([key, value]) => [key, { type: typeof value }])); // Add geometry information properties['geometry'] = { 'format': `geometry-${item.getGeometry().getType().toLowerCase()}`, 'x-ogc-role': 'primary-geometry' }; // mark fid or id as primary key ['fid', 'id'].forEach((key) => { if (properties[key]) { properties[key]['x-ogc-role'] = 'id'; } }); return { properties: properties }; } }