Skip to content

Commit

Permalink
Merge pull request #839 from geoadmin/develop
Browse files Browse the repository at this point in the history
New Release v1.16.0 - #minor
  • Loading branch information
ltshb authored May 14, 2024
2 parents 9c7e462 + a676c58 commit 07866de
Show file tree
Hide file tree
Showing 87 changed files with 2,918 additions and 1,537 deletions.
33 changes: 28 additions & 5 deletions src/api/features/features.api.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@ import LayerFeature from '@/api/features/LayerFeature.class'
import ExternalLayer from '@/api/layers/ExternalLayer.class'
import ExternalWMSLayer from '@/api/layers/ExternalWMSLayer.class'
import GeoAdminLayer from '@/api/layers/GeoAdminLayer.class'
import { API_BASE_URL } from '@/config'
import { API_BASE_URL, DEFAULT_FEATURE_COUNT_SINGLE_POINT } from '@/config'
import allCoordinateSystems, { LV95 } from '@/utils/coordinates/coordinateSystems'
import { projExtent } from '@/utils/coordinates/coordinateUtils'
import { createPixelExtentAround } from '@/utils/extentUtils'
import { getGeoJsonFeatureCoordinates, reprojectGeoJsonData } from '@/utils/geoJsonUtils'
import log from '@/utils/logging'

const DEFAULT_FEATURE_COUNT = 10
const GET_FEATURE_INFO_FAKE_VIEWPORT_SIZE = 100

const APPLICATION_JSON_TYPE = 'application/json'
Expand Down Expand Up @@ -94,18 +93,36 @@ export function extractOlFeatureGeodesicCoordinates(feature) {
* @param {[Number, Number, Number, Number]} mapExtent
* @param {String} lang
* @param {Number} featureCount
* @param {Number} [offset] Offset of how many items the identification should start after. This
* enables us to do some "pagination" or "load more" (if you already have 10 features, set an
* offset of 10 to get the 10 next, 20 in total).
* @returns {Promise<LayerFeature[]>}
*/
async function identifyOnGeomAdminLayer({
export async function identifyOnGeomAdminLayer({
layer,
projection,
coordinate,
screenWidth,
screenHeight,
mapExtent,
lang,
featureCount,
featureCount = DEFAULT_FEATURE_COUNT_SINGLE_POINT,
offset = null,
}) {
if (!layer) {
throw new GetFeatureInfoError('Missing layer')
}
if (!Array.isArray(coordinate)) {
throw new GetFeatureInfoError('Coordinate are required to perform a getFeatureInfo request')
}
if (featureCount === null) {
throw new GetFeatureInfoError(
'A feature count is required to perform a getFeatureInfo request'
)
}
if (lang === null) {
throw new GetFeatureInfoError('A lang is required to build a getFeatureInfo request')
}
const identifyResponse = await axios.get(
`${API_BASE_URL}rest/services/${layer.getTopicForIdentifyAndTooltipRequests()}/MapServer/identify`,
{
Expand All @@ -123,6 +140,7 @@ async function identifyOnGeomAdminLayer({
returnGeometry: true,
timeInstant: layer.timeConfig?.currentYear ?? null,
lang: lang,
offset,
},
}
)
Expand Down Expand Up @@ -399,6 +417,9 @@ async function identifyOnExternalWmsLayer(config) {
* @param {Number} config.screenWidth
* @param {Number} config.screenHeight
* @param {String} config.lang
* @param {Number} [config.offset] Offset of how many items the identification should start after.
* This enables us to do some "pagination" or "load more" (if you already have 10 features, set an
* offset of 10 to get the 10 next, 20 in total). This only works with GeoAdmin backends
* @param {CoordinateSystem} config.projection Projection in which the coordinates of the features
* should be expressed
* @returns {Promise<LayerFeature[]>}
Expand All @@ -413,7 +434,8 @@ export const identify = (config) => {
screenHeight = null,
lang = null,
projection = null,
featureCount = DEFAULT_FEATURE_COUNT,
featureCount = DEFAULT_FEATURE_COUNT_SINGLE_POINT,
offset = null,
} = config
return new Promise((resolve, reject) => {
if (!layer?.id) {
Expand Down Expand Up @@ -446,6 +468,7 @@ export const identify = (config) => {
mapExtent,
lang,
featureCount,
offset,
})
.then(resolve)
.catch((error) => {
Expand Down
2 changes: 1 addition & 1 deletion src/api/layers/GeoAdmin3DLayer.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default class GeoAdmin3DLayer extends GeoAdminLayer {
name: layerId,
type: LayerTypes.VECTOR,
technicalName: layerId,
geoAdminId: layerId,
id: layerId,
baseUrl: BASE_URL_3D_TILES,
ensureTrailingSlashInBaseUrl: true,
opacity: 1.0,
Expand Down
2 changes: 1 addition & 1 deletion src/api/layers/GeoAdminAggregateLayer.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export default class GeoAdminAggregateLayer extends GeoAdminLayer {
type: LayerTypes.AGGREGATE,
// no base URL for aggregate layers, so giving an empty base URL to accommodate constraints
baseUrl: '',
geoAdminId: id,
id: id,
technicalName: id,
opacity,
visible,
Expand Down
2 changes: 1 addition & 1 deletion src/api/layers/GeoAdminGeoJsonLayer.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export default class GeoAdminGeoJsonLayer extends GeoAdminLayer {
name,
type: LayerTypes.GEOJSON,
baseUrl: geoJsonUrl,
geoAdminId: id,
id: id,
technicalName: id,
opacity,
visible,
Expand Down
2 changes: 1 addition & 1 deletion src/api/layers/GeoAdminGroupOfLayers.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default class GeoAdminGroupOfLayers extends GeoAdminLayer {
super({
name,
type: LayerTypes.GROUP,
geoAdminId: id,
id: id,
technicalName: id,
baseUrl: '',
attributions: [new LayerAttribution('swisstopo', 'https://www.swisstopo.admin.ch/')],
Expand Down
20 changes: 9 additions & 11 deletions src/api/layers/GeoAdminLayer.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,12 @@ import { InvalidLayerDataError } from '@/api/layers/InvalidLayerData.error'
export default class GeoAdminLayer extends AbstractLayer {
/**
* @param {String} layerData.name Name of this layer in the current lang
* @param {LayerTypes} layerData.type See {@link LayerTypes} geoAdminLayerData. * @param {String}
* geoAdminLayerData.geoAdminId The unique ID of this layer that will be used to identify this
* layer
* @param {LayerTypes} layerData.type See {@link LayerTypes} geoAdminLayerData.
* @param {String} geoAdminLayerData.id The unique ID of this layer that will be used to
* identify this layer
* @param {String} layerData.technicalName The ID/name to use when requesting the WMS/WMTS
* backend, this might be different than geoAdminId, and many layers (with different
* geoAdminId) can in fact request the same layer, through the same technical name, in the
* end)
* backend, this might be different than id, and many layers (with different id) can in fact
* request the same layer, through the same technical name, in the end)
* @param {Number} [layerData.opacity=1.0] Value from 0.0 to 1.0 telling with which opacity this
* layer should be shown on the map. Default is `1.0`
* @param {boolean} [layerData.visible=true] If the layer should be shown on the map. Default is
Expand Down Expand Up @@ -69,7 +68,7 @@ export default class GeoAdminLayer extends AbstractLayer {
const {
name = null,
type = null,
geoAdminId = null,
id = null,
technicalName = null,
opacity = 1.0,
visible = true,
Expand All @@ -86,7 +85,7 @@ export default class GeoAdminLayer extends AbstractLayer {
hasLegend = false,
searchable = false,
} = layerData
if (geoAdminId === null) {
if (id === null) {
throw new InvalidLayerDataError('Missing geoadmin layer ID', layerData)
}
if (technicalName === null) {
Expand All @@ -103,7 +102,7 @@ export default class GeoAdminLayer extends AbstractLayer {
}
super({
name,
id: geoAdminId,
id,
type,
baseUrl,
ensureTrailingSlashInBaseUrl,
Expand All @@ -115,12 +114,11 @@ export default class GeoAdminLayer extends AbstractLayer {
hasDescription,
hasLegend,
})
this.geoAdminId = geoAdminId
this.technicalName = technicalName
this.isBackground = isBackground
this.isHighlightable = isHighlightable
this.topics = topics
this.isSpecificFor3D = geoAdminId.toLowerCase().endsWith('_3d')
this.isSpecificFor3D = id.toLowerCase().endsWith('_3d')
this.timeConfig = timeConfig
this.hasMultipleTimestamps = this.timeConfig?.timeEntries?.length > 1
this.searchable = searchable
Expand Down
2 changes: 1 addition & 1 deletion src/api/layers/GeoAdminVectorLayer.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default class GeoAdminVectorLayer extends GeoAdminLayer {
name: layerId,
type: LayerTypes.VECTOR,
baseUrl: VECTOR_TILE_BASE_URL,
geoAdminId: layerId,
id: layerId,
technicalName: layerId,
attributions: [
...extraAttributions,
Expand Down
10 changes: 5 additions & 5 deletions src/api/layers/GeoAdminWMSLayer.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ import { WMS_BASE_URL } from '@/config'
export default class GeoAdminWMSLayer extends GeoAdminLayer {
/**
* @param {String} layerData.name The name of this layer (lang specific)
* @param {String} layerData.geoAdminId The unique ID of this layer
* @param {String} layerData.id The unique ID of this layer
* @param {String} layerData.technicalName The ID/name to use when requesting the WMS backend,
* this might be different than geoAdminId, and many layers (with different geoAdminId) can in
* fact request the same layer, through the same technical name, in the end)
* this might be different than id, and many layers (with different id) can in fact request
* the same layer, through the same technical name, in the end)
* @param {Number} [layerData.opacity=1.0] The opacity to apply to this layer (between 0.0 and
* 1.0). Default is `1.0`
* @param {boolean} [layerData.visible=true] If the layer should be shown on the map. Default is
Expand Down Expand Up @@ -62,7 +62,7 @@ export default class GeoAdminWMSLayer extends GeoAdminLayer {
}
const {
name = null,
geoAdminId = null,
id = null,
technicalName = null,
opacity = 1.0,
visible = true,
Expand All @@ -82,7 +82,7 @@ export default class GeoAdminWMSLayer extends GeoAdminLayer {
super({
name,
type: LayerTypes.WMS,
geoAdminId,
id,
technicalName,
opacity,
visible,
Expand Down
6 changes: 3 additions & 3 deletions src/api/layers/GeoAdminWMTSLayer.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { TILEGRID_RESOLUTIONS } from '@/utils/coordinates/SwissCoordinateSystem.
export default class GeoAdminWMTSLayer extends GeoAdminLayer {
/**
* @param {String} layerData.name Layer name (internationalized)
* @param {String} layerData.geoAdminId Unique layer ID
* @param {String} layerData.id Unique layer ID
* @param {String} layerData.technicalName ID to be used in our backend (can be different from
* the id)
* @param {Number} [layerData.opacity=1.0] Opacity value between 0.0 (transparent) and 1.0
Expand Down Expand Up @@ -58,7 +58,7 @@ export default class GeoAdminWMTSLayer extends GeoAdminLayer {
}
const {
name = null,
geoAdminId = null,
id = null,
technicalName = null,
opacity = 1.0,
visible = true,
Expand All @@ -83,7 +83,7 @@ export default class GeoAdminWMTSLayer extends GeoAdminLayer {
super({
name,
type: LayerTypes.WMTS,
geoAdminId,
id,
technicalName,
opacity,
visible,
Expand Down
4 changes: 2 additions & 2 deletions src/api/layers/layers.api.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ const generateClassForLayerConfig = (layerConfig, id, allOtherLayers, lang) => {
case 'wmts':
layer = new GeoAdminWMTSLayer({
name,
geoAdminId: id,
id: id,
technicalName: serverLayerName,
opacity,
visible: false,
Expand All @@ -94,7 +94,7 @@ const generateClassForLayerConfig = (layerConfig, id, allOtherLayers, lang) => {
case 'wms':
layer = new GeoAdminWMSLayer({
name,
geoAdminId: id,
id: id,
technicalName: serverLayerName,
opacity,
visible: false,
Expand Down
19 changes: 19 additions & 0 deletions src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -309,3 +309,22 @@ export const YOUNGEST_YEAR = new Date().getFullYear() - 1
* @type {String[]}
*/
export const WHITELISTED_HOSTNAMES = ['test.map.geo.admin.ch', 'map.geo.admin.ch']

/**
* How many features we will request our backends when identifying features under a single
* coordinate (mouse click)
*
* @type {number}
*/
export const DEFAULT_FEATURE_COUNT_SINGLE_POINT = 10

/**
* How many features we will request our backends when doing a rectangle selection on the map
* (CLTR+drag)
*
* There's a hard limit of 50 on our backend.
*
* @type {number}
* @see https://api3.geo.admin.ch/services/sdiservices.html#id10
*/
export const DEFAULT_FEATURE_COUNT_RECTANGLE_SELECTION = 50
4 changes: 2 additions & 2 deletions src/modules/drawing/components/SharePopup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ async function updateAdminShareUrl() {
@click="copyShareUrl(false)"
/>
<button
class="btn btn-outline-secondary"
class="btn btn-outline-group"
type="button"
data-cy="drawing-share-normal-link"
@click="copyShareUrl(false)"
Expand All @@ -141,7 +141,7 @@ async function updateAdminShareUrl() {
@click="copyAdminShareUrl()"
/>
<button
class="btn btn-outline-secondary"
class="btn btn-outline-group"
type="button"
data-cy="drawing-share-admin-link"
@click="copyAdminShareUrl()"
Expand Down
10 changes: 9 additions & 1 deletion src/modules/i18n/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -664,5 +664,13 @@
"share_map_title": "Link zum Geoportal der Schweizerischen Eidgenossenschaft",
"link_description": "Link Beschreibung (optional)",
"media_disclaimer": "Enthält Inhalte von Drittanbietern",
"drawing_attached": "Zeichnung als Anhang hinzugefügt"
"drawing_attached": "Zeichnung als Anhang hinzugefügt",
"switch_tooltip_attached_to_feature": "Tooltip an Geometrie anhängen",
"switch_tooltip_floating": "Eine schwebende Tooltip verwenden",
"field_required": "Dieses Feld ist erforderlich",
"invalid_email": "ungültige E-Mail",
"no_email": "Das E-Mail-Feld ist erforderlich",
"file_unsupported_format": "Dieses Dateiformat wird nicht unterstützt. Nur die folgenden Formate sind erlaubt: ALLOWED_FORMATS",
"form_invalid": "Das Formular ist ungültig",
"file_imported_success": "Datei erfolgreich importiert"
}
10 changes: 9 additions & 1 deletion src/modules/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -664,5 +664,13 @@
"share_map_title": "Link to the geoportal of Swiss Confederation",
"link_description": "Link description (optional)",
"media_disclaimer": "Contains third party content",
"drawing_attached": "Drawing added as attachment"
"drawing_attached": "Drawing added as attachment",
"switch_tooltip_attached_to_feature": "Attach tooltip to geometry",
"switch_tooltip_floating": "Use a floating tooltip",
"field_required": "This field is required",
"invalid_email": "Invalid email",
"no_email": "Email field is required",
"file_unsupported_format": "This file format is not supported. Only the following formats are allowed: ALLOWED_FORMATS",
"form_invalid": "Form is invalid",
"file_imported_success": "File successfully imported"
}
10 changes: 9 additions & 1 deletion src/modules/i18n/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -664,5 +664,13 @@
"share_map_title": "Lien sur le géoportail de la Confédération",
"link_description": "Description du lien (facultatif)",
"media_disclaimer": "Contient du contenu de tiers",
"drawing_attached": "Dessin ajouté en pièce jointe"
"drawing_attached": "Dessin ajouté en pièce jointe",
"switch_tooltip_attached_to_feature": "Attacher le tooltip à la géométrie",
"switch_tooltip_floating": "Utiliser un tooltip flottant",
"field_required": "Ce champ est requis",
"invalid_email": "e-mail invalide",
"no_email": "Le champ email est requis",
"file_unsupported_format": "Ce format de fichier n'est pas pris en charge. Seuls les formats suivants sont autorisés : ALLOWED_FORMATS",
"form_invalid": "Le formulaire est invalide",
"file_imported_success": "Fichier importé avec succès"
}
10 changes: 9 additions & 1 deletion src/modules/i18n/locales/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -664,5 +664,13 @@
"share_map_title": "Link al geoportale della Confederazione Svizzera",
"link_description": "Descrizione del link (facoltativo)",
"media_disclaimer": "Contiene contenuti di terze parti",
"drawing_attached": "Disegno aggiunto come allegato"
"drawing_attached": "Disegno aggiunto come allegato",
"switch_tooltip_attached_to_feature": "Collegare il tooltip alla geometria",
"switch_tooltip_floating": "Utilizzare un tooltip fluttuante",
"field_required": "Questo campo è obbligatorio",
"invalid_email": "e-mail non valide",
"no_email": "Il campo email è obbligatorio",
"file_unsupported_format": "Questo formato file non è supportato. Sono ammessi solo i seguenti formati: ALLOWED_FORMATS",
"form_invalid": "Il modulo non è valido",
"file_imported_success": "File importato con successo"
}
10 changes: 9 additions & 1 deletion src/modules/i18n/locales/rm.json
Original file line number Diff line number Diff line change
Expand Up @@ -662,5 +662,13 @@
"share_map_title": "Link al geoportail da la Confederaziun Svizra",
"link_description": "Descripziun link (optional)",
"media_disclaimer": "Contegn contens da terzas partidas",
"drawing_attached": "Dessin agiunt sco allegat"
"drawing_attached": "Dessin agiunt sco allegat",
"switch_tooltip_attached_to_feature": "Agiuntar il detagl da la geometria",
"switch_tooltip_floating": "Duvrar in tool sin ballarait",
"field_required": "Quest champ è necessari",
"invalid_email": "ungültige E-Mail",
"no_email": "Il champ da posta eletronicala è necessari",
"file_unsupported_format": "Quest format da datoteca na vegn betg sustegnì. Sun ils seguents formats èn permess: ALLOWED_FORMATS",
"form_invalid": "Il formular è invalid",
"file_imported_success": "Datoteca importada cun success"
}
Loading

0 comments on commit 07866de

Please sign in to comment.