From f08648e4b5a9f7855a2ed9068a386e2f3c596322 Mon Sep 17 00:00:00 2001 From: Ruben Beltran del Rio Date: Tue, 16 Dec 2025 10:40:44 +0100 Subject: Initial implementation --- examples/generate_map.rs | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 examples/generate_map.rs (limited to 'examples/generate_map.rs') diff --git a/examples/generate_map.rs b/examples/generate_map.rs new file mode 100644 index 0000000..8b9cf80 --- /dev/null +++ b/examples/generate_map.rs @@ -0,0 +1,38 @@ +use std::fs; +use wmap_renderer::{render_to_png, render_to_svg, Configuration, StageType}; + +fn main() -> Result<(), Box> { + // Read the example.wmap file + let map_source = fs::read_to_string("examples/example.wmap")?; + let map = wmap_parser::parse(&map_source); + let config = Configuration::default(); + + // Generate PNG with smart positioning + println!("Generating PNG with smart positioning..."); + let png_data = render_to_png(&map, StageType::Activities, &config)?; + fs::write("example.png", png_data)?; + println!("Generated example.png"); + + // Generate SVG with smart positioning + println!("Generating SVG with smart positioning..."); + let svg_data = render_to_svg(&map, StageType::Activities, &config)?; + fs::write("example.svg", svg_data)?; + println!("Generated example.svg"); + + // Generate with different stage type + println!("Generating with publication types stage type..."); + let png_publication_types = render_to_png(&map, StageType::PublicationTypes, &config)?; + fs::write("example_publication_types.png", png_publication_types)?; + println!("Generated example_publication_types.png"); + + // Generate without smart positioning (simple right-side positioning) + println!("Generating without smart positioning..."); + let mut config_no_smart = Configuration::default(); + config_no_smart.options.smart_label_positioning = false; + let png_no_smart = render_to_png(&map, StageType::Activities, &config_no_smart)?; + fs::write("example_no_smart_positioning.png", png_no_smart)?; + println!("Generated example_no_smart_positioning.png"); + + println!("\nAll examples generated successfully!"); + Ok(()) +} -- cgit