public FeatureSet DrawLine() { FeatureSet lineF = new FeatureSet(FeatureType.Line); lineF.Projection = map.Projection; lineF.DataTable.Columns.Add("Value", typeof(double));//方便之后在等值线上标注 MapLineLayer lineLayer = default(MapLineLayer); lineLayer = (MapLineLayer)map.Layers.Add(lineF); LineSymbolizer symnol = new LineSymbolizer(Color.Black, 2); lineLayer.Symbolizer = symnol; string[] thename = raster.Filename.Split('\\'); lineLayer.LegendText = thename[thename.Length - 1] + "_line"; //MapLabelLayer MapLabelLayer labelLayer = new MapLabelLayer(); ILabelCategory category = labelLayer.Symbology.Categories[0]; category.Expression = "[Value]"; category.SelectionSymbolizer.BackColorEnabled = true; category.Symbolizer.BorderVisible = false; category.Symbolizer.BackColor = Color.FromArgb(128, Color.LightBlue);; category.Symbolizer.FontStyle = FontStyle.Regular; category.Symbolizer.FontColor = Color.Black; category.Symbolizer.FontSize = 8.5f; category.Symbolizer.Orientation = ContentAlignment.MiddleCenter; category.Symbolizer.Alignment = StringAlignment.Center; lineLayer.ShowLabels = true; lineLayer.LabelLayer = labelLayer; /*double min_X, min_Y, max_X, max_Y; * min_X = raster.Xllcenter - raster.CellWidth / 2; * min_Y = raster.Yllcenter - raster.CellHeight / 2; * max_X = raster.CellToProj(0, raster.NumColumns-1).X + raster.CellWidth / 2; * max_Y = raster.CellToProj(0, 0).Y + raster.CellHeight/2; * double interspace = (raster.CellToProj(1, 1).X - raster.CellToProj(0, 0).X) * * (raster.CellToProj(1, 1).X - raster.CellToProj(0, 0).X) + (raster.CellToProj(1, 1).Y - raster.CellToProj(0, 0).Y) * * (raster.CellToProj(1, 1).Y - raster.CellToProj(0, 0).Y); * Console.WriteLine("minX: " + min_X + " , minY: "+ min_Y + " , maxX: " + max_X + " , maxY: " + max_Y);*/ List <Tin_Point> lpoints = new List <Tin_Point>(); foreach (var lines in contourData) { //if(lines.Key == 18) //{ //int i = 0; foreach (var line in lines.Value) { Tin_Point p1 = new Tin_Point(line.startPoint.X, line.startPoint.Y, lines.Key); Tin_Point p2 = new Tin_Point(line.endPoint.X, line.endPoint.Y, lines.Key); //p1.Type = i; //p2.Type = i; lpoints.Add(p1); lpoints.Add(p2); List <Coordinate> lineArray = new List <Coordinate>(); LineString lineGeometry = new LineString(lineArray); IFeature lineFeature = lineF.AddFeature(lineGeometry); lineFeature.Coordinates.Add(line.startPoint); lineFeature.Coordinates.Add(line.endPoint); lineFeature.DataRow["Value"] = lines.Key; lineF.InitializeVertices(); //i++; } //} } /* * Polish polish = new Polish(); * List<List<Tin_Point>> new_tin_points = polish.ClassifyLine(lpoints); * Console.WriteLine("new_tin_point num: " + new_tin_points.Count); * foreach(var lines in new_tin_points) * { * //int i = 0; * foreach(var p in lines) * { * Console.Write(p.X + " , " + p.Y + "||"); * } * Console.WriteLine("*********************************"); * } * foreach (var lines in new_tin_points) * { * //int i = 0; * * Console.WriteLine(lines[0].X + " , " + lines[0].Y + "||" + lines[lines.Count-1].X + " , " + lines[lines.Count - 1].Y); * } * * * foreach (var freeline in new_tin_points) * { * List<Coordinate> lineArray = new List<Coordinate>(); ; * ILineString lineGeometry = new LineString(lineArray); * IFeature lineFeature = lineF.AddFeature(lineGeometry); * lineFeature.DataRow["Value"] = (int)freeline[0].Value; * foreach (var p in freeline) * { * Coordinate coordinate = new Coordinate(p.X, p.Y); * lineArray.Add(coordinate); * lineFeature.Coordinates.Add(coordinate); * lineF.InitializeVertices(); * } * } */ map.ResetBuffer(); return(lineF); }
/// <summary> /// Load base maps for World template project. The base shapefiles /// are loaded from the [Program Files]\[Cuahsi HIS]\HydroDesktop\maps\BaseData folder. /// </summary> public static Boolean LoadBaseMaps(AppManager applicationManager1, Map mainMap) { //set the projection of main map mainMap.Projection = projWorld.WebMercator; Extent defaultMapExtent = new Extent(-170, -50, 170, 50); string baseMapFolder = Settings.Instance.DefaultBaseMapDirectory; //MapGroup baseGroup = new MapGroup(mainMap.Layers, mainMap.MapFrame, mainMap.ProgressHandler); //baseGroup.LegendText = "Base Map Data"; //baseGroup.ParentMapFrame = mainMap.MapFrame; //baseGroup.MapFrame = mainMap.MapFrame; //baseGroup.IsVisible = true; //load the 'Countries of the world' layer try { mainMap.BackColor = Color.LightBlue; string fileName = Path.Combine(baseMapFolder, "world_countries.shp"); if (File.Exists(fileName)) { IFeatureSet fsCountries = FeatureSet.OpenFile(fileName); MapPolygonLayer layCountries = new MapPolygonLayer(fsCountries); layCountries.LegendText = "Countries"; layCountries.Symbolizer = new PolygonSymbolizer(Color.FromArgb(255, 239, 213), Color.LightGray); //PolygonScheme schmCountries = new PolygonScheme(); //schmCountries.EditorSettings.StartColor = Color.Orange; //schmCountries.EditorSettings.EndColor = Color.Silver; //schmCountries.EditorSettings.ClassificationType = // ClassificationType.UniqueValues; //schmCountries.EditorSettings.FieldName = "NAME"; //schmCountries.EditorSettings.UseGradient = true; //schmCountries.CreateCategories(layCountries.DataSet.DataTable); //layCountries.Symbology = schmCountries; //baseGroup.Layers.Add(layCountries); mainMap.Layers.Add(layCountries); layCountries.MapFrame = mainMap.MapFrame; layCountries.ProgressReportingEnabled = false; } } catch { } //load a rivers layer try { var fileName = Path.Combine(baseMapFolder, "world_rivers.shp"); if (File.Exists(fileName)) { IFeatureSet fsRivers = FeatureSet.OpenFile(fileName); //fsRivers.Reproject(mainMap.Projection); MapLineLayer layRivers = new MapLineLayer(fsRivers); layRivers.LegendText = "rivers"; LineSymbolizer symRivers = new LineSymbolizer(Color.Blue, 1.0); layRivers.Symbolizer = symRivers; mainMap.Layers.Add(layRivers); layRivers.MapFrame = mainMap.MapFrame; } } catch { } //load a lakes layer try { var fileName = Path.Combine(baseMapFolder, "world_lakes.shp"); if (File.Exists(fileName)) { IFeatureSet fsLakes = FeatureSet.OpenFile(fileName); //fsLakes.Reproject(mainMap.Projection); MapPolygonLayer layLakes = new MapPolygonLayer(fsLakes); layLakes.LegendText = "lakes"; PolygonSymbolizer symLakes = new PolygonSymbolizer(Color.Blue, Color.Blue); layLakes.Symbolizer = symLakes; mainMap.Layers.Add(layLakes); layLakes.MapFrame = mainMap.MapFrame; layLakes.ProgressReportingEnabled = false; } } catch { } double[] xy = new double[4]; xy[0] = defaultMapExtent.MinX; xy[1] = defaultMapExtent.MinY; xy[2] = defaultMapExtent.MaxX; xy[3] = defaultMapExtent.MaxY; double[] z = new double[] { 0, 0 }; var wgs84 = ProjectionInfo.FromEsriString(Properties.Resources.wgs_84_esri_string); Reproject.ReprojectPoints(xy, z, wgs84, mainMap.Projection, 0, 2); mainMap.ViewExtents = new Extent(xy); return(true); }
/// <summary> /// Sets up the Table to work with the specified layer. This should be the copy, /// and not the original. /// </summary> /// <param name="layer"></param> public void Initialize(IFeatureLayer layer) { _original = layer.Symbology; _newScheme = _original.Copy(); _source = layer.DataSet; if (!layer.DataSet.AttributesPopulated) { if (layer.DataSet.NumRows() < 100000) { _source.FillAttributes(); // for small datasets, it is better to just load and cache it. } } if (_source.AttributesPopulated) { _expressionDialog.Table = _source.DataTable; } else { _expressionDialog.AttributeSource = _source; } _schemeType = GetSchemeType(layer); if (_schemeType != SymbolizerType.Polygon) { chkUseGradients.Visible = false; angGradientAngle.Visible = false; } else { chkUseGradients.Visible = true; angGradientAngle.Visible = true; } if (_schemeType == SymbolizerType.Point) { IPointScheme ps = _newScheme as IPointScheme; if (ps != null) { IPointSymbolizer sym; if (ps.Categories.Count == 0 || ps.Categories[0].Symbolizer == null) { sym = new PointSymbolizer(); } else { sym = ps.Categories[0].Symbolizer; } _ignoreRefresh = true; featureSizeRangeControl1.SizeRange = new FeatureSizeRange(sym, _newScheme.EditorSettings.StartSize, _newScheme.EditorSettings.EndSize); featureSizeRangeControl1.Initialize(new SizeRangeEventArgs(_newScheme.EditorSettings.StartSize, _newScheme.EditorSettings.EndSize, sym, _newScheme.EditorSettings.UseSizeRange)); featureSizeRangeControl1.Scheme = ps; featureSizeRangeControl1.Visible = true; _ignoreRefresh = false; } } else if (_schemeType == SymbolizerType.Line) { ILineScheme ls = _newScheme as ILineScheme; if (ls != null) { ILineSymbolizer sym; if (ls.Categories.Count == 0 || ls.Categories[0].Symbolizer == null) { sym = new LineSymbolizer(); } else { sym = ls.Categories[0].Symbolizer; } _ignoreRefresh = true; featureSizeRangeControl1.SizeRange = new FeatureSizeRange(sym, _newScheme.EditorSettings.StartSize, _newScheme.EditorSettings.EndSize); featureSizeRangeControl1.Initialize(new SizeRangeEventArgs(_newScheme.EditorSettings.StartSize, _newScheme.EditorSettings.EndSize, sym, _newScheme.EditorSettings.UseSizeRange)); featureSizeRangeControl1.Scheme = ls; featureSizeRangeControl1.Visible = true; _ignoreRefresh = false; } } else { featureSizeRangeControl1.Visible = false; } UpdateFields(); if (_newScheme.EditorSettings.ClassificationType != ClassificationType.Quantities) return; nudCategoryCount.Enabled = true; tabScheme.Visible = true; dgvCategories.Height = 217; UpdateStatistics(false, null); }
private LineSymbolizer CreateLineSymbolizer(NodePropertyValue[] properties) { LineSymbolizer symLine = new LineSymbolizer(); symLine.Stroke.LineCap = System.Drawing.Drawing2D.LineCap.Flat; symLine.Stroke.LineJoin = System.Drawing.Drawing2D.LineJoin.Miter; symLine.Clip = true; GeometryTransformInfo geomTrans = new GeometryTransformInfo(); NodePropertyValue pv = null; try { int nProps = properties.Length; for (int i = 0; i < nProps; i++) { pv = properties[i]; switch (pv.Name) { case "line-width": symLine.Stroke.Width = Convert.ToSingle(pv.Value); break; case "line-color": Color clr = ColorUtility.FromHtml(pv.Value); symLine.Stroke.Color = clr; if (clr.A != 255) symLine.Stroke.Opacity = clr.A / 255.0F; break; case "line-opacity": symLine.Stroke.Opacity = Convert.ToSingle(pv.Value); break; case "line-join": symLine.Stroke.LineJoin = ToLineJoin(pv.Value); break; case "line-cap": symLine.Stroke.LineCap = ToLineCap(pv.Value); break; case "line-dasharray": symLine.Stroke.DashArray = ConvertUtility.ToFloatArray(pv.Value); break; case "line-miterlimit": symLine.Stroke.MiterLimit = Convert.ToSingle(pv.Value); break; case "line-dash-offset": symLine.Stroke.DashOffset = Convert.ToSingle(pv.Value); break; case "line-comp-op": UnsupportedProperty(pv); AddProperty(symLine, "comp-op", pv.Value); break; case "line-rasterizer": UnsupportedProperty(pv); break; case "line-simplify": geomTrans.Simplify = pv.Value; break; case "line-simplify-algorithm": geomTrans.SimplifyAlgorithm = pv.Value; break; case "line-smooth": geomTrans.Smooth = pv.Value; break; case "line-offset": geomTrans.Offset = pv.Value; break; case "line-geometry-transform": geomTrans.GeometryTransform = pv.Value; break; } } } catch(Exception ex) { ThrowParsingException(ex, pv); } symLine.GeometryExpression = ToGeometryExpression(geomTrans); return symLine; }
/// <summary> /// Translates the given style as line style and adds it to the given line scheme. /// </summary> /// <param name="scheme">The scheme the style gets added to.</param> /// <param name="style">The style that gets translated.</param> private static void TranslateLineStyle(LineScheme scheme, string style) { if (string.IsNullOrWhiteSpace(style)) { return; } var mystyle = style; int index = mystyle.IndexOf("(", StringComparison.Ordinal); if (index < 1) { return; } var toolname = mystyle.Substring(0, index); mystyle = mystyle.Substring(index + 1); Color col = Color.Black; double width = 1; DashStyle dashStyle = DashStyle.Solid; float[] pattern = null; bool invisible = true; switch (toolname) { case "PEN": col = GetColor(ref mystyle, Parameters.Color); width = GetWidth(ref mystyle); pattern = GetPattern(ref mystyle); dashStyle = GetDashStyle(ref mystyle, out invisible); break; } if (pattern != null) { dashStyle = DashStyle.Custom; } if (invisible) { col = Color.Transparent; } var stroke = new CartographicStroke(col) { Width = width, DashStyle = dashStyle }; if (pattern != null) { stroke.DashPattern = pattern; } var symb = new LineSymbolizer { ScaleMode = ScaleMode.Simple, Smoothing = false, Strokes = { [0] = stroke } }; var cat = new LineCategory { FilterExpression = $"[style] = '{style}'", LegendText = style, Symbolizer = symb }; scheme.AddCategory(cat); }
public void setSymbolizer() { double baseWidth = 20.0; double baseOutlineWidth = 10.0; double adjWidth = baseWidth; double adjOutlineWidth = baseOutlineWidth; LineScheme rdScheme = new LineScheme(); LineSymbolizer catSelSym = new LineSymbolizer(); catSelSym.ScaleMode = ScaleMode.Geographic; catSelSym.SetWidth(adjWidth); catSelSym.SetOutline(Color.Blue, adjOutlineWidth); catSelSym.SetFillColor(Color.White); LineSymbolizer symDef = new LineSymbolizer(); symDef.ScaleMode = ScaleMode.Geographic; symDef.SetWidth(adjWidth); symDef.SetOutline(Color.Black, adjOutlineWidth); symDef.SetFillColor(Color.Gray); LineCategory catDef = new LineCategory(); catDef.LegendText = "No RSL Info"; catDef.SelectionSymbolizer = catSelSym; catDef.Symbolizer = symDef; rdScheme.AddCategory(catDef); int[] r = new int[30]; int[] g = new int[30]; int[] b = new int[30]; if (Project.settings.GetValue("road_colors").Contains("t")) { if (moduleRoads.roadColors == "RSL") { for (int rsl = 0; rsl <= 20; rsl++) { // create a category LineCategory colorCat = new LineCategory(); colorCat.FilterExpression = "[TAMSROADRSL] = '" + rsl.ToString() + "'"; LineSymbolizer colorSym = new LineSymbolizer(); colorSym.ScaleMode = ScaleMode.Geographic; colorSym.SetWidth(adjWidth); colorSym.SetOutline(Color.DarkGray, adjOutlineWidth); Color fillColor = Color.Gray; if (rsl == 20 || rsl == 19) { fillColor = Color.Blue; } if (rsl <= 18 && rsl >= 16) { fillColor = Color.DeepSkyBlue; } if (rsl <= 15 && rsl >= 13) { fillColor = Color.Green; } if (rsl <= 12 && rsl >= 10) { fillColor = Color.LimeGreen; } if (rsl <= 9 && rsl >= 7) { fillColor = Color.Yellow; } if (rsl <= 6 && rsl >= 4) { fillColor = Color.Orange; } if (rsl <= 3 && rsl >= 1) { fillColor = Color.Red; } if (rsl == 0) { fillColor = Color.DarkRed; } if (selectedColors[fillColor]) { colorSym.SetFillColor(fillColor); } else { continue; } colorCat.Symbolizer = colorSym; // assign (default) selection symbolizer colorCat.SelectionSymbolizer = catSelSym; // done rdScheme.AddCategory(colorCat); } } if (moduleRoads.roadColors == "Treatment") { DataTable nameToTreatment = Database.GetDataByQuery(Project.conn, "SELECT name, category FROM treatments;"); string[] treatments = new string[30]; int j = 0; foreach (DataRow row in nameToTreatment.Rows) { treatments[j] = row["name"].ToString(); if (row["category"].ToString() == "routine") { r[j] = 0; } g[j] = 0; b[j] = 255; if (row["category"].ToString() == "patch") { r[j] = 50; } g[j] = 205; b[j] = 50; if (row["category"].ToString() == "preventative") { r[j] = 255; } g[j] = 255; b[j] = 0; if (row["category"].ToString() == "rehabilitation") { r[j] = 255; } g[j] = 0; b[j] = 0; if (row["category"].ToString() == "reconstruction") { r[j] = 139; } g[j] = 0; b[j] = 0; j++; } treatments[24] = "Routine"; r[24] = 0; g[24] = 0; b[24] = 255; treatments[25] = "Patching"; r[25] = 50; g[25] = 205; b[25] = 50; treatments[26] = "Preventative"; r[26] = 255; g[26] = 255; b[26] = 0; treatments[27] = "Preventative with Patching"; r[27] = 255; g[27] = 165; b[27] = 0; treatments[28] = "Rehabilitation"; r[28] = 255; g[28] = 0; b[28] = 0; treatments[29] = "Reconstruction"; r[29] = 139; g[29] = 0; b[29] = 0; for (int i = 0; i < treatments.Length; i++) { // TODO: Get this to work Color fillColor = Color.Gray; if (r[i] == 0 && g[i] == 0 && b[i] == 255) { fillColor = Color.Blue; } if (r[i] == 50 && g[i] == 205 && b[i] == 50) { fillColor = Color.LimeGreen; } if (r[i] == 255 && g[i] == 255 && b[i] == 0) { fillColor = Color.Yellow; } if (r[i] == 255 && g[i] == 165 && b[i] == 0) { fillColor = Color.Orange; } if (r[i] == 255 && g[i] == 0 && b[i] == 0) { fillColor = Color.Red; } if (r[i] == 139 && g[i] == 0 && b[i] == 0) { fillColor = Color.DarkRed; } if (!selectedColors[fillColor]) { continue; } LineCategory colorCat = new LineCategory(); colorCat.FilterExpression = "[TAMSTREATMENT] = '" + treatments[i] + "'"; LineSymbolizer colorSym = new LineSymbolizer(); colorSym.ScaleMode = ScaleMode.Geographic; colorSym.SetWidth(adjWidth); colorSym.SetOutline(Color.DarkGray, adjOutlineWidth); colorSym.SetFillColor(Color.FromArgb(r[i], g[i], b[i])); colorCat.Symbolizer = colorSym; // assign (default) selection symbolizer colorCat.SelectionSymbolizer = catSelSym; // done rdScheme.AddCategory(colorCat); } } } ((MapLineLayer)moduleRoads.Layer).ShowLabels = false; FeatureLayer roadFeatures = moduleRoads.Layer as FeatureLayer; if (!string.IsNullOrEmpty(Project.settings.GetValue("road_labels"))) { string streetnames = "[" + Project.settings.GetValue(ModuleName + "_f_streetname") + "]"; roadFeatures.AddLabels(streetnames, new Font("Tahoma", (float)8.0), moduleRoads.labelColor); roadFeatures.ShowLabels = Project.settings.GetValue("road_labels").Contains("true"); } ((MapLineLayer)moduleRoads.Layer).Symbology = rdScheme; ((MapLineLayer)moduleRoads.Layer).ApplyScheme(rdScheme); }
private void DrawLineSymbolizer(LineSymbolizer sym, Graphics g, Rectangle rect) { if (sym != null) { g.FillRectangle(Brushes.White, rect); GraphicsPath gp = new GraphicsPath(); gp.AddLine(10, rect.Height / 2, rect.Width - 20, rect.Height / 2); foreach (IStroke stroke in sym.Strokes) { stroke.DrawPath(g, gp, 1); } gp.Dispose(); } }
private void button1_Click(object sender, EventArgs e) { if (comboBox1.Text == "") { MessageBox.Show("要素信息不能为空", "TIN提示信息", MessageBoxButtons.OKCancel); } if (comboBox5.Text == "") { MessageBox.Show("纬度选择", "TIN提示信息", MessageBoxButtons.OKCancel); } if (comboBox6.Text == "") { MessageBox.Show("经度选择", "TIN提示信息", MessageBoxButtons.OKCancel); } if (flag == false) { FeatureSet delaunayline = new FeatureSet(FeatureType.Line); MapLineLayer ml = (MapLineLayer)map.Layers.Add(delaunayline); LineSymbolizer symbol = new LineSymbolizer(Color.Black, 2); ml.Symbolizer = symbol; ml.LegendText = "delaunay"; List <Tin_Point> tin_Points = new List <Tin_Point>(); for (int i = 0; i < ifeatureset.Features.Count; i++) { //Console.WriteLine("x: " + ifeatureset.Features[i].BasicGeometry.Coordinates[0].X + ", y: " + ifeatureset.Features[i].BasicGeometry.Coordinates[0].Y); tin_Points.Add(new Tin_Point(ifeatureset.Features[i].BasicGeometry.Coordinates[0].X, ifeatureset.Features[i].BasicGeometry.Coordinates[0].Y)); } Delaunay delaunay = new Delaunay(); List <Triangle> triangles = new List <Triangle>(); triangles = delaunay.ConstructionDelaunay(tin_Points); foreach (var tri in triangles) { Coordinate a = new Coordinate(tri.p1.X, tri.p1.Y); Coordinate b = new Coordinate(tri.p2.X, tri.p2.Y); Coordinate c = new Coordinate(tri.p3.X, tri.p3.Y); List <Coordinate> lineArray = new List <Coordinate>(); ILineString lineGeometry = new LineString(lineArray); IFeature lineFeature = delaunayline.AddFeature(lineGeometry); lineArray.Add(a); lineArray.Add(b); lineArray.Add(c); DotSpatial.Topology.LineString ls = new LineString(lineArray); lineFeature.Coordinates.Add(a); lineFeature.Coordinates.Add(b); lineFeature.Coordinates.Add(c); delaunayline.InitializeVertices(); map.ResetBuffer(); } } if (FileName != "") { ifeatureset.SaveAs(FileName, true); if (checkBox1.CheckState == CheckState.Checked) { var shp = Shapefile.OpenFile(FileName); shp.Projection = ifeatureset.Projection; map.Layers.Add(shp); } } MessageBox.Show("TIN操作完成", "TIN提示信息", MessageBoxButtons.OK); this.Close(); }
public void ExerciseWmcFromCodeTest() { ViewContext context = new ViewContext(); // Context -> General context.General.Window.Width = 500; context.General.Window.Height = 300; context.General.BoundingBox.SRS = "EPSG:4326"; context.General.BoundingBox.MinX = -180; context.General.BoundingBox.MinY = -90; context.General.BoundingBox.MaxX = 180; context.General.BoundingBox.MaxY = 90; context.General.Title = "EOS Data Gateways"; context.General.KeywordList.Add("EOS"); context.General.KeywordList.Add("EOSDIS"); context.General.KeywordList.Add("NASA"); context.General.KeywordList.Add("CCRS"); context.General.KeywordList.Add("CEOS"); context.General.KeywordList.Add("OGC"); context.General.Abstract = "Map View of EOSDIS partners locations"; context.General.LogoURL.Width = 130; context.General.LogoURL.Height = 74; context.General.LogoURL.Format = "image/gif"; context.General.LogoURL.OnlineResource.Type = "simple"; context.General.LogoURL.OnlineResource.Href = "http://redhook.gsfc.nasa.gov/~imswww/pub/icons/logo.gif"; context.General.DescriptionURL.Format = "text/html"; context.General.DescriptionURL.OnlineResource.Type = "simple"; context.General.DescriptionURL.OnlineResource.Href = "http://eos.nasa.gov/imswelcome"; context.General.ContactInformation.ContactPersonPrimary.ContactPerson = "Tom Kralidis"; context.General.ContactInformation.ContactPersonPrimary.ContactOrganisation = "Canada Centre for Remote Sensing"; context.General.ContactInformation.ContactPosition = "Systems Scientist"; context.General.ContactInformation.ContactAddress.AddressType = "postal"; context.General.ContactInformation.ContactAddress.Address = "615 Booth Street, room 650"; context.General.ContactInformation.ContactAddress.City = "Ottawa"; context.General.ContactInformation.ContactAddress.StateOrProvince = "Ontario"; context.General.ContactInformation.ContactAddress.Country = "Canada"; context.General.ContactInformation.ContactVoiceTelephone = "+01 613 947 1828"; context.General.ContactInformation.ContactFacsimileTelephone = "+01 613 947 2410"; context.General.ContactInformation.ContactElectronicMailAddress = "*****@*****.**"; context.Version = "1.0"; context.Id = "TEST"; // Context -> Layer Layer layer = new Layer(); layer.Queryable = 1; layer.Hidden = 0; layer.Server.Service = GeospatialServices.Ogc.Common.ServiceNames.WMS; layer.Server.Version = "1.0.7"; layer.Title = "The GLOBE Program Visualization Server"; layer.Server.OnlineResource.Type = "simple"; layer.Server.OnlineResource.Href = "http://globe.digitalearth.gov/viz-bin/wmt.cgi"; layer.Name = "NATIONAL"; layer.Title = "National Boundaries"; layer.Abstract = "Context layer: National Boundaries"; layer.SRS = "EPSG:4326"; // Context -> Layer -> Format layer.FormatList.Add(new Format("GIF", 1)); // Context -> Layer -> Style Style style1 = new Style(); style1.Current = 1; style1.Name = "default"; style1.LegendURL.Width = 16; style1.LegendURL.Height = 16; style1.LegendURL.Format = "image/gif"; style1.LegendURL.OnlineResource.Type = "simple"; style1.LegendURL.OnlineResource.Href = "http://mapserv2.esrin.esa.it/cubestor/cubeserv.cgi?VERSION=1.1.0&REQUEST=GetLegendIcon&LAYER=WORLD_MODIS_1KM:MapAdmin&SPATIAL_TYPE=RASTER&STYLE=default&FORMAT=image//gif"; // Context -> Layer -> Style -> Named Layer NamedLayer namedLayer = new NamedLayer(); namedLayer.Name = "Roads"; // Context -> Layer -> Style -> Named Layer -> Named Styles namedLayer.NamedStyles.Add(new NamedStyle("Casing")); namedLayer.NamedStyles.Add(new NamedStyle("Centerline")); // Context -> Layer -> Style -> Named Layer -> User Style UserStyle userStyle1 = new UserStyle(); // Context -> Layer -> Style -> Named Layer -> User Style -> FeatureTypeStyle FeatureTypeStyle featureTypeStyle1 = new FeatureTypeStyle(); Rule rule1 = new Rule(); // Context -> Layer -> Style -> Named Layer -> User Style -> FeatureTypeStyle -> Rule -> Symbolizers BaseSymbolizer[] symbolizers = new BaseSymbolizer[6]; SymbolizerTypes[] symbolizerSelections = new SymbolizerTypes[6]; // Line Symbolizer LineSymbolizer lineSymbolizer = new LineSymbolizer(); lineSymbolizer.Geometry.PropertyName = "center-line"; lineSymbolizer.Stroke.SvgParameters.Add(new SvgParameter("stroke", "#0000ff")); lineSymbolizer.Stroke.SvgParameters.Add(new SvgParameter("stroke-width", "2")); symbolizers[0] = lineSymbolizer; symbolizerSelections[0] = SymbolizerTypes.LineSymbolizer; // Polygon Symbolizer PolygonSymbolizer polygonSymbolizer = new PolygonSymbolizer(); polygonSymbolizer.Geometry.PropertyName = "the_area"; polygonSymbolizer.Fill.SvgParameters.Add(new SvgParameter("fill", "#aaaaff")); polygonSymbolizer.Stroke.SvgParameters.Add(new SvgParameter("stroke", "#0000aa")); symbolizers[1] = polygonSymbolizer; symbolizerSelections[1] = SymbolizerTypes.PolygonSymbolizer; // Point Symbolizer PointSymbolizer pointSymbolizer = new PointSymbolizer(); // Point Symbolizer - > External Graphic 1 ExternalGraphic externalGraphic1 = new ExternalGraphic(); externalGraphic1.OnlineResource.Type = "simple"; externalGraphic1.OnlineResource.Href = "http://www.vendor.com/geosym/2267.svg"; externalGraphic1.Format = "image/svg+xml"; pointSymbolizer.Graphic.ExternalGraphics.Add(externalGraphic1); // Point Symbolizer - > External Graphic 2 ExternalGraphic externalGraphic2 = new ExternalGraphic(); externalGraphic2.OnlineResource.Type = "simple"; externalGraphic2.OnlineResource.Href = "http://www.vendor.com/geosym/2267.png"; externalGraphic2.Format = "image/png"; pointSymbolizer.Graphic.ExternalGraphics.Add(externalGraphic2); pointSymbolizer.Graphic.Size = 15.0; symbolizers[2] = pointSymbolizer; symbolizerSelections[2] = SymbolizerTypes.PointSymbolizer; // Text Symbolizer TextSymbolizer textSymbolizer = new TextSymbolizer(); textSymbolizer.Geometry.PropertyName = "locatedAt"; textSymbolizer.Label = @"ogc:PropertyName[hospitalName]"; textSymbolizer.Font.SvgParameters.Add(new SvgParameter("font-family", "Arial")); textSymbolizer.Font.SvgParameters.Add(new SvgParameter("font-family", "Sans-Serif")); textSymbolizer.Font.SvgParameters.Add(new SvgParameter("font-style", "italic")); textSymbolizer.Font.SvgParameters.Add(new SvgParameter("font-size", "10")); textSymbolizer.Fill.SvgParameters.Add(new SvgParameter("fill", "#000000")); textSymbolizer.LabelPlacement.PointPlacement = new PointPlacement(); textSymbolizer.LabelPlacement.PointPlacement.AnchorPoint.AnchorPointX = 456; textSymbolizer.LabelPlacement.PointPlacement.AnchorPoint.AnchorPointY = 123; textSymbolizer.LabelPlacement.PointPlacement.Rotation = 180; textSymbolizer.LabelPlacement.PointPlacement.Displacement.DisplacementX = 111; textSymbolizer.LabelPlacement.PointPlacement.Displacement.DisplacementY = 222; textSymbolizer.LabelPlacement.LinePlacement = new LinePlacement(); textSymbolizer.LabelPlacement.LinePlacement.Gap = 12; textSymbolizer.LabelPlacement.LinePlacement.GeneraliseLine = 3; textSymbolizer.LabelPlacement.LinePlacement.InitialGap = 3; textSymbolizer.LabelPlacement.LinePlacement.IsAligned = 0; textSymbolizer.LabelPlacement.LinePlacement.IsRepeated = 1; textSymbolizer.LabelPlacement.LinePlacement.PerpendicularOffset = 5; textSymbolizer.Halo.Fill = new Fill(); textSymbolizer.Halo.Fill.SvgParameters.Add(new SvgParameter("fill", "#000000")); textSymbolizer.Halo.Radius = 3; symbolizers[3] = textSymbolizer; symbolizerSelections[3] = SymbolizerTypes.TextSymbolizer; // Raster Symbolizer 1 RasterSymbolizer rasterSymbolizer1 = new RasterSymbolizer(); rasterSymbolizer1.Opacity = 1.0; rasterSymbolizer1.OverlapBehaviour = OverlapBehaviourTypes.Average; rasterSymbolizer1.ColourMap.Categorize.LookupValue = "Rasterdata"; rasterSymbolizer1.ColourMap.Categorize.Values.Add("#00ff00"); rasterSymbolizer1.ColourMap.Categorize.Thresholds.Add(-417); rasterSymbolizer1.ColourMap.Categorize.Values.Add("#00fa00"); rasterSymbolizer1.ColourMap.Categorize.Thresholds.Add(-333); symbolizers[4] = rasterSymbolizer1; symbolizerSelections[4] = SymbolizerTypes.RasterSymbolizer; // Raster Symbolizer 2 RasterSymbolizer rasterSymbolizer2 = new RasterSymbolizer(); rasterSymbolizer2.Opacity = 1.0; rasterSymbolizer2.OverlapBehaviour = OverlapBehaviourTypes.LatestOnTop; rasterSymbolizer2.ChannelSelection.RedChannel.SourceChannelName = "1"; rasterSymbolizer2.ChannelSelection.GreenChannel.SourceChannelName = "2"; rasterSymbolizer2.ChannelSelection.GreenChannel.ContrastEnhancement.GammaValue = 2.5; rasterSymbolizer2.ChannelSelection.BlueChannel.SourceChannelName = "3"; rasterSymbolizer2.ColourMap.Interpolate.FallBackValue = "#dddddd"; rasterSymbolizer2.ColourMap.Interpolate.LookupValue = "Rasterdata"; rasterSymbolizer2.ColourMap.Interpolate.InterpolationPoints.Add(new InterpolationPoint(0, "#000000")); rasterSymbolizer2.ColourMap.Interpolate.InterpolationPoints.Add(new InterpolationPoint(255, "#ffffff")); rasterSymbolizer2.ContrastEnhancement.GammaValue = 1; rasterSymbolizer2.Geometry.PropertyName = "Coastlines"; symbolizers[5] = rasterSymbolizer2; symbolizerSelections[5] = SymbolizerTypes.RasterSymbolizer; rule1.SymbolizerSelections = symbolizerSelections; rule1.Symbolizers = symbolizers; featureTypeStyle1.Rules.Add(rule1); Rule rule2 = new Rule(); rule2.ElseFilter = new ElseFilter(); featureTypeStyle1.Rules.Add(rule2); Rule rule3 = new Rule(); GeospatialServices.Ogc.Wmc.PropertyIsEqualTo propEqualTo = new PropertyIsEqualTo(); propEqualTo.Literal.Value = "NEW YORK"; propEqualTo.PropertyName = "SALES_AREA"; //BaseComparisonOps ComparisonOps[] = new BaseComparisonOps[2]; rule3.Filter.FilterExpression = propEqualTo; featureTypeStyle1.Rules.Add(rule3); userStyle1.FeatureTypeStyles.Add(featureTypeStyle1); namedLayer.UserStyles.Add(userStyle1); // Context - > Layer -> Style -> User Layer UserLayer userLayer = new UserLayer(); userLayer.Name = "Lakes and Rivers"; UserStyle userStyle = new UserStyle("Default"); userStyle.FeatureTypeStyles.Add(featureTypeStyle1); userLayer.UserStyles = new List <UserStyle>(); userLayer.UserStyles.Add(userStyle); style1.SLD.StyledLayerDescriptor.NamedLayers.Add(namedLayer); style1.SLD.StyledLayerDescriptor.UserLayers.Add(userLayer); layer.StyleList.Add(style1); context.Layers.Add(layer); }
private void lbxItems_DrawItem(object sender, DrawItemEventArgs e) { if (e.Index == -1) { return; } //prepare to draw the rectangle for symbol display and selection Rectangle outer = new Rectangle(e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height); if ((e.State & DrawItemState.Selected) == DrawItemState.Selected) { e.Graphics.FillRectangle(SystemBrushes.Highlight, outer); } else { Brush b = new SolidBrush(BackColor); e.Graphics.FillRectangle(b, outer); b.Dispose(); } Rectangle inner = new Rectangle(e.Bounds.X + 5, e.Bounds.Y + 1, e.Bounds.Width - 10, e.Bounds.Height - 3); e.Graphics.FillRectangle(Brushes.White, inner); e.Graphics.DrawRectangle(Pens.Black, inner); //draw the symbolizer itself PointSymbolizer pointSym = lbxItems.Items[e.Index] as PointSymbolizer; if (pointSym != null) { DrawPointSymbolizer(pointSym, e.Graphics, inner); return; } LineSymbolizer lineSym = lbxItems.Items[e.Index] as LineSymbolizer; if (lineSym != null) { DrawLineSymbolizer(lineSym, e.Graphics, inner); return; } PolygonSymbolizer polySym = lbxItems.Items[e.Index] as PolygonSymbolizer; if (polySym != null) { DrawPolygonSymbolizer(polySym, e.Graphics, inner); return; } //IFeatureSymbolizer sym = lbxItems.Items[e.Index] as IFeatureSymbolizer; //if (sym == null) return; //Matrix old = e.Graphics.Transform; //Matrix shift = e.Graphics.Transform; //Size2D size = _symbolizers.GetBoundingSize(); //double scaleSize = 1; //if (_scaleMode == ScaleModes.Geographic || size.Height > 14) //{ // scaleSize = (ItemHeight - 6) / size.Height; //} //shift.Translate(e.Bounds.Left + e.Bounds.Width / 2, e.Bounds.Top + e.Bounds.Height / 2); ////shift.Translate(-(float)(size.Width * scaleSize / 2), -(float)(size.Height * scaleSize / 2)); //e.Graphics.Transform = shift; //sym.Draw(e.Graphics, scaleSize); //e.Graphics.Transform = old; }
private void drawToolStripMenuItem_Click(object sender, EventArgs e) //绘制曲流颈和曲流轴 { //DataColumn column = new DataColumn("LineID"); //if (!lineF_.DataTable.Columns.Contains("LineID")) //{ // lineF_.DataTable.Columns.Add(column); //} foreach (List <DotSpatial.Topology.Coordinate> FeaturePoint in FeaturePoints) { //Create a new List called lineArray. //This list will store the Coordinates //We are going to store the mouse click coordinates into this array. List <DotSpatial.Topology.Coordinate> lineArray = new List <DotSpatial.Topology.Coordinate>(); //Create an instance for LineString class. //We need to pass collection of list coordinates LineString lineGeometry = new LineString(lineArray); //Add the linegeometry to line feature //add 曲流颈 coordinate to the line feature IFeature lineFeature1 = lineF_.AddFeature(lineGeometry); //添加线要素 lineFeature1.Coordinates.Add(FeaturePoint[0]); lineFeature1.Coordinates.Add(FeaturePoint[1]); //DataRowBuilder dataRowBuilder1 = new DataRowBuilder(); //lineFeature1.DataRow = new DataRow(); //Add the linegeometry to line feature //add 曲流轴 coordinate to the line feature IFeature lineFeature2 = lineF_.AddFeature(lineGeometry); //添加线要素 lineFeature2.Coordinates.Add(FeaturePoint[2]); lineFeature2.Coordinates.Add(FeaturePoint[3]); //refresh the map if line has 2 or more points if (lineFeature1.Coordinates.Count >= 2 && lineFeature2.Coordinates.Count >= 2) { lineF_.InitializeVertices(); map1.ResetBuffer(); } } //set projection lineF_.Projection = map1.Projection; //initialize the featureSet attribute table DataColumn column = new DataColumn("LineID"); if (!lineF_.DataTable.Columns.Contains("LineID")) { lineF_.DataTable.Columns.Add(column); } //add the featureSet as map layer lineLayer = (MapLineLayer)map1.Layers.Add(lineF_); //Set the symbolizer to the line feature. LineSymbolizer symbol = new LineSymbolizer(Color.Red, Color.Red, 2, DashStyle.Dot, LineCap.Square); lineLayer.Symbolizer = symbol; lineLayer.LegendText = "line"; MessageBox.Show("Draw Over!!!"); }
private void SymbolizerLines(IMapFeatureLayer aLayer) { //Method 1. simple symbolizer aLayer.Symbolizer = new LineSymbolizer(Color.Brown, 1); //Method 2. Combined symbolizer LineSymbolizer road = new LineSymbolizer(Color.Yellow, 5); road.SetOutline(Color.Black, 1); aLayer.Symbolizer = road; /* Method 3. Symbology by unique values: * HueSatLight = true, then the ramp is created by adjusting the * hue, saturation and lightness between the start and end colors. * HueSatLight = false, then the red, blue and green values are ramped instead. * * In both cases, alpha (transparency) is ramped the same way. */ LineScheme lScheme = new LineScheme(); lScheme.EditorSettings.ClassificationType = ClassificationType.UniqueValues; lScheme.EditorSettings.FieldName = "CARTO"; lScheme.CreateCategories(aLayer.DataSet.DataTable); aLayer.Symbology = lScheme; //Method 4. Collapsible field name in legend via 'AppearsInLegend' LineScheme lScheme1 = new LineScheme(); lScheme1.Categories.Clear(); //redundant??? LineCategory lowCat = new LineCategory(Color.Blue, 2); lowCat.FilterExpression = "[CARTO] = 3"; lowCat.LegendText = "Low"; LineCategory highCat = new LineCategory( Color.Red, Color.Black, 6, DashStyle.Solid, LineCap.Triangle);; highCat.FilterExpression = "[CARTO] = 2"; highCat.LegendText = "High"; lScheme1.AppearsInLegend = true; lScheme1.LegendText = "CARTO"; lScheme1.Categories.Add(lowCat); aLayer.Symbology = lScheme1; lScheme1.Categories.Add(highCat); /*Method 5. Lines with multiple strokes * Each individual LineSymbolizer is made up of at least one, * but potentially several strokes overlapping each other */ LineSymbolizer multiStrokeSym = new LineSymbolizer(); multiStrokeSym.Strokes.Clear(); //redundant??? CartographicStroke ties = new CartographicStroke(Color.Brown); ties.DashPattern = new float[] { 1 / 6f, 2 / 6f }; ties.Width = 6; ties.EndCap = LineCap.Flat; ties.StartCap = LineCap.Flat; CartographicStroke rails = new CartographicStroke(Color.DarkGray); rails.CompoundArray = new float[] { .15f, .3f, .6f, .75f }; rails.Width = 6; rails.EndCap = LineCap.Flat; rails.StartCap = LineCap.Flat; multiStrokeSym.Strokes.Add(ties); multiStrokeSym.Strokes.Add(rails); aLayer.Symbolizer = multiStrokeSym; }