sl-glw
Fetch, parse, and render GlobalWind (GLW) wind/current/wave event overlays for Second Life sailing maps.
GlobalWind is a community weather system for Second Life sailing: a GLW "event" describes a base wind/current/wave state for an area of the grid, plus per-region rectangular areas and circles that override it. This crate fetches an event from a GLW server, parses its JSON into strongly typed values, and draws the wind arrows, current arrows, wave glyphs, override labels, and an optional legend onto a Second Life map image.
It builds on sl-map-apis (the MapLike map image and grid
geometry) and sl-types (grid coordinates and zoom levels).
What it gives you
- Typed model of a GLW event (
GlwEvent,Base,Area,Circle, and the per-quantity newtypes likeWindDirection,KnotSpeed,WaveHeight) with validating constructors that reject out-of-range values. - Fetching by numeric id or string key, either through the low-level
GlwClient/fetch_event_by_*functions or the cachingGlwEventCache. - HTTP caching via
http-cache-semantics, layered as an in-memory LRU over a persistent on-diskredbstore, so repeated lookups respect the server's cache headers instead of re-fetching. - Rendering through the
MapLikeGlwExtextension trait, which addsdraw_glw_event/draw_glw_event_with_font(and per-shape helpers) to anysl-map-apisMapLike. Appearance is controlled byGlwStyleandGlwColorPalette.
Fonts
The crate never bundles a font. Label and legend rendering takes any
ab_glyph::Font you supply, so you choose the typeface and licensing.
The drawing methods that emit text (draw_glw_event_with_font and the
*_label / *_legend helpers) require a font argument; draw_glw_event
draws only the geometric overlay and needs none. A copy of DejaVuSans is
checked in at the workspace root for examples and tests.
Example
Fetch an event and draw it onto a map. GlwEventCache::new takes a cache
directory and an optional base URL (None uses the GLW default); the
MapLike here is whatever sl-map-apis map you are rendering onto.
use ;
use PlacementSlot;
// Persistent cache under ./cache, default GLW server.
let mut cache = new?;
// Returns Ok(None) if the server reports no such event.
if let Some = cache.get_event_by_id.await?
For a complete, runnable program — including a minimal in-memory MapLike
that needs no map tiles — see examples/render_sample.rs:
cargo run -p sl-glw --example render_sample -- DejaVuSans.ttf
The sl-map-cli and sl-map-web crates in the
same workspace show the overlay wired into real map renders.
License
Licensed under either of the Apache License, Version 2.0 or the MIT license
at your option (MIT OR Apache-2.0).