use geozero::geojson::GeoJsonReader; use geozero::ProcessToSvg; use std::fs::File; type Result = std::result::Result>; #[test] fn json_to_svg() -> Result<()> { let f = File::open("tests/data/places.json")?; let svg = GeoJsonReader(f).to_svg().unwrap(); println!("{svg}"); assert_eq!( &svg[svg.len() - 100..], r#"387481909902 1.294979325105942 Z"/> "# ); Ok(()) } /* // FlatgeoBuf to SVG conversion // Disabled, since we don't want to have a circular dependency between flatgeobuf and geozero use flatgeobuf::{FgbReader, Header}; use geozero::svg::SvgWriter; use seek_bufread::BufReader; use std::io::Write; fn invert_y(header: &Header) -> bool { if let Some(crs) = header.crs() { if crs.code() == 4326 { return true; } } false } fn svg_writer(header: &Header, width: u32, height: u32, out: W) -> SvgWriter { let mut svg = SvgWriter::new(out, invert_y(header)); if let Some(envelope) = header.envelope() { svg.set_dimensions( envelope.get(0), envelope.get(1), envelope.get(2), envelope.get(3), width, height, ); } svg } #[test] fn fgb_to_svg() -> Result<()> { let mut filein = BufReader::new(File::open("tests/data/countries.fgb")?); let mut fgb = FgbReader::open(&mut filein)?.select_bbox(8.8, 47.2, 9.5, 55.3)?; let mut svg_data: Vec = Vec::new(); let mut svg = svg_writer(&fgb.header(), 800, 400, &mut svg_data); fgb.process_features(&mut svg)?; let out = std::str::from_utf8(&svg_data).unwrap(); let expected = r#" "#; assert_eq!(&out[..expected.len()], expected); let expected = r#"99.93976 -78.88094 Z "/> "#; assert_eq!(&out[svg_data.len() - expected.len()..], expected); Ok(()) } */