diff --git a/packages/api/src/features.ts b/packages/api/src/features.ts index 085623c000..2ff64c51cc 100644 --- a/packages/api/src/features.ts +++ b/packages/api/src/features.ts @@ -6,7 +6,7 @@ import type Feature from 'ol/Feature' import type { LineString, MultiLineString, MultiPolygon, Point, Polygon } from 'ol/geom' import { allCoordinateSystems, extentUtils, LV95 } from '@swissgeo/coordinates' -import { ALL_YEARS_TIMESTAMP, CURRENT_YEAR_TIMESTAMP, LayerType } from '@swissgeo/layers' +import { ALL_YEARS_TIMESTAMP, CURRENT_YEAR_TIMESTAMP } from '@swissgeo/layers' import { geoJsonUtils, layerUtils } from '@swissgeo/layers/utils' import log from '@swissgeo/log' import { getApi3BaseUrl } from '@swissgeo/staging-config' @@ -236,7 +236,7 @@ async function identifyOnExternalLayer(config: IdentifyConfig): Promise { - if (currentLayer.type === LayerType.KML) { + if (currentLayer.type === 'KML') { const kmlLayer = currentLayer as KMLLayer return returnLayers.concat( searchFeatures( @@ -338,7 +337,7 @@ function searchLayerFeaturesKMLGPX( ) ) } - if (currentLayer.type === LayerType.GPX) { + if (currentLayer.type === 'GPX') { const gpxLayer = currentLayer as GPXLayer const gpxData = gpxLayer.gpxData if (!gpxData) { diff --git a/packages/api/src/utils/__tests__/legacyLayerParamUtils.spec.ts b/packages/api/src/utils/__tests__/legacyLayerParamUtils.spec.ts index 8f88b10ab8..755664c40f 100644 --- a/packages/api/src/utils/__tests__/legacyLayerParamUtils.spec.ts +++ b/packages/api/src/utils/__tests__/legacyLayerParamUtils.spec.ts @@ -1,6 +1,5 @@ import type { ExternalWMSLayer, GeoAdminLayer, Layer } from '@swissgeo/layers' -import { LayerType } from '@swissgeo/layers' import { layerUtils, timeConfigUtils } from '@swissgeo/layers/utils' import { describe, expect, it } from 'vitest' @@ -162,7 +161,7 @@ describe('Test parsing of legacy URL param into new params', () => { expect(result).to.be.an('Array').length(1) const [kmlLayer] = result expect(kmlLayer.id).to.eq(`KML|${kmlFileUrl}`) - expect(kmlLayer.type).to.eq(LayerType.KML) + expect(kmlLayer.type).to.eq('KML') expect(kmlLayer.baseUrl).to.eq(kmlFileUrl) }) it('Handles opacity/visibility correctly with external layers', () => { @@ -194,7 +193,7 @@ describe('Test parsing of legacy URL param into new params', () => { ) expect(result).to.be.an('Array').length(1) const [externalWmsLayer] = result - expect(externalWmsLayer.type).to.eq(LayerType.WMS) + expect(externalWmsLayer.type).to.eq('WMS') expect(externalWmsLayer.opacity).to.eq(0.45) expect((externalWmsLayer as ExternalWMSLayer).wmsVersion).to.eq(wmsVersion) expect(externalWmsLayer.id).to.eq(wmsLayerId) @@ -216,7 +215,7 @@ describe('Test parsing of legacy URL param into new params', () => { ) expect(result).to.be.an('Array').length(1) const [externalWmtsLayer] = result - expect(externalWmtsLayer.type).to.eq(LayerType.WMTS) + expect(externalWmtsLayer.type).to.eq('WMTS') expect(externalWmtsLayer.opacity).to.eq(0.77) expect(externalWmtsLayer.isVisible).to.be.false expect(externalWmtsLayer.id).to.eq(wmtsLayerId) diff --git a/packages/api/src/utils/kmlUtils.ts b/packages/api/src/utils/kmlUtils.ts index 489b07359a..63811f8488 100644 --- a/packages/api/src/utils/kmlUtils.ts +++ b/packages/api/src/utils/kmlUtils.ts @@ -9,7 +9,6 @@ import type { Size } from 'ol/size' import type Style from 'ol/style/Style' import { registerProj4, WGS84 } from '@swissgeo/coordinates' -import { KMLStyle } from '@swissgeo/layers' import log, { LogPreDefinedColor } from '@swissgeo/log' import { DEFAULT_TITLE_OFFSET, @@ -595,7 +594,8 @@ function getEditableFeatureFromKmlFeature( iconSize, textPlacement, showDescriptionOnMap, - } as EditableFeature + isEditable: true, + } } /** @@ -776,7 +776,7 @@ function parseKml( featureProjection: projection.epsg, }) - if (kmlLayer.style === KMLStyle.GEOADMIN) { + if (kmlLayer.style === 'GEOADMIN') { features.forEach((olFeature) => { const editableFeature = getEditableFeatureFromKmlFeature( olFeature, @@ -856,7 +856,11 @@ export interface KMZObject { * @returns Returns a KMZ unzip object */ async function unzipKmz(kmzContent: ArrayBuffer, kmzFileName: string): Promise { - const kmz: KMZObject = { name: kmzFileName, files: new Map(), kmz: kmzContent } + const kmz: KMZObject = { + name: kmzFileName, + files: new Map(), + kmz: kmzContent, + } const zip = new JSZip() try { await zip.loadAsync(kmzContent) diff --git a/packages/api/src/utils/legacyLayerParamUtils.ts b/packages/api/src/utils/legacyLayerParamUtils.ts index 9e4dae0011..ff4c9c889a 100644 --- a/packages/api/src/utils/legacyLayerParamUtils.ts +++ b/packages/api/src/utils/legacyLayerParamUtils.ts @@ -1,7 +1,6 @@ import type { GeoAdminLayer, KMLLayer, Layer } from '@swissgeo/layers' import type { Staging } from '@swissgeo/staging-config' -import { KMLStyle } from '@swissgeo/layers' import { layerUtils, timeConfigUtils } from '@swissgeo/layers/utils' import log from '@swissgeo/log' @@ -114,7 +113,7 @@ function getLayersFromLegacyUrlParams( layer = layerUtils.makeKMLLayer({ kmlFileUrl: url, isVisible: true, - style: KMLStyle.GEOADMIN, + style: 'GEOADMIN', }) } if (layerId.startsWith('GPX||')) { @@ -219,7 +218,10 @@ function getBackgroundLayerFromLegacyUrlParams( * @param adminId KML admin ID * @returns KML Layer */ -async function getKmlLayerFromLegacyAdminIdParam(adminId: string, staging: Staging = 'production'): Promise { +async function getKmlLayerFromLegacyAdminIdParam( + adminId: string, + staging: Staging = 'production' +): Promise { const kmlMetadata = await filesAPI.getKmlMetadataByAdminId(adminId, staging) return layerUtils.makeKMLLayer({ kmlFileUrl: kmlMetadata.links.kml, diff --git a/packages/config/staging/src/constants/print.config.ts b/packages/config/staging/src/constants/print.config.ts index 36018b28a1..b0d162408c 100644 --- a/packages/config/staging/src/constants/print.config.ts +++ b/packages/config/staging/src/constants/print.config.ts @@ -6,15 +6,7 @@ export const PRINT_DPI_COMPENSATION: number = 144 //So when there is a non 0 scale, we set its minimum to 0.0001 export const MIN_PRINT_SCALE_SIZE: number = 0.0001 -export enum PrintLayout { - A0 = 'A0', - A1 = 'A1', - A2 = 'A2', - A3 = 'A3', - A4 = 'A4', - A5 = 'A5', - A6 = 'A6', -} +export type PrintLayout = 'A0' | 'A1' | 'A2' | 'A3' | 'A4' | 'A5' | 'A6' /** Dimensions in mm of the viewport for each print format */ export const PRINT_DIMENSIONS: Record = { diff --git a/packages/layers/src/api/__test__/internal.spec.ts b/packages/layers/src/api/__test__/internal.spec.ts index a847d7eb15..36da2d2876 100644 --- a/packages/layers/src/api/__test__/internal.spec.ts +++ b/packages/layers/src/api/__test__/internal.spec.ts @@ -9,7 +9,7 @@ import type { } from '@/types' import { generateLayerObject } from '@/api' -import { LayerType, YEAR_TO_DESCRIBE_ALL_OR_CURRENT_DATA } from '@/types' +import { YEAR_TO_DESCRIBE_ALL_OR_CURRENT_DATA } from '@/types' import rawLayerConfig from './rawLayerConfig.json' @@ -251,7 +251,7 @@ describe('Test layer config parsing', () => { const layer = parseLayer(layerId) expect(layer).to.not.be.undefined - expect(layer.type).to.eq(LayerType.GEOJSON) + expect(layer.type).to.eq('GEOJSON') const geoJsonLayer = layer as GeoAdminGeoJSONLayer expect(geoJsonLayer.geoJsonUrl).to.eq( diff --git a/packages/layers/src/api/internal.ts b/packages/layers/src/api/internal.ts index c7f3eb29db..56569d1270 100644 --- a/packages/layers/src/api/internal.ts +++ b/packages/layers/src/api/internal.ts @@ -14,7 +14,6 @@ import type { } from '@/index' import { DEFAULT_GEOADMIN_MAX_WMTS_RESOLUTION } from '@/config' -import { LayerType } from '@/index' import { layerUtils, timeConfigUtils } from '@/utils' export interface LayerConfigResponse { @@ -150,7 +149,7 @@ export function generateLayerObject( break case 'wmts': { return layerUtils.makeGeoAdminWMTSLayer({ - type: LayerType.WMTS, + type: 'WMTS', name, id, baseUrl: _urlWithTrailingSlash(getWmtsBaseUrl(staging)), @@ -173,7 +172,7 @@ export function generateLayerObject( } case 'wms': { return layerUtils.makeGeoAdminWMSLayer({ - type: LayerType.WMS, + type: 'WMS', name, id: id, idIn3d: layerConfig.config3d, @@ -197,7 +196,7 @@ export function generateLayerObject( } case 'geojson': { return layerUtils.makeGeoAdminGeoJSONLayer({ - type: LayerType.GEOJSON, + type: 'GEOJSON', name, id, opacity, @@ -250,10 +249,7 @@ export function generateLayerObject( lang, staging ) - if ( - subLayer && - (subLayer.type === LayerType.WMS || subLayer.type === LayerType.WMTS) - ) { + if (subLayer && (subLayer.type === 'WMS' || subLayer.type === 'WMTS')) { subLayers.push( layerUtils.makeAggregateSubLayer({ subLayerId, diff --git a/packages/layers/src/parsers/WMTSCapabilitiesParser.ts b/packages/layers/src/parsers/WMTSCapabilitiesParser.ts index a7ea1e6391..2fcc82ed98 100644 --- a/packages/layers/src/parsers/WMTSCapabilitiesParser.ts +++ b/packages/layers/src/parsers/WMTSCapabilitiesParser.ts @@ -23,10 +23,10 @@ import type { WMTSLegendURL, WMTSOnlineResource, WMTSTileMatrixSetLink, + WMTSEncodingType, } from '@/types' import type { TileMatrix } from '@/types/layers' -import { LayerType, WMTSEncodingType } from '@/types' import layerUtils from '@/utils/layerUtils' import timeConfigUtils from '@/utils/timeConfigUtils' import { CapabilitiesError } from '@/validation' @@ -331,7 +331,7 @@ function getLayerAttributes( getCapUrl = capabilities.originUrl.toString() } - let getTileEncoding: WMTSEncodingType = WMTSEncodingType.REST + let getTileEncoding: WMTSEncodingType = 'REST' if ( capabilities.OperationsMetadata && 'GetTile' in capabilities.OperationsMetadata && @@ -471,7 +471,7 @@ function getExternalLayer( } return layerUtils.makeExternalWMTSLayer({ - type: LayerType.WMTS, + type: 'WMTS', ...attributes, opacity, isVisible, diff --git a/packages/layers/src/types/layers.ts b/packages/layers/src/types/layers.ts index 1744067491..33df86deac 100644 --- a/packages/layers/src/types/layers.ts +++ b/packages/layers/src/types/layers.ts @@ -11,17 +11,18 @@ export type * from '@/types/geoJsonStyle' export const DEFAULT_OPACITY = 1.0 export const WMS_SUPPORTED_VERSIONS = ['1.3.0'] -export enum LayerType { - WMTS = 'WMTS', - WMS = 'WMS', - GEOJSON = 'GEOJSON', - AGGREGATE = 'AGGREGATE', - KML = 'KML', - GPX = 'GPX', - VECTOR = 'VECTOR', - GROUP = 'GROUP', - COG = 'COG', -} +export const LayerTypes = [ + 'WMTS', + 'WMS', + 'GEOJSON', + 'AGGREGATE', + 'KML', + 'GPX', + 'VECTOR', + 'GROUP', + 'COG', +] as const +export type LayerType = (typeof LayerTypes)[number] export interface LayerAttribution { name: string @@ -97,6 +98,8 @@ export interface Layer { readonly isExternal: boolean /** Set to true if some parts of the layer (e.g. metadata) are still loading */ isLoading: boolean + /** Promise that resolves when the layer is fully loaded */ + loadedPromise?: Promise /** Time series config */ timeConfig: LayerTimeConfig /** @@ -154,7 +157,7 @@ export interface GeoAdminLayer extends Layer { /** Represent a WMS Layer from geo.admin.ch */ export interface GeoAdminWMSLayer extends GeoAdminLayer { - readonly type: LayerType.WMS + readonly type: 'WMS' /** * How much of a gutter (extra pixels around the image) we want. This is specific for tiled WMS, * if unset this layer will be a considered a single tile WMS. @@ -173,7 +176,7 @@ export interface GeoAdminWMSLayer extends GeoAdminLayer { /** Represent a WMTS layer from geo.admin.ch */ export interface GeoAdminWMTSLayer extends GeoAdminLayer { - readonly type: LayerType.WMTS + readonly type: 'WMTS' /** Define the maximum resolution the layer can reach */ readonly maxResolution: number /** In which image format the backend must be requested. */ @@ -181,7 +184,7 @@ export interface GeoAdminWMTSLayer extends GeoAdminLayer { } export interface GeoAdmin3DLayer extends GeoAdminLayer { - readonly type: LayerType.VECTOR + readonly type: 'VECTOR' /* If the JSON file stored in the /3d-tiles/ sub-folder on the S3 bucket */ readonly use3dTileSubFolder: boolean /** @@ -193,7 +196,7 @@ export interface GeoAdmin3DLayer extends GeoAdminLayer { } export interface GeoAdminGeoJSONLayer extends GeoAdminLayer { - readonly type: LayerType.GEOJSON + readonly type: 'GEOJSON' /** * Delay after which the data of this layer should be re-requested (if null is given, no further * data reload will be triggered). A good example would be layer @@ -209,7 +212,7 @@ export interface GeoAdminGeoJSONLayer extends GeoAdminLayer { } export interface GeoAdminVectorLayer extends GeoAdminLayer { - readonly type: LayerType.VECTOR + readonly type: 'VECTOR' } // #endregion @@ -221,7 +224,7 @@ export interface FileLayer extends Layer { } export interface CloudOptimizedGeoTIFFLayer extends FileLayer { - readonly type: LayerType.COG + readonly type: 'COG' readonly fileSource?: string /** Data/content of the COG file, as a string. */ data?: string | Blob @@ -274,13 +277,10 @@ export interface KMLMetadata { readonly links: KMLMetadataLinks } -export enum KMLStyle { - DEFAULT = 'DEFAULT', - GEOADMIN = 'GEOADMIN', -} +export type KMLStyle = 'DEFAULT' | 'GEOADMIN' export interface KMLLayer extends FileLayer { - readonly type: LayerType.KML + readonly type: 'KML' /** The URL to access the KML data. */ kmlFileUrl: string /** @@ -320,8 +320,8 @@ export interface KMLLayer extends FileLayer { */ linkFiles?: Record /** - * KMZ content as ArrayBuffer. This is used to load the KMZ in the 3D viewer (Cesium), so that it - * is able to link all the files inside the KMZ archive. + * KMZ content as ArrayBuffer. This is used to load the KMZ in the 3D viewer (Cesium), so that + * it is able to link all the files inside the KMZ archive. */ kmzContent?: ArrayBuffer /** @@ -355,7 +355,7 @@ export interface GPXMetadata { } export interface GPXLayer extends FileLayer { - readonly type: LayerType.GPX + readonly type: 'GPX' /** URL to the GPX file (can also be a local file URI) */ readonly gpxFileUrl?: string /** Data/content of the GPX file, as a string. */ @@ -407,10 +407,7 @@ export interface BoundingBox { readonly dimensions?: number } -export enum WMTSEncodingType { - KVP = 'KVP', - REST = 'REST', -} +export type WMTSEncodingType = 'KVP' | 'REST' /** Configuration describing how to request this layer's server to get feature information. */ export interface ExternalLayerGetFeatureInfoCapability { @@ -435,7 +432,7 @@ export interface ExternalLayer extends Layer { } export interface ExternalWMTSLayer extends ExternalLayer { - readonly type: LayerType.WMTS + readonly type: 'WMTS' /** WMTS Get Capabilities options */ readonly options?: Partial /** WMTS Get Tile encoding (KVP or REST). */ @@ -452,7 +449,7 @@ export interface ExternalWMTSLayer extends ExternalLayer { } export interface ExternalWMSLayer extends ExternalLayer { - readonly type: LayerType.WMS + readonly type: 'WMS' /** * Description of the layers being part of this WMS layer (they will all be displayed at the * same time, in contrast to an aggregate layer) @@ -482,12 +479,12 @@ export interface AggregateSubLayer { } export interface GeoAdminAggregateLayer extends GeoAdminLayer { - readonly type: LayerType.AGGREGATE + readonly type: 'AGGREGATE' readonly subLayers: AggregateSubLayer[] } export interface GeoAdminGroupOfLayers extends GeoAdminLayer { - readonly type: LayerType.GROUP + readonly type: 'GROUP' /** Description of the layers being part of this group */ readonly layers: GeoAdminLayer[] } diff --git a/packages/layers/src/utils/__test__/timeConfigUtils.spec.ts b/packages/layers/src/utils/__test__/timeConfigUtils.spec.ts index bbc7841099..a2cad7bfbe 100644 --- a/packages/layers/src/utils/__test__/timeConfigUtils.spec.ts +++ b/packages/layers/src/utils/__test__/timeConfigUtils.spec.ts @@ -3,7 +3,6 @@ import { describe, it } from 'vitest' import type { Layer } from '@/types/layers' -import { LayerType } from '@/types/layers' import timeConfigUtils from '@/utils/timeConfigUtils' describe('Test utility functions', () => { @@ -14,7 +13,7 @@ describe('Test utility functions', () => { id: 'ch.bgdi.simple', opacity: 0, isVisible: true, - type: LayerType.WMTS, + type: 'WMTS', attributions: [], hasTooltip: false, hasDescription: false, diff --git a/packages/layers/src/utils/layerUtils.ts b/packages/layers/src/utils/layerUtils.ts index 1593557904..e3a3c76776 100644 --- a/packages/layers/src/utils/layerUtils.ts +++ b/packages/layers/src/utils/layerUtils.ts @@ -20,12 +20,13 @@ import type { GeoAdminWMTSLayer, GPXLayer, KMLLayer, + KMLStyle, Layer, LayerAttribution, } from '@/types/layers' import { DEFAULT_GEOADMIN_MAX_WMTS_RESOLUTION } from '@/config' -import { DEFAULT_OPACITY, KMLStyle, LayerType, WMTSEncodingType } from '@/types/layers' +import { DEFAULT_OPACITY } from '@/types/layers' import timeConfigUtils from '@/utils/timeConfigUtils' import { InvalidLayerDataError } from '@/validation' @@ -33,10 +34,6 @@ export const EMPTY_KML_DATA = '' const ENC_PIPE = '%7C' -function transformToLayerTypeEnum(value: string): LayerType | undefined { - return Object.values(LayerType).includes(value as LayerType) ? (value as LayerType) : undefined -} - /** * Determine if a file URL is a local file or a remote URL. * @@ -84,7 +81,7 @@ function makeGeoAdminWMSLayer(values: Partial): GeoAdminWMSLay const defaults: DefaultLayerConfig = { uuid: uuidv4(), isExternal: false, - type: LayerType.WMS, + type: 'WMS', opacity: DEFAULT_OPACITY, isVisible: true, isLoading: false, @@ -123,7 +120,7 @@ function makeGeoAdminWMSLayer(values: Partial): GeoAdminWMSLay function makeGeoAdminWMTSLayer(values: Partial): GeoAdminWMTSLayer { const defaults: DefaultLayerConfig = { uuid: uuidv4(), - type: LayerType.WMTS, + type: 'WMTS', idIn3d: undefined, technicalName: undefined, opacity: 1.0, @@ -169,13 +166,13 @@ function makeExternalWMTSLayer(values: Partial): ExternalWMTS const defaults: DefaultLayerConfig = { uuid: uuidv4(), isExternal: true, - type: LayerType.WMTS, + type: 'WMTS', opacity: DEFAULT_OPACITY, isVisible: true, abstract: '', legends: [], availableProjections: [], - getTileEncoding: WMTSEncodingType.REST, + getTileEncoding: 'REST', urlTemplate: '', style: '', tileMatrixSets: [], @@ -238,7 +235,7 @@ function makeExternalWMSLayer(values: Partial): ExternalWMSLay dimensions: [], currentYear: undefined, customAttributes: undefined, - type: LayerType.WMS, + type: 'WMS', isExternal: true, hasError: false, hasWarning: false, @@ -299,7 +296,7 @@ function makeKMLLayer(values: Partial): KMLLayer { if (values.style !== undefined) { style = values.style } else { - style = isExternal ? KMLStyle.DEFAULT : KMLStyle.GEOADMIN + style = isExternal ? 'DEFAULT' : 'GEOADMIN' } let fileId = values.fileId @@ -345,7 +342,7 @@ function makeKMLLayer(values: Partial): KMLLayer { isLocalFile: isLocal, attributions, style, - type: LayerType.KML, + type: 'KML', hasTooltip: false, hasError: false, hasWarning: false, @@ -400,7 +397,7 @@ function makeGPXLayer(values: Partial): GPXLayer { extent: undefined, name: name, id: `GPX|${encodeExternalLayerParam(values.gpxFileUrl)}`, - type: LayerType.GPX, + type: 'GPX', opacity: 0, isVisible: false, attributions, @@ -436,7 +433,7 @@ function makeGeoAdminVectorLayer(values: Partial): GeoAdmin const defaults: DefaultLayerConfig = { uuid: uuidv4(), - type: LayerType.VECTOR, + type: 'VECTOR', technicalName: '', attributions, opacity: 0, @@ -480,7 +477,7 @@ function makeGeoAdmin3DLayer(values: Partial): GeoAdmin3DLayer use3dTileSubFolder: false, urlTimestampToUse: undefined, name: values.name ?? values.id ?? '3D layer', - type: LayerType.VECTOR, + type: 'VECTOR', opacity: 1, isVisible: true, attributions, @@ -528,7 +525,7 @@ function makeCloudOptimizedGeoTIFFLayer( const defaults: CloudOptimizedGeoTIFFLayer = { uuid: uuidv4(), baseUrl: fileSource, - type: LayerType.COG, + type: 'COG', isLocalFile: isLocal, fileSource: undefined, data: undefined, @@ -565,7 +562,7 @@ function makeGeoAdminAggregateLayer( ): GeoAdminAggregateLayer { const defaults: DefaultLayerConfig = { uuid: uuidv4(), - type: LayerType.AGGREGATE, + type: 'AGGREGATE', subLayers: [], opacity: 1, isVisible: true, @@ -600,7 +597,7 @@ function makeGeoAdminAggregateLayer( function makeGeoAdminGeoJSONLayer(values: Partial): GeoAdminGeoJSONLayer { const defaults: DefaultLayerConfig = { uuid: uuidv4(), - type: LayerType.GEOJSON, + type: 'GEOJSON', updateDelay: 0, styleUrl: '', geoJsonUrl: '', @@ -642,7 +639,7 @@ function makeGeoAdminGroupOfLayers(values: Partial): GeoA const defaults: DefaultLayerConfig = { uuid: uuidv4(), layers: [], - type: LayerType.GROUP, + type: 'GROUP', opacity: 1, isVisible: true, attributions: [], @@ -735,7 +732,7 @@ function getWmtsXyzUrl( } ): string | undefined { const { addTimestamp = false, baseUrlOverride } = options ?? {} - if (wmtsLayerConfig?.type === LayerType.WMTS && projection) { + if (wmtsLayerConfig?.type === 'WMTS' && projection) { let timestamp = '{Time}' if (addTimestamp) { timestamp = timeConfigUtils.getTimestampFromConfig(wmtsLayerConfig) ?? '{Time}' @@ -757,8 +754,7 @@ function getWmtsXyzUrl( return } -export interface GeoadminLayerUtils { - transformToLayerTypeEnum: typeof transformToLayerTypeEnum +export interface SwissGeoLayerUtils { makeGPXLayer: typeof makeGPXLayer makeKMLLayer: typeof makeKMLLayer makeGeoAdminWMSLayer: typeof makeGeoAdminWMSLayer @@ -779,8 +775,7 @@ export interface GeoadminLayerUtils { getWmtsXyzUrl: typeof getWmtsXyzUrl } -export const layerUtils: GeoadminLayerUtils = { - transformToLayerTypeEnum, +export const layerUtils: SwissGeoLayerUtils = { makeGPXLayer, makeKMLLayer, makeGeoAdminWMSLayer, diff --git a/packages/layers/src/utils/timeConfigUtils.ts b/packages/layers/src/utils/timeConfigUtils.ts index 3c91bcba32..d151a36239 100644 --- a/packages/layers/src/utils/timeConfigUtils.ts +++ b/packages/layers/src/utils/timeConfigUtils.ts @@ -2,16 +2,12 @@ import log from '@swissgeo/log' import { isTimestampYYYYMMDD } from '@swissgeo/numbers' import { Interval } from 'luxon' -import type {Layer, LayerTimeConfig, LayerTimeConfigEntry} from '@/types'; +import type { Layer, LayerTimeConfig, LayerTimeConfigEntry } from '@/types' import { ALL_YEARS_TIMESTAMP, CURRENT_YEAR_TIMESTAMP, - - - - LayerType, - YEAR_TO_DESCRIBE_ALL_OR_CURRENT_DATA + YEAR_TO_DESCRIBE_ALL_OR_CURRENT_DATA, } from '@/types' const hasTimestamp = (timeConfig: LayerTimeConfig, timestamp: string): boolean => @@ -23,7 +19,10 @@ const getTimeEntryForYear = ( ): LayerTimeConfigEntry | undefined => { const yearAsInterval = Interval.fromISO(`${year}-01-01/P1Y`) return timeConfig.timeEntries.find((entry: LayerTimeConfigEntry) => { - if (entry.nonTimeBasedValue && [ALL_YEARS_TIMESTAMP, CURRENT_YEAR_TIMESTAMP].includes(entry.nonTimeBasedValue)) { + if ( + entry.nonTimeBasedValue && + [ALL_YEARS_TIMESTAMP, CURRENT_YEAR_TIMESTAMP].includes(entry.nonTimeBasedValue) + ) { return year === YEAR_TO_DESCRIBE_ALL_OR_CURRENT_DATA } if (yearAsInterval.isValid && entry.interval) { @@ -156,7 +155,10 @@ const hasMultipleTimestamps = (layer: Layer): boolean => { } export function getYearFromLayerTimeEntry(timeEntry: LayerTimeConfigEntry): number | undefined { - if (timeEntry.nonTimeBasedValue && [ALL_YEARS_TIMESTAMP, CURRENT_YEAR_TIMESTAMP].includes(timeEntry.nonTimeBasedValue)) { + if ( + timeEntry.nonTimeBasedValue && + [ALL_YEARS_TIMESTAMP, CURRENT_YEAR_TIMESTAMP].includes(timeEntry.nonTimeBasedValue) + ) { return YEAR_TO_DESCRIBE_ALL_OR_CURRENT_DATA } if (timeEntry.interval && timeEntry.interval.start?.year !== undefined) { @@ -183,7 +185,7 @@ const getTimeEntryForInterval = ( /** Returns timestamp for WMS or WMTS layer from config data */ function getTimestampFromConfig(layer: Layer): string | undefined { let timestamp = layer.timeConfig?.currentTimeEntry?.timestamp - if (!timestamp && layer.type === LayerType.WMTS) { + if (!timestamp && layer.type === 'WMTS') { // for WMTS layer fallback to current timestamp = CURRENT_YEAR_TIMESTAMP } diff --git a/packages/mapviewer/scripts/check-external-layers-providers.ts b/packages/mapviewer/scripts/check-external-layers-providers.ts index 813b96ba10..251d633f8c 100644 --- a/packages/mapviewer/scripts/check-external-layers-providers.ts +++ b/packages/mapviewer/scripts/check-external-layers-providers.ts @@ -16,7 +16,6 @@ import type { } from 'axios' import { LV95 } from '@swissgeo/coordinates' -import { LayerType } from '@swissgeo/layers' import { EXTERNAL_SERVER_TIMEOUT, setWmsGetMapParams } from '@swissgeo/layers/api' import { wmsCapabilitiesParser, wmtsCapabilitiesParser } from '@swissgeo/layers/parsers' import axios, { AxiosError } from 'axios' @@ -221,7 +220,7 @@ async function handleWmts(provider: string, content: string, result: Result): Pr }) const firstLayer = findFirstLeaf(layers) - if (!firstLayer || firstLayer.type !== LayerType.WMTS) { + if (!firstLayer || firstLayer.type !== 'WMTS') { return false } const firstWmtsLayer = firstLayer as ExternalWMTSLayer @@ -326,7 +325,7 @@ function findFirstLeaf(layers: ExternalLayer[]): ExternalLayer | undefined { } for (const layer of layers) { - if (layer.type !== LayerType.WMS) { + if (layer.type !== 'WMS') { return layer } diff --git a/packages/mapviewer/src/modules/drawing/DrawingModule.vue b/packages/mapviewer/src/modules/drawing/DrawingModule.vue index d145a2bc49..cba056b3f5 100644 --- a/packages/mapviewer/src/modules/drawing/DrawingModule.vue +++ b/packages/mapviewer/src/modules/drawing/DrawingModule.vue @@ -1,32 +1,26 @@