/// <summary> /// Returns the style based on a feature /// </summary> /// <param name="feature">Set of attribute values to calculate the <see cref="SharpMap.Styles.IStyle"/> from</param> /// <returns>The style</returns> public SharpMap.Styles.IStyle GetStyle(GeoAPI.Features.IFeature feature) { 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 SharpMap.Styles.IStyle GetStyle(GeoAPI.Features.IFeature fdr) { var retval = new SharpMap.Styles.VectorStyle(); if (fdr.Attributes["Bearing"] == DBNull.Value) { var bmp = new System.Drawing.Bitmap(36, 36); using (var g = System.Drawing.Graphics.FromImage(bmp)) { g.Clear(System.Drawing.Color.Wheat); g.FillEllipse(System.Drawing.Brushes.Green, 0, 0, 36, 36); g.DrawEllipse(new System.Drawing.Pen(System.Drawing.Brushes.Yellow, 3), 4, 4, 28, 28); g.DrawString("H", new System.Drawing.Font("Arial", 18, System.Drawing.FontStyle.Bold), System.Drawing.Brushes.Yellow, new System.Drawing.RectangleF(2, 2, 34, 34), new System.Drawing.StringFormat { Alignment = System.Drawing.StringAlignment.Center, LineAlignment = System.Drawing.StringAlignment.Center }); } bmp.MakeTransparent(System.Drawing.Color.Wheat); retval.Symbol = bmp; } else { retval.Symbol = ColoredArrow(_brush); var rot = Convert.ToSingle(fdr.Attributes["Bearing"]); retval.SymbolRotation = rot % 360f; } return(retval); }
/// <summary> /// Method for creating pie chart symbols /// </summary> /// <remarks> /// <para>In this example we just create some random pie charts, /// but it probably should be based on attributes read from the row.</para> /// <para>Credits goes to gonzalo_ar for posting this in the forum</para></remarks> /// <param name="row"></param> /// <returns></returns> private static Bitmap GetPieChart(GeoAPI.Features.IFeature row) { // Replace polygon with a center point (this is where we place the symbol row.Geometry = row.Geometry.Centroid; // Just for the example I use random values int size = rand.Next(20, 35); int angle1 = rand.Next(60, 180); int angle2 = rand.Next(angle1 + 60, 300); RectangleF rect = new RectangleF(0, 0, size, size); Bitmap b = new Bitmap(size, size); using (IGraphics g = Graphics.FromImage(b).G()) { // Draw Pie g.FillPie(Brushes.LightGreen, rect, 0, angle1); g.FillPie(Brushes.Pink, rect, angle1, angle2 - angle1); g.FillPie(Brushes.PeachPuff, rect, angle2, 360 - angle2); // Draw Borders g.DrawPie(Pens.Green, rect, 0, angle1); g.DrawPie(Pens.Red, rect, angle1, angle2 - angle1); g.DrawPie(Pens.Orange, rect, angle2, 360 - angle2); } return(b); }
internal static int GetRiverLength(GeoAPI.Features.IFeature row) { if (row == null) { return(0); } if (row.Geometry == null) { return(0); } var ml = row.Geometry as GeoAPI.Geometries.IMultiLineString; if (ml != null) { return(System.Convert.ToInt32(ml.Length)); } var l = row.Geometry as GeoAPI.Geometries.ILineString; if (l != null) { return(System.Convert.ToInt32(l.Length)); } return(0); }
/// <summary> /// This method is used for determining the style /// It is used as a delegate for the CustomTheme class. /// </summary> /// <param name="row"></param> /// <returns></returns> private VectorStyle GetCountryStyle(GeoAPI.Features.IFeature row) { VectorStyle s = new VectorStyle(); s.Fill = new SolidBrush(Color.Green); s.Symbol = GetPieChart(row); return(s); }
public void Test11GetFeature() { using (var provider = GetProvider()) { GeoAPI.Features.IFeature feature = null; NUnit.Framework.Assert.DoesNotThrow(() => feature = provider.GetFeatureByOid(5)); NUnit.Framework.Assert.NotNull(feature); NUnit.Framework.Assert.AreEqual(5, feature.Attributes[provider.ObjectIdColumn]); } }
public static bool JustTracks(GeoAPI.Features.IFeature fdr) { //System.Console.WriteLine(fdr [0] + ";"+ fdr[4]); var s = fdr.Attributes[4] as string; if (s != null) { return(s == "track"); } return(true); }
public void TestGetFeature() { using (var p = CreateProvider()) { GeoAPI.Features.IFeature feature = null; Assert.DoesNotThrow(() => feature = p.GetFeatureByOid(3)); Assert.IsNotNull(feature); Assert.AreEqual(3, (int)feature.Attributes[p.ObjectIdColumn]); Assert.AreEqual(feature.Geometry.Centroid.Coordinate, new Coordinate(429003.31, 360425.45)); } }
public SharpMap.Styles.VectorStyle GetRotatedSymol(GeoAPI.Features.IFeature row) { if (!System.String.IsNullOrEmpty(StyleRotationColumn)) { try { SharpMap.Styles.VectorStyle dataStyle = CloneStyle(DefaultStyle); dataStyle.SymbolRotation = System.Convert.ToSingle(row.Attributes[StyleRotationColumn]); return(dataStyle); } catch { } } return(null); }
public SharpMap.Styles.VectorStyle GetRotatedSymol(GeoAPI.Features.IFeature row) { if (!System.String.IsNullOrEmpty(SymbolColumn)) { try { SharpMap.Styles.VectorStyle dataStyle = CloneStyle(DefaultStyle); if (!row.IsNull(SymbolColumn)) { dataStyle.Symbol = new System.Drawing.Bitmap( new System.IO.MemoryStream((byte[])row.Attributes[SymbolColumn])); } return(dataStyle); } catch { } } return(null); }