import Feature from 'ol/Feature' ; import { Group , Layer } from 'ol/layer' ; import { DOMFeatureLink } from './dom-feature-link.type' ; import { Geometry } from 'ol/geom' ; import { HsLaymanLayerDescriptor } from '../components/save-map/layman-layer-descriptor.interface' ; import { Source } from 'ol/source' ; import { accessRightsModel } from '../components/add-data/common/access-rights.model' ; const ABSTRACT = 'abstract' ; const ACCESS_RIGHTS = 'access_rights' ; const ACTIVE = 'active' ; const ATTRIBUTION = 'attribution' ; const AUTO_LEGEND = 'autoLegend' ; const BASE = 'base' ; const CAPABILITIES = 'capabilities' ; const CLUSTER = 'cluster' ; const CUSTOM_INFO_TEMPLATE = 'customInfoTemplate' ; const DEFINITION = 'definition' ; const DIMENSIONS = 'dimensions' ; const EDITOR = 'editor' ; const ENABLEPROXY = 'enableProxy' ; const EVENTS_SUSPENDED = 'eventsSuspended' ; const EXCLUSIVE = 'exclusive' ; const FEATURE_INFO_LANG = 'featureInfoLang' ; const FROM_COMPOSITION = 'fromComposition' ; const GET_FEATURE_INFO_TARGET = 'getFeatureInfoTarget' ; const HS_LAYMAN_SYNCHRONIZING = 'hsLaymanSynchronizing' ; const HS_QML = 'qml' ; const HS_SLD = 'sld' ; const INFO_FORMAT = 'infoFormat' ; const INLINE_LEGEND = 'inlineLegend' ; const LAYMAN_LAYER_DESCRIPTOR = 'laymanLayerDescriptor' ; const LEGENDS = 'legends' ; const MAX_RESOLUTION_DENOMINATOR = 'maxResolutionDenominator' ; const METADATA = 'metadata' ; const MINIMUM_TERRAIN_LEVEL = 'minimumTerrainLevel' ; const NAME = 'name' ; const ON_FEATURE_SELECTED = 'onFeatureSelected' ; const PATH = 'path' ; const POPUP = 'popUp' ; const POPUP_CLASS = 'popupClass' ; const QUERY_CAPABILITIES = 'queryCapabilities' ; const QUERY_FILTER = 'queryFilter' ; const QUERYABLE = 'queryable' ; const REMOVABLE = 'removable' ; const SHOW_IN_LAYER_MANAGER = 'showInLayerManager' ; const SUB_LAYERS = [ 'subLayers' , 'sublayers' ] ; const SWIPE_SIDE = 'swipeSide' ; const THUMBNAIL = 'thumbnail' ; const TITLE = 'title' ; const VIRTUAL_ATTRIBUTES = 'virtualAttributes' ; const WFS_URL = 'wfsUrl' ; const WORKSPACE = 'workspace' ; export const DOM_FEATURE_LINKS = 'domFeatureLinks' ; export type Attribution = { onlineResource ? : string ; title ? : string ; logoUrl ? : { format ? : string ; onlineResource ? : string ; } ; /**
     * If set to true even if get capabilities receives some attribution,
     * it will not be updated and existing hardcoded attribution will be used
     */ locked ? : boolean ; } ; export type Definition = { format ? : string ; url ? : string ; } ; export type Editor = { editable ? : boolean ; /**
     * Object of key value pairs where key is the attribute name and value
     * is the default attribute value to set
     */ defaultAttributes ? : any ; } ; export type popUpAttribute = { attribute : string ; displayFunction ? : any ; label ? : string ; } ; export type popUp = { attributes ? : Array < popUpAttribute | string > ; widgets ? : string [ ] ; displayFunction ? : any ; } ; export function getAccessRights ( layer ) { return layer . get ( ACCESS_RIGHTS ) ; } export function setAccessRights ( layer , access_rights ) { layer . set ( ACCESS_RIGHTS , access_rights ) ; } export function setTitle ( layer , title ) { layer . set ( TITLE , title ) ; } export function getTitle ( layer ) { return layer . get ( TITLE ) ; } export function setName ( layer , name ) { layer . set ( NAME , name ) ; } export function getName ( layer ) { return layer . get ( NAME ) ; } export function setAbstract ( layer , abstract ) { layer . set ( ABSTRACT , abstract ) ; } export function getAbstract ( layer ) { return layer . get ( ABSTRACT ) ; } export function setActive ( group , active ) { group . set ( ACTIVE , active ) ; } export function getActive ( group ) { return group . get ( ACTIVE ) ; } export function setAttribution ( layer , attribution ) { layer . set ( ATTRIBUTION , attribution ) ; } export function getAttribution ( layer ) { return layer . get ( ATTRIBUTION ) ; } export function setAutoLegend ( layer , value ) { layer . set ( AUTO_LEGEND , value ) ; } export function getAutoLegend ( layer ) { return layer . get ( AUTO_LEGEND ) ; } export function getCachedCapabilities ( layer ) { return layer . get ( CAPABILITIES ) ; } export function setCacheCapabilities ( layer , capabilities ) { layer . set ( CAPABILITIES , capabilities ) ; } export function setBase ( layer , base ) { layer . set ( BASE , base ) ; } export function getBase ( layer ) { return layer . get ( BASE ) ; } export function setCluster ( layer , clusterActive ) { layer . set ( CLUSTER , clusterActive ) ; } export function getCluster ( layer ) { return layer . get ( CLUSTER ) ; } export function setCustomInfoTemplate ( layer , customInfoTemplate ) { layer . set ( CUSTOM_INFO_TEMPLATE , customInfoTemplate ) ; } export function getCustomInfoTemplate ( layer ) { return layer . get ( CUSTOM_INFO_TEMPLATE ) ; } export function setDefinition ( layer , definition ) { layer . set ( DEFINITION , definition ) ; } export function getDefinition ( layer ) { return layer . get ( DEFINITION ) ; } export interface Dimension { label : string ; onlyInEditor ? : boolean ; type ? : 'datetime' | 'date' ; value ? : any ; default ? : any ; units ? : string ; /**
     * Can be represented either by an array of values or, in case of time, as a ISO8601 time definition
     */ values ? : any [ ] | string ; availability ? ( ) : boolean ; } export interface DimensionsList { [ key ] : Dimension ; } param layer param dimensions example export function setDimensions ( layer , dimensions ) { layer . set ( DIMENSIONS , dimensions ) ; } export function getDimensions ( layer ) { return layer . get ( DIMENSIONS ) ; } param layer param dimension param type export function setDimension ( layer , dimension , type ) { if ( layer . get ( DIMENSIONS ) ) { const dims = layer . get ( DIMENSIONS ) ; dims [ type ] = dimension ; layer . set ( DIMENSIONS , dims ) ; } else { layer . set ( DIMENSIONS , { [ type ] : dimension } ) ; } } param layer param type returns export function getDimension ( layer , type ) { return layer . get ( DIMENSIONS ) ? layer . get ( DIMENSIONS ) [ type ] : undefined ; } export function setDomFeatureLinks ( layer , domFeatureLinks ) { layer . set ( DOM_FEATURE_LINKS , domFeatureLinks ) ; } export function getDomFeatureLinks ( layer ) { return layer . get ( DOM_FEATURE_LINKS ) ; } export function setEditor ( layer , editor ) { layer . set ( EDITOR , editor ) ; } export function getEditor ( layer ) { return layer . get ( EDITOR ) ; } export function setEnableProxy ( layer , enableProxy ) { layer . set ( ENABLEPROXY , enableProxy ) ; } export function getEnableProxy ( layer ) { return layer . get ( ENABLEPROXY ) ; } export function setEventsSuspended ( layer , eventsSuspended ) { layer . set ( EVENTS_SUSPENDED , eventsSuspended ) ; } export function getEventsSuspended ( layer ) { return layer . get ( EVENTS_SUSPENDED ) ; } export function setExclusive ( layer , exclusive ) { layer . set ( EXCLUSIVE , exclusive ) ; } export function getExclusive ( layer ) { return layer . get ( EXCLUSIVE ) ; } export function setFeatureInfoLang ( layer , featureInfoLang ) { layer . set ( FEATURE_INFO_LANG , featureInfoLang ) ; } export function getFeatureInfoLang ( layer ) { return layer . get ( FEATURE_INFO_LANG ) ; } export function setFromComposition ( layer , fromComposition ) { layer . set ( FROM_COMPOSITION , fromComposition ) ; } export function getFromComposition ( layer ) { return layer . get ( FROM_COMPOSITION ) ; } export function setFeatureInfoTarget ( layer , featureInfoTarget ) { layer . set ( GET_FEATURE_INFO_TARGET , featureInfoTarget ) ; } export function getFeatureInfoTarget ( layer ) { return layer . get ( GET_FEATURE_INFO_TARGET ) ; } export function getSld ( layer ) { return layer . get ( HS_SLD ) ; } export function getQml ( layer ) { return layer . get ( HS_QML ) ; } export function setSld ( layer , sld ) { layer . set ( HS_SLD , sld ) ; } export function setHsLaymanSynchronizing ( layer , hsLaymanSynchronizing ) { layer . set ( HS_LAYMAN_SYNCHRONIZING , hsLaymanSynchronizing ) ; } export function getHsLaymanSynchronizing ( layer ) { return layer . get ( HS_LAYMAN_SYNCHRONIZING ) ; } export function setInfoFormat ( layer , infoFormat ) { layer . set ( INFO_FORMAT , infoFormat ) ; } export function getInfoFormat ( layer ) { return layer . get ( INFO_FORMAT ) ; } export function setInlineLegend ( layer , inlineLegend ) { layer . set ( INLINE_LEGEND , inlineLegend ) ; } export function getInlineLegend ( layer ) { return layer . get ( INLINE_LEGEND ) ; } export function setLaymanLayerDescriptor ( layer , hsLaymanLayerDescriptor ) { layer . set ( LAYMAN_LAYER_DESCRIPTOR , hsLaymanLayerDescriptor ) ; } export function getLaymanLayerDescriptor ( layer ) { return layer . get ( LAYMAN_LAYER_DESCRIPTOR ) ; } export function setLegends ( layer , path ) { layer . set ( LEGENDS , path ) ; } export function getLegends ( layer ) { if ( layer . get ( LEGENDS ) == undefined && layer . get ( 'legendImage' ) !== undefined ) { console . warn ( '"legendImage" layer property is deprecated in favor of "legends"' ) ; return layer . get ( 'legendImage' ) ; } return layer . get ( LEGENDS ) ; } export function setMaxResolutionDenominator ( layer , maxResolutionDenominator ) { layer . set ( MAX_RESOLUTION_DENOMINATOR , maxResolutionDenominator ) ; } export function getMaxResolutionDenominator ( layer ) { return layer . get ( MAX_RESOLUTION_DENOMINATOR ) ; } export type MetadataUrl = { type ? : string ; format ? : string ; onlineResource ? : string ; } ; export type Metadata = { id ? : string | number ; urls ? : MetadataUrl [ ] ; styles ? : any ; } ; param layer param metadata export function setMetadata ( layer , metadata ) { layer . set ( METADATA , metadata ) ; } export function getMetadata ( layer ) { return layer . get ( METADATA ) ; } export function setMinimumTerrainLevel ( layer , minimumTerrainLevel ) { layer . set ( MINIMUM_TERRAIN_LEVEL , minimumTerrainLevel ) ; } export function getMinimumTerrainLevel ( layer ) { return layer . get ( MINIMUM_TERRAIN_LEVEL ) ; } interface FeatureSelector { ( feature ) : void ; } export function setOnFeatureSelected ( layer , onFeatureSelected ) { layer . set ( ON_FEATURE_SELECTED , onFeatureSelected ) ; } export function getOnFeatureSelected ( layer ) { return layer . get ( ON_FEATURE_SELECTED ) ; } export function setPath ( layer , path ) { layer . set ( PATH , path ) ; } export function getPath ( layer ) { return layer . get ( PATH ) ; } export function setPopUp ( layer , popUp ) { layer . set ( POPUP , popUp ) ; } export function getPopUp ( layer ) { return layer . get ( POPUP ) ; } export function setPopupClass ( layer , popupClass ) { layer . set ( POPUP_CLASS , popupClass ) ; } export function getPopupClass ( layer ) { return layer . get ( POPUP_CLASS ) ; } export function setQueryable ( layer , queryable ) { layer . set ( QUERYABLE , queryable ) ; } export function getQueryable ( layer ) { return layer . get ( QUERYABLE ) ; } export function setQueryCapabilities ( layer , queryCapabilities ) { layer . set ( QUERY_CAPABILITIES , queryCapabilities ) ; } export function getQueryCapabilities ( layer ) { return layer . get ( QUERY_CAPABILITIES ) ; } export function setQueryFilter ( layer , queryFilter ) { layer . set ( QUERY_FILTER , queryFilter ) ; } export function getQueryFilter ( layer ) { return layer . get ( QUERY_FILTER ) ; } export function setRemovable ( layer , removable ) { layer . set ( REMOVABLE , removable ) ; } export function getRemovable ( layer ) { return layer . get ( REMOVABLE ) ; } export function setShowInLayerManager ( layer , showInLayerManager ) { layer . set ( SHOW_IN_LAYER_MANAGER , showInLayerManager ) ; } export function getShowInLayerManager ( layer ) { return layer . get ( SHOW_IN_LAYER_MANAGER ) ; } param layer param subLayers export function setSubLayers ( layer , subLayers ) { layer . set ( SUB_LAYERS [ 0 ] , subLayers ) ; } param layer export function getSubLayers ( layer ) { return layer . get ( SUB_LAYERS [ 0 ] ) ?? layer . get ( SUB_LAYERS [ 1 ] ) ; } export function setThumbnail ( layer , thumbnail ) { layer . set ( THUMBNAIL , thumbnail ) ; } export function getThumbnail ( layer ) { return layer . get ( THUMBNAIL ) ; } export function setVirtualAttributes ( layer , virtualAttributes ) { layer . set ( VIRTUAL_ATTRIBUTES , virtualAttributes ) ; } export function getVirtualAttributes ( layer ) { return layer . get ( VIRTUAL_ATTRIBUTES ) ; } export function getWorkspace ( layer ) { return layer . get ( WORKSPACE ) ; } export function setWorkspace ( layer , workspace ) { layer . set ( WORKSPACE , workspace ) ; } export function getWfsUrl ( layer ) { return layer . get ( WFS_URL ) ; } export function setWfsUrl ( layer , url ) { layer . set ( WFS_URL , url ) ; } export function getSwipeSide ( layer ) { return layer . get ( SWIPE_SIDE ) ; } export function setSwipeSide ( layer , side ) { layer . set ( SWIPE_SIDE , side ) ; } export const HsLayerExt = { getAccessRights , setAccessRights , setTitle , getTitle , setName , getName , setAbstract , getAbstract , setActive , getActive , setAttribution , getAttribution , setCacheCapabilities , getCachedCapabilities , setBase , getBase , setCluster , getCluster , setCustomInfoTemplate , getCustomInfoTemplate , setDefinition , getDefinition , setDimensions , getDimensions , getDomFeatureLinks , setDomFeatureLinks , setEditor , getEditor , setEnableProxy , getEnableProxy , setEventsSuspended , getEventsSuspended , setExclusive , getExclusive , setFeatureInfoLang , getFeatureInfoLang , setFromComposition , getFromComposition , setFeatureInfoTarget , getFeatureInfoTarget , setHsLaymanSynchronizing , getHsLaymanSynchronizing , setInfoFormat , getInfoFormat , setInlineLegend , getInlineLegend , setLaymanLayerDescriptor , getLaymanLayerDescriptor , setMaxResolutionDenominator , getMaxResolutionDenominator , setMetadata , getMetadata , setMinimumTerrainLevel , getMinimumTerrainLevel , setOnFeatureSelected , getOnFeatureSelected , setPath , getPath , setPopUp , getPopUp , setPopupClass , getPopupClass , setQueryable , getQueryable , setQueryCapabilities , getQueryCapabilities , setQueryFilter , getQueryFilter , setRemovable , getRemovable , setShowInLayerManager , getShowInLayerManager , setThumbnail , getThumbnail , setVirtualAttributes , getVirtualAttributes , setWorkspace , getWorkspace , getWfsUrl , setWfsUrl , getSwipeSide , setSwipeSide , } ;