/// <summary> /// Writes two geometries to an svg file /// </summary> /// <param name="filename">The path of the svg file.</param> /// <param name="a">The A geometry</param> /// <param name="b">The B geometry</param> public void DisplayTest(string filename, Geometry a, Geometry b) { Geotools.Geometries.PrecisionModel pm = new Geotools.Geometries.PrecisionModel(1, 0, 0); GeometryFactory fact = new GeometryFactory(pm, 0); GeometrySVGWriter svgWriter = new GeometrySVGWriter(fact.PrecisionModel); StreamWriter sw = new StreamWriter(filename); GeometryCollection geomCollection = fact.CreateGeometryCollection(new Geometry[] { a, b }); double minx, miny, maxx, maxy; geomCollection.Extent2D(out minx, out miny, out maxx, out maxy); sw.WriteLine(String.Format("<svg viewBox=\"{0} {1} {2} {3}\">", minx, miny, maxx, maxy * 1.2)); svgWriter.Write(a, sw, "fill-rule:evenodd;", "fill:blue;stroke:blue;stroke-width:1;fill-opacity:0.2"); svgWriter.Write(b, sw, "fill-rule:evenodd;", "fill:red;stroke:red;stroke-width:1;fill-opacity:0.2"); sw.WriteLine("</svg>"); sw.Close(); }
/// <summary> /// Converts the geometry to svg and writes the svg to a file. /// </summary> /// <param name="filename">The name of the svg file.</param> /// <param name="pm">The precision model for the geometries</param> /// <param name="a">The geometry to be written to svg.</param> public void CreateSVG(string filename, Geotools.Geometries.PrecisionModel pm, Geometry a) { GeometrySVGWriter svgWriter = new GeometrySVGWriter(pm); StreamWriter sw = new StreamWriter(filename); double minx, miny, maxx, maxy; a.Extent2D(out minx, out miny, out maxx, out maxy); sw.WriteLine(String.Format("<svg viewBox=\"{0} {1} {2} {3}\">", minx, miny, maxx, maxy * 1.2)); svgWriter.Write(a, sw, "fill-rule:evenodd;", "fill:ltgray;stroke:blue;stroke-width:1;fill-opacity:0.2"); sw.WriteLine("</svg>"); sw.Close(); }