From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id E9D281FF0B4 for ; Fri, 27 Nov 2026 17:13:38 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 130C6217B2; Fri, 27 Nov 2026 17:13:12 +0100 (CET) From: Dominik Csapak To: pdm-devel@lists.proxmox.com Subject: [PATCH yew-widget-toolkit 21/38] widget: charts: world map: add a graticule Date: Fri, 27 Nov 2026 17:12:18 +0100 Message-ID: <20261127161241.3713494-22-d.csapak@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261127161241.3713494-1-d.csapak@proxmox.com> References: <20261127161241.3713494-1-d.csapak@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.252 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: ZH6WRSEUY7HZPNIKU2DG6GW4JBP5NHL5 X-Message-ID-Hash: ZH6WRSEUY7HZPNIKU2DG6GW4JBP5NHL5 X-MailFrom: d.csapak@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox Datacenter Manager development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: with a line of constant latitude or longitude every 30 degrees. It makes the water look less empty and helps to see how far the map is zoomed in. Signed-off-by: Dominik Csapak --- src/widget/charts/world_map.rs | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/widget/charts/world_map.rs b/src/widget/charts/world_map.rs index a73d279..172eab9 100644 --- a/src/widget/charts/world_map.rs +++ b/src/widget/charts/world_map.rs @@ -26,6 +26,9 @@ const HEIGHT: f64 = WIDTH / WIDTH_RATIO; // paths outside of the area it has to draw, which is much cheaper than clipping one huge path. const REGION_SIZE: f64 = WIDTH / 12.0; +// the distance between the lines of the graticule in degrees +const GRATICULE_STEP: usize = 30; + /// Represents a Location in the world using the geographic coordinate system. #[derive(Clone, Copy, PartialEq)] pub struct Location { @@ -244,6 +247,20 @@ fn calculate_shapes(geojson: &GeoJson) -> Vec { } } +/// The path commands for the lines of constant latitude and longitude. +fn graticule() -> String { + let mut path = String::new(); + for longitude in (GRATICULE_STEP..360).step_by(GRATICULE_STEP) { + let x = longitude as f64 * (WIDTH / 360.0); + let _ = write!(path, "M{x:.2},0V{HEIGHT:.2}"); + } + for latitude in (GRATICULE_STEP..180).step_by(GRATICULE_STEP) { + let y = latitude as f64 * (HEIGHT / 180.0); + let _ = write!(path, "M0,{y:.2}H{WIDTH:.2}"); + } + path +} + /// The background of a [WorldMap]. /// /// The shapes are big, and a [Map] renders a lot while it is panned and zoomed. Comparing them @@ -286,7 +303,10 @@ impl Component for WorldMapShapesComp { .into() }); - Group::new().children(features).into() + Group::new() + .with_child(Path::new().class("pwt-world-map-graticule").d(graticule())) + .children(features) + .into() } } -- 2.47.3