Stage 1 of the GIS Analytical Tools concept — client-side spatial analysis: - src/analysis/overlay.js: vector overlays (intersect / clip / difference / union-dissolve) on Turf.js, reprojecting to WGS84 and merging attributes (intersect keeps both layers', clip keeps only A's). - src/analysis/zonal.js: vector-in-vector zonal statistics — count / sum / mean / min / max / total area per zone, with centroid-in-zone (default) or any-overlap membership. - Bounding-box pre-filtering in both: only genuinely overlapping pairs reach the expensive geometry test. 43 zones x 25,004 parcels now completes in ~106 ms; previously it was refused as too large. - src/analysis-modal.js + markup: Analysis panel with "Apply to" scoping — whole layer, current map view, selected features, or the catch of a drawn Circle/Area. Reached from a new "Analyse" dock button. - MapView.addCOGLayer() for Cloud-Optimized GeoTIFF display (WebGLTile + GeoTIFF source, imported lazily); listVectorLayers(); getSelectedFeatures(). - Circle/Area analysis popup: one "Export" button (PDF folded into the export modal as a fourth format, field-rename table hidden for it) plus an "Analyse" button that opens the panel pre-scoped to the intersecting features. - vite.config.js: code-split turf, geotiff and pako so the eager bundle is unchanged (~283 kB). Giving pako its own chunk also fixes a circular chunk between jspdf and geotiff, which share it via fast-png. Drawing-tool fixes carried in the same working tree: - Delete/Backspace key deletes the selection via the EditBar's Delete interaction (same undoable block as the button). - Multi-select: shift-click toggles, Ctrl/Cmd-drag box-selects; helper layers (vertex overlay, GPS) excluded. - Undo: split/merge/divide wrapped in undo blocks so one press reverses the whole operation; vertex-overlay churn no longer pollutes the undo stack; sources are re-scanned and the stack cleared when edit mode is entered, so deletes on sub-grouped layers are undoable. NOTE: the undo behaviour is not yet confirmed on-device. - ol-ext TouchCursor gated to touch-only devices, so hybrid touchscreen laptops keep the normal cursor. Service worker v12 -> v13. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
85 lines
3.0 KiB
JavaScript
85 lines
3.0 KiB
JavaScript
/**
|
|
* Vite Configuration
|
|
*
|
|
* Configures:
|
|
* - Cross-origin isolation headers (required for OPFS/SQLite)
|
|
* - Worker bundling
|
|
*/
|
|
|
|
import { defineConfig } from 'vite';
|
|
|
|
export default defineConfig({
|
|
// Development server configuration
|
|
server: {
|
|
headers: {
|
|
// Required for OPFS (Origin Private File System) access
|
|
'Cross-Origin-Opener-Policy': 'same-origin',
|
|
'Cross-Origin-Embedder-Policy': 'require-corp',
|
|
},
|
|
},
|
|
|
|
// Preview server (npm run preview) configuration
|
|
preview: {
|
|
headers: {
|
|
'Cross-Origin-Opener-Policy': 'same-origin',
|
|
'Cross-Origin-Embedder-Policy': 'require-corp',
|
|
},
|
|
},
|
|
|
|
// Build configuration
|
|
build: {
|
|
// Generate source maps for debugging
|
|
sourcemap: true,
|
|
|
|
// Target modern browsers that support OPFS
|
|
target: 'esnext',
|
|
|
|
// Raise the chunk-size warning threshold.
|
|
// Rationale: the two largest chunks are unavoidable —
|
|
// • openlayers (~535 kB / ~152 kB gzipped) — the OL library itself,
|
|
// used app-wide; further splitting just creates more HTTP round-trips
|
|
// • sqlite3.wasm (~856 kB) — a runtime WASM binary, not a JS chunk;
|
|
// code-splitting does not apply
|
|
// 900 kB silences the noise without hiding genuine regressions.
|
|
chunkSizeWarningLimit: 900,
|
|
|
|
rollupOptions: {
|
|
output: {
|
|
manualChunks(id) {
|
|
// pako (zlib) is pulled in by BOTH geotiff and jspdf (via fast-png).
|
|
// Without its own chunk, Rollup assigns it to one of them and the two
|
|
// chunks reference each other ("Circular chunk: jspdf -> geotiff").
|
|
if (id.includes('node_modules/pako/')) return 'pako';
|
|
// Turf.js — only needed when the Analysis panel is opened, which
|
|
// main.js imports dynamically. Keep it out of the eager bundle.
|
|
if (id.includes('node_modules/@turf/')) return 'turf';
|
|
// geotiff.js + the OL modules that use it — only needed when the user
|
|
// opens a Cloud-Optimized GeoTIFF layer, which MapView.addCOGLayer()
|
|
// imports dynamically. Must be tested BEFORE the generic ol/ rule so
|
|
// it isn't swallowed into the eagerly-loaded openlayers chunk.
|
|
if (id.includes('node_modules/geotiff/') ||
|
|
id.includes('node_modules/ol/source/GeoTIFF') ||
|
|
id.includes('node_modules/ol/layer/WebGLTile')) return 'geotiff';
|
|
if (id.includes('node_modules/ol/')) return 'openlayers';
|
|
if (id.includes('node_modules/ol-ext/')) return 'ol-ext';
|
|
if (id.includes('node_modules/bootstrap/')) return 'bootstrap';
|
|
// shpjs (+ its jszip dependency) — dynamically imported at runtime,
|
|
// so this chunk is only fetched when the user imports a shapefile.
|
|
if (id.includes('node_modules/shpjs/') || id.includes('node_modules/jszip/')) return 'shpjs';
|
|
if (id.includes('node_modules/jspdf')) return 'jspdf';
|
|
},
|
|
},
|
|
},
|
|
},
|
|
|
|
// Worker configuration
|
|
worker: {
|
|
format: 'es',
|
|
},
|
|
|
|
// Dependency optimization
|
|
optimizeDeps: {
|
|
exclude: ['sqlocal'],
|
|
},
|
|
});
|