UNPKG

@geogirafe/lib-geoportal

Version:

GeoGirafe is a flexible application to build online geoportals.

69 lines (68 loc) 2.25 kB
function sameUrlAndImageTypeForAll(layers) { if (layers.length === 0) { return [true, true]; } const url = layers[0].ogcServer.url; const imageType = layers[0].ogcServer.imageType; let sameUrlForAll = true; let sameImageTypeForAll = true; for (const layer of layers) { sameUrlForAll = sameUrlForAll && layer.ogcServer.url === url; sameImageTypeForAll = sameImageTypeForAll && layer.ogcServer.imageType === imageType; } if (!sameUrlForAll) { throw new Error('Not all layers of this list have the same server URL.'); } if (!sameImageTypeForAll) { throw new Error('Not all layers of this list have the same image type.'); } return [sameUrlForAll, sameImageTypeForAll]; } /** Selection parameters defined by: * - 1 ogc Sever * - a list of layers * - a selection box */ export default class SelectionParam { constructor(ogcServer, layers, selectionBox, srid, _oLayer) { Object.defineProperty(this, "_ogcServer", { enumerable: true, configurable: true, writable: true, value: void 0 }); Object.defineProperty(this, "_layers", { enumerable: true, configurable: true, writable: true, value: void 0 }); Object.defineProperty(this, "_oLayer", { enumerable: true, configurable: true, writable: true, value: void 0 }); Object.defineProperty(this, "selectionBox", { enumerable: true, configurable: true, writable: true, value: void 0 }); Object.defineProperty(this, "srid", { enumerable: true, configurable: true, writable: true, value: void 0 }); this._ogcServer = ogcServer; this._layers = layers; this.selectionBox = selectionBox; this.srid = srid; this._oLayer = _oLayer; sameUrlAndImageTypeForAll(this._layers); } clone(layerFilter = () => true) { return new SelectionParam(this._ogcServer, this._layers.filter(layerFilter), this.selectionBox, this.srid, this._oLayer); } }