Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions packages/api/src/features.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -236,7 +236,7 @@ async function identifyOnExternalLayer(config: IdentifyConfig): Promise<LayerFea
// If we use different projection, we also need to project out initial coordinate
requestedCoordinate = proj4(projection.epsg, requestProjection.epsg, coordinate)
}
if (layer.type === LayerType.WMS) {
if (layer.type === 'WMS') {
return await identifyOnExternalWmsLayer({
...config,
coordinate: requestedCoordinate,
Expand Down Expand Up @@ -483,7 +483,7 @@ async function identifyOnExternalWmsLayer(config: IdentifyConfig): Promise<Layer
outputProjection ?? projection,
projection
),
popupDataCanBeTrusted: !layer.isExternal && layer.type !== LayerType.KML,
popupDataCanBeTrusted: !layer.isExternal && layer.type !== 'KML',
}
return layerFeature
})
Expand Down Expand Up @@ -657,7 +657,7 @@ function parseGeomAdminFeature(
coordinates: center,
extent: featureExtent,
geometry: featureGeoJSONGeometry,
popupDataCanBeTrusted: !layer.isExternal && layer.type !== LayerType.KML,
popupDataCanBeTrusted: !layer.isExternal && layer.type !== 'KML',
}
return layerFeature
}
Expand Down
5 changes: 2 additions & 3 deletions packages/api/src/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import type { AxiosResponse, CancelToken, CancelTokenSource } from 'axios'
import type Feature from 'ol/Feature'

import { CustomCoordinateSystem, LV95, WGS84 } from '@swissgeo/coordinates'
import { LayerType } from '@swissgeo/layers'
import { geoJsonUtils } from '@swissgeo/layers/utils'
import log, { LogPreDefinedColor } from '@swissgeo/log'
import { getApi3BaseUrl } from '@swissgeo/staging-config'
Expand Down Expand Up @@ -327,7 +326,7 @@ function searchLayerFeaturesKMLGPX(
iconSets: DrawingIconSet[]
): SearchResult[] {
return layersToSearch.reduce((returnLayers: SearchResult[], currentLayer: Layer) => {
if (currentLayer.type === LayerType.KML) {
if (currentLayer.type === 'KML') {
const kmlLayer = currentLayer as KMLLayer
return returnLayers.concat(
searchFeatures(
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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'

Expand Down Expand Up @@ -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', () => {
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down
12 changes: 8 additions & 4 deletions packages/api/src/utils/kmlUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -595,7 +594,8 @@ function getEditableFeatureFromKmlFeature(
iconSize,
textPlacement,
showDescriptionOnMap,
} as EditableFeature
isEditable: true,
}
}

/**
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -856,7 +856,11 @@ export interface KMZObject {
* @returns Returns a KMZ unzip object
*/
async function unzipKmz(kmzContent: ArrayBuffer, kmzFileName: string): Promise<KMZObject> {
const kmz: KMZObject = { name: kmzFileName, files: new Map<string, ArrayBuffer>(), kmz: kmzContent }
const kmz: KMZObject = {
name: kmzFileName,
files: new Map<string, ArrayBuffer>(),
kmz: kmzContent,
}
const zip = new JSZip()
try {
await zip.loadAsync(kmzContent)
Expand Down
8 changes: 5 additions & 3 deletions packages/api/src/utils/legacyLayerParamUtils.ts
Original file line number Diff line number Diff line change
@@ -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'

Expand Down Expand Up @@ -114,7 +113,7 @@ function getLayersFromLegacyUrlParams(
layer = layerUtils.makeKMLLayer({
kmlFileUrl: url,
isVisible: true,
style: KMLStyle.GEOADMIN,
style: 'GEOADMIN',
})
}
if (layerId.startsWith('GPX||')) {
Expand Down Expand Up @@ -219,7 +218,10 @@ function getBackgroundLayerFromLegacyUrlParams(
* @param adminId KML admin ID
* @returns KML Layer
*/
async function getKmlLayerFromLegacyAdminIdParam(adminId: string, staging: Staging = 'production'): Promise<KMLLayer> {
async function getKmlLayerFromLegacyAdminIdParam(
adminId: string,
staging: Staging = 'production'
): Promise<KMLLayer> {
const kmlMetadata = await filesAPI.getKmlMetadataByAdminId(adminId, staging)
return layerUtils.makeKMLLayer({
kmlFileUrl: kmlMetadata.links.kml,
Expand Down
10 changes: 1 addition & 9 deletions packages/config/staging/src/constants/print.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<PrintLayout, [number, number]> = {
Expand Down
4 changes: 2 additions & 2 deletions packages/layers/src/api/__test__/internal.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down Expand Up @@ -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(
Expand Down
12 changes: 4 additions & 8 deletions packages/layers/src/api/internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -150,7 +149,7 @@ export function generateLayerObject(
break
case 'wmts': {
return layerUtils.makeGeoAdminWMTSLayer({
type: LayerType.WMTS,
type: 'WMTS',
name,
id,
baseUrl: _urlWithTrailingSlash(getWmtsBaseUrl(staging)),
Expand All @@ -173,7 +172,7 @@ export function generateLayerObject(
}
case 'wms': {
return layerUtils.makeGeoAdminWMSLayer({
type: LayerType.WMS,
type: 'WMS',
name,
id: id,
idIn3d: layerConfig.config3d,
Expand All @@ -197,7 +196,7 @@ export function generateLayerObject(
}
case 'geojson': {
return layerUtils.makeGeoAdminGeoJSONLayer({
type: LayerType.GEOJSON,
type: 'GEOJSON',
name,
id,
opacity,
Expand Down Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions packages/layers/src/parsers/WMTSCapabilitiesParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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 &&
Expand Down Expand Up @@ -471,7 +471,7 @@ function getExternalLayer(
}

return layerUtils.makeExternalWMTSLayer({
type: LayerType.WMTS,
type: 'WMTS',
...attributes,
opacity,
isVisible,
Expand Down
Loading
Loading