geo-svg

This crate is a lib to generate SVG strings from geo-types.

crate.io docs.rs

Below is an example of a geometry collection rendered to SVG.

example

Features

Example

The following will show how to convert a line to a SVG string. The [to_svg] method is provided by the [ToSvg] trait which is implemented for all geo-types.

```rust use geotypes::{Coordinate, Line, Point}; use geosvg::{Color, ToSvg}; let point = Point::new(10.0, 28.1); let line = Line::new( Coordinate { x: 114.19, y: 22.26 }, Coordinate { x: 15.93, y: -15.76 }, );

let svg = point .tosvg() .withradius(2.0) .and(line.tosvg().withstrokewidth(2.5)) .fill(Color::Named("red")) .withstrokecolor(Color::Rgb(200, 0, 100)) .withfill_opacity(0.7);

println!("{}", svg); ```

Result

xml <svg xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMidYMid meet" viewBox="7 -18.26 109.69 49.36"><circle cx="10" cy="28.1" r="2" fill="red" fill-opacity="0.7" stroke="rgb(200,0,100)"/><path d="M 114.19 22.26 L 15.93 -15.76" fill="red" fill-opacity="0.7" stroke="rgb(200,0,100)" stroke-width="2.5"/></svg>