From e09050162407e8458c753a0e521d6a05b1ad49d9 Mon Sep 17 00:00:00 2001 From: core Date: Fri, 16 May 2025 22:12:54 -0400 Subject: [PATCH] feat: client work --- client/bun.lock | 10 ++++++++ client/package.json | 2 ++ client/src/lib/Map.svelte | 5 ++++ client/src/lib/ToolbarProductSelector.svelte | 23 ++++++++++++++++--- client/src/lib/components/ui/sonner/index.ts | 1 + .../lib/components/ui/sonner/sonner.svelte | 20 ++++++++++++++++ client/src/lib/stationData.ts | 1 + client/src/routes/+layout.svelte | 3 +++ client/src/routes/+page.server.ts | 6 ++--- crates/ar2/src/lib.rs | 1 - crates/ar2/src/main.rs | 4 ++-- crates/tiler/config.toml | 23 +++++++------------ 12 files changed, 75 insertions(+), 24 deletions(-) create mode 100644 client/src/lib/components/ui/sonner/index.ts create mode 100644 client/src/lib/components/ui/sonner/sonner.svelte diff --git a/client/bun.lock b/client/bun.lock index 47bcc71..3a87140 100644 --- a/client/bun.lock +++ b/client/bun.lock @@ -22,12 +22,14 @@ "eslint-config-prettier": "^10.0.1", "eslint-plugin-svelte": "^3.0.0", "globals": "^16.0.0", + "mode-watcher": "^1.0.7", "paneforge": "^1.0.0-next.5", "prettier": "^3.4.2", "prettier-plugin-svelte": "^3.3.3", "prettier-plugin-tailwindcss": "^0.6.11", "svelte": "^5.0.0", "svelte-check": "^4.0.0", + "svelte-sonner": "^1.0.1", "tailwind-merge": "^3.3.0", "tailwind-variants": "^1.0.0", "tailwindcss": "^4.1.6", @@ -840,6 +842,8 @@ "mkdirp": ["mkdirp@3.0.1", "", { "bin": { "mkdirp": "dist/cjs/src/bin.js" } }, "sha512-+NsyUUAZDmo6YVHzL/stxSu3t9YS1iljliy3BSDrXJ/dkn1KYdmtZODGGjLcc9XLgVVpH4KshHB8XmZgMhaBXg=="], + "mode-watcher": ["mode-watcher@1.0.7", "", { "dependencies": { "runed": "^0.25.0", "svelte-toolbelt": "^0.7.1" }, "peerDependencies": { "svelte": "^5.27.0" } }, "sha512-ZGA7ZGdOvBJeTQkzdBOnXSgTkO6U6iIFWJoyGCTt6oHNg9XP9NBvS26De+V4W2aqI+B0yYXUskFG2VnEo3zyMQ=="], + "mri": ["mri@1.2.0", "", {}, "sha512-tzzskb3bG8LvYGFF/mDTpq3jpI6Q9wc3LEmBaghu+DdCssd1FakN7Bc0hVNmEyGq1bq3RgfkCb3cmQLpNPOroA=="], "mrmime": ["mrmime@2.0.1", "", {}, "sha512-Y3wQdFg2Va6etvQ5I82yUhGdsKrcYox6p7FfL1LbK2J4V01F9TGlepTIhnK24t7koZibmg82KGglhA1XK5IsLQ=="], @@ -1004,6 +1008,8 @@ "svelte-eslint-parser": ["svelte-eslint-parser@1.1.3", "", { "dependencies": { "eslint-scope": "^8.2.0", "eslint-visitor-keys": "^4.0.0", "espree": "^10.0.0", "postcss": "^8.4.49", "postcss-scss": "^4.0.9", "postcss-selector-parser": "^7.0.0" }, "peerDependencies": { "svelte": "^3.37.0 || ^4.0.0 || ^5.0.0" }, "optionalPeers": ["svelte"] }, "sha512-DUc/z/vk+AFVoxGv54+BOBFqUrmUgNg2gSO2YqrE3OL6ro19/0azPmQj/4wN3s9RxuF5l7G0162q/Ddk4LJhZA=="], + "svelte-sonner": ["svelte-sonner@1.0.1", "", { "dependencies": { "runed": "^0.26.0" }, "peerDependencies": { "svelte": "^5.0.0" } }, "sha512-vz0eqcs9GNnJ2CTtTno7v/jSA0P3r+X+3y/hrJg+FPpB2rZCFywIKNKD3wiRI8449i3LXVcgQ+q5R5ocOd6ydA=="], + "svelte-toolbelt": ["svelte-toolbelt@0.7.1", "", { "dependencies": { "clsx": "^2.1.1", "runed": "^0.23.2", "style-to-object": "^1.0.8" }, "peerDependencies": { "svelte": "^5.0.0" } }, "sha512-HcBOcR17Vx9bjaOceUvxkY3nGmbBmCBBbuWLLEWO6jtmWH8f/QoWmbyUfQZrpDINH39en1b8mptfPQT9VKQ1xQ=="], "sweepline-intersections": ["sweepline-intersections@1.5.0", "", { "dependencies": { "tinyqueue": "^2.0.0" } }, "sha512-AoVmx72QHpKtItPu72TzFL+kcYjd67BPLDoR0LarIk+xyaRg+pDTMFXndIEvZf9xEKnJv6JdhgRMnocoG0D3AQ=="], @@ -1120,8 +1126,12 @@ "micromatch/picomatch": ["picomatch@2.3.1", "", {}, "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA=="], + "mode-watcher/runed": ["runed@0.25.0", "", { "dependencies": { "esm-env": "^1.0.0" }, "peerDependencies": { "svelte": "^5.7.0" } }, "sha512-7+ma4AG9FT2sWQEA0Egf6mb7PBT2vHyuHail1ie8ropfSjvZGtEAx8YTmUjv/APCsdRRxEVvArNjALk9zFSOrg=="], + "rbush/quickselect": ["quickselect@2.0.0", "", {}, "sha512-RKJ22hX8mHe3Y6wH/N3wCM6BWtjaxIyyUIkpHOvfFnxdI4yD4tBXEBKSbriGujF6jnSVkJrffuo6vxACiSSxIw=="], + "svelte-sonner/runed": ["runed@0.26.0", "", { "dependencies": { "esm-env": "^1.0.0" }, "peerDependencies": { "svelte": "^5.7.0" } }, "sha512-qWFv0cvLVRd8pdl/AslqzvtQyEn5KaIugEernwg9G98uJVSZcs/ygvPBvF80LA46V8pwRvSKnaVLDI3+i2wubw=="], + "sweepline-intersections/tinyqueue": ["tinyqueue@2.0.3", "", {}, "sha512-ppJZNDuKGgxzkHihX8v9v9G5f+18gzaTfrukGrq6ueg0lmH4nqVnA2IPG0AEH3jKEk2GRJCUhDoqpoiw3PHLBA=="], "tailwind-variants/tailwind-merge": ["tailwind-merge@3.0.2", "", {}, "sha512-l7z+OYZ7mu3DTqrL88RiKrKIqO3NcpEO8V/Od04bNpvk0kiIFndGEoqfuzvj4yuhRkHKjRkII2z+KS2HfPcSxw=="], diff --git a/client/package.json b/client/package.json index 327f01f..ea9967d 100644 --- a/client/package.json +++ b/client/package.json @@ -26,12 +26,14 @@ "eslint-config-prettier": "^10.0.1", "eslint-plugin-svelte": "^3.0.0", "globals": "^16.0.0", + "mode-watcher": "^1.0.7", "paneforge": "^1.0.0-next.5", "prettier": "^3.4.2", "prettier-plugin-svelte": "^3.3.3", "prettier-plugin-tailwindcss": "^0.6.11", "svelte": "^5.0.0", "svelte-check": "^4.0.0", + "svelte-sonner": "^1.0.1", "tailwind-merge": "^3.3.0", "tailwind-variants": "^1.0.0", "tailwindcss": "^4.1.6", diff --git a/client/src/lib/Map.svelte b/client/src/lib/Map.svelte index b2038f0..edd2364 100644 --- a/client/src/lib/Map.svelte +++ b/client/src/lib/Map.svelte @@ -5,6 +5,7 @@ import { onMount } from 'svelte'; import type { LayerList } from './layerList'; import type { StationStatus } from './stationData'; + import {toast} from "svelte-sonner"; interface Props { categories: LayerList; @@ -39,6 +40,10 @@ load_image('radar-rect-green'); load_image('radar-rect-red'); }); + map.on('error', (e) => { + console.error(e); + toast.error('Data loading failed!'); + }); }); diff --git a/client/src/lib/ToolbarProductSelector.svelte b/client/src/lib/ToolbarProductSelector.svelte index a375b74..0584c45 100644 --- a/client/src/lib/ToolbarProductSelector.svelte +++ b/client/src/lib/ToolbarProductSelector.svelte @@ -73,8 +73,7 @@ type: 'raster', tiles: [ data.tileUrl.replace('{site}', selectedSite) - ], - 'tileSize': 512 + ] }); } if (map.getLayer("data")) { @@ -114,6 +113,25 @@ map.removeLayer(`select-${currentlySelectingFor}`); } } + if (map.getLayer("data")) { + map.removeLayer('data'); + } + if (layer.type === 'raster') { + if (!map.getSource(layer.id)) { + map.addSource(layer.id, { + type: 'raster', + tiles: [ + layer.tileUrl + ] + }); + } + map.addLayer({ + id: 'data', + type: 'raster', + source: `${layer.id}` + }); + } + }} > {layer.layer} @@ -177,7 +195,6 @@ tiles: [ idToTileUrlCache[selectedPrimaryLayer].replace('{site}', selectedSite) ], - 'tileSize': 512 }); } if (map.getLayer("data")) { diff --git a/client/src/lib/components/ui/sonner/index.ts b/client/src/lib/components/ui/sonner/index.ts new file mode 100644 index 0000000..1ad9f4a --- /dev/null +++ b/client/src/lib/components/ui/sonner/index.ts @@ -0,0 +1 @@ +export { default as Toaster } from "./sonner.svelte"; diff --git a/client/src/lib/components/ui/sonner/sonner.svelte b/client/src/lib/components/ui/sonner/sonner.svelte new file mode 100644 index 0000000..0631191 --- /dev/null +++ b/client/src/lib/components/ui/sonner/sonner.svelte @@ -0,0 +1,20 @@ + + + diff --git a/client/src/lib/stationData.ts b/client/src/lib/stationData.ts index f12dcb3..1b53b2f 100644 --- a/client/src/lib/stationData.ts +++ b/client/src/lib/stationData.ts @@ -50,6 +50,7 @@ export function stationGeojson(stationMap: Record): Featu const stations: Feature[] = []; for (const [icao, station] of Object.entries(stationMap)) { + if (station.stationType == 'TDWR') continue; const feature = turf.point([station.long, station.lat], { icao, icon: (() => { diff --git a/client/src/routes/+layout.svelte b/client/src/routes/+layout.svelte index 697cf5a..3e3a24a 100644 --- a/client/src/routes/+layout.svelte +++ b/client/src/routes/+layout.svelte @@ -1,10 +1,13 @@ + + {@render children()} \ No newline at end of file diff --git a/client/src/routes/+page.server.ts b/client/src/routes/+page.server.ts index c5a594b..5e03ff5 100644 --- a/client/src/routes/+page.server.ts +++ b/client/src/routes/+page.server.ts @@ -15,14 +15,14 @@ export const load: PageServerLoad = async () => { layer: 'Composite Reflectivity', type: 'raster', tileUrl: - 'https://tiler.weather.ax/grib2/noaa_mrms_composite_reflectivity_qcd_CONUS/{z}/{x}/{y}.png' + 'http://localhost:3000/grib2/noaa_mrms_merged_composite_reflectivity_qc_CONUS/{z}/{x}/{y}@2x.png', }, { id: '01JV7RZJ7W9KZBJ34CG7YSS0PZ', layer: 'Differential Reflectivity', type: 'raster', tileUrl: - 'https://tiler.weather.ax/grib2/noaa_mrms_composite_reflectivity_rhohv_CONUS/{z}/{x}/{y}.png' + 'https://tiler.weather.ax/grib2/noaa_mrms_composite_reflectivity_rhohv_CONUS/{z}/{x}/{y}@2x.png', } ] }, @@ -37,7 +37,7 @@ export const load: PageServerLoad = async () => { layer: 'Super Resolution Base Reflectivity (Tilt 1)', type: 'raster', tileUrl: - 'http://localhost:3000/nexrad/base_reflectivity_halfdegree/{site}/{z}/{x}/{y}@2x.png' + 'http://localhost:3000/nexrad/base_reflectivity_halfdegree/{site}/{z}/{x}/{y}@2x.png', }, ] } diff --git a/crates/ar2/src/lib.rs b/crates/ar2/src/lib.rs index d023935..4a49e29 100644 --- a/crates/ar2/src/lib.rs +++ b/crates/ar2/src/lib.rs @@ -87,7 +87,6 @@ pub fn parse(input: Vec) -> nexrad_data::result::Result { let mut vcp = None; let mut radials = vec![]; - println!("{:?}", file.header()); for mut record in file.records() { if record.compressed() { record = record.decompress()?; diff --git a/crates/ar2/src/main.rs b/crates/ar2/src/main.rs index 0b36bd9..e4fb654 100644 --- a/crates/ar2/src/main.rs +++ b/crates/ar2/src/main.rs @@ -1,8 +1,8 @@ -use std::fs; +use std::{env, fs}; use wxbox_ar2::parse; fn main() { - let f = fs::read("KCRP20170825_235733_V06").unwrap(); + let f = fs::read(env::args().nth(1).unwrap()).unwrap(); let f = parse(f).unwrap(); println!( "{:?}", diff --git a/crates/tiler/config.toml b/crates/tiler/config.toml index dcc43a5..b9a718b 100644 --- a/crates/tiler/config.toml +++ b/crates/tiler/config.toml @@ -18,19 +18,12 @@ no_coverage = -999.0 [data.nexrad.base_reflectivity_halfdegree] from = "DS.p94r0" palette = """ -Color: 5 0x40 0xe8 0xe3 -Color: 10 0x26 0xa4 0xfa -Color: 15 0x00 0x30 0xed -Color: 20 0x49 0xfb 0x3e -Color: 25 0x36 0xc2 0x2e -Color: 30 0x27 0x8c 0x1e -Color: 35 0xfe 0xf5 0x43 -Color: 40 0xeb 0xb4 0x33 -Color: 45 0xf6 0x95 0x2e -Color: 50 0xf8 0x0a 0x26 -Color: 55 0xcb 0x05 0x16 -Color: 60 0xa9 0x08 0x13 -Color: 65 0xee 0x34 0xfa -Color: 70 0x91 0x61 0xc4 -Color: 75 0xff 0xff 0xff +Color: 10 164 164 255 100 100 192 +Color: 20 64 128 255 32 64 128 +Color: 30 0 255 0 0 128 0 +Color: 40 255 255 0 255 128 0 +Color: 50 255 0 0 160 0 0 +Color: 60 255 0 255 128 0 128 +Color: 70 255 255 255 128 128 128 +Color: 80 128 128 128 """ \ No newline at end of file