/// <summary> /// Returns the style based on a feature /// </summary> /// <param name="attribute">Set of attribute values to calculate the <see cref="SharpMap.Styles.IStyle"/> from</param> /// <returns>The style</returns> public SharpMap.Styles.IStyle GetStyle(SharpMap.Data.FeatureDataRow attribute) { var res = _style; var cls = new SharpMap.Rendering.Symbolizer.CachedLineSymbolizer(); cls.LineSymbolizeHandlers.Add(new SharpMap.Rendering.Symbolizer.PlainLineSymbolizeHandler { Line = new System.Drawing.Pen(System.Drawing.Color.Gold, 2) }); var wls = new SharpMap.Rendering.Symbolizer.WarpedLineSymbolizeHander { Pattern = SharpMap.Rendering.Symbolizer.WarpedLineSymbolizer. GetGreaterSeries(3, 3), Line = new System.Drawing.Pen(System.Drawing.Color.Firebrick, 1) , Interval = 20 }; cls.LineSymbolizeHandlers.Add(wls); cls.ImmediateMode = true; res.LineSymbolizer = cls; return(res); }
public static void Example3() { var map = new SharpMap.Map(new Size(1280, 1084)); SharpMap.Data.Providers.IProvider provider = new SharpMap.Data.Providers.ShapeFile( @"C:\temp\Data\niedersachsen.shp\railways.shp"); var cls = new SharpMap.Rendering.Symbolizer.CachedLineSymbolizer(); cls.LineSymbolizeHandlers.Add( new SharpMap.Rendering.Symbolizer.PlainLineSymbolizeHandler { Line = new System.Drawing.Pen(System.Drawing.Color.Gold, 2) }); var wls = new SharpMap.Rendering.Symbolizer.WarpedLineSymbolizeHander { Pattern = SharpMap.Rendering.Symbolizer.WarpedLineSymbolizer. GetGreaterSeries(3, 3), Line = new System.Drawing.Pen(System.Drawing.Color.Firebrick, 1), Interval = 20 }; cls.LineSymbolizeHandlers.Add(wls); var vl = new SharpMap.Layers.Symbolizer.LinealVectorLayer( "Railways", provider); vl.Symbolizer = cls; map.Layers.Add(vl); var env = vl.Envelope; env.ExpandBy(-0.45f * env.Width, -0.45 * env.Height); map.ZoomToBox(env); var mapImage = map.GetMap(); mapImage.Save("Example3.png", System.Drawing.Imaging.ImageFormat.Png); }
public void TestWarpedLineSymbolizer() { if (!System.IO.File.Exists("d:\\daten\\GeoFabrik\\Aurich\\roads.shp")) { throw new NUnit.Framework.IgnoreException(""); } var p = new SharpMap.Data.Providers.ShapeFile(@"d:\\daten\\GeoFabrik\\Aurich\\roads.shp", false); var l = new SharpMap.Layers.VectorLayer("roads", p); var cls = new SharpMap.Rendering.Symbolizer.CachedLineSymbolizer(); cls.LineSymbolizeHandlers.Add(new SharpMap.Rendering.Symbolizer.PlainLineSymbolizeHandler { Line = new System.Drawing.Pen(System.Drawing.Color.Gold, 2) }); var wls = new SharpMap.Rendering.Symbolizer.WarpedLineSymbolizeHander { Pattern = SharpMap.Rendering.Symbolizer.WarpedLineSymbolizer. GetGreaterSeries(3, 3), Line = new System.Drawing.Pen(System.Drawing.Color.Firebrick, 1) , Interval = 20 }; cls.LineSymbolizeHandlers.Add(wls); l.Style.LineSymbolizer = cls; var m = new SharpMap.Map(new System.Drawing.Size(720, 540)) { BackColor = System.Drawing.Color.Cornsilk }; m.Layers.Add(l); m.ZoomToExtents(); var sw = new System.Diagnostics.Stopwatch(); sw.Start(); var bmp = m.GetMap(); sw.Stop(); System.Console.WriteLine(string.Format("Rendering new method: {0}ms", sw.ElapsedMilliseconds)); bmp.Save("AurichRoads1.bmp"); cls.LineSymbolizeHandlers[1] = new SharpMap.Rendering.Symbolizer.WarpedLineSymbolizeHander { Pattern = SharpMap.Rendering.Symbolizer.WarpedLineSymbolizer. GetTriangle(4, 0), Line = new System.Drawing.Pen(System.Drawing.Color.Firebrick, 1), Fill = new System.Drawing.SolidBrush(System.Drawing.Color.Firebrick) , Interval = 10 }; sw.Reset(); sw.Start(); bmp = m.GetMap(); sw.Stop(); System.Console.WriteLine(string.Format("Rendering new method: {0}ms", sw.ElapsedMilliseconds)); bmp.Save("AurichRoads2-0.bmp"); cls.LineSymbolizeHandlers[1] = new SharpMap.Rendering.Symbolizer.WarpedLineSymbolizeHander { Pattern = SharpMap.Rendering.Symbolizer.WarpedLineSymbolizer. GetTriangle(4, 1), Line = new System.Drawing.Pen(System.Drawing.Color.Firebrick, 1), Fill = new System.Drawing.SolidBrush(System.Drawing.Color.Firebrick) , Interval = 10 }; sw.Reset(); sw.Start(); bmp = m.GetMap(); sw.Stop(); System.Console.WriteLine(string.Format("Rendering new method: {0}ms", sw.ElapsedMilliseconds)); bmp.Save("AurichRoads2-1.bmp"); cls.LineSymbolizeHandlers[1] = new SharpMap.Rendering.Symbolizer.WarpedLineSymbolizeHander { Pattern = SharpMap.Rendering.Symbolizer.WarpedLineSymbolizer. GetTriangle(4, 2), Line = new System.Drawing.Pen(System.Drawing.Color.Firebrick, 1), Fill = new System.Drawing.SolidBrush(System.Drawing.Color.Firebrick) , Interval = 10 }; sw.Reset(); sw.Start(); bmp = m.GetMap(); sw.Stop(); System.Console.WriteLine(string.Format("Rendering new method: {0}ms", sw.ElapsedMilliseconds)); bmp.Save("AurichRoads2-2.bmp"); cls.LineSymbolizeHandlers[1] = new SharpMap.Rendering.Symbolizer.WarpedLineSymbolizeHander { Pattern = SharpMap.Rendering.Symbolizer.WarpedLineSymbolizer. GetTriangle(4, 3), Line = new System.Drawing.Pen(System.Drawing.Color.Firebrick, 1), Fill = new System.Drawing.SolidBrush(System.Drawing.Color.Firebrick) , Interval = 10 }; sw.Reset(); sw.Start(); bmp = m.GetMap(); sw.Stop(); System.Console.WriteLine(string.Format("Rendering new method: {0}ms", sw.ElapsedMilliseconds)); bmp.Save("AurichRoads2-3.bmp"); //cls.LineSymbolizeHandlers[0] = cls.LineSymbolizeHandlers[1]; cls.LineSymbolizeHandlers[1] = new SharpMap.Rendering.Symbolizer.WarpedLineSymbolizeHander { Pattern = SharpMap.Rendering.Symbolizer.WarpedLineSymbolizer.GetZigZag(4, 4), Line = new System.Drawing.Pen(System.Drawing.Color.Firebrick, 1), //Fill = new System.Drawing.SolidBrush(System.Drawing.Color.Firebrick) }; sw.Reset(); sw.Start(); bmp = m.GetMap(); sw.Stop(); System.Console.WriteLine(string.Format("Rendering new method: {0}ms", sw.ElapsedMilliseconds)); bmp.Save("AurichRoads3.bmp"); }
public void TestWarpedLineSymbolizer() { var p = new SharpMap.Data.Providers.ShapeFile(@"d:\\daten\GeoFabrik\\Aurich\\roads.shp", false); var l = new SharpMap.Layers.VectorLayer("roads", p); var cls = new SharpMap.Rendering.Symbolizer.CachedLineSymbolizer(); cls.LineSymbolizeHandlers.Add(new SharpMap.Rendering.Symbolizer.PlainLineSymbolizeHandler {Line = new System.Drawing.Pen(System.Drawing.Color.Gold, 2)}); var wls = new SharpMap.Rendering.Symbolizer.WarpedLineSymbolizeHander { Pattern = SharpMap.Rendering.Symbolizer.WarpedLineSymbolizer. GetGreaterSeries(3, 3), Line = new System.Drawing.Pen(System.Drawing.Color.Firebrick, 1) , Interval = 20 }; cls.LineSymbolizeHandlers.Add(wls); l.Style.LineSymbolizer = cls; var m = new SharpMap.Map(new System.Drawing.Size(720, 540)) {BackColor = System.Drawing.Color.Cornsilk}; m.Layers.Add(l); m.ZoomToExtents(); var sw = new System.Diagnostics.Stopwatch(); sw.Start(); var bmp = m.GetMap(); sw.Stop(); System.Console.WriteLine(string.Format("Rendering new method: {0}ms", sw.ElapsedMilliseconds)); bmp.Save("AurichRoads1.bmp"); cls.LineSymbolizeHandlers[1] = new SharpMap.Rendering.Symbolizer.WarpedLineSymbolizeHander { Pattern = SharpMap.Rendering.Symbolizer.WarpedLineSymbolizer. GetTriangle(4, 0), Line = new System.Drawing.Pen(System.Drawing.Color.Firebrick, 1), Fill = new System.Drawing.SolidBrush(System.Drawing.Color.Firebrick) ,Interval = 10 }; sw.Reset(); sw.Start(); bmp = m.GetMap(); sw.Stop(); System.Console.WriteLine(string.Format("Rendering new method: {0}ms", sw.ElapsedMilliseconds)); bmp.Save("AurichRoads2-0.bmp"); cls.LineSymbolizeHandlers[1] = new SharpMap.Rendering.Symbolizer.WarpedLineSymbolizeHander { Pattern = SharpMap.Rendering.Symbolizer.WarpedLineSymbolizer. GetTriangle(4, 1), Line = new System.Drawing.Pen(System.Drawing.Color.Firebrick, 1), Fill = new System.Drawing.SolidBrush(System.Drawing.Color.Firebrick) , Interval = 10 }; sw.Reset(); sw.Start(); bmp = m.GetMap(); sw.Stop(); System.Console.WriteLine(string.Format("Rendering new method: {0}ms", sw.ElapsedMilliseconds)); bmp.Save("AurichRoads2-1.bmp"); cls.LineSymbolizeHandlers[1] = new SharpMap.Rendering.Symbolizer.WarpedLineSymbolizeHander { Pattern = SharpMap.Rendering.Symbolizer.WarpedLineSymbolizer. GetTriangle(4, 2), Line = new System.Drawing.Pen(System.Drawing.Color.Firebrick, 1), Fill = new System.Drawing.SolidBrush(System.Drawing.Color.Firebrick) , Interval = 10 }; sw.Reset(); sw.Start(); bmp = m.GetMap(); sw.Stop(); System.Console.WriteLine(string.Format("Rendering new method: {0}ms", sw.ElapsedMilliseconds)); bmp.Save("AurichRoads2-2.bmp"); cls.LineSymbolizeHandlers[1] = new SharpMap.Rendering.Symbolizer.WarpedLineSymbolizeHander { Pattern = SharpMap.Rendering.Symbolizer.WarpedLineSymbolizer. GetTriangle(4, 3), Line = new System.Drawing.Pen(System.Drawing.Color.Firebrick, 1), Fill = new System.Drawing.SolidBrush(System.Drawing.Color.Firebrick) , Interval = 10 }; sw.Reset(); sw.Start(); bmp = m.GetMap(); sw.Stop(); System.Console.WriteLine(string.Format("Rendering new method: {0}ms", sw.ElapsedMilliseconds)); bmp.Save("AurichRoads2-3.bmp"); //cls.LineSymbolizeHandlers[0] = cls.LineSymbolizeHandlers[1]; cls.LineSymbolizeHandlers[1] = new SharpMap.Rendering.Symbolizer.WarpedLineSymbolizeHander { Pattern = SharpMap.Rendering.Symbolizer.WarpedLineSymbolizer.GetZigZag(4, 4), Line = new System.Drawing.Pen(System.Drawing.Color.Firebrick, 1), //Fill = new System.Drawing.SolidBrush(System.Drawing.Color.Firebrick) }; sw.Reset(); sw.Start(); bmp = m.GetMap(); sw.Stop(); System.Console.WriteLine(string.Format("Rendering new method: {0}ms", sw.ElapsedMilliseconds)); bmp.Save("AurichRoads3.bmp"); }
/// <summary> /// Returns the style based on a feature /// </summary> /// <param name="attribute">Set of attribute values to calculate the <see cref="SharpMap.Styles.IStyle"/> from</param> /// <returns>The style</returns> public SharpMap.Styles.IStyle GetStyle(SharpMap.Data.FeatureDataRow attribute) { var res = _style; var cls = new SharpMap.Rendering.Symbolizer.CachedLineSymbolizer(); cls.LineSymbolizeHandlers.Add(new SharpMap.Rendering.Symbolizer.PlainLineSymbolizeHandler { Line = new System.Drawing.Pen(System.Drawing.Color.Gold, 2) }); var wls = new SharpMap.Rendering.Symbolizer.WarpedLineSymbolizeHander { Pattern = SharpMap.Rendering.Symbolizer.WarpedLineSymbolizer. GetGreaterSeries(3, 3), Line = new System.Drawing.Pen(System.Drawing.Color.Firebrick, 1) , Interval = 20 }; cls.LineSymbolizeHandlers.Add(wls); cls.ImmediateMode = true; res.LineSymbolizer = cls; return res; }
public void TestWarpedLineSymbolizer() { var p = new SharpMap.Data.Providers.ShapeFile(GetTestFile(), false); var l = new SharpMap.Layers.VectorLayer("roads", p); var cls = new SharpMap.Rendering.Symbolizer.CachedLineSymbolizer(); cls.LineSymbolizeHandlers.Add(new SharpMap.Rendering.Symbolizer.PlainLineSymbolizeHandler { Line = new System.Drawing.Pen(System.Drawing.Color.Gold, 2) }); var wls = new SharpMap.Rendering.Symbolizer.WarpedLineSymbolizeHander { Pattern = SharpMap.Rendering.Symbolizer.WarpedLineSymbolizer. GetGreaterSeries(3, 3), Line = new System.Drawing.Pen(System.Drawing.Color.Firebrick, 1) , Interval = 20 }; cls.LineSymbolizeHandlers.Add(wls); l.Style.LineSymbolizer = cls; var m = new SharpMap.Map(new System.Drawing.Size(720, 540)) { BackColor = System.Drawing.Color.Cornsilk }; m.Layers.Add(l); m.ZoomToExtents(); var sw = new System.Diagnostics.Stopwatch(); sw.Start(); var bmp = m.GetMap(); sw.Stop(); System.Diagnostics.Trace.WriteLine(string.Format("Rendering new method: {0}ms", sw.ElapsedMilliseconds)); bmp.Save(System.IO.Path.Combine(UnitTestsFixture.GetImageDirectory(this), "AurichRoads1.bmp")); cls.LineSymbolizeHandlers[1] = new SharpMap.Rendering.Symbolizer.WarpedLineSymbolizeHander { Pattern = SharpMap.Rendering.Symbolizer.WarpedLineSymbolizer. GetTriangle(4, 0), Line = new System.Drawing.Pen(System.Drawing.Color.Firebrick, 1), Fill = new System.Drawing.SolidBrush(System.Drawing.Color.Firebrick) , Interval = 10 }; sw.Reset(); sw.Start(); bmp = m.GetMap(); sw.Stop(); System.Diagnostics.Trace.WriteLine(string.Format("Rendering new method: {0}ms", sw.ElapsedMilliseconds)); bmp.Save(System.IO.Path.Combine(UnitTestsFixture.GetImageDirectory(this), "AurichRoads2-0.bmp")); cls.LineSymbolizeHandlers[1] = new SharpMap.Rendering.Symbolizer.WarpedLineSymbolizeHander { Pattern = SharpMap.Rendering.Symbolizer.WarpedLineSymbolizer. GetTriangle(4, 1), Line = new System.Drawing.Pen(System.Drawing.Color.Firebrick, 1), Fill = new System.Drawing.SolidBrush(System.Drawing.Color.Firebrick) , Interval = 10 }; sw.Reset(); sw.Start(); bmp = m.GetMap(); sw.Stop(); System.Diagnostics.Trace.WriteLine(string.Format("Rendering new method: {0}ms", sw.ElapsedMilliseconds)); bmp.Save(System.IO.Path.Combine(UnitTestsFixture.GetImageDirectory(this), "AurichRoads2-1.bmp")); cls.LineSymbolizeHandlers[1] = new SharpMap.Rendering.Symbolizer.WarpedLineSymbolizeHander { Pattern = SharpMap.Rendering.Symbolizer.WarpedLineSymbolizer. GetTriangle(4, 2), Line = new System.Drawing.Pen(System.Drawing.Color.Firebrick, 1), Fill = new System.Drawing.SolidBrush(System.Drawing.Color.Firebrick) , Interval = 10 }; sw.Reset(); sw.Start(); bmp = m.GetMap(); sw.Stop(); System.Diagnostics.Trace.WriteLine(string.Format("Rendering new method: {0}ms", sw.ElapsedMilliseconds)); bmp.Save(System.IO.Path.Combine(UnitTestsFixture.GetImageDirectory(this), "AurichRoads2-2.bmp")); cls.LineSymbolizeHandlers[1] = new SharpMap.Rendering.Symbolizer.WarpedLineSymbolizeHander { Pattern = SharpMap.Rendering.Symbolizer.WarpedLineSymbolizer. GetTriangle(4, 3), Line = new System.Drawing.Pen(System.Drawing.Color.Firebrick, 1), Fill = new System.Drawing.SolidBrush(System.Drawing.Color.Firebrick) , Interval = 10 }; sw.Reset(); sw.Start(); bmp = m.GetMap(); sw.Stop(); System.Diagnostics.Trace.WriteLine(string.Format("Rendering new method: {0}ms", sw.ElapsedMilliseconds)); bmp.Save(System.IO.Path.Combine(UnitTestsFixture.GetImageDirectory(this), "AurichRoads2-3.bmp")); //cls.LineSymbolizeHandlers[0] = cls.LineSymbolizeHandlers[1]; cls.LineSymbolizeHandlers[1] = new SharpMap.Rendering.Symbolizer.WarpedLineSymbolizeHander { Pattern = SharpMap.Rendering.Symbolizer.WarpedLineSymbolizer.GetZigZag(4, 4), Line = new System.Drawing.Pen(System.Drawing.Color.Firebrick, 1), //Fill = new System.Drawing.SolidBrush(System.Drawing.Color.Firebrick) }; sw.Reset(); sw.Start(); bmp = m.GetMap(); sw.Stop(); System.Diagnostics.Trace.WriteLine(string.Format("Rendering new method: {0}ms", sw.ElapsedMilliseconds)); bmp.Save(System.IO.Path.Combine(UnitTestsFixture.GetImageDirectory(this), "AurichRoads3.bmp")); }