Add dataset docs, source credits and run script (#4)
- docs/datasets.md: overview of all sources with Mermaid diagrams, plus one page per dataset in docs/datasets/ (source, licence, fetch, refresh, cache, flowchart) - CLAUDE.md: mandatory rule to keep the dataset docs up to date - Map footers credit title, publisher and licence link of every source as required by CC BY 4.0, plus swisstopo and the processing applied - run.ps1 builds the client and starts the server Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Claudio Schaad <c.schaad@pog.ch> Co-committed-by: Claudio Schaad <c.schaad@pog.ch>
This commit is contained in:
parent
688775e742
commit
6a6b3a88c5
19 changed files with 464 additions and 22 deletions
|
|
@ -5,6 +5,10 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
|
||||||
## Commands
|
## Commands
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
# Build the client and start the server in one go (PowerShell; -SkipClient, -Install)
|
||||||
|
.
|
||||||
|
un.ps1
|
||||||
|
|
||||||
# Backend (ASP.NET Core 10) — API + static client at http://localhost:5080
|
# Backend (ASP.NET Core 10) — API + static client at http://localhost:5080
|
||||||
dotnet build
|
dotnet build
|
||||||
dotnet run --project Schaad.OpenData.Server --launch-profile http
|
dotnet run --project Schaad.OpenData.Server --launch-profile http
|
||||||
|
|
@ -24,7 +28,7 @@ npm run format # prettier
|
||||||
docker compose up --build # http://localhost:8080, data in volume opendatavisualizer-data
|
docker compose up --build # http://localhost:8080, data in volume opendatavisualizer-data
|
||||||
```
|
```
|
||||||
|
|
||||||
There is no lint step besides `tsc` (strict, no unused locals/parameters). `dotnet build` with the server running fails on locked DLLs; build or test only `Schaad.OpenData.Tests` in that case.
|
There is no lint step besides `tsc` (strict, no unused locals/parameters). `dotnet build` with the server running fails on locked DLLs; build or test only `Schaad.OpenData.Tests` in that case. The server serves the client from `Schaad.OpenData.Server/wwwroot` (gitignored), which `dotnet run` does not rebuild: after client changes run `npm run build` or `run.ps1`.
|
||||||
|
|
||||||
## Architecture
|
## Architecture
|
||||||
|
|
||||||
|
|
@ -110,6 +114,7 @@ Brand counts only include the group `Personenwagen`, with `Andere` always last.
|
||||||
|
|
||||||
## Conventions
|
## Conventions
|
||||||
|
|
||||||
|
- **Keep the dataset docs up to date (mandatory):** every change that adds a dataset or map, or changes where data comes from, how it is fetched, how often it is refreshed or where it is cached, must update the docs in the same change. Each dataset has its own file in `docs/datasets/` (source, publisher, licence, fetch, refresh, cache, code, Mermaid flowchart, notes); a new dataset gets a new file with the same structure. `docs/datasets.md` is the overview: update its overview diagram and add or change the dataset's table row, linked to its file. Write in German, like the existing pages, and check the Mermaid syntax renders (quote labels containing `{}`, `()` or `/`).
|
||||||
- C#: `var`, primary constructors, file-scoped namespaces, one type per file, no comments, `DateOnly` for dates, central package versions in `Directory.Packages.props`, shared settings in `Directory.Build.props`.
|
- C#: `var`, primary constructors, file-scoped namespaces, one type per file, no comments, `DateOnly` for dates, central package versions in `Directory.Packages.props`, shared settings in `Directory.Build.props`.
|
||||||
- Classes that tests need to mock (`SwisstopoClient`, `StationGeometryService`, `ThurgauTrafficClient`, `TrafficCacheStorage`, `ThurgauWatercraftClient`, `WatercraftCacheStorage`, `ThurgauVehicleClient`, `MunicipalityBoundaryClient`, `VehicleCacheStorage`) use `virtual` methods instead of single-implementation interfaces.
|
- Classes that tests need to mock (`SwisstopoClient`, `StationGeometryService`, `ThurgauTrafficClient`, `TrafficCacheStorage`, `ThurgauWatercraftClient`, `WatercraftCacheStorage`, `ThurgauVehicleClient`, `MunicipalityBoundaryClient`, `VehicleCacheStorage`) use `virtual` methods instead of single-implementation interfaces.
|
||||||
- Tests: one `<Subject>TestShould` class per subject, method names `DoThisWhenThat`, Shouldly assertions (no `Assert.*`). HTTP clients are tested with a stub `HttpMessageHandler`, storage with a temp directory cleaned up in `Dispose`.
|
- Tests: one `<Subject>TestShould` class per subject, method names `DoThisWhenThat`, Shouldly assertions (no `Assert.*`). HTTP clients are tested with a stub `HttpMessageHandler`, storage with a temp directory cleaned up in `Dispose`.
|
||||||
|
|
|
||||||
11
README.md
11
README.md
|
|
@ -39,4 +39,15 @@ docker compose up --build
|
||||||
|
|
||||||
Then open http://localhost:8080. On the first start the app downloads the data from data.tg.ch and builds the road geometry (one to two minutes); it is cached in the `opendatavisualizer-data` volume and refreshed every six hours. Since data.tg.ch only serves the last two weeks, the cache keeps growing over time.
|
Then open http://localhost:8080. On the first start the app downloads the data from data.tg.ch and builds the road geometry (one to two minutes); it is cached in the `opendatavisualizer-data` volume and refreshed every six hours. Since data.tg.ch only serves the last two weeks, the cache keeps growing over time.
|
||||||
|
|
||||||
|
Without Docker (needs Node.js and the .NET 10 SDK), build the client and start the server with
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
.
|
||||||
|
un.ps1
|
||||||
|
```
|
||||||
|
|
||||||
|
and open http://localhost:5080. `-SkipClient` starts the server without rebuilding the client.
|
||||||
|
|
||||||
|
Where each dataset comes from and how it is downloaded and refreshed is described in [docs/datasets.md](docs/datasets.md), with one page per dataset in [docs/datasets/](docs/datasets/).
|
||||||
|
|
||||||
For development see [CLAUDE.md](CLAUDE.md).
|
For development see [CLAUDE.md](CLAUDE.md).
|
||||||
|
|
|
||||||
|
|
@ -15,10 +15,13 @@ public static class VehicleEndpoints
|
||||||
var overview = VehicleAnalysis.BuildOverview(snapshot);
|
var overview = VehicleAnalysis.BuildOverview(snapshot);
|
||||||
return new VehicleMetaResponse(
|
return new VehicleMetaResponse(
|
||||||
"Strassenfahrzeugbestand nach Fahrzeuggruppe, Fahrzeugart, Marke und Politischer Gemeinde ab 2023",
|
"Strassenfahrzeugbestand nach Fahrzeuggruppe, Fahrzeugart, Marke und Politischer Gemeinde ab 2023",
|
||||||
"Strassenverkehrsamt Kanton Thurgau (data.tg.ch / opendata.swiss)",
|
"Strassenverkehrsamt Kanton Thurgau",
|
||||||
"https://opendata.swiss/de/dataset/strassenfahrzeugbestand-nach-fahrzeuggruppe-fahrzeugart-marke-und-politischer-gemeinde-ab-2023",
|
"https://opendata.swiss/de/dataset/strassenfahrzeugbestand-nach-fahrzeuggruppe-fahrzeugart-marke-und-politischer-gemeinde-ab-2023",
|
||||||
"CC BY 4.0",
|
"CC BY 4.0",
|
||||||
|
"Ständige Wohnbevölkerung der Thurgauer Gemeinden",
|
||||||
|
"Amt für Daten und Statistik Kanton Thurgau",
|
||||||
"https://data.tg.ch/explore/dataset/sk-stat-56/",
|
"https://data.tg.ch/explore/dataset/sk-stat-56/",
|
||||||
|
"CC BY 4.0",
|
||||||
overview.Years,
|
overview.Years,
|
||||||
overview.Groups,
|
overview.Groups,
|
||||||
overview.Types,
|
overview.Types,
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,10 @@ public sealed record VehicleMetaResponse(
|
||||||
string Publisher,
|
string Publisher,
|
||||||
string SourceUrl,
|
string SourceUrl,
|
||||||
string License,
|
string License,
|
||||||
|
string PopulationTitle,
|
||||||
|
string PopulationPublisher,
|
||||||
string PopulationSourceUrl,
|
string PopulationSourceUrl,
|
||||||
|
string PopulationLicense,
|
||||||
IReadOnlyList<VehicleYearInfo> Years,
|
IReadOnlyList<VehicleYearInfo> Years,
|
||||||
IReadOnlyList<string> Groups,
|
IReadOnlyList<string> Groups,
|
||||||
IReadOnlyList<VehicleTypeInfo> Types,
|
IReadOnlyList<VehicleTypeInfo> Types,
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ public static class WatercraftEndpoints
|
||||||
var overview = WatercraftAnalysis.BuildOverview(snapshot);
|
var overview = WatercraftAnalysis.BuildOverview(snapshot);
|
||||||
return new WatercraftMetaResponse(
|
return new WatercraftMetaResponse(
|
||||||
"Bestand der bei der Schifffahrtskontrolle des Kantons Thurgau immatrikulierten Wasserfahrzeuge",
|
"Bestand der bei der Schifffahrtskontrolle des Kantons Thurgau immatrikulierten Wasserfahrzeuge",
|
||||||
"Kantonspolizei Thurgau, Schifffahrtskontrolle (data.tg.ch / opendata.swiss)",
|
"Kantonspolizei Thurgau, Schifffahrtskontrolle",
|
||||||
"https://opendata.swiss/de/dataset/bestand-der-bei-der-schifffahrtskontrolle-des-kantons-thurgau-immatrikulierten-wasserfahrz-2023",
|
"https://opendata.swiss/de/dataset/bestand-der-bei-der-schifffahrtskontrolle-des-kantons-thurgau-immatrikulierten-wasserfahrz-2023",
|
||||||
"CC BY 4.0",
|
"CC BY 4.0",
|
||||||
overview.Years,
|
overview.Years,
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,10 @@ export interface VehicleMeta {
|
||||||
publisher: string;
|
publisher: string;
|
||||||
sourceUrl: string;
|
sourceUrl: string;
|
||||||
license: string;
|
license: string;
|
||||||
|
populationTitle: string;
|
||||||
|
populationPublisher: string;
|
||||||
populationSourceUrl: string;
|
populationSourceUrl: string;
|
||||||
|
populationLicense: string;
|
||||||
years: VehicleYearInfo[];
|
years: VehicleYearInfo[];
|
||||||
groups: string[];
|
groups: string[];
|
||||||
types: VehicleType[];
|
types: VehicleType[];
|
||||||
|
|
|
||||||
33
client/src/components/DatasetCredit.tsx
Normal file
33
client/src/components/DatasetCredit.tsx
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
const LICENSE_URLS: Record<string, string> = {
|
||||||
|
'CC BY 4.0': 'https://creativecommons.org/licenses/by/4.0/deed.de',
|
||||||
|
'CC0 1.0': 'https://creativecommons.org/publicdomain/zero/1.0/deed.de',
|
||||||
|
};
|
||||||
|
|
||||||
|
interface DatasetCreditProps {
|
||||||
|
title: string;
|
||||||
|
publisher: string;
|
||||||
|
url: string;
|
||||||
|
license: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function DatasetCredit({ title, publisher, url, license }: DatasetCreditProps) {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<a href={url} target="_blank" rel="noreferrer">
|
||||||
|
«{title}»
|
||||||
|
</a>
|
||||||
|
, {publisher}, <LicenseLink license={license} />
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function LicenseLink({ license }: { license: string }) {
|
||||||
|
const url = LICENSE_URLS[license.trim().toUpperCase()];
|
||||||
|
return url ? (
|
||||||
|
<a href={url} target="_blank" rel="noreferrer">
|
||||||
|
{license}
|
||||||
|
</a>
|
||||||
|
) : (
|
||||||
|
<>{license}</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
@ -2,6 +2,7 @@ import { keepPreviousData, useQuery } from '@tanstack/react-query';
|
||||||
import { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
import { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
import { fetchDay, fetchMeta, fetchStations } from '../api/traffic';
|
import { fetchDay, fetchMeta, fetchStations } from '../api/traffic';
|
||||||
|
import { LicenseLink } from '../components/DatasetCredit';
|
||||||
import { Legend } from '../components/Legend';
|
import { Legend } from '../components/Legend';
|
||||||
import { StationPanel } from '../components/StationPanel';
|
import { StationPanel } from '../components/StationPanel';
|
||||||
import { SPEEDS, TimeControls } from '../components/TimeControls';
|
import { SPEEDS, TimeControls } from '../components/TimeControls';
|
||||||
|
|
@ -178,7 +179,8 @@ export function TrafficThurgauPage() {
|
||||||
<a href={metaQuery.data?.sourceUrl} target="_blank" rel="noreferrer">
|
<a href={metaQuery.data?.sourceUrl} target="_blank" rel="noreferrer">
|
||||||
{metaQuery.data?.publisher ?? 'Kanton Thurgau'}
|
{metaQuery.data?.publisher ?? 'Kanton Thurgau'}
|
||||||
</a>{' '}
|
</a>{' '}
|
||||||
· Lizenz {metaQuery.data?.license ?? 'CC0 1.0'}
|
· Lizenz <LicenseLink license={metaQuery.data?.license ?? 'CC0 1.0'} /> · Karten und
|
||||||
|
Strassennetz © swisstopo
|
||||||
{metaQuery.data?.lastRefresh &&
|
{metaQuery.data?.lastRefresh &&
|
||||||
` · aktualisiert ${new Date(metaQuery.data.lastRefresh).toLocaleString('de-CH')}`}
|
` · aktualisiert ${new Date(metaQuery.data.lastRefresh).toLocaleString('de-CH')}`}
|
||||||
</footer>
|
</footer>
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ import { useQuery } from '@tanstack/react-query';
|
||||||
import { memo, useCallback, useEffect, useMemo, useState } from 'react';
|
import { memo, useCallback, useEffect, useMemo, useState } from 'react';
|
||||||
import { Link, useSearchParams } from 'react-router-dom';
|
import { Link, useSearchParams } from 'react-router-dom';
|
||||||
import { fetchMunicipalityShapes, fetchVehicleMeta, fetchVehicleYears } from '../api/vehicles';
|
import { fetchMunicipalityShapes, fetchVehicleMeta, fetchVehicleYears } from '../api/vehicles';
|
||||||
|
import { DatasetCredit } from '../components/DatasetCredit';
|
||||||
import { MetricControls } from '../components/vehicles/MetricControls';
|
import { MetricControls } from '../components/vehicles/MetricControls';
|
||||||
import { MunicipalityPanel } from '../components/vehicles/MunicipalityPanel';
|
import { MunicipalityPanel } from '../components/vehicles/MunicipalityPanel';
|
||||||
import { VehicleMap } from '../components/vehicles/VehicleMap';
|
import { VehicleMap } from '../components/vehicles/VehicleMap';
|
||||||
|
|
@ -193,17 +194,30 @@ export function VehiclesThurgauPage() {
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<footer className="app-footer">
|
<footer className="app-footer">
|
||||||
Quelle:{' '}
|
{meta ? (
|
||||||
<a href={meta?.sourceUrl} target="_blank" rel="noreferrer">
|
<>
|
||||||
{meta?.publisher ?? 'Strassenverkehrsamt Kanton Thurgau'}
|
Quellen:{' '}
|
||||||
</a>{' '}
|
<DatasetCredit
|
||||||
· Lizenz {meta?.license ?? 'CC BY 4.0'} ·{' '}
|
title={meta.title}
|
||||||
<a href={meta?.populationSourceUrl} target="_blank" rel="noreferrer">
|
publisher={meta.publisher}
|
||||||
Bevölkerung: Dienststelle für Statistik Thurgau
|
url={meta.sourceUrl}
|
||||||
</a>{' '}
|
license={meta.license}
|
||||||
· Gemeindegrenzen: swisstopo
|
/>{' '}
|
||||||
{meta?.lastRefresh &&
|
·{' '}
|
||||||
|
<DatasetCredit
|
||||||
|
title={meta.populationTitle}
|
||||||
|
publisher={meta.populationPublisher}
|
||||||
|
url={meta.populationSourceUrl}
|
||||||
|
license={meta.populationLicense}
|
||||||
|
/>{' '}
|
||||||
|
· Gemeindegrenzen und Karten © swisstopo · Bearbeitung: Werte pro Gemeinde aggregiert
|
||||||
|
und mit der Bevölkerung verknüpft
|
||||||
|
{meta.lastRefresh &&
|
||||||
` · aktualisiert ${new Date(meta.lastRefresh).toLocaleString('de-CH')}`}
|
` · aktualisiert ${new Date(meta.lastRefresh).toLocaleString('de-CH')}`}
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
'Quelle: Strassenverkehrsamt Kanton Thurgau'
|
||||||
|
)}
|
||||||
</footer>
|
</footer>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ import { useQuery } from '@tanstack/react-query';
|
||||||
import { memo, useCallback, useEffect, useMemo, useState } from 'react';
|
import { memo, useCallback, useEffect, useMemo, useState } from 'react';
|
||||||
import { Link, useSearchParams } from 'react-router-dom';
|
import { Link, useSearchParams } from 'react-router-dom';
|
||||||
import { fetchWatercraftMeta, fetchWatercraftYears, type DimensionKey } from '../api/watercraft';
|
import { fetchWatercraftMeta, fetchWatercraftYears, type DimensionKey } from '../api/watercraft';
|
||||||
|
import { DatasetCredit } from '../components/DatasetCredit';
|
||||||
import { CategoryLegend } from '../components/watercraft/CategoryLegend';
|
import { CategoryLegend } from '../components/watercraft/CategoryLegend';
|
||||||
import { LocationPanel } from '../components/watercraft/LocationPanel';
|
import { LocationPanel } from '../components/watercraft/LocationPanel';
|
||||||
import { WatercraftMap } from '../components/watercraft/WatercraftMap';
|
import { WatercraftMap } from '../components/watercraft/WatercraftMap';
|
||||||
|
|
@ -225,13 +226,23 @@ export function WatercraftThurgauPage() {
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<footer className="app-footer">
|
<footer className="app-footer">
|
||||||
|
{meta ? (
|
||||||
|
<>
|
||||||
Quelle:{' '}
|
Quelle:{' '}
|
||||||
<a href={meta?.sourceUrl} target="_blank" rel="noreferrer">
|
<DatasetCredit
|
||||||
{meta?.publisher ?? 'Kantonspolizei Thurgau'}
|
title={meta.title}
|
||||||
</a>{' '}
|
publisher={meta.publisher}
|
||||||
· Lizenz {meta?.license ?? 'CC BY 4.0'} · Positionen: Uferpunkt beim jeweiligen Ort
|
url={meta.sourceUrl}
|
||||||
{meta?.lastRefresh &&
|
license={meta.license}
|
||||||
|
/>{' '}
|
||||||
|
· Karten © swisstopo · Bearbeitung: Boote pro Standort und Jahr aggregiert, Positionen
|
||||||
|
als Uferpunkt beim jeweiligen Ort ergänzt
|
||||||
|
{meta.lastRefresh &&
|
||||||
` · aktualisiert ${new Date(meta.lastRefresh).toLocaleString('de-CH')}`}
|
` · aktualisiert ${new Date(meta.lastRefresh).toLocaleString('de-CH')}`}
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
'Quelle: Kantonspolizei Thurgau, Schifffahrtskontrolle'
|
||||||
|
)}
|
||||||
</footer>
|
</footer>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
81
docs/datasets.md
Normal file
81
docs/datasets.md
Normal file
|
|
@ -0,0 +1,81 @@
|
||||||
|
# Datensätze und Datenfluss
|
||||||
|
|
||||||
|
Übersicht, woher jeder Datensatz kommt und wie der Server ihn herunterlädt und aktualisiert.
|
||||||
|
|
||||||
|
> **Pflege:** Jeder Datensatz hat eine eigene Datei in [`datasets/`](datasets/). Bei einem neuen Datensatz und bei jeder Änderung an Quelle, Abruf, Aktualisierung oder Cache müssen diese Datei und die Übersicht hier nachgeführt werden (siehe Regel in [CLAUDE.md](../CLAUDE.md#conventions)).
|
||||||
|
|
||||||
|
## Überblick
|
||||||
|
|
||||||
|
```mermaid
|
||||||
|
flowchart LR
|
||||||
|
subgraph tg["data.tg.ch"]
|
||||||
|
traffic["dbu-tba-1<br/>Verkehrszählungen"]
|
||||||
|
boats["djs-kpo-*<br/>Wasserfahrzeuge pro Jahr"]
|
||||||
|
stock["djs-stv-17<br/>Strassenfahrzeugbestand"]
|
||||||
|
pop["sk-stat-56<br/>Wohnbevölkerung"]
|
||||||
|
end
|
||||||
|
|
||||||
|
subgraph geo["swisstopo API"]
|
||||||
|
tlm["swissTLM3D Strassen<br/>+ SearchServer"]
|
||||||
|
bound["swissBOUNDARIES3D<br/>Gemeindegrenzen"]
|
||||||
|
end
|
||||||
|
|
||||||
|
wmts["swisstopo WMTS<br/>Grundkarten"]
|
||||||
|
|
||||||
|
subgraph server["Server"]
|
||||||
|
tr["TrafficRefresher<br/>alle 6 h"]
|
||||||
|
wr["WatercraftRefresher<br/>täglich"]
|
||||||
|
vr["VehicleRefresher<br/>täglich"]
|
||||||
|
end
|
||||||
|
|
||||||
|
cache[("JSON-Cache<br/>{DataPath}/…")]
|
||||||
|
api["/api/traffic<br/>/api/watercraft<br/>/api/vehicles"]
|
||||||
|
client["React-Client"]
|
||||||
|
|
||||||
|
traffic --> tr
|
||||||
|
tlm -->|einmal pro Station| tr
|
||||||
|
boats --> wr
|
||||||
|
stock --> vr
|
||||||
|
pop --> vr
|
||||||
|
bound -->|einmal pro Gemeinde| vr
|
||||||
|
tr & wr & vr --> cache
|
||||||
|
cache --> api --> client
|
||||||
|
wmts -->|direkt im Browser| client
|
||||||
|
```
|
||||||
|
|
||||||
|
Jeder Refresher lädt beim Start zuerst den Cache, damit die Karte sofort Daten hat, und prüft danach periodisch, ob eine Aktualisierung fällig ist:
|
||||||
|
|
||||||
|
```mermaid
|
||||||
|
sequenceDiagram
|
||||||
|
participant S as RefreshService
|
||||||
|
participant R as Refresher
|
||||||
|
participant Q as Quelle
|
||||||
|
participant C as Cache (JSON)
|
||||||
|
participant D as DataStore
|
||||||
|
|
||||||
|
S->>R: LoadCacheAsync()
|
||||||
|
R->>C: lesen
|
||||||
|
R->>D: Snapshot ersetzen
|
||||||
|
loop alle 15 bzw. 30 Minuten
|
||||||
|
S->>R: IsRefreshDue(RefreshInterval)?
|
||||||
|
alt fällig
|
||||||
|
R->>Q: nur Neues / Geändertes abrufen
|
||||||
|
R->>C: speichern
|
||||||
|
R->>D: Snapshot atomar ersetzen
|
||||||
|
end
|
||||||
|
end
|
||||||
|
```
|
||||||
|
|
||||||
|
## Datensätze
|
||||||
|
|
||||||
|
| Datensatz | Quelle | Lizenz | Abruf | Aktualisierung | Cache |
|
||||||
|
|---|---|---|---|---|---|
|
||||||
|
| [Verkehrszählungen](datasets/verkehrszaehlungen.md) | data.tg.ch `dbu-tba-1` (Tiefbauamt TG) | CC0 1.0 | JSON-Export, gefiltert ab letztem Cache-Tag − 1 | Prüfung alle 15 min, Abruf alle 6 h | `traffic/thurgau/counts/yyyy-MM-dd.json`, `stations.json` |
|
||||||
|
| [Strassengeometrie](datasets/strassengeometrie.md) | swisstopo swissTLM3D + SearchServer | swisstopo OGD | identify um jede Station, Geocoding der Richtungsziele | einmal pro Station; neu bei geänderter `GeometryFileName` | `traffic/thurgau/geometry-vN.json` |
|
||||||
|
| [Wasserfahrzeuge](datasets/wasserfahrzeuge.md) | data.tg.ch `djs-kpo-5/8/7/9/10` (Kantonspolizei TG) | CC BY 4.0 | Katalogsuche nach Jahres-Datensätzen, JSON-Export pro Jahr | Prüfung alle 30 min, Abruf täglich; nur neue Jahre oder geändertes `modified` | `watercraft/thurgau/years/{jahr}.json` |
|
||||||
|
| [Strassenfahrzeugbestand](datasets/strassenfahrzeugbestand.md) | data.tg.ch `djs-stv-17` (Strassenverkehrsamt TG) | CC BY 4.0 | JSON-Export des ganzen Datensatzes | Prüfung alle 30 min, täglich; Export nur bei geändertem `modified` | `vehicles/thurgau/stock.json` |
|
||||||
|
| [Wohnbevölkerung](datasets/wohnbevoelkerung.md) | data.tg.ch `sk-stat-56` (Amt für Daten und Statistik TG) | CC BY 4.0 | JSON-Export des ganzen Datensatzes | wie Fahrzeugbestand | `vehicles/thurgau/population.json` |
|
||||||
|
| [Gemeindegrenzen](datasets/gemeindegrenzen.md) | swisstopo swissBOUNDARIES3D | swisstopo OGD | Feature pro BFS-Nummer (WGS84) | einmal pro Gemeinde; neu bei geänderter `OutlinesFileName` | `vehicles/thurgau/outlines-v1.json` |
|
||||||
|
| [Grundkarten](datasets/grundkarten.md) | swisstopo WMTS (`pixelkarte-grau/-farbe`, `swissimage`) | swisstopo OGD | Kacheln direkt vom Browser | nie gecacht vom Server | – |
|
||||||
|
|
||||||
|
Alle Intervalle und Pfade sind in `appsettings.json` unter `Traffic`, `Watercraft` und `Vehicles` konfigurierbar (`DataPath`, `RefreshInterval`). Die Quellenangaben, die die Lizenzen verlangen, stehen in der Fusszeile jeder Karte. Details, Ablaufdiagramm und Besonderheiten stehen in der Datei des jeweiligen Datensatzes.
|
||||||
30
docs/datasets/gemeindegrenzen.md
Normal file
30
docs/datasets/gemeindegrenzen.md
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
# Gemeindegrenzen
|
||||||
|
|
||||||
|
[← Übersicht](../datasets.md)
|
||||||
|
|
||||||
|
| | |
|
||||||
|
|---|---|
|
||||||
|
| Datensatz | swissBOUNDARIES3D Gemeindegrenzen (`ch.swisstopo.swissboundaries3d-gemeinde-flaeche.fill`) |
|
||||||
|
| Quelle | [api3.geo.admin.ch](https://api3.geo.admin.ch/) |
|
||||||
|
| Herausgeber | Bundesamt für Landestopografie swisstopo |
|
||||||
|
| Lizenz | Open Government Data (BGDI), Quellenangabe «© swisstopo» |
|
||||||
|
| Inhalt | Umriss pro Gemeinde (BFS-Nummer) in WGS84, auf 5 Dezimalstellen gerundet |
|
||||||
|
| Verwendet in | Karte `/fahrzeuge/thurgau` (Choroplethen-Karte) |
|
||||||
|
| Abruf | `MapServer/ch.swisstopo.swissboundaries3d-gemeinde-flaeche.fill/{BFS}` pro Gemeinde |
|
||||||
|
| Aktualisierung | nur für Gemeinden des Fahrzeugbestands ohne gespeicherten Umriss; alle neu, wenn `OutlinesFileName` in `VehicleCacheStorage` erhöht wird |
|
||||||
|
| Cache | `{DataPath}/vehicles/thurgau/outlines-v1.json` |
|
||||||
|
| Code | `Schaad.OpenData.Vehicles` (`MunicipalityBoundaryClient`, `VehicleRefresher`) |
|
||||||
|
|
||||||
|
## Ablauf
|
||||||
|
|
||||||
|
```mermaid
|
||||||
|
flowchart LR
|
||||||
|
A[(stock.json)] --> B{"Gemeinde ohne<br/>Umriss?"}
|
||||||
|
B -- ja --> C["swissBOUNDARIES3D<br/>…gemeinde-flaeche.fill/{BFS}"]
|
||||||
|
C --> D["WGS84, 5 Dezimalstellen"] --> E[("outlines-v1.json")]
|
||||||
|
B -- nein --> F[Cache behalten]
|
||||||
|
```
|
||||||
|
|
||||||
|
## Hinweise
|
||||||
|
|
||||||
|
- Gemeindefusionen erscheinen als neue BFS-Nummer im Fahrzeugbestand; deren Umriss wird beim nächsten Abruf automatisch geholt.
|
||||||
24
docs/datasets/grundkarten.md
Normal file
24
docs/datasets/grundkarten.md
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
# Grundkarten
|
||||||
|
|
||||||
|
[← Übersicht](../datasets.md)
|
||||||
|
|
||||||
|
| | |
|
||||||
|
|---|---|
|
||||||
|
| Datensatz | swisstopo WMTS: Landeskarte grau (`ch.swisstopo.pixelkarte-grau`, Standard), Landeskarte farbig (`ch.swisstopo.pixelkarte-farbe`), Luftbild (`ch.swisstopo.swissimage`) |
|
||||||
|
| Quelle | [wmts.geo.admin.ch](https://wmts.geo.admin.ch/) |
|
||||||
|
| Herausgeber | Bundesamt für Landestopografie swisstopo |
|
||||||
|
| Lizenz | Open Government Data (BGDI), Quellenangabe «© swisstopo» |
|
||||||
|
| Verwendet in | allen Karten |
|
||||||
|
| Abruf | Kacheln direkt vom Browser (Leaflet), nicht über den Server |
|
||||||
|
| Aktualisierung | keine; der Browser lädt immer die aktuellen Kacheln |
|
||||||
|
| Cache | keiner im Server (nur Browser-Cache) |
|
||||||
|
| Code | `client/src/map/baseLayers.ts` |
|
||||||
|
|
||||||
|
## Ablauf
|
||||||
|
|
||||||
|
```mermaid
|
||||||
|
flowchart LR
|
||||||
|
A["Leaflet im Browser"] --> B{"gewählte Grundkarte<br/>localStorage odv.baseMap"}
|
||||||
|
B --> C["wmts.geo.admin.ch<br/>Kacheln"]
|
||||||
|
C --> A
|
||||||
|
```
|
||||||
34
docs/datasets/strassenfahrzeugbestand.md
Normal file
34
docs/datasets/strassenfahrzeugbestand.md
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
# Strassenfahrzeugbestand
|
||||||
|
|
||||||
|
[← Übersicht](../datasets.md)
|
||||||
|
|
||||||
|
| | |
|
||||||
|
|---|---|
|
||||||
|
| Datensatz | «Strassenfahrzeugbestand nach Fahrzeuggruppe, Fahrzeugart, Marke und Politischer Gemeinde ab 2023», `djs-stv-17` |
|
||||||
|
| Quelle | [data.tg.ch/explore/dataset/djs-stv-17](https://data.tg.ch/explore/dataset/djs-stv-17/) |
|
||||||
|
| Herausgeber | Strassenverkehrsamt Kanton Thurgau |
|
||||||
|
| Lizenz | CC BY 4.0 |
|
||||||
|
| Inhalt | Anzahl Fahrzeuge pro Gemeinde (BFS-Nummer), Fahrzeuggruppe, Fahrzeugart und Marke am 31.12., jährlich ab 2023 |
|
||||||
|
| Verwendet in | Karte `/fahrzeuge/thurgau` |
|
||||||
|
| Abruf | Katalog-Metadaten `…/catalog/datasets/djs-stv-17` (`modified`), bei Änderung JSON-Export des ganzen Datensatzes |
|
||||||
|
| Aktualisierung | Prüfung alle 30 min, Abruf täglich (`Vehicles:RefreshInterval`); exportiert wird nur, wenn sich `modified` geändert hat oder der Cache leer ist |
|
||||||
|
| Cache | `{DataPath}/vehicles/thurgau/stock.json`, Versionsstand in `meta.json` |
|
||||||
|
| Code | `Schaad.OpenData.Vehicles` (`ThurgauVehicleClient`, `VehicleRefresher`, `VehicleCacheStorage`) |
|
||||||
|
|
||||||
|
## Ablauf
|
||||||
|
|
||||||
|
```mermaid
|
||||||
|
flowchart LR
|
||||||
|
S["VehicleRefreshService<br/>alle 30 min"] --> R{"letzter Abruf<br/>älter als 1 Tag?"}
|
||||||
|
R -- ja --> A["Katalog-Metadaten<br/>djs-stv-17"]
|
||||||
|
A --> B{"modified geändert<br/>oder Cache leer?"}
|
||||||
|
B -- ja --> C["djs-stv-17/exports/json"] --> D[(stock.json)]
|
||||||
|
B -- nein --> E[Cache behalten]
|
||||||
|
D --> F["VehicleAnalysis<br/>mit Wohnbevölkerung und Gemeindegrenzen"]
|
||||||
|
```
|
||||||
|
|
||||||
|
## Hinweise
|
||||||
|
|
||||||
|
- Der Datensatz enthält alle Jahre und wird bei einer Änderung vollständig neu exportiert.
|
||||||
|
- Marken mit weniger als 5 Fahrzeugen pro Gemeinde und Fahrzeugart fasst die Quelle unter «Andere» zusammen. Markenauswertungen gibt es nur für die Gruppe «Personenwagen».
|
||||||
|
- Für Werte pro 1000 Einwohner kommt die [Wohnbevölkerung](wohnbevoelkerung.md) dazu, für die Karte die [Gemeindegrenzen](gemeindegrenzen.md).
|
||||||
35
docs/datasets/strassengeometrie.md
Normal file
35
docs/datasets/strassengeometrie.md
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
# Strassengeometrie
|
||||||
|
|
||||||
|
[← Übersicht](../datasets.md)
|
||||||
|
|
||||||
|
| | |
|
||||||
|
|---|---|
|
||||||
|
| Datensatz | swissTLM3D Strassen (`ch.swisstopo.swisstlm3d-strassen`) und SearchServer (Gemeinden, Gazetteer) |
|
||||||
|
| Quelle | [api3.geo.admin.ch](https://api3.geo.admin.ch/) |
|
||||||
|
| Herausgeber | Bundesamt für Landestopografie swisstopo |
|
||||||
|
| Lizenz | Open Government Data (BGDI), Quellenangabe «© swisstopo» |
|
||||||
|
| Inhalt | Strassenverlauf pro Zählstelle und Richtung, in Fahrtrichtung orientiert |
|
||||||
|
| Verwendet in | Karte `/verkehr/thurgau` (Animation der Fahrzeuge) |
|
||||||
|
| Abruf | `MapServer/identify` im Umkreis der Station (seitenweise à 200), `SearchServer?type=locations` für Richtungsziele |
|
||||||
|
| Aktualisierung | einmal pro Station; alle Stationen neu, wenn `GeometryFileName` in `TrafficCacheStorage` erhöht wird |
|
||||||
|
| Cache | `{DataPath}/traffic/thurgau/geometry-vN.json` (aktuell `geometry-v7.json`) |
|
||||||
|
| Code | `Schaad.OpenData.Traffic/Geometry` (`SwisstopoClient`, `StationGeometryService`, `RoadPathBuilder`) |
|
||||||
|
|
||||||
|
## Ablauf
|
||||||
|
|
||||||
|
```mermaid
|
||||||
|
flowchart TB
|
||||||
|
A["Station ohne Geometrie"] --> B["identify swissTLM3D<br/>Strassensegmente um die Station"]
|
||||||
|
B --> C["RoadPathBuilder.BuildRoadPath<br/>Hauptstrasse ≤ 60 m, ±300 m"]
|
||||||
|
A --> K{"Kreisel-Station?"}
|
||||||
|
K -- ja --> L["Ziel 3 km auswärts<br/>vom Kreiselzentrum"]
|
||||||
|
K -- nein --> M["SearchServer<br/>Richtungsziel geocodieren"]
|
||||||
|
L & M --> O["RoadPathBuilder.Orient<br/>Richtung zum / vom Ziel"]
|
||||||
|
C --> O
|
||||||
|
O --> P[("geometry-vN.json")]
|
||||||
|
```
|
||||||
|
|
||||||
|
## Hinweise
|
||||||
|
|
||||||
|
- Die Quelle der Verkehrszählungen hat nur einen Punkt pro Station und die Richtungen als Text (`nach X`, `von X`); die Geometrie wird daraus abgeleitet. Details zum Algorithmus stehen in [CLAUDE.md](../../CLAUDE.md#road-geometry-for-the-direction-animation).
|
||||||
|
- Ziele wie `Umfahrung`, `Zentrum` oder Strassennamen lassen sich nicht geocodieren.
|
||||||
37
docs/datasets/verkehrszaehlungen.md
Normal file
37
docs/datasets/verkehrszaehlungen.md
Normal file
|
|
@ -0,0 +1,37 @@
|
||||||
|
# Verkehrszählungen
|
||||||
|
|
||||||
|
[← Übersicht](../datasets.md)
|
||||||
|
|
||||||
|
| | |
|
||||||
|
|---|---|
|
||||||
|
| Datensatz | stündliche Verkehrszählungen nach Fahrzeugklassen, `dbu-tba-1` |
|
||||||
|
| Quelle | [data.tg.ch/explore/dataset/dbu-tba-1](https://data.tg.ch/explore/dataset/dbu-tba-1/) |
|
||||||
|
| Herausgeber | Tiefbauamt Kanton Thurgau |
|
||||||
|
| Lizenz | CC0 1.0 |
|
||||||
|
| Inhalt | stündliche Zählungen an 64 Zählstellen, je zwei Richtungen, 10 Fahrzeugklassen (SWISS10) |
|
||||||
|
| Verwendet in | Karte `/verkehr/thurgau` |
|
||||||
|
| Abruf | JSON-Export `…/catalog/datasets/dbu-tba-1/exports/json?where=datum >= …` |
|
||||||
|
| Aktualisierung | Prüfung alle 15 min, Abruf alle 6 h (`Traffic:RefreshInterval`) |
|
||||||
|
| Cache | `{DataPath}/traffic/thurgau/stations.json`, `meta.json`, `counts/yyyy-MM-dd.json` |
|
||||||
|
| Code | `Schaad.OpenData.Traffic` (`ThurgauTrafficClient`, `TrafficRefresher`, `TrafficCacheStorage`) |
|
||||||
|
|
||||||
|
## Ablauf
|
||||||
|
|
||||||
|
```mermaid
|
||||||
|
flowchart LR
|
||||||
|
S["TrafficRefreshService<br/>alle 15 min"] --> R{"letzter Abruf<br/>älter als 6 h?"}
|
||||||
|
R -- nein --> W[warten]
|
||||||
|
R -- ja --> A["dbu-tba-1/exports/json<br/>where datum >= letzter Tag − 1"]
|
||||||
|
A --> B[ThurgauTrafficMapper]
|
||||||
|
B --> C["TrafficSnapshot.Merge<br/>neue Tage ersetzen, alte bleiben"]
|
||||||
|
C --> D[("counts/yyyy-MM-dd.json<br/>stations.json")]
|
||||||
|
C --> G["Strassengeometrie<br/>für neue Stationen"]
|
||||||
|
C --> E[TrafficDataStore]
|
||||||
|
```
|
||||||
|
|
||||||
|
## Hinweise
|
||||||
|
|
||||||
|
- data.tg.ch hält nur die letzten rund 14 Tage. Der Cache sammelt die Historie über dieses Fenster hinaus; wird er gelöscht, sind ältere Tage weg.
|
||||||
|
- Abgerufen wird ab dem letzten Cache-Tag minus einem Tag, damit ein zuvor unvollständiger Tag ersetzt wird.
|
||||||
|
- Die Strassenverläufe pro Richtung stammen aus einem eigenen Ablauf: [Strassengeometrie](strassengeometrie.md).
|
||||||
|
- Jahresarchive ab 2011 (`ogdtg.ch/verkehrsdaten/fahrzeugklassen/{jahr}_fzkl_data.csv.gz`) werden noch nicht importiert.
|
||||||
34
docs/datasets/wasserfahrzeuge.md
Normal file
34
docs/datasets/wasserfahrzeuge.md
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
# Wasserfahrzeuge
|
||||||
|
|
||||||
|
[← Übersicht](../datasets.md)
|
||||||
|
|
||||||
|
| | |
|
||||||
|
|---|---|
|
||||||
|
| Datensatz | «Bestand der bei der Schifffahrtskontrolle immatrikulierten Wasserfahrzeuge {Jahr}», ein Datensatz pro Jahr: `djs-kpo-5` (2021), `djs-kpo-8` (2022), `djs-kpo-7` (2023), `djs-kpo-9` (2024), `djs-kpo-10` (2025) |
|
||||||
|
| Quelle | [data.tg.ch](https://data.tg.ch/explore/?q=Schifffahrtskontrolle) |
|
||||||
|
| Herausgeber | Kantonspolizei Thurgau, Schifffahrtskontrolle |
|
||||||
|
| Lizenz | CC BY 4.0 |
|
||||||
|
| Inhalt | rund 7000 Boote, eine Zeile pro Boot: Standort, Typ, Antrieb, Treibstoff, Emissionsgruppe, Länge, Leistung |
|
||||||
|
| Verwendet in | Karte `/schifffahrt/thurgau` |
|
||||||
|
| Abruf | Katalogsuche nach den Jahres-Datensätzen, danach JSON-Export `…/catalog/datasets/{id}/exports/json` pro Jahr |
|
||||||
|
| Aktualisierung | Prüfung alle 30 min, Abruf täglich (`Watercraft:RefreshInterval`); exportiert werden nur neue Jahre oder Jahre mit geänderter Datensatz-ID bzw. geändertem `modified` |
|
||||||
|
| Cache | `{DataPath}/watercraft/thurgau/meta.json`, `years/{jahr}.json` |
|
||||||
|
| Code | `Schaad.OpenData.Watercraft` (`ThurgauWatercraftClient`, `WatercraftRefresher`, `WatercraftCacheStorage`) |
|
||||||
|
|
||||||
|
## Ablauf
|
||||||
|
|
||||||
|
```mermaid
|
||||||
|
flowchart LR
|
||||||
|
S["WatercraftRefreshService<br/>alle 30 min"] --> R{"letzter Abruf<br/>älter als 1 Tag?"}
|
||||||
|
R -- ja --> A["Katalogsuche<br/>«immatrikulierten Wasserfahrzeuge»"]
|
||||||
|
A --> B["Titel «Bestand der bei der<br/>Schifffahrtskontrolle … {Jahr}»"]
|
||||||
|
B --> C{"Jahr neu oder<br/>modified geändert?"}
|
||||||
|
C -- ja --> D["{id}/exports/json"] --> E[("years/{jahr}.json")]
|
||||||
|
C -- nein --> F[Cache behalten]
|
||||||
|
```
|
||||||
|
|
||||||
|
## Hinweise
|
||||||
|
|
||||||
|
- Ein neues Jahr wird über die Katalogsuche automatisch gefunden, solange der Titel dem bisherigen Muster folgt.
|
||||||
|
- Die Quelle hat keine Koordinaten. Die Uferpunkte der Standorte sind fest in `WatercraftLocations` hinterlegt (einmalig aus dem swisstopo-Gazetteer bestimmt). Neue Standortnamen erscheinen ohne Position neben der Karte.
|
||||||
|
- Fehlende Werte werden zu eigenen Kategorien (`Ohne Motor`, `Keine Angabe`, `Ohne besondere Verwendung`).
|
||||||
30
docs/datasets/wohnbevoelkerung.md
Normal file
30
docs/datasets/wohnbevoelkerung.md
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
# Wohnbevölkerung
|
||||||
|
|
||||||
|
[← Übersicht](../datasets.md)
|
||||||
|
|
||||||
|
| | |
|
||||||
|
|---|---|
|
||||||
|
| Datensatz | «Ständige Wohnbevölkerung der Thurgauer Gemeinden», `sk-stat-56` |
|
||||||
|
| Quelle | [data.tg.ch/explore/dataset/sk-stat-56](https://data.tg.ch/explore/dataset/sk-stat-56/) |
|
||||||
|
| Herausgeber | Amt für Daten und Statistik Kanton Thurgau |
|
||||||
|
| Lizenz | CC BY 4.0 |
|
||||||
|
| Inhalt | ständige Wohnbevölkerung pro Gemeinde (BFS-Nummer) und Jahr, ab 2007 |
|
||||||
|
| Verwendet in | Karte `/fahrzeuge/thurgau` (Fahrzeuge pro 1000 Einwohner) |
|
||||||
|
| Abruf | Katalog-Metadaten `…/catalog/datasets/sk-stat-56` (`modified`), bei Änderung JSON-Export des ganzen Datensatzes |
|
||||||
|
| Aktualisierung | zusammen mit dem [Strassenfahrzeugbestand](strassenfahrzeugbestand.md): Prüfung alle 30 min, Abruf täglich, Export nur bei geändertem `modified` oder leerem Cache |
|
||||||
|
| Cache | `{DataPath}/vehicles/thurgau/population.json`, Versionsstand in `meta.json` |
|
||||||
|
| Code | `Schaad.OpenData.Vehicles` (`ThurgauVehicleClient.FetchPopulationAsync`, `VehicleRefresher`) |
|
||||||
|
|
||||||
|
## Ablauf
|
||||||
|
|
||||||
|
```mermaid
|
||||||
|
flowchart LR
|
||||||
|
R["VehicleRefresher<br/>täglich"] --> A["Katalog-Metadaten<br/>sk-stat-56"]
|
||||||
|
A --> B{"modified geändert<br/>oder Cache leer?"}
|
||||||
|
B -- ja --> C["sk-stat-56/exports/json"] --> D[(population.json)]
|
||||||
|
B -- nein --> E[Cache behalten]
|
||||||
|
```
|
||||||
|
|
||||||
|
## Hinweise
|
||||||
|
|
||||||
|
- Fehlt die Bevölkerung für ein Jahr des Fahrzeugbestands (die Statistik erscheint oft später), nimmt die Auswertung das letzte frühere Jahr.
|
||||||
52
run.ps1
Normal file
52
run.ps1
Normal file
|
|
@ -0,0 +1,52 @@
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Builds the client and starts the OpenDataVisualizer server on http://localhost:5080.
|
||||||
|
|
||||||
|
.PARAMETER SkipClient
|
||||||
|
Does not rebuild the client; the server serves the existing build in Schaad.OpenData.Server/wwwroot.
|
||||||
|
|
||||||
|
.PARAMETER Install
|
||||||
|
Runs "npm ci" before building, also when client/node_modules already exists.
|
||||||
|
|
||||||
|
.EXAMPLE
|
||||||
|
.\run.ps1
|
||||||
|
.\run.ps1 -SkipClient
|
||||||
|
#>
|
||||||
|
param(
|
||||||
|
[switch]$SkipClient,
|
||||||
|
[switch]$Install
|
||||||
|
)
|
||||||
|
|
||||||
|
$ErrorActionPreference = 'Stop'
|
||||||
|
$root = $PSScriptRoot
|
||||||
|
$client = Join-Path $root 'client'
|
||||||
|
$server = Join-Path $root 'Schaad.OpenData.Server'
|
||||||
|
|
||||||
|
function Invoke-Step([string]$Title, [scriptblock]$Command) {
|
||||||
|
Write-Host "==> $Title" -ForegroundColor Cyan
|
||||||
|
& $Command
|
||||||
|
if ($LASTEXITCODE -ne 0) {
|
||||||
|
throw "$Title failed (exit code $LASTEXITCODE)"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$running = Get-Process -Name 'Schaad.OpenData.Server' -ErrorAction SilentlyContinue
|
||||||
|
if ($running) {
|
||||||
|
throw "The server is already running (PID $($running.Id -join ', ')). Stop it first, otherwise the build fails on locked files."
|
||||||
|
}
|
||||||
|
|
||||||
|
if (-not $SkipClient) {
|
||||||
|
Push-Location $client
|
||||||
|
try {
|
||||||
|
if ($Install -or -not (Test-Path (Join-Path $client 'node_modules'))) {
|
||||||
|
Invoke-Step 'Installing client packages' { npm ci }
|
||||||
|
}
|
||||||
|
Invoke-Step 'Building client into Schaad.OpenData.Server/wwwroot' { npm run build }
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
Pop-Location
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host '==> Starting server on http://localhost:5080 (Ctrl+C to stop)' -ForegroundColor Cyan
|
||||||
|
dotnet run --project $server --launch-profile http
|
||||||
Loading…
Reference in a new issue