Skip to content

Commit a993dff

Browse files
committed
Merge branch 'main' of github.com:visualize-admin/visualization-tool into feat/show-values-improvements
2 parents 3e4752d + 424c59c commit a993dff

32 files changed

+62565
-170
lines changed

.storybook/main.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
import type { StorybookConfig } from "@storybook/nextjs";
22
import { dirname, join, resolve } from "path";
3+
import { config as dotEnvConfig } from "dotenv";
4+
import { existsSync } from "fs";
5+
6+
const dotEnvFilePaths = [
7+
join(__dirname, "../app/.env.local"),
8+
join(__dirname, "../app/.env.development"),
9+
];
10+
for (let file of dotEnvFilePaths) {
11+
if (existsSync(file)) {
12+
dotEnvConfig({
13+
path: file,
14+
});
15+
}
16+
}
317

418
/**
519
* This function is used to resolve the absolute path of a package.
@@ -11,6 +25,10 @@ function getAbsolutePath(value: string): any {
1125
const config: StorybookConfig = {
1226
stories: ["../app/**/*.docs.mdx", "../app/**/*.stories.@(js|jsx|mjs|ts|tsx)"],
1327

28+
// react-docgen-typescript is slow and we do not use docgen so we disable
29+
// docgen at the moment
30+
typescript: { reactDocgen: false },
31+
1432
addons: [
1533
getAbsolutePath("@storybook/addon-links"),
1634
getAbsolutePath("@storybook/addon-essentials"),
@@ -21,6 +39,18 @@ const config: StorybookConfig = {
2139
options: {},
2240
},
2341
docs: {},
42+
env: (config) => {
43+
const keys = Object.keys(process.env).filter((key) => {
44+
return key.startsWith("NEXT_PUBLIC_");
45+
});
46+
const forwardedEnv = Object.fromEntries(
47+
keys.map((k) => [k, process.env[k] ?? ""] as const)
48+
);
49+
return {
50+
...config,
51+
...forwardedEnv,
52+
};
53+
},
2454
webpackFinal: async (config) => {
2555
if (!config.resolve) {
2656
config.resolve = {};

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,14 @@ You can also check the
1919
others too – and we fall back to a regular string in case the label is not
2020
localized
2121
- Value labels in segmented bar charts are now centered horizontally
22+
- It's now possible to enter www links in text blocks link elements, instead
23+
of having to always use https://
2224
- Fixes
2325
- Color palette can be changed again
2426
- Combo charts tooltips now work correctly again
2527
- Interactive 100% mode switch doesn't overlap with Y axis label anymore
28+
- Chart preview using hash parameters now correctly deals with spacial
29+
characters
2630

2731
# [5.7.0] - 2025-04-16
2832

app/charts/map/map-custom-layers-legend.tsx

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import { Box, Typography } from "@mui/material";
2+
import uniq from "lodash/uniq";
23
import NextImage from "next/image";
34

4-
import { ParsedWMSLayer, useWMSLayers } from "@/charts/map/wms-utils";
5+
import { useWMTSorWMSLayers } from "@/charts/map/wms-endpoint-utils";
6+
import { DEFAULT_WMS_URL, ParsedWMSLayer } from "@/charts/map/wms-utils";
57
import {
8+
DEFAULT_WMTS_URL,
69
getWMTSLayerValue,
710
ParsedWMTSLayer,
8-
useWMTSLayers,
911
} from "@/charts/map/wmts-utils";
1012
import { Error, InlineLoading } from "@/components/hint";
1113
import { InfoIconTooltip } from "@/components/info-icon-tooltip";
@@ -86,8 +88,25 @@ const useLegendsData = ({
8688
customLayers: BaseLayer["customLayers"];
8789
}) => {
8890
const locale = useLocale();
89-
const { data: wmsLayers, error: wmsError } = useWMSLayers();
90-
const { data: wmtsLayers, error: wmtsError } = useWMTSLayers();
91+
const wmsLayerConfigs = customLayers.filter((layer) => layer.type === "wms");
92+
const wmtsLayerConfigs = customLayers.filter(
93+
(layer) => layer.type === "wmts"
94+
);
95+
96+
const wmtsEndpoints = uniq(
97+
wmtsLayerConfigs.map((x) => x.endpoint ?? DEFAULT_WMTS_URL)
98+
);
99+
const wmsEndpoints = uniq(
100+
wmsLayerConfigs.map((x) => x.endpoint ?? DEFAULT_WMS_URL)
101+
);
102+
const { data: groupedLayers, error: customLayersError } = useWMTSorWMSLayers([
103+
...wmtsEndpoints,
104+
...wmsEndpoints,
105+
]);
106+
const { wms: wmsLayers, wmts: wmtsLayers } = groupedLayers ?? {
107+
wms: [],
108+
wmts: [],
109+
};
91110
const { data: legendsData, error: legendsError } = useFetchData({
92111
queryKey: [
93112
"custom-layers-legends",
@@ -140,6 +159,6 @@ const useLegendsData = ({
140159

141160
return {
142161
data: legendsData,
143-
error: wmsError ?? wmtsError ?? legendsError,
162+
error: customLayersError ?? legendsError,
144163
};
145164
};

app/charts/map/map.tsx

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { hexToRgba } from "@uiw/react-color";
1010
import { geoArea } from "d3-geo";
1111
import debounce from "lodash/debounce";
1212
import orderBy from "lodash/orderBy";
13+
import uniq from "lodash/uniq";
1314
import maplibreglRaw from "maplibre-gl";
1415
import { useEffect, useMemo, useRef, useState } from "react";
1516
import Map, { LngLatLike, MapboxEvent } from "react-map-gl";
@@ -29,8 +30,9 @@ import {
2930
import { MapState } from "@/charts/map/map-state";
3031
import { HoverObjectType, useMapTooltip } from "@/charts/map/map-tooltip";
3132
import { getMap, setMap } from "@/charts/map/ref";
32-
import { getWMSTile, useWMSLayers } from "@/charts/map/wms-utils";
33-
import { getWMTSTile, useWMTSLayers } from "@/charts/map/wmts-utils";
33+
import { useWMTSorWMSLayers } from "@/charts/map/wms-endpoint-utils";
34+
import { DEFAULT_WMS_URL, getWMSTile } from "@/charts/map/wms-utils";
35+
import { DEFAULT_WMTS_URL, getWMTSTile } from "@/charts/map/wmts-utils";
3436
import { useChartState } from "@/charts/shared/chart-state";
3537
import { useInteraction } from "@/charts/shared/use-interaction";
3638
import { useLimits } from "@/config-utils";
@@ -117,12 +119,20 @@ export const MapComponent = ({
117119
};
118120
}, [customLayers]);
119121

120-
const { data: wmsLayers } = useWMSLayers({
121-
pause: wmsCustomLayers.length === 0,
122-
});
123-
const { data: wmtsLayers } = useWMTSLayers({
124-
pause: wmtsCustomLayers.length === 0,
125-
});
122+
const wmsEndpoints = uniq(
123+
wmsCustomLayers.map((x) => x.endpoint ?? DEFAULT_WMS_URL)
124+
);
125+
const wmtsEndpoints = uniq(
126+
wmtsCustomLayers.map((x) => x.endpoint ?? DEFAULT_WMTS_URL)
127+
);
128+
const { data: groupedLayers } = useWMTSorWMSLayers([
129+
...wmsEndpoints,
130+
...wmtsEndpoints,
131+
]);
132+
const { wms: wmsLayers, wmts: wmtsLayers } = groupedLayers ?? {
133+
wms: [],
134+
wmts: [],
135+
};
126136
const { behindAreaCustomLayers, afterAreaCustomLayers } = useMemo(() => {
127137
return {
128138
behindAreaCustomLayers: customLayers

app/charts/map/mocks/README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
1. Get bio-discomap.xml
2+
3+
```
4+
curl
5+
'https://bio.discomap.eea.europa.eu/arcgis/services/Ecosystem/Ecosystems/MapServer/WMSServer?SERVICE=WMS&REQUEST=GetCapabilities&VERSION=1.3.0&FORMAT=text%2Fxml&lang=en'
6+
--compressed -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15;
7+
rv:137.0) Gecko/20100101 Firefox/137.0' -H 'Accept: application/json,
8+
text/plain, _/_' -H 'Accept-Language: en-US,en;q=0.5' -H 'Accept-Encoding: gzip,
9+
deflate, br, zstd' -H 'Origin: https://map.geo.admin.ch' -H 'Connection:
10+
keep-alive' -H 'Referer: https://map.geo.admin.ch/' -H 'Sec-Fetch-Dest: empty'
11+
-H 'Sec-Fetch-Mode: cors' -H 'Sec-Fetch-Site: cross-site' -H 'Priority: u=0' -H
12+
'Pragma: no-cache' -H 'Cache-Control: no-cache'
13+
```
14+
15+
2. Get geo-admin.wmts.xml
16+
17+
```
18+
curl 'https://wmts.geo.admin.ch/EPSG/3857/1.0.0/WMTSCapabilities.xml?SERVICE=WMTS&REQUEST=GetCapabilities&lang=en' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:137.0) Gecko/20100101 Firefox/137.0' -H 'Accept: application/json, text/plain, */*' -H 'Accept-Language: en-US,en;q=0.5' -H 'Accept-Encoding: gzip, deflate, br, zstd' -H 'Origin: https://map.geo.admin.ch' -H 'Connection: keep-alive' -H 'Referer: https://map.geo.admin.ch/' -H 'Sec-Fetch-Dest: empty' -H 'Sec-Fetch-Mode: cors' -H 'Sec-Fetch-Site: same-site' -H 'Priority: u=0' -H 'Pragma: no-cache' -H 'Cache-Control: no-cache' -H 'TE: trailers'
19+
```

0 commit comments

Comments
 (0)