@geogirafe/lib-geoportal
Version:
GeoGirafe is a flexible application to build online geoportals.
32 lines (31 loc) • 1.32 kB
JavaScript
import OgcApiFeaturesClient from './ogcapifeaturesclient';
import { DEMO_LAYERS } from './demolayers';
export default class OgcApiFeaturesClientGeorama extends OgcApiFeaturesClient {
constructor(serverConfig) {
super(serverConfig);
}
/**
* POC overwrite: Upper/lowercase issues with collection property `storageCrs`: pygeoapi uses `storageCRS`.
*/
async getCollection(collectionId) {
const collection = await super.getCollection(collectionId);
if (Object.keys(collection).includes('storageCRS')) {
// @ts-expect-error Wrong property name form server
collection.storageCrs = collection.storageCRS;
}
return collection;
}
/**
Overwrite base method fetch options because the Georama demo server currently only supports basic auth.
*/
getFetchOptions(method = 'GET', crsIdentifier) {
const fetchOptions = super.getFetchOptions(method, crsIdentifier);
const headers = new Headers(fetchOptions?.headers);
// POC: Only basic auth for now
headers.set('Authorization', `Basic ${window.btoa(DEMO_LAYERS.GEORAMA.credentials)}`);
fetchOptions.credentials = 'include';
fetchOptions.mode = 'cors';
fetchOptions.headers = headers;
return fetchOptions;
}
}