Netz-Modul src/net (Offline-Modus, Host-Liste, kein fetch ausserhalb), Renderer-Umschalter WebGL2 entfernt, Offline-Schalter in den Einstellungen; i18n-Waechter gegen fest eingebaute Texte

This commit is contained in:
karim committed 2026-10-27 19:47:18 +01:00
1 parent cf99fc3d11
commit 3d864047cf
19 files changed
+329 -95

No files matched your search

+2
View File
@@ -7,6 +7,7 @@
//
// Bezeichner englisch, Kommentare deutsch (CONVENTIONS.md).
import { allowHost } from "../net/net";
import Delaunator from "delaunator";
import type { ContextObject, Contour, ImportedMesh } from "../model/types";
import { GEO_CATEGORY_DEFS } from "../model/contextCategories";
@@ -285,5 +286,6 @@ export function geoProxyBase(): string {
*/
export function viaProxy(url: string): string {
const base = geoProxyBase();
if (base) allowHost(base);
return base ? `${base}?u=${encodeURIComponent(url)}` : url;
}
+2 -1
View File
@@ -10,6 +10,7 @@
//
// Bezeichner englisch, Kommentare deutsch (CONVENTIONS.md). Einheiten: Meter.
import { netFetch } from "../net/net";
import { lv95BboxToWgs84, makeOrigin, wgs84ToLocal } from "./lv95";
import type { GeoOrigin, LV95 } from "./lv95";
import { bboxAround } from "./lv95";
@@ -145,7 +146,7 @@ export async function fetchOsm(
const bbox = lv95BboxToWgs84(bboxAround(center, radius));
const query = buildQuery(bbox, sel);
const res = await fetch(viaProxy(OVERPASS), {
const res = await netFetch(viaProxy(OVERPASS), {
method: "POST",
headers: { "Content-Type": "application/x-www-form-urlencoded" },
body: "data=" + encodeURIComponent(query),
+3 -2
View File
@@ -6,6 +6,7 @@
//
// Bezeichner englisch, Kommentare deutsch (CONVENTIONS.md). Einheiten: Meter.
import { netFetch } from "../net/net";
import JSZip from "jszip";
import { viaProxy } from "./geoContext";
@@ -34,7 +35,7 @@ export async function stacQuery(
const url =
`${STAC_BASE}/collections/${collectionId}/items` +
`?bbox=${bbox.west},${bbox.south},${bbox.east},${bbox.north}&limit=${limit}`;
const res = await fetch(viaProxy(url));
const res = await netFetch(viaProxy(url));
if (!res.ok) throw new Error(`STAC-Abfrage fehlgeschlagen (${res.status})`);
const data = (await res.json()) as {
features?: {
@@ -115,7 +116,7 @@ function pickZipEntry(
* Netzwerkfehler oder Grössenüberschreitung; wirft nie. */
async function fetchAssetWithinLimit(asset: StacAsset): Promise<Response | null> {
if (asset.size != null && asset.size > MAX_ASSET_BYTES) return null;
const res = await fetch(viaProxy(asset.href));
const res = await netFetch(viaProxy(asset.href));
if (!res.ok) return null;
// STAC-Metadaten (`file:size`) fehlen manchmal (leeres `file:size`-Feld,
// z. B. bei swissBUILDINGS3D v3) — dann greift die Prüfung oben NICHT, und
+3 -2
View File
@@ -9,6 +9,7 @@
//
// Bezeichner englisch, Kommentare deutsch (CONVENTIONS.md). Einheiten: Meter.
import { netFetch } from "../net/net";
import { bboxAround, makeOrigin } from "./lv95";
import type { GeoOrigin, LV95 } from "./lv95";
import { viaProxy } from "./geoContext";
@@ -132,7 +133,7 @@ export async function decodeImageToRgba(dataUrl: string): Promise<DecodedImage |
return null;
}
try {
const res = await fetch(dataUrl);
const res = await netFetch(dataUrl);
const blob = await res.blob();
const bmp = await createImageBitmap(blob);
const canvas = new OffscreenCanvas(bmp.width, bmp.height);
@@ -168,7 +169,7 @@ export async function fetchSwissImage(
const max = { x: bboxLv95[2] - origin.e, y: bboxLv95[3] - origin.n };
try {
const res = await fetch(viaProxy(buildSwissImageUrl(bboxLv95, px, px)));
const res = await netFetch(viaProxy(buildSwissImageUrl(bboxLv95, px, px)));
if (!res.ok) return { origin, dataUrl: null, min, max };
// WMS liefert bei Fehlern manchmal eine XML-Fehlermeldung statt eines Bildes.
const mime = res.headers.get("content-type") ?? "";
+3 -2
View File
@@ -17,6 +17,7 @@
//
// Bezeichner englisch, Kommentare deutsch (CONVENTIONS.md). Einheiten: Meter.
import { netFetch } from "../net/net";
import { bboxAround, makeOrigin, wgs84ToLv95 } from "./lv95";
import type { GeoOrigin, LV95 } from "./lv95";
import type { GeoFeature } from "./geoContext";
@@ -50,7 +51,7 @@ export async function geocode(
`?searchText=${encodeURIComponent(q)}` +
`&type=locations&sr=2056&limit=${limit}`;
const res = await fetch(viaProxy(url));
const res = await netFetch(viaProxy(url));
if (!res.ok) throw new Error(`Geocode fehlgeschlagen (${res.status})`);
const data = (await res.json()) as {
results?: {
@@ -120,7 +121,7 @@ export async function fetchBuildings(
`&layers=all:ch.swisstopo.vec25-gebaeude` +
`&returnGeometry=true&sr=2056&limit=200`;
const res = await fetch(viaProxy(url));
const res = await netFetch(viaProxy(url));
if (!res.ok) throw new Error(`Gebäude-Abruf fehlgeschlagen (${res.status})`);
const data = (await res.json()) as {
results?: { geometry?: EsriPolygon }[];