mirror of
https://github.com/Findus23/vienna-cycling-quality.git
synced 2024-09-09 04:13:48 +02:00
very rough copy/paste state
This commit is contained in:
commit
3ef3c90156
38 changed files with 8370 additions and 0 deletions
18
.eslintrc.cjs
Normal file
18
.eslintrc.cjs
Normal file
|
@ -0,0 +1,18 @@
|
|||
module.exports = {
|
||||
root: true,
|
||||
env: { browser: true, es2020: true },
|
||||
extends: [
|
||||
'eslint:recommended',
|
||||
'plugin:@typescript-eslint/recommended',
|
||||
'plugin:react-hooks/recommended',
|
||||
],
|
||||
ignorePatterns: ['dist', '.eslintrc.cjs'],
|
||||
parser: '@typescript-eslint/parser',
|
||||
plugins: ['react-refresh'],
|
||||
rules: {
|
||||
'react-refresh/only-export-components': [
|
||||
'warn',
|
||||
{ allowConstantExport: true },
|
||||
],
|
||||
},
|
||||
}
|
24
.gitignore
vendored
Normal file
24
.gitignore
vendored
Normal file
|
@ -0,0 +1,24 @@
|
|||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
pnpm-debug.log*
|
||||
lerna-debug.log*
|
||||
|
||||
node_modules
|
||||
dist
|
||||
dist-ssr
|
||||
*.local
|
||||
|
||||
# Editor directories and files
|
||||
.vscode/*
|
||||
!.vscode/extensions.json
|
||||
.idea
|
||||
.DS_Store
|
||||
*.suo
|
||||
*.ntvs*
|
||||
*.njsproj
|
||||
*.sln
|
||||
*.sw?
|
202
LICENSE
Normal file
202
LICENSE
Normal file
|
@ -0,0 +1,202 @@
|
|||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
5
README.md
Normal file
5
README.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
# Vienna Cycling Quality
|
||||
|
||||
Porting the amazing [www.osm-verkehrswende.org](https://www.osm-verkehrswende.org/) Cycling Quality Index to Vienna
|
||||
|
||||
Based on the code by [@SupaplexOSM](https://github.com/SupaplexOSM) and [@tordans](https://github.com/tordans)
|
13
index.html
Normal file
13
index.html
Normal file
|
@ -0,0 +1,13 @@
|
|||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Vite + React + TS</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
<script type="module" src="/src/main.tsx"></script>
|
||||
</body>
|
||||
</html>
|
5886
package-lock.json
generated
Normal file
5886
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load diff
32
package.json
Normal file
32
package.json
Normal file
|
@ -0,0 +1,32 @@
|
|||
{
|
||||
"name": "test",
|
||||
"private": true,
|
||||
"version": "0.0.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "tsc && vite build",
|
||||
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
|
||||
"preview": "vite preview"
|
||||
},
|
||||
"dependencies": {
|
||||
"@nanostores/react": "^0.7.2",
|
||||
"@turf/turf": "^6.5.0",
|
||||
"maplibre-gl": "^4.1.1",
|
||||
"react": "^18.2.0",
|
||||
"react-dom": "^18.2.0",
|
||||
"react-map-gl": "^7.1.7"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/react": "^18.2.66",
|
||||
"@types/react-dom": "^18.2.22",
|
||||
"@typescript-eslint/eslint-plugin": "^7.2.0",
|
||||
"@typescript-eslint/parser": "^7.2.0",
|
||||
"@vitejs/plugin-react": "^4.2.1",
|
||||
"eslint": "^8.57.0",
|
||||
"eslint-plugin-react-hooks": "^4.6.0",
|
||||
"eslint-plugin-react-refresh": "^0.4.6",
|
||||
"typescript": "^5.2.2",
|
||||
"vite": "^5.2.0"
|
||||
}
|
||||
}
|
1
public/vite.svg
Normal file
1
public/vite.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
|
After Width: | Height: | Size: 1.5 KiB |
42
src/App.css
Normal file
42
src/App.css
Normal file
|
@ -0,0 +1,42 @@
|
|||
#root {
|
||||
max-width: 1280px;
|
||||
margin: 0 auto;
|
||||
padding: 2rem;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.logo {
|
||||
height: 6em;
|
||||
padding: 1.5em;
|
||||
will-change: filter;
|
||||
transition: filter 300ms;
|
||||
}
|
||||
.logo:hover {
|
||||
filter: drop-shadow(0 0 2em #646cffaa);
|
||||
}
|
||||
.logo.react:hover {
|
||||
filter: drop-shadow(0 0 2em #61dafbaa);
|
||||
}
|
||||
|
||||
@keyframes logo-spin {
|
||||
from {
|
||||
transform: rotate(0deg);
|
||||
}
|
||||
to {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: no-preference) {
|
||||
a:nth-of-type(2) .logo {
|
||||
animation: logo-spin infinite 20s linear;
|
||||
}
|
||||
}
|
||||
|
||||
.card {
|
||||
padding: 2em;
|
||||
}
|
||||
|
||||
.read-the-docs {
|
||||
color: #888;
|
||||
}
|
27
src/App.tsx
Normal file
27
src/App.tsx
Normal file
|
@ -0,0 +1,27 @@
|
|||
import * as turf from '@turf/turf'
|
||||
import type {LngLatBoundsLike} from 'react-map-gl/maplibre'
|
||||
import {CqiMap} from "./page_map/CqiMap.tsx";
|
||||
|
||||
function App() {
|
||||
|
||||
const berlinInnenstadtBbox = [13.08, 52.336, 13.76, 52.676] satisfies ReturnType<typeof turf.bbox>
|
||||
const maxBounds = turf.bbox(
|
||||
turf.buffer(turf.bboxPolygon(berlinInnenstadtBbox), 250, {
|
||||
units: 'meters',
|
||||
}),
|
||||
) as LngLatBoundsLike
|
||||
|
||||
const minZoom = 10
|
||||
|
||||
return (
|
||||
<>
|
||||
<CqiMap client:load maxBounds={maxBounds} minZoom={minZoom}/>
|
||||
<div className="absolute bottom-3 left-3 rounded bg-white/80 px-1 py-0.5 text-xs">
|
||||
Datenstand: 02.03.2024
|
||||
</div>
|
||||
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
export default App
|
86
src/BaseMap/BaseMap.tsx
Normal file
86
src/BaseMap/BaseMap.tsx
Normal file
|
@ -0,0 +1,86 @@
|
|||
import { useStore } from '@nanostores/react'
|
||||
import maplibregl from 'maplibre-gl'
|
||||
import 'maplibre-gl/dist/maplibre-gl.css'
|
||||
import * as pmtiles from 'pmtiles'
|
||||
import { useEffect, useState } from 'react'
|
||||
import { Map, type ViewStateChangeEvent } from 'react-map-gl/maplibre'
|
||||
import {
|
||||
$clickedMapData,
|
||||
$mapLoaded,
|
||||
$searchParams,
|
||||
paramMapParse,
|
||||
paramMapStringify,
|
||||
type MapSearchParam,
|
||||
type SearchParamBaseMap,
|
||||
} from './store'
|
||||
import { roundPositionForURL } from './utils/roundNumber'
|
||||
|
||||
type Props = {
|
||||
initialViewState: MapSearchParam
|
||||
interactiveLayerIds: string[]
|
||||
boxZoom?: boolean
|
||||
children: React.ReactNode
|
||||
}
|
||||
|
||||
export const BaseMap = ({ initialViewState, interactiveLayerIds, boxZoom, children }: Props) => {
|
||||
useEffect(() => {
|
||||
const protocol = new pmtiles.Protocol()
|
||||
maplibregl.addProtocol('pmtiles', protocol.tile)
|
||||
return () => {
|
||||
maplibregl.removeProtocol('pmtiles')
|
||||
}
|
||||
}, [])
|
||||
|
||||
const params = useStore($searchParams) as SearchParamBaseMap
|
||||
|
||||
const [cursorStyle, setCursorStyle] = useState('grab')
|
||||
|
||||
const setParamsMap = ({ latitude, longitude, zoom }: MapSearchParam) => {
|
||||
const mapParamsRounded = roundPositionForURL({ latitude, longitude, zoom })
|
||||
const mapParamString = paramMapStringify(mapParamsRounded)
|
||||
const replaceHistory = true
|
||||
$searchParams.open({ ...params, map: mapParamString }, replaceHistory)
|
||||
}
|
||||
|
||||
// Update ?map on zoom or pan of map
|
||||
const handleMoveEnd = (event: ViewStateChangeEvent) => {
|
||||
const { latitude, longitude, zoom } = event.viewState
|
||||
setParamsMap({ latitude, longitude, zoom })
|
||||
}
|
||||
|
||||
// Set ?map to `initialViewState` if no `map` present, yet
|
||||
useEffect(() => {
|
||||
if (params.map) return
|
||||
setParamsMap(initialViewState)
|
||||
}, [])
|
||||
|
||||
const latLngZoom = paramMapParse(params.map)
|
||||
|
||||
return (
|
||||
<Map
|
||||
initialViewState={{
|
||||
...initialViewState,
|
||||
zoom: latLngZoom.zoom || initialViewState.zoom,
|
||||
latitude: latLngZoom.latitude || initialViewState.latitude,
|
||||
longitude: latLngZoom.longitude || initialViewState.longitude,
|
||||
}}
|
||||
// Style: https://cloud.maptiler.com/maps/dataviz/
|
||||
mapStyle="https://api.maptiler.com/maps/dataviz/style.json?key=ur6Yh3ULc6QjatOYBgln"
|
||||
style={{ width: '100%', height: '100%' }}
|
||||
boxZoom={boxZoom || true}
|
||||
// hash
|
||||
// Set map state for <MapData>:
|
||||
onLoad={() => $mapLoaded.set(true)}
|
||||
// MapLocation
|
||||
onMoveEnd={handleMoveEnd}
|
||||
// Handle cursor and click:
|
||||
interactiveLayerIds={interactiveLayerIds}
|
||||
cursor={cursorStyle}
|
||||
onMouseEnter={() => setCursorStyle('pointer')}
|
||||
onMouseLeave={() => setCursorStyle('grab')}
|
||||
onClick={(event) => $clickedMapData.set(event.features)}
|
||||
>
|
||||
{children}
|
||||
</Map>
|
||||
)
|
||||
}
|
35
src/BaseMap/store.ts
Normal file
35
src/BaseMap/store.ts
Normal file
|
@ -0,0 +1,35 @@
|
|||
import { createSearchParams } from '@nanostores/router'
|
||||
import { atom } from 'nanostores'
|
||||
import type { LngLatBoundsLike, MapGeoJSONFeature } from 'react-map-gl/maplibre'
|
||||
|
||||
export const $mapLoaded = atom(false)
|
||||
export const $clickedMapData = atom<MapGeoJSONFeature[] | undefined>(undefined)
|
||||
|
||||
export type SearchParamBaseMap = {
|
||||
map: string
|
||||
}
|
||||
export type MapSearchParam = {
|
||||
longitude: number
|
||||
latitude: number
|
||||
zoom: number
|
||||
// https://maplibre.org/maplibre-gl-js/docs/API/classes/maplibregl.Map/#setmaxbounds
|
||||
maxBounds?: LngLatBoundsLike
|
||||
// https://maplibre.org/maplibre-gl-js/docs/API/classes/maplibregl.Map/#setminzoom
|
||||
minZoom?: number
|
||||
// https://maplibre.org/maplibre-gl-js/docs/API/classes/maplibregl.Map/#setmaxzoom
|
||||
maxZoom?: number
|
||||
}
|
||||
|
||||
export const $searchParams = createSearchParams()
|
||||
|
||||
export const paramMapStringify = ({ longitude, latitude, zoom }: MapSearchParam) => {
|
||||
return `${zoom}/${longitude}/${latitude}`
|
||||
}
|
||||
|
||||
export const paramMapParse = (query: string | undefined) => {
|
||||
return {
|
||||
zoom: query ? Number(query.split('/')[0]) : undefined,
|
||||
longitude: query ? Number(query.split('/')[1]) : undefined,
|
||||
latitude: query ? Number(query.split('/')[2]) : undefined,
|
||||
}
|
||||
}
|
8
src/BaseMap/utils/cleanupMapboxLayerJson.ts
Normal file
8
src/BaseMap/utils/cleanupMapboxLayerJson.ts
Normal file
|
@ -0,0 +1,8 @@
|
|||
export const cleanupMapboxLayerJson = (id: string, input: Record<string, any>[]) => {
|
||||
const output = input[0] || {}
|
||||
delete output?.['source']
|
||||
delete output?.['source-layer']
|
||||
delete output?.['layout']?.['visibility']
|
||||
output.id = id
|
||||
return output
|
||||
}
|
40
src/BaseMap/utils/debugLayerStyles.ts
Normal file
40
src/BaseMap/utils/debugLayerStyles.ts
Normal file
|
@ -0,0 +1,40 @@
|
|||
import { wrapFilterWithAll } from './wrapFilterWithAll'
|
||||
|
||||
export const debugLayerStyles = ({
|
||||
filter,
|
||||
}: {
|
||||
filter?: ['match', ['get', string], string[], boolean, boolean]
|
||||
}) => {
|
||||
return [
|
||||
{
|
||||
id: 'debugStyleLayerLine',
|
||||
type: 'line',
|
||||
paint: {
|
||||
'line-width': 10,
|
||||
'line-color': '#a21caf',
|
||||
'line-opacity': 0.6,
|
||||
},
|
||||
filter: wrapFilterWithAll(filter),
|
||||
},
|
||||
{
|
||||
id: 'debugStyleLayerCircle',
|
||||
type: 'circle',
|
||||
paint: {
|
||||
'circle-radius': 5,
|
||||
'circle-opacity': 0.6,
|
||||
'circle-color': '#701a75',
|
||||
},
|
||||
filter: wrapFilterWithAll(filter),
|
||||
},
|
||||
{
|
||||
id: 'debugStyleLayerFill',
|
||||
type: 'fill',
|
||||
paint: {
|
||||
'fill-color': '#a21caf',
|
||||
'fill-outline-color': '#701a75',
|
||||
'fill-opacity': 0.3,
|
||||
},
|
||||
filter: wrapFilterWithAll(filter),
|
||||
},
|
||||
]
|
||||
}
|
27
src/BaseMap/utils/roundNumber.ts
Normal file
27
src/BaseMap/utils/roundNumber.ts
Normal file
|
@ -0,0 +1,27 @@
|
|||
import type { MapSearchParam } from '../store'
|
||||
|
||||
export const roundNumber = (number: number | string, precision?: number) => {
|
||||
if (typeof number === 'string') {
|
||||
return Number.parseFloat(Number.parseFloat(number).toFixed(precision))
|
||||
} else {
|
||||
return Number.parseFloat(number.toFixed(precision))
|
||||
}
|
||||
}
|
||||
|
||||
const roundByZoom = (number: number | string, zoom: number) => {
|
||||
// Keep URL as clean as possible. Relevant zoom changes below 13 are in 3 digits; then 4; after 17+ we need 5.
|
||||
const latLngPrecisionByZoom = zoom >= 17 ? 5 : zoom < 13 ? 3 : 4
|
||||
|
||||
return roundNumber(number, latLngPrecisionByZoom)
|
||||
}
|
||||
|
||||
export const roundPositionForURL = ({ longitude, latitude, zoom }: MapSearchParam) => {
|
||||
longitude = roundByZoom(longitude, zoom)
|
||||
latitude = roundByZoom(latitude, zoom)
|
||||
zoom = roundNumber(zoom, 1)
|
||||
return {
|
||||
longitude,
|
||||
latitude,
|
||||
zoom,
|
||||
} satisfies MapSearchParam
|
||||
}
|
24
src/BaseMap/utils/wrapFilterWithAll.ts
Normal file
24
src/BaseMap/utils/wrapFilterWithAll.ts
Normal file
|
@ -0,0 +1,24 @@
|
|||
export const wrapFilterWithAll = (filterArray: any[] | undefined) => {
|
||||
let workingArray: typeof filterArray = []
|
||||
// Cleanup input: `[null]` becomes `[]`
|
||||
workingArray = filterArray?.filter(Boolean)
|
||||
// Cleanup input: `[]` becomes `undefined`
|
||||
if (workingArray?.length === 0) {
|
||||
workingArray = undefined // `[]` becomes `undefined`
|
||||
}
|
||||
|
||||
// Case: Input empty/undefined
|
||||
if (!workingArray) {
|
||||
return ['all']
|
||||
}
|
||||
|
||||
// Cleanup input: 'all's are removed
|
||||
workingArray = workingArray.filter((item) => !(typeof item === 'string' && item === 'all'))
|
||||
|
||||
// Case: Input is multi dimensional array of filters
|
||||
if (Array.isArray(workingArray[0])) {
|
||||
return ['all', workingArray].flat().filter(Boolean)
|
||||
}
|
||||
// Case: Input is only one filter
|
||||
return ['all', workingArray].filter(Boolean)
|
||||
}
|
1
src/assets/react.svg
Normal file
1
src/assets/react.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="35.93" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 228"><path fill="#00D8FF" d="M210.483 73.824a171.49 171.49 0 0 0-8.24-2.597c.465-1.9.893-3.777 1.273-5.621c6.238-30.281 2.16-54.676-11.769-62.708c-13.355-7.7-35.196.329-57.254 19.526a171.23 171.23 0 0 0-6.375 5.848a155.866 155.866 0 0 0-4.241-3.917C100.759 3.829 77.587-4.822 63.673 3.233C50.33 10.957 46.379 33.89 51.995 62.588a170.974 170.974 0 0 0 1.892 8.48c-3.28.932-6.445 1.924-9.474 2.98C17.309 83.498 0 98.307 0 113.668c0 15.865 18.582 31.778 46.812 41.427a145.52 145.52 0 0 0 6.921 2.165a167.467 167.467 0 0 0-2.01 9.138c-5.354 28.2-1.173 50.591 12.134 58.266c13.744 7.926 36.812-.22 59.273-19.855a145.567 145.567 0 0 0 5.342-4.923a168.064 168.064 0 0 0 6.92 6.314c21.758 18.722 43.246 26.282 56.54 18.586c13.731-7.949 18.194-32.003 12.4-61.268a145.016 145.016 0 0 0-1.535-6.842c1.62-.48 3.21-.974 4.76-1.488c29.348-9.723 48.443-25.443 48.443-41.52c0-15.417-17.868-30.326-45.517-39.844Zm-6.365 70.984c-1.4.463-2.836.91-4.3 1.345c-3.24-10.257-7.612-21.163-12.963-32.432c5.106-11 9.31-21.767 12.459-31.957c2.619.758 5.16 1.557 7.61 2.4c23.69 8.156 38.14 20.213 38.14 29.504c0 9.896-15.606 22.743-40.946 31.14Zm-10.514 20.834c2.562 12.94 2.927 24.64 1.23 33.787c-1.524 8.219-4.59 13.698-8.382 15.893c-8.067 4.67-25.32-1.4-43.927-17.412a156.726 156.726 0 0 1-6.437-5.87c7.214-7.889 14.423-17.06 21.459-27.246c12.376-1.098 24.068-2.894 34.671-5.345a134.17 134.17 0 0 1 1.386 6.193ZM87.276 214.515c-7.882 2.783-14.16 2.863-17.955.675c-8.075-4.657-11.432-22.636-6.853-46.752a156.923 156.923 0 0 1 1.869-8.499c10.486 2.32 22.093 3.988 34.498 4.994c7.084 9.967 14.501 19.128 21.976 27.15a134.668 134.668 0 0 1-4.877 4.492c-9.933 8.682-19.886 14.842-28.658 17.94ZM50.35 144.747c-12.483-4.267-22.792-9.812-29.858-15.863c-6.35-5.437-9.555-10.836-9.555-15.216c0-9.322 13.897-21.212 37.076-29.293c2.813-.98 5.757-1.905 8.812-2.773c3.204 10.42 7.406 21.315 12.477 32.332c-5.137 11.18-9.399 22.249-12.634 32.792a134.718 134.718 0 0 1-6.318-1.979Zm12.378-84.26c-4.811-24.587-1.616-43.134 6.425-47.789c8.564-4.958 27.502 2.111 47.463 19.835a144.318 144.318 0 0 1 3.841 3.545c-7.438 7.987-14.787 17.08-21.808 26.988c-12.04 1.116-23.565 2.908-34.161 5.309a160.342 160.342 0 0 1-1.76-7.887Zm110.427 27.268a347.8 347.8 0 0 0-7.785-12.803c8.168 1.033 15.994 2.404 23.343 4.08c-2.206 7.072-4.956 14.465-8.193 22.045a381.151 381.151 0 0 0-7.365-13.322Zm-45.032-43.861c5.044 5.465 10.096 11.566 15.065 18.186a322.04 322.04 0 0 0-30.257-.006c4.974-6.559 10.069-12.652 15.192-18.18ZM82.802 87.83a323.167 323.167 0 0 0-7.227 13.238c-3.184-7.553-5.909-14.98-8.134-22.152c7.304-1.634 15.093-2.97 23.209-3.984a321.524 321.524 0 0 0-7.848 12.897Zm8.081 65.352c-8.385-.936-16.291-2.203-23.593-3.793c2.26-7.3 5.045-14.885 8.298-22.6a321.187 321.187 0 0 0 7.257 13.246c2.594 4.48 5.28 8.868 8.038 13.147Zm37.542 31.03c-5.184-5.592-10.354-11.779-15.403-18.433c4.902.192 9.899.29 14.978.29c5.218 0 10.376-.117 15.453-.343c-4.985 6.774-10.018 12.97-15.028 18.486Zm52.198-57.817c3.422 7.8 6.306 15.345 8.596 22.52c-7.422 1.694-15.436 3.058-23.88 4.071a382.417 382.417 0 0 0 7.859-13.026a347.403 347.403 0 0 0 7.425-13.565Zm-16.898 8.101a358.557 358.557 0 0 1-12.281 19.815a329.4 329.4 0 0 1-23.444.823c-7.967 0-15.716-.248-23.178-.732a310.202 310.202 0 0 1-12.513-19.846h.001a307.41 307.41 0 0 1-10.923-20.627a310.278 310.278 0 0 1 10.89-20.637l-.001.001a307.318 307.318 0 0 1 12.413-19.761c7.613-.576 15.42-.876 23.31-.876H128c7.926 0 15.743.303 23.354.883a329.357 329.357 0 0 1 12.335 19.695a358.489 358.489 0 0 1 11.036 20.54a329.472 329.472 0 0 1-11 20.722Zm22.56-122.124c8.572 4.944 11.906 24.881 6.52 51.026c-.344 1.668-.73 3.367-1.15 5.09c-10.622-2.452-22.155-4.275-34.23-5.408c-7.034-10.017-14.323-19.124-21.64-27.008a160.789 160.789 0 0 1 5.888-5.4c18.9-16.447 36.564-22.941 44.612-18.3ZM128 90.808c12.625 0 22.86 10.235 22.86 22.86s-10.235 22.86-22.86 22.86s-22.86-10.235-22.86-22.86s10.235-22.86 22.86-22.86Z"></path></svg>
|
After Width: | Height: | Size: 4 KiB |
68
src/index.css
Normal file
68
src/index.css
Normal file
|
@ -0,0 +1,68 @@
|
|||
:root {
|
||||
font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
|
||||
line-height: 1.5;
|
||||
font-weight: 400;
|
||||
|
||||
color-scheme: light dark;
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
background-color: #242424;
|
||||
|
||||
font-synthesis: none;
|
||||
text-rendering: optimizeLegibility;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
||||
|
||||
a {
|
||||
font-weight: 500;
|
||||
color: #646cff;
|
||||
text-decoration: inherit;
|
||||
}
|
||||
a:hover {
|
||||
color: #535bf2;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
display: flex;
|
||||
place-items: center;
|
||||
min-width: 320px;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 3.2em;
|
||||
line-height: 1.1;
|
||||
}
|
||||
|
||||
button {
|
||||
border-radius: 8px;
|
||||
border: 1px solid transparent;
|
||||
padding: 0.6em 1.2em;
|
||||
font-size: 1em;
|
||||
font-weight: 500;
|
||||
font-family: inherit;
|
||||
background-color: #1a1a1a;
|
||||
cursor: pointer;
|
||||
transition: border-color 0.25s;
|
||||
}
|
||||
button:hover {
|
||||
border-color: #646cff;
|
||||
}
|
||||
button:focus,
|
||||
button:focus-visible {
|
||||
outline: 4px auto -webkit-focus-ring-color;
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: light) {
|
||||
:root {
|
||||
color: #213547;
|
||||
background-color: #ffffff;
|
||||
}
|
||||
a:hover {
|
||||
color: #747bff;
|
||||
}
|
||||
button {
|
||||
background-color: #f9f9f9;
|
||||
}
|
||||
}
|
10
src/main.tsx
Normal file
10
src/main.tsx
Normal file
|
@ -0,0 +1,10 @@
|
|||
import React from 'react'
|
||||
import ReactDOM from 'react-dom/client'
|
||||
import App from './App.tsx'
|
||||
import './index.css'
|
||||
|
||||
ReactDOM.createRoot(document.getElementById('root')!).render(
|
||||
<React.StrictMode>
|
||||
<App />
|
||||
</React.StrictMode>,
|
||||
)
|
45
src/page_map/CqiMap.tsx
Normal file
45
src/page_map/CqiMap.tsx
Normal file
|
@ -0,0 +1,45 @@
|
|||
import { $searchParams, type MapSearchParam } from '@components/BaseMap/store'
|
||||
import { useStore } from '@nanostores/react'
|
||||
import 'maplibre-gl/dist/maplibre-gl.css'
|
||||
import { NavigationControl } from 'react-map-gl/maplibre'
|
||||
import { MapInspector } from './MapInspector'
|
||||
import { MapSourceCqi } from './MapSourceCqi'
|
||||
import { validAnzeigeValues, type SearchParamsCqiMap } from './storeCqi'
|
||||
import { interactiveLayerIdsByGroup } from './layers/layers'
|
||||
import { Overlay } from './Overlay'
|
||||
|
||||
type Props = {
|
||||
maxBounds: MapSearchParam['maxBounds']
|
||||
minZoom: MapSearchParam['minZoom']
|
||||
maxZoom?: MapSearchParam['maxZoom']
|
||||
}
|
||||
|
||||
export const CqiMap = ({ maxBounds, minZoom, maxZoom }: Props) => {
|
||||
const params = useStore($searchParams) as SearchParamsCqiMap
|
||||
|
||||
// Guard against invalid "anzeige" param values
|
||||
if (!validAnzeigeValues.includes(params.anzeige)) {
|
||||
$searchParams.open({ ...params, ...{ anzeige: 'cqi' } })
|
||||
}
|
||||
|
||||
return (
|
||||
<BaseMap
|
||||
initialViewState={{
|
||||
longitude: 13.390386527027175,
|
||||
latitude: 52.5180225850377,
|
||||
zoom: 12,
|
||||
// Only pass the props if they are implicitly present
|
||||
// Needed to get rid of Astro's strict TS settings https://www.typescriptlang.org/tsconfig#exactOptionalPropertyTypes
|
||||
...(maxBounds ? { maxBounds } : {}),
|
||||
...(minZoom ? { minZoom } : {}),
|
||||
...(maxZoom ? { maxZoom } : {}),
|
||||
}}
|
||||
interactiveLayerIds={interactiveLayerIdsByGroup[params?.anzeige] || []}
|
||||
>
|
||||
<MapSourceCqi />
|
||||
<NavigationControl showCompass={false} position="top-right" />
|
||||
<MapInspector />
|
||||
<Overlay />
|
||||
</BaseMap>
|
||||
)
|
||||
}
|
101
src/page_map/MapInspector.tsx
Normal file
101
src/page_map/MapInspector.tsx
Normal file
|
@ -0,0 +1,101 @@
|
|||
import { $clickedMapData } from '@components/BaseMap/store'
|
||||
import { useStore } from '@nanostores/react'
|
||||
import { MapInspectorPrimaryInformation } from './inspector/MapInspectorPrimaryInformation'
|
||||
import {
|
||||
listStyledKeys,
|
||||
skipInspectorKeys,
|
||||
translationTagValues,
|
||||
translationsKey,
|
||||
} from './translations.const'
|
||||
import { MapInspectorValueAsList } from './inspector/MapInspectorValueAsList'
|
||||
|
||||
export const MapInspector = () => {
|
||||
const clickedMapData = useStore($clickedMapData)
|
||||
|
||||
if (!clickedMapData || !clickedMapData.length) return null
|
||||
|
||||
return (
|
||||
<section className="absolute inset-x-1 bottom-1 z-50 overflow-y-auto rounded-lg bg-gray-900 p-4 text-gray-50 shadow-xl sm:inset-x-auto sm:inset-y-2.5 sm:right-2.5 sm:w-96">
|
||||
<button
|
||||
onClick={() => $clickedMapData.set(undefined)}
|
||||
className="absolute right-2.5 top-2.5 z-10 rounded-full bg-white p-1.5 text-gray-900 hover:bg-gray-50 hover:shadow-lg"
|
||||
>
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 24 24"
|
||||
fill="currentColor"
|
||||
className="h-5 w-5"
|
||||
>
|
||||
<path
|
||||
fillRule="evenodd"
|
||||
d="M5.47 5.47a.75.75 0 011.06 0L12 10.94l5.47-5.47a.75.75 0 111.06 1.06L13.06 12l5.47 5.47a.75.75 0 11-1.06 1.06L12 13.06l-5.47 5.47a.75.75 0 01-1.06-1.06L10.94 12 5.47 6.53a.75.75 0 010-1.06z"
|
||||
clipRule="evenodd"
|
||||
/>
|
||||
</svg>
|
||||
|
||||
<span className="sr-only">Details ausblenden</span>
|
||||
</button>
|
||||
|
||||
{clickedMapData.map((feature) => {
|
||||
return (
|
||||
<div key={`${feature.properties.id}/${feature.properties.side}`} className="mt-8">
|
||||
<h2 className="text-lg">{feature.properties.name || feature.properties.id}</h2>
|
||||
<MapInspectorPrimaryInformation properties={feature.properties} />
|
||||
|
||||
<table className="w-full">
|
||||
<tbody>
|
||||
{Object.entries(feature.properties as Record<string, string | number>)
|
||||
.filter(([key, _]) => !skipInspectorKeys.includes(key))
|
||||
.map(([key, value]) => {
|
||||
const multipleValues =
|
||||
value &&
|
||||
typeof value === 'string' &&
|
||||
(value.includes(';') || Object.keys(listStyledKeys).includes(key))
|
||||
const translationTag = `${key}=${value}`
|
||||
|
||||
return (
|
||||
<tr key={key} className="border-b border-gray-800">
|
||||
<th className="py-1 text-left leading-tight">
|
||||
{translationsKey[key] || <code>{key}</code>}
|
||||
</th>
|
||||
<td className="w-full break-all py-1 pl-2 leading-tight">
|
||||
{typeof value === 'number' ? (
|
||||
<span>{value.toLocaleString()}</span>
|
||||
) : multipleValues ? (
|
||||
<MapInspectorValueAsList
|
||||
tagKey={key}
|
||||
tagValue={value}
|
||||
listStyle={listStyledKeys[key] || 'list'}
|
||||
/>
|
||||
) : translationTagValues[translationTag] ? (
|
||||
<span data-key={translationTag}>
|
||||
{translationTagValues[translationTag]}
|
||||
</span>
|
||||
) : (
|
||||
<div className="flex w-full items-center justify-between">
|
||||
<code>
|
||||
{typeof value === 'boolean' ? JSON.stringify(value) : value}
|
||||
</code>
|
||||
{typeof value === 'string' && value.includes('way/') && (
|
||||
<a
|
||||
href={`https://osm.org/${value}`}
|
||||
target="_blank"
|
||||
className="underline hover:decoration-2"
|
||||
>
|
||||
OSM
|
||||
</a>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</td>
|
||||
</tr>
|
||||
)
|
||||
})}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
)
|
||||
})}
|
||||
</section>
|
||||
)
|
||||
}
|
75
src/page_map/MapSourceCqi.tsx
Normal file
75
src/page_map/MapSourceCqi.tsx
Normal file
|
@ -0,0 +1,75 @@
|
|||
import { $clickedMapData, $searchParams } from '@components/BaseMap/store'
|
||||
import { useStore } from '@nanostores/react'
|
||||
import type { FilterSpecification } from 'maplibre-gl'
|
||||
import { Layer, Source } from 'react-map-gl/maplibre'
|
||||
import { wrapFilterWithAll } from '../../BaseMap/utils/wrapFilterWithAll'
|
||||
import { layerByGroups, layersSelected } from './layers/layers'
|
||||
import { $focus, type SearchParamsCqiMap } from './storeCqi'
|
||||
|
||||
export const MapSourceCqi = () => {
|
||||
const params = useStore($searchParams) as SearchParamsCqiMap
|
||||
const focus = useStore($focus)
|
||||
const mapData = useStore($clickedMapData)
|
||||
const mapDataIds = mapData?.map((feature) => feature.properties?.id) ?? []
|
||||
|
||||
// Debugging:
|
||||
// console.log(mapDataIds)
|
||||
// const map = useMap()
|
||||
// console.log(map.current?.getStyle())
|
||||
|
||||
const focusFilter = focus ? ['match', ['get', focus.key], focus.values, true, false] : null
|
||||
|
||||
return (
|
||||
<Source
|
||||
id="cqi"
|
||||
type="vector"
|
||||
url="pmtiles://https://atlas-tiles.s3.eu-central-1.amazonaws.com/cycling_quality_index.pmtiles"
|
||||
attribution="© OpenStreetMap"
|
||||
>
|
||||
{layersSelected.map((layer) => {
|
||||
return (
|
||||
<Layer
|
||||
key={layer.id}
|
||||
id={layer.id}
|
||||
source="cqi"
|
||||
source-layer="default"
|
||||
type={layer.type}
|
||||
paint={layer.paint}
|
||||
layout={layer.layout}
|
||||
filter={
|
||||
wrapFilterWithAll([
|
||||
focusFilter,
|
||||
...(layer.filter ? layer.filter : []),
|
||||
['in', 'id', ...mapDataIds],
|
||||
]) as FilterSpecification
|
||||
}
|
||||
/>
|
||||
)
|
||||
})}
|
||||
|
||||
{Object.entries(layerByGroups).map(([groupkey, groupLayers]) => {
|
||||
return groupLayers.map((layer) => {
|
||||
const visible = params?.anzeige === groupkey
|
||||
|
||||
return (
|
||||
<Layer
|
||||
key={layer.id}
|
||||
id={layer.id}
|
||||
source="cqi"
|
||||
source-layer="default"
|
||||
type={layer.type}
|
||||
paint={layer.paint}
|
||||
layout={{ visibility: visible ? 'visible' : 'none' }}
|
||||
filter={
|
||||
wrapFilterWithAll([
|
||||
focusFilter,
|
||||
...(layer.filter ? layer.filter : []),
|
||||
]) as FilterSpecification
|
||||
}
|
||||
/>
|
||||
)
|
||||
})
|
||||
})}
|
||||
</Source>
|
||||
)
|
||||
}
|
11
src/page_map/Overlay.tsx
Normal file
11
src/page_map/Overlay.tsx
Normal file
|
@ -0,0 +1,11 @@
|
|||
import { OverlayLayerSelection } from './OverlayLayerSelection'
|
||||
import { OverlayLegendAndFocus } from './OverlayLegendAndFocus'
|
||||
|
||||
export const Overlay = () => {
|
||||
return (
|
||||
<nav className="absolute left-6 top-6 flex flex-col rounded-md bg-white shadow">
|
||||
<OverlayLayerSelection />
|
||||
<OverlayLegendAndFocus />
|
||||
</nav>
|
||||
)
|
||||
}
|
87
src/page_map/OverlayLayerSelection.tsx
Normal file
87
src/page_map/OverlayLayerSelection.tsx
Normal file
|
@ -0,0 +1,87 @@
|
|||
import { $searchParams } from '@components/BaseMap/store'
|
||||
import { RadioGroup } from '@headlessui/react'
|
||||
import { useStore } from '@nanostores/react'
|
||||
import { useEffect, useState } from 'react'
|
||||
import { twJoin } from 'tailwind-merge'
|
||||
import { layerSelection } from './layers/layers'
|
||||
import { $focus, type SearchParamsCqiMap } from './storeCqi'
|
||||
|
||||
export const OverlayLayerSelection = () => {
|
||||
const params = useStore($searchParams)
|
||||
// TODO: I really don't get why we need this but something prevents the rerendering of the buttons so the active state is wrong. Did not find any AstroJS Docs on this. And we are doing what we are supposed to do with nanostores.
|
||||
const [localSelected, setLocalSelected] = useState<SearchParamsCqiMap['anzeige']>('cqi')
|
||||
|
||||
const setSelected = (value: string) => {
|
||||
$searchParams.open({ ...params, ...{ anzeige: value } })
|
||||
$focus.set(null)
|
||||
setLocalSelected(value as SearchParamsCqiMap['anzeige'])
|
||||
}
|
||||
|
||||
// Initialize URL with filter=none
|
||||
useEffect(() => {
|
||||
setSelected(params.anzeige || 'cqi')
|
||||
}, [])
|
||||
|
||||
const handleChange = (value: SearchParamsCqiMap['anzeige']) => {
|
||||
setSelected(value)
|
||||
}
|
||||
|
||||
return (
|
||||
<RadioGroup value={localSelected} onChange={handleChange}>
|
||||
<RadioGroup.Label className="sr-only">Filterung der Karte ändern</RadioGroup.Label>
|
||||
{layerSelection.map(({ key, name, description }) => (
|
||||
<RadioGroup.Option
|
||||
key={key}
|
||||
value={key}
|
||||
className={({ checked }) =>
|
||||
twJoin(
|
||||
// buttonIdx === 0 ? 'rounded-tl-md rounded-tr-md' : '-mt-px',
|
||||
'-mx-px -mt-px',
|
||||
// buttonIdx === buttons.length - 1 ? 'rounded-bl-md rounded-br-md' : '',
|
||||
checked ? 'z-10 border-emerald-200 bg-emerald-50' : 'border-gray-200',
|
||||
'relative flex w-full min-w-[19em] cursor-pointer border px-4 py-2.5 hover:bg-blue-50 focus:outline-none',
|
||||
)
|
||||
}
|
||||
>
|
||||
{({ active, checked }) => (
|
||||
<>
|
||||
<span
|
||||
className={twJoin(
|
||||
checked ? 'border-transparent bg-emerald-600' : 'border-gray-300 bg-white',
|
||||
active ? 'ring-2 ring-emerald-600 ring-offset-2' : '',
|
||||
'mt-0.5 flex h-4 w-4 shrink-0 cursor-pointer items-center justify-center rounded-full border ',
|
||||
)}
|
||||
aria-hidden="true"
|
||||
>
|
||||
<span className="h-1.5 w-1.5 rounded-full bg-white" />
|
||||
</span>
|
||||
<span className="ml-3 flex flex-col">
|
||||
<RadioGroup.Label
|
||||
as="div"
|
||||
className={twJoin(
|
||||
checked ? 'font-medium text-emerald-900' : 'font-normal text-gray-900',
|
||||
'text-sm',
|
||||
)}
|
||||
>
|
||||
{name}
|
||||
</RadioGroup.Label>
|
||||
|
||||
{checked && (
|
||||
<RadioGroup.Description
|
||||
as="span"
|
||||
className={twJoin(
|
||||
checked ? 'text-emerald-700' : 'text-gray-500',
|
||||
'block text-sm',
|
||||
)}
|
||||
>
|
||||
{description}
|
||||
</RadioGroup.Description>
|
||||
)}
|
||||
</span>
|
||||
</>
|
||||
)}
|
||||
</RadioGroup.Option>
|
||||
))}
|
||||
</RadioGroup>
|
||||
)
|
||||
}
|
129
src/page_map/OverlayLegendAndFocus.tsx
Normal file
129
src/page_map/OverlayLegendAndFocus.tsx
Normal file
|
@ -0,0 +1,129 @@
|
|||
import { $searchParams } from '@components/BaseMap/store'
|
||||
import { Disclosure } from '@headlessui/react'
|
||||
import { useStore } from '@nanostores/react'
|
||||
import { twJoin } from 'tailwind-merge'
|
||||
import { legendByGroups } from './layers/layers'
|
||||
import { $focus, type SearchParamsCqiMap } from './storeCqi'
|
||||
|
||||
export const OverlayLegendAndFocus = () => {
|
||||
const params = useStore($searchParams) as SearchParamsCqiMap
|
||||
const focus = useStore($focus)
|
||||
const curentLegendGroup = legendByGroups[params?.anzeige ?? 'cqi']
|
||||
|
||||
// const map = useMap()
|
||||
// console.log(map.current?.getStyle())
|
||||
|
||||
const smallScreen = typeof window !== 'undefined' && window.innerWidth < 1024
|
||||
|
||||
return (
|
||||
<Disclosure defaultOpen={!smallScreen}>
|
||||
{({ open }) => (
|
||||
<>
|
||||
<Disclosure.Button
|
||||
className={twJoin(
|
||||
'gap-1 px-2 py-2 text-sm hover:font-medium',
|
||||
smallScreen ? 'flex' : 'hidden',
|
||||
)}
|
||||
>
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
fill="none"
|
||||
viewBox="0 0 24 24"
|
||||
strokeWidth={1.5}
|
||||
stroke="currentColor"
|
||||
className={twJoin('h-5 w-5 transition-transform', open ? 'rotate-90 transform' : '')}
|
||||
>
|
||||
<path strokeLinecap="round" strokeLinejoin="round" d="m8.25 4.5 7.5 7.5-7.5 7.5" />
|
||||
</svg>
|
||||
Legende
|
||||
</Disclosure.Button>
|
||||
<Disclosure.Panel>
|
||||
{curentLegendGroup.map((legendGroup) => {
|
||||
return (
|
||||
<div key={`${params.anzeige}-${legendGroup.title}`}>
|
||||
<h2 className={legendGroup.primary ? 'sr-only' : 'px-2 pb-2 text-sm'}>
|
||||
{legendGroup.title}
|
||||
</h2>
|
||||
<ul
|
||||
className={twJoin(
|
||||
'group/legend space-y-2 px-2 pb-4 text-sm font-normal leading-4 text-gray-900',
|
||||
open && smallScreen ? '' : 'pt-4',
|
||||
)}
|
||||
>
|
||||
{legendGroup.legends.map((legend) => {
|
||||
const hasFocus = legend.filterConfig !== null
|
||||
return (
|
||||
<li
|
||||
key={`${legend.label}-${legend.color}`}
|
||||
className={twJoin(
|
||||
'flex items-center justify-between gap-2',
|
||||
hasFocus ? 'group/focus cursor-pointer' : '',
|
||||
)}
|
||||
onClick={() => {
|
||||
if (hasFocus && $focus) {
|
||||
if (JSON.stringify(focus) !== JSON.stringify(legend.filterConfig)) {
|
||||
$focus.set(legend.filterConfig)
|
||||
} else if (focus === null) {
|
||||
$focus.set(legend.filterConfig)
|
||||
} else {
|
||||
$focus.set(null)
|
||||
}
|
||||
}
|
||||
}}
|
||||
>
|
||||
<div className="items-top flex gap-2">
|
||||
<div
|
||||
className="mt-1 h-2 w-7 rounded-full"
|
||||
style={{ backgroundColor: legend.color }}
|
||||
/>
|
||||
<span>{legend.label}</span>
|
||||
</div>
|
||||
{hasFocus && (
|
||||
<button className="rounded-md border border-white p-1.5 text-gray-300 transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-white/75 group-hover/focus:border-gray-200 group-hover/focus:bg-blue-50 group-hover/legend:text-gray-800">
|
||||
{JSON.stringify(focus) === JSON.stringify(legend.filterConfig) ? (
|
||||
<svg
|
||||
// Heroicon Solid light-bulb
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 24 24"
|
||||
fill="currentColor"
|
||||
className="size-4"
|
||||
>
|
||||
<path d="M12 .75a8.25 8.25 0 0 0-4.135 15.39c.686.398 1.115 1.008 1.134 1.623a.75.75 0 0 0 .577.706c.352.083.71.148 1.074.195.323.041.6-.218.6-.544v-4.661a6.714 6.714 0 0 1-.937-.171.75.75 0 1 1 .374-1.453 5.261 5.261 0 0 0 2.626 0 .75.75 0 1 1 .374 1.452 6.712 6.712 0 0 1-.937.172v4.66c0 .327.277.586.6.545.364-.047.722-.112 1.074-.195a.75.75 0 0 0 .577-.706c.02-.615.448-1.225 1.134-1.623A8.25 8.25 0 0 0 12 .75Z" />
|
||||
<path
|
||||
fillRule="evenodd"
|
||||
d="M9.013 19.9a.75.75 0 0 1 .877-.597 11.319 11.319 0 0 0 4.22 0 .75.75 0 1 1 .28 1.473 12.819 12.819 0 0 1-4.78 0 .75.75 0 0 1-.597-.876ZM9.754 22.344a.75.75 0 0 1 .824-.668 13.682 13.682 0 0 0 2.844 0 .75.75 0 1 1 .156 1.492 15.156 15.156 0 0 1-3.156 0 .75.75 0 0 1-.668-.824Z"
|
||||
clipRule="evenodd"
|
||||
/>
|
||||
</svg>
|
||||
) : (
|
||||
<svg
|
||||
// Heroicon Outline light-bulb
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
fill="none"
|
||||
viewBox="0 0 24 24"
|
||||
strokeWidth={1.5}
|
||||
stroke="currentColor"
|
||||
className="size-4"
|
||||
>
|
||||
<path
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
d="M12 18v-5.25m0 0a6.01 6.01 0 0 0 1.5-.189m-1.5.189a6.01 6.01 0 0 1-1.5-.189m3.75 7.478a12.06 12.06 0 0 1-4.5 0m3.75 2.383a14.406 14.406 0 0 1-3 0M14.25 18v-.192c0-.983.658-1.823 1.508-2.316a7.5 7.5 0 1 0-7.517 0c.85.493 1.509 1.333 1.509 2.316V18"
|
||||
/>
|
||||
</svg>
|
||||
)}
|
||||
</button>
|
||||
)}
|
||||
</li>
|
||||
)
|
||||
})}
|
||||
</ul>
|
||||
</div>
|
||||
)
|
||||
})}
|
||||
</Disclosure.Panel>
|
||||
</>
|
||||
)}
|
||||
</Disclosure>
|
||||
)
|
||||
}
|
7
src/page_map/README.md
Normal file
7
src/page_map/README.md
Normal file
|
@ -0,0 +1,7 @@
|
|||
# Vector Tiles Style
|
||||
|
||||
Quelle: https://studio.mapbox.com/styles/osm-verkehrswende/clsx94szl009j01qo7zxte41t/edit/#17.42/52.49422/13.415105
|
||||
|
||||
# Vector Tiles Prozessieren
|
||||
|
||||
`npm run updateCqi`
|
86
src/page_map/inspector/MapInspectorPrimaryInformation.tsx
Normal file
86
src/page_map/inspector/MapInspectorPrimaryInformation.tsx
Normal file
|
@ -0,0 +1,86 @@
|
|||
import { $searchParams } from '@components/BaseMap/store'
|
||||
import { useStore } from '@nanostores/react'
|
||||
import { twJoin } from 'tailwind-merge'
|
||||
import { legendCqi } from '../layers/layersCqi'
|
||||
import { legendLts } from '../layers/layersLts'
|
||||
import type { SearchParamsCqiMap } from '../storeCqi'
|
||||
import { MapInspectorValueAsList } from './MapInspectorValueAsList'
|
||||
|
||||
type Props = {
|
||||
properties: GeoJSON.Feature['properties']
|
||||
}
|
||||
|
||||
export const MapInspectorPrimaryInformation = ({ properties }: Props) => {
|
||||
const params = useStore($searchParams) as SearchParamsCqiMap
|
||||
|
||||
if (!properties) {
|
||||
return null
|
||||
}
|
||||
|
||||
if (params.anzeige === 'cqi') {
|
||||
// Der index berechnet sich aus base_index (Basisindex entsprechend des Wegetyps) * fac_1 (Faktor für Breite und Oberfläche) * fac_2 (Faktor für Straßenklasse und Höchstgeschwindigkeit) * fac_3 (Faktor für Physische Trennung und Sicherheitsabstand, derzeit nicht implementiert und daher immer 1) * fac_4 (Sonstige auf- oder abwertende Umgebungsvariablen). Die einzelnen Faktoren wiederum basieren insbesondere auf den proc_*-Werten, also fac_1 z.B. auf proc_width und proc_surface. Da steckt aber viel Vodoo und Gewichtungen dahinter, daher ist mMn eigentlich höchstens die Anzeige der fac_1..4 sinnvoll.
|
||||
const color = legendCqi
|
||||
.find((group) => group.primary)
|
||||
?.legends?.find((l) => l.key === `index_${properties.index_10}`)?.color
|
||||
|
||||
return (
|
||||
<div
|
||||
className="my-2 flex items-center justify-center gap-1 rounded py-2 text-gray-950"
|
||||
style={{ backgroundColor: color }}
|
||||
>
|
||||
{properties.index != 1 && <>1…</>}
|
||||
<span className="text-2xl font-bold leading-tight">{String(properties.index)}</span>
|
||||
{properties.index != 100 && <>…100</>}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
if (params.anzeige === 'lts') {
|
||||
const displayLevels = [1, 2, 3, 4]
|
||||
return (
|
||||
<div className="my-2 flex justify-center gap-1">
|
||||
{displayLevels.map((displayLevel) => {
|
||||
const current = properties.stress_level === displayLevel
|
||||
const color = legendLts
|
||||
.find((group) => group.primary)
|
||||
?.legends.find((l) => l.key === `stress_level_${displayLevel}`)?.color
|
||||
|
||||
return (
|
||||
<div
|
||||
key={displayLevel}
|
||||
className={twJoin(
|
||||
'flex min-h-12 min-w-12 items-center justify-center rounded-full border-2 leading-tight',
|
||||
current
|
||||
? 'bg-gray-500 text-2xl font-bold text-gray-950'
|
||||
: 'bg-gray-900 text-xl text-gray-200',
|
||||
)}
|
||||
style={{
|
||||
backgroundColor: current ? color : undefined,
|
||||
borderColor: color,
|
||||
}}
|
||||
>
|
||||
{String(displayLevel)}
|
||||
</div>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
if (params.anzeige === 'incompleteness') {
|
||||
return (
|
||||
<div className="my-1 flex rounded bg-gray-950 p-2 text-base">
|
||||
{!properties.data_missing && <>Keine</>}
|
||||
{properties.data_missing && (
|
||||
<MapInspectorValueAsList
|
||||
tagKey={'data_missing'}
|
||||
tagValue={properties.data_missing}
|
||||
listStyle="questionmark"
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
51
src/page_map/inspector/MapInspectorValueAsList.tsx
Normal file
51
src/page_map/inspector/MapInspectorValueAsList.tsx
Normal file
|
@ -0,0 +1,51 @@
|
|||
import { translationTagValues } from '../translations.const'
|
||||
|
||||
export type ListStyleType = 'plus' | 'minus' | 'questionmark' | 'list'
|
||||
type Props = {
|
||||
tagKey: string
|
||||
tagValue: string
|
||||
listStyle: ListStyleType
|
||||
}
|
||||
|
||||
export const MapInspectorValueAsList = ({ tagKey, tagValue, listStyle }: Props) => {
|
||||
const values = tagValue.split(';')
|
||||
|
||||
return (
|
||||
<ul className={listStyle === 'list' ? 'ml-3 list-disc' : 'space-y-1'}>
|
||||
{values.map((singleValue) => {
|
||||
const translationTag = `${tagKey}=${singleValue}`
|
||||
return (
|
||||
<li
|
||||
key={translationTag}
|
||||
className={listStyle !== 'list' ? 'flex items-center gap-1' : ''}
|
||||
>
|
||||
{listStyle === 'plus' && (
|
||||
<span className="flex size-4 items-center justify-center rounded-full bg-gray-700 font-mono font-bold">
|
||||
+
|
||||
</span>
|
||||
)}
|
||||
{listStyle === 'minus' && (
|
||||
<span className="flex size-4 items-center justify-center rounded-full bg-gray-700 font-mono font-bold">
|
||||
-
|
||||
</span>
|
||||
)}
|
||||
{listStyle === 'questionmark' && (
|
||||
<span className="flex size-4 items-center justify-center rounded-full bg-gray-700 font-mono text-xs">
|
||||
?
|
||||
</span>
|
||||
)}
|
||||
{translationTagValues[translationTag] ? (
|
||||
<span data-key={translationTag}>{translationTagValues[translationTag]}</span>
|
||||
) : (
|
||||
<code data-key={translationTag}>
|
||||
<span>
|
||||
{typeof singleValue === 'boolean' ? JSON.stringify(singleValue) : singleValue}
|
||||
</span>
|
||||
</code>
|
||||
)}
|
||||
</li>
|
||||
)
|
||||
})}
|
||||
</ul>
|
||||
)
|
||||
}
|
91
src/page_map/layers/layers.ts
Normal file
91
src/page_map/layers/layers.ts
Normal file
|
@ -0,0 +1,91 @@
|
|||
import { cleanupMapboxLayerJson } from '../../../BaseMap/utils/cleanupMapboxLayerJson'
|
||||
import type { SearchParamsCqiMap } from '../storeCqi'
|
||||
import { layersCqi, legendCqi } from './layersCqi'
|
||||
import { layersIncompletness, legendIncompletness } from './layersIncompletness'
|
||||
import { layersLts, legendLts } from './layersLts'
|
||||
// import { layersLts, legendLts } from './layersLts'
|
||||
|
||||
export const layersSelected = [
|
||||
cleanupMapboxLayerJson('index_casing_selected', [
|
||||
{
|
||||
layout: {
|
||||
'line-cap': 'square',
|
||||
'line-sort-key': [
|
||||
'case',
|
||||
['match', ['get', 'proc_mandatory'], ['use_sidepath', 'optional_sidepath'], true, false],
|
||||
0,
|
||||
[
|
||||
'match',
|
||||
['get', 'way_type'],
|
||||
['bicycle road', 'shared bus lane', 'shared traffic lane', 'shared road'],
|
||||
true,
|
||||
false,
|
||||
],
|
||||
2,
|
||||
1,
|
||||
],
|
||||
visibility: 'none',
|
||||
},
|
||||
type: 'line',
|
||||
source: 'composite',
|
||||
id: 'index_casing_selected',
|
||||
paint: {
|
||||
'line-width': ['interpolate', ['linear'], ['zoom'], 0, 2.8, 10, 2.8, 22, 32],
|
||||
'line-offset': [
|
||||
'interpolate',
|
||||
['linear'],
|
||||
['zoom'],
|
||||
0,
|
||||
['match', ['get', 'side'], ['right'], 1, ['left'], -1, 0],
|
||||
10,
|
||||
['match', ['get', 'side'], ['right'], 1, ['left'], -1, 0],
|
||||
22,
|
||||
['match', ['get', 'side'], ['right'], 12, ['left'], -12, 0],
|
||||
],
|
||||
'line-color': 'rgb(41, 103, 118)',
|
||||
},
|
||||
'source-layer': 'cycling_quality_index_epsg432-4roq5v',
|
||||
},
|
||||
]),
|
||||
]
|
||||
|
||||
export const layerSelection: {
|
||||
key: SearchParamsCqiMap['anzeige']
|
||||
name: string
|
||||
description: null | string
|
||||
}[] = [
|
||||
{ key: 'cqi', name: 'Cycling Quality Index', description: 'Indexwerte 0 bis 100' },
|
||||
{ key: 'lts', name: 'Level of Traffic Stress', description: 'Stress Levels 1 bis 4' },
|
||||
{ key: 'incompleteness', name: 'Datenlücken', description: null },
|
||||
]
|
||||
|
||||
export const layerByGroups: Record<SearchParamsCqiMap['anzeige'], Record<string, any>[]> = {
|
||||
cqi: layersCqi,
|
||||
lts: layersLts,
|
||||
incompleteness: layersIncompletness,
|
||||
}
|
||||
|
||||
export type FilterConfig = {
|
||||
key: string
|
||||
values: (string | number)[]
|
||||
}
|
||||
|
||||
export type LegendGroup = { title: string; primary?: boolean; legends: Legend[] }
|
||||
type Legend = {
|
||||
key: string
|
||||
color: string
|
||||
label: string
|
||||
filterConfig: null | FilterConfig
|
||||
}
|
||||
|
||||
export const legendByGroups: Record<SearchParamsCqiMap['anzeige'], LegendGroup[]> = {
|
||||
cqi: legendCqi,
|
||||
lts: legendLts,
|
||||
incompleteness: legendIncompletness,
|
||||
}
|
||||
|
||||
export const interactiveLayerIdsByGroup = {
|
||||
cqi: ['index_casing'],
|
||||
lts: ['lts_casing'],
|
||||
incompleteness: ['incomp_casing'],
|
||||
}
|
451
src/page_map/layers/layersCqi.ts
Normal file
451
src/page_map/layers/layersCqi.ts
Normal file
|
@ -0,0 +1,451 @@
|
|||
import { cleanupMapboxLayerJson } from '../../../BaseMap/utils/cleanupMapboxLayerJson'
|
||||
import type { LegendGroup } from './layers'
|
||||
|
||||
export const layersCqi = [
|
||||
cleanupMapboxLayerJson('index_casing', [
|
||||
{
|
||||
layout: {
|
||||
'line-cap': 'round',
|
||||
'line-sort-key': [
|
||||
'case',
|
||||
['match', ['get', 'proc_mandatory'], ['use_sidepath', 'optional_sidepath'], true, false],
|
||||
0,
|
||||
[
|
||||
'match',
|
||||
['get', 'way_type'],
|
||||
['bicycle road', 'shared bus lane', 'shared traffic lane', 'shared road'],
|
||||
true,
|
||||
false,
|
||||
],
|
||||
2,
|
||||
1,
|
||||
],
|
||||
},
|
||||
type: 'line',
|
||||
source: 'composite',
|
||||
id: 'index_casing',
|
||||
paint: {
|
||||
'line-width': ['interpolate', ['linear'], ['zoom'], 0, 1.4, 10, 1.4, 22, 16],
|
||||
'line-offset': [
|
||||
'interpolate',
|
||||
['linear'],
|
||||
['zoom'],
|
||||
0,
|
||||
['match', ['get', 'side'], ['right'], 1, ['left'], -1, 0],
|
||||
10,
|
||||
['match', ['get', 'side'], ['right'], 1, ['left'], -1, 0],
|
||||
22,
|
||||
['match', ['get', 'side'], ['right'], 12, ['left'], -12, 0],
|
||||