import { Injectable } from '@angular/core' ; import { Layer } from 'ol/layer' ; import { Source } from 'ol/source' ; import { AddDataUrlType } from './types/url.type' ; import { HsAddDataCommonService } from '../common/common.service' ; import { HsAddDataUrlService } from './add-data-url.service' ; import { HsArcgisGetCapabilitiesService } from '../../../common/get-capabilities/arcgis-get-capabilities.service' ; import { HsHistoryListService } from '../../../common/history-list/history-list.service' ; import { HsUrlArcGisService } from './arcgis/arcgis.service' ; import { HsUrlTypeServiceModel } from './models/url-type-service.model' ; import { HsUrlWfsService } from './wfs/wfs.service' ; import { HsUrlWmsService } from './wms/wms.service' ; import { HsUrlWmtsService } from './wmts/wmts-service' ; import { HsWfsGetCapabilitiesService } from '../../../common/get-capabilities/wfs-get-capabilities.service' ; import { HsWmsGetCapabilitiesService } from '../../../common/get-capabilities/wms-get-capabilities.service' ; import { HsWmtsGetCapabilitiesService } from '../../../common/get-capabilities/wmts-get-capabilities.service' ; import { IGetCapabilities } from '../../../common/get-capabilities/get-capabilities.interface' ; import { owsConnection } from './types/ows-connection.type' ; import { urlDataObject } from './types/data-object.type' ; @ Injectable ( { providedIn : 'root' , } ) export class HsAddDataOwsService { typeService : HsUrlTypeServiceModel ; typeCapabilitiesService : IGetCapabilities ; constructor ( public hsAddDataCommonService , public hsAddDataUrlService , public hsHistoryListService , public hsArcgisGetCapabilitiesService , public hsUrlArcGisService , public hsUrlWfsService , public hsWfsGetCapabilitiesService , public hsUrlWmsService , public hsWmsGetCapabilitiesService , public hsWmtsGetCapabilitiesService , public hsUrlWmtsService ) { } async connect ( style ? ) { await this . setTypeServices ( ) ; const url = this . hsAddDataCommonService . url ; if ( ! url || url === '' ) { return ; } if ( this . hsAddDataUrlService . typeSelected === 'arcgis' ) { this . typeService . data . get_map_url = url ; } this . hsAddDataUrlService . hasAnyChecked = false ; this . hsHistoryListService . addSourceHistory ( this . hsAddDataUrlService . typeSelected , url ) ; Object . assign ( this . hsAddDataCommonService , { loadingInfo : true , showDetails : true , } ) ; const wrapper = await this . typeCapabilitiesService . request ( url ) ; return await this . typeService . addLayerFromCapabilities ( wrapper , style ) ; } param url param layer async setUrlAndConnect ( params ) { this . hsAddDataCommonService . layerToSelect = params . layer ; this . hsAddDataCommonService . updateUrl ( params . uri ) ; return await this . connect ( params . style ) ; } changed ( data ) { this . hsAddDataUrlService . searchForChecked ( data . services ) ; } /**
     * replaces `ows.${type}_connecting`
     */ async connectToOWS ( params ) { this . hsAddDataUrlService . typeSelected = params . type as AddDataUrlType ; return await this . setUrlAndConnect ( params ) ; } async setTypeServices ( ) { switch ( this . hsAddDataUrlService . typeSelected ) { case 'wmts' : this . typeService = this . hsUrlWmtsService ; this . typeCapabilitiesService = this . hsWmtsGetCapabilitiesService ; return ; case 'wms' : this . typeService = this . hsUrlWmsService ; this . typeCapabilitiesService = this . hsWmsGetCapabilitiesService ; return ; case 'wfs' : this . typeService = this . hsUrlWfsService ; this . typeCapabilitiesService = this . hsWfsGetCapabilitiesService ; return ; case 'arcgis' : this . typeService = this . hsUrlArcGisService ; this . typeCapabilitiesService = this . hsArcgisGetCapabilitiesService ; return ; default : return ; } } }