@geogirafe/lib-geoportal
Version:
GeoGirafe is a flexible application to build online geoportals.
33 lines (32 loc) • 1.32 kB
JavaScript
import OgcApiFeaturesClient from './ogcapifeaturesclient';
export default class OgcApiFeaturesClientGmf extends OgcApiFeaturesClient {
constructor(serverConfig) {
super(serverConfig);
}
/**
* 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())
.filter(([key, _value]) => ['fid', 'name', 'type'].includes(key))
.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 as primary key
properties['fid']['x-ogc-role'] = 'id';
return {
properties: properties
};
}
getFetchOptions(method = 'GET', crsIdentifier) {
const fetchOptions = super.getFetchOptions(method, crsIdentifier);
fetchOptions.mode = 'cors';
return fetchOptions;
}
}