Skip to content

Commit dc0f195

Browse files
add plot middle cross layers fixed #52
1 parent b9f1e8a commit dc0f195

File tree

1 file changed

+71
-1
lines changed

1 file changed

+71
-1
lines changed

BExIS.Pmm.Model/Plotchart.cs

Lines changed: 71 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using BExIS.Pmm.Entities;
33
using BExIS.Pmm.Services;
44
using GeoAPI.Geometries;
5+
using NetTopologySuite.IO;
56
using System;
67
using System.Collections.Generic;
78
using System.Drawing;
@@ -499,6 +500,75 @@ private SharpMap.Map InitializeMap(Size outputsize, Plot plot, int zoom = 1, boo
499500

500501
plot.Geometries = plot.Geometries.OrderByDescending(p => p.Geometry.Length).ToList();
501502

503+
#region add plot middle cross layers
504+
505+
string text1 = calCoordd("linestring", "(-1,1),(0,0)", bb, "xy", "");
506+
string text2 = calCoordd("linestring", "(0,0),(-1,1)", bb, "xy", "");
507+
WKTReader reader = new WKTReader();
508+
IGeometry crossLine1 = reader.Read(text1);
509+
IGeometry crossLine2 = reader.Read(text2);
510+
List<IGeometry> geometriesCross = new List<IGeometry>();
511+
geometriesCross.Add(crossLine1);
512+
geometriesCross.Add(crossLine2);
513+
514+
foreach (var geo in geometriesCross)
515+
{
516+
var dd = new SharpMap.Data.FeatureDataTable();
517+
dd.Columns.Add("Label");
518+
SharpMap.Data.FeatureDataRow newRow = dd.NewRow();
519+
newRow.Geometry = geo;
520+
521+
SharpMap.Layers.VectorLayer plotLayer1 = new SharpMap.Layers.VectorLayer("");
522+
plotLayer1.DataSource = new SharpMap.Data.Providers.GeometryProvider(geo);
523+
plotLayer1.CoordinateTransformation = ctFact.CreateFromCoordinateSystems(ProjNet.CoordinateSystems.GeographicCoordinateSystem.WGS84, webmercator);
524+
plotLayer1.ReverseCoordinateTransformation = ctFact.CreateFromCoordinateSystems(webmercator, ProjNet.CoordinateSystems.GeographicCoordinateSystem.WGS84);
525+
String borderColor = "#000000";
526+
527+
Pen pen = new Pen(ColorTranslator.FromHtml(RGBAToArgb(borderColor)), 6);
528+
pen.Width = 10;
529+
530+
int argb = Int32.Parse(RGBAToArgb(borderColor).Replace("#", ""), NumberStyles.HexNumber);
531+
Color clr = Color.FromArgb(argb);
532+
plotLayer1.Style.Fill = new SolidBrush(clr);
533+
plotLayer1.Style.Outline = pen;
534+
plotLayer1.Style.EnableOutline = true;
535+
536+
dd.Rows.Clear();
537+
dd.Rows.Add(newRow);
538+
plotLayer1.DataSource = new SharpMap.Data.Providers.GeometryFeatureProvider(dd);
539+
540+
SharpMap.Layers.LabelLayer layLabel1 = new SharpMap.Layers.LabelLayer("Country labels")
541+
{
542+
DataSource = plotLayer1.DataSource,
543+
Enabled = true,
544+
LabelColumn = "Label",
545+
MultipartGeometryBehaviour = SharpMap.Layers.LabelLayer.MultipartGeometryBehaviourEnum.Largest,
546+
LabelFilter = SharpMap.Rendering.LabelCollisionDetection.ThoroughCollisionDetection,
547+
CoordinateTransformation = plotLayer1.CoordinateTransformation,
548+
PriorityColumn = "Label",
549+
550+
Style = new SharpMap.Styles.LabelStyle()
551+
{
552+
Font = new Font(FontFamily.GenericSerif, 40),
553+
HorizontalAlignment = SharpMap.Styles.LabelStyle.HorizontalAlignmentEnum.Right,
554+
VerticalAlignment = SharpMap.Styles.LabelStyle.VerticalAlignmentEnum.Top,
555+
CollisionDetection = true,
556+
Enabled = true,
557+
}
558+
};
559+
560+
layLabel1.Style.VerticalAlignment = SharpMap.Styles.LabelStyle.VerticalAlignmentEnum.Top;
561+
layLabel1.Style.HorizontalAlignment = SharpMap.Styles.LabelStyle.HorizontalAlignmentEnum.Left;
562+
layLabel1.MultipartGeometryBehaviour = SharpMap.Layers.LabelLayer.MultipartGeometryBehaviourEnum.Largest;
563+
564+
layLabel1.Style.Offset = (new PointF((float)plotLayer1.Envelope.MaxX, (float)plotLayer1.Envelope.MaxY));
565+
566+
map.Layers.Add(plotLayer1);
567+
map.Layers.Add(layLabel1);
568+
}
569+
570+
#endregion
571+
502572
foreach (var geometry in plot.Geometries)
503573
{
504574
//check to ignore deactive geometries
@@ -508,8 +578,8 @@ private SharpMap.Map InitializeMap(Size outputsize, Plot plot, int zoom = 1, boo
508578
SharpMap.Layers.VectorLayer plotLayer = new SharpMap.Layers.VectorLayer(geometry.Id.ToString());
509579

510580
double disss = geometry.Geometry.Envelope.Distance(plot.Geometry.Envelope);
511-
512581
List<IGeometry> geometries = new List<IGeometry>();
582+
513583
geometries.Add(geometry.Geometry);
514584
var dd = new SharpMap.Data.FeatureDataTable();
515585
dd.Columns.Add("Label");

0 commit comments

Comments
 (0)