/// <summary> /// returns a Random VectorStyle with no symbols. /// /// </summary> /// <returns></returns> public static GeoJsonGeometryStyle RandomGeometryStyle() { GeoJsonGeometryStyle vs = new GeoJsonGeometryStyle(); vs.EnableOutline = random.Next(0, 2) == 1; vs.Fill = RandomBrush(); vs.Line = RandomPen(); vs.Outline = RandomPen(); vs.Symbol = RandomSymbol(); vs.Outline.Width += vs.Line.Width; vs.HighlightFill = RandomBrush(); vs.HighlightLine = RandomPen(); vs.HighlightOutline = RandomPen(); vs.HighlightSymbol = RandomSymbol(); vs.SelectFill = RandomBrush(); vs.SelectLine = RandomPen(); vs.SelectOutline = RandomPen(); vs.SelectSymbol = RandomSymbol(); return(vs); }
protected override IEnumerable <TRenderObject> DoRenderFeature(IFeatureDataRecord feature, GeoJsonGeometryStyle style, RenderState state, ILayer layer) { if (feature == null) { throw new ArgumentNullException("feature"); } if (style == null) { throw new ArgumentNullException("style"); } if (feature.Geometry == null) { throw new InvalidOperationException("Feature must have a geometry to be rendered."); } StringBuilder sb = new StringBuilder(); GeoJsonFeatureWriter.WriteFeature(sb, style, feature); yield return((TRenderObject)(object)(new GeoJsonRenderObject(sb.ToString()))); /* oh dear - i feel very dirty now */ }
private static void setupShapefile(HttpContext context, Map m) { GeometryServices geometryServices = new GeometryServices(); string[] layernames = new[] { "Countries", "Rivers" /*, * "Cities"*/ }; foreach (string s in layernames) { ShapeFileProvider shapeFile = new ShapeFileProvider(context.Server.MapPath(string.Format("~/App_Data/Shapefiles/{0}.shp", s)), geometryServices.DefaultGeometryFactory, geometryServices.CoordinateSystemFactory, false); shapeFile.IsSpatiallyIndexed = false; AppStateMonitoringFeatureProvider provider = new AppStateMonitoringFeatureProvider(shapeFile); GeoJsonGeometryStyle style = RandomStyle.RandomGeometryStyle(); /* include GeoJson styles */ style.IncludeAttributes = false; style.IncludeBBox = true; style.PreProcessGeometries = false; style.CoordinateNumberFormatString = "{0:F}"; GeometryLayer geometryLayer = new GeometryLayer(s, style, provider); geometryLayer.Features.IsSpatiallyIndexed = false; m.AddLayer(geometryLayer); provider.Open(); } }
private static void setupMsSqlSpatial(Map m) { string[] layernames = new[] { "Rivers", "Countries" /*, * "Cities"*/ }; string sridstr = SridMap.DefaultInstance.Process(4326, ""); foreach (string lyrname in layernames) { string tbl = lyrname; AppStateMonitoringFeatureProvider provider = new AppStateMonitoringFeatureProvider( new MsSqlSpatialProvider( new GeometryServices()[sridstr], ConfigurationManager.ConnectionStrings["db"].ConnectionString, "st", "dbo", tbl, "oid", "Geometry") { DefaultProviderProperties = new ProviderPropertiesExpression( new ProviderPropertyExpression[] { new WithNoLockExpression(true) }) }); GeoJsonGeometryStyle style = new GeoJsonGeometryStyle(); switch (tbl) { case "Rivers": { StyleBrush brush = new SolidStyleBrush(StyleColor.Blue); StylePen pen = new StylePen(brush, 1); style.Enabled = true; style.EnableOutline = true; style.Line = pen; style.Fill = brush; break; } case "Countries": { StyleBrush brush = new SolidStyleBrush(new StyleColor(0, 0, 0, 255)); StylePen pen = new StylePen(brush, 2); style.Enabled = true; style.EnableOutline = true; style.Line = pen; style.Fill = new SolidStyleBrush(StyleColor.Green); break; } default: { style = RandomStyle.RandomGeometryStyle(); style.MaxVisible = 100000; break; } } /* include GeoJson styles */ style.IncludeAttributes = false; style.IncludeBBox = true; style.PreProcessGeometries = false; style.CoordinateNumberFormatString = "{0:F}"; GeometryLayer layer = new GeometryLayer(tbl, style, provider); layer.Features.IsSpatiallyIndexed = false; layer.AddProperty(AppStateMonitoringFeatureLayerProperties.AppStateMonitor, provider.Monitor); m.AddLayer(layer); } }