Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
removeOGCDataSource_(dataSource) {
if (dataSource.ogcType === Type.WMS) {
// WMS data source
if (!dataSource.wmsUrl) {
throw new Error('Missing dataSource.wmsUrl');
}
const wmsGroup = this.getWMSGroup(dataSource.wmsUrl);
if (wmsGroup && wmsGroup.dataSources.includes(dataSource)) {
// Remove from group
wmsGroup.removeDataSource(dataSource);
// In case we removed the last data source from the group, then remove
// and destroy the group, and remove the layer from the map as well.
if (!wmsGroup.dataSources.length) {
this.removeLayer_(wmsGroup.layer);
wmsGroup.destroy();
this.removeWMSGroup_(wmsGroup);
connect() {
const url = this.url;
const serviceType = guessServiceTypeByUrl(url);
this.startWorking_();
if (serviceType === Type.WMS) {
this.ngeoQuerent_.wmsGetCapabilities(url).then(
(wmsCapabilities) => {
this.wmsCapabilities = wmsCapabilities;
this.stopWorking_();
},
() => {
// Something went wrong...
this.stopWorking_(true);
}
);
} else if (serviceType === Type.WMTS) {
this.ngeoQuerent_.wmtsGetCapabilities(url).then(
(wmtsCapabilities) => {
this.wmtsCapabilities = wmtsCapabilities;
this.stopWorking_();
},
// queryable
const queryable = layer.queryable === true &&
wmsInfoFormat !== undefined;
// TODO - MaxScaleDenominator
// TODO - MinScaleDenominator
/** @type {import('ngeo/datasource/OGC').OGCOptions} */
const options = {
id: id,
name: layer.Title,
ogcImageType: ogcImageType,
wmsLayers: [{
name: layer.Name,
queryable: queryable
}],
ogcType: Type.WMS,
visible: true,
wmsUrl: url
};
if (wmsInfoFormat) {
options.wmsInfoFormat = wmsInfoFormat;
}
dataSource = new ngeoDatasourceOGC(options);
// Keep a reference to the external data source in the cache
this.extDataSources_[id] = dataSource;
}
// (2) Add data source in WMS group, unless it's already in there.
// Will also add the data source to the `import('ngeo/datasource/DataSource.js').DataSources`
// collection.
connect() {
if (!this.url) {
throw new Error('Missing url');
}
const url = this.url;
const serviceType = guessServiceTypeByUrl(url);
this.isLoading = true;
this.startWorking_();
if (serviceType === Type.WMS) {
this.ngeoQuerent_.wmsGetCapabilities(url).then(
(wmsCapabilities) => {
this.wmsCapabilities = wmsCapabilities;
this.isLoading = false;
this.stopWorking_();
this.search();
},
() => {
this.isLoading = false;
// Something went wrong...
this.stopWorking_(true);
}
);
} else if (serviceType === Type.WMTS) {
this.ngeoQuerent_.wmtsGetCapabilities(url).then(
(wmtsCapabilities) => {