Skip to content

Commit

Permalink
Prepare release 24.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Aschwanden committed Jan 28, 2024
2 parents 2402820 + 1370647 commit 0a837df
Show file tree
Hide file tree
Showing 8 changed files with 671 additions and 99 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"name": "sitrep",
"version": "24.1.0",
"version": "24.1.1",
"private": true,
"dependencies": {
"@apollo/client": "^3.8.10",
"@fortawesome/fontawesome-svg-core": "^6.5.1",
"@fortawesome/free-regular-svg-icons": "^6.5.1",
"@fortawesome/free-solid-svg-icons": "^6.5.1",
"@fortawesome/react-fontawesome": "^0.2.0",
"@mapbox/mapbox-gl-draw": "~1.3.0",
"@mapbox/mapbox-gl-draw": "^1.3.0",
"@svgr/webpack": "^8.1.0",
"@testing-library/dom": "^9.3.4",
"@turf/bearing": "^6.5.0",
Expand Down
2 changes: 1 addition & 1 deletion public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Content-Security-Policy"
content="default-src 'self'; img-src 'self' data:; style-src 'self' 'unsafe-inline'; style-src-attr 'self'; child-src 'none'; worker-src 'self' blob:; script-src-elem 'self' https://api.mapbox.com; connect-src 'self' ws://* wss://* https://api.mapbox.com https://api.mapbox.com https://vectortiles.geo.admin.ch https://vectortiles0.geo.admin.ch https://vectortiles1.geo.admin.ch https://vectortiles2.geo.admin.ch https://vectortiles3.geo.admin.ch https://vectortiles4.geo.admin.ch https://wmts.geo.admin.ch https://wms.geo.admin.ch;" />
content="default-src 'self'; img-src 'self' data:; style-src 'self' 'unsafe-inline'; style-src-attr 'self'; child-src 'none'; worker-src 'self' blob:; script-src-elem 'self' https://api.mapbox.com; connect-src 'self' ws://* wss://* https://*;" />
<meta name="description" content="SitRep" />
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
Expand Down
134 changes: 134 additions & 0 deletions src/components/map/EnrichedLayerFeatures.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
import bearing from '@turf/bearing';
import { point } from '@turf/helpers';
import { BabsIcon, Schaeden, Others } from 'components/BabsIcons';
import { Feature, FeatureCollection, GeoJsonProperties, Geometry } from 'geojson';
import { Layer, Source } from "react-map-gl";

const enrichFeature = (f: Feature<Geometry, GeoJsonProperties>): Feature<Geometry, GeoJsonProperties>[] => {

if (f === undefined) {
return []
}

let features: Feature<Geometry, GeoJsonProperties>[] = [];

if (f.geometry.type === "LineString") {
let enrich: EnrichLineConfig | undefined = EnrichLineStringMap[f.properties?.lineType]
if (enrich !== undefined) {
if (enrich.iconStart) {
let startPoint = point(f.geometry.coordinates[0]);
startPoint.id = f.id + ":start";
startPoint.properties = {
parent: f.id,
icon: enrich.iconStart.name,
iconRotation: bearing(point(f.geometry.coordinates[0]), point(f.geometry.coordinates[1])) + enrich.iconRotation,
}
features.push(startPoint)
}

if (enrich.iconEnd) {
let endPoint = point(f.geometry.coordinates.slice(-1)[0]);
endPoint.id = f.id + ":end";
endPoint.properties = {
parent: f.id,
icon: enrich.iconEnd.name,
iconRotation: bearing(f.geometry.coordinates.slice(-1)[0], point(f.geometry.coordinates.slice(-2)[0])) + enrich.iconRotation,
};
features.push(endPoint);
}
}
}

return features
}

type EnrichLineConfig = {
iconStart?: BabsIcon;
iconEnd?: BabsIcon;
iconRotation: number;
}

const EnrichLineStringMap: { [key: string]: EnrichLineConfig } = {
"begehbar": {
iconStart: Schaeden.Beschaedigung,
iconEnd: Schaeden.Beschaedigung,
iconRotation: 90,
},
"schwerBegehbar": {
iconStart: Schaeden.Teilzerstoerung,
iconEnd: Schaeden.Teilzerstoerung,
iconRotation: 90,
},
"unpassierbar": {
iconStart: Schaeden.Totalzerstoerung,
iconEnd: Schaeden.Totalzerstoerung,
iconRotation: 90,
},
"beabsichtigteErkundung": {
iconStart: undefined,
iconEnd: Others.Verschiebung,
iconRotation: 90,
},
"durchgeführteErkundung": {
iconStart: undefined,
iconEnd: Others.Verschiebung,
iconRotation: 90,
},
"beabsichtigteVerschiebung": {
iconStart: undefined,
iconEnd: Others.Verschiebung,
iconRotation: 90,
},
"rettungsAchse": {
iconStart: undefined,
iconEnd: Others.Verschiebung,
iconRotation: 90,
},
"durchgeführteVerschiebung": {
iconStart: undefined,
iconEnd: Others.Verschiebung,
iconRotation: 90,
},
"beabsichtigterEinsatz": {
iconStart: undefined,
iconEnd: Others.Einsatz,
iconRotation: 90,
},
"durchgeführterEinsatz": {
iconStart: undefined,
iconEnd: Others.Einsatz,
iconRotation: 90,
},
}



const EnrichedSymbolSource = (props: EnrichedFeaturesProps) => {
let enrichedFC: FeatureCollection = { "type": "FeatureCollection", "features": [] };
enrichedFC.features = Object.assign([], props.featureCollection.features.filter(f => f.properties?.deletedAt === undefined).filter(f => f.id !== props.selectedFeature).flatMap(f => enrichFeature(f)))

return <Source id="enriched" type="geojson" data={enrichedFC} >
<Layer type="symbol" layout={{
'icon-image': ['coalesce', ["get", "icon"], 'default_marker'],
'icon-allow-overlap': true,
'icon-size': ['interpolate', ['linear'], ['zoom'], 12, 0.1, 17, 1],
'icon-rotation-alignment': 'map',
'icon-pitch-alignment': 'map',
'icon-rotate': ['coalesce', ["get", "iconRotation"], 0]
}} />
</Source>
}

export const EnrichedFeaturesSource = (props: EnrichedFeaturesProps) => {

return <>
<EnrichedSymbolSource {...props} />
</>
}

interface EnrichedFeaturesProps {
featureCollection: FeatureCollection;
selectedFeature: string | number | undefined
}

export default EnrichedFeaturesSource;
28 changes: 14 additions & 14 deletions src/views/map/FeatureDetails.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import bearing from "@turf/bearing";
import { LineString, point } from "@turf/helpers";
import { BabsIcon, IconGroups, Others, Schaeden } from "components/BabsIcons";
import { BabsIcon, IconGroups, } from "components/BabsIcons";
import { Feature, GeoJsonProperties } from "geojson";
import { isEmpty, isUndefined, omitBy } from "lodash";
import { SetStateAction, memo, useCallback, useEffect, useState } from "react";
Expand Down Expand Up @@ -79,7 +79,7 @@ function FeatureDetail(props: { onUpdate: (e: any) => void, feature: Feature | u

return (
<div>
<h3 className='title is-size-5'>Eigenschaften</h3>
< h3 className='title is-size-5' > Eigenschaften</h3 >
{feature && feature.geometry.type === "Point" ?
<div className="field is-horizontal">
<div className="field-label is-normal">
Expand Down Expand Up @@ -184,40 +184,40 @@ const ZoneTypes: SelectableTypes = {

const LineTypes: SelectableTypes = {
"Rutschgebiet": {
name: "Rutschgebiet", description: "Rutschgebiet", color: Colors.Red, icon: undefined,
name: "Rutschgebiet", description: "Rutschgebiet", color: Colors.Red,
},
"RutschgebietGespiegelt": {
name: "RutschgebietGespiegelt", description: "Rutschgebiet (umgekehrt)", color: Colors.Red, icon: undefined,
name: "RutschgebietGespiegelt", description: "Rutschgebiet (umgekehrt)", color: Colors.Red,
},
"begehbar": {
name: "begehbar", description: "Strasse erschwert befahrbar / begehbar", color: Colors.Red, icon: Schaeden.Beschaedigung,
name: "begehbar", description: "Strasse erschwert befahrbar / begehbar", color: Colors.Red,
},
"schwerBegehbar": {
name: "schwerBegehbar", description: "Strasse nicht befahrbar / schwer Begehbar", color: Colors.Red, icon: Schaeden.Teilzerstoerung,
name: "schwerBegehbar", description: "Strasse nicht befahrbar / schwer Begehbar", color: Colors.Red,
},
"unpassierbar": {
name: "unpassierbar", description: "Strasse unpassierbar / gesperrt", color: Colors.Red, icon: Schaeden.Totalzerstoerung,
name: "unpassierbar", description: "Strasse unpassierbar / gesperrt", color: Colors.Red,
},
"beabsichtigteErkundung": {
name: "beabsichtigteErkundung", description: "Beabsichtigte Erkundung", color: Colors.Blue, icon: Others.Verschiebung,
name: "beabsichtigteErkundung", description: "Beabsichtigte Erkundung", color: Colors.Blue,
},
"durchgeführteErkundung": {
name: "durchgeführteErkundung", description: "Durchgeführte Erkundung", color: Colors.Blue, icon: Others.Verschiebung,
name: "durchgeführteErkundung", description: "Durchgeführte Erkundung", color: Colors.Blue,
},
"beabsichtigteVerschiebung": {
name: "beabsichtigteVerschiebung", description: "Beabsichtigte Verschiebung", color: Colors.Blue, icon: Others.Verschiebung,
name: "beabsichtigteVerschiebung", description: "Beabsichtigte Verschiebung", color: Colors.Blue,
},
"rettungsAchse": {
name: "rettungsAchse", description: "Rettungs Achse", color: Colors.Blue, icon: Others.Verschiebung,
name: "rettungsAchse", description: "Rettungs Achse", color: Colors.Blue,
},
"durchgeführteVerschiebung": {
name: "durchgeführteVerschiebung", description: "Durchgeführte Verschiebung", color: Colors.Blue, icon: Others.Verschiebung,
name: "durchgeführteVerschiebung", description: "Durchgeführte Verschiebung", color: Colors.Blue,
},
"beabsichtigterEinsatz": {
name: "beabsichtigterEinsatz", description: "Beabsichtigter Einsatz", color: Colors.Blue, icon: Others.Einsatz,
name: "beabsichtigterEinsatz", description: "Beabsichtigter Einsatz", color: Colors.Blue,
},
"durchgeführterEinsatz": {
name: "durchgeführterEinsatz", description: "Durchgeführter Einsatz", color: Colors.Blue, icon: Others.Einsatz,
name: "durchgeführterEinsatz", description: "Durchgeführter Einsatz", color: Colors.Blue,
},
};

Expand Down
Loading

0 comments on commit 0a837df

Please sign in to comment.