diff --git a/Examples/DemoWinForm/ConvertProjectionAndCoordinatesForm.cs b/Examples/DemoWinForm/ConvertProjectionAndCoordinatesForm.cs index eff34d2e..ab60a6e4 100644 --- a/Examples/DemoWinForm/ConvertProjectionAndCoordinatesForm.cs +++ b/Examples/DemoWinForm/ConvertProjectionAndCoordinatesForm.cs @@ -1,25 +1,20 @@ using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Text; using System.Windows.Forms; namespace DemoWinForm { - public partial class ConvertProjectionAndCoordinatesForm : Form - { - public ConvertProjectionAndCoordinatesForm() - { - InitializeComponent(); - } + public partial class ConvertProjectionAndCoordinatesForm : Form + { + public ConvertProjectionAndCoordinatesForm() + { + InitializeComponent(); + } - protected override void OnResize(EventArgs e) - { - base.OnResize(e); + protected override void OnResize(EventArgs e) + { + base.OnResize(e); - MainSplitContainer.SplitterDistance = (Width - MainSplitContainer.SplitterWidth) / 2; - } - } + MainSplitContainer.SplitterDistance = (Width - MainSplitContainer.SplitterWidth) / 2; + } + } } \ No newline at end of file diff --git a/Examples/DemoWinForm/DemoWinForm.csproj b/Examples/DemoWinForm/DemoWinForm.csproj index 01500ab5..60310ecc 100644 --- a/Examples/DemoWinForm/DemoWinForm.csproj +++ b/Examples/DemoWinForm/DemoWinForm.csproj @@ -22,10 +22,6 @@ - - - - @@ -37,4 +33,8 @@ + + + + diff --git a/Examples/DemoWinForm/MainForm.cs b/Examples/DemoWinForm/MainForm.cs index cc058361..39a4cc91 100644 --- a/Examples/DemoWinForm/MainForm.cs +++ b/Examples/DemoWinForm/MainForm.cs @@ -15,20 +15,19 @@ // along with SharpMap; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Drawing; -using System.IO; -using System.Windows.Forms; using DemoWinForm.Properties; using NetTopologySuite.Geometries; using SharpMap.Data; using SharpMap.Data.Providers; using SharpMap.Forms; -using GeoAPI.Geometries; using SharpMap.Layers; -using GeoPoint = GeoAPI.Geometries.Coordinate; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Drawing; +using System.IO; +using System.Windows.Forms; +using GeoPoint = NetTopologySuite.Geometries.Coordinate; namespace DemoWinForm { @@ -67,16 +66,16 @@ private void registerSymbols() private static void registerKnownColors(Dictionary colorTable) { - foreach (string colorName in Enum.GetNames(typeof (KnownColor))) + foreach (string colorName in Enum.GetNames(typeof(KnownColor))) { - KnownColor color = (KnownColor) Enum.Parse(typeof (KnownColor), colorName); + KnownColor color = (KnownColor)Enum.Parse(typeof(KnownColor), colorName); colorTable[colorName] = Color.FromKnownColor(color); } } private void registerLayerFactories() { -// ConfigurationManager.GetSection("LayerFactories"); + // ConfigurationManager.GetSection("LayerFactories"); _layerFactoryCatalog[".shp"] = new ShapeFileLayerFactory(); } @@ -90,7 +89,7 @@ private void addLayer(ILayer layer) private void addNewRandomGeometryLayer() { Random rndGen = new Random(); - Collection geometry = new Collection(); + Collection geometry = new Collection(); VectorLayer layer = new VectorLayer(String.Empty); var gf = new GeometryFactory(); @@ -157,14 +156,14 @@ private Color GetRandomColor(Random rndGen) return Color.FromArgb(rndGen.Next(255), rndGen.Next(255), rndGen.Next(255)); } - private static void GeneratePolygons(IGeometryFactory factory, ICollection geometry, Random rndGen) + private static void GeneratePolygons(GeometryFactory factory, ICollection geometry, Random rndGen) { int numPolygons = rndGen.Next(10, 100); for (var polyIndex = 0; polyIndex < numPolygons; polyIndex++) { var vertices = new GeoPoint[5]; - var upperLeft = new GeoPoint(rndGen.NextDouble()*1000, rndGen.NextDouble()*1000); - var sideLength = rndGen.NextDouble()*50; + var upperLeft = new GeoPoint(rndGen.NextDouble() * 1000, rndGen.NextDouble() * 1000); + var sideLength = rndGen.NextDouble() * 50; // Make a square vertices[0] = new GeoPoint(upperLeft.X, upperLeft.Y); @@ -172,12 +171,12 @@ private static void GeneratePolygons(IGeometryFactory factory, ICollection geometry, Random rndGen) + private static void GenerateLines(GeometryFactory factory, ICollection geometry, Random rndGen) { var numLines = rndGen.Next(10, 100); for (var lineIndex = 0; lineIndex < numLines; lineIndex++) @@ -185,7 +184,7 @@ private static void GenerateLines(IGeometryFactory factory, ICollection geometry, Random rndGen) + private static void GeneratePoints(GeometryFactory factory, ICollection geometry, Random rndGen) { var numPoints = rndGen.Next(10, 100); for (var pointIndex = 0; pointIndex < numPoints; pointIndex++) { - var point = new GeoPoint(rndGen.NextDouble()*1000, rndGen.NextDouble()*1000); + var point = new GeoPoint(rndGen.NextDouble() * 1000, rndGen.NextDouble() * 1000); geometry.Add(factory.CreatePoint(point)); } } @@ -273,7 +272,7 @@ private void changeMode(MapBox.Tools tool) private object getLayerTypeIcon(Type type) { - if (type == typeof (VectorLayer)) + if (type == typeof(VectorLayer)) { return Resources.polygon; } @@ -335,32 +334,32 @@ private void MainMapImage_MapQueried(FeatureDataTable data) private void AddLayerToolStripButton_Click(object sender, EventArgs e) { - BeginInvoke((MethodInvoker) delegate { LoadLayer(); }); + BeginInvoke((MethodInvoker)delegate { LoadLayer(); }); } private void RemoveLayerToolStripButton_Click(object sender, EventArgs e) { - BeginInvoke((MethodInvoker) delegate { RemoveLayer(); }); + BeginInvoke((MethodInvoker)delegate { RemoveLayer(); }); } private void AddLayerToolStripMenuItem_Click(object sender, EventArgs e) { - BeginInvoke((MethodInvoker) delegate { LoadLayer(); }); + BeginInvoke((MethodInvoker)delegate { LoadLayer(); }); } private void RemoveLayerToolStripMenuItem_Click(object sender, EventArgs e) { - BeginInvoke((MethodInvoker) delegate { RemoveLayer(); }); + BeginInvoke((MethodInvoker)delegate { RemoveLayer(); }); } private void ZoomToExtentsToolStripButton_Click(object sender, EventArgs e) { - BeginInvoke((MethodInvoker) delegate { zoomToExtents(); }); + BeginInvoke((MethodInvoker)delegate { zoomToExtents(); }); } private void PanToolStripButton_Click(object sender, EventArgs e) { - BeginInvoke((MethodInvoker) delegate { changeMode(MapBox.Tools.Pan); }); + BeginInvoke((MethodInvoker)delegate { changeMode(MapBox.Tools.Pan); }); } private void QueryModeToolStripButton_Click(object sender, EventArgs e) @@ -418,7 +417,7 @@ private void MoveDownToolStripMenuItem_Click(object sender, EventArgs e) private void LayersDataGridView_SelectionChanged(object sender, EventArgs e) { - BeginInvoke((MethodInvoker) delegate + BeginInvoke((MethodInvoker)delegate { changeUIOnLayerSelectionChange(); @@ -437,7 +436,7 @@ private void MainMapImage_MouseMove(GeoPoint WorldPos, MouseEventArgs ImagePos) private void AddNewRandomGeometryLayer_Click(object sender, EventArgs e) { - BeginInvoke((MethodInvoker) delegate { addNewRandomGeometryLayer(); }); + BeginInvoke((MethodInvoker)delegate { addNewRandomGeometryLayer(); }); } } } \ No newline at end of file diff --git a/Examples/DemoWinForm/Program.cs b/Examples/DemoWinForm/Program.cs index a6c2a4bc..74fbee82 100644 --- a/Examples/DemoWinForm/Program.cs +++ b/Examples/DemoWinForm/Program.cs @@ -15,12 +15,12 @@ // along with SharpMap; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -using System; -using System.Text; -using System.Windows.Forms; using NetTopologySuite; using ProjNet.CoordinateSystems; using ProjNet.CoordinateSystems.Transformations; +using SharpMap.CoordinateSystems; +using System; +using System.Windows.Forms; namespace DemoWinForm { @@ -32,13 +32,11 @@ internal static class Program [STAThread] private static void Main() { - var gss = new NtsGeometryServices(); - var css = new SharpMap.CoordinateSystems.CoordinateSystemServices( + var gss = NtsGeometryServices.Instance; + var css = new CoordinateSystemServices( new CoordinateSystemFactory(), new CoordinateTransformationFactory(), SharpMap.Converters.WellKnownText.SpatialReference.GetAllReferenceSystems()); - - GeoAPI.GeometryServiceProvider.Instance = gss; SharpMap.Session.Instance .SetGeometryServices(gss) .SetCoordinateSystemServices(css) @@ -49,4 +47,4 @@ private static void Main() Application.Run(new MainForm()); } } -} \ No newline at end of file +} diff --git a/Examples/ExampleCodeSnippets/ClipLabelPosition.cs b/Examples/ExampleCodeSnippets/ClipLabelPosition.cs index d7b00d46..ff910180 100644 --- a/Examples/ExampleCodeSnippets/ClipLabelPosition.cs +++ b/Examples/ExampleCodeSnippets/ClipLabelPosition.cs @@ -5,8 +5,8 @@ /// public class ClipLabelPosition { - private GeoAPI.Geometries.IGeometry _clip; - private GeoAPI.Geometries.Prepared.IPreparedGeometry _prepClip; + private NetTopologySuite.Geometries.Geometry _clip; + private NetTopologySuite.Geometries.Prepared.IPreparedGeometry _prepClip; /// /// Creates an instance of this class @@ -27,7 +27,7 @@ public ClipLabelPosition(SharpMap.Map map) /// /// A feature /// A label position - public GeoAPI.Geometries.Coordinate GetClippedPosition(SharpMap.Data.FeatureDataRow row) + public NetTopologySuite.Geometries.Coordinate GetClippedPosition(SharpMap.Data.FeatureDataRow row) { var g = _prepClip.Contains(row.Geometry) ? row.Geometry diff --git a/Examples/ExampleCodeSnippets/CreatingData.cs b/Examples/ExampleCodeSnippets/CreatingData.cs index 8c4e250f..8fba29b5 100644 --- a/Examples/ExampleCodeSnippets/CreatingData.cs +++ b/Examples/ExampleCodeSnippets/CreatingData.cs @@ -32,7 +32,7 @@ public static System.Double[] GetRandomOrdinates(System.Int32 size, System.Doubl return arr; } - + /// /// Creates a FeatureDataTable from arrays of x, y and z components /// @@ -40,7 +40,7 @@ public static System.Double[] GetRandomOrdinates(System.Int32 size, System.Doubl /// an array of doubles representing the y ordinate values /// an array of doubles representing the z ordinate values /// - public static SharpMap.Data.FeatureDataTable CreatePointFeatureDataTableFromArrays(double[] xcomponents, + public static SharpMap.Data.FeatureDataTable CreatePointFeatureDataTableFromArrays(double[] xcomponents, double[] ycomponents, double[] zcomponents, double[] data = null) { @@ -60,18 +60,18 @@ public static SharpMap.Data.FeatureDataTable CreatePointFeatureDataTableFromArra } var fdt = new SharpMap.Data.FeatureDataTable(); - fdt.Columns.Add("TimeStamp", typeof (System.DateTime)); // add example timestamp attribute + fdt.Columns.Add("TimeStamp", typeof(System.DateTime)); // add example timestamp attribute if (data != null) fdt.Columns.Add("Data", typeof(System.Double)); // add example timestamp attribute - + for (var i = 0; i < xcomponents.Length; i++) { SharpMap.Data.FeatureDataRow fdr = fdt.NewRow(); fdr.Geometry = factory.CreatePoint(threedee - ? new GeoAPI.Geometries.Coordinate(xcomponents[i], ycomponents[i], zcomponents[i]) - : new GeoAPI.Geometries.Coordinate(xcomponents[i], ycomponents[i])); + ? new NetTopologySuite.Geometries.CoordinateZ(xcomponents[i], ycomponents[i], zcomponents[i]) + : new NetTopologySuite.Geometries.Coordinate(xcomponents[i], ycomponents[i])); fdr["TimeStamp"] = System.DateTime.Now; //set the timestamp property if (data != null) @@ -86,48 +86,48 @@ public static SharpMap.Data.FeatureDataTable CreatePointFeatureDataTableFromArra public static class ShapeFactory { - public static GeoAPI.Geometries.ILinearRing CreateRectangle(GeoAPI.Geometries.IGeometryFactory factory, - GeoAPI.Geometries.Coordinate leftTop, GeoAPI.Geometries.Coordinate rightBottom) + public static NetTopologySuite.Geometries.LinearRing CreateRectangle(NetTopologySuite.Geometries.GeometryFactory factory, + NetTopologySuite.Geometries.Coordinate leftTop, NetTopologySuite.Geometries.Coordinate rightBottom) { var pts = new[] { - leftTop, - new GeoAPI.Geometries.Coordinate(rightBottom.X, leftTop.Y), + leftTop, + new NetTopologySuite.Geometries.Coordinate(rightBottom.X, leftTop.Y), rightBottom, - new GeoAPI.Geometries.Coordinate(leftTop.X, rightBottom.Y), + new NetTopologySuite.Geometries.Coordinate(leftTop.X, rightBottom.Y), leftTop }; return factory.CreateLinearRing(pts); } - public static GeoAPI.Geometries.ILinearRing CreateRectangle(GeoAPI.Geometries.IGeometryFactory factory, - GeoAPI.Geometries.Coordinate center, System.Drawing.SizeF size) + public static NetTopologySuite.Geometries.LinearRing CreateRectangle(NetTopologySuite.Geometries.GeometryFactory factory, + NetTopologySuite.Geometries.Coordinate center, System.Drawing.SizeF size) { var wh = new System.Drawing.SizeF(size.Width * 0.5f, size.Height * 0.5f); - var lt = new GeoAPI.Geometries.Coordinate(center.X - wh.Width, center.Y + wh.Height); - var rb = new GeoAPI.Geometries.Coordinate(center.X + wh.Width, center.Y - wh.Height); + var lt = new NetTopologySuite.Geometries.Coordinate(center.X - wh.Width, center.Y + wh.Height); + var rb = new NetTopologySuite.Geometries.Coordinate(center.X + wh.Width, center.Y - wh.Height); return CreateRectangle(factory, lt, rb); } - public static GeoAPI.Geometries.ILinearRing CreateEllipse(GeoAPI.Geometries.IGeometryFactory factory, - GeoAPI.Geometries.Coordinate center, System.Drawing.SizeF size) + public static NetTopologySuite.Geometries.LinearRing CreateEllipse(NetTopologySuite.Geometries.GeometryFactory factory, + NetTopologySuite.Geometries.Coordinate center, System.Drawing.SizeF size) { return CreateEllipse(factory, center, size, 12); } - public static GeoAPI.Geometries.ILinearRing CreateEllipse(GeoAPI.Geometries.IGeometryFactory factory, - GeoAPI.Geometries.Coordinate center, System.Drawing.SizeF size, int segmentsPerQuadrant) + public static NetTopologySuite.Geometries.LinearRing CreateEllipse(NetTopologySuite.Geometries.GeometryFactory factory, + NetTopologySuite.Geometries.Coordinate center, System.Drawing.SizeF size, int segmentsPerQuadrant) { const double piHalf = System.Math.PI * 0.5d; var step = piHalf / segmentsPerQuadrant; - var pts = new GeoAPI.Geometries.Coordinate[4 * segmentsPerQuadrant + 1]; + var pts = new NetTopologySuite.Geometries.Coordinate[4 * segmentsPerQuadrant + 1]; var angle = 0d; for (var i = 0; i < 4 * segmentsPerQuadrant; i++) { - pts[i] = new GeoAPI.Geometries.Coordinate(center.X + System.Math.Cos(angle) * size.Width, + pts[i] = new NetTopologySuite.Geometries.Coordinate(center.X + System.Math.Cos(angle) * size.Width, center.Y + System.Math.Sin(angle) * size.Height); angle += step; } @@ -138,17 +138,17 @@ public static GeoAPI.Geometries.ILinearRing CreateEllipse(GeoAPI.Geometries.IGeo public class TestShapeFactory { - public static readonly GeoAPI.Geometries.IGeometryFactory Factory = + public static readonly NetTopologySuite.Geometries.GeometryFactory Factory = new NetTopologySuite.Geometries.GeometryFactory(new NetTopologySuite.Geometries.PrecisionModel(1000)); - + [NUnit.Framework.Test] public void TestRectangle() { - var rect = ShapeFactory.CreateRectangle(Factory, new GeoAPI.Geometries.Coordinate(1, 2), new GeoAPI.Geometries.Coordinate(2, 1)); + var rect = ShapeFactory.CreateRectangle(Factory, new NetTopologySuite.Geometries.Coordinate(1, 2), new NetTopologySuite.Geometries.Coordinate(2, 1)); NUnit.Framework.Assert.AreEqual(rect.StartPoint, rect.EndPoint); NUnit.Framework.Assert.AreEqual(4, rect.Length); - var rect2 = ShapeFactory.CreateRectangle(Factory, new GeoAPI.Geometries.Coordinate(1.5, 1.5), new System.Drawing.SizeF(1f, 1f)); + var rect2 = ShapeFactory.CreateRectangle(Factory, new NetTopologySuite.Geometries.Coordinate(1.5, 1.5), new System.Drawing.SizeF(1f, 1f)); NUnit.Framework.Assert.AreEqual(rect, rect2); NUnit.Framework.Assert.AreEqual("LINEARRING (1 2, 2 2, 2 1, 1 1, 1 2)", rect.ToString()); @@ -157,13 +157,13 @@ public void TestRectangle() [NUnit.Framework.Test] public void TestEllipse() { - var ell = ShapeFactory.CreateEllipse(Factory, new GeoAPI.Geometries.Coordinate(1, 1), new System.Drawing.SizeF(1, 1), 1); + var ell = ShapeFactory.CreateEllipse(Factory, new NetTopologySuite.Geometries.Coordinate(1, 1), new System.Drawing.SizeF(1, 1), 1); NUnit.Framework.Assert.AreEqual(ell.StartPoint, ell.EndPoint); NUnit.Framework.Assert.LessOrEqual(System.Math.Abs(4 * System.Math.Sqrt(2) - ell.Length), 0.00001d); NUnit.Framework.Assert.AreEqual("LINEARRING (2 1, 1 2, 0 1, 1 0, 2 1)", ell.ToString()); - var ell2 = ShapeFactory.CreateEllipse(Factory, new GeoAPI.Geometries.Coordinate(1, 1), new System.Drawing.SizeF(1, 1)); + var ell2 = ShapeFactory.CreateEllipse(Factory, new NetTopologySuite.Geometries.Coordinate(1, 1), new System.Drawing.SizeF(1, 1)); System.Console.WriteLine(ell2.ToString()); } @@ -175,17 +175,17 @@ public void TestLayer() new[] { Factory.CreatePolygon( - ShapeFactory.CreateEllipse(Factory, new GeoAPI.Geometries.Coordinate(0, 0), + ShapeFactory.CreateEllipse(Factory, new NetTopologySuite.Geometries.Coordinate(0, 0), new System.Drawing.SizeF(40, 30)), new[] { - ShapeFactory.CreateEllipse(Factory, new GeoAPI.Geometries.Coordinate(90, 55), + ShapeFactory.CreateEllipse(Factory, new NetTopologySuite.Geometries.Coordinate(90, 55), new System.Drawing.SizeF(40, 30)), - ShapeFactory.CreateEllipse(Factory, new GeoAPI.Geometries.Coordinate(77, 24), + ShapeFactory.CreateEllipse(Factory, new NetTopologySuite.Geometries.Coordinate(77, 24), new System.Drawing.SizeF(40, 30)), - ShapeFactory.CreateEllipse(Factory, new GeoAPI.Geometries.Coordinate(-80, 41), + ShapeFactory.CreateEllipse(Factory, new NetTopologySuite.Geometries.Coordinate(-80, 41), new System.Drawing.SizeF(40, 30)), - ShapeFactory.CreateEllipse(Factory, new GeoAPI.Geometries.Coordinate(-45, -36), + ShapeFactory.CreateEllipse(Factory, new NetTopologySuite.Geometries.Coordinate(-45, -36), new System.Drawing.SizeF(40, 30)), }) }); @@ -196,4 +196,4 @@ public void TestLayer() mapimage.Save("ellipse.png", System.Drawing.Imaging.ImageFormat.Png); } } -} \ No newline at end of file +} diff --git a/Examples/ExampleCodeSnippets/EnsureVisibleSample.cs b/Examples/ExampleCodeSnippets/EnsureVisibleSample.cs index 0c71c0cd..9f6a4af9 100644 --- a/Examples/ExampleCodeSnippets/EnsureVisibleSample.cs +++ b/Examples/ExampleCodeSnippets/EnsureVisibleSample.cs @@ -1,69 +1,89 @@ +using NetTopologySuite; +using NetTopologySuite.Geometries; +using NUnit.Framework; +using ProjNet.CoordinateSystems; +using ProjNet.CoordinateSystems.Transformations; +using SharpMap; +using SharpMap.CoordinateSystems; using System; using System.Drawing; -using GeoAPI.Geometries; -using NUnit.Framework; +using System.IO; namespace ExampleCodeSnippets { using cd = CreatingData; - [NUnit.Framework.TestFixture] + [NUnit.Framework.TestFixture] public class EnsureVisibleSample { -public static void EnsureVisible(SharpMap.Map map, GeoAPI.Geometries.Coordinate pt) -{ - const double ensureVisibleRatio = 0.1d; - - //Get current map envelope - var bb = map.Envelope; - System.Console.WriteLine(string.Format("Map envelope: {0}", bb)); - - //Set valid envelope - var evbb = bb.Grow(- ensureVisibleRatio * bb.Width, -ensureVisibleRatio * bb.Height ); - System.Console.WriteLine(string.Format("Valid envelope: {0}", evbb)); - - //Test if Point is in valid envelope - if (evbb.Contains(pt)) return; - - //It is not - System.Console.WriteLine(string.Format("Valid envelope does not contain {0}", pt)); - - //LineString from Map.Center -> to Point - var ls = map.Factory.CreateLineString(new[] {evbb.Centre, pt}); - System.Console.WriteLine(string.Format("LineString Map.Center -> Point: {0}", ls)); - - //Setup Linestring from BoundingBox - var evbbpts = new [] {evbb.TopLeft(), evbb.TopRight(), evbb.BottomRight(), evbb.BottomLeft(), evbb.TopLeft() }; - var evbblinearring = map.Factory.CreateLineString(evbbpts); - System.Console.WriteLine(string.Format("Linestring of valid envelope: {0}", evbblinearring)); - - //// convert geometries to NTS - //var ntsevbb = (NetTopologySuite.Geometries.LineString) - // SharpMap.Converters.NTS.GeometryConverter.ToNTSGeometry(evbblinearring, gf); - //var ntsls = (NetTopologySuite.Geometries.LineString) - // SharpMap.Converters.NTS.GeometryConverter.ToNTSGeometry(ls, gf); - - // Get intersection point - var intGeo = evbblinearring.Intersection(ls); - var intPt = (NetTopologySuite.Geometries.Point)intGeo; - System.Console.WriteLine(string.Format("Intersection point is: {0}", intPt)); - - //Compute offset - var dx = pt.X - intPt.X; - var dy = pt.Y - intPt.Y; - System.Console.WriteLine(string.Format("Map.Center needs to be shifted by: [{0}, {1}]", dx, dy)); - - //Set new center Center - map.Center = new GeoAPI.Geometries.Coordinate(map.Center.X + dx, map.Center.Y + dy); + [OneTimeSetUp] + public void OneTimeSetUp() + { + var gss = NtsGeometryServices.Instance; + var css = new CoordinateSystemServices( + new CoordinateSystemFactory(), + new CoordinateTransformationFactory(), + SharpMap.Converters.WellKnownText.SpatialReference.GetAllReferenceSystems()); + Session.Instance + .SetGeometryServices(gss) + .SetCoordinateSystemServices(css) + .SetCoordinateSystemRepository(css); + } -} + public static void EnsureVisible(SharpMap.Map map, NetTopologySuite.Geometries.Coordinate pt) + { + const double ensureVisibleRatio = 0.1d; + + //Get current map envelope + var bb = map.Envelope; + System.Console.WriteLine(string.Format("Map envelope: {0}", bb)); + + //Set valid envelope + var evbb = bb.Grow(-ensureVisibleRatio * bb.Width, -ensureVisibleRatio * bb.Height); + System.Console.WriteLine(string.Format("Valid envelope: {0}", evbb)); + + //Test if Point is in valid envelope + if (evbb.Contains(pt)) return; + + //It is not + System.Console.WriteLine(string.Format("Valid envelope does not contain {0}", pt)); + + //LineString from Map.Center -> to Point + var ls = map.Factory.CreateLineString(new[] { evbb.Centre, pt }); + System.Console.WriteLine(string.Format("LineString Map.Center -> Point: {0}", ls)); + + //Setup Linestring from BoundingBox + var evbbpts = new[] { evbb.TopLeft(), evbb.TopRight(), evbb.BottomRight(), evbb.BottomLeft(), evbb.TopLeft() }; + var evbblinearring = map.Factory.CreateLineString(evbbpts); + System.Console.WriteLine(string.Format("Linestring of valid envelope: {0}", evbblinearring)); + + //// convert geometries to NTS + //var ntsevbb = (NetTopologySuite.Geometries.LineString) + // SharpMap.Converters.NTS.GeometryConverter.ToNTSGeometry(evbblinearring, gf); + //var ntsls = (NetTopologySuite.Geometries.LineString) + // SharpMap.Converters.NTS.GeometryConverter.ToNTSGeometry(ls, gf); + + // Get intersection point + var intGeo = evbblinearring.Intersection(ls); + var intPt = (NetTopologySuite.Geometries.Point)intGeo; + System.Console.WriteLine(string.Format("Intersection point is: {0}", intPt)); + + //Compute offset + var dx = pt.X - intPt.X; + var dy = pt.Y - intPt.Y; + System.Console.WriteLine(string.Format("Map.Center needs to be shifted by: [{0}, {1}]", dx, dy)); + + //Set new center Center + map.Center = new NetTopologySuite.Geometries.Coordinate(map.Center.X + dx, map.Center.Y + dy); + + } [NUnit.Framework.Test] public void TestEnsureVisible() { //Create a map - SharpMap.Map map = new SharpMap.Map(new System.Drawing.Size(720,360)); - + SharpMap.Map map = new SharpMap.Map(new System.Drawing.Size(720, 360)); + //Create some random sample data SharpMap.Data.FeatureDataTable fdt = cd.CreatePointFeatureDataTableFromArrays(cd.GetRandomOrdinates(80, -180, 180), @@ -71,10 +91,14 @@ public void TestEnsureVisible() //Create layer and datasource SharpMap.Layers.VectorLayer vl = new SharpMap.Layers.VectorLayer("Points", new SharpMap.Data.Providers.GeometryFeatureProvider(fdt)); - + //Create default style SharpMap.Styles.VectorStyle defaultStyle = new SharpMap.Styles.VectorStyle(); - defaultStyle.Symbol = new System.Drawing.Bitmap(@"..\..\..\DemoWinForm\Resources\flag.png"); + var stylePath = Path.GetFullPath( + Path.Combine( + Path.GetDirectoryName(GetType().Assembly.Location), + "..\\..\\..\\..\\DemoWinForm\\Resources\\flag.png")); + defaultStyle.Symbol = new System.Drawing.Bitmap(stylePath); defaultStyle.SymbolScale = 0.5f; //Create theming class and apply to layer @@ -85,16 +109,16 @@ public void TestEnsureVisible() map.Layers.Add(vl); map.ZoomToExtents(); map.Zoom = 60; //2*30 - map.Center = new GeoAPI.Geometries.Coordinate(0,0); + map.Center = new NetTopologySuite.Geometries.Coordinate(0, 0); System.Console.WriteLine(map.Center); - EnsureVisible(map, new GeoAPI.Geometries.Coordinate(-30, 0)); + EnsureVisible(map, new NetTopologySuite.Geometries.Coordinate(-30, 0)); System.Console.WriteLine(map.Center); System.Console.WriteLine(); - EnsureVisible(map, new GeoAPI.Geometries.Coordinate(15, 20)); + EnsureVisible(map, new NetTopologySuite.Geometries.Coordinate(15, 20)); System.Console.WriteLine(map.Center); System.Console.WriteLine(); - EnsureVisible(map, new GeoAPI.Geometries.Coordinate(15, -20)); + EnsureVisible(map, new NetTopologySuite.Geometries.Coordinate(15, -20)); System.Console.WriteLine(map.Center); } diff --git a/Examples/ExampleCodeSnippets/ExampleCodeSession.cs b/Examples/ExampleCodeSnippets/ExampleCodeSession.cs index a83045d6..713d1188 100644 --- a/Examples/ExampleCodeSnippets/ExampleCodeSession.cs +++ b/Examples/ExampleCodeSnippets/ExampleCodeSession.cs @@ -1,22 +1,21 @@ -namespace ExampleCodeSnippets +using SharpMap.CoordinateSystems; + +namespace ExampleCodeSnippets { - [NUnit.Framework.SetUpFixture] public class ExampleCodeSession { - [NUnit.Framework.SetUp] + [NUnit.Framework.OneTimeSetUp] public void SetUp() { - var gss = new NetTopologySuite.NtsGeometryServices(); - var css = new SharpMap.CoordinateSystems.CoordinateSystemServices( + var gss = NetTopologySuite.NtsGeometryServices.Instance; + var css = new CoordinateSystemServices( new ProjNet.CoordinateSystems.CoordinateSystemFactory(), new ProjNet.CoordinateSystems.Transformations.CoordinateTransformationFactory(), SharpMap.Converters.WellKnownText.SpatialReference.GetAllReferenceSystems()); - - GeoAPI.GeometryServiceProvider.Instance = gss; SharpMap.Session.Instance .SetGeometryServices(gss) .SetCoordinateSystemServices(css) .SetCoordinateSystemRepository(css); } } -} \ No newline at end of file +} diff --git a/Examples/ExampleCodeSnippets/ExampleCodeSnippets.csproj b/Examples/ExampleCodeSnippets/ExampleCodeSnippets.csproj index b8005dc1..5e4ddf9f 100644 --- a/Examples/ExampleCodeSnippets/ExampleCodeSnippets.csproj +++ b/Examples/ExampleCodeSnippets/ExampleCodeSnippets.csproj @@ -16,10 +16,8 @@ - - - - + + @@ -29,4 +27,8 @@ + + + + diff --git a/Examples/ExampleCodeSnippets/GeoJsonExample.cs b/Examples/ExampleCodeSnippets/GeoJsonExample.cs index 9bb156b8..fa4ab2ae 100644 --- a/Examples/ExampleCodeSnippets/GeoJsonExample.cs +++ b/Examples/ExampleCodeSnippets/GeoJsonExample.cs @@ -30,7 +30,7 @@ public void TestGeoJson(System.Collections.Generic.IEnumerable jsons) { var gjr = new NetTopologySuite.IO.GeoJsonReader(); - var geom = jsons.Select(json => gjr.Read(json)).ToList(); + var geom = jsons.Select(json => gjr.Read(json)).ToList(); var fp = new SharpMap.Data.Providers.GeometryFeatureProvider(geom); var l = new SharpMap.Layers.VectorLayer("geojson", fp); diff --git a/Examples/ExampleCodeSnippets/HeatLayerExample.cs b/Examples/ExampleCodeSnippets/HeatLayerExample.cs index 8096e30b..da0845da 100644 --- a/Examples/ExampleCodeSnippets/HeatLayerExample.cs +++ b/Examples/ExampleCodeSnippets/HeatLayerExample.cs @@ -1,22 +1,18 @@ -using System.Collections.Generic; -using System.Data; -using System.Drawing; -using System.Drawing.Imaging; -using GeoAPI.Geometries; +using NetTopologySuite; +using NetTopologySuite.Geometries; using NUnit.Framework; -using NetTopologySuite; using SharpMap.Data; using SharpMap.Layers; +using System.Collections.Generic; +using System.Data; +using System.Drawing; +using System.Drawing.Imaging; namespace ExampleCodeSnippets { [TestFixture] public class HeatLayerExample { - static HeatLayerExample () - { - GeoAPI.GeometryServiceProvider.Instance = new NtsGeometryServices(); - } [Test] public void HeatLayerTest() { @@ -82,8 +78,8 @@ public void TestRealData() private static FeatureDataTable GetRealFeatureDataTable() { var res = new FeatureDataTable(); - res.Columns.Add("Oid", typeof (uint)); - res.Columns.Add("Data", typeof (int)); + res.Columns.Add("Oid", typeof(uint)); + res.Columns.Add("Data", typeof(int)); return res; } @@ -91,12 +87,12 @@ private static FeatureDataTable GetRealFeatureDataTable() private static void FillRealDataTable(FeatureDataTable table) { table.BeginLoadData(); - var factory = GeoAPI.GeometryServiceProvider.Instance.CreateGeometryFactory(4326); + var factory = NtsGeometryServices.Instance.CreateGeometryFactory(4326); uint id = 0; foreach (var datas in PointData()) { - var row = (FeatureDataRow) table.LoadDataRow(new object[] {id++, datas[0]}, LoadOption.OverwriteChanges); + var row = (FeatureDataRow)table.LoadDataRow(new object[] { id++, datas[0] }, LoadOption.OverwriteChanges); row.Geometry = factory.CreatePoint(new Coordinate(datas[2], datas[1])); } table.EndLoadData(); diff --git a/Examples/ExampleCodeSnippets/LengthIndexedLineSample.cs b/Examples/ExampleCodeSnippets/LengthIndexedLineSample.cs index 79fff1d5..b98589c8 100644 --- a/Examples/ExampleCodeSnippets/LengthIndexedLineSample.cs +++ b/Examples/ExampleCodeSnippets/LengthIndexedLineSample.cs @@ -5,41 +5,41 @@ namespace ExampleCodeSnippets [NUnit.Framework.TestFixture] public class LengthIndexedLineSample { -public GeoAPI.Geometries.IMultiLineString SplitLineString( - GeoAPI.Geometries.ILineString lineString, - System.Double length) -{ - if (lineString == null || lineString.IsEmpty) - throw new System.ArgumentException("Linestring is null or Empty", "lineString"); + public NetTopologySuite.Geometries.MultiLineString SplitLineString( + NetTopologySuite.Geometries.LineString lineString, + System.Double length) + { + if (lineString == null || lineString.IsEmpty) + throw new System.ArgumentException("Linestring is null or Empty", "lineString"); - //var gf = new NetTopologySuite.Geometries.GeometryFactory(); - //var ntsLine = (NetTopologySuite.Geometries.LineString) - // SharpMap.Converters.NTS.GeometryConverter.ToNTSGeometry(lineString, gf); + //var gf = new NetTopologySuite.Geometries.GeometryFactory(); + //var ntsLine = (NetTopologySuite.Geometries.LineString) + // SharpMap.Converters.NTS.GeometryConverter.ToNTSGeometry(lineString, gf); - var ret = new System.Collections.Generic.List(); - var lil = new NetTopologySuite.LinearReferencing.LengthIndexedLine(lineString); + var ret = new System.Collections.Generic.List(); + var lil = new NetTopologySuite.LinearReferencing.LengthIndexedLine(lineString); - double currentLength = 0d; - while (currentLength < lineString.Length) - { - var tmpLine = (GeoAPI.Geometries.ILineString) - lil.ExtractLine(currentLength, currentLength + length); - ret.Add(tmpLine); - currentLength += length; - } - return lineString.Factory.CreateMultiLineString(ret.ToArray()); -} + double currentLength = 0d; + while (currentLength < lineString.Length) + { + var tmpLine = (NetTopologySuite.Geometries.LineString) + lil.ExtractLine(currentLength, currentLength + length); + ret.Add(tmpLine); + currentLength += length; + } + return lineString.Factory.CreateMultiLineString(ret.ToArray()); + } [NUnit.Framework.Test] public void TestLengthIndexedLine() { var gf = new NetTopologySuite.Geometries.GeometryFactory(); var l = gf.CreateLineString( - new [] - { new GeoAPI.Geometries.Coordinate(0, 0), - new GeoAPI.Geometries.Coordinate(300, 100),}); + new[] + { new NetTopologySuite.Geometries.Coordinate(0, 0), + new NetTopologySuite.Geometries.Coordinate(300, 100),}); System.Console.WriteLine(SplitLineString(l, 20d)); } } -} \ No newline at end of file +} diff --git a/Examples/ExampleCodeSnippets/LineSymbolizerTest.cs b/Examples/ExampleCodeSnippets/LineSymbolizerTest.cs index df68789d..c7fe3ad9 100644 --- a/Examples/ExampleCodeSnippets/LineSymbolizerTest.cs +++ b/Examples/ExampleCodeSnippets/LineSymbolizerTest.cs @@ -1,134 +1,129 @@ namespace ExampleCodeSnippets { -/// -/// A (simple) street direction symbolizer -/// -public class StreetDirectionSymbolizer : SharpMap.Rendering.Symbolizer.BaseSymbolizer, - SharpMap.Rendering.Symbolizer.ILineSymbolizer -{ /// - /// Creates an instance of this class + /// A (simple) street direction symbolizer /// - public StreetDirectionSymbolizer() + public class StreetDirectionSymbolizer : SharpMap.Rendering.Symbolizer.BaseSymbolizer, + SharpMap.Rendering.Symbolizer.ILineSymbolizer { - RepeatInterval = 500; - ArrowLength = 100; - ArrowPen = new System.Drawing.Pen(System.Drawing.Color.Black, 2) + /// + /// Creates an instance of this class + /// + public StreetDirectionSymbolizer() { - EndCap = System.Drawing.Drawing2D.LineCap.ArrowAnchor - }; - } - - /// - /// Method to place the street direction symbols - /// - /// - /// - /// - private void OnRenderInternal(SharpMap.MapViewport map, GeoAPI.Geometries.ILineString lineString, - System.Drawing.Graphics graphics) - { + RepeatInterval = 500; + ArrowLength = 100; + ArrowPen = new System.Drawing.Pen(System.Drawing.Color.Black, 2) + { + EndCap = System.Drawing.Drawing2D.LineCap.ArrowAnchor + }; + } - var length = lineString.Length; - var lil = new NetTopologySuite.LinearReferencing.LengthIndexedLine(lineString); - if (length < RepeatInterval + ArrowLength) + /// + /// Method to place the street direction symbols + /// + /// + /// + /// + private void OnRenderInternal(SharpMap.MapViewport map, NetTopologySuite.Geometries.LineString lineString, + System.Drawing.Graphics graphics) { - var start = System.Math.Max(0, (length - ArrowLength)/2); - var end = System.Math.Min(length, (length + ArrowLength)/2); - var arrow = (GeoAPI.Geometries.ILineString) lil.ExtractLine(start, end); - RenderArrow(map, graphics, arrow); + var length = lineString.Length; + var lil = new NetTopologySuite.LinearReferencing.LengthIndexedLine(lineString); + if (length < RepeatInterval + ArrowLength) + { + var start = System.Math.Max(0, (length - ArrowLength) / 2); + var end = System.Math.Min(length, (length + ArrowLength) / 2); + var arrow = (NetTopologySuite.Geometries.LineString)lil.ExtractLine(start, end); - return; - } + RenderArrow(map, graphics, arrow); - var numArrows = (int) ((lineString.Length - ArrowLength)/RepeatInterval); - var offset = (lineString.Length - numArrows*RepeatInterval - ArrowLength)*0.5; + return; + } - while (offset + ArrowLength < lineString.Length) - { - var arrow = (GeoAPI.Geometries.ILineString) lil.ExtractLine(offset, offset + ArrowLength); - RenderArrow(map, graphics, arrow); - offset += RepeatInterval; - } + var numArrows = (int)((lineString.Length - ArrowLength) / RepeatInterval); + var offset = (lineString.Length - numArrows * RepeatInterval - ArrowLength) * 0.5; - } + while (offset + ArrowLength < lineString.Length) + { + var arrow = (NetTopologySuite.Geometries.LineString)lil.ExtractLine(offset, offset + ArrowLength); + RenderArrow(map, graphics, arrow); + offset += RepeatInterval; + } - /// - /// Method to render the arrow - /// - /// The map - /// The graphics object - /// The arrow - private void RenderArrow(SharpMap.MapViewport map, System.Drawing.Graphics graphics, GeoAPI.Geometries.ILineString arrow) - { - var pts = new System.Drawing.PointF[arrow.Coordinates.Length]; - for (var i = 0; i < pts.Length; i++) - pts[i] = map.WorldToImage(arrow.GetCoordinateN(i)); - graphics.DrawLines(ArrowPen, pts); - } + } - /// - /// Gets or sets a value indicating at which distances a street direction marker should be drawn. - /// - public double RepeatInterval { get; set; } + /// + /// Method to render the arrow + /// + /// The map + /// The graphics object + /// The arrow + private void RenderArrow(SharpMap.MapViewport map, System.Drawing.Graphics graphics, NetTopologySuite.Geometries.LineString arrow) + { + var pts = new System.Drawing.PointF[arrow.Coordinates.Length]; + for (var i = 0; i < pts.Length; i++) + pts[i] = map.WorldToImage(arrow.GetCoordinateN(i)); + graphics.DrawLines(ArrowPen, pts); + } - /// - /// Gets or sets a value indicating the length of the street direction arrow. - /// - public double ArrowLength { get; set; } + /// + /// Gets or sets a value indicating at which distances a street direction marker should be drawn. + /// + public double RepeatInterval { get; set; } - /// - /// Gets or sets a value indicating the pen to use when drawing the marker - /// - public System.Drawing.Pen ArrowPen { get; set; } + /// + /// Gets or sets a value indicating the length of the street direction arrow. + /// + public double ArrowLength { get; set; } - public override void Begin(System.Drawing.Graphics g, SharpMap.MapViewport map, int aproximateNumberOfGeometries) - { - base.Begin(g, map, aproximateNumberOfGeometries); + /// + /// Gets or sets a value indicating the pen to use when drawing the marker + /// + public System.Drawing.Pen ArrowPen { get; set; } - //Adjust Arrow cap - var size = (float) (ArrowLength/5/map.PixelWidth); - ArrowPen.CustomEndCap = new System.Drawing.Drawing2D.AdjustableArrowCap(size, size); - } + public override void Begin(System.Drawing.Graphics g, SharpMap.MapViewport map, int aproximateNumberOfGeometries) + { + base.Begin(g, map, aproximateNumberOfGeometries); - public void Render(SharpMap.MapViewport map, GeoAPI.Geometries.ILineal geometry, System.Drawing.Graphics graphics) - { - if (geometry is GeoAPI.Geometries.IMultiLineString) + //Adjust Arrow cap + var size = (float)(ArrowLength / 5 / map.PixelWidth); + ArrowPen.CustomEndCap = new System.Drawing.Drawing2D.AdjustableArrowCap(size, size); + } + + public void Render(SharpMap.MapViewport map, NetTopologySuite.Geometries.ILineal geometry, System.Drawing.Graphics graphics) { - var mls = (GeoAPI.Geometries.IMultiLineString) geometry; - for (var i = 0; i < mls.Count; i++) + if (geometry is NetTopologySuite.Geometries.MultiLineString) { - OnRenderInternal(map, (GeoAPI.Geometries.ILineString) mls.GetGeometryN(i), graphics); + var mls = (NetTopologySuite.Geometries.MultiLineString)geometry; + for (var i = 0; i < mls.Count; i++) + { + OnRenderInternal(map, (NetTopologySuite.Geometries.LineString)mls.GetGeometryN(i), graphics); + } + return; } - return; + OnRenderInternal(map, (NetTopologySuite.Geometries.LineString)geometry, graphics); } - OnRenderInternal(map, (GeoAPI.Geometries.ILineString) geometry, graphics); - } - protected override void ReleaseManagedResources() - { - base.ReleaseManagedResources(); - ArrowPen.Dispose(); - } + protected override void ReleaseManagedResources() + { + base.ReleaseManagedResources(); + ArrowPen.Dispose(); + } - public override object Clone() - { - var res = (StreetDirectionSymbolizer) MemberwiseClone(); - res.ArrowPen = new System.Drawing.Pen(((System.Drawing.SolidBrush) ArrowPen.Brush).Color, ArrowPen.Width); - return res; + public override object Clone() + { + var res = (StreetDirectionSymbolizer)MemberwiseClone(); + res.ArrowPen = new System.Drawing.Pen(((System.Drawing.SolidBrush)ArrowPen.Brush).Color, ArrowPen.Width); + return res; + } } -} public class LineSymbolizerTest { - [NUnit.Framework.OneTimeSetUp] - public void OneTimeSetUp() - { - GeoAPI.GeometryServiceProvider.Instance = NetTopologySuite.NtsGeometryServices.Instance; - } - [NUnit.Framework.Test] + [NUnit.Framework.Test] public void TestBasicLineSymbolizer() { if (!System.IO.File.Exists("d:\\daten\\GeoFabrik\\roads.shp")) @@ -139,7 +134,7 @@ public void TestBasicLineSymbolizer() //l.Style.Outline = new System.Drawing.Pen(System.Drawing.Color.Firebrick, 5); l.Style.Line = new System.Drawing.Pen(System.Drawing.Color.Gold, 1); l.Style.EnableOutline = false; - var m = new SharpMap.Map(new System.Drawing.Size(1440,1080)) {BackColor = System.Drawing.Color.Cornsilk}; + var m = new SharpMap.Map(new System.Drawing.Size(1440, 1080)) { BackColor = System.Drawing.Color.Cornsilk }; m.Layers.Add(l); m.ZoomToExtents(); @@ -184,7 +179,8 @@ public void TestStreetDirectionSymbolizer() l.Style.EnableOutline = true; var sd = new SharpMap.Layers.Symbolizer.LinealVectorLayer("streetd", p, new StreetDirectionSymbolizer() { - ArrowLength = 100, RepeatInterval = 500 + ArrowLength = 100, + RepeatInterval = 500 }); var m = new SharpMap.Map(new System.Drawing.Size(1440, 1080)) { BackColor = System.Drawing.Color.Cornsilk }; m.Layers.Add(l); @@ -210,23 +206,24 @@ 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)}); + { Line = new System.Drawing.Pen(System.Drawing.Color.Gold, 2) }); var wls = new SharpMap.Rendering.Symbolizer.WarpedLineSymbolizeHander - { - Pattern = + { + Pattern = SharpMap.Rendering.Symbolizer.WarpedLineSymbolizer. GetGreaterSeries(3, 3), - Line = new System.Drawing.Pen(System.Drawing.Color.Firebrick, 1) - , Interval = 20 - }; + 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}; + var m = new SharpMap.Map(new System.Drawing.Size(720, 540)) { BackColor = System.Drawing.Color.Cornsilk }; m.Layers.Add(l); m.ZoomToExtents(); @@ -240,14 +237,15 @@ public void TestWarpedLineSymbolizer() bmp.Save("AurichRoads1.bmp"); cls.LineSymbolizeHandlers[1] = new SharpMap.Rendering.Symbolizer.WarpedLineSymbolizeHander - { - Pattern = + { + 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 - }; + 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(); @@ -304,12 +302,12 @@ public void TestWarpedLineSymbolizer() //cls.LineSymbolizeHandlers[0] = cls.LineSymbolizeHandlers[1]; cls.LineSymbolizeHandlers[1] = new SharpMap.Rendering.Symbolizer.WarpedLineSymbolizeHander - { - Pattern = + { + 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) - }; + 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(); @@ -373,7 +371,7 @@ public SharpMap.Styles.IStyle GetStyle(SharpMap.Data.FeatureDataRow attribute) Line = new System.Drawing.Pen(System.Drawing.Color.Firebrick, 1) , Interval = 20 - + }; cls.LineSymbolizeHandlers.Add(wls); cls.ImmediateMode = true; @@ -392,18 +390,18 @@ public void TestTransformation() var m = new SharpMap.Map(new System.Drawing.Size(640, 320)); var l = new SharpMap.Layers.Symbolizer.PuntalVectorLayer("l", - new SharpMap.Data.Providers.GeometryProvider(m.Factory.CreatePoint(new GeoAPI.Geometries.Coordinate(0, 51.478885))), + new SharpMap.Data.Providers.GeometryProvider(m.Factory.CreatePoint(new NetTopologySuite.Geometries.Coordinate(0, 51.478885))), SharpMap.Rendering.Symbolizer.PathPointSymbolizer.CreateCircle(System.Drawing.Pens.Aquamarine, System.Drawing.Brushes.BurlyWood, 24)); var ctFact = new ProjNet.CoordinateSystems.Transformations.CoordinateTransformationFactory(); l.CoordinateTransformation = ctFact.CreateFromCoordinateSystems(ProjNet.CoordinateSystems.GeographicCoordinateSystem.WGS84, ProjNet.CoordinateSystems.ProjectedCoordinateSystem.WebMercator); l.ReverseCoordinateTransformation = ctFact.CreateFromCoordinateSystems(ProjNet.CoordinateSystems.ProjectedCoordinateSystem.WebMercator, ProjNet.CoordinateSystems.GeographicCoordinateSystem.WGS84); - m.Layers.Add(new SharpMap.Layers.TileLayer(BruTile.Predefined.KnownTileSources.Create(),"b")); + m.Layers.Add(new SharpMap.Layers.TileLayer(BruTile.Predefined.KnownTileSources.Create(), "b")); m.Layers.Add(l); - var e = new GeoAPI.Geometries.Envelope(-0.02, 0.02, 51.478885 - 0.01, 51.478885 + 0.01); - e = GeoAPI.CoordinateSystems.Transformations.GeometryTransform.TransformBox(e, + var e = new NetTopologySuite.Geometries.Envelope(-0.02, 0.02, 51.478885 - 0.01, 51.478885 + 0.01); + e = NetTopologySuite.CoordinateSystems.Transformations.GeometryTransform.TransformBox(e, l.CoordinateTransformation.MathTransform); m.ZoomToBox(e); m.GetMap().Save("Greenwich.png", System.Drawing.Imaging.ImageFormat.Png); diff --git a/Examples/ExampleCodeSnippets/NtsTests.cs b/Examples/ExampleCodeSnippets/NtsTests.cs index 1d0521fc..ac8bd382 100644 --- a/Examples/ExampleCodeSnippets/NtsTests.cs +++ b/Examples/ExampleCodeSnippets/NtsTests.cs @@ -1,18 +1,11 @@ -using System.Data.OleDb; -using SharpMap.Data.Providers; +using SharpMap.Data.Providers; +using System.Data.OleDb; namespace ExampleCodeSnippets { [NUnit.Framework.TestFixture] public class NtsTests { - [NUnit.Framework.OneTimeSetUp] - public void OneTimeSetUp() - { - GeoAPI.GeometryServiceProvider.Instance = - NetTopologySuite.NtsGeometryServices.Instance; - } - [NUnit.Framework.Test] public void TestDiscussionNtsAndBaffeled() { @@ -22,15 +15,15 @@ public void TestDiscussionNtsAndBaffeled() 429023.1119599645 360406.75878171506, 429004.52340613387 360451.71714446822, 429004.52340613387 360451.71714446822, 428999.76819468878 360451.93329044303))"); - var points = new System.Collections.Generic.List(new [] + var points = new System.Collections.Generic.List(new[] { - reader.Factory.CreatePoint(new GeoAPI.Geometries.Coordinate(429012.5, 360443.18)), - reader.Factory.CreatePoint(new GeoAPI.Geometries.Coordinate(429001.59, 360446.98)), - reader.Factory.CreatePoint(new GeoAPI.Geometries.Coordinate(429003.31, 360425.45)), - reader.Factory.CreatePoint(new GeoAPI.Geometries.Coordinate(429016.9, 360413.04)) + reader.Factory.CreatePoint(new NetTopologySuite.Geometries.Coordinate(429012.5, 360443.18)), + reader.Factory.CreatePoint(new NetTopologySuite.Geometries.Coordinate(429001.59, 360446.98)), + reader.Factory.CreatePoint(new NetTopologySuite.Geometries.Coordinate(429003.31, 360425.45)), + reader.Factory.CreatePoint(new NetTopologySuite.Geometries.Coordinate(429016.9, 360413.04)) }); - var inside = new System.Collections.Generic.List(new[] {false, true, true, true}); + var inside = new System.Collections.Generic.List(new[] { false, true, true, true }); for (var i = 0; i < points.Count; i++) { @@ -55,7 +48,7 @@ public void TestDiscussionNtsAndBaffeledOleDb() var table = WriteCsv(); - var p = new DbPoint(OleDbFactory.Instance, + var p = new DbPoint(OleDbFactory.Instance, "Provider=" + Properties.Settings.Default.OleDbProvider + ";Data Source=\"" + System.IO.Path.GetTempPath() + "\";" + "Extended Properties=\"text;HDR=Yes;FMT=Delimited\"", table, "ID", "X", "Y"); @@ -83,7 +76,7 @@ public void TestDiscussionNtsAndBaffeledOleDb() var ext = p.GetExtents(); var oids = p.GetObjectIDsInView(ext); NUnit.Framework.Assert.AreEqual(4, oids.Count); - + System.IO.File.Delete(System.IO.Path.Combine(System.IO.Path.GetTempPath(), table)); } @@ -103,10 +96,10 @@ private static string WriteCsv() using (var sr = new System.IO.StreamWriter(System.IO.File.OpenWrite(filename))) { sr.WriteLine("ID;Name;X;Y"); - sr.WriteLine("1;One;{0};{1}", 429012.5,360443.18); - sr.WriteLine("2;Two;{0};{1}",429001.59,360446.98); - sr.WriteLine("3;Three;{0};{1}",429003.31,360425.45); - sr.WriteLine("4;Four;{0};{1}",429016.9,360413.04); + sr.WriteLine("1;One;{0};{1}", 429012.5, 360443.18); + sr.WriteLine("2;Two;{0};{1}", 429001.59, 360446.98); + sr.WriteLine("3;Three;{0};{1}", 429003.31, 360425.45); + sr.WriteLine("4;Four;{0};{1}", 429016.9, 360413.04); } return System.IO.Path.GetFileName(filename); diff --git a/Examples/ExampleCodeSnippets/PointSymbolizerTest.cs b/Examples/ExampleCodeSnippets/PointSymbolizerTest.cs index 9a6d5eef..05035306 100644 --- a/Examples/ExampleCodeSnippets/PointSymbolizerTest.cs +++ b/Examples/ExampleCodeSnippets/PointSymbolizerTest.cs @@ -1,3 +1,5 @@ +using System.IO; + namespace ExampleCodeSnippets { /// @@ -12,16 +14,16 @@ public void TestCharacterPointSymbolizer() CreatingData.GetRandomOrdinates(50, -180, 180), CreatingData.GetRandomOrdinates(50, -90, 90), null); var geometryFeatureProvider = new SharpMap.Data.Providers.GeometryFeatureProvider(fdt); var layer = new SharpMap.Layers.VectorLayer("randompoints", geometryFeatureProvider); - var cps = new SharpMap.Rendering.Symbolizer.CharacterPointSymbolizer - { - Halo = 1, - HaloBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Wheat), - //Font = new System.Drawing.Font("Arial", 12), - CharacterIndex = 0xcc, - }; + var cps = new SharpMap.Rendering.Symbolizer.CharacterPointSymbolizer + { + Halo = 1, + HaloBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Wheat), + //Font = new System.Drawing.Font("Arial", 12), + CharacterIndex = 0xcc, + }; layer.Style.PointSymbolizer = cps; var map = new SharpMap.Map(new System.Drawing.Size(720, 360)); - + map.Layers.Add(layer); map.ZoomToExtents(); map.GetMap().Save("CharacterPointSymbolizer1.bmp"); @@ -63,7 +65,7 @@ public void TestPathPointSymbolizer() map.GetMap().Save("PathPointSymbolizer3.bmp"); var gpTriangle1 = new System.Drawing.Drawing2D.GraphicsPath(); - gpTriangle1.AddPolygon(new [] { new System.Drawing.Point(0, 0), new System.Drawing.Point(5, 10), new System.Drawing.Point(10, 0), new System.Drawing.Point(0, 0), }); + gpTriangle1.AddPolygon(new[] { new System.Drawing.Point(0, 0), new System.Drawing.Point(5, 10), new System.Drawing.Point(10, 0), new System.Drawing.Point(0, 0), }); var gpTriangle2 = new System.Drawing.Drawing2D.GraphicsPath(); gpTriangle2.AddPolygon(new[] { new System.Drawing.Point(0, 0), new System.Drawing.Point(-5, -10), new System.Drawing.Point(-10, 0), new System.Drawing.Point(0, 0), }); pps = new @@ -90,7 +92,8 @@ public void TestPathPointSymbolizer() System.Drawing.Color.Red) } - }){ Rotation = 45 }; + }) + { Rotation = 45 }; layer.Style.PointSymbolizer = pps; map.GetMap().Save("PathPointSymbolizer4.bmp"); @@ -106,8 +109,12 @@ public void TestRasterPointSymbolizer() CreatingData.GetRandomOrdinates(50, -180, 180), CreatingData.GetRandomOrdinates(50, -90, 90), null); var geometryFeatureProvider = new SharpMap.Data.Providers.GeometryFeatureProvider(fdt); var layer = new SharpMap.Layers.VectorLayer("randompoints", geometryFeatureProvider); + var stylePath = Path.GetFullPath( + Path.Combine( + Path.GetDirectoryName(GetType().Assembly.Location), + "..\\..\\..\\..\\DemoWinForm\\Resources\\women.png")); var rps = - new SharpMap.Rendering.Symbolizer.RasterPointSymbolizer {Symbol = new System.Drawing.Bitmap("women.png")}; + new SharpMap.Rendering.Symbolizer.RasterPointSymbolizer { Symbol = new System.Drawing.Bitmap(stylePath) }; layer.Style.PointSymbolizer = rps; var map = new SharpMap.Map(new System.Drawing.Size(720, 360)); @@ -120,14 +127,14 @@ public void TestRasterPointSymbolizer() rps.Rotation = 0; var cps = new SharpMap.Rendering.Symbolizer.CharacterPointSymbolizer - { - Halo = 1, - HaloBrush = new System.Drawing.SolidBrush(System.Drawing.Color.WhiteSmoke), - Foreground = new System.Drawing.SolidBrush(System.Drawing.Color.Black), - Font = new System.Drawing.Font("Arial", 12), - Text = "Anne", - Offset = new System.Drawing.PointF(0, rps.Size.Height*0.5f) - + { + Halo = 1, + HaloBrush = new System.Drawing.SolidBrush(System.Drawing.Color.WhiteSmoke), + Foreground = new System.Drawing.SolidBrush(System.Drawing.Color.Black), + Font = new System.Drawing.Font("Arial", 12), + Text = "Anne", + Offset = new System.Drawing.PointF(0, rps.Size.Height * 0.5f) + }; var lps = new SharpMap.Rendering.Symbolizer.ListPointSymbolizer { rps, cps }; @@ -171,4 +178,4 @@ public void TestListPointSymbolizer() } //D:\Development\Codeplex\_SharpMap\Repository\Trunk\DemoWinForm\Resources //D:\Development\Codeplex\_SharpMap\Repository\Trunk\DemoWinForm\Resources\Women.png -// \ No newline at end of file +// diff --git a/Examples/ExampleCodeSnippets/PolygonSymbolizerTest.cs b/Examples/ExampleCodeSnippets/PolygonSymbolizerTest.cs index a186d33a..4d457d60 100644 --- a/Examples/ExampleCodeSnippets/PolygonSymbolizerTest.cs +++ b/Examples/ExampleCodeSnippets/PolygonSymbolizerTest.cs @@ -1,3 +1,6 @@ +using SharpMap.CoordinateSystems; +using System.IO; + namespace ExampleCodeSnippets { [NUnit.Framework.TestFixture] @@ -12,10 +15,10 @@ public override void Begin(System.Drawing.Graphics g, SharpMap.MapViewport map, base.Begin(g, map, aproximateNumberOfGeometries); _oldRenderOrigin = g.RenderingOrigin; } - protected override void OnRenderInternal(SharpMap.MapViewport map, GeoAPI.Geometries.IPolygon polygon, System.Drawing.Graphics g) + protected override void OnRenderInternal(SharpMap.MapViewport map, NetTopologySuite.Geometries.Polygon polygon, System.Drawing.Graphics g) { var pt = polygon.Centroid; - g.RenderingOrigin = + g.RenderingOrigin = System.Drawing.Point.Truncate(map.WorldToImage(pt.Coordinate)); base.OnRenderInternal(map, polygon, g); } @@ -28,23 +31,36 @@ public override void End(System.Drawing.Graphics g, SharpMap.MapViewport map) [NUnit.Framework.OneTimeSetUp] public void OneTimeSetUp() - { } + { + var gss = NetTopologySuite.NtsGeometryServices.Instance; + var css = new CoordinateSystemServices( + new ProjNet.CoordinateSystems.CoordinateSystemFactory(), + new ProjNet.CoordinateSystems.Transformations.CoordinateTransformationFactory(), + SharpMap.Converters.WellKnownText.SpatialReference.GetAllReferenceSystems()); + SharpMap.Session.Instance + .SetGeometryServices(gss) + .SetCoordinateSystemServices(css) + .SetCoordinateSystemRepository(css); + } [NUnit.Framework.Test] public void TestPlainPolygonSymbolizer() { - var provider = new SharpMap.Data.Providers.ShapeFile( - "..\\..\\..\\WinFormSamples\\GeoData\\World\\countries.shp", true); + var shapePath = Path.GetFullPath( + Path.Combine( + Path.GetDirectoryName(GetType().Assembly.Location), + "..\\..\\..\\..\\WinFormSamples\\GeoData\\World\\countries.shp")); + var provider = new SharpMap.Data.Providers.ShapeFile(shapePath, true); var l = new SharpMap.Layers.Symbolizer.PolygonalVectorLayer("Countries", provider); l.Symbolizer = new ModifiedBasicPolygonSymbolizer - { - Fill = new System.Drawing.Drawing2D.HatchBrush( - System.Drawing.Drawing2D.HatchStyle.WideDownwardDiagonal, + { + Fill = new System.Drawing.Drawing2D.HatchBrush( + System.Drawing.Drawing2D.HatchStyle.WideDownwardDiagonal, System.Drawing.Color.Red /*, System.Drawing.Color.LightPink*/), - UseClipping = false, - //Outline = System.Drawing.Pens.AliceBlue - }; + UseClipping = false, + //Outline = System.Drawing.Pens.AliceBlue + }; var m = new SharpMap.Map(new System.Drawing.Size(1440, 1080)) { BackColor = System.Drawing.Color.Cornsilk }; m.Layers.Add(l); @@ -53,7 +69,7 @@ public void TestPlainPolygonSymbolizer() var sw = new System.Diagnostics.Stopwatch(); var img = m.GetMap(); - + sw.Start(); img = m.GetMap(); img.Save("PolygonSymbolizer-1.bmp", System.Drawing.Imaging.ImageFormat.Bmp); @@ -75,7 +91,7 @@ public void TestPlainPolygonSymbolizer() img.Save("PolygonSymbolizer-2.bmp", System.Drawing.Imaging.ImageFormat.Bmp); sw.Stop(); System.Console.WriteLine(string.Format("Rendering new method:{0}ms", sw.ElapsedMilliseconds)); - + } } diff --git a/Examples/ExampleCodeSnippets/ProjectionExamples.cs b/Examples/ExampleCodeSnippets/ProjectionExamples.cs index 1ceacf0c..71e137ee 100644 --- a/Examples/ExampleCodeSnippets/ProjectionExamples.cs +++ b/Examples/ExampleCodeSnippets/ProjectionExamples.cs @@ -1,8 +1,11 @@ //#define alglib +using NetTopologySuite; +using ProjNet.CoordinateSystems; + namespace ExampleCodeSnippets { - + [NUnit.Framework.TestFixture] public class ProjectionExamples { @@ -33,7 +36,7 @@ public void TestConversionProjNet() /// X' = _a*X + _b*Y + _c /// Y' = _d*X + _e*Y + _f /// - public class AffineCoordinateTransformation2D : ProjNet.CoordinateSystems.Transformations.MathTransform, GeoAPI.CoordinateSystems.Transformations.ICoordinateTransformation + public class AffineCoordinateTransformation2D : ProjNet.CoordinateSystems.Transformations.MathTransform, NetTopologySuite.CoordinateSystems.Transformations.ICoordinateTransformation { private readonly double _a, _b, _c, _d, _e, _f; private readonly double _ainv, _binv, _cinv, _dinv, _einv, _finv; @@ -110,7 +113,7 @@ public AffineCoordinateTransformation2D(double[,] matrix) #region Overrides of MathTransform - public override GeoAPI.CoordinateSystems.Transformations.IMathTransform Inverse() + public override NetTopologySuite.CoordinateSystems.Transformations.MathTransform Inverse() { //#warning(System.Drawing.Drawing2D.Matrix uses single precision floating point numbers. This involves reduction of precision, not at all accurate!) @@ -201,7 +204,7 @@ public long AuthorityCode get { throw new System.NotImplementedException(); } } - public GeoAPI.CoordinateSystems.Transformations.IMathTransform MathTransform + public NetTopologySuite.CoordinateSystems.Transformations.MathTransform MathTransform { get { return this; } } @@ -216,19 +219,19 @@ public string Remarks get { return ""; } } - public GeoAPI.CoordinateSystems.ICoordinateSystem SourceCS + public NetTopologySuite.CoordinateSystems.ICoordinateSystem SourceCS { get { return null; } } - public GeoAPI.CoordinateSystems.ICoordinateSystem TargetCS + public NetTopologySuite.CoordinateSystems.ICoordinateSystem TargetCS { get { return null; } } - public GeoAPI.CoordinateSystems.Transformations.TransformType TransformType + public NetTopologySuite.CoordinateSystems.Transformations.TransformType TransformType { - get { return GeoAPI.CoordinateSystems.Transformations.TransformType.Transformation; } + get { return NetTopologySuite.CoordinateSystems.Transformations.TransformType.Transformation; } } #endregion @@ -262,7 +265,7 @@ private static SharpMap.Data.FeatureDataTable TransformedFeatureDataTable( for (System.Int32 i = 0; i < fdtClone.Columns.Count; i++) newRow[i] = row[i]; - GeoAPI.Geometries.IPoint smpt = (GeoAPI.Geometries.IPoint)row.Geometry; + NetTopologySuite.Geometries.Point smpt = (NetTopologySuite.Geometries.Point)row.Geometry; System.Drawing.PointF[] pts = new System.Drawing.PointF[] { new System.Drawing.PointF((float)smpt.X, (float)smpt.Y) }; matrix.TransformPoints(pts); @@ -369,8 +372,8 @@ public void TestAffineTransform2D() //Get affine transformation calculates mean points to improve accuaracy //Unfortunately the result is not very good, so, since I know better I manually set these //mean points. - lst.SetMeanPoints(new GeoAPI.Geometries.IPoint(0, 0), - new GeoAPI.Geometries.IPoint(matrix.OffsetX, matrix.OffsetY)); + lst.SetMeanPoints(new NetTopologySuite.Geometries.Point(0, 0), + new NetTopologySuite.Geometries.Point(matrix.OffsetX, matrix.OffsetY)); */ //Create Affine @@ -383,13 +386,13 @@ public void TestAffineTransform2D() map.Layers.Add(new SharpMap.Layers.VectorLayer("L1", new SharpMap.Data.Providers.GeometryFeatureProvider(fdt1))); ((SharpMap.Layers.VectorLayer) map.Layers[0]).Style.Symbol = - new System.Drawing.Bitmap(@"..\..\..\DemoWinForm\Resources\flag.png"); + new System.Drawing.Bitmap("Examples\\DemoWinForm\\Resources\\flag.png"); //Add transformed layer map.Layers.Add(new SharpMap.Layers.VectorLayer("L2", new SharpMap.Data.Providers.GeometryFeatureProvider(fdt2))); ((SharpMap.Layers.VectorLayer) map.Layers[1]).Style.Symbol = - new System.Drawing.Bitmap(@"..\..\..\DemoWinForm\Resources\women.png"); + new System.Drawing.Bitmap("Examples\DemoWinForm\\Resources\\women.png"); //Render map map.ZoomToExtents(); @@ -412,7 +415,7 @@ public void TestAffineTransform2D() } } - #endif +#endif [NUnit.Framework.Test] public void TestGdalRasterLayer() @@ -428,7 +431,7 @@ public void TestGdalRasterLayer() var p1 = ecw1.GetProjection(); ecw2.ReprojectToCoordinateSystem(p1); - var m = new SharpMap.Map(new System.Drawing.Size( 1024, 768)); + var m = new SharpMap.Map(new System.Drawing.Size(1024, 768)); m.Layers.Add(ecw1); m.Layers.Add(ecw2); @@ -439,34 +442,34 @@ public void TestGdalRasterLayer() } } -public static void ReprojectFeatureDataSet(SharpMap.Data.FeatureDataSet fds, - GeoAPI.CoordinateSystems.ICoordinateSystem target) -{ - for (var i = 0; i < fds.Tables.Count; i ++) - { - var fdt = fds.Tables[i]; - ReprojectFeatureDataTable(fdt, target); - } + public static void ReprojectFeatureDataSet(SharpMap.Data.FeatureDataSet fds, + CoordinateSystem target) + { + for (var i = 0; i < fds.Tables.Count; i++) + { + var fdt = fds.Tables[i]; + ReprojectFeatureDataTable(fdt, target); + } -} + } -public static void ReprojectFeatureDataTable(SharpMap.Data.FeatureDataTable fdt, - GeoAPI.CoordinateSystems.ICoordinateSystem target) -{ - var source = SharpMap.CoordinateSystems.CoordinateSystemExtensions.GetCoordinateSystem(fdt[0].Geometry); + public static void ReprojectFeatureDataTable(SharpMap.Data.FeatureDataTable fdt, + CoordinateSystem target) + { + var source = SharpMap.CoordinateSystems.CoordinateSystemExtensions.GetCoordinateSystem(fdt[0].Geometry); - var ctFactory = new ProjNet.CoordinateSystems.Transformations.CoordinateTransformationFactory(); - var ct = ctFactory.CreateFromCoordinateSystems(source, target); - - var geomFactory = GeoAPI.GeometryServiceProvider.Instance.CreateGeometryFactory((int)target.AuthorityCode); + var ctFactory = new ProjNet.CoordinateSystems.Transformations.CoordinateTransformationFactory(); + var ct = ctFactory.CreateFromCoordinateSystems(source, target); - for (var i = 0; i < fdt.Rows.Count; i++) - { - var fdr = fdt[i]; - fdr.Geometry = - GeoAPI.CoordinateSystems.Transformations.GeometryTransform.TransformGeometry(fdr.Geometry, - ct.MathTransform, geomFactory); - } -} + var geomFactory = NtsGeometryServices.Instance.CreateGeometryFactory((int)target.AuthorityCode); + + for (var i = 0; i < fdt.Rows.Count; i++) + { + var fdr = fdt[i]; + fdr.Geometry = + NetTopologySuite.CoordinateSystems.Transformations.GeometryTransform.TransformGeometry(fdr.Geometry, + ct.MathTransform, geomFactory); + } + } } } diff --git a/Examples/ExampleCodeSnippets/ReadXmlExample.cs b/Examples/ExampleCodeSnippets/ReadXmlExample.cs index 9357326e..34397b18 100644 --- a/Examples/ExampleCodeSnippets/ReadXmlExample.cs +++ b/Examples/ExampleCodeSnippets/ReadXmlExample.cs @@ -3,13 +3,13 @@ public class ReadXmlExample { /// - /// Creates an enumeration of s from an xml string + /// Creates an enumeration of s from an xml string /// /// /// the xml string /// Coordinates - public static System.Collections.Generic.IEnumerable PointsFromXml( - GeoAPI.Geometries.IGeometryFactory factory, + public static System.Collections.Generic.IEnumerable PointsFromXml( + NetTopologySuite.Geometries.GeometryFactory factory, System.IO.Stream xml) { foreach (var coordinate in CoordinatesFromXml(xml)) @@ -17,11 +17,11 @@ public class ReadXmlExample } /// - /// Creates an enumeration of s from an xml string + /// Creates an enumeration of s from an xml string /// /// the xml string /// Coordinates - public static System.Collections.Generic.IEnumerable CoordinatesFromXml(System.IO.Stream xml) + public static System.Collections.Generic.IEnumerable CoordinatesFromXml(System.IO.Stream xml) { var reader = System.Xml.XmlReader.Create(xml); var doc = System.Xml.Linq.XDocument.Load(reader); @@ -47,11 +47,11 @@ public class ReadXmlExample var y = double.Parse(element.Value, System.Globalization.NumberFormatInfo.InvariantInfo); - yield return new GeoAPI.Geometries.Coordinate(x, y); + yield return new NetTopologySuite.Geometries.Coordinate(x, y); } } } - + [NUnit.Framework.Test] public void TestXml1() { @@ -65,7 +65,7 @@ public void TestXml1() "; var xmlFileName = System.IO.Path.ChangeExtension(System.IO.Path.GetTempFileName(), "xml"); - + using (var sw = new System.IO.StreamWriter(System.IO.File.OpenWrite(xmlFileName))) sw.Write(xml); diff --git a/Examples/ExampleCodeSnippets/Theming.cs b/Examples/ExampleCodeSnippets/Theming.cs index ce23d3fa..9f9ccc3f 100644 --- a/Examples/ExampleCodeSnippets/Theming.cs +++ b/Examples/ExampleCodeSnippets/Theming.cs @@ -1,5 +1,6 @@ namespace ExampleCodeSnippets { + using System.IO; using cd = CreatingData; public class SymbolRotationTheming @@ -19,7 +20,7 @@ public class SymbolRotationTheming /// /// Name of the column, which contains the rotation angle in degrees [0°, 360°] public SymbolRotationTheming(System.String styleRotationColumn) - :this(styleRotationColumn, new SharpMap.Styles.VectorStyle()) + : this(styleRotationColumn, new SharpMap.Styles.VectorStyle()) { } @@ -38,19 +39,19 @@ private static SharpMap.Styles.VectorStyle CloneStyle(SharpMap.Styles.VectorStyl { SharpMap.Styles.VectorStyle style = new SharpMap.Styles.VectorStyle - { - Enabled = styleToClone.Enabled, - MinVisible = styleToClone.MinVisible, - MaxVisible = styleToClone.MaxVisible, - Line = styleToClone.Line.Clone() as System.Drawing.Pen, - Fill = styleToClone.Fill.Clone() as System.Drawing.Brush, - Outline = styleToClone.Outline.Clone() as System.Drawing.Pen, - EnableOutline = styleToClone.EnableOutline, - Symbol = styleToClone.Symbol.Clone() as System.Drawing.Bitmap, - SymbolOffset = styleToClone.SymbolOffset, - SymbolRotation = styleToClone.SymbolRotation, - SymbolScale = styleToClone.SymbolScale - }; + { + Enabled = styleToClone.Enabled, + MinVisible = styleToClone.MinVisible, + MaxVisible = styleToClone.MaxVisible, + Line = styleToClone.Line.Clone() as System.Drawing.Pen, + Fill = styleToClone.Fill.Clone() as System.Drawing.Brush, + Outline = styleToClone.Outline.Clone() as System.Drawing.Pen, + EnableOutline = styleToClone.EnableOutline, + Symbol = styleToClone.Symbol.Clone() as System.Drawing.Bitmap, + SymbolOffset = styleToClone.SymbolOffset, + SymbolRotation = styleToClone.SymbolRotation, + SymbolScale = styleToClone.SymbolScale + }; return style; } @@ -132,7 +133,7 @@ public SharpMap.Styles.VectorStyle GetRotatedSymol(SharpMap.Data.FeatureDataRow if (!row.IsNull(SymbolColumn)) { dataStyle.Symbol = new System.Drawing.Bitmap( - new System.IO.MemoryStream((byte[]) row[SymbolColumn])); + new System.IO.MemoryStream((byte[])row[SymbolColumn])); } return dataStyle; } @@ -150,37 +151,41 @@ static System.Double[] GetRandomOrdinates(System.Int32 size, System.Double min, { System.Double[] arr = new System.Double[size]; System.Double width = max - min; - for(System.Int32 i = 0; i < size; i++) + for (System.Int32 i = 0; i < size; i++) { System.Double randomValue = _randomNumberGenerator.NextDouble(); - arr[i] = min + randomValue*width; + arr[i] = min + randomValue * width; } return arr; } - + [NUnit.Framework.Test] public void TestSymbolRotationTheming() { //Create a map - SharpMap.Map map = new SharpMap.Map(new System.Drawing.Size(720,360)); - + SharpMap.Map map = new SharpMap.Map(new System.Drawing.Size(720, 360)); + //Create some random sample data SharpMap.Data.FeatureDataTable fdt = cd.CreatePointFeatureDataTableFromArrays(cd.GetRandomOrdinates(80, -180, 180), cd.GetRandomOrdinates(80, -90, 90), null); //Add rotation column and fill with random rotation values - fdt.Columns.Add("Rotation", typeof (System.Double)); + fdt.Columns.Add("Rotation", typeof(System.Double)); foreach (SharpMap.Data.FeatureDataRow row in fdt.Rows) - row["Rotation"] = _randomNumberGenerator.NextDouble()*360d; + row["Rotation"] = _randomNumberGenerator.NextDouble() * 360d; //Create layer and datasource SharpMap.Layers.VectorLayer vl = new SharpMap.Layers.VectorLayer("Points", new SharpMap.Data.Providers.GeometryFeatureProvider(fdt)); - + //Create default style SharpMap.Styles.VectorStyle defaultStyle = new SharpMap.Styles.VectorStyle(); - defaultStyle.Symbol = new System.Drawing.Bitmap(@"..\..\..\DemoWinForm\Resources\flag.png"); + var stylePath = Path.GetFullPath( + Path.Combine( + Path.GetDirectoryName(GetType().Assembly.Location), + "..\\..\\..\\..\\DemoWinForm\\Resources\\flag.png")); + defaultStyle.Symbol = new System.Drawing.Bitmap(stylePath); defaultStyle.SymbolScale = 0.5f; //Create theming class and apply to layer @@ -232,7 +237,11 @@ public void TestSymbolSelectionTheming() //Create default style SharpMap.Styles.VectorStyle defaultStyle = new SharpMap.Styles.VectorStyle(); - defaultStyle.Symbol = new System.Drawing.Bitmap(@"..\..\..\DemoWinForm\Resources\flag.png"); + var resPath = Path.GetFullPath( + Path.Combine( + Path.GetDirectoryName(GetType().Assembly.Location), + "..\\..\\..\\..\\DemoWinForm\\Resources\\flag.png")); + defaultStyle.Symbol = new System.Drawing.Bitmap(resPath); defaultStyle.SymbolScale = 0.5f; //Create theming class and apply to layer @@ -247,8 +256,8 @@ public void TestSymbolSelectionTheming() private byte[] RandomSymbol(int number) { - number = number%360; - string text =""; + number = number % 360; + string text = ""; System.Drawing.Brush brush = null; if (number < 60) return null; @@ -257,7 +266,7 @@ private byte[] RandomSymbol(int number) text = "<120"; brush = System.Drawing.Brushes.DarkGreen; } - else if(number < 240) + else if (number < 240) { text = number.ToString(); brush = System.Drawing.Brushes.Orange; @@ -273,7 +282,7 @@ private byte[] RandomSymbol(int number) System.Drawing.RectangleF size = new System.Drawing.RectangleF(0f, 0f, 120f, 60f); g.FillRectangle(System.Drawing.Brushes.White, size); var sf = new System.Drawing.StringFormat(System.Drawing.StringFormatFlags.NoWrap) - {Alignment = System.Drawing.StringAlignment.Center}; + { Alignment = System.Drawing.StringAlignment.Center }; g.DrawString(text, new System.Drawing.Font("Arial", 24), brush, size, sf); g.Flush(); @@ -296,11 +305,11 @@ public void DoTest() new SharpMap.Data.Providers.GeometryFeatureProvider(fds.Tables[0]); System.Data.DataTable dt = new System.Data.DataTable("external"); - dt.Columns.Add("city", typeof (string)); - dt.Columns.Add("males", typeof (int)); - dt.Columns.Add("females", typeof (int)); + dt.Columns.Add("city", typeof(string)); + dt.Columns.Add("males", typeof(int)); + dt.Columns.Add("females", typeof(int)); } } -} \ No newline at end of file +} diff --git a/Examples/ExampleCodeSnippets/app.config b/Examples/ExampleCodeSnippets/app.config index 4913f2e5..6fa6f181 100644 --- a/Examples/ExampleCodeSnippets/app.config +++ b/Examples/ExampleCodeSnippets/app.config @@ -1,15 +1,23 @@  - - -
- - - - - - Microsoft.ACE.OLEDB.15.0 - - - + + +
+ + + + + + Microsoft.ACE.OLEDB.12.0 + + + + + + + + + + + diff --git a/Examples/ExampleCodeSnipplets.VB/CustomThemeExample.vb b/Examples/ExampleCodeSnipplets.VB/CustomThemeExample.vb index a209e1c2..bc2b00af 100644 --- a/Examples/ExampleCodeSnipplets.VB/CustomThemeExample.vb +++ b/Examples/ExampleCodeSnipplets.VB/CustomThemeExample.vb @@ -11,7 +11,7 @@ Protected Overrides Sub Finalize() - For Each kvp as KeyValuePair(Of String, SharpMap.Styles.IStyle) in _styles + For Each kvp as KeyValuePair(Of String, SharpMap.Styles.IStyle) in _styles kvp.Value.Dispose() Next @@ -52,23 +52,23 @@ End Class public Class UniqueValuesThemeTest - Private delObjektLabelBez As SharpMap.Layers.LabelLayer.GetLabelMethod - Private delObjektLabelPos As SharpMap.Layers.LabelLayer.GetLocationMethod - Private delObjektLabelStyle As SharpMap.Rendering.Thematics.CustomTheme.GetStyleMethod - Private delObjektStyle As SharpMap.Rendering.Thematics.CustomTheme.GetStyleMethod - ' + Private delObjektLabelBez As SharpMap.Layers.LabelLayer.GetLabelMethod + Private delObjektLabelPos As SharpMap.Layers.LabelLayer.GetLocationMethod + Private delObjektLabelStyle As SharpMap.Rendering.Thematics.CustomTheme.GetStyleMethod + Private delObjektStyle As SharpMap.Rendering.Thematics.CustomTheme.GetStyleMethod + ' Private _map As SharpMap.Map - + public class OtherClassItem - public Property Name () As String + public Property Name() As String Public Property Datasource() As string Public Property Table() As string Public Property Field() As string End Class - public class OtherClass + public class OtherClass Inherits System.Collections.Generic.List(Of OtherClassItem) - public Property Name () As String + public Property Name() As String End Class Private _polygonTheme As SharpMap.Rendering.Thematics.UniqueValuesTheme(Of Int32) = CreatePolygonTheme() @@ -84,14 +84,14 @@ public Class UniqueValuesThemeTest s.EnableOutline = True styleMap.Add(1, s) '2 - s = New SharpMap.Styles. VectorStyle() - s.Outline=new Drawing.Pen(Drawing.Color.Black, 1) + s = New SharpMap.Styles.VectorStyle() + s.Outline = new Drawing.Pen(Drawing.Color.Black, 1) s.Fill = New Drawing.SolidBrush(Drawing.Color.Blue) s.EnableOutline = True styleMap.Add(2, s) '3 s = New SharpMap.Styles.VectorStyle() - s.Outline =new Drawing.Pen(Drawing.Color.Black, 1) + s.Outline = new Drawing.Pen(Drawing.Color.Black, 1) s.Fill = New Drawing.SolidBrush(Drawing.Color.Red) s.EnableOutline = True styleMap.Add(2, s) @@ -100,103 +100,103 @@ public Class UniqueValuesThemeTest Return new SharpMap.Rendering.Thematics.UniqueValuesTheme(Of Integer)("FilterColumn", styleMap, SharpMap.Styles.VectorStyle.CreateRandomPolygonalStyle()) End Function - Public Sub CreateLayers(ByVal config as OtherClass) - ' - delObjektLabelBez = New SharpMap.Layers.LabelLayer.GetLabelMethod(AddressOf LabelObjektBezeichnung) - delObjektLabelPos = New SharpMap.Layers.LabelLayer.GetLocationMethod(AddressOf LabelBezeichnungPos) - delObjektStyle = New SharpMap.Rendering.Thematics.CustomTheme.GetStyleMethod(AddressOf GetObjektStyle) - delObjektLabelStyle = New SharpMap.Rendering.Thematics.CustomTheme.GetStyleMethod(AddressOf GetObjektLabelStyle) - ' - For each itm as OtherClassItem in config - Select Case itm.Name - Case "Name1" - Dim smp as New SharpMap.Data.Providers.PostGIS(itm.Datasource, itm.Table, itm.Field) - Dim vLay as New SharpMap.Layers.VectorLayer(itm.Name, smp) - 'Dim layTheme = New SharpMap.Rendering.Thematics.CustomTheme(delObjektStyle) - vLay.Theme = Me._polygonTheme 'layTheme - ' - Dim labLay As New SharpMap.Layers.LabelLayer("Lable: " & itm.Name) - Dim labTheme as New SharpMap.Rendering.Thematics.CustomTheme(delObjektLabelStyle) - labLay.DataSource = vLay.DataSource - labLay.Theme = labTheme - labLay.LabelStringDelegate = delObjektLabelBez - labLay.LabelPositionDelegate = delObjektLabelPos - ' - _map.Layers.Add(vLay) - _Map.Layers.Add(labLay) - ' - Case "Name2" - Dim smp as New SharpMap.Data.Providers.PostGIS(itm.Datasource, itm.Table, itm.Field) - Dim vLay as New SharpMap.Layers.VectorLayer(itm.Name, smp) - ' - 'other code - ' - Dim labLay As New SharpMap.Layers.LabelLayer("Lable: " & itm.Name) - Dim labTheme as New SharpMap.Rendering.Thematics.CustomTheme(delObjektLabelStyle) - labLay.DataSource = vLay.DataSource - labLay.Theme = labTheme - labLay.LabelStringDelegate = delObjektLabelBez - labLay.LabelPositionDelegate = delObjektLabelPos - ' - _map.Layers.Add(vLay) - _map.Layers.Add(labLay) + Public Sub CreateLayers(ByVal config as OtherClass) + ' + delObjektLabelBez = New SharpMap.Layers.LabelLayer.GetLabelMethod(AddressOf LabelObjektBezeichnung) + delObjektLabelPos = New SharpMap.Layers.LabelLayer.GetLocationMethod(AddressOf LabelBezeichnungPos) + delObjektStyle = New SharpMap.Rendering.Thematics.CustomTheme.GetStyleMethod(AddressOf GetObjektStyle) + delObjektLabelStyle = New SharpMap.Rendering.Thematics.CustomTheme.GetStyleMethod(AddressOf GetObjektLabelStyle) + ' + For each itm as OtherClassItem in config + Select Case itm.Name + Case "Name1" + Dim smp as New SharpMap.Data.Providers.PostGIS(itm.Datasource, itm.Table, itm.Field) + Dim vLay as New SharpMap.Layers.VectorLayer(itm.Name, smp) + 'Dim layTheme = New SharpMap.Rendering.Thematics.CustomTheme(delObjektStyle) + vLay.Theme = Me._polygonTheme 'layTheme + ' + Dim labLay As New SharpMap.Layers.LabelLayer("Lable: " & itm.Name) + Dim labTheme as New SharpMap.Rendering.Thematics.CustomTheme(delObjektLabelStyle) + labLay.DataSource = vLay.DataSource + labLay.Theme = labTheme + labLay.LabelStringDelegate = delObjektLabelBez + labLay.LabelPositionDelegate = delObjektLabelPos + ' + _map.Layers.Add(vLay) + _Map.Layers.Add(labLay) ' - End Select + Case "Name2" + Dim smp as New SharpMap.Data.Providers.PostGIS(itm.Datasource, itm.Table, itm.Field) + Dim vLay as New SharpMap.Layers.VectorLayer(itm.Name, smp) + ' + 'other code + ' + Dim labLay As New SharpMap.Layers.LabelLayer("Lable: " & itm.Name) + Dim labTheme as New SharpMap.Rendering.Thematics.CustomTheme(delObjektLabelStyle) + labLay.DataSource = vLay.DataSource + labLay.Theme = labTheme + labLay.LabelStringDelegate = delObjektLabelBez + labLay.LabelPositionDelegate = delObjektLabelPos + ' + _map.Layers.Add(vLay) + _map.Layers.Add(labLay) + ' + End Select + ' + Next + ' + 'Other Code ..... ' - Next - ' - 'Other Code ..... - ' - End Sub - + End Sub + Private Shared function LabelObjektBezeichnung(fdr As SharpMap.Data.FeatureDataRow) As String return "The quick brown fox ..." - End function + End Function - Private Shared Function LabelBezeichnungPos(fdr As SharpMap.Data.FeatureDataRow) As GeoAPI.Geometries.Coordinate - return new GeoAPI.Geometries.Coordinate(0, 0) + Private Shared Function LabelBezeichnungPos(fdr As SharpMap.Data.FeatureDataRow) As NetTopologySuite.Geometries.Coordinate + Return New NetTopologySuite.Geometries.Coordinate(0, 0) End Function - + Private shared function GetObjektLabelStyle(fdr As SharpMap.Data.FeatureDataRow) As SharpMap.Styles.LabelStyle End function - Private shared Function GetObjektStyle(fdr As SharpMap.Data.FeatureDataRow) As SharpMap.Styles.VectorStyle - ' - Dim style As New SharpMap.Styles.VectorStyle - Dim c as Drawing.Color - Dim p as Drawing.Pen - Dim b as Drawing.Brush - ' - Select Case fdr.Table.TableName - Case "Name1" '-- Polygon - Select Case fdr("FilterColumn") - Case 1 - c = Drawing.Color.Green - p = New Drawing.Pen(Drawing.Color.Black, 1) - b = New Drawing.SolidBrush(c) - Case 2 - c = Drawing.Color.Blue - p = New Drawing.Pen(Drawing.Color.Black, 1) - b = New Drawing.SolidBrush(c) - Case Else - c = Drawing.Color.Red - p = New Drawing.Pen(Drawing.Color.Black, 1) - b = New Drawing.SolidBrush(c) - End Select - ' - style.Fill = b - style.Outline = p + Private shared Function GetObjektStyle(fdr As SharpMap.Data.FeatureDataRow) As SharpMap.Styles.VectorStyle + ' + Dim style As New SharpMap.Styles.VectorStyle + Dim c as Drawing.Color + Dim p as Drawing.Pen + Dim b as Drawing.Brush + ' + Select Case fdr.Table.TableName + Case "Name1" '-- Polygon + Select Case fdr("FilterColumn") + Case 1 + c = Drawing.Color.Green + p = New Drawing.Pen(Drawing.Color.Black, 1) + b = New Drawing.SolidBrush(c) + Case 2 + c = Drawing.Color.Blue + p = New Drawing.Pen(Drawing.Color.Black, 1) + b = New Drawing.SolidBrush(c) + Case Else + c = Drawing.Color.Red + p = New Drawing.Pen(Drawing.Color.Black, 1) + b = New Drawing.SolidBrush(c) + End Select + ' + style.Fill = b + style.Outline = p ' - Case "Name2"' -- Lines - ' - ' this Code will not Run - ' - Case Else - End Select - ' - Return style + Case "Name2" ' -- Lines + ' + ' this Code will not Run + ' + Case Else + End Select + ' + Return style + ' + End Function ' - End Function - ' End Class diff --git a/Examples/ExampleCodeSnipplets.VB/ExampleCodeSnipplets.VB.vbproj b/Examples/ExampleCodeSnipplets.VB/ExampleCodeSnipplets.VB.vbproj index eaccd23e..ecc65b16 100644 --- a/Examples/ExampleCodeSnipplets.VB/ExampleCodeSnipplets.VB.vbproj +++ b/Examples/ExampleCodeSnipplets.VB/ExampleCodeSnipplets.VB.vbproj @@ -21,8 +21,7 @@ - - + @@ -36,5 +35,9 @@ + + + + diff --git a/Examples/SharpMap.Demo.Wms/Controllers/BuildingsController.cs b/Examples/SharpMap.Demo.Wms/Controllers/BuildingsController.cs index 0934fbc6..36635da6 100644 --- a/Examples/SharpMap.Demo.Wms/Controllers/BuildingsController.cs +++ b/Examples/SharpMap.Demo.Wms/Controllers/BuildingsController.cs @@ -1,19 +1,13 @@ namespace SharpMap.Demo.Wms.Controllers { + using NetTopologySuite.Geometries; + using SharpMap.Data; + using SharpMap.Data.Providers; using System; using System.Collections.Generic; using System.IO; - using System.Linq; using System.Web.Mvc; - - using GeoAPI; - using GeoAPI.Geometries; - - using NetTopologySuite; - using NetTopologySuite.Geometries; - - using SharpMap.Data; - using SharpMap.Data.Providers; + using Point = System.Drawing.Point; public class BuildingsController : Controller { @@ -21,10 +15,7 @@ public class BuildingsController : Controller private const int TileSize = 256; private const int MaxZoom = 18; - public BuildingsController() - { - GeometryServiceProvider.SetInstanceIfNotAlreadySetDirectly(new NtsGeometryServices()); - } + public BuildingsController() { } private Point GeoToPixel(double lat, double lon, int zoom) { @@ -70,10 +61,10 @@ public JsonResult GetData(float w, float n, float e, float s, int z) if (c == 0) c = 5; // default value for "null" (zero) heights int h = c * ScaleZ >> zz; - if (h <= 1) + if (h <= 1) h = 1; - IGeometry geometry = row.Geometry; + Geometry geometry = row.Geometry; Coordinate[] coords = geometry.Coordinates; int total = coords.Length; double[] values = new double[total * 2]; diff --git a/Examples/SharpMap.Demo.Wms/Controllers/HomeController.cs b/Examples/SharpMap.Demo.Wms/Controllers/HomeController.cs index c3e899f9..981c82f5 100644 --- a/Examples/SharpMap.Demo.Wms/Controllers/HomeController.cs +++ b/Examples/SharpMap.Demo.Wms/Controllers/HomeController.cs @@ -1,26 +1,25 @@ namespace SharpMap.Demo.Wms.Controllers { + using SharpMap.Demo.Wms.Models; using System; using System.Collections.Generic; using System.Reflection; using System.Web.Mvc; - using SharpMap.Demo.Wms.Models; - public class HomeController : Controller { private List GetDemoItems() { List items = new List(); - Type type = this.GetType(); + Type type = GetType(); // how to retrieve all public instance methods? // BindingFlags.Public | BindingFlags.DeclaredOnly returns an empty array... MethodInfo[] methods = type.GetMethods(); foreach (MethodInfo method in methods) - { + { bool valid = method.ReturnType == typeof(ActionResult); - if (!valid) + if (!valid) continue; object[] attributes = method.GetCustomAttributes(typeof(ObsoleteAttribute), false); @@ -30,70 +29,73 @@ private List GetDemoItems() int i = type.Name.IndexOf("Controller", StringComparison.Ordinal); string url = String.Format("{0}/{1}", type.Name.Substring(0, i), method.Name); items.Add(new DemoItem(method.Name, url)); - } + } return items; } - + [Obsolete] public ActionResult Index() { - this.ViewData["DemoItems"] = this.GetDemoItems(); - return this.View(); + ViewData["DemoItems"] = GetDemoItems(); + return View(); } public ActionResult Default() { - return this.View(); + return View(); } public ActionResult Openlayers() { - return this.View(); + return View(); } + [Obsolete] public ActionResult Polymaps() { - return this.View(); + return View(); } public ActionResult Leaflet() { - return this.View(); + return View(); } public ActionResult Geojson() { - return this.View(); + return View(); } public ActionResult Editor() { - return this.View(); + return View(); } + [Obsolete] public ActionResult Offline() { - return this.View(); + return View(); } public ActionResult TileCanvas() { - return this.View(); + return View(); } public ActionResult Buildings() { - return this.View(); + return View(); } + [Obsolete] public ActionResult UtfGrid() { - return this.View(); + return View(); } public ActionResult D3() { - return this.View(); - } + return View(); + } } } diff --git a/Examples/SharpMap.Demo.Wms/Controllers/ProcessController.cs b/Examples/SharpMap.Demo.Wms/Controllers/ProcessController.cs index f9fbd36c..aaa2dfb5 100644 --- a/Examples/SharpMap.Demo.Wms/Controllers/ProcessController.cs +++ b/Examples/SharpMap.Demo.Wms/Controllers/ProcessController.cs @@ -1,73 +1,66 @@ namespace SharpMap.Demo.Wms.Controllers { - using System; - using System.Collections; - using System.Collections.Generic; - using System.Collections.ObjectModel; - using System.IO; - using System.Linq; - using System.Web.Mvc; - - using GeoAPI.Geometries; - using NetTopologySuite.Geometries; using NetTopologySuite.Geometries.Utilities; using NetTopologySuite.IO; - using NetTopologySuite.Operation.Linemerge; using NetTopologySuite.Operation.Polygonize; using NetTopologySuite.Operation.Union; using NetTopologySuite.Simplify; - using SharpMap.Converters.GeoJSON; + using System; + using System.Collections.Generic; + using System.IO; + using System.Linq; + using System.Web.Mvc; public class ProcessController : Controller { - private readonly IGeometryFactory factory = GeometryFactory.Default; + private readonly GeometryFactory factory = GeometryFactory.Default; - private IGeometryCollection ValidateGeo(string geo) + private GeometryCollection ValidateGeo(string geo) { if (String.IsNullOrEmpty(geo)) throw new ArgumentException("invalid argument 'geo': empty string"); - WKTReader reader = new WKTReader(this.factory); - IGeometry data = reader.Read(geo); + WKTReader reader = new WKTReader(NetTopologySuite.NtsGeometryServices.Instance); + Geometry data = reader.Read(geo); // we should expect a GeometryCollection object - if (data is IGeometryCollection) - return data as IGeometryCollection; - throw new ArgumentException("invalid argument 'geo': IGeometryCollection expected"); + if (data is GeometryCollection) + return data as GeometryCollection; + throw new ArgumentException("invalid argument 'geo': GeometryCollection expected"); } - private ILineString ValidateCut(string cut) + private LineString ValidateCut(string cut) { if (String.IsNullOrEmpty(cut)) throw new ArgumentException("invalid argument 'cut': empty string"); WKTReader reader = new WKTReader(this.factory); - IGeometry data = reader.Read(cut); + Geometry data = reader.Read(cut); // we should expect a GeometryCollection object - if (data is ILineString) - return data as ILineString; - throw new ArgumentException("invalid argument 'cut': ILineString expected"); + if (data is LineString) + return data as LineString; + throw new ArgumentException("invalid argument 'cut': LineString expected"); } - private ActionResult MakeResponse(IEnumerable geometries) + private ActionResult MakeResponse(IEnumerable geometries) { if (geometries == null) throw new ArgumentNullException("geometries"); // we should return a GeometryCollection object - IGeometry[] array = geometries.ToArray(); - IGeometryCollection result = this.factory.CreateGeometryCollection(array); + Geometry[] array = geometries.ToArray(); + GeometryCollection result = this.factory.CreateGeometryCollection(array); StringWriter writer = new StringWriter(); GeoJSONWriter.Write(result, writer); return this.Json(new { geo = writer.ToString() }); } - private static IEnumerable GetItems(IGeometry coll) + private static IEnumerable GetItems(Geometry coll) { - if (coll == null) + if (coll == null) throw new ArgumentNullException("coll"); for (int i = 0; i < coll.NumGeometries; i++) @@ -77,52 +70,52 @@ private static IEnumerable GetItems(IGeometry coll) [HttpPost] public ActionResult Clean(string geo) { - IGeometryCollection coll = this.ValidateGeo(geo); - IEnumerable data = DoClean(coll); + GeometryCollection coll = this.ValidateGeo(geo); + IEnumerable data = DoClean(coll); return this.MakeResponse(data); } - private static IEnumerable DoClean(IGeometryCollection coll) + private static IEnumerable DoClean(GeometryCollection coll) { if (coll == null) throw new ArgumentNullException("coll"); - IEnumerable items = GetItems(coll); - foreach (IGeometry geom in items) + IEnumerable items = GetItems(coll); + foreach (Geometry geom in items) { DouglasPeuckerSimplifier simplifier = new DouglasPeuckerSimplifier(geom); - IGeometry clean = simplifier.GetResultGeometry(); + Geometry clean = simplifier.GetResultGeometry(); yield return clean; } - } + } [HttpPost] public ActionResult Merge(string geo) { - IGeometryCollection coll = this.ValidateGeo(geo); - IEnumerable data = DoMerge(coll); + GeometryCollection coll = this.ValidateGeo(geo); + IEnumerable data = DoMerge(coll); return this.MakeResponse(data); } - private static IEnumerable DoMerge(IGeometryCollection coll) + private static IEnumerable DoMerge(GeometryCollection coll) { if (coll == null) throw new ArgumentNullException("coll"); - IEnumerable items = GetItems(coll); + IEnumerable items = GetItems(coll); yield return UnaryUnionOp.Union(items.ToArray()); } [HttpPost] public ActionResult Split(string geo, string cut) { - IGeometryCollection coll = this.ValidateGeo(geo); - ILineString split = this.ValidateCut(cut); - IEnumerable data = DoSplit(coll, split); + GeometryCollection coll = this.ValidateGeo(geo); + LineString split = this.ValidateCut(cut); + IEnumerable data = DoSplit(coll, split); return this.MakeResponse(data); } - public static IGeometry Polygonize(IGeometry geometry) + public static Geometry Polygonize(Geometry geometry) { if (geometry == null) throw new ArgumentNullException("geometry"); @@ -130,13 +123,13 @@ public static IGeometry Polygonize(IGeometry geometry) var lines = LineStringExtracter.GetLines(geometry); var geoms = lines.ToList(); - var polygonizer = new Polygonizer(); + var polygonizer = new Polygonizer(); polygonizer.Add(geoms); var polys = polygonizer.GetPolygons(); return geometry.Factory.BuildGeometry(polys); } - private static IEnumerable DoSplit(IGeometryCollection coll, ILineString cut) + private static IEnumerable DoSplit(GeometryCollection coll, LineString cut) { if (coll == null) throw new ArgumentNullException("coll"); @@ -146,36 +139,36 @@ private static IEnumerable DoSplit(IGeometryCollection coll, ILineStr // adapted from 'SplitPolygon WPS' GeoServer extension: // https://github.com/mdavisog/wps-splitpoly/tree/master/src - IList output = new List(); - IEnumerable items = GetItems(coll); - IEnumerable valid = items.Where(i => i is IPolygon); - foreach (IGeometry item in valid) + IList output = new List(); + IEnumerable items = GetItems(coll); + IEnumerable valid = items.Where(i => i is Polygon); + foreach (Geometry item in valid) { - IGeometry nodedLinework = item.Boundary.Union(cut); - IGeometry polygons = Polygonize(nodedLinework); + Geometry nodedLinework = item.Boundary.Union(cut); + Geometry polygons = Polygonize(nodedLinework); // only keep polygons which are inside the input for (int i = 0; i < polygons.NumGeometries; i++) { - IPolygon candpoly = (IPolygon)polygons.GetGeometryN(i); + Polygon candpoly = (Polygon)polygons.GetGeometryN(i); if (item.Contains(candpoly.InteriorPoint)) output.Add(candpoly); - } + } } return output; /* - IEnumerable items = GetItems(coll); + IEnumerable items = GetItems(coll); LineMerger merger = new LineMerger(); merger.Add(items); merger.Add(cut); - IList list = merger.GetMergedLineStrings(); + IList list = merger.GetMergedLineStrings(); - IGeometry union = UnaryUnionOp.Union(list); + Geometry union = UnaryUnionOp.Union(list); Polygonizer polygonizer = new Polygonizer(); polygonizer.Add(union); - ICollection split = polygonizer.GetPolygons(); + ICollection split = polygonizer.GetPolygons(); return split; * */ } diff --git a/Examples/SharpMap.Demo.Wms/Controllers/UtfGridController.cs b/Examples/SharpMap.Demo.Wms/Controllers/UtfGridController.cs index 3c0a402d..fc41a3ca 100644 --- a/Examples/SharpMap.Demo.Wms/Controllers/UtfGridController.cs +++ b/Examples/SharpMap.Demo.Wms/Controllers/UtfGridController.cs @@ -1,22 +1,19 @@ // code adapted from: https://github.com/awcoats/mapstache namespace SharpMap.Demo.Wms.Controllers { - using System; - using System.Collections.Generic; - using System.Drawing; - using System.Linq; - using System.Web.Mvc; - - using GeoAPI.Geometries; - using Mapstache; - - using GeoAPI.CoordinateSystems.Transformations; - + using NetTopologySuite.Geometries; + using ProjNet.CoordinateSystems.Transformations; using SharpMap.Converters.GeoJSON; using SharpMap.Data; using SharpMap.Demo.Wms.Helpers; using SharpMap.Layers; + using System; + using System.Collections.Generic; + using System.Drawing; + using System.Linq; + using System.Web.Mvc; + using Point = System.Drawing.Point; public class UtfGridController : Controller { @@ -74,7 +71,7 @@ public JsonResult GetData(string layer, int z, int x, int y) int i = 1; foreach (GeoJSON val in data) { - IGeometry geom = val.Geometry; + Geometry geom = val.Geometry; IDictionary dict = val.Values; grid.FillPolygon(geom, i, dict); i = i + 1; @@ -85,4 +82,4 @@ public JsonResult GetData(string layer, int z, int x, int y) } } } -} \ No newline at end of file +} diff --git a/Examples/SharpMap.Demo.Wms/Global.asax.cs b/Examples/SharpMap.Demo.Wms/Global.asax.cs index c88bfce2..e5b6c298 100644 --- a/Examples/SharpMap.Demo.Wms/Global.asax.cs +++ b/Examples/SharpMap.Demo.Wms/Global.asax.cs @@ -1,5 +1,6 @@ namespace SharpMap.Demo.Wms { + using SharpMap.CoordinateSystems; using System.Web; using System.Web.Mvc; using System.Web.Routing; @@ -15,11 +16,15 @@ public static void RegisterRoutes(RouteCollection routes) protected void Application_Start() { + var gss = NetTopologySuite.NtsGeometryServices.Instance; + var css = new CoordinateSystemServices( + new ProjNet.CoordinateSystems.CoordinateSystemFactory(), + new ProjNet.CoordinateSystems.Transformations.CoordinateTransformationFactory(), + Converters.WellKnownText.SpatialReference.GetAllReferenceSystems()); SharpMap.Session.Instance - .SetGeometryServices(NetTopologySuite.NtsGeometryServices.Instance) - .SetCoordinateSystemServices(CoordinateSystems.CoordinateSystemServices - .FromSpatialRefSys(new ProjNet.CoordinateSystems.CoordinateSystemFactory(), - new ProjNet.CoordinateSystems.Transformations.CoordinateTransformationFactory())); + .SetGeometryServices(gss) + .SetCoordinateSystemServices(css) + .SetCoordinateSystemRepository(css); AreaRegistration.RegisterAllAreas(); RegisterRoutes(RouteTable.Routes); diff --git a/Examples/SharpMap.Demo.Wms/Handlers/AbstractStdMapHandler.cs b/Examples/SharpMap.Demo.Wms/Handlers/AbstractStdMapHandler.cs index db07b875..b9311089 100644 --- a/Examples/SharpMap.Demo.Wms/Handlers/AbstractStdMapHandler.cs +++ b/Examples/SharpMap.Demo.Wms/Handlers/AbstractStdMapHandler.cs @@ -1,23 +1,13 @@ namespace SharpMap.Demo.Wms.Handlers { + using SharpMap.Demo.Wms.Helpers; using System; using System.Web; - using GeoAPI; - - using NetTopologySuite; - - using SharpMap.Demo.Wms.Helpers; - public abstract class AbstractStdMapHandler : IHttpHandler { private static readonly object SyncLock = new object(); - static AbstractStdMapHandler() - { - GeometryServiceProvider.SetInstanceIfNotAlreadySetDirectly(NtsGeometryServices.Instance); - } - public abstract void ProcessRequest(HttpContext context); protected string GetFixedUrl(HttpRequest request) @@ -27,7 +17,7 @@ protected string GetFixedUrl(HttpRequest request) return uri.Query.Length <= 0 ? absoluteUri : absoluteUri.Replace(uri.Query, String.Empty); } - protected Web.Wms.Capabilities.WmsServiceDescription GetDescription(string url) + protected Web.Wms.Capabilities.WmsServiceDescription GetDescription(string url) { var description = new Web.Wms.Capabilities.WmsServiceDescription("Acme Corp. Map Server", url); description.MaxWidth = 500; @@ -44,7 +34,7 @@ protected Web.Wms.Capabilities.WmsServiceDescription GetDescription(string url) protected Map GetMap(HttpRequest request) { - string type = request.Params["MAP_TYPE"]; + string type = request.Params["MAP_TYPE"]; if (String.Equals(type, "DEF", StringComparison.InvariantCultureIgnoreCase)) return ShapefileHelper.Default(); if (String.Equals(type, "SPH", StringComparison.InvariantCultureIgnoreCase)) @@ -53,7 +43,7 @@ protected Map GetMap(HttpRequest request) return DatabaseHelper.SqlServer(); string format = String.Format("unsupported map type: '{0}'", type); throw new NotSupportedException(format); - } + } public bool IsReusable { diff --git a/Examples/SharpMap.Demo.Wms/Handlers/StdJsonMapHandler.cs b/Examples/SharpMap.Demo.Wms/Handlers/StdJsonMapHandler.cs index 5caac04b..5c02548f 100644 --- a/Examples/SharpMap.Demo.Wms/Handlers/StdJsonMapHandler.cs +++ b/Examples/SharpMap.Demo.Wms/Handlers/StdJsonMapHandler.cs @@ -1,23 +1,19 @@ namespace SharpMap.Demo.Wms.Handlers { + using NetTopologySuite.CoordinateSystems.Transformations; + using ProjNet.CoordinateSystems.Transformations; + using SharpMap.Converters.GeoJSON; + using SharpMap.Data; + using SharpMap.Layers; + using SharpMap.Web.Wms; using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Web; - - using NetTopologySuite.Geometries; - - using GeoAPI.CoordinateSystems.Transformations; - - using SharpMap.Converters.GeoJSON; - using SharpMap.Data; - using SharpMap.Layers; - using SharpMap.Web.Wms; - - using Geometry = GeoAPI.Geometries.IGeometry; - using BoundingBox = GeoAPI.Geometries.Envelope; + using BoundingBox = NetTopologySuite.Geometries.Envelope; + using Geometry = NetTopologySuite.Geometries.Geometry; public class StdJsonMapHandler : AbstractStdMapHandler { @@ -47,10 +43,10 @@ public override void ProcessRequest(HttpContext context) string[] layers = ls.Split(','); foreach (ILayer layer in map.Layers) if (!layers.Contains(layer.LayerName)) - layer.Enabled = false; + layer.Enabled = false; } - IEnumerable items = GetData(map, bbox); + IEnumerable items = GetData(map, bbox); StringWriter writer = new StringWriter(); GeoJSONWriter.Write(items, writer); string buffer = writer.ToString(); @@ -75,11 +71,11 @@ private static IEnumerable GetData(Map map, BoundingBox bbox) { if (map == null) throw new ArgumentNullException("map"); - + // Only queryable data! IQueryable coll = map.Layers .AsQueryable() - .Where(l => l.Enabled) + .Where(l => l.Enabled) .OfType() .Where(l => l.IsQueryEnabled); @@ -103,7 +99,7 @@ private static IEnumerable QueryData(BoundingBox bbox, ICanQueryLayer l IEnumerable data = GeoJSONHelper.GetData(ds); // Reproject geometries if needed - IMathTransform transform = null; + MathTransform transform = null; if (layer is VectorLayer) { ICoordinateTransformation transformation = (layer as VectorLayer).CoordinateTransformation; @@ -111,10 +107,9 @@ private static IEnumerable QueryData(BoundingBox bbox, ICanQueryLayer l } if (transform != null) { - GeometryFactory gf = new GeometryFactory(); data = data.Select(d => { - Geometry converted = GeometryTransform.TransformGeometry(d.Geometry, transform, gf); + Geometry converted = GeometryTransform.TransformGeometry(d.Geometry, transform, d.Geometry.Factory); d.SetGeometry(converted); return d; }); diff --git a/Examples/SharpMap.Demo.Wms/Handlers/StdWmsMapHandler.cs b/Examples/SharpMap.Demo.Wms/Handlers/StdWmsMapHandler.cs index 987adde5..0de19062 100644 --- a/Examples/SharpMap.Demo.Wms/Handlers/StdWmsMapHandler.cs +++ b/Examples/SharpMap.Demo.Wms/Handlers/StdWmsMapHandler.cs @@ -1,11 +1,10 @@ namespace SharpMap.Demo.Wms.Handlers { + using SharpMap.Web.Wms; using System; using System.Diagnostics; using System.Web; - using SharpMap.Web.Wms; - public class StdWmsMapHandler : AbstractStdMapHandler { public override void ProcessRequest(HttpContext context) diff --git a/Examples/SharpMap.Demo.Wms/Helpers/DatabaseHelper.cs b/Examples/SharpMap.Demo.Wms/Helpers/DatabaseHelper.cs index ef33acc0..46f050b8 100644 --- a/Examples/SharpMap.Demo.Wms/Helpers/DatabaseHelper.cs +++ b/Examples/SharpMap.Demo.Wms/Helpers/DatabaseHelper.cs @@ -1,26 +1,23 @@ namespace SharpMap.Demo.Wms.Helpers { - using System; - using System.Drawing; - using System.Drawing.Drawing2D; - - using GeoAPI.CoordinateSystems.Transformations; - using SharpMap.Data.Providers; using SharpMap.Layers; using SharpMap.Styles; + using System; + using System.Drawing; + using System.Drawing.Drawing2D; public static class DatabaseHelper { public static Map SqlServer() { const string connstr = "Data Source=.\\SQL2008R2;Initial Catalog=SampleData;Integrated Security=SSPI;"; - Map map = new Map(new Size(1, 1)); + Map map = new Map(new Size(1, 1)); VectorStyle style0 = new VectorStyle { Line = new Pen(Color.DarkGray, 2) }; VectorLayer layer0 = CreateLayer(connstr, "osm_boundaries", style0); map.Layers.Add(layer0); - + VectorStyle style1 = new VectorStyle { Line = new Pen(Color.DarkRed, 2.5f) }; VectorLayer layer1 = CreateLayer(connstr, "osm_roads_major", style1); map.Layers.Add(layer1); @@ -28,7 +25,7 @@ public static Map SqlServer() VectorStyle style2 = new VectorStyle { Line = new Pen(Color.DarkBlue, 1.5f) }; VectorLayer layer2 = CreateLayer(connstr, "osm_roads_minor", style2); map.Layers.Add(layer2); - + return map; } @@ -39,9 +36,10 @@ private static VectorLayer CreateLayer(string connstr, string name, VectorStyle if (name == null) throw new ArgumentNullException("name"); - - var source = new SqlServer2008(connstr, name, "geom", "ID", - SqlServerSpatialObjectType.Geometry, 0, SqlServer2008ExtentsMode.QueryIndividualFeatures) { ValidateGeometries = true }; + + var source = new SqlServer2008(connstr, name, "geom", "ID", + SqlServerSpatialObjectType.Geometry, 0, SqlServer2008ExtentsMode.QueryIndividualFeatures) + { ValidateGeometries = true }; var transformation = ProjHelper.LatLonToGoogle(); var item = new VectorLayer(name, source) { diff --git a/Examples/SharpMap.Demo.Wms/Helpers/ExtensionMethods.cs b/Examples/SharpMap.Demo.Wms/Helpers/ExtensionMethods.cs index bc866cb2..84201f15 100644 --- a/Examples/SharpMap.Demo.Wms/Helpers/ExtensionMethods.cs +++ b/Examples/SharpMap.Demo.Wms/Helpers/ExtensionMethods.cs @@ -13,11 +13,11 @@ public static string Join(this IEnumerable strings) public static string Join(this IEnumerable strings, char separator) { - if (strings == null) + if (strings == null) return String.Empty; var sb = new StringBuilder(); - foreach (var s in strings) + foreach (var s in strings) sb.Append(s).Append(separator); return sb.ToString().TrimEnd(separator); } @@ -33,7 +33,7 @@ public static string Fix(this string bbox) return arr.Join(','); } - private static void Flip(IList arr, int first, int second) + private static void Flip(IList arr, int first, int second) { var temp = arr[first]; arr[first] = arr[second]; diff --git a/Examples/SharpMap.Demo.Wms/Helpers/ProjHelper.cs b/Examples/SharpMap.Demo.Wms/Helpers/ProjHelper.cs index 328b656d..5e252526 100644 --- a/Examples/SharpMap.Demo.Wms/Helpers/ProjHelper.cs +++ b/Examples/SharpMap.Demo.Wms/Helpers/ProjHelper.cs @@ -1,17 +1,13 @@ namespace SharpMap.Demo.Wms.Helpers { - using System; - using System.Collections.Generic; - using System.Drawing; - using System.Drawing.Drawing2D; - - using GeoAPI.CoordinateSystems; using ProjNet.CoordinateSystems; - using GeoAPI.CoordinateSystems.Transformations; using ProjNet.CoordinateSystems.Transformations; - using SharpMap.Layers; using SharpMap.Rendering; + using System; + using System.Collections.Generic; + using System.Drawing; + using System.Drawing.Drawing2D; public static class ProjHelper { @@ -19,7 +15,7 @@ public static ICoordinateTransformation LatLonToGoogle() { CoordinateSystemFactory csFac = new CoordinateSystemFactory(); CoordinateTransformationFactory ctFac = new CoordinateTransformationFactory(); - IGeographicCoordinateSystem sourceCs = csFac.CreateGeographicCoordinateSystem( + GeographicCoordinateSystem sourceCs = csFac.CreateGeographicCoordinateSystem( "WGS 84", AngularUnit.Degrees, HorizontalDatum.WGS84, @@ -38,7 +34,7 @@ public static ICoordinateTransformation LatLonToGoogle() new ProjectionParameter("false_northing", 0.0) }; IProjection projection = csFac.CreateProjection("Google Mercator", "mercator_1sp", parameters); - IProjectedCoordinateSystem targetCs = csFac.CreateProjectedCoordinateSystem( + ProjectedCoordinateSystem targetCs = csFac.CreateProjectedCoordinateSystem( "Google Mercator", sourceCs, projection, @@ -56,14 +52,14 @@ public static LabelLayer CreateLabelLayer(VectorLayer src, string column) { string name = String.Format("{0}:Labels", src.LayerName); LabelLayer layer = new LabelLayer(name) - { - DataSource = src.DataSource, - LabelColumn = column, - LabelFilter = LabelCollisionDetection.ThoroughCollisionDetection, - MultipartGeometryBehaviour = LabelLayer.MultipartGeometryBehaviourEnum.CommonCenter, - MaxVisible = src.MaxVisible, - MinVisible = src.MinVisible, - Style = + { + DataSource = src.DataSource, + LabelColumn = column, + LabelFilter = LabelCollisionDetection.ThoroughCollisionDetection, + MultipartGeometryBehaviour = LabelLayer.MultipartGeometryBehaviourEnum.CommonCenter, + MaxVisible = src.MaxVisible, + MinVisible = src.MinVisible, + Style = { CollisionDetection = true, CollisionBuffer = new SizeF(10F, 10F), @@ -71,10 +67,10 @@ public static LabelLayer CreateLabelLayer(VectorLayer src, string column) Font = new Font(FontFamily.GenericSansSerif, 12), Halo = new Pen(Color.White, 2) }, - SmoothingMode = SmoothingMode.HighQuality, - CoordinateTransformation = src.CoordinateTransformation - }; + SmoothingMode = SmoothingMode.HighQuality, + CoordinateTransformation = src.CoordinateTransformation + }; return layer; } } -} \ No newline at end of file +} diff --git a/Examples/SharpMap.Demo.Wms/Helpers/ShapefileHelper.cs b/Examples/SharpMap.Demo.Wms/Helpers/ShapefileHelper.cs index 47cd69d9..2a281857 100644 --- a/Examples/SharpMap.Demo.Wms/Helpers/ShapefileHelper.cs +++ b/Examples/SharpMap.Demo.Wms/Helpers/ShapefileHelper.cs @@ -1,7 +1,10 @@ -using ProjNet.CoordinateSystems; - namespace SharpMap.Demo.Wms.Helpers { + using ProjNet.CoordinateSystems; + using SharpMap.Data.Providers; + using SharpMap.Demo.Wms.Models; + using SharpMap.Layers; + using SharpMap.Styles; using System; using System.Collections.Generic; using System.Drawing; @@ -9,13 +12,6 @@ namespace SharpMap.Demo.Wms.Helpers using System.IO; using System.Web; - using GeoAPI.CoordinateSystems.Transformations; - - using SharpMap.Data.Providers; - using SharpMap.Demo.Wms.Models; - using SharpMap.Layers; - using SharpMap.Styles; - public static class ShapefileHelper { private static readonly IDictionary Nyc; diff --git a/Examples/SharpMap.Demo.Wms/Models/DemoItem.cs b/Examples/SharpMap.Demo.Wms/Models/DemoItem.cs index acce6e14..4597c58d 100644 --- a/Examples/SharpMap.Demo.Wms/Models/DemoItem.cs +++ b/Examples/SharpMap.Demo.Wms/Models/DemoItem.cs @@ -6,9 +6,9 @@ public class DemoItem : IEquatable { public DemoItem(string name, string url) { - if (name == null) + if (name == null) throw new ArgumentNullException("name"); - if (url == null) + if (url == null) throw new ArgumentNullException("url"); this.Name = name; this.Url = url; @@ -25,20 +25,20 @@ public override string ToString() public bool Equals(DemoItem other) { - if (ReferenceEquals(null, other)) + if (ReferenceEquals(null, other)) return false; - if (ReferenceEquals(this, other)) + if (ReferenceEquals(this, other)) return true; return Equals(other.Name, this.Name) && Equals(other.Url, this.Url); } public override bool Equals(object obj) { - if (ReferenceEquals(null, obj)) + if (ReferenceEquals(null, obj)) return false; - if (ReferenceEquals(this, obj)) + if (ReferenceEquals(this, obj)) return true; - if (obj.GetType() != typeof(DemoItem)) + if (obj.GetType() != typeof(DemoItem)) return false; return this.Equals((DemoItem)obj); } @@ -49,6 +49,6 @@ public override int GetHashCode() { return (this.Name.GetHashCode() * 397) ^ this.Url.GetHashCode(); } - } + } } } \ No newline at end of file diff --git a/Examples/SharpMap.Demo.Wms/Plugins/GraphicsPathBuilder.cs b/Examples/SharpMap.Demo.Wms/Plugins/GraphicsPathBuilder.cs index 6f29674f..68312562 100644 --- a/Examples/SharpMap.Demo.Wms/Plugins/GraphicsPathBuilder.cs +++ b/Examples/SharpMap.Demo.Wms/Plugins/GraphicsPathBuilder.cs @@ -1,13 +1,13 @@ // code adapted from: https://github.com/awcoats/mapstache namespace Mapstache { + using NetTopologySuite.Geometries; using System; using System.Collections.Generic; using System.Drawing; using System.Drawing.Drawing2D; using System.Linq; - - using GeoAPI.Geometries; + using Point = System.Drawing.Point; public class GraphicsPathBuilder { @@ -22,36 +22,36 @@ public GraphicsPathBuilder(RectangleF bounds, Size size) if (size.IsEmpty) throw new ArgumentException("Size is empty.", "size"); - this.metersToPixel = bounds.Width/size.Width; - this.topLeft = new Point((int) bounds.Left, (int) (bounds.Top)); + this.metersToPixel = bounds.Width / size.Width; + this.topLeft = new Point((int)bounds.Left, (int)(bounds.Top)); this.size = size; } - public GraphicsPath Build(IGeometry geometry) + public GraphicsPath Build(Geometry geometry) { GraphicsPath graphicsPath = new GraphicsPath { FillMode = FillMode.Alternate }; string geometryType = geometry.GeometryType; switch (geometryType) { case "Polygon": - this.AddPolygon((IPolygon)geometry, graphicsPath); + this.AddPolygon((Polygon)geometry, graphicsPath); break; case "MultiPolygon": - this.AddMultiPolygon((IMultiPolygon)geometry, graphicsPath); + this.AddMultiPolygon((MultiPolygon)geometry, graphicsPath); break; case "GeometryCollection": for (int i = 0; i < geometry.NumGeometries; i++) { - IGeometry geom = geometry.GetGeometryN(i + 1); + Geometry geom = geometry.GetGeometryN(i + 1); switch (geom.GeometryType) { case "Polygon": - this.AddPolygon((IPolygon)geom, graphicsPath); + this.AddPolygon((Polygon)geom, graphicsPath); break; case "MultiPolygon": - this.AddMultiPolygon((IMultiPolygon)geom, graphicsPath); + this.AddMultiPolygon((MultiPolygon)geom, graphicsPath); break; } } @@ -64,32 +64,32 @@ public GraphicsPath Build(IGeometry geometry) return graphicsPath; } - private void AddMultiPolygon(IMultiPolygon geometry, GraphicsPath graphicsPath) + private void AddMultiPolygon(MultiPolygon geometry, GraphicsPath graphicsPath) { if (geometry == null) throw new ArgumentNullException("geometry"); foreach (var geom in geometry.Geometries) - this.AddPolygon((IPolygon)geom, graphicsPath); + this.AddPolygon((Polygon)geom, graphicsPath); } - private void AddPolygon(IPolygon polygon, GraphicsPath graphicsPath) + private void AddPolygon(Polygon polygon, GraphicsPath graphicsPath) { if (polygon == null) throw new ArgumentNullException("polygon"); - ILineString exterior = polygon.ExteriorRing; + LineString exterior = polygon.ExteriorRing; IEnumerable coords = this.GetCoords(exterior); graphicsPath.AddPolygon(coords.ToArray()); - foreach (ILineString ring in polygon.InteriorRings) + foreach (LineString ring in polygon.InteriorRings) { coords = this.GetCoords(ring); graphicsPath.AddPolygon(coords.ToArray()); } } - private IEnumerable GetCoords(IGeometry lineString) + private IEnumerable GetCoords(Geometry lineString) { if (lineString == null) throw new ArgumentNullException("lineString"); @@ -102,8 +102,8 @@ private IEnumerable GetCoords(IGeometry lineString) private PointF GetPixel(PointF ll) { Point meters = SphericalMercator.FromLonLat(ll); - float x = (meters.X - this.topLeft.X)/this.metersToPixel; - float y = (meters.Y - this.topLeft.Y)/this.metersToPixel; + float x = (meters.X - this.topLeft.X) / this.metersToPixel; + float y = (meters.Y - this.topLeft.Y) / this.metersToPixel; y = this.size.Height - y; return new PointF(x, y); } diff --git a/Examples/SharpMap.Demo.Wms/Plugins/Utf8Grid.cs b/Examples/SharpMap.Demo.Wms/Plugins/Utf8Grid.cs index c1d8c4ed..34b8e9aa 100644 --- a/Examples/SharpMap.Demo.Wms/Plugins/Utf8Grid.cs +++ b/Examples/SharpMap.Demo.Wms/Plugins/Utf8Grid.cs @@ -1,6 +1,7 @@ // code adapted from: https://github.com/awcoats/mapstache namespace Mapstache { + using NetTopologySuite.Geometries; using System; using System.Collections.Generic; using System.Drawing; @@ -9,8 +10,7 @@ namespace Mapstache using System.Globalization; using System.Runtime.InteropServices; using System.Text; - - using GeoAPI.Geometries; + using Point = System.Drawing.Point; public class Utf8GridResults { @@ -29,11 +29,11 @@ public Utf8GridResults() } public class Utf8Grid : IDisposable - { + { private Bitmap bitmap; private Graphics graphics; - private readonly Utf8GridResults results; + private readonly Utf8GridResults results; private readonly GraphicsPathBuilder graphicsPathBuilder; public Utf8Grid(int utfGridResolution, int tileX, int tileY, int zoom) @@ -42,7 +42,7 @@ public Utf8Grid(int utfGridResolution, int tileX, int tileY, int zoom) this.bitmap = new Bitmap(size.Width, size.Height, PixelFormat.Format32bppRgb); this.graphics = Graphics.FromImage(this.bitmap); RectangleF bbox = this.GetBoundingBoxInLatLngWithMargin(tileX, tileY, zoom); - this.graphicsPathBuilder = new GraphicsPathBuilder(SphericalMercator.FromLonLat(bbox), size); + this.graphicsPathBuilder = new GraphicsPathBuilder(SphericalMercator.FromLonLat(bbox), size); this.results = new Utf8GridResults(); } @@ -53,7 +53,7 @@ public RectangleF GetBoundingBoxInLatLngWithMargin(int tileX, int tileY, int zoo return RectangleF.FromLTRB(lonlat1.X, lonlat2.Y, lonlat2.X, lonlat1.Y); } - public void FillPolygon(IGeometry geometry, int i, object data = null) + public void FillPolygon(Geometry geometry, int i, object data = null) { using (GraphicsPath gp = this.graphicsPathBuilder.Build(geometry)) using (Brush brush = CreateBrush(i)) @@ -65,7 +65,7 @@ public void FillPolygon(IGeometry geometry, int i, object data = null) public Utf8GridResults CreateUtfGridJson() { BitmapData bitmapData = this.bitmap.LockBits( - new Rectangle(0, 0, this.bitmap.Width, this.bitmap.Height), + new Rectangle(0, 0, this.bitmap.Width, this.bitmap.Height), ImageLockMode.ReadOnly, this.bitmap.PixelFormat); IntPtr ptr = bitmapData.Scan0; int bytes = Math.Abs(bitmapData.Stride) * this.bitmap.Height; diff --git a/Examples/SharpMap.Demo.Wms/Scripts/leaflet.js b/Examples/SharpMap.Demo.Wms/Scripts/leaflet.js index fb79a997..8f5765b3 100644 --- a/Examples/SharpMap.Demo.Wms/Scripts/leaflet.js +++ b/Examples/SharpMap.Demo.Wms/Scripts/leaflet.js @@ -7616,4 +7616,4 @@ L.Map.include({ -}(this)); \ No newline at end of file +}(this)); diff --git a/Examples/SharpMap.Demo.Wms/Scripts/script_buildings.js b/Examples/SharpMap.Demo.Wms/Scripts/script_buildings.js index 732c770d..bd0f5dd1 100644 --- a/Examples/SharpMap.Demo.Wms/Scripts/script_buildings.js +++ b/Examples/SharpMap.Demo.Wms/Scripts/script_buildings.js @@ -1,11 +1,10 @@ $(document).ready(function () { - var map = new L.Map('map'), zoom = 16, cloudmade, buildings; - cloudmade = new L.TileLayer(['http://{s}tile.cloudmade.com', '/1a235b638b614b458deeb77c7dae4f80', '/998/256/{z}/{x}/{y}.png'].join(''), { - maxZoom: 18, - subdomains: ['a.', 'b.', 'c.', ''] - }); - map.addLayer(cloudmade); - + var map = new L.Map('map'), zoom = 16; + var osm = new L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { + attribution: '© OpenStreetMap contributors' + }) + map.addLayer(osm); + $('#link1').click(function () { map.setView(new L.LatLng(52.52111, 13.40988), zoom); }).click(); @@ -16,6 +15,6 @@ map.setView(new L.LatLng(52.50983, 13.37455), zoom); }); - buildings = new OSMBuildings(map); + var buildings = new OSMBuildings(map); buildings.loadData('/buildings/getdata?w={w}&n={n}&e={e}&s={s}&z={z}'); -}); \ No newline at end of file +}); diff --git a/Examples/SharpMap.Demo.Wms/Scripts/script_editor.js b/Examples/SharpMap.Demo.Wms/Scripts/script_editor.js index a106154c..a2002875 100644 --- a/Examples/SharpMap.Demo.Wms/Scripts/script_editor.js +++ b/Examples/SharpMap.Demo.Wms/Scripts/script_editor.js @@ -63,4 +63,4 @@ editor.startEditMode(); }; init(); -}); \ No newline at end of file +}); diff --git a/Examples/SharpMap.Demo.Wms/Scripts/script_geojs.js b/Examples/SharpMap.Demo.Wms/Scripts/script_geojs.js index 7a231337..50e9dcb8 100644 --- a/Examples/SharpMap.Demo.Wms/Scripts/script_geojs.js +++ b/Examples/SharpMap.Demo.Wms/Scripts/script_geojs.js @@ -12,7 +12,7 @@ $(document).ready(function () { options = { wms: 'WMS', controls: [], - projection: 'EPSG:900913', + projection: 'EPSG:3857', displayProjection: 'EPSG:4326', format: 'text/json' }; diff --git a/Examples/SharpMap.Demo.Wms/Scripts/script_ll.js b/Examples/SharpMap.Demo.Wms/Scripts/script_ll.js index ba935259..508839c1 100644 --- a/Examples/SharpMap.Demo.Wms/Scripts/script_ll.js +++ b/Examples/SharpMap.Demo.Wms/Scripts/script_ll.js @@ -3,9 +3,8 @@ map = new L.Map('map'), center, url, cloudmade; map.on('load', function (e) { - var bounds, jsurl, options, layer; - bounds = e.target.getBounds(); - jsurl = [ + var bounds = e.target.getBounds(); + var jsurl = [ '/json.ashx?MAP_TYPE=DEF&BBOX=', bounds._southWest.lat, ',', bounds._southWest.lng, ',', @@ -13,7 +12,7 @@ bounds._northEast.lng ].join(''); - options = { + var options = { radius: 8, fillColor: "#FF7800", color: "#000000", @@ -21,7 +20,7 @@ opacity: 1, fillOpacity: 0.8 }; - layer = new L.GeoJSON(null, { + var layer = new L.GeoJSON(null, { pointToLayer: function (f) { var raw = f.geometry.coordinates; var ll = new L.LatLng(raw[1], raw[0]); @@ -50,15 +49,11 @@ }); }); - center = new L.LatLng(lat, lon); + var center = new L.LatLng(lat, lon); map.setView(center, zoom); - url = ['http://{s}tile.cloudmade.com', '/1a235b638b614b458deeb77c7dae4f80', '/998/256/{z}/{x}/{y}.png'].join(''); - cloudmade = new L.TileLayer(url, { - maxZoom: 18, - subdomains: ['a.', 'b.', 'c.', ''] - }); - map.addLayer(cloudmade); - - -}); \ No newline at end of file + var osm = new L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { + attribution: '© OpenStreetMap contributors' + }) + map.addLayer(osm); +}); diff --git a/Examples/SharpMap.Demo.Wms/Scripts/script_tc.js b/Examples/SharpMap.Demo.Wms/Scripts/script_tc.js index 02ab3bdd..15ce3a79 100644 --- a/Examples/SharpMap.Demo.Wms/Scripts/script_tc.js +++ b/Examples/SharpMap.Demo.Wms/Scripts/script_tc.js @@ -4,12 +4,10 @@ var zoom = 10; var map = new L.Map('map'); - var cmurl = ['http://{s}tile.cloudmade.com', '/1a235b638b614b458deeb77c7dae4f80', '/997/256/{z}/{x}/{y}.png'].join(''); - var cloudmade = new L.TileLayer(cmurl, { - maxZoom: 18, - subdomains: ['a.', 'b.', 'c.', ''] - }); - map.addLayer(cloudmade); + var osm = new L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { + attribution: '© OpenStreetMap contributors' + }) + map.addLayer(osm); var tile = new L.TileLayer.TileJSON({ debug: false, @@ -60,4 +58,4 @@ var center = new L.LatLng(lat, lon); map.setView(center, zoom); -}); \ No newline at end of file +}); diff --git a/Examples/SharpMap.Demo.Wms/Scripts/script_utfgrid.js b/Examples/SharpMap.Demo.Wms/Scripts/script_utfgrid.js index 5b2068a3..646930a6 100644 --- a/Examples/SharpMap.Demo.Wms/Scripts/script_utfgrid.js +++ b/Examples/SharpMap.Demo.Wms/Scripts/script_utfgrid.js @@ -83,4 +83,4 @@ $(document).ready(function () { map.setCenter(center, zoom); }; init(); -}); \ No newline at end of file +}); diff --git a/Examples/SharpMap.Demo.Wms/SharpMap.Demo.Wms.csproj b/Examples/SharpMap.Demo.Wms/SharpMap.Demo.Wms.csproj index 69545110..2b6863a8 100644 --- a/Examples/SharpMap.Demo.Wms/SharpMap.Demo.Wms.csproj +++ b/Examples/SharpMap.Demo.Wms/SharpMap.Demo.Wms.csproj @@ -58,33 +58,40 @@ ..\..\packages\Common.Logging.Core.3.4.1\lib\net40\Common.Logging.Core.dll - - ..\..\packages\GeoAPI.Core.1.7.5\lib\net40-client\GeoAPI.dll - - - ..\..\packages\GeoAPI.CoordinateSystems.1.7.5\lib\net40-client\GeoAPI.CoordinateSystems.dll - - - ..\..\packages\NetTopologySuite.Core.1.15.3\lib\net45\NetTopologySuite.dll + + ..\..\packages\Microsoft.Web.Infrastructure.2.0.0\lib\net40\Microsoft.Web.Infrastructure.dll - - ..\..\packages\NetTopologySuite.CoordinateSystems.1.15.3\lib\net45\NetTopologySuite.CoordinateSystems.dll + + ..\..\packages\NetTopologySuite.2.5.0\lib\netstandard2.0\NetTopologySuite.dll - - ..\..\packages\Newtonsoft.Json.11.0.2\lib\net45\Newtonsoft.Json.dll + + ..\..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll - - ..\..\packages\ProjNET4GeoAPI.1.4.1\lib\net40-client\ProjNET.dll + + ..\..\packages\ProjNET.2.0.0\lib\netstandard2.0\ProjNET.dll + + ..\..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll + - - ..\..\packages\System.Data.SQLite.Core.1.0.112.0\lib\net46\System.Data.SQLite.dll + + ..\..\packages\Stub.System.Data.SQLite.Core.NetFramework.1.0.116.0\lib\net46\System.Data.SQLite.dll + + + ..\..\packages\System.Drawing.Common.6.0.0\lib\net461\System.Drawing.Common.dll - - ..\..\packages\System.Drawing.Common.4.6.0\lib\net461\System.Drawing.Common.dll + + ..\..\packages\System.Memory.4.5.5\lib\net461\System.Memory.dll + + + + ..\..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll + + + ..\..\packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll @@ -95,34 +102,30 @@ - ..\..\packages\Microsoft.AspNet.WebPages.3.2.7\lib\net45\System.Web.Helpers.dll + ..\..\packages\Microsoft.AspNet.WebPages.3.2.9\lib\net45\System.Web.Helpers.dll - - ..\..\packages\Microsoft.AspNet.Mvc.5.2.7\lib\net45\System.Web.Mvc.dll + + ..\..\packages\Microsoft.AspNet.Mvc.5.2.9\lib\net45\System.Web.Mvc.dll - ..\..\packages\Microsoft.AspNet.Razor.3.2.7\lib\net45\System.Web.Razor.dll + ..\..\packages\Microsoft.AspNet.Razor.3.2.9\lib\net45\System.Web.Razor.dll - ..\..\packages\Microsoft.AspNet.WebPages.3.2.7\lib\net45\System.Web.WebPages.dll + ..\..\packages\Microsoft.AspNet.WebPages.3.2.9\lib\net45\System.Web.WebPages.dll - ..\..\packages\Microsoft.AspNet.WebPages.3.2.7\lib\net45\System.Web.WebPages.Deployment.dll + ..\..\packages\Microsoft.AspNet.WebPages.3.2.9\lib\net45\System.Web.WebPages.Deployment.dll - ..\..\packages\Microsoft.AspNet.WebPages.3.2.7\lib\net45\System.Web.WebPages.Razor.dll + ..\..\packages\Microsoft.AspNet.WebPages.3.2.9\lib\net45\System.Web.WebPages.Razor.dll - - ..\..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll - True - @@ -758,11 +761,11 @@ - + - Dieses Projekt verweist auf mindestens ein NuGet-Paket, das auf diesem Computer fehlt. Verwenden Sie die Wiederherstellung von NuGet-Paketen, um die fehlenden Dateien herunterzuladen. Weitere Informationen finden Sie unter "http://go.microsoft.com/fwlink/?LinkID=322105". Die fehlende Datei ist "{0}". + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + \ No newline at end of file diff --git a/Examples/SharpMap.Demo.Wms/Web.config b/Examples/SharpMap.Demo.Wms/Web.config index f1efc51d..197989a6 100644 --- a/Examples/SharpMap.Demo.Wms/Web.config +++ b/Examples/SharpMap.Demo.Wms/Web.config @@ -1,13 +1,11 @@ - + - + - - + + /// A GraphicsPath - public static GraphicsPath LineStringToPath(ILineString lineString, MapViewport map/*, bool useClipping*/) + public static GraphicsPath LineStringToPath(LineString lineString, MapViewport map/*, bool useClipping*/) { var gp = new GraphicsPath(FillMode.Alternate); - gp.AddLines(lineString.TransformToImage(map)); + gp.AddLines(lineString.TransformToImage(map)); return gp; } } diff --git a/SharpMap/Layers/Layer.cs b/SharpMap/Layers/Layer.cs index de842a52..03f82983 100644 --- a/SharpMap/Layers/Layer.cs +++ b/SharpMap/Layers/Layer.cs @@ -15,15 +15,14 @@ // along with SharpMap; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -using System; -using System.Drawing; -using GeoAPI.CoordinateSystems.Transformations; -using GeoAPI.Geometries; -using NetTopologySuite.Geometries.Utilities; +using NetTopologySuite.CoordinateSystems.Transformations; +using NetTopologySuite.Geometries; +using ProjNet.CoordinateSystems.Transformations; using SharpMap.Base; using SharpMap.Rendering; using SharpMap.Styles; -using SharpMap.Utilities; +using System; +using System.Drawing; namespace SharpMap.Layers { @@ -101,8 +100,8 @@ protected virtual void OnLayerNameChanged(EventArgs eventArgs) private ICoordinateTransformation _coordinateTransform; private ICoordinateTransformation _reverseCoordinateTransform; - private IGeometryFactory _sourceFactory; - private IGeometryFactory _targetFactory; + private GeometryFactory _sourceFactory; + private GeometryFactory _targetFactory; private string _layerName; private string _layerTitle; @@ -111,13 +110,13 @@ protected virtual void OnLayerNameChanged(EventArgs eventArgs) private int? _targetSrid; [field: NonSerialized] private bool _shouldNotResetCt; - + /// /// The area of the map that was covered by this layer /// [field: NonSerialized] protected RectangleF CanvasArea = RectangleF.Empty; - + // ReSharper disable PublicConstructorInAbstractClass /// /// Creates an instance of this class using the given Style @@ -150,7 +149,7 @@ protected override void ReleaseManagedResources() } /// - /// Gets or sets the applied + /// Gets or sets the applied /// to this vectorlayer prior to rendering /// public virtual ICoordinateTransformation CoordinateTransformation @@ -185,7 +184,7 @@ public virtual ICoordinateTransformation CoordinateTransformation } else { - _sourceFactory = GeoAPI.GeometryServiceProvider.Instance.CreateGeometryFactory(SRID); + _sourceFactory = NetTopologySuite.NtsGeometryServices.Instance.CreateGeometryFactory(SRID); // causes targetFactory to be cleared TargetSRID = 0; } @@ -230,15 +229,15 @@ protected virtual void OnCoordinateTransformationChanged(EventArgs e) /// /// Gets the geometry factory to create source geometries /// - protected internal IGeometryFactory SourceFactory { get { return _sourceFactory ?? (_sourceFactory = GeoAPI.GeometryServiceProvider.Instance.CreateGeometryFactory(SRID)); } } + protected internal GeometryFactory SourceFactory { get { return _sourceFactory ?? (_sourceFactory = NetTopologySuite.NtsGeometryServices.Instance.CreateGeometryFactory(SRID)); } } /// /// Gets the geometry factory to create target geometries /// - protected internal IGeometryFactory TargetFactory { get { return _targetFactory ?? _sourceFactory; } } + protected internal GeometryFactory TargetFactory { get { return _targetFactory ?? _sourceFactory; } } /// - /// Certain Transformations cannot be inverted in ProjNet, in those cases use this property to set the reverse (of CoordinateTransformation) to fetch data from Datasource + /// Certain Transformations cannot be inverted in ProjNet, in those cases use this property to set the reverse (of CoordinateTransformation) to fetch data from Datasource /// /// If your CoordinateTransformation can be inverted you can leave this property to null /// @@ -302,7 +301,7 @@ public virtual int SRID { _srid = value; - _sourceFactory = GeoAPI.GeometryServiceProvider.Instance.CreateGeometryFactory(value); + _sourceFactory = NetTopologySuite.NtsGeometryServices.Instance.CreateGeometryFactory(value); if (!_shouldNotResetCt) _coordinateTransform = _reverseCoordinateTransform = null; @@ -327,7 +326,7 @@ public virtual int TargetSRID else if (_targetSrid != value) { _targetSrid = value; - _targetFactory = GeoAPI.GeometryServiceProvider.Instance.CreateGeometryFactory(value); + _targetFactory = NetTopologySuite.NtsGeometryServices.Instance.CreateGeometryFactory(value); } if (!_shouldNotResetCt) _coordinateTransform = _reverseCoordinateTransform = null; @@ -367,7 +366,7 @@ public virtual void Render(Graphics g, MapViewport map) Rectangle ILayerEx.Render(Graphics g, MapViewport map) { Render(g, map, out var canvasArea); - return canvasArea; + return canvasArea; } private bool _renderCalled; @@ -381,12 +380,12 @@ protected virtual void Render(Graphics g, MapViewport mvp, out Rectangle affecte { if (_renderCalled) return; - + _renderCalled = true; Render(g, mvp); _renderCalled = false; - var mapRect = new Rectangle(new Point(0, 0), mvp.Size); + var mapRect = new Rectangle(new System.Drawing.Point(0, 0), mvp.Size); if (CanvasArea.IsEmpty) { affectedArea = mapRect; @@ -400,7 +399,7 @@ protected virtual void Render(Graphics g, MapViewport mvp, out Rectangle affecte CanvasArea = RectangleF.Empty; } - + OnLayerRendered(g); } @@ -423,16 +422,16 @@ protected static Rectangle ToGraphicsCanvas(RectangleF area, System.Drawing.Draw // This is the area of the graphics canvas that needs to be refreshed when invalidating the image. var affectedArea = area.ToRectangle(); -// // proof of concept: draw affected area to screen aligned with graphics canvas -// using (var orig = g.Transform.Clone()) -// { -// var areaToBeRendered = affectedArea; -// areaToBeRendered.Intersect(mapRect); -// g.ResetTransform(); -// g.DrawRectangle(new Pen(Color.Red, 3f) {Alignment = System.Drawing.Drawing2D.PenAlignment.Inset}, -// areaToBeRendered); -// g.Transform = orig; -// } + // // proof of concept: draw affected area to screen aligned with graphics canvas + // using (var orig = g.Transform.Clone()) + // { + // var areaToBeRendered = affectedArea; + // areaToBeRendered.Intersect(mapRect); + // g.ResetTransform(); + // g.DrawRectangle(new Pen(Color.Red, 3f) {Alignment = System.Drawing.Drawing2D.PenAlignment.Inset}, + // areaToBeRendered); + // g.Transform = orig; + // } // allow for bleed and/or minor labelling misdemeanours affectedArea.Inflate(1, 1); @@ -583,7 +582,7 @@ public void RaiseRenderRequired() /// Utility function to transform given envelope using a specific transformation /// /// The source envelope - /// The to use. + /// The to use. /// The target envelope protected virtual Envelope ToTarget(Envelope envelope, ICoordinateTransformation coordinateTransformation) { @@ -633,7 +632,7 @@ protected virtual Envelope ToSource(Envelope envelope) /// /// A geometry /// The transformed geometry - protected virtual IGeometry ToTarget(IGeometry geometry) + protected virtual Geometry ToTarget(Geometry geometry) { if (geometry.SRID == TargetSRID) return geometry; @@ -651,7 +650,7 @@ protected virtual IGeometry ToTarget(IGeometry geometry) /// /// A geometry /// The transformed geometry - protected virtual IGeometry ToSource(IGeometry geometry) + protected virtual Geometry ToSource(Geometry geometry) { if (geometry.SRID == SRID) return geometry; diff --git a/SharpMap/Layers/LayerCollection.cs b/SharpMap/Layers/LayerCollection.cs index 9d889a88..e30f8f7d 100644 --- a/SharpMap/Layers/LayerCollection.cs +++ b/SharpMap/Layers/LayerCollection.cs @@ -73,7 +73,7 @@ public LayerCollection Clone() { var cloneable = lay as ICloneable; if (cloneable != null) - newColl.Add((ILayer) cloneable.Clone()); + newColl.Add((ILayer)cloneable.Clone()); else newColl.Add(lay); } diff --git a/SharpMap/Layers/LayerGroup.cs b/SharpMap/Layers/LayerGroup.cs index e5a24ce3..b29d29d2 100644 --- a/SharpMap/Layers/LayerGroup.cs +++ b/SharpMap/Layers/LayerGroup.cs @@ -15,15 +15,15 @@ // along with SharpMap; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +using NetTopologySuite.Geometries; +using ProjNet.CoordinateSystems.Transformations; +using SharpMap.Data; +using SharpMap.Styles; using System; using System.Collections; using System.Collections.ObjectModel; using System.Drawing; using System.Linq; -using SharpMap.Data; -using GeoAPI.Geometries; -using SharpMap.Styles; -using GeoAPI.CoordinateSystems.Transformations; namespace SharpMap.Layers { @@ -121,13 +121,13 @@ public override Envelope Envelope var layerEnvelope = layers[i].Envelope; if (layerEnvelope != null) { - if(bbox == null) + if (bbox == null) bbox = new Envelope(layerEnvelope); else bbox.ExpandToInclude(layerEnvelope); } } - + return bbox; } } @@ -141,7 +141,7 @@ public override Envelope Envelope public virtual bool SkipTransformationPropagation { get; set; } /// - /// Gets or sets the applied + /// Gets or sets the applied /// to this vectorlayer prior to rendering /// @@ -163,7 +163,7 @@ public override ICoordinateTransformation CoordinateTransformation } /// - /// Certain Transformations cannot be inverted in ProjNet, in those cases use this property to set the reverse (of CoordinateTransformation) to fetch data from Datasource + /// Certain Transformations cannot be inverted in ProjNet, in those cases use this property to set the reverse (of CoordinateTransformation) to fetch data from Datasource /// /// If your CoordinateTransformation can be inverted you can leave this property to null /// @@ -236,7 +236,7 @@ protected override void ReleaseManagedResources() var layers = GetSnapshot(); foreach (var layer in layers.OfType().Where(layer => layer != null)) layer.Dispose(); - + Layers.Clear(); base.ReleaseManagedResources(); } @@ -263,8 +263,8 @@ public virtual ILayer GetLayerByName(string name) public override void Render(Graphics g, MapViewport map) { var layers = GetSnapshot(); - var compare = VisibilityUnits == VisibilityUnits.ZoomLevel - ? map.Zoom + var compare = VisibilityUnits == VisibilityUnits.ZoomLevel + ? map.Zoom : map.GetMapScale((int)g.DpiX); foreach (var layer in layers) @@ -275,7 +275,7 @@ public override void Render(Graphics g, MapViewport map) } } - #region Implementation of ICanQueryLayer + #region Implementation of ICanQueryLayer /// /// Returns the data associated with all the geometries that are intersected by 'geom' @@ -297,7 +297,7 @@ public virtual void ExecuteIntersectionQuery(Envelope box, FeatureDataSet ds) /// /// Geometry to intersect with /// FeatureDataSet to fill data into - public virtual void ExecuteIntersectionQuery(IGeometry geometry, FeatureDataSet ds) + public virtual void ExecuteIntersectionQuery(Geometry geometry, FeatureDataSet ds) { var layers = GetSnapshot(); @@ -307,7 +307,7 @@ public virtual void ExecuteIntersectionQuery(IGeometry geometry, FeatureDataSet } } - #endregion + #endregion /// /// Create an empty new LayerGroup instance. @@ -350,7 +350,7 @@ public virtual object Clone() { var cloneable = layer as ICloneable; if (cloneable != null) - clonedGroup.Layers.Add((ILayer) cloneable.Clone()); + clonedGroup.Layers.Add((ILayer)cloneable.Clone()); else clonedGroup.Layers.Add(layer); } diff --git a/SharpMap/Layers/Symbolizer/AnyGeometryVectorLayer.cs b/SharpMap/Layers/Symbolizer/AnyGeometryVectorLayer.cs index d708c65c..b64c4e26 100644 --- a/SharpMap/Layers/Symbolizer/AnyGeometryVectorLayer.cs +++ b/SharpMap/Layers/Symbolizer/AnyGeometryVectorLayer.cs @@ -1,7 +1,7 @@ -using System; -using GeoAPI.Geometries; +using NetTopologySuite.Geometries; using SharpMap.Data.Providers; using SharpMap.Rendering.Symbolizer; +using System; namespace SharpMap.Layers.Symbolizer { @@ -9,7 +9,7 @@ namespace SharpMap.Layers.Symbolizer /// Vector layer class than can symbolize any type of geometry /// [Serializable] - public class AnyGeometryVectorLayer : BaseVectorLayer + public class AnyGeometryVectorLayer : BaseVectorLayer { /// /// Creates an instance of this class @@ -17,7 +17,7 @@ public class AnyGeometryVectorLayer : BaseVectorLayer /// The layer's name public AnyGeometryVectorLayer(string layerName) : this(layerName, null) - {} + { } /// /// Creates an instance of this class @@ -26,11 +26,11 @@ public AnyGeometryVectorLayer(string layerName) /// The layers's datasource public AnyGeometryVectorLayer(string layerName, IProvider datasource) : this(layerName, datasource, new GeometrySymbolizer - { - PointSymbolizer = new RasterPointSymbolizer(), - LineSymbolizer = new BasicLineSymbolizer(), - PolygonSymbolizer = new BasicPolygonSymbolizer() - }) + { + PointSymbolizer = new RasterPointSymbolizer(), + LineSymbolizer = new BasicLineSymbolizer(), + PolygonSymbolizer = new BasicPolygonSymbolizer() + }) { } diff --git a/SharpMap/Layers/Symbolizer/BaseVectorLayer.cs b/SharpMap/Layers/Symbolizer/BaseVectorLayer.cs index 35da8071..e6f5a85c 100644 --- a/SharpMap/Layers/Symbolizer/BaseVectorLayer.cs +++ b/SharpMap/Layers/Symbolizer/BaseVectorLayer.cs @@ -1,14 +1,14 @@ +using Common.Logging; +using NetTopologySuite.Geometries; +using SharpMap.Data; +using SharpMap.Data.Providers; +using SharpMap.Rendering.Symbolizer; using System; using System.Collections.ObjectModel; using System.Drawing; using System.Drawing.Drawing2D; using System.Runtime.CompilerServices; -using GeoAPI.Geometries; -using SharpMap.Data; -using SharpMap.Data.Providers; -using SharpMap.Rendering.Symbolizer; -using IGeometry = GeoAPI.Geometries.IGeometry; -using Common.Logging; +using Geometry = NetTopologySuite.Geometries.Geometry; namespace SharpMap.Layers.Symbolizer { @@ -18,18 +18,18 @@ namespace SharpMap.Layers.Symbolizer /// The geometry type [Serializable] public abstract class BaseVectorLayer : Layer, ICanQueryLayer - where TGeometry : class//, IGeometry + where TGeometry : class//, Geometry { #region Private fields private readonly object _dataSourceLock = new object(); private IProvider _dataSource; - private Collection _geometries; + private Collection _geometries; #endregion static readonly ILog logger = LogManager.GetLogger(typeof(BaseVectorLayer)); - + /// /// Creates an instance of this class /// @@ -95,7 +95,7 @@ public override void Render(Graphics g, MapViewport map) // Initialize Rendering OnRender(g, map); - + // Render OnRendering(g, map); @@ -227,7 +227,7 @@ public void ExecuteIntersectionQuery(Envelope box, FeatureDataSet ds) /// /// Geometry to intersect with /// FeatureDataSet to fill data into - public void ExecuteIntersectionQuery(IGeometry geometry, FeatureDataSet ds) + public void ExecuteIntersectionQuery(Geometry geometry, FeatureDataSet ds) { geometry = ToSource(geometry); diff --git a/SharpMap/Layers/Symbolizer/LinealVectorLayer.cs b/SharpMap/Layers/Symbolizer/LinealVectorLayer.cs index 0e0fa2f4..fa43be26 100644 --- a/SharpMap/Layers/Symbolizer/LinealVectorLayer.cs +++ b/SharpMap/Layers/Symbolizer/LinealVectorLayer.cs @@ -1,7 +1,7 @@ -using System; -using GeoAPI.Geometries; +using NetTopologySuite.Geometries; using SharpMap.Data.Providers; using SharpMap.Rendering.Symbolizer; +using System; namespace SharpMap.Layers.Symbolizer { @@ -9,7 +9,7 @@ namespace SharpMap.Layers.Symbolizer /// A vector layer class that can symbolize lineal geometries /// [Serializable] - public class LinealVectorLayer : BaseVectorLayer + public class LinealVectorLayer : BaseVectorLayer { /// /// Creates an instance of this class diff --git a/SharpMap/Layers/Symbolizer/PolygonalVectorLayer.cs b/SharpMap/Layers/Symbolizer/PolygonalVectorLayer.cs index 4e1a3798..5cf16311 100644 --- a/SharpMap/Layers/Symbolizer/PolygonalVectorLayer.cs +++ b/SharpMap/Layers/Symbolizer/PolygonalVectorLayer.cs @@ -1,7 +1,7 @@ -using System; -using GeoAPI.Geometries; +using NetTopologySuite.Geometries; using SharpMap.Data.Providers; using SharpMap.Rendering.Symbolizer; +using System; namespace SharpMap.Layers.Symbolizer { @@ -9,14 +9,14 @@ namespace SharpMap.Layers.Symbolizer /// A vector layer class that can symbolize polygonal geometries. /// [Serializable] - public class PolygonalVectorLayer : BaseVectorLayer + public class PolygonalVectorLayer : BaseVectorLayer { /// /// Creates an instance of this class /// /// The layers's name - public PolygonalVectorLayer(string layerName) + public PolygonalVectorLayer(string layerName) : this(layerName, null) { } diff --git a/SharpMap/Layers/Symbolizer/PuntalVectorLayer.cs b/SharpMap/Layers/Symbolizer/PuntalVectorLayer.cs index 7127c6f6..d331167c 100644 --- a/SharpMap/Layers/Symbolizer/PuntalVectorLayer.cs +++ b/SharpMap/Layers/Symbolizer/PuntalVectorLayer.cs @@ -1,7 +1,7 @@ -using System; -using GeoAPI.Geometries; +using NetTopologySuite.Geometries; using SharpMap.Data.Providers; using SharpMap.Rendering.Symbolizer; +using System; namespace SharpMap.Layers.Symbolizer { diff --git a/SharpMap/Layers/TiledWmsLayer.cs b/SharpMap/Layers/TiledWmsLayer.cs index c98144f7..b570ddc7 100644 --- a/SharpMap/Layers/TiledWmsLayer.cs +++ b/SharpMap/Layers/TiledWmsLayer.cs @@ -16,6 +16,11 @@ // along with SharpMap; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +using Common.Logging; +using NetTopologySuite.Geometries; +using SharpMap.Rendering.Exceptions; +using SharpMap.Web.Wms; +using SharpMap.Web.Wms.Tiling; using System; using System.Collections.Generic; using System.Collections.ObjectModel; @@ -26,12 +31,6 @@ using System.IO; using System.Net; using System.Text; -using GeoAPI.Geometries; -using SharpMap.Rendering.Exceptions; -using SharpMap.Utilities; -using SharpMap.Web.Wms; -using SharpMap.Web.Wms.Tiling; -using Common.Logging; namespace SharpMap.Layers { @@ -51,10 +50,10 @@ namespace SharpMap.Layers /// TiledWmsLayer tiledWmsLayer = new TiledWmsLayer("Metacarta", url); /// tiledWmsLayer.TileSetsActive.Add(tiledWmsLayer.TileSets["satellite"].Name); /// map.Layers.Add(tiledWmsLayer); - /// map.ZoomToBox(new GeoAPI.Geometries.Envelope(-180.0, 180.0, -90.0, 90.0)); + /// map.ZoomToBox(new NetTopologySuite.Geometries.Envelope(-180.0, 180.0, -90.0, 90.0)); /// /// - [Obsolete("use TileLayer instead") ] + [Obsolete("use TileLayer instead")] public class TiledWmsLayer : Layer, ILayer { @@ -258,13 +257,13 @@ public override void Render(Graphics g, MapViewport map) PointF destMin = map.WorldToImage(tileExtent.Min()); PointF destMax = map.WorldToImage(tileExtent.Max()); - double minX = (int) Math.Round(destMin.X); - double minY = (int) Math.Round(destMax.Y); - double maxX = (int) Math.Round(destMax.X); - double maxY = (int) Math.Round(destMin.Y); + double minX = (int)Math.Round(destMin.X); + double minY = (int)Math.Round(destMax.Y); + double maxX = (int)Math.Round(destMax.X); + double maxY = (int)Math.Round(destMin.Y); g.DrawImage(bitmap, - new Rectangle((int) minX, (int) minY, (int) (maxX - minX), (int) (maxY - minY)), + new Rectangle((int)minX, (int)minY, (int)(maxX - minX), (int)(maxY - minY)), 0, 0, tileSet.Width, tileSet.Height, GraphicsUnit.Pixel, _ImageAttributes); } @@ -286,7 +285,7 @@ public override void Render(Graphics g, MapViewport map) /// Bounding box corresponding to the extent of the features in the layer public override Envelope Envelope { - get + get { return _WmsClient.Layer.LatLonBoundingBox; //TODO: no box is allowed in capabilities so check for it } @@ -336,7 +335,7 @@ private string GetRequestUrl(Envelope box, TileSet tileSet) box.MinX, box.MinY, box.MaxX, box.MaxY); strReq.AppendFormat("&WIDTH={0}&Height={1}", tileSet.Width, tileSet.Height); strReq.Append("&LAYERS="); - // LAYERS is set in caps because the current version of tilecache.py does not accept mixed case (a little bug) + // LAYERS is set in caps because the current version of tilecache.py does not accept mixed case (a little bug) if (tileSet.Layers != null && tileSet.Layers.Count > 0) { foreach (string layer in tileSet.Layers) @@ -395,13 +394,13 @@ private Bitmap WmsGetMap(Envelope extent, TileSet tileSet) try { - webResponse = (HttpWebResponse) webRequest.GetResponse(); + webResponse = (HttpWebResponse)webRequest.GetResponse(); if (webResponse.ContentType.StartsWith("image")) { responseStream = webResponse.GetResponseStream(); - bitmap = (Bitmap) Bitmap.FromStream(responseStream); - return (Bitmap) bitmap; + bitmap = (Bitmap)Bitmap.FromStream(responseStream); + return (Bitmap)bitmap; } else { @@ -477,7 +476,7 @@ private static Rectangle RoundRectangle(RectangleF dest) double minY = Math.Round(dest.Y); double maxX = Math.Round(dest.Right); double maxY = Math.Round(dest.Bottom); - return new Rectangle((int) minX, (int) minY, (int) (maxX - minX), (int) (maxY - minY)); + return new Rectangle((int)minX, (int)minY, (int)(maxX - minX), (int)(maxY - minY)); } } } diff --git a/SharpMap/Layers/VariableLayerCollection.cs b/SharpMap/Layers/VariableLayerCollection.cs index c1c6de99..e1049503 100644 --- a/SharpMap/Layers/VariableLayerCollection.cs +++ b/SharpMap/Layers/VariableLayerCollection.cs @@ -41,7 +41,7 @@ public enum LayerCollectionType public class VariableLayerCollection : LayerCollection { //private readonly LayerCollection _variableLayers; - + //[NonSerialized] //private Timer _timer; diff --git a/SharpMap/Layers/VectorLayer.cs b/SharpMap/Layers/VectorLayer.cs index 9fd8ee6f..92e00aa4 100644 --- a/SharpMap/Layers/VectorLayer.cs +++ b/SharpMap/Layers/VectorLayer.cs @@ -15,18 +15,18 @@ // along with SharpMap; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -using System; -using System.Collections.ObjectModel; -using System.Drawing; -using System.Drawing.Drawing2D; +using Common.Logging; +using NetTopologySuite.Geometries; using SharpMap.Data; using SharpMap.Data.Providers; -using GeoAPI.Geometries; using SharpMap.Rendering; using SharpMap.Rendering.Thematics; using SharpMap.Styles; +using System; using System.Collections.Generic; -using Common.Logging; +using System.Collections.ObjectModel; +using System.Drawing; +using System.Drawing.Drawing2D; namespace SharpMap.Layers { @@ -89,8 +89,8 @@ public ITheme Theme /// Specifies whether polygons should be clipped prior to rendering /// /// - /// Clipping will clip and - /// to the current view prior + /// Clipping will clip and + /// to the current view prior /// to rendering the object. /// Enabling clipping might improve rendering speed if you are rendering /// only small portions of very large objects. @@ -269,7 +269,7 @@ protected void RenderInternal(Graphics g, MapViewport map, Envelope envelope, IT evalStyle = new ThemeExEvaluator((IThemeEx)theme).GetStyle; else evalStyle = new ThemeEvaluator(theme).GetStyle; - + foreach (FeatureDataTable features in ds.Tables) { // Transform geometries if necessary @@ -301,14 +301,14 @@ protected void RenderInternal(Graphics g, MapViewport map, Envelope envelope, IT if (outlineStyle != null) { //Draw background of all line-outlines first - if (feature.Geometry is ILineString) + if (feature.Geometry is LineString) { - canvasArea = VectorRenderer.DrawLineStringEx(g, feature.Geometry as ILineString, outlineStyle.Outline, + canvasArea = VectorRenderer.DrawLineStringEx(g, feature.Geometry as LineString, outlineStyle.Outline, map, outlineStyle.LineOffset); } - else if (feature.Geometry is IMultiLineString) + else if (feature.Geometry is MultiLineString) { - canvasArea = VectorRenderer.DrawMultiLineStringEx(g, feature.Geometry as IMultiLineString, + canvasArea = VectorRenderer.DrawMultiLineStringEx(g, feature.Geometry as MultiLineString, outlineStyle.Outline, map, outlineStyle.LineOffset); } combinedArea = canvasArea.ExpandToInclude(combinedArea); @@ -374,7 +374,7 @@ protected void RenderInternal(Graphics g, MapViewport map, Envelope envelope) var canvasArea = RectangleF.Empty; var combinedArea = RectangleF.Empty; - Collection geoms = null; + Collection geoms = null; foreach (var style in stylesToRender) { @@ -428,17 +428,17 @@ protected void RenderInternal(Graphics g, MapViewport map, Envelope envelope) if (geom != null) { //Draw background of all line-outlines first - if (geom is ILineString) - canvasArea = VectorRenderer.DrawLineStringEx(g, geom as ILineString, vStyle.Outline, map, vStyle.LineOffset); - else if (geom is IMultiLineString) - canvasArea = VectorRenderer.DrawMultiLineStringEx(g, geom as IMultiLineString, vStyle.Outline, map, vStyle.LineOffset); + if (geom is LineString) + canvasArea = VectorRenderer.DrawLineStringEx(g, geom as LineString, vStyle.Outline, map, vStyle.LineOffset); + else if (geom is MultiLineString) + canvasArea = VectorRenderer.DrawMultiLineStringEx(g, geom as MultiLineString, vStyle.Outline, map, vStyle.LineOffset); combinedArea = canvasArea.ExpandToInclude(combinedArea); } } } } - foreach (IGeometry geom in geoms) + foreach (Geometry geom in geoms) { if (geom != null) { @@ -492,7 +492,7 @@ public static IEnumerable GetStylesToRender(IStyle style) /// The map /// The feature's geometry /// The style to apply - protected void RenderGeometry(Graphics g, MapViewport map, IGeometry feature, VectorStyle style) + protected void RenderGeometry(Graphics g, MapViewport map, Geometry feature, VectorStyle style) { RenderGeometryEx(g, map, feature, style); } @@ -504,7 +504,7 @@ protected void RenderGeometry(Graphics g, MapViewport map, IGeometry feature, Ve /// The map /// The feature's geometry /// The style to apply - protected RectangleF RenderGeometryEx(Graphics g, MapViewport map, IGeometry feature, VectorStyle style) + protected RectangleF RenderGeometryEx(Graphics g, MapViewport map, Geometry feature, VectorStyle style) { if (feature == null) return RectangleF.Empty; @@ -513,62 +513,62 @@ protected RectangleF RenderGeometryEx(Graphics g, MapViewport map, IGeometry fea { case OgcGeometryType.Polygon: if (style.EnableOutline) - return VectorRenderer.DrawPolygonEx(g, (IPolygon)feature, style.Fill, style.Outline, _clippingEnabled, + return VectorRenderer.DrawPolygonEx(g, (Polygon)feature, style.Fill, style.Outline, _clippingEnabled, map); else - return VectorRenderer.DrawPolygonEx(g, (IPolygon)feature, style.Fill, null, _clippingEnabled, map); + return VectorRenderer.DrawPolygonEx(g, (Polygon)feature, style.Fill, null, _clippingEnabled, map); case OgcGeometryType.MultiPolygon: if (style.EnableOutline) - return VectorRenderer.DrawMultiPolygonEx(g, (IMultiPolygon)feature, style.Fill, style.Outline, _clippingEnabled, map); - return VectorRenderer.DrawMultiPolygonEx(g, (IMultiPolygon)feature, style.Fill, null, _clippingEnabled, map); + return VectorRenderer.DrawMultiPolygonEx(g, (MultiPolygon)feature, style.Fill, style.Outline, _clippingEnabled, map); + return VectorRenderer.DrawMultiPolygonEx(g, (MultiPolygon)feature, style.Fill, null, _clippingEnabled, map); case OgcGeometryType.LineString: if (style.LineSymbolizer != null) { - style.LineSymbolizer.Render(map, (ILineString)feature, g); - return RectangleF.Empty; + style.LineSymbolizer.Render(map, (LineString)feature, g); + return RectangleF.Empty; } - return VectorRenderer.DrawLineStringEx(g, (ILineString)feature, style.Line, map, style.LineOffset); + return VectorRenderer.DrawLineStringEx(g, (LineString)feature, style.Line, map, style.LineOffset); case OgcGeometryType.MultiLineString: if (style.LineSymbolizer != null) { - style.LineSymbolizer.Render(map, (IMultiLineString)feature, g); + style.LineSymbolizer.Render(map, (MultiLineString)feature, g); return RectangleF.Empty; } - return VectorRenderer.DrawMultiLineStringEx(g, (IMultiLineString)feature, style.Line, map, style.LineOffset); - + return VectorRenderer.DrawMultiLineStringEx(g, (MultiLineString)feature, style.Line, map, style.LineOffset); + case OgcGeometryType.Point: if (style.PointSymbolizer != null) - return VectorRenderer.DrawPointEx(style.PointSymbolizer, g, (IPoint)feature, map); + return VectorRenderer.DrawPointEx(style.PointSymbolizer, g, (NetTopologySuite.Geometries.Point)feature, map); if (style.Symbol != null || style.PointColor == null) - return VectorRenderer.DrawPointEx(g, (IPoint)feature, style.Symbol, style.SymbolScale, style.SymbolOffset, + return VectorRenderer.DrawPointEx(g, (NetTopologySuite.Geometries.Point)feature, style.Symbol, style.SymbolScale, style.SymbolOffset, style.SymbolRotation, map); - return VectorRenderer.DrawPointEx(g, (IPoint)feature, style.PointColor, style.PointSize, style.SymbolOffset, map); + return VectorRenderer.DrawPointEx(g, (NetTopologySuite.Geometries.Point)feature, style.PointColor, style.PointSize, style.SymbolOffset, map); case OgcGeometryType.MultiPoint: if (style.PointSymbolizer != null) - return VectorRenderer.DrawMultiPointEx(style.PointSymbolizer, g, (IMultiPoint)feature, map); - + return VectorRenderer.DrawMultiPointEx(style.PointSymbolizer, g, (MultiPoint)feature, map); + if (style.Symbol != null || style.PointColor == null) - return VectorRenderer.DrawMultiPointEx(g, (IMultiPoint)feature, style.Symbol, style.SymbolScale, style.SymbolOffset, style.SymbolRotation, map); + return VectorRenderer.DrawMultiPointEx(g, (MultiPoint)feature, style.Symbol, style.SymbolScale, style.SymbolOffset, style.SymbolRotation, map); - return VectorRenderer.DrawMultiPointEx(g, (IMultiPoint)feature, style.PointColor, style.PointSize, style.SymbolOffset, map); + return VectorRenderer.DrawMultiPointEx(g, (MultiPoint)feature, style.PointColor, style.PointSize, style.SymbolOffset, map); case OgcGeometryType.GeometryCollection: - var coll = (IGeometryCollection)feature; + var coll = (GeometryCollection)feature; var combinedArea = RectangleF.Empty; for (var i = 0; i < coll.NumGeometries; i++) { - IGeometry geom = coll[i]; + Geometry geom = coll[i]; var canvasArea = RenderGeometryEx(g, map, geom, style); combinedArea = canvasArea.ExpandToInclude(combinedArea); } return combinedArea; - + } throw new NotSupportedException(); } @@ -609,7 +609,7 @@ public void ExecuteIntersectionQuery(Envelope box, FeatureDataSet ds) /// /// Geometry to intersect with /// FeatureDataSet to fill data into - public void ExecuteIntersectionQuery(IGeometry geometry, FeatureDataSet ds) + public void ExecuteIntersectionQuery(Geometry geometry, FeatureDataSet ds) { geometry = ToSource(geometry); diff --git a/SharpMap/Layers/WmsLayer.cs b/SharpMap/Layers/WmsLayer.cs index ff264797..ac792418 100644 --- a/SharpMap/Layers/WmsLayer.cs +++ b/SharpMap/Layers/WmsLayer.cs @@ -15,19 +15,19 @@ // along with SharpMap; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +using Common.Logging; +using NetTopologySuite.Geometries; +using SharpMap.CoordinateSystems; +using SharpMap.Rendering.Exceptions; +using SharpMap.Web.Wms; using System; -using System.Collections.ObjectModel; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.Drawing; using System.Drawing.Imaging; using System.IO; using System.Net; using System.Text; -using GeoAPI.Geometries; -using SharpMap.CoordinateSystems; -using SharpMap.Rendering.Exceptions; -using SharpMap.Web.Wms; -using Common.Logging; namespace SharpMap.Layers { @@ -53,7 +53,7 @@ namespace SharpMap.Layers /// myLayer.SetImageFormat(layWms.OutputFormats[0]); /// myLayer.SRID = 4326; /// myMap.Layers.Add(myLayer); - /// myMap.Center = new GeoAPI.Geometries.Coordinate(0, 0); + /// myMap.Center = new NetTopologySuite.Geometries.Coordinate(0, 0); /// myMap.Zoom = 360; /// myMap.MaximumZoom = 360; /// myMap.MinimumZoom = 0.1; @@ -137,7 +137,7 @@ public WmsLayer(string layername, string url, TimeSpan cachetime, IWebProxy prox /// public WmsLayer(string layername, string url, TimeSpan cachetime, IWebProxy proxy, ICredentials credentials) - :this(layername, GetClient(url, proxy, credentials, cachetime)) + : this(layername, GetClient(url, proxy, credentials, cachetime)) { } @@ -207,7 +207,7 @@ public void ForceOnlineResourceUrl(string url) for (int i = 0; i < _wmsClient.GetMapRequests.Length; i++) { _wmsClient.GetMapRequests[i].OnlineResource = url; - } + } } @@ -369,7 +369,7 @@ public ImageAttributes ImageAttributes /// Returns the extent of the layer /// /// Bounding box corresponding to the extent of the features in the layer - public override Envelope Envelope + public override Envelope Envelope { get { return _envelope ?? (_envelope = GetEnvelope()); } } @@ -608,7 +608,7 @@ public override void Render(Graphics g, MapViewport map) if (Logger.IsDebugEnabled) Logger.Debug("Beginning request"); - using(var myWebResponse = (HttpWebResponse)myWebRequest.GetResponse()) + using (var myWebResponse = (HttpWebResponse)myWebRequest.GetResponse()) { if (Logger.IsDebugEnabled) Logger.Debug("Got response"); @@ -620,7 +620,7 @@ public override void Render(Graphics g, MapViewport map) if (Logger.IsDebugEnabled) Logger.Debug("Reading image from stream"); - var cLength = (int) myWebResponse.ContentLength; + var cLength = (int)myWebResponse.ContentLength; if (Logger.IsDebugEnabled) Logger.Debug("Content-Length: " + cLength); diff --git a/SharpMap/Map/Map.cs b/SharpMap/Map/Map.cs index 357d751c..80d1a189 100644 --- a/SharpMap/Map/Map.cs +++ b/SharpMap/Map/Map.cs @@ -15,30 +15,26 @@ // along with SharpMap; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +using Common.Logging; +using NetTopologySuite.Geometries; +using SharpMap.Layers; +using SharpMap.Rendering; +using SharpMap.Rendering.Decoration; +using SharpMap.Styles; +using SharpMap.Utilities; using System; -using System.Collections; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Collections.Specialized; using System.ComponentModel; -using System.Diagnostics; using System.Drawing; using System.Drawing.Drawing2D; +using System.Drawing.Imaging; using System.Globalization; using System.IO; using System.Linq; -using System.Runtime.InteropServices; -using GeoAPI.Geometries; -using NetTopologySuite; -using SharpMap.Layers; -using SharpMap.Rendering; -using SharpMap.Rendering.Decoration; -using SharpMap.Styles; -using SharpMap.Utilities; -using Point = GeoAPI.Geometries.Coordinate; -using System.Drawing.Imaging; -using Common.Logging; using System.Reflection; +using Point = NetTopologySuite.Geometries.Coordinate; namespace SharpMap { @@ -60,14 +56,14 @@ public static void Configure() } /// - /// Static constructor. Needed to get set. + /// Static constructor. Needed to get set. /// static Map() { try { - _logger.Debug("Trying to get GeoAPI.GeometryServiceProvider.Instance"); - var instance = GeoAPI.GeometryServiceProvider.Instance; + _logger.Debug("Trying to get NetTopologySuite.NetTopologySuite.NtsGeometryServices.Instance"); + var instance = NetTopologySuite.NtsGeometryServices.Instance; if (instance == null) { _logger.Debug("Returned null"); @@ -79,8 +75,8 @@ static Map() _logger.Debug("Loading NetTopologySuite"); Assembly.Load("NetTopologySuite"); _logger.Debug("Loaded NetTopologySuite"); - _logger.Debug("Trying to get GeoAPI.GeometryServiceProvider.Instance"); - var instance = GeoAPI.GeometryServiceProvider.Instance; + _logger.Debug("Trying to get NetTopologySuite.NetTopologySuite.NtsGeometryServices.Instance"); + var instance = NetTopologySuite.NtsGeometryServices.Instance; if (instance == null) { _logger.Debug("Returned null"); @@ -94,23 +90,23 @@ static Map() { _logger.Debug("In design mode"); Trace.WriteLine("In design mode"); - // We have to do this initialization with reflection due to the fact that NTS can reference an older version of GeoAPI and redirection + // We have to do this initialization with reflection due to the fact that NTS can reference an older version of NetTopologySuite and redirection // is not available at design time.. var ntsAssembly = Assembly.Load("NetTopologySuite"); _logger.Debug("Loaded NetTopologySuite"); Trace.WriteLine("Loaded NetTopologySuite"); try { - _logger.Debug("Trying to access GeoAPI.GeometryServiceProvider.Instance"); - Trace.WriteLine("Trying to access GeoAPI.GeometryServiceProvider.Instance"); - if (GeoAPI.GeometryServiceProvider.Instance == null) + _logger.Debug("Trying to access NetTopologySuite.NetTopologySuite.NtsGeometryServices.Instance"); + Trace.WriteLine("Trying to access NetTopologySuite.NetTopologySuite.NtsGeometryServices.Instance"); + if (NetTopologySuite.NetTopologySuite.NtsGeometryServices.Instance == null) { _logger.Debug("Returned null, setting it to default"); Trace.WriteLine("Returned null, setting it to default"); var ntsApiGeometryServices = ntsAssembly.GetType("NetTopologySuite.NtsGeometryServices"); - GeoAPI.GeometryServiceProvider.Instance = + NetTopologySuite.NetTopologySuite.NtsGeometryServices.Instance = ntsApiGeometryServices.GetProperty("Instance").GetValue(null, null) as - GeoAPI.IGeometryServices; + NetTopologySuite.IGeometryServices; } } @@ -119,9 +115,9 @@ static Map() _logger.Debug("InvalidOperationException thrown, setting it to default"); Trace.WriteLine("InvalidOperationException thrown, setting it to default"); var ntsApiGeometryServices = ntsAssembly.GetType("NetTopologySuite.NtsGeometryServices"); - GeoAPI.GeometryServiceProvider.Instance = + NetTopologySuite.NetTopologySuite.NtsGeometryServices.Instance = ntsApiGeometryServices.GetProperty("Instance").GetValue(null, null) as - GeoAPI.IGeometryServices; + NetTopologySuite.IGeometryServices; } _logger.Debug("Exiting design mode handling"); Trace.WriteLine("Exiting design mode handling"); @@ -148,14 +144,14 @@ static Map() private readonly VariableLayerCollection _variableLayers; #pragma warning disable 169 // both fields redundant, but unable to remove without violating serialization - private Matrix _mapTransform; + private Matrix _mapTransform; private Matrix _mapTransformInverted; #pragma warning restore 169 private readonly object _lockMapTransform = new object(); private readonly object _lockMapTransformInverted = new object(); - private float[] _mapTransformElements; + private float[] _mapTransformElements; private float[] _mapTransformInvertedElements; - + private readonly MapViewPortGuard _mapViewportGuard; private readonly Dictionary> _layersPerGroup = new Dictionary>(); private ObservableCollection _replacingCollection; @@ -190,7 +186,7 @@ public Map(Size size) if (LicenseManager.UsageMode != LicenseUsageMode.Designtime) { - Factory = GeoAPI.GeometryServiceProvider.Instance.CreateGeometryFactory(_srid); + Factory = Session.Instance.GeometryServices.CreateGeometryFactory(_srid); } _layers = new LayerCollection(); _layersPerGroup.Add(_layers, new List()); @@ -611,8 +607,8 @@ public void RenderMap(Graphics g) throw new InvalidOperationException("No layers to render"); g.Transform = MapTransform; - - var mvp = (MapViewport) this; + + var mvp = (MapViewport)this; g.Clear(BackColor); g.PageUnit = GraphicsUnit.Pixel; @@ -661,7 +657,7 @@ public void RenderMap(Graphics g) OnLayerRendering(layer, LayerCollectionType.Static); if (layer.Enabled && layer.MaxVisible >= visibleLevel && layer.MinVisible < visibleLevel) LayerCollectionRenderer.RenderLayer(layer, g, mvp); - + OnLayerRendered(layer, LayerCollectionType.Static); } } @@ -679,7 +675,7 @@ public void RenderMap(Graphics g) double visibleLevel = layer.VisibilityUnits == VisibilityUnits.ZoomLevel ? zoom : scale; if (layer.Enabled && layer.MaxVisible >= visibleLevel && layer.MinVisible < visibleLevel) LayerCollectionRenderer.RenderLayer(layer, g, mvp); - + OnLayerRendered(layer, LayerCollectionType.Variable); } } @@ -815,7 +811,7 @@ public void RenderMap(Graphics g, LayerCollectionType layerCollectionType, bool g.Transform = MapTransform; - var mvp = (MapViewport) this; + var mvp = (MapViewport)this; if (!drawTransparent) g.Clear(BackColor); @@ -1027,7 +1023,7 @@ public void ZoomToBox(Envelope bbox, bool careAboutTransform = false) bbox.Centre.Y - newHeight * 0.5, bbox.Centre.Y + newHeight * 0.5); } - + //Ensure aspect ratio var resX = Size.Width == 0 ? double.MaxValue : bbox.Width / Size.Width; var resY = Size.Height == 0 ? double.MaxValue : bbox.Height / Size.Height; @@ -1068,8 +1064,8 @@ public PointF[] WorldToImage(Coordinate[] coordinates, bool careAboutMapTransfor if (MapTransformRotation.Equals(0f)) { // simple case is non-rotated views (ie MapTransform does NOT need to be applied) - var left = Center.X - Zoom * 0.5; - var top = Center.Y + MapHeight * 0.5; + var left = Center.X - Zoom * 0.5; + var top = Center.Y + MapHeight * 0.5; return Transform.WorldToMap(coordinates, left, top, PixelWidth, PixelHeight); } @@ -1082,7 +1078,7 @@ public PointF[] WorldToImage(Coordinate[] coordinates, bool careAboutMapTransfor Center, PixelWidth, PixelHeight, MapTransformRotation, Size, careAboutMapTransform); return Transform.WorldToMap(coordinates, matrix); } - + /// /// Converts a point in world coordinates to image coordinates based on the current , , /// map , and (optionally) the . @@ -1093,7 +1089,7 @@ public PointF[] WorldToImage(Coordinate[] coordinates, bool careAboutMapTransfor /// PointF in image coordinates public PointF WorldToImage(Coordinate p, bool careAboutMapTransform = false) { - var points = WorldToImage(new Coordinate[] {p}, careAboutMapTransform); + var points = WorldToImage(new Coordinate[] { p }, careAboutMapTransform); return points[0]; } @@ -1113,7 +1109,7 @@ public Point[] ImageToWorld(PointF[] points, bool careAboutMapTransform = false) return Transform.MapToWorld(points, this); } - + /// /// Converts a point from image coordinates to world coordinates based on the current , , /// map , and (optionally) the . @@ -1152,14 +1148,14 @@ public int SRID if (_srid == value) return; _srid = value; - Factory = GeoAPI.GeometryServiceProvider.Instance.CreateGeometryFactory(_srid); + Factory = NetTopologySuite.NtsGeometryServices.Instance.CreateGeometryFactory(_srid); } } /// /// Factory used to create geometries /// - public IGeometryFactory Factory { get; private set; } + public GeometryFactory Factory { get; private set; } /// /// List of all map decorations @@ -1190,26 +1186,26 @@ public Envelope Envelope var ur = new Coordinate(Center.X + Zoom * .5, Center.Y + height * .5); // simple, non-rotated view - if (MapTransformRotation.Equals(0f)) + if (MapTransformRotation.Equals(0f)) return new Envelope(ll, ur); - // otherwise derive envelope containing rotated view (required for layers to select data) - if (Size.Width == 0 || Size.Height == 0) - return new Envelope(0, 0, 0, 0); + // otherwise derive envelope containing rotated view (required for layers to select data) + if (Size.Width == 0 || Size.Height == 0) + return new Envelope(0, 0, 0, 0); - var rad = (double) -MapTransformRotation * Math.PI / 180.0; - var newWidth = (ur.X - ll.X) * Math.Abs(Math.Cos(rad)) + - (ur.Y - ll.Y) * Math.Abs(Math.Sin(rad)); - var newHeight = (ur.X - ll.X) * Math.Abs(Math.Sin(rad)) + - (ur.Y - ll.Y) * Math.Abs(Math.Cos(rad)); + var rad = (double)-MapTransformRotation * Math.PI / 180.0; + var newWidth = (ur.X - ll.X) * Math.Abs(Math.Cos(rad)) + + (ur.Y - ll.Y) * Math.Abs(Math.Sin(rad)); + var newHeight = (ur.X - ll.X) * Math.Abs(Math.Sin(rad)) + + (ur.Y - ll.Y) * Math.Abs(Math.Cos(rad)); - ll = new Coordinate(Center.X - newWidth * .5, Center.Y - newHeight * .5); - ur = new Coordinate(Center.X + newWidth * .5, Center.Y + newHeight * .5); + ll = new Coordinate(Center.X - newWidth * .5, Center.Y - newHeight * .5); + ur = new Coordinate(Center.X + newWidth * .5, Center.Y + newHeight * .5); - return new Envelope(ll, ur); - } + return new Envelope(ll, ur); + } } - + /// /// Using the you can alter the coordinate system of the map rendering. /// This makes it possible to rotate the image, for instance to have another direction than north upwards. @@ -1254,7 +1250,7 @@ public Matrix MapTransform inverted.Invert(); _mapTransformInvertedElements = inverted.Elements; } - + if (value.IsIdentity) MapTransformRotation = 0f; else @@ -1287,7 +1283,7 @@ internal Matrix MapTransformInverted _mapTransformInvertedElements[5]); } } - + /// /// MapTransform Rotation in degrees. Facilitates determining if map is rotated without locking MapTransform. /// Positive rotation is applied anti-clockwise, with the apparent effect of north arrow rotating clockwise. diff --git a/SharpMap/Map/MapViewport.cs b/SharpMap/Map/MapViewport.cs index 1a87bc67..3feb0834 100644 --- a/SharpMap/Map/MapViewport.cs +++ b/SharpMap/Map/MapViewport.cs @@ -1,8 +1,8 @@ -using System; -using System.Drawing; -using GeoAPI.Geometries; +using NetTopologySuite.Geometries; using NetTopologySuite.Geometries.Utilities; using SharpMap.Utilities; +using System; +using System.Drawing; namespace SharpMap { @@ -40,7 +40,7 @@ public class MapViewport /// An affine map transform matrix /// The affine map transformation that inverts /// The rotation in degrees applied by - public MapViewport(Guid mapId, int srid, double zoom, double mapHeight, Envelope env, Size size, double pixelAspectRatio, + public MapViewport(Guid mapId, int srid, double zoom, double mapHeight, Envelope env, Size size, double pixelAspectRatio, System.Drawing.Drawing2D.Matrix mapTransform, System.Drawing.Drawing2D.Matrix mapTransformInverted, float mapTransformRotation) { @@ -55,7 +55,7 @@ public MapViewport(Guid mapId, int srid, double zoom, double mapHeight, Envelope _center = env.Centre; PixelAspectRatio = pixelAspectRatio; - PixelWidth = Zoom / size.Width; + PixelWidth = Zoom / size.Width; PixelHeight = PixelWidth * pixelAspectRatio; _mapTransformElements = mapTransform.Elements; @@ -182,7 +182,7 @@ internal AffineTransformation WorldToMapTransform(bool careAboutTransform) _worldToMapElements[5] ); } - + /// /// Gets a value indicating the center of the map viewport /// @@ -218,7 +218,7 @@ public Coordinate CenterOfInterest /// Applicable to non-rotated views only, returning the minimum X value of the map viewport in world units /// public double Left { get; } - + /// /// Applicable to non-rotated views only, returning the maximum Y value of the map viewport in world units /// @@ -278,7 +278,7 @@ public PointF[] WorldToImage(Coordinate[] coordinates, bool careAboutMapTransfor var matrix = WorldToMapTransform(careAboutMapTransform); return Transform.WorldToMap(coordinates, matrix); } - + /// /// Converts a point in world coordinates to image coordinates based on the current , , /// map , and (optionally) the . @@ -289,7 +289,7 @@ public PointF[] WorldToImage(Coordinate[] coordinates, bool careAboutMapTransfor /// PointF in image coordinates public PointF WorldToImage(Coordinate p, bool careAboutMapTransform = false) { - var points = WorldToImage(new Coordinate[] {p}, careAboutMapTransform); + var points = WorldToImage(new Coordinate[] { p }, careAboutMapTransform); return points[0]; } @@ -320,7 +320,7 @@ public Coordinate[] ImageToWorld(PointF[] points, bool careAboutMapTransform = f /// Point in world coordinates public Coordinate ImageToWorld(PointF p, bool careAboutMapTransform = false) { - var pts = ImageToWorld(new PointF[] {p}, careAboutMapTransform); + var pts = ImageToWorld(new PointF[] { p }, careAboutMapTransform); return pts[0]; } diff --git a/SharpMap/Map/MapViewportGuard.cs b/SharpMap/Map/MapViewportGuard.cs index 3feb82c0..5eb525fd 100644 --- a/SharpMap/Map/MapViewportGuard.cs +++ b/SharpMap/Map/MapViewportGuard.cs @@ -1,6 +1,6 @@ -using System; +using NetTopologySuite.Geometries; +using System; using System.Drawing; -using GeoAPI.Geometries; namespace SharpMap { @@ -107,7 +107,7 @@ public double VerifyZoom(double zoom, Coordinate center) if (!EnforceMaximumExtents) return zoom; - double arWidth = (double)Size.Width/Size.Height; + double arWidth = (double)Size.Width / Size.Height; if (zoom > _maximumExtents.Width) zoom = _maximumExtents.Width; @@ -136,7 +136,7 @@ private double VerifyValidViewport(double zoom, Coordinate center) double maxZoomHeight = _maximumZoom < double.MaxValue ? _maximumZoom : double.MaxValue; if (2 * halfHeight > maxZoomHeight) { - halfHeight = 0.5d*maxZoomHeight; + halfHeight = 0.5d * maxZoomHeight; halfWidth = halfHeight / (_pixelAspectRatio * ((double)Size.Height / Size.Width)); zoom = 2 * halfWidth; } @@ -149,14 +149,14 @@ private double VerifyValidViewport(double zoom, Coordinate center) double dx = testEnvelope.MinX < maxExtents.MinX ? maxExtents.MinX - testEnvelope.MinX - : testEnvelope.MaxX > maxExtents.MaxX - ? maxExtents.MaxX - testEnvelope.MaxX + : testEnvelope.MaxX > maxExtents.MaxX + ? maxExtents.MaxX - testEnvelope.MaxX : 0; double dy = testEnvelope.MinY < maxExtents.MinY ? maxExtents.MinY - testEnvelope.MinY - : testEnvelope.MaxY > maxExtents.MaxY - ? maxExtents.MaxY - testEnvelope.MaxY + : testEnvelope.MaxY > maxExtents.MaxY + ? maxExtents.MaxY - testEnvelope.MaxY : 0; center.X += dx; diff --git a/SharpMap/Rendering/Decoration/Disclaimer.cs b/SharpMap/Rendering/Decoration/Disclaimer.cs index c2abad38..6b14ab49 100644 --- a/SharpMap/Rendering/Decoration/Disclaimer.cs +++ b/SharpMap/Rendering/Decoration/Disclaimer.cs @@ -1,7 +1,7 @@ -using System; +using SharpMap.Rendering.Symbolizer; +using System; using System.Drawing; using System.Drawing.Drawing2D; -using SharpMap.Rendering.Symbolizer; namespace SharpMap.Rendering.Decoration { @@ -44,7 +44,7 @@ public Disclaimer() /// public Color ForeColor { - get ; set; + get; set; } private Pen _halo; @@ -56,7 +56,7 @@ public Color ForeColor /// public int Halo { - get { return _halo == null ? 0 : (int) _halo.Width; } + get { return _halo == null ? 0 : (int)_halo.Width; } set { if (value < 0) value = 0; @@ -73,7 +73,8 @@ public int Halo public Color HaloColor { get { return _haloColor; } - set { + set + { _haloColor = value; if (Halo > 0) _halo = new Pen(value, Halo); @@ -102,7 +103,7 @@ protected override void OnRender(Graphics g, MapViewport map) if (Halo > 0) { var gp = new GraphicsPath(); - gp.AddString(Text, Font.FontFamily, (int) Font.Style, + gp.AddString(Text, Font.FontFamily, (int)Font.Style, Utility.ScaleSizeToDeviceUnits(Font.SizeInPoints, GraphicsUnit.Point, g), layoutRectangle, Format); g.DrawPath(_halo, gp); g.FillPath(b, gp); @@ -111,7 +112,7 @@ protected override void OnRender(Graphics g, MapViewport map) g.DrawString(Text, Font, b, layoutRectangle); } - + #endregion } } diff --git a/SharpMap/Rendering/Decoration/EyeOfSight.cs b/SharpMap/Rendering/Decoration/EyeOfSight.cs index 67f38724..af69173b 100644 --- a/SharpMap/Rendering/Decoration/EyeOfSight.cs +++ b/SharpMap/Rendering/Decoration/EyeOfSight.cs @@ -10,12 +10,12 @@ namespace SharpMap.Rendering.Decoration [Serializable] public class EyeOfSight : NorthArrow { - private static readonly string[] Directions = {"N", "E", "S", "W"}; + private static readonly string[] Directions = { "N", "E", "S", "W" }; private static Bitmap GetEyeOfSightImage() { var roestte = new Bitmap(120, 120); - + //Anyone for a more sophisticated roestte? using (var g = Graphics.FromImage(roestte)) { @@ -25,8 +25,8 @@ private static Bitmap GetEyeOfSightImage() var f = new Font(FontFamily.GenericSansSerif, 20, FontStyle.Bold); var b = new SolidBrush(Color.Black); var p = new Pen(Color.Black, 5); - var sf = new StringFormat(StringFormat.GenericTypographic) {Alignment = StringAlignment.Center}; - var rect = new RectangleF(- 45f, - 45f, 90f, 90f); + var sf = new StringFormat(StringFormat.GenericTypographic) { Alignment = StringAlignment.Center }; + var rect = new RectangleF(-45f, -45f, 90f, 90f); foreach (var s in Directions) { @@ -44,17 +44,17 @@ public EyeOfSight() { NorthArrowImage = GetEyeOfSightImage(); } - + /// /// Gets or sets the outline color /// public Color NeedleOutlineColor { get; set; } - + /// /// The width of the needle outline /// public int NeedleOutlineWidth { get; set; } - + /// /// The color to /// @@ -67,10 +67,10 @@ protected override void OnRender(Graphics g, MapViewport mvp) { // Render the rosetta base.OnRender(g, mvp); - + var clip = g.ClipBounds; //var oldTransform = g.Transform; - var newTransform = new Matrix(1f, 0f, 0f, 1f, clip.Left + Size.Width*0.5f, clip.Top + Size.Height*0.5f); + var newTransform = new Matrix(1f, 0f, 0f, 1f, clip.Left + Size.Width * 0.5f, clip.Top + Size.Height * 0.5f); g.Transform = newTransform; @@ -86,13 +86,13 @@ protected override void OnRender(Graphics g, MapViewport mvp) }; // need to outline the needle - if (NeedleOutlineWidth>0) + if (NeedleOutlineWidth > 0) { g.DrawPolygon(new Pen(OpacityColor(NeedleOutlineColor), NeedleOutlineWidth), pts); } // need to outline the needle - g.FillPolygon(new SolidBrush(OpacityColor(NeedleFillColor)), pts ); + g.FillPolygon(new SolidBrush(OpacityColor(NeedleFillColor)), pts); //g.Transform = oldTransform; } diff --git a/SharpMap/Rendering/Decoration/Graticule/Graticule.cs b/SharpMap/Rendering/Decoration/Graticule/Graticule.cs index 8a44492e..3925df87 100644 --- a/SharpMap/Rendering/Decoration/Graticule/Graticule.cs +++ b/SharpMap/Rendering/Decoration/Graticule/Graticule.cs @@ -1,17 +1,17 @@ -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Drawing.Drawing2D; -using System.Linq; using Common.Logging; -using GeoAPI.CoordinateSystems; -using GeoAPI.CoordinateSystems.Transformations; -using GeoAPI.Geometries; +using NetTopologySuite.CoordinateSystems.Transformations; using NetTopologySuite.Geometries; using NetTopologySuite.Geometries.Utilities; using NetTopologySuite.Utilities; +using ProjNet.CoordinateSystems; +using ProjNet.CoordinateSystems.Transformations; using SharpMap.Styles; using SharpMap.Utilities; +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Drawing.Drawing2D; +using System.Linq; using Matrix = System.Drawing.Drawing2D.Matrix; using Point = NetTopologySuite.Geometries.Point; @@ -40,13 +40,13 @@ public class Graticule : MapDecoration private const int PcsPowerRangeMin = -5; private const int PcsPowerRangeMax = 10; - private readonly double[] _pcsPreferredMultiples = {5, 2.5, 2, 1}; // MUST be in descending order + private readonly double[] _pcsPreferredMultiples = { 5, 2.5, 2, 1 }; // MUST be in descending order private const int GcsPowerRangeMin = -5; private const int GcsPowerRangeMax = 0; private readonly double[] - _gcsPreferredMultiples = {90, 60, 30, 20, 15, 10, 5, 2.5, 2, 1}; // MUST be in descending order + _gcsPreferredMultiples = { 90, 60, 30, 20, 15, 10, 5, 2.5, 2, 1 }; // MUST be in descending order private readonly Polygon _webMercatorClipPolygon = new Polygon( new LinearRing(new[] @@ -61,14 +61,14 @@ private readonly double[] private int _srid; private Envelope _oldViewExtents; private Polygon _viewClipPolygon; - private ICoordinateSystem _coordinateSystem; + private CoordinateSystem _coordinateSystem; private string _pcsUnitSuffix; private double _mapScale; private Envelope _pcsDomain; private Envelope _gcsDomain; - private IMathTransform _unProject; - private IMathTransform _project; + private MathTransform _unProject; + private MathTransform _project; private Envelope _pcsConstrExtents; private Envelope _gcsConstrExtents; private int _oldPcsNumSubdivisions; @@ -135,7 +135,7 @@ public Graticule() GraticuleLineStyle.Continuous, true, GraticuleBorders.LeftBottom) { - SecondaryPen = {DashStyle = DashStyle.Dash} + SecondaryPen = { DashStyle = DashStyle.Dash } }; GcsGraticuleStyle = new GraticuleStyle(GraticuleStyle.GraticuleTheme.Subtle, @@ -170,7 +170,7 @@ protected override void OnRender(Graphics g, MapViewport map) PcsGraticuleMode != _oldPcsGraticuleMode) CalculateMetrics(g, map, webMercatorScaleLinesActive); - if (_coordinateSystem is IProjectedCoordinateSystem) + if (_coordinateSystem is ProjectedCoordinateSystem) { OnRenderInternal(g, map, PcsGraticuleStyle, _pcsConstrExtents, _pcsDomain, webMercatorScaleLinesActive); @@ -222,7 +222,7 @@ private void OnRenderInternal(Graphics g, MapViewport map, GraticuleStyle style, if (isGcsStyle && _project != null) { def.WcsGraticule = - (LineString) GeometryTransform.TransformLineString(def.WcsGraticule, _project, targetFactory); + (LineString)GeometryTransform.TransformLineString(def.WcsGraticule, _project, targetFactory); def.WcsTickMarks = new MultiPoint(TransformPreserveZ(_project, def.WcsTickMarks.Coordinates)); } @@ -234,19 +234,19 @@ private void OnRenderInternal(Graphics g, MapViewport map, GraticuleStyle style, int same; if (def.IsParallel) { - var initialY = def.WcsGraticule .Coordinates[0].Y; + var initialY = def.WcsGraticule.Coordinates[0].Y; same = def.WcsGraticule.Coordinates.Count(c => Math.Abs(c.Y - initialY) < tolerance); } else { - var initialX = def.WcsGraticule .Coordinates[0].X; + var initialX = def.WcsGraticule.Coordinates[0].X; same = def.WcsGraticule.Coordinates.Count(c => Math.Abs(c.X - initialX) < tolerance); } if (def.WcsGraticule.Coordinates.Length == same) { // simplify to single line segment - def.WcsGraticule = new LineString(new[] + def.WcsGraticule = new LineString(new[] { def.WcsGraticule .Coordinates.First(), def.WcsGraticule .Coordinates.Last() @@ -377,7 +377,7 @@ private List CalculateParallels(GraticuleStyle style, Envelope con IsPrimary = isPrimaryParallel, Label = GetFormattedLabel(isGeographicGraticule, thisY, AxisOrientationEnum.North), WcsGraticule = new LineString(coordList.ToArray()), - WcsTickMarks = (MultiPoint) MultiPoint.Empty // new List().ToArray()) + WcsTickMarks = (MultiPoint)MultiPoint.Empty // new List().ToArray()) }); } @@ -398,7 +398,7 @@ private List CalculateMeridians(GraticuleStyle style, Envelope con { var meridians = new List(); var coordList = new List(); - var tickList = new List(); + var tickList = new List(); var isGeographicGraticule = style == GcsGraticuleStyle; var tolerance = isGeographicGraticule ? GeographicTolerance : ProjectedTolerance; @@ -584,11 +584,11 @@ private string GetFormattedLabel(bool isGeographicCoordinateSystem, double value // DMS: 8dp approx = 1mm (= 1" arc to 4dp) var deg = Math.Round(Math.Abs(value), 8, MidpointRounding.AwayFromZero); - var iDeg = (int) (deg); // equiv to Math.Truncate + var iDeg = (int)(deg); // equiv to Math.Truncate var dec = deg - iDeg; var mins = dec * 60; - var iMin = (int) (mins); // equiv to Math.Truncate + var iMin = (int)(mins); // equiv to Math.Truncate var secs = Math.Round(deg * 3600 - (iDeg * 3600) - (iMin * 60), 4, MidpointRounding.AwayFromZero); @@ -640,9 +640,9 @@ private static int GetDecimalPlaces(double value, int maxPrecision) /// /// /// Transformed array with z ordinate preserved - private IPoint[] TransformPreserveZ(IMathTransform transform, Coordinate[] coords) + private Point[] TransformPreserveZ(MathTransform transform, Coordinate[] coords) { - var transformed = new IPoint[coords.Length]; + var transformed = new Point[coords.Length]; for (var i = 0; i < coords.Length; i++) { var pt = transform.Transform(coords[i].ToDoubleArray()); @@ -725,7 +725,7 @@ private void RenderGraticuleTicks(Graphics g, IEnumerable graticul matrix.Reset(); matrix.Translate(tick.X, tick.Y, MatrixOrder.Append); - matrix.RotateAt((float) deg, tick, MatrixOrder.Append); + matrix.RotateAt((float)deg, tick, MatrixOrder.Append); g.Transform = matrix; g.DrawPath(def.ImageTickStyle[i] ? style.PrimaryPen : style.SecondaryPen, @@ -764,7 +764,7 @@ private void RenderEdgeCuts(Graphics g, IEnumerable graticuleDefs) // starting cut var dX = def.ImageGraticule[1].X - def.ImageGraticule[0].X; var dY = def.ImageGraticule[1].Y - def.ImageGraticule[0].Y; - var ratio = (float) (margin / Math.Sqrt(Math.Pow(dX, 2) + Math.Pow(dY, 2))); + var ratio = (float)(margin / Math.Sqrt(Math.Pow(dX, 2) + Math.Pow(dY, 2))); pt.X = def.ImageGraticule[0].X + dX * ratio; pt.Y = def.ImageGraticule[0].Y + dY * ratio; @@ -775,7 +775,7 @@ private void RenderEdgeCuts(Graphics g, IEnumerable graticuleDefs) var len = def.ImageGraticule.Length; dX = def.ImageGraticule[len - 2].X - def.ImageGraticule[len - 1].X; dY = def.ImageGraticule[len - 2].Y - def.ImageGraticule[len - 1].Y; - ratio = (float) (margin / Math.Sqrt(Math.Pow(dX, 2) + Math.Pow(dY, 2))); + ratio = (float)(margin / Math.Sqrt(Math.Pow(dX, 2) + Math.Pow(dY, 2))); pt.X = def.ImageGraticule[len - 1].X + dX * ratio; pt.Y = def.ImageGraticule[len - 1].Y + dY * ratio; @@ -855,30 +855,30 @@ private LabelEnds GetLabelEnds(GraticuleStyle style, GraticuleDef def, float map case var _ when mapTransformRotation.Equals((0f)): case var _ when mapTransformRotation > 325f || mapTransformRotation <= 45f: - if (((int) style.LabelBorders & (int) MapDecorationAnchorFlags.Left) > 0) + if (((int)style.LabelBorders & (int)MapDecorationAnchorFlags.Left) > 0) ends |= LabelEnds.Start; - if (((int) style.LabelBorders & (int) MapDecorationAnchorFlags.Right) > 0) + if (((int)style.LabelBorders & (int)MapDecorationAnchorFlags.Right) > 0) ends |= LabelEnds.End; break; case var _ when mapTransformRotation > 45f && mapTransformRotation <= 135f: - if (((int) style.LabelBorders & (int) MapDecorationAnchorFlags.Top) > 0) + if (((int)style.LabelBorders & (int)MapDecorationAnchorFlags.Top) > 0) ends |= LabelEnds.Start; - if (((int) style.LabelBorders & (int) MapDecorationAnchorFlags.Bottom) > 0) + if (((int)style.LabelBorders & (int)MapDecorationAnchorFlags.Bottom) > 0) ends |= LabelEnds.End; break; case var _ when mapTransformRotation > 135 && mapTransformRotation <= 225f: - if (((int) style.LabelBorders & (int) MapDecorationAnchorFlags.Right) > 0) + if (((int)style.LabelBorders & (int)MapDecorationAnchorFlags.Right) > 0) ends |= LabelEnds.Start; - if (((int) style.LabelBorders & (int) MapDecorationAnchorFlags.Left) > 0) + if (((int)style.LabelBorders & (int)MapDecorationAnchorFlags.Left) > 0) ends |= LabelEnds.End; break; case var _ when mapTransformRotation > 225 && mapTransformRotation <= 325: - if (((int) style.LabelBorders & (int) MapDecorationAnchorFlags.Bottom) > 0) + if (((int)style.LabelBorders & (int)MapDecorationAnchorFlags.Bottom) > 0) ends |= LabelEnds.Start; - if (((int) style.LabelBorders & (int) MapDecorationAnchorFlags.Top) > 0) + if (((int)style.LabelBorders & (int)MapDecorationAnchorFlags.Top) > 0) ends |= LabelEnds.End; break; } @@ -889,30 +889,30 @@ private LabelEnds GetLabelEnds(GraticuleStyle style, GraticuleDef def, float map case var _ when mapTransformRotation.Equals((0f)): case var _ when mapTransformRotation > 325f || mapTransformRotation <= 45f: - if (((int) style.LabelBorders & (int) MapDecorationAnchorFlags.Bottom) > 0) + if (((int)style.LabelBorders & (int)MapDecorationAnchorFlags.Bottom) > 0) ends |= LabelEnds.Start; - if (((int) style.LabelBorders & (int) MapDecorationAnchorFlags.Top) > 0) + if (((int)style.LabelBorders & (int)MapDecorationAnchorFlags.Top) > 0) ends |= LabelEnds.End; break; case var _ when mapTransformRotation > 45f && mapTransformRotation <= 135f: - if (((int) style.LabelBorders & (int) MapDecorationAnchorFlags.Left) > 0) + if (((int)style.LabelBorders & (int)MapDecorationAnchorFlags.Left) > 0) ends |= LabelEnds.Start; - if (((int) style.LabelBorders & (int) MapDecorationAnchorFlags.Right) > 0) + if (((int)style.LabelBorders & (int)MapDecorationAnchorFlags.Right) > 0) ends |= LabelEnds.End; break; case var _ when mapTransformRotation > 135 && mapTransformRotation <= 225f: - if (((int) style.LabelBorders & (int) MapDecorationAnchorFlags.Top) > 0) + if (((int)style.LabelBorders & (int)MapDecorationAnchorFlags.Top) > 0) ends |= LabelEnds.Start; - if (((int) style.LabelBorders & (int) MapDecorationAnchorFlags.Bottom) > 0) + if (((int)style.LabelBorders & (int)MapDecorationAnchorFlags.Bottom) > 0) ends |= LabelEnds.End; break; case var _ when mapTransformRotation > 225 && mapTransformRotation <= 325: - if (((int) style.LabelBorders & (int) MapDecorationAnchorFlags.Right) > 0) + if (((int)style.LabelBorders & (int)MapDecorationAnchorFlags.Right) > 0) ends |= LabelEnds.Start; - if (((int) style.LabelBorders & (int) MapDecorationAnchorFlags.Left) > 0) + if (((int)style.LabelBorders & (int)MapDecorationAnchorFlags.Left) > 0) ends |= LabelEnds.End; break; } @@ -929,7 +929,7 @@ private LabelEnds GetLabelEnds(GraticuleStyle style, GraticuleDef def, float map /// Graticule Style /// estimated label size from g.MeasureString /// the end of the line to be labelled - private void RenderLabel(Graphics g, Matrix matrix, GraticuleDef def, GraticuleStyle style, + private void RenderLabel(Graphics g, Matrix matrix, GraticuleDef def, GraticuleStyle style, SizeF labelSize, LabelEnds thisEnd) { var origin = thisEnd == LabelEnds.Start ? def.ImageGraticule.First() : def.ImageGraticule.Last(); @@ -938,7 +938,7 @@ private void RenderLabel(Graphics g, Matrix matrix, GraticuleDef def, GraticuleS // NB invert Y axis var rad = Math.Atan2(-1 * (orientOn.Y - origin.Y), orientOn.X - origin.X); if (rad < 0) rad += 2 * Math.PI; - var deg = (float) Radians.ToDegrees(rad); + var deg = (float)Radians.ToDegrees(rad); if (deg < 0) deg += 360f; var offset = def.IsPrimary ? style.PrimaryLabelOffset : style.SecondaryLabelOffset; @@ -972,7 +972,7 @@ private void RenderLabel(Graphics g, Matrix matrix, GraticuleDef def, GraticuleS def.IsPrimary ? style.PrimaryLabelColor : style.SecondaryLabelColor, origin); } - + /// /// Render web mercator scale distortion meridians /// @@ -999,16 +999,16 @@ private void RenderScaleLineLabels(Graphics g, List graticuleDefs, PcsGraticuleStyle.PrimaryMargin + PcsGraticuleStyle.PrimaryLabelOffset.X); var dictIntersections = new Dictionary>(); - + for (var i = 0; i < sides.Length; i++) { - var side = sides[i]; + var side = sides[i]; // check to see if this is one of the borders to be labelled - if (((int) side & (int) PcsGraticuleStyle.LabelBorders) == 0) continue; + if (((int)side & (int)PcsGraticuleStyle.LabelBorders) == 0) continue; // perform intersection in world units - dictIntersections[side] = CalculateScaleLineIntersections(filteredDefs, (LineString) intersectionLines[i]); + dictIntersections[side] = CalculateScaleLineIntersections(filteredDefs, (LineString)intersectionLines[i]); } // determine label size in world units @@ -1067,7 +1067,7 @@ private void RenderScaleLineLabels(Graphics g, List graticuleDefs, g.Transform = oldTransform; } - + /// /// Construct lines inset from image border, then convert to world units to /// be used for calculating intersections with graticule lines in world units @@ -1081,7 +1081,7 @@ private MultiLineString GetIntersectionLines(Graphics g, MapViewport map, MapDec int margin) { // Image space - var pts = new [] + var pts = new[] { new PointF(g.ClipBounds.Left + margin, g.ClipBounds.Bottom), // left side new PointF(g.ClipBounds.Left + margin, g.ClipBounds.Top), @@ -1097,23 +1097,23 @@ private MultiLineString GetIntersectionLines(Graphics g, MapViewport map, MapDec var coords = map.ImageToWorld(pts, true); // construct world lines - var lines = new ILineString[4]; + var lines = new LineString[4]; for (var i = 0; i < sides.Length; i++) { var side = sides[i]; switch (side) { case MapDecorationAnchorFlags.Left: - lines[i] = new LineString(new[] {coords[0], coords[1]}); // left + lines[i] = new LineString(new[] { coords[0], coords[1] }); // left break; case MapDecorationAnchorFlags.Top: - lines[i] = new LineString(new[] {coords[2], coords[3]}); // top + lines[i] = new LineString(new[] { coords[2], coords[3] }); // top break; case MapDecorationAnchorFlags.Right: - lines[i] = new LineString(new[] {coords[4], coords[5]}); // right + lines[i] = new LineString(new[] { coords[4], coords[5] }); // right break; case MapDecorationAnchorFlags.Bottom: - lines[i] = new LineString(new[] {coords[6], coords[7]}); // bottom + lines[i] = new LineString(new[] { coords[6], coords[7] }); // bottom break; } } @@ -1185,11 +1185,11 @@ private void InitCoordinateSystem(int mapSrid) case null: return; - case IGeographicCoordinateSystem _: + case GeographicCoordinateSystem _: _gcsDomain = GetCrsDomain(_coordinateSystem); return; - case IProjectedCoordinateSystem pcs: + case ProjectedCoordinateSystem pcs: _pcsDomain = GetCrsDomain(pcs); _gcsDomain = _srid == GeoSpatialMath.WebMercatorSrid @@ -1220,7 +1220,7 @@ private void InitCoordinateSystem(int mapSrid) /// /// /// Crs Domain envelope, or null Envelope if not defined and cannot be derived - private Envelope GetCrsDomain(ICoordinateSystem crs) + private Envelope GetCrsDomain(CoordinateSystem crs) { if (crs.DefaultEnvelope != null && crs.DefaultEnvelope.Length == 4) // supplied PCS constraints (currently not defined on any coordinate systems) @@ -1232,7 +1232,7 @@ private Envelope GetCrsDomain(ICoordinateSystem crs) if (crs.AuthorityCode == GeoSpatialMath.WebMercatorSrid) return GeoSpatialMath.WebMercatorEnv; - if (crs is IGeographicCoordinateSystem) + if (crs is GeographicCoordinateSystem) return new Envelope(-180, 180, -90, 90); return new Envelope(); @@ -1256,9 +1256,9 @@ private void CalculateMetrics(Graphics g, MapViewport map, bool webMercatorScale _oldGcsNumSubdivisions = GcsGraticuleStyle.NumSubdivisions; _oldPcsGraticuleMode = PcsGraticuleMode; - _mapScale = map.GetMapScale((int) g.DpiX); + _mapScale = map.GetMapScale((int)g.DpiX); - if (_coordinateSystem is IProjectedCoordinateSystem) + if (_coordinateSystem is ProjectedCoordinateSystem) { // pcsConstrExtents is expanded to the next multiple of division _pcsConstrExtents = CalcPcsConstrExtents(_oldViewExtents, webMercatorScaleLinesActive); @@ -1267,20 +1267,20 @@ private void CalculateMetrics(Graphics g, MapViewport map, bool webMercatorScale try { var coords = _unProject.TransformList( - new List() + new[] { _oldViewExtents.BottomLeft(), _oldViewExtents.TopLeft(), _oldViewExtents.TopRight(), _oldViewExtents.BottomRight() - }); + }.Select(c => new[] { c.X, c.Y }).ToArray()); _gcsConstrExtents = CalcGcsConstrExtents( new Envelope( - coords.Min(c => c.X), - coords.Max(c => c.X), - coords.Min(c => c.Y), - coords.Max(c => c.Y) + coords.Min(c => c[0]), + coords.Max(c => c[0]), + coords.Min(c => c[1]), + coords.Max(c => c[1]) )); } catch (Exception ex) @@ -1308,12 +1308,12 @@ private void CalculateMetrics(Graphics g, MapViewport map, bool webMercatorScale var at = AffineTransformation.RotationInstance( Degrees.ToRadians(map.MapTransformRotation), map.Center.X, map.Center.Y); - _viewClipPolygon = (Polygon) at.Transform(_viewClipPolygon); + _viewClipPolygon = (Polygon)at.Transform(_viewClipPolygon); } // special handling for Web Mercator to ensure curved meridian lines are correctly trimmed if (_srid == GeoSpatialMath.WebMercatorSrid && _viewClipPolygon.Intersects(_webMercatorClipPolygon)) - _viewClipPolygon = (Polygon) _viewClipPolygon.Intersection(_webMercatorClipPolygon); + _viewClipPolygon = (Polygon)_viewClipPolygon.Intersection(_webMercatorClipPolygon); } /// diff --git a/SharpMap/Rendering/Decoration/Graticule/GraticuleStyle.cs b/SharpMap/Rendering/Decoration/Graticule/GraticuleStyle.cs index e2b2288d..14f04d63 100644 --- a/SharpMap/Rendering/Decoration/Graticule/GraticuleStyle.cs +++ b/SharpMap/Rendering/Decoration/Graticule/GraticuleStyle.cs @@ -1,6 +1,6 @@ +using SharpMap.Styles; using System.Drawing; using System.Drawing.Drawing2D; -using SharpMap.Styles; namespace SharpMap.Rendering.Decoration.Graticule { @@ -58,7 +58,7 @@ public int PrimaryTickSize { _primaryTickSize = value; _isDirty = true; - } + } } /// @@ -151,13 +151,13 @@ public int SecondaryTickSize /// /// True if secondary edge cuts (ie subdivisions) should be labelled in addition to primary labels (ie division)/> /// - public bool LabelSubdivisions { get; set; } + public bool LabelSubdivisions { get; set; } /// /// Background color to assist reading labels, or null for no halo /// public Brush LabelHalo { get; set; } - + /// /// Interval between Primary graticule lines (calculated to provide at least 2 cuts along shortest border) /// @@ -195,8 +195,8 @@ public int SecondaryTickSize /// /// /// - public GraticuleStyle(GraticuleTheme theme, - GraticuleLineStyle lineStyle, + public GraticuleStyle(GraticuleTheme theme, + GraticuleLineStyle lineStyle, bool withSecondaryIntervals, GraticuleBorders labelBorders) : this() { @@ -225,14 +225,14 @@ public GraticuleStyle(GraticuleTheme theme, SecondaryLabelOffset = new Point(2, 1); LabelBorders = labelBorders; - LabelHalo = Brushes.AliceBlue; + LabelHalo = Brushes.AliceBlue; LabelSubdivisions = true; break; default: - + PrimaryPen = new Pen(Brushes.Gray, 2); PrimaryLineStyle = lineStyle; PrimaryTickSize = 10; @@ -251,7 +251,7 @@ public GraticuleStyle(GraticuleTheme theme, SecondaryLabelFont = new Font(FontFamily.GenericSansSerif, 6, FontStyle.Regular); SecondaryLabelColor = Brushes.LightGray; - SecondaryLabelOffset = new Point(SecondaryMargin + 1, -1 - SecondaryLabelFont.Height/2 ); + SecondaryLabelOffset = new Point(SecondaryMargin + 1, -1 - SecondaryLabelFont.Height / 2); LabelBorders = labelBorders; LabelHalo = Brushes.Gainsboro; // Brushes.PowderBlue; @@ -270,8 +270,8 @@ public GraticuleStyle(GraticuleTheme theme, /// /// Creates an instance of this class. /// - public GraticuleStyle() {} - + public GraticuleStyle() { } + /// /// Returns true if a primary or secondary tick is required for given combination of primary and secondary meridians and parallels /// @@ -284,7 +284,7 @@ public bool IsTickRequired(bool isPrimaryMeridian, bool isPrimaryParallel) return SecondaryLineStyle == GraticuleLineStyle.SolidTick || SecondaryLineStyle == GraticuleLineStyle.HollowTick; } - + /// /// Returns the appropriate tick /// @@ -299,7 +299,7 @@ public GraphicsPath GetTick(bool isPrimaryTick) _secondaryTick = CreateTick(SecondaryMargin, SecondaryLineStyle); _isDirty = false; } - + return isPrimaryTick ? _primaryTick : _secondaryTick; } @@ -316,7 +316,7 @@ private GraphicsPath CreateTick(int primaryTickSize, GraticuleLineStyle lineStyl var tickSize50 = primaryTickSize * 0.5f; var tickSize20 = primaryTickSize * 0.2f; - + switch (lineStyle) { case GraticuleLineStyle.SolidTick: @@ -325,7 +325,7 @@ private GraphicsPath CreateTick(int primaryTickSize, GraticuleLineStyle lineStyl points[1] = new PointF(tickSize50, 0); points[2] = new PointF(0, -tickSize50); points[3] = new PointF(0, tickSize50); - + break; case GraticuleLineStyle.HollowTick: points = new PointF[8]; @@ -333,22 +333,22 @@ private GraphicsPath CreateTick(int primaryTickSize, GraticuleLineStyle lineStyl points[1] = new PointF(-tickSize20, 0); points[2] = new PointF(tickSize20, 0); points[3] = new PointF(tickSize50, 0); - - points[4] = new PointF(0,-tickSize50); - points[5] = new PointF(0,-tickSize20); - points[6] = new PointF(0,tickSize20); - points[7] = new PointF(0,tickSize50); + + points[4] = new PointF(0, -tickSize50); + points[5] = new PointF(0, -tickSize20); + points[6] = new PointF(0, tickSize20); + points[7] = new PointF(0, tickSize50); break; - + default: return null; } - + var gp = new GraphicsPath(); for (var i = 0; i < points.Length; i += 2) { gp.StartFigure(); - gp.AddLine(points[i], points[i+1]); + gp.AddLine(points[i], points[i + 1]); } return gp; diff --git a/SharpMap/Rendering/Decoration/MapDecoration.cs b/SharpMap/Rendering/Decoration/MapDecoration.cs index d78197fb..071395ac 100644 --- a/SharpMap/Rendering/Decoration/MapDecoration.cs +++ b/SharpMap/Rendering/Decoration/MapDecoration.cs @@ -119,7 +119,7 @@ protected Color OpacityColor(Color color) public Color BackgroundColor { get; set; } private float _opacity; - + /// /// Gets or sets the opacity of map decoration /// @@ -177,7 +177,7 @@ public float Opacity [Obsolete("Use InternalSize(Graphics, MapViewport")] protected virtual Size InternalSize(Graphics g, Map map) { - return InternalSize(g, (MapViewport) map); + return InternalSize(g, (MapViewport)map); } private void CalcMapDecorationMetrics(Graphics g, MapViewport map) @@ -207,8 +207,8 @@ private static GraphicsPath CreateRoundedRectangle(Rectangle rectangle, Size mar int y1 = rectangle.Top + margin.Height; int y2 = rectangle.Bottom - margin.Height; - int arcWidth = 2*margin.Width; - int arcHeight = 2*margin.Height; + int arcWidth = 2 * margin.Width; + int arcHeight = 2 * margin.Height; if (arcWidth > 0 && arcHeight > 0) { @@ -248,7 +248,7 @@ public void Render(Graphics g, MapViewport mvp) // remove any image to world rotation var oldTransform = g.Transform; g.ResetTransform(); - + //Preparing rendering OnRendering(g, mvp); @@ -273,7 +273,7 @@ public void Render(Graphics g, MapViewport mvp) //Restore old clip region g.Clip = oldClip; - + // restore any image to world rotation g.Transform = oldTransform; @@ -317,7 +317,7 @@ protected virtual void OnRender(Graphics g, MapViewport mvp) [Obsolete("Use OnRender(Graphics, MapViewport")] protected virtual void OnRender(Graphics g, Map map) { - OnRender(g, (MapViewport) map); + OnRender(g, (MapViewport)map); } /// @@ -362,7 +362,7 @@ protected virtual void OnRendered(Graphics g, MapViewport mvp) [Obsolete("Use OnRendered(Graphics, MapViewport")] protected virtual void OnRendered(Graphics g, Map map) { - OnRendered(g, (MapViewport) map); + OnRendered(g, (MapViewport)map); } } } diff --git a/SharpMap/Rendering/Decoration/MapDecorationAnchorFlags.cs b/SharpMap/Rendering/Decoration/MapDecorationAnchorFlags.cs index e03dc492..d4dfe173 100644 --- a/SharpMap/Rendering/Decoration/MapDecorationAnchorFlags.cs +++ b/SharpMap/Rendering/Decoration/MapDecorationAnchorFlags.cs @@ -12,7 +12,7 @@ public enum MapDecorationAnchorFlags /// No anchor specified /// None = 0, - + /// /// Left anchor /// @@ -47,12 +47,12 @@ public enum MapDecorationAnchorFlags /// /// Vertical = Top | VerticalCenter | Bottom, - + /// /// /// Horizontal = Left | HorizontalCenter | Right } - + } \ No newline at end of file diff --git a/SharpMap/Rendering/Decoration/NorthArrow.cs b/SharpMap/Rendering/Decoration/NorthArrow.cs index 2eb30fdf..978eec2e 100644 --- a/SharpMap/Rendering/Decoration/NorthArrow.cs +++ b/SharpMap/Rendering/Decoration/NorthArrow.cs @@ -1,8 +1,8 @@ -using System; +using SharpMap.Utilities; +using System; using System.Drawing; using System.Drawing.Drawing2D; using System.Drawing.Imaging; -using SharpMap.Utilities; namespace SharpMap.Rendering.Decoration { @@ -17,24 +17,24 @@ public class NorthArrow : MapDecoration static NorthArrow() { - lock(_lockObject) + lock (_lockObject) { DefaultNorthArrowBitmap = new Bitmap(120, 120); using (var g = Graphics.FromImage(DefaultNorthArrowBitmap)) { g.Clear(Color.Transparent); var b = new SolidBrush(Color.Black); - var p = new Pen(new SolidBrush(Color.Black), 10) {LineJoin = LineJoin.Miter}; + var p = new Pen(new SolidBrush(Color.Black), 10) { LineJoin = LineJoin.Miter }; g.FillEllipse(b, new RectangleF(50, 50, 20, 20)); g.DrawLine(p, 60, 110, 60, 40); - var pts = new[] {new PointF(45, 40), new PointF(60, 10), new PointF(75, 40), new PointF(45, 40)}; + var pts = new[] { new PointF(45, 40), new PointF(60, 10), new PointF(75, 40), new PointF(45, 40) }; g.FillPolygon(b, pts); g.DrawPolygon(p, pts); b = new SolidBrush(Color.White); g.DrawString("N", new Font(FontFamily.GenericSansSerif, 20, FontStyle.Bold, GraphicsUnit.Pixel), b, new RectangleF(50, 25, 20, 20), new StringFormat - {LineAlignment = StringAlignment.Center, Alignment = StringAlignment.Center}); + { LineAlignment = StringAlignment.Center, Alignment = StringAlignment.Center }); } } } @@ -83,35 +83,35 @@ protected override void OnRender(Graphics g, MapViewport mvp) var mapSize = mvp.Size; //Get rotation - var ptTop = mvp.ImageToWorld(new PointF(mapSize.Width/2f, 0f),true); + var ptTop = mvp.ImageToWorld(new PointF(mapSize.Width / 2f, 0f), true); var ptBottom = mvp.ImageToWorld(new PointF(mapSize.Width / 2f, mapSize.Height * 0.5f), true); var dx = ptTop.X - ptBottom.X; var dy = ptBottom.Y - ptTop.Y; - var length = Math.Sqrt(dx*dx + dy*dy); + var length = Math.Sqrt(dx * dx + dy * dy); - var cos = dx/length; + var cos = dx / length; var rot = -90 + (dy > 0 ? -1 : 1) * Math.Acos(cos) / GeoSpatialMath.DegToRad; - var halfSize = new Size((int)(0.5f*Size.Width), (int)(0.5f*Size.Height)); + var halfSize = new Size((int)(0.5f * Size.Width), (int)(0.5f * Size.Height)); //var oldTransform = g.Transform; - + var clip = g.ClipBounds; - var newTransform = new Matrix(1f, 0f, 0f, 1f, + var newTransform = new Matrix(1f, 0f, 0f, 1f, clip.Left + halfSize.Width, clip.Top + halfSize.Height); newTransform.Rotate((float)rot); // Setup image attributes var ia = new ImageAttributes(); - var cmap = new [] { + var cmap = new[] { new ColorMap { OldColor = Color.Transparent, NewColor = OpacityColor(BackgroundColor) }, new ColorMap { OldColor = Color.Black, NewColor = OpacityColor(ForeColor) } }; - ia.SetRemapTable( cmap ); + ia.SetRemapTable(cmap); g.Transform = newTransform; - + var rect = new Rectangle(-halfSize.Width, -halfSize.Height, Size.Width, Size.Height); g.DrawImage(image, rect, 0, 0, image.Size.Width, image.Size.Height, GraphicsUnit.Pixel, ia); diff --git a/SharpMap/Rendering/Decoration/ScaleBar/ScaleBar.cs b/SharpMap/Rendering/Decoration/ScaleBar/ScaleBar.cs index 798a25cc..1adba033 100644 --- a/SharpMap/Rendering/Decoration/ScaleBar/ScaleBar.cs +++ b/SharpMap/Rendering/Decoration/ScaleBar/ScaleBar.cs @@ -1,7 +1,7 @@ -using System; +using SharpMap.Utilities; +using System; using System.Collections.Generic; using System.Drawing; -using SharpMap.Utilities; namespace SharpMap.Rendering.Decoration.ScaleBar { @@ -134,7 +134,7 @@ protected override Size InternalSize(Graphics g, MapViewport mvp) protected override void OnRender(Graphics g, MapViewport mvp) { var rectF = g.ClipBounds; - + if (MapUnit == (int)Unit.Degree) { // do not use map.Envelope as this is not apparent width on rotated viewports @@ -149,7 +149,7 @@ protected override void OnRender(Graphics g, MapViewport mvp) switch (mvp.SRID) { - case 3857: + case 3857: //other spherical variations (all of which are deprecated except 900913): 900913 54004 41001 102113 102100 3785 // constrain to 85deg N/S @@ -464,8 +464,8 @@ private static void RenderTicBarMeridian1(Graphics g, int nNumTics, int nBarWidt } } -private void CalcLargeOrSmallUnit(int dpi, int widthOnDevice, int numTics, double mapScale, double fBarUnitFactor, - out int pixelsPerTic, out double scaleBarUnitsPerTic) + private void CalcLargeOrSmallUnit(int dpi, int widthOnDevice, int numTics, double mapScale, double fBarUnitFactor, + out int pixelsPerTic, out double scaleBarUnitsPerTic) { if (_forceRecalc) { @@ -668,7 +668,7 @@ private void CalcScale(int dpi) fScale = ScaleCalculations.CalculateScaleNonLatLong(_mapWidth, _pageWidth, _mapUnitFactor, dpi); Scale = fScale; } - + private void SetScaleD(int dpi, double lon1, double lon2, double lat, int widthInPixel) { _lon1 = lon1; @@ -977,7 +977,7 @@ public double Scale private set { if (_scale == value) return; - + _scale = value; OnViewChanged(); } @@ -996,7 +996,7 @@ public void SetCustomUnit(double factor, string name, string shortName) if (factor <= 0.0) //factor should be >0 factor = 1.0; - ScaleBar.Units[(int)Unit.Custom] = new UnitInfo((int)Unit.Custom, factor, name, shortName); + ScaleBar.Units[(int)Unit.Custom] = new UnitInfo((int)Unit.Custom, factor, name, shortName); MapUnit = (int)Unit.Custom; _barUnitLargeScale = (int)Unit.Custom; @@ -1030,7 +1030,7 @@ private void GetBarUnitInfo(out double factor, out string name, out string short } */ - + /// /// Gets or sets the number of ticks @@ -1148,7 +1148,7 @@ public UnitInfo(int unit, double toMeter, string name, string abbreviation) } #region Private static helpers - + //for multipliers ranging from .00001 to 10000000000 // Candidates are 1, 2, 2.5, and 5 * multiplier diff --git a/SharpMap/Rendering/Decoration/ScaleBar/Unit.cs b/SharpMap/Rendering/Decoration/ScaleBar/Unit.cs index 534ec979..68ad3be3 100644 --- a/SharpMap/Rendering/Decoration/ScaleBar/Unit.cs +++ b/SharpMap/Rendering/Decoration/ScaleBar/Unit.cs @@ -35,7 +35,7 @@ public enum Unit /// Kilometer /// Kilometer, - + /// /// Degree /// diff --git a/SharpMap/Rendering/Label.cs b/SharpMap/Rendering/Label.cs index 0884af0d..01c0de54 100644 --- a/SharpMap/Rendering/Label.cs +++ b/SharpMap/Rendering/Label.cs @@ -15,12 +15,12 @@ // along with SharpMap; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +using NetTopologySuite.Geometries; +using SharpMap.Styles; using System; using System.Collections.Generic; using System.Drawing; using System.Drawing.Drawing2D; -using GeoAPI.Geometries; -using SharpMap.Styles; namespace SharpMap.Rendering { @@ -112,7 +112,7 @@ public float Bottom { get { return _top - _height; } } - + #region IComparable Members /// @@ -205,7 +205,7 @@ protected BaseLabel(string text, float rotation, int priority, _Text = text; //_LabelPoint = labelpoint; _Rotation = rotation; - _Priority = priority; + _Priority = priority; _Style = style; _show = true; } @@ -282,10 +282,10 @@ public LabelStyle Style /// public virtual int CompareTo(BaseLabel other) { -// if (this.TextOnPathLabel != null) -// { -// return CompareToTextOnPath(other); -// } + // if (this.TextOnPathLabel != null) + // { + // return CompareToTextOnPath(other); + // } if (this == other) return 0; if (_box == null) @@ -294,33 +294,33 @@ public virtual int CompareTo(BaseLabel other) return 1; return _box.CompareTo(other.Box); } -// private int CompareToTextOnPath(BaseLabel other) -// { -// if (this == other) -// return 0; -// if (TextOnPathLabel == null) -// return -1; -// if (other.TextOnPathLabel == null) -// return 1; -// -// for (int i = 0; i < TextOnPathLabel.RegionList.Count; i++) -// { -// for (int j = 0; j < other.TextOnPathLabel.RegionList.Count; j++) -// { -// if (TextOnPathLabel.RegionList[i].IntersectsWith(other.TextOnPathLabel.RegionList[j])) -// return 0; -// } -// } -// if (_box == null) -// return -1; -// if (other.Box == null) -// return 1; -// if (other.Box.Left > this.Box.Right || -// other.Box.Bottom > this.Box.Top) -// return 1; -// else -// return -1; -// } + // private int CompareToTextOnPath(BaseLabel other) + // { + // if (this == other) + // return 0; + // if (TextOnPathLabel == null) + // return -1; + // if (other.TextOnPathLabel == null) + // return 1; + // + // for (int i = 0; i < TextOnPathLabel.RegionList.Count; i++) + // { + // for (int j = 0; j < other.TextOnPathLabel.RegionList.Count; j++) + // { + // if (TextOnPathLabel.RegionList[i].IntersectsWith(other.TextOnPathLabel.RegionList[j])) + // return 0; + // } + // } + // if (_box == null) + // return -1; + // if (other.Box == null) + // return 1; + // if (other.Box.Left > this.Box.Right || + // other.Box.Bottom > this.Box.Top) + // return 1; + // else + // return -1; + // } #endregion @@ -359,7 +359,7 @@ protected BaseLabel(string text, T location, float rotation, int priority, Label : base(text, rotation, priority, collisionbox, style) { //if (typeof(T) is ValueType) - if (location==null) + if (location == null) return; if (!(location is PointF || location is GraphicsPath)) @@ -413,7 +413,7 @@ public PathLabel(string text, GraphicsPath location, float rotation, int priorit /// /// Bounding polygon in world coordinates /// - public IPolygon AffectedArea { get; set; } + public Polygon AffectedArea { get; set; } /// public override int CompareTo(BaseLabel other) @@ -468,6 +468,6 @@ public PointF LabelPoint get; set; } - + } } diff --git a/SharpMap/Rendering/LabelCollisionDetection.cs b/SharpMap/Rendering/LabelCollisionDetection.cs index 6f7ee0f9..a07b11d6 100644 --- a/SharpMap/Rendering/LabelCollisionDetection.cs +++ b/SharpMap/Rendering/LabelCollisionDetection.cs @@ -15,12 +15,12 @@ // along with SharpMap; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +using System; using System.Collections.Generic; using System.Linq; -using System; namespace SharpMap.Rendering -{ +{ /// /// Class defining delegate for label collision detection and static predefined methods /// diff --git a/SharpMap/Rendering/LayerCollectionRenderer.cs b/SharpMap/Rendering/LayerCollectionRenderer.cs index 2fbbae29..e10f1f6b 100644 --- a/SharpMap/Rendering/LayerCollectionRenderer.cs +++ b/SharpMap/Rendering/LayerCollectionRenderer.cs @@ -1,13 +1,13 @@ -using System; +using Common.Logging; +using SharpMap.Layers; +using SharpMap.Styles; +using System; using System.Collections.Generic; using System.Drawing; using System.Drawing.Drawing2D; using System.Drawing.Imaging; using System.Runtime.CompilerServices; using System.Threading.Tasks; -using Common.Logging; -using SharpMap.Layers; -using SharpMap.Styles; namespace SharpMap.Rendering { @@ -119,7 +119,7 @@ private void RenderParellel(Graphics g) _images = new Image[_layers.Length]; var res = Parallel.For(0, _layers.Length, RenderToImage); - + var tmpTransform = g.Transform; g.Transform = new Matrix(); if (res.IsCompleted) @@ -142,7 +142,7 @@ private void RenderToImage(int layerIndex, ParallelLoopState pls) return; var layer = _layers[layerIndex]; - + if (layer.Enabled) { double compare = layer.VisibilityUnits == VisibilityUnits.ZoomLevel ? _mapViewPort.Zoom : _mapScale; @@ -152,10 +152,10 @@ private void RenderToImage(int layerIndex, ParallelLoopState pls) using (var g = Graphics.FromImage(image)) { g.PageUnit = GraphicsUnit.Pixel; - ApplyTransform(_mapViewPort.MapTransform , g); + ApplyTransform(_mapViewPort.MapTransform, g); g.Clear(Color.Transparent); - RenderLayer(layer, g, _mapViewPort ); + RenderLayer(layer, g, _mapViewPort); } } } @@ -182,10 +182,10 @@ public static void RenderLayer(ILayer layer, Graphics g, MapViewport mapViewport var size = mapViewport.Size; g.DrawLine(pen, 0, 0, size.Width, size.Height); - g.DrawLine(pen, size.Width,0, 0, size.Height); + g.DrawLine(pen, size.Width, 0, 0, size.Height); g.DrawRectangle(pen, 0, 0, size.Width, size.Height); } - + } } @@ -202,7 +202,7 @@ public void Dispose() { foreach (var image in _images) { - if (image != null)image.Dispose(); + if (image != null) image.Dispose(); } } } diff --git a/SharpMap/Rendering/Symbolizer/BaseSymbolizer.cs b/SharpMap/Rendering/Symbolizer/BaseSymbolizer.cs index 21ad5f49..80951a6a 100644 --- a/SharpMap/Rendering/Symbolizer/BaseSymbolizer.cs +++ b/SharpMap/Rendering/Symbolizer/BaseSymbolizer.cs @@ -1,7 +1,7 @@ +using SharpMap.Base; using System; using System.Drawing; using System.Drawing.Drawing2D; -using SharpMap.Base; namespace SharpMap.Rendering.Symbolizer { diff --git a/SharpMap/Rendering/Symbolizer/BasicLineSymbolizer.cs b/SharpMap/Rendering/Symbolizer/BasicLineSymbolizer.cs index 5899f2b0..fde3b1bb 100644 --- a/SharpMap/Rendering/Symbolizer/BasicLineSymbolizer.cs +++ b/SharpMap/Rendering/Symbolizer/BasicLineSymbolizer.cs @@ -1,6 +1,6 @@ +using NetTopologySuite.Geometries; using System; using System.Drawing; -using GeoAPI.Geometries; namespace SharpMap.Rendering.Symbolizer { @@ -17,7 +17,7 @@ public class BasicLineSymbolizer : LineSymbolizer /// A symbolizer exactly like this one public override object Clone() { - return new BasicLineSymbolizer {Line = (Pen) Line.Clone()}; + return new BasicLineSymbolizer { Line = (Pen)Line.Clone() }; } /// @@ -26,7 +26,7 @@ public override object Clone() /// The map /// The linestring /// The graphics object - protected override void OnRenderInternal(MapViewport map, ILineString lineString, Graphics graphics) + protected override void OnRenderInternal(MapViewport map, LineString lineString, Graphics graphics) { graphics.DrawLines(Line, VectorRenderer.LimitValues(lineString.TransformToImage(map), VectorRenderer.ExtremeValueLimit)); } @@ -46,7 +46,7 @@ public class BasicLineSymbolizerWithOffset : LineSymbolizer /// A symbolizer exactly like this one public override object Clone() { - return new BasicLineSymbolizerWithOffset {Line = (Pen) Line.Clone(), Offset = Offset}; + return new BasicLineSymbolizerWithOffset { Line = (Pen)Line.Clone(), Offset = Offset }; } /// @@ -60,7 +60,7 @@ public override object Clone() /// The map /// The linestring /// The graphics object - protected override void OnRenderInternal(MapViewport map, ILineString lineString, Graphics graphics) + protected override void OnRenderInternal(MapViewport map, LineString lineString, Graphics graphics) { var pts = VectorRenderer.LimitValues(VectorRenderer.OffsetRight(lineString.TransformToImage(map), Offset), VectorRenderer.ExtremeValueLimit); graphics.DrawLines(Line, pts); @@ -68,4 +68,4 @@ protected override void OnRenderInternal(MapViewport map, ILineString lineString } -} \ No newline at end of file +} diff --git a/SharpMap/Rendering/Symbolizer/BasicPolygonSymbolizer.cs b/SharpMap/Rendering/Symbolizer/BasicPolygonSymbolizer.cs index d011d818..40c3ec34 100644 --- a/SharpMap/Rendering/Symbolizer/BasicPolygonSymbolizer.cs +++ b/SharpMap/Rendering/Symbolizer/BasicPolygonSymbolizer.cs @@ -1,6 +1,6 @@ +using NetTopologySuite.Geometries; using System; using System.Drawing; -using GeoAPI.Geometries; namespace SharpMap.Rendering.Symbolizer { @@ -49,12 +49,12 @@ protected override void ReleaseManagedResources() public override object Clone() { return new BasicPolygonSymbolizer - { - Fill = (Brush) Fill.Clone(), - Outline = (Pen) Outline.Clone(), - RenderOrigin = RenderOrigin, - UseClipping = UseClipping, - }; + { + Fill = (Brush)Fill.Clone(), + Outline = (Pen)Outline.Clone(), + RenderOrigin = RenderOrigin, + UseClipping = UseClipping, + }; } /// @@ -63,7 +63,7 @@ public override object Clone() /// The map /// The feature /// The graphics object - protected override void OnRenderInternal(MapViewport map, IPolygon polygon, Graphics g) + protected override void OnRenderInternal(MapViewport map, Polygon polygon, Graphics g) { // convert points var pts = /*LimitValues(*/polygon.TransformToImage(map, UseClipping)/*)*/; @@ -71,11 +71,11 @@ protected override void OnRenderInternal(MapViewport map, IPolygon polygon, Grap //// clip //if (UseClipping) // pts = VectorRenderer.ClipPolygon(pts, map.Size.Width, map.Size.Height); - + // fill the polygon if (Fill != null) g.FillPath(Fill, pts); - + // outline the polygon if (Outline != null) g.DrawPath(Outline, pts); @@ -126,12 +126,12 @@ protected override void ReleaseManagedResources() public override object Clone() { return new PolygonSymbolizerUsingLineSymbolizer - { - Fill = (Brush) Fill.Clone(), - Outline = (LineSymbolizer) Outline.Clone(), - RenderOrigin = RenderOrigin, - UseClipping = UseClipping - }; + { + Fill = (Brush)Fill.Clone(), + Outline = (LineSymbolizer)Outline.Clone(), + RenderOrigin = RenderOrigin, + UseClipping = UseClipping + }; } /// @@ -140,11 +140,11 @@ public override object Clone() /// The map /// The polygon to render /// The graphics object to use - protected override void OnRenderInternal(MapViewport map, IPolygon polygon, Graphics g) + protected override void OnRenderInternal(MapViewport map, Polygon polygon, Graphics g) { // convert points var pts = /*VectorRenderer.LimitValues*(*/polygon.TransformToImage(map)/*, VectorRenderer.ExtremeValueLimit))*/; - + //// clip //if (UseClipping) // pts = VectorRenderer.ClipPolygon(pts, map.Size.Width, map.Size.Height); @@ -157,7 +157,7 @@ protected override void OnRenderInternal(MapViewport map, IPolygon polygon, Grap if (Outline != null) { Outline.Render(map, polygon.ExteriorRing, g); - foreach( var ls in polygon.InteriorRings ) + foreach (var ls in polygon.InteriorRings) Outline.Render(map, ls, g); } } @@ -196,4 +196,4 @@ public override void End(Graphics g, MapViewport map) base.End(g, map); } } -} \ No newline at end of file +} diff --git a/SharpMap/Rendering/Symbolizer/CachedLineSymbolizer.cs b/SharpMap/Rendering/Symbolizer/CachedLineSymbolizer.cs index cbab507a..fd99cdd8 100644 --- a/SharpMap/Rendering/Symbolizer/CachedLineSymbolizer.cs +++ b/SharpMap/Rendering/Symbolizer/CachedLineSymbolizer.cs @@ -1,9 +1,9 @@ +using NetTopologySuite.Geometries; +using SharpMap.Base; using System; using System.Collections.Generic; using System.Drawing; using System.Drawing.Drawing2D; -using GeoAPI.Geometries; -using SharpMap.Base; namespace SharpMap.Rendering.Symbolizer { @@ -71,7 +71,7 @@ protected override void ReleaseManagedResources() Fill.Dispose(); if (Pattern != null) Pattern.Dispose(); - + base.ReleaseManagedResources(); } @@ -106,7 +106,7 @@ public void SymbolizePaths(Graphics g, IEnumerable paths) { var clonedPattern = (GraphicsPath)Pattern.Clone(); var warpedPath = WarpPathToPath.Warp(graphicsPath, clonedPattern, true, Interval); - + if (warpedPath == null) continue; if (Fill != null) @@ -125,7 +125,7 @@ public class CachedLineSymbolizer : LineSymbolizer { private List _graphicsPaths; private readonly List _lineSymbolizeHandlers; - private readonly ILineSymbolizeHandler _fallback = new PlainLineSymbolizeHandler {Line = new Pen(Color.Black)}; + private readonly ILineSymbolizeHandler _fallback = new PlainLineSymbolizeHandler { Line = new Pen(Color.Black) }; /// /// Creates an instance of this class /// @@ -156,7 +156,7 @@ protected override void ReleaseManagedResources() if (_fallback != null) _fallback.Dispose(); - + base.ReleaseManagedResources(); } @@ -200,13 +200,13 @@ public List LineSymbolizeHandlers /// /// /// - protected override void OnRenderInternal(MapViewport map, ILineString lineString, Graphics graphics) + protected override void OnRenderInternal(MapViewport map, LineString lineString, Graphics graphics) { var gp = new GraphicsPath(); gp.AddLines(VectorRenderer.LimitValues(lineString.TransformToImage(map), VectorRenderer.ExtremeValueLimit)); if (ImmediateMode) { - var tmp = new List(new[] {gp}); + var tmp = new List(new[] { gp }); Symbolize(graphics, map, tmp); } else @@ -257,4 +257,4 @@ public override void End(Graphics g, MapViewport map) base.End(g, map); } } -} \ No newline at end of file +} diff --git a/SharpMap/Rendering/Symbolizer/CharacterPointSymbolizer.cs b/SharpMap/Rendering/Symbolizer/CharacterPointSymbolizer.cs index 48eaedec..9d8ab938 100644 --- a/SharpMap/Rendering/Symbolizer/CharacterPointSymbolizer.cs +++ b/SharpMap/Rendering/Symbolizer/CharacterPointSymbolizer.cs @@ -30,7 +30,7 @@ public class CharacterPointSymbolizer : PointSymbolizer private string _text; private int _characterIndex; - + /// /// Initializes a new TextPointStyle /// @@ -41,7 +41,7 @@ public CharacterPointSymbolizer() Foreground = Brushes.Firebrick; Halo = 0; HaloBrush = Brushes.Transparent; - StringFormat = new StringFormat(StringFormatFlags.NoClip){ Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center, Trimming = StringTrimming.None }; + StringFormat = new StringFormat(StringFormatFlags.NoClip) { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center, Trimming = StringTrimming.None }; } /// @@ -76,11 +76,11 @@ protected override void ReleaseManagedResources() /// A that matches this instance public override object Clone() { - var res = (CharacterPointSymbolizer) MemberwiseClone(); - res.Font = (Font) Font.Clone(); - res.Foreground = (Brush) Foreground.Clone(); - res.HaloBrush = (Brush) HaloBrush.Clone(); - + var res = (CharacterPointSymbolizer)MemberwiseClone(); + res.Font = (Font)Font.Clone(); + res.Foreground = (Brush)Foreground.Clone(); + res.HaloBrush = (Brush)HaloBrush.Clone(); + return res; } @@ -114,9 +114,9 @@ public override object Clone() /// /// The index of the character, -1 if the is longer than 1 character. /// - public int CharacterIndex + public int CharacterIndex { - get {return _characterIndex;} + get { return _characterIndex; } set { _characterIndex = value; @@ -134,7 +134,7 @@ public string Text { if (string.IsNullOrEmpty(value)) return; - + _text = value; if (_text.Length > 1) @@ -179,7 +179,7 @@ public override Size Size /// /// Gets or sets the scale factor for this symbol
Always returns 1f ///
- public override float Scale + public override float Scale { get { @@ -199,9 +199,9 @@ internal override void OnRenderInternal(PointF pt, Graphics g) { //need to look it up using (var path = new GraphicsPath(FillMode.Winding)) - using (var haloPen = new Pen(HaloBrush, 2 * Halo) {MiterLimit = 1.0f}) + using (var haloPen = new Pen(HaloBrush, 2 * Halo) { MiterLimit = 1.0f }) { - path.AddString(_text, Font.FontFamily, (int) Font.Style, Font.Size, pt, StringFormat); + path.AddString(_text, Font.FontFamily, (int)Font.Style, Font.Size, pt, StringFormat); g.DrawPath(haloPen, path); g.FillPath(Foreground, path); CanvasArea = path.GetBounds(); @@ -212,7 +212,7 @@ internal override void OnRenderInternal(PointF pt, Graphics g) // g.DrawString(_text, Font, Foreground, pt, StringFormat); using (var path = new GraphicsPath(FillMode.Winding)) { - path.AddString(_text, Font.FontFamily, (int) Font.Style, Font.Size, pt, StringFormat); + path.AddString(_text, Font.FontFamily, (int)Font.Style, Font.Size, pt, StringFormat); g.FillPath(Foreground, path); CanvasArea = path.GetBounds(); } diff --git a/SharpMap/Rendering/Symbolizer/CohenSutherlandLineClipping.cs b/SharpMap/Rendering/Symbolizer/CohenSutherlandLineClipping.cs index 586b9237..7b4ed228 100644 --- a/SharpMap/Rendering/Symbolizer/CohenSutherlandLineClipping.cs +++ b/SharpMap/Rendering/Symbolizer/CohenSutherlandLineClipping.cs @@ -1,6 +1,6 @@ +using NetTopologySuite.Geometries; using System; using System.Collections.Generic; -using GeoAPI.Geometries; namespace SharpMap.Rendering.Symbolizer { @@ -20,7 +20,7 @@ private enum OutsideClipCodes Top = 8 } - private readonly double _xmin, _xmax, _ymin, _ymax ; + private readonly double _xmin, _xmax, _ymin, _ymax; /// /// Creates an instance of this class @@ -55,17 +55,17 @@ private OutsideClipCodes ComputeClipCode(double x, double y) } /// - /// Clips a to the bounding box defined by . + /// Clips a to the bounding box defined by . /// /// The line string to clip /// A (possibly multi) line string - public IMultiLineString ClipLineString(ILineString lineString) + public MultiLineString ClipLineString(LineString lineString) { //Factory var factory = lineString.Factory; //List of line strings that make up the multi line string result - var lineStrings = new List(); + var lineStrings = new List(); //list of clipped vertices for current pass var clippedVertices = new List(); @@ -78,10 +78,10 @@ public IMultiLineString ClipLineString(ILineString lineString) double x0, y0; OutsideClipCodes oc0Initial; var oc0 = oc0Initial = ComputeClipCode(vertices[0], out x0, out y0); - + //Point is inside => add it to the list if (oc0 == OutsideClipCodes.Inside) - clippedVertices.Add( vertices[0] ); + clippedVertices.Add(vertices[0]); double x1Old = double.NaN, y1Old = double.NaN; @@ -122,25 +122,25 @@ public IMultiLineString ClipLineString(ILineString lineString) if ((ocOut & OutsideClipCodes.Top) == OutsideClipCodes.Top) { // point is above the clip rectangle - x = x0 + (x1 - x0)*(_ymax - y0)/(y1 - y0); + x = x0 + (x1 - x0) * (_ymax - y0) / (y1 - y0); y = _ymax; } else if ((ocOut & OutsideClipCodes.Bottom) == OutsideClipCodes.Bottom) { // point is below the clip rectangle - x = x0 + (x1 - x0)*(_ymin - y0)/(y1 - y0); + x = x0 + (x1 - x0) * (_ymin - y0) / (y1 - y0); y = _ymin; } else if ((ocOut & OutsideClipCodes.Right) == OutsideClipCodes.Right) { // point is to the right of clip rectangle - y = y0 + (y1 - y0)*(_xmax - x0)/(x1 - x0); + y = y0 + (y1 - y0) * (_xmax - x0) / (x1 - x0); x = _xmax; } else if ((ocOut & OutsideClipCodes.Left) == OutsideClipCodes.Left) { // point is to the left of clip rectangle - y = y0 + (y1 - y0)*(_xmin - x0)/(x1 - x0); + y = y0 + (y1 - y0) * (_xmin - x0) / (x1 - x0); x = _xmin; } // Now we move outside point to intersection point to clip @@ -158,12 +158,12 @@ public IMultiLineString ClipLineString(ILineString lineString) oc1 = ComputeClipCode(x, y); } } - + if (accept) { if (oc0Initial != oc0) clippedVertices.Add(new Coordinate(x0, y0)); - + if (x1Old != x1 || y1Old != y1) clippedVertices.Add(new Coordinate(x1, y1)); @@ -189,22 +189,22 @@ public IMultiLineString ClipLineString(ILineString lineString) /// - /// Clips a to the bounding box defined by . + /// Clips a to the bounding box defined by . /// /// The multi-line string to clip /// A (possibly multi) line string - public IMultiLineString ClipLineString(IMultiLineString lineStrings) + public MultiLineString ClipLineString(MultiLineString lineStrings) { - var clippedLineStringList = new List(); + var clippedLineStringList = new List(); for (var i = 0; i < lineStrings.NumGeometries; i++) { - var s = (ILineString) lineStrings.GetGeometryN(i); + var s = (LineString)lineStrings.GetGeometryN(i); var clippedLineStrings = ClipLineString(s); for (var j = 0; j < clippedLineStrings.NumGeometries; j++) { - var clippedLineString = (ILineString)clippedLineStrings.GetGeometryN(j); + var clippedLineString = (LineString)clippedLineStrings.GetGeometryN(j); clippedLineStringList.Add(clippedLineString); } } @@ -213,4 +213,4 @@ public IMultiLineString ClipLineString(IMultiLineString lineStrings) } } -} \ No newline at end of file +} diff --git a/SharpMap/Rendering/Symbolizer/GeometrySymbolizer.cs b/SharpMap/Rendering/Symbolizer/GeometrySymbolizer.cs index 6bf839b5..db4a0c9c 100644 --- a/SharpMap/Rendering/Symbolizer/GeometrySymbolizer.cs +++ b/SharpMap/Rendering/Symbolizer/GeometrySymbolizer.cs @@ -1,8 +1,6 @@ -using System; +using NetTopologySuite.Geometries; +using System; using System.Drawing; -using GeoAPI.Geometries; -using SharpMap.Data; -using SharpMap.Rendering.Thematics; namespace SharpMap.Rendering.Symbolizer { @@ -10,7 +8,7 @@ namespace SharpMap.Rendering.Symbolizer /// Multi geometry symbolizer class /// [Serializable] - public class GeometrySymbolizer : ISymbolizer + public class GeometrySymbolizer : ISymbolizer { private IPointSymbolizer _pointSymbolizer; private ILineSymbolizer _lineSymbolizer; @@ -30,11 +28,11 @@ public GeometrySymbolizer() public object Clone() { return new GeometrySymbolizer - { - _pointSymbolizer = (IPointSymbolizer) _pointSymbolizer.Clone(), - _lineSymbolizer = (ILineSymbolizer) _lineSymbolizer.Clone(), - _polygonSymbolizer = (IPolygonSymbolizer) _polygonSymbolizer.Clone() - }; + { + _pointSymbolizer = (IPointSymbolizer)_pointSymbolizer.Clone(), + _lineSymbolizer = (ILineSymbolizer)_lineSymbolizer.Clone(), + _polygonSymbolizer = (IPolygonSymbolizer)_polygonSymbolizer.Clone() + }; } @@ -45,7 +43,7 @@ public IPointSymbolizer PointSymbolizer { get { return _pointSymbolizer; } set { _pointSymbolizer = value; } - + } /// @@ -74,7 +72,7 @@ public IPolygonSymbolizer PolygonSymbolizer /// The map object, mainly needed for transformation purposes. /// The geometry to symbolize. /// The graphics object to use. - public void Render(MapViewport map, IGeometry geometry, Graphics graphics) + public void Render(MapViewport map, Geometry geometry, Graphics graphics) { switch (geometry.OgcGeometryType) { @@ -94,7 +92,7 @@ public void Render(MapViewport map, IGeometry geometry, Graphics graphics) return; case OgcGeometryType.GeometryCollection: - foreach (var g in ((IGeometryCollection)geometry)) + foreach (var g in ((GeometryCollection)geometry)) { Render(map, g, graphics); } @@ -170,4 +168,4 @@ public System.Drawing.Drawing2D.PixelOffsetMode PixelOffsetMode } } } -} \ No newline at end of file +} diff --git a/SharpMap/Rendering/Symbolizer/ILineSymbolizer.cs b/SharpMap/Rendering/Symbolizer/ILineSymbolizer.cs index ec182848..cc234e9a 100644 --- a/SharpMap/Rendering/Symbolizer/ILineSymbolizer.cs +++ b/SharpMap/Rendering/Symbolizer/ILineSymbolizer.cs @@ -15,8 +15,7 @@ // along with SharpMap; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -using System.Drawing; -using GeoAPI.Geometries; +using NetTopologySuite.Geometries; namespace SharpMap.Rendering.Symbolizer { @@ -43,4 +42,4 @@ public interface ILineSymbolizer : ISymbolizer void Render(Map map, MultiLineString multiLineString, Graphics g); */ } -} \ No newline at end of file +} diff --git a/SharpMap/Rendering/Symbolizer/IPointSymbolizer.cs b/SharpMap/Rendering/Symbolizer/IPointSymbolizer.cs index 375e33bd..da4720b7 100644 --- a/SharpMap/Rendering/Symbolizer/IPointSymbolizer.cs +++ b/SharpMap/Rendering/Symbolizer/IPointSymbolizer.cs @@ -15,9 +15,8 @@ // along with SharpMap; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +using NetTopologySuite.Geometries; using System.Drawing; -using GeoAPI.Geometries; -using Point = GeoAPI.Geometries.IPoint; namespace SharpMap.Rendering.Symbolizer { @@ -57,4 +56,4 @@ public interface IPointSymbolizer : ISymbolizer //Image ToSymbol(); } -} \ No newline at end of file +} diff --git a/SharpMap/Rendering/Symbolizer/IPointSymbolizerEx.cs b/SharpMap/Rendering/Symbolizer/IPointSymbolizerEx.cs index 3f2ac771..1afba43f 100644 --- a/SharpMap/Rendering/Symbolizer/IPointSymbolizerEx.cs +++ b/SharpMap/Rendering/Symbolizer/IPointSymbolizerEx.cs @@ -2,7 +2,7 @@ namespace SharpMap.Rendering.Symbolizer { - + /// /// An extended interface for /// diff --git a/SharpMap/Rendering/Symbolizer/IPolygonSymbolizer.cs b/SharpMap/Rendering/Symbolizer/IPolygonSymbolizer.cs index a4b92fec..4bb4925b 100644 --- a/SharpMap/Rendering/Symbolizer/IPolygonSymbolizer.cs +++ b/SharpMap/Rendering/Symbolizer/IPolygonSymbolizer.cs @@ -1,4 +1,4 @@ -using GeoAPI.Geometries; +using NetTopologySuite.Geometries; namespace SharpMap.Rendering.Symbolizer { @@ -6,6 +6,6 @@ namespace SharpMap.Rendering.Symbolizer /// Interface for classes that can symbolize polygons /// public interface IPolygonSymbolizer : ISymbolizer - { + { } } \ No newline at end of file diff --git a/SharpMap/Rendering/Symbolizer/LineSymbolizer.cs b/SharpMap/Rendering/Symbolizer/LineSymbolizer.cs index 461baa8f..3a784e2c 100644 --- a/SharpMap/Rendering/Symbolizer/LineSymbolizer.cs +++ b/SharpMap/Rendering/Symbolizer/LineSymbolizer.cs @@ -1,6 +1,6 @@ +using NetTopologySuite.Geometries; using System.Drawing; using System.Drawing.Drawing2D; -using GeoAPI.Geometries; //using KnownColor = System.Drawing.KnownColor namespace SharpMap.Rendering.Symbolizer @@ -33,9 +33,9 @@ protected override void ReleaseManagedResources() { CheckDisposed(); - if (Line != null) + if (Line != null) Line.Dispose(); - + base.ReleaseManagedResources(); } @@ -47,17 +47,17 @@ protected override void ReleaseManagedResources() /// The graphics object to use. public void Render(MapViewport map, ILineal lineal, Graphics g) { - var ms = lineal as IMultiLineString; + var ms = lineal as MultiLineString; if (ms != null) { for (var i = 0; i < ms.NumGeometries; i++) { - var lineString = (ILineString) ms[i]; + var lineString = (LineString)ms[i]; OnRenderInternal(map, lineString, g); } return; } - OnRenderInternal(map, (ILineString)lineal, g); + OnRenderInternal(map, (LineString)lineal, g); } /// @@ -66,7 +66,7 @@ public void Render(MapViewport map, ILineal lineal, Graphics g) /// The map /// The line string to symbolize. /// The graphics - protected abstract void OnRenderInternal(MapViewport map, ILineString lineString, Graphics graphics); + protected abstract void OnRenderInternal(MapViewport map, LineString lineString, Graphics graphics); /// /// Function to transform a linestring to a graphics path for further processing @@ -75,7 +75,7 @@ public void Render(MapViewport map, ILineal lineal, Graphics g) /// The map /// /// A GraphicsPath - public static GraphicsPath LineStringToPath(ILineString lineString, MapViewport map) + public static GraphicsPath LineStringToPath(LineString lineString, MapViewport map) { var gp = new GraphicsPath(FillMode.Alternate); gp.AddLines(lineString.TransformToImage(map)); diff --git a/SharpMap/Rendering/Symbolizer/ListPointSymbolizer.cs b/SharpMap/Rendering/Symbolizer/ListPointSymbolizer.cs index 30d06d04..0606c16a 100644 --- a/SharpMap/Rendering/Symbolizer/ListPointSymbolizer.cs +++ b/SharpMap/Rendering/Symbolizer/ListPointSymbolizer.cs @@ -15,15 +15,14 @@ // along with SharpMap; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +using NetTopologySuite.Geometries; +using SharpMap.Base; using System; using System.Collections.ObjectModel; using System.Drawing; using System.Drawing.Drawing2D; -using GeoAPI.Geometries; -using SharpMap.Base; -using Point = GeoAPI.Geometries.IPoint; -namespace SharpMap.Rendering.Symbolizer +namespace SharpMap.Rendering.Symbolizer { /// /// ListPointSymbolizer class @@ -132,7 +131,7 @@ public Size Size /// /// Gets or sets the scale /// - public float Scale + public float Scale { get => 1; set { } diff --git a/SharpMap/Rendering/Symbolizer/PathPointSymbolizer.cs b/SharpMap/Rendering/Symbolizer/PathPointSymbolizer.cs index bc4edde6..5f5f93bc 100644 --- a/SharpMap/Rendering/Symbolizer/PathPointSymbolizer.cs +++ b/SharpMap/Rendering/Symbolizer/PathPointSymbolizer.cs @@ -27,7 +27,7 @@ namespace SharpMap.Rendering.Symbolizer [Serializable] public class PathPointSymbolizer : PointSymbolizer { - + /// /// Creates a that renders circles. /// @@ -82,7 +82,7 @@ public static PathPointSymbolizer CreateRectangle(Pen line, Brush fill, float wi ///The PathPointSymbolizer object public static PathPointSymbolizer CreateSquare(Pen line, Brush fill, float size) { - + GraphicsPath path = new GraphicsPath(); path.AddRectangle(new RectangleF(-0.5f * size, -0.5f * size, size, size)); return new PathPointSymbolizer( @@ -156,11 +156,11 @@ public void Dispose() public object Clone() { return new PathDefinition - { - Fill = (Brush) (Fill != null ? Fill.Clone() : null), - Line = (Pen) (Line != null ? Line.Clone() : null), - Path = (GraphicsPath) (Path != null ? Path.Clone() : null), - }; + { + Fill = (Brush)(Fill != null ? Fill.Clone() : null), + Line = (Pen)(Line != null ? Line.Clone() : null), + Path = (GraphicsPath)(Path != null ? Path.Clone() : null), + }; } #endregion @@ -169,7 +169,7 @@ public object Clone() private readonly PathDefinition[] _paths; - + /// /// Creates an instance of this class /// @@ -199,8 +199,8 @@ public override object Clone() { var pathDefinitions = new PathDefinition[_paths.Length]; for (var i = 0; i < _paths.Length; i++) - pathDefinitions[i] = (PathDefinition) _paths[i].Clone(); - + pathDefinitions[i] = (PathDefinition)_paths[i].Clone(); + return new PathPointSymbolizer(pathDefinitions); } diff --git a/SharpMap/Rendering/Symbolizer/PointSymbolizer.cs b/SharpMap/Rendering/Symbolizer/PointSymbolizer.cs index 4a34bfb2..1fdef01f 100644 --- a/SharpMap/Rendering/Symbolizer/PointSymbolizer.cs +++ b/SharpMap/Rendering/Symbolizer/PointSymbolizer.cs @@ -15,10 +15,10 @@ // along with SharpMap; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +using NetTopologySuite.Geometries; using System; using System.Drawing; using System.Drawing.Drawing2D; -using GeoAPI.Geometries; namespace SharpMap.Rendering.Symbolizer { @@ -110,7 +110,7 @@ protected void RenderPoint(MapViewport map, Coordinate point, Graphics g) g.Transform = origTrans; } - + using (var symTrans = new Matrix()) { symTrans.RotateAt(Rotation, rotationCenter); @@ -165,7 +165,7 @@ public virtual IPointSymbolizer ToRasterPointSymbolizer() /// The graphics object to use. public void Render(MapViewport map, IPuntal geometry, Graphics graphics) { - var mp = geometry as IMultiPoint; + var mp = geometry as MultiPoint; if (mp != null) { var combinedArea = RectangleF.Empty; @@ -177,7 +177,7 @@ public void Render(MapViewport map, IPuntal geometry, Graphics graphics) CanvasArea = combinedArea; return; } - RenderPoint(map, ((IPoint)geometry).Coordinate, graphics); + RenderPoint(map, ((NetTopologySuite.Geometries.Point)geometry).Coordinate, graphics); } } } diff --git a/SharpMap/Rendering/Symbolizer/PolygonSymbolizer.cs b/SharpMap/Rendering/Symbolizer/PolygonSymbolizer.cs index b647f3c5..bb217155 100644 --- a/SharpMap/Rendering/Symbolizer/PolygonSymbolizer.cs +++ b/SharpMap/Rendering/Symbolizer/PolygonSymbolizer.cs @@ -1,6 +1,6 @@ +using NetTopologySuite.Geometries; using System.Drawing; using System.Drawing.Drawing2D; -using GeoAPI.Geometries; using Point = System.Drawing.Point; namespace SharpMap.Rendering.Symbolizer @@ -63,17 +63,17 @@ protected override void ReleaseManagedResources() /// The graphics object to use. public void Render(MapViewport map, IPolygonal geometry, Graphics graphics) { - var mp = geometry as IMultiPolygon; + var mp = geometry as MultiPolygon; if (mp != null) { - for (var i = 0; i < mp.NumGeometries;i++) + for (var i = 0; i < mp.NumGeometries; i++) { - var poly = (IPolygon) mp[i]; + var poly = (Polygon)mp[i]; OnRenderInternal(map, poly, graphics); } return; } - OnRenderInternal(map, (IPolygon)geometry, graphics); + OnRenderInternal(map, (Polygon)geometry, graphics); } /// @@ -82,7 +82,7 @@ public void Render(MapViewport map, IPolygonal geometry, Graphics graphics) /// The map /// The polygon to render /// The graphics object to use - protected abstract void OnRenderInternal(MapViewport map, IPolygon polygon, Graphics g); + protected abstract void OnRenderInternal(MapViewport map, Polygon polygon, Graphics g); private Point _renderOrigin; @@ -116,7 +116,7 @@ public override void End(Graphics g, MapViewport map) /// The map /// The polygon /// A graphics path - protected static GraphicsPath PolygonToGraphicsPath(Map map, IPolygon polygon) + protected static GraphicsPath PolygonToGraphicsPath(Map map, Polygon polygon) { return polygon.TransformToImage(map); } diff --git a/SharpMap/Rendering/Symbolizer/RasterPointSymbolizer.cs b/SharpMap/Rendering/Symbolizer/RasterPointSymbolizer.cs index 3c1db07e..0cab8505 100644 --- a/SharpMap/Rendering/Symbolizer/RasterPointSymbolizer.cs +++ b/SharpMap/Rendering/Symbolizer/RasterPointSymbolizer.cs @@ -205,24 +205,24 @@ internal override void OnRenderInternal(PointF pt, Graphics g) { lock (symbol) { - g.DrawImageUnscaled(symbol, (int) (pt.X), (int) (pt.Y)); + g.DrawImageUnscaled(symbol, (int)(pt.X), (int)(pt.Y)); } } else { lock (symbol) { - g.DrawImage(symbol, (int) pt.X, (int) pt.Y, width, height); + g.DrawImage(symbol, (int)pt.X, (int)pt.Y, width, height); } } } else { - int x = (int) (pt.X); - int y = (int) (pt.Y); + int x = (int)(pt.X); + int y = (int)(pt.Y); g.DrawImage( symbol, - new Rectangle(x, y, (int) width, (int) height), + new Rectangle(x, y, (int)width, (int)height), 0, 0, symbol.Width, diff --git a/SharpMap/Rendering/Symbolizer/Utility.cs b/SharpMap/Rendering/Symbolizer/Utility.cs index 62c0a4c2..3b120371 100644 --- a/SharpMap/Rendering/Symbolizer/Utility.cs +++ b/SharpMap/Rendering/Symbolizer/Utility.cs @@ -22,9 +22,9 @@ static Utility() { //Get all known colors _knownColors = new List(); - _knownColors.AddRange((KnownColor[]) Enum.GetValues(typeof(KnownColor))); + _knownColors.AddRange((KnownColor[])Enum.GetValues(typeof(KnownColor))); //We remove the system colors - _knownColors.RemoveAll(x => (int) x < 27 || (int)x > 167); + _knownColors.RemoveAll(x => (int)x < 27 || (int)x > 167); } /// @@ -73,15 +73,15 @@ public static float ScaleSizeToDeviceUnits(float size, GraphicsUnit unit, Graphi case GraphicsUnit.World: size *= g.DpiY / g.PageScale; break; - /* - case GraphicsUnit.Pixel: - default: - //do nothing - break; - */ + /* + case GraphicsUnit.Pixel: + default: + //do nothing + break; + */ } - return (float) Math.Round(size, MidpointRounding.AwayFromZero); + return (float)Math.Round(size, MidpointRounding.AwayFromZero); } } } diff --git a/SharpMap/Rendering/Symbolizer/WarpPathToPath.cs b/SharpMap/Rendering/Symbolizer/WarpPathToPath.cs index ff48d7f0..697fbac9 100644 --- a/SharpMap/Rendering/Symbolizer/WarpPathToPath.cs +++ b/SharpMap/Rendering/Symbolizer/WarpPathToPath.cs @@ -265,7 +265,7 @@ internal static GraphicsPath PrepareTextPathToWarp(GraphicsPath path, Double tot break; } - path.Transform(new Matrix(1f, 0f, 0f, 1f, (float)xStart, yStart)); + path.Transform(new Matrix(1f, 0f, 0f, 1f, (float)xStart, yStart)); return path; } @@ -456,14 +456,14 @@ private static bool CheckMaxX(Single x, Single maxX) /// /// /// actual text height as rendered by graphic - public static void DrawString(this Graphics self, Pen halo, Brush fill, string text, FontFamily fontFamily, + public static void DrawString(this Graphics self, Pen halo, Brush fill, string text, FontFamily fontFamily, int style, float emSize, StringFormat format, bool ignoreLength, GraphicsPath path, float textHeight) { if (path == null || path.PointCount == 0) return; - var gp = new GraphicsPath(); + var gp = new GraphicsPath(); gp.AddString(text, fontFamily, style, emSize, new Point(0, 0), format); SortedList edges; @@ -487,6 +487,6 @@ public static void DrawString(this Graphics self, Pen halo, Brush fill, string t gp.Dispose(); } - + } } diff --git a/SharpMap/Rendering/Symbolizer/WarpedLineSymbolizer.cs b/SharpMap/Rendering/Symbolizer/WarpedLineSymbolizer.cs index 3f53444a..e17a5446 100644 --- a/SharpMap/Rendering/Symbolizer/WarpedLineSymbolizer.cs +++ b/SharpMap/Rendering/Symbolizer/WarpedLineSymbolizer.cs @@ -1,7 +1,7 @@ +using NetTopologySuite.Geometries; using System; using System.Drawing; using System.Drawing.Drawing2D; -using GeoAPI.Geometries; namespace SharpMap.Rendering.Symbolizer { @@ -30,9 +30,9 @@ public class WarpedLineSymbolizer : LineSymbolizer public static GraphicsPath GetGreaterSeries(float x, float y) { var gp = new GraphicsPath(); - gp.AddLine(new PointF(0.5f*x, y), new PointF(1.5f * x, 0f)); + gp.AddLine(new PointF(0.5f * x, y), new PointF(1.5f * x, 0f)); gp.CloseFigure(); - gp.AddLine(new PointF(1.5f * x, 0f), new PointF(0.5f*x, -y)); + gp.AddLine(new PointF(1.5f * x, 0f), new PointF(0.5f * x, -y)); gp.CloseFigure(); return gp; } @@ -48,9 +48,9 @@ public static GraphicsPath GetZigZag(float x, float y) var gp = new GraphicsPath(); gp.AddLine(new PointF(0f, 0f), new PointF(0f, y)); gp.CloseFigure(); - gp.AddLine(new PointF(0f, y), new PointF(2*x, -y)); + gp.AddLine(new PointF(0f, y), new PointF(2 * x, -y)); gp.CloseFigure(); - gp.AddLine(new PointF(2*x, -y), new PointF(2*x, 0)); + gp.AddLine(new PointF(2 * x, -y), new PointF(2 * x, 0)); gp.CloseFigure(); return gp; } @@ -68,16 +68,16 @@ public static GraphicsPath GetZigZag(float x, float y) /// public static GraphicsPath GetTriangle(float size, int orientation) { - orientation = orientation%4; - var half = 0.5f*size; - var twoThirds = 2f*size/3f; + orientation = orientation % 4; + var half = 0.5f * size; + var twoThirds = 2f * size / 3f; var gp = new GraphicsPath(); switch (orientation) { case 0: - gp.AddPolygon(new[] { - new PointF(size, 0f), new PointF(0f, 0f), - new PointF(half, twoThirds), new PointF(size, 0f) + gp.AddPolygon(new[] { + new PointF(size, 0f), new PointF(0f, 0f), + new PointF(half, twoThirds), new PointF(size, 0f) }); break; case 1: @@ -88,7 +88,7 @@ public static GraphicsPath GetTriangle(float size, int orientation) break; case 2: gp.AddPolygon(new[] { - new PointF(size, 0f), new PointF(0f, 0f), + new PointF(size, 0f), new PointF(0f, 0f), new PointF(half, -twoThirds), new PointF(size, 0f) }); break; @@ -114,9 +114,9 @@ public static GraphicsPath GetTriangle(float size, int orientation) public static GraphicsPath GetTriangleSeries(float x, float y) { var gp = new GraphicsPath(); - gp.AddPolygon(new[] { new PointF(x, 0f), new PointF(0f, 0f), new PointF(0.5f*x, 2f*x/3f), new PointF(x, 0f) }); + gp.AddPolygon(new[] { new PointF(x, 0f), new PointF(0f, 0f), new PointF(0.5f * x, 2f * x / 3f), new PointF(x, 0f) }); gp.CloseFigure(); - + //Just to move to a new position gp.AddEllipse(y, 0f, 0f, 0f); gp.CloseFigure(); @@ -133,7 +133,7 @@ public static GraphicsPath GetTriangleSeries(float x, float y) public static GraphicsPath GetTriangleSeriesForward(float x, float y) { var gp = new GraphicsPath(); - gp.AddPolygon(new[] { new PointF(0f, -0.5f*x), new PointF(0f, 0.5f*x), new PointF(2f * x / 3f, 0), new PointF(0f, -0.5f*x) }); + gp.AddPolygon(new[] { new PointF(0f, -0.5f * x), new PointF(0f, 0.5f * x), new PointF(2f * x / 3f, 0), new PointF(0f, -0.5f * x) }); gp.CloseFigure(); //Just to move to a new position @@ -166,10 +166,10 @@ protected override void ReleaseManagedResources() public override object Clone() { var res = (WarpedLineSymbolizer)MemberwiseClone(); - res.Fill = (Brush) Fill.Clone(); - res.Line = (Pen) Line.Clone(); - res.Pattern = (GraphicsPath) Pattern.Clone(); - + res.Fill = (Brush)Fill.Clone(); + res.Line = (Pen)Line.Clone(); + res.Pattern = (GraphicsPath)Pattern.Clone(); + return res; } @@ -184,17 +184,17 @@ public override object Clone() /// The map /// The line string to symbolize. /// The graphics - protected override void OnRenderInternal(MapViewport map, ILineString lineString, Graphics graphics) + protected override void OnRenderInternal(MapViewport map, LineString lineString, Graphics graphics) { - var clonedPattern = (GraphicsPath) Pattern.Clone(); + var clonedPattern = (GraphicsPath)Pattern.Clone(); var graphicsPath = WarpPathToPath.Warp(LineStringToPath(lineString, map), clonedPattern, true, Interval); - + if (graphicsPath == null) return; // Fill? if (Fill != null) graphics.FillPath(Fill, graphicsPath); - + // Outline if (Line != null) graphics.DrawPath(Line, graphicsPath); diff --git a/SharpMap/Rendering/TextOnPath.cs b/SharpMap/Rendering/TextOnPath.cs index 358ab089..2055ed6e 100644 --- a/SharpMap/Rendering/TextOnPath.cs +++ b/SharpMap/Rendering/TextOnPath.cs @@ -144,7 +144,7 @@ public static RectangleF[] MeasureString(Graphics graphics, string s, Font font, /// An array of s public static void DrawString(Graphics graphics, string s, Font font, Brush brush, TextPathAlign textPathAlign, TextPathPosition textPathPosition, int letterSpace, GraphicsPath graphicsPath) { - DrawString(graphics, s, font, brush, textPathAlign, textPathPosition, 100, 0, graphicsPath,false); + DrawString(graphics, s, font, brush, textPathAlign, textPathPosition, 100, 0, graphicsPath, false); } /// @@ -203,7 +203,7 @@ public static RectangleF[] MeasureString(Graphics graphics, string s, Font font, public static void DrawString(Graphics graphics, string s, Font font, Brush brush, TextPathAlign textPathAlign, TextPathPosition textPathPosition, int letterSpace, float rotateDegree, GraphicsPath graphicsPath, bool showPath) { var top = TextOnPath.TextOnPathInstance; - + top.Text = s; top.Font = font; top.FillColorTop = brush; @@ -233,7 +233,7 @@ public class TextOnPath private bool _measureString; private Font _font; - private Pen _colorHalo = new Pen(Color.Black,1); + private Pen _colorHalo = new Pen(Color.Black, 1); private Brush _fillBrush = new SolidBrush(Color.Black); private TextPathAlign _pathalign = TextPathAlign.Center; private double _letterspacepercentage = 1; @@ -244,12 +244,12 @@ public class TextOnPath private List _pointText = new List(); private List _pointTextUp = new List(); private readonly List _angles = new List(); - + /// /// The last catched exception is stored here /// public Exception LastError; - + /// /// Gets or sets the object @@ -260,7 +260,7 @@ public class TextOnPath /// Gets or sets a value indicating the used to render text along /// public GraphicsPath GraphicsPath { get; set; } - + /// /// Gets or sets a value indicating whether the string should be measured /// @@ -269,7 +269,7 @@ public bool MeasureString get { return _measureString; } set { _measureString = value; } } - + /// /// Gets or sets a list of regions @@ -288,7 +288,7 @@ public List PointsText get { return _pointText; } set { _pointText = value; } } - + /// /// Gets or sets a list of s /// @@ -309,7 +309,7 @@ public List Angles /// /// Gets or sets a value indicating the rotation /// - public float RotateDegree { get; set; } + public float RotateDegree { get; set; } /// /// Creates an instance of this class @@ -391,7 +391,7 @@ public TextPathAlign TextPathAlignTop public int LetterSpacePercentage { get { return (int)(100 * _letterspacepercentage); } - set { _letterspacepercentage = value/100d; } + set { _letterspacepercentage = value / 100d; } } /// @@ -414,7 +414,7 @@ public void DrawTextOnPath(PathData pathdata, string text, Font font, Pen haloPe _pathdata = pathdata; Text = text; _font = font; - _colorHalo= haloPen; + _colorHalo = haloPen; _fillBrush = fillcolor; _letterspacepercentage = letterspacepercentage / 100d; @@ -435,8 +435,8 @@ public void DrawTextOnPath() /// The area covered by the rendering process public RectangleF DrawTextOnPathEx() { - var affectedArea = new RectangleF(); - + var affectedArea = new RectangleF(); + var points = new PointF[25001]; var count = 0; var gp = new GraphicsPath(_pathdata.Points, _pathdata.Types) { FillMode = FillMode.Winding }; @@ -498,7 +498,7 @@ private static PointF[] CleanPoints(PointF[] points) { if (points == null) return null; - if (points.Length == 0) + if (points.Length == 0) return new PointF[0]; var tmpPoints = new List(points.Length); tmpPoints.Add(points[0]); @@ -524,8 +524,8 @@ private static PointF[] CleanPoints(PointF[] points) public bool IsVisible(PointF[] points, int maxPoints) { var result = true; - var g = Graphics; - var count = 0; + var g = Graphics; + var count = 0; var maxWidthText = default(double); int i; for (i = 0; i <= Text.Length - 1; i++) @@ -534,14 +534,14 @@ public bool IsVisible(PointF[] points, int maxPoints) } switch (_pathalign) { - case TextPathAlign.Left: + case TextPathAlign.Left: count = 0; break; case TextPathAlign.Center: - count = (int)((maxPoints - maxWidthText) / 2); + count = (int)((maxPoints - maxWidthText) / 2); break; case TextPathAlign.Right: - count = (int)(maxPoints - maxWidthText - (double)StringRegion(g, Text.Length - 1) * LetterSpacePercentage / 100); + count = (int)(maxPoints - maxWidthText - (double)StringRegion(g, Text.Length - 1) * LetterSpacePercentage / 100); break; } var lStrWidth = (int)(StringRegion(g, 0) * LetterSpacePercentage / 100); @@ -550,10 +550,10 @@ public bool IsVisible(PointF[] points, int maxPoints) count = -(lStrWidth / 2); } double currentWidthText = 0; - for (int j =count+lStrWidth/2; j <= Text.Length - 1; j++) + for (int j = count + lStrWidth / 2; j <= Text.Length - 1; j++) { currentWidthText += StringRegion(g, j) * LetterSpacePercentage / 100; - } + } if ((int)currentWidthText >= maxPoints) { result = false; @@ -621,14 +621,14 @@ private void DrawText(Graphics g, PointF[] points, int maxPoints) count += lStrWidth; var point2 = points[count]; //PointF point = points[count - lStrWidth / 2]; - var point = new PointF((point2.X+point1.X)/2,(point2.Y+point1.Y)/2); + var point = new PointF((point2.X + point1.X) / 2, (point2.Y + point1.Y) / 2); var angle = GetAngle(point1, point2); DrawRotatedText(g, Text[charStep].ToString(CultureInfo.InvariantCulture), (float)angle, point); point1 = points[count]; } else { - count += lStrWidth; + count += lStrWidth; } charStep += 1; } @@ -671,7 +671,7 @@ private float StringRegion(Graphics g, int textpos) /// An angle in degrees private static double GetAngle(PointF point1, PointF point2) { - const double rad2Deg = 180d/Math.PI; + const double rad2Deg = 180d / Math.PI; var c = Math.Sqrt(Math.Pow((point2.X - point1.X), 2) + Math.Pow((point2.Y - point1.Y), 2)); if (c == 0d) @@ -679,7 +679,7 @@ private static double GetAngle(PointF point1, PointF point2) return 0; } - var res = Math.Asin((point2.Y - point1.Y)/c)*rad2Deg; + var res = Math.Asin((point2.Y - point1.Y) / c) * rad2Deg; return point1.X > point2.X ? res - 180 : res; @@ -695,31 +695,31 @@ private static double GetAngle(PointF point1, PointF point2) private void DrawRotatedText(Graphics gr, string text, float angle, PointF pointCenter) { angle -= RotateDegree; - var stringFormat = new StringFormat { Alignment = StringAlignment.Center }; + var stringFormat = new StringFormat { Alignment = StringAlignment.Center }; //gr.SmoothingMode = SmoothingMode.HighQuality; //gr.CompositingQuality = CompositingQuality.HighQuality; //gr.TextRenderingHint = TextRenderingHint.AntiAlias; using (var graphicsPath = new GraphicsPath()) { - var x = (int) pointCenter.X; - var y = (int) pointCenter.Y; + var x = (int)pointCenter.X; + var y = (int)pointCenter.Y; var pOrigin = new Point(); switch (TextPathPathPosition) { case TextPathPosition.OverPath: - pOrigin = new Point(x, (int) (y - _font.Size)); - graphicsPath.AddString(text, _font.FontFamily, (int) _font.Style, _font.Size, - new Point(x, (int) (y - _font.Size)), stringFormat); + pOrigin = new Point(x, (int)(y - _font.Size)); + graphicsPath.AddString(text, _font.FontFamily, (int)_font.Style, _font.Size, + new Point(x, (int)(y - _font.Size)), stringFormat); break; case TextPathPosition.CenterPath: - pOrigin = new Point(x, (int) (y - _font.Size/2)); - graphicsPath.AddString(text, _font.FontFamily, (int) _font.Style, _font.Size, - new Point(x, (int) (y - _font.Size/2)), stringFormat); + pOrigin = new Point(x, (int)(y - _font.Size / 2)); + graphicsPath.AddString(text, _font.FontFamily, (int)_font.Style, _font.Size, + new Point(x, (int)(y - _font.Size / 2)), stringFormat); break; case TextPathPosition.UnderPath: pOrigin = new Point(x, y); - graphicsPath.AddString(text, _font.FontFamily, (int) _font.Style, _font.Size, new Point(x, y), + graphicsPath.AddString(text, _font.FontFamily, (int)_font.Style, _font.Size, new Point(x, y), stringFormat); break; } diff --git a/SharpMap/Rendering/Thematics/ColorBlend.cs b/SharpMap/Rendering/Thematics/ColorBlend.cs index 4a391441..1e965da4 100644 --- a/SharpMap/Rendering/Thematics/ColorBlend.cs +++ b/SharpMap/Rendering/Thematics/ColorBlend.cs @@ -78,10 +78,10 @@ public Color[] Colors public float[] Positions { get { return _positions; } - set - { + set + { _positions = value; - if ( value == null ) + if (value == null) _minimum = _maximum = float.NaN; else { @@ -116,13 +116,13 @@ public Color GetColor(float pos) int i = 1; while (i < _positions.Length && _positions[i] < pos) i++; - float frac = (pos - _positions[i - 1])/(_positions[i] - _positions[i - 1]); + float frac = (pos - _positions[i - 1]) / (_positions[i] - _positions[i - 1]); frac = Math.Max(frac, 0.0f); frac = Math.Min(frac, 1.0f); - int R = (int) Math.Round((_colors[i - 1].R*(1 - frac) + _colors[i].R*frac)); - int G = (int) Math.Round((_colors[i - 1].G*(1 - frac) + _colors[i].G*frac)); - int B = (int) Math.Round((_colors[i - 1].B*(1 - frac) + _colors[i].B*frac)); - int A = (int) Math.Round((_colors[i - 1].A*(1 - frac) + _colors[i].A*frac)); + int R = (int)Math.Round((_colors[i - 1].R * (1 - frac) + _colors[i].R * frac)); + int G = (int)Math.Round((_colors[i - 1].G * (1 - frac) + _colors[i].G * frac)); + int B = (int)Math.Round((_colors[i - 1].B * (1 - frac) + _colors[i].B * frac)); + int A = (int)Math.Round((_colors[i - 1].A * (1 - frac) + _colors[i].A * frac)); return Color.FromArgb(A, R, G, B); } @@ -160,8 +160,8 @@ public static ColorBlend RainbowMOHID get { return new ColorBlend( - new Color[] {Color.FromArgb(0,0,127), Color.FromArgb(0,0,255), Color.FromArgb(0,255,255), Color.FromArgb(0,255,0), - Color.FromArgb(127,255,0), Color.FromArgb(255,255,0), Color.FromArgb(255,127,0), Color.FromArgb(255,0,0), + new Color[] {Color.FromArgb(0,0,127), Color.FromArgb(0,0,255), Color.FromArgb(0,255,255), Color.FromArgb(0,255,0), + Color.FromArgb(127,255,0), Color.FromArgb(255,255,0), Color.FromArgb(255,127,0), Color.FromArgb(255,0,0), Color.FromArgb(127,0,0)}, new float[] { 0f, 0.125f, 0.25f, 0.375f, 0.5f, 0.625f, 0.75f, 0.875f, 1f }); } @@ -179,7 +179,7 @@ public static ColorBlend InverseRainbowMOHID get { return new ColorBlend( - new Color[] {Color.FromArgb(127,0,0), Color.FromArgb(255,0,0), Color.FromArgb(255,127,0), Color.FromArgb(255,255,0), + new Color[] {Color.FromArgb(127,0,0), Color.FromArgb(255,0,0), Color.FromArgb(255,127,0), Color.FromArgb(255,255,0), Color.FromArgb(127,255,0), Color.FromArgb(0,255,0), Color.FromArgb(0,255,255), Color.FromArgb(0,0,255), Color.FromArgb(0,0,127)}, new float[] { 0f, 0.125f, 0.25f, 0.375f, 0.5f, 0.625f, 0.75f, 0.875f, 1f }); @@ -197,8 +197,8 @@ public static ColorBlend DigitalTerrainModelMOHID get { return new ColorBlend( - new Color[] - {Color.FromArgb(16, 56, 0), Color.FromArgb(38, 127, 0), Color.FromArgb(58, 193, 0), Color.FromArgb(255, 247, 176), + new Color[] + {Color.FromArgb(16, 56, 0), Color.FromArgb(38, 127, 0), Color.FromArgb(58, 193, 0), Color.FromArgb(255, 247, 176), Color.FromArgb(244, 170, 81), Color.FromArgb(239, 139, 2), Color.FromArgb(205, 112, 9), Color.FromArgb(148, 82, 17), Color.FromArgb(99, 66, 3)}, new float[] { 0f, 0.125f, 0.25f, 0.375f, 0.5f, 0.625f, 0.75f, 0.875f, 1f }); @@ -216,7 +216,7 @@ public static ColorBlend BathymetryMOHID get { return new ColorBlend( - new Color[] {Color.FromArgb(254, 255, 255), Color.FromArgb(223, 241, 251), Color.FromArgb(187, 228, 246), + new Color[] {Color.FromArgb(254, 255, 255), Color.FromArgb(223, 241, 251), Color.FromArgb(187, 228, 246), Color.FromArgb(133,208, 239), Color.FromArgb(63,189, 237), Color.FromArgb(87, 153, 203)}, new float[] { 0f, 0.2f, 0.4f, 0.6f, 0.8f, 1.0f }); } @@ -251,8 +251,8 @@ public static ColorBlend Rainbow5 get { return new ColorBlend( - new[] {Color.Red, Color.Yellow, Color.Green, Color.Cyan, Color.Blue}, - new[] {0f, 0.25f, 0.5f, 0.75f, 1f}); + new[] { Color.Red, Color.Yellow, Color.Green, Color.Cyan, Color.Blue }, + new[] { 0f, 0.25f, 0.5f, 0.75f, 1f }); } } @@ -261,7 +261,7 @@ public static ColorBlend Rainbow5 /// public static ColorBlend BlackToWhite { - get { return new ColorBlend(new[] {Color.Black, Color.White}, new[] {0f, 1f}); } + get { return new ColorBlend(new[] { Color.Black, Color.White }, new[] { 0f, 1f }); } } /// @@ -269,7 +269,7 @@ public static ColorBlend BlackToWhite /// public static ColorBlend WhiteToBlack { - get { return new ColorBlend(new[] {Color.White, Color.Black}, new[] {0f, 1f}); } + get { return new ColorBlend(new[] { Color.White, Color.Black }, new[] { 0f, 1f }); } } /// @@ -277,7 +277,7 @@ public static ColorBlend WhiteToBlack /// public static ColorBlend RedToGreen { - get { return new ColorBlend(new[] {Color.Red, Color.Green}, new[] {0f, 1f}); } + get { return new ColorBlend(new[] { Color.Red, Color.Green }, new[] { 0f, 1f }); } } /// @@ -285,7 +285,7 @@ public static ColorBlend RedToGreen /// public static ColorBlend GreenToRed { - get { return new ColorBlend(new[] {Color.Green, Color.Red}, new[] {0f, 1f}); } + get { return new ColorBlend(new[] { Color.Green, Color.Red }, new[] { 0f, 1f }); } } /// @@ -293,7 +293,7 @@ public static ColorBlend GreenToRed /// public static ColorBlend BlueToGreen { - get { return new ColorBlend(new[] {Color.Blue, Color.Green}, new[] {0f, 1f}); } + get { return new ColorBlend(new[] { Color.Blue, Color.Green }, new[] { 0f, 1f }); } } /// @@ -301,7 +301,7 @@ public static ColorBlend BlueToGreen /// public static ColorBlend GreenToBlue { - get { return new ColorBlend(new[] {Color.Green, Color.Blue}, new[] {0f, 1f}); } + get { return new ColorBlend(new[] { Color.Green, Color.Blue }, new[] { 0f, 1f }); } } /// @@ -309,7 +309,7 @@ public static ColorBlend GreenToBlue /// public static ColorBlend RedToBlue { - get { return new ColorBlend(new[] {Color.Red, Color.Blue}, new[] {0f, 1f}); } + get { return new ColorBlend(new[] { Color.Red, Color.Blue }, new[] { 0f, 1f }); } } /// @@ -317,7 +317,7 @@ public static ColorBlend RedToBlue /// public static ColorBlend BlueToRed { - get { return new ColorBlend(new[] {Color.Blue, Color.Red}, new[] {0f, 1f}); } + get { return new ColorBlend(new[] { Color.Blue, Color.Red }, new[] { 0f, 1f }); } } #endregion @@ -332,7 +332,7 @@ public static ColorBlend BlueToRed /// public static ColorBlend TwoColors(Color fromColor, Color toColor) { - return new ColorBlend(new[] {fromColor, toColor}, new[] {0f, 1f}); + return new ColorBlend(new[] { fromColor, toColor }, new[] { 0f, 1f }); } /// @@ -340,7 +340,7 @@ public static ColorBlend TwoColors(Color fromColor, Color toColor) /// public static ColorBlend ThreeColors(Color fromColor, Color middleColor, Color toColor) { - return new ColorBlend(new[] {fromColor, middleColor, toColor}, new[] {0f, 0.5f, 1f}); + return new ColorBlend(new[] { fromColor, middleColor, toColor }, new[] { 0f, 0.5f, 1f }); } #endregion diff --git a/SharpMap/Rendering/Thematics/CustomTheme.cs b/SharpMap/Rendering/Thematics/CustomTheme.cs index 64746bc8..9e97d955 100644 --- a/SharpMap/Rendering/Thematics/CustomTheme.cs +++ b/SharpMap/Rendering/Thematics/CustomTheme.cs @@ -15,10 +15,10 @@ // along with SharpMap; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -using System; -using System.Runtime.Serialization; using SharpMap.Data; using SharpMap.Styles; +using System; +using System.Runtime.Serialization; namespace SharpMap.Rendering.Thematics { @@ -84,7 +84,7 @@ public CustomTheme(GetStyleMethod getStyleMethod) { _getStyleDelegate = getStyleMethod; } - + /// /// Gets or sets the default style when an attribute isn't found in any bucket /// diff --git a/SharpMap/Rendering/Thematics/FontSizeTheme.cs b/SharpMap/Rendering/Thematics/FontSizeTheme.cs index b782496d..4b27f961 100644 --- a/SharpMap/Rendering/Thematics/FontSizeTheme.cs +++ b/SharpMap/Rendering/Thematics/FontSizeTheme.cs @@ -1,9 +1,9 @@ -using System; -using System.Drawing; -using SharpMap.Base; +using SharpMap.Base; using SharpMap.Data; using SharpMap.Layers; using SharpMap.Styles; +using System; +using System.Drawing; namespace SharpMap.Rendering.Thematics { @@ -66,7 +66,7 @@ private void HandleStyleChanged(object sender, EventArgs e) { if (_currentStyle != null) _currentStyle.Dispose(); - + _currentStyle = _labelLayer.Style.Clone(); _currentSize = _currentStyle.Font.Size; } @@ -85,7 +85,7 @@ public IStyle GetStyle(FeatureDataRow attribute) if (!style.Enabled) return style; if (!(style is LabelStyle)) return style; - var labelStyle = (LabelStyle) style; + var labelStyle = (LabelStyle)style; return UpdateStyle(labelStyle, CalculateSize(_map, labelStyle.Font.SizeInPoints)); } @@ -94,7 +94,7 @@ public IStyle GetStyle(FeatureDataRow attribute) { // Get the new size var newSize = CalculateSize(_map, _currentSize); - + // Update the style _currentStyle = UpdateStyle(_currentStyle, newSize); _currentZoom = _map.Zoom; @@ -117,7 +117,7 @@ protected virtual LabelStyle UpdateStyle(LabelStyle labelStyle, float newSize) labelStyle.Enabled = false; return labelStyle; } - + // Make sure label style is enabled labelStyle.Enabled = true; @@ -160,7 +160,7 @@ public float TreatSizeAsMapUnits(Map map, float sizeInMapUnits) { if (FontSizeScale.HasValue) sizeInMapUnits *= FontSizeScale.Value; - return (float)(sizeInMapUnits/_map.PixelHeight); + return (float)(sizeInMapUnits / _map.PixelHeight); } /// diff --git a/SharpMap/Rendering/Thematics/GradientTheme.cs b/SharpMap/Rendering/Thematics/GradientTheme.cs index 8354b071..f1dde146 100644 --- a/SharpMap/Rendering/Thematics/GradientTheme.cs +++ b/SharpMap/Rendering/Thematics/GradientTheme.cs @@ -15,11 +15,11 @@ // along with SharpMap; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +using SharpMap.Data; +using SharpMap.Styles; using System; using System.Drawing; using System.Drawing.Drawing2D; -using SharpMap.Data; -using SharpMap.Styles; namespace SharpMap.Rendering.Thematics { @@ -257,9 +257,9 @@ protected SolidBrush InterpolateBrush(Brush min, Brush max, double attr) protected Pen InterpolatePen(Pen min, Pen max, double attr) { var oldMin = min; - min = (Pen) oldMin.Clone(); + min = (Pen)oldMin.Clone(); var oldMax = max; - max = (Pen) oldMax.Clone(); + max = (Pen)oldMax.Clone(); if (min.PenType != PenType.SolidColor || max.PenType != PenType.SolidColor) throw (new ArgumentException("Only SolidColor pens are supported in GradientTheme")); @@ -295,10 +295,10 @@ protected Pen InterpolatePen(Pen min, Pen max, double attr) protected Color InterpolateColor(Color minCol, Color maxCol, double attr) { double frac = Fraction(attr); - + if (frac == 1) return maxCol; - + if (frac == 0) return minCol; @@ -310,7 +310,7 @@ protected Color InterpolateColor(Color minCol, Color maxCol, double attr) if (g > 255) g = 255; if (b > 255) b = 255; if (a > 255) a = 255; - + return Color.FromArgb((int)a, (int)r, (int)g, (int)b); } @@ -434,11 +434,11 @@ protected override double GetAttributeValue(FeatureDataRow row) /// public object Clone() { - var res = (GradientTheme) MemberwiseClone(); + var res = (GradientTheme)MemberwiseClone(); if (res.MinStyle is ICloneable) - res.MinStyle = (IStyle) ((ICloneable) MinStyle).Clone(); + res.MinStyle = (IStyle)((ICloneable)MinStyle).Clone(); if (res.MaxStyle is ICloneable) - res.MaxStyle = (IStyle) ((ICloneable) MaxStyle).Clone(); + res.MaxStyle = (IStyle)((ICloneable)MaxStyle).Clone(); return res; } diff --git a/SharpMap/Rendering/Thematics/ITheme.cs b/SharpMap/Rendering/Thematics/ITheme.cs index 1d74894c..e54c41d9 100644 --- a/SharpMap/Rendering/Thematics/ITheme.cs +++ b/SharpMap/Rendering/Thematics/ITheme.cs @@ -46,7 +46,7 @@ public interface ITheme /// when they make use of , or likewise /// objects of the namespace. Otherwise they are prone to GDI+ rendering exceptions. /// - public interface IThemeEx: ITheme + public interface IThemeEx : ITheme { /// /// Calculates a style for a given based on a given . diff --git a/SharpMap/Rendering/Thematics/UniqueValuesTheme.cs b/SharpMap/Rendering/Thematics/UniqueValuesTheme.cs index be81400b..dd96d27e 100644 --- a/SharpMap/Rendering/Thematics/UniqueValuesTheme.cs +++ b/SharpMap/Rendering/Thematics/UniqueValuesTheme.cs @@ -12,9 +12,9 @@ // You should have received a copy of the GNU Lesser General Public License // along with SharpMap; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +using SharpMap.Styles; using System; using System.Collections.Generic; -using SharpMap.Styles; namespace SharpMap.Rendering.Thematics { @@ -23,7 +23,7 @@ namespace SharpMap.Rendering.Thematics /// /// Type of the featureattribute to match [Serializable] - public class UniqueValuesTheme : ITheme, ICloneable + public class UniqueValuesTheme : ITheme, ICloneable { readonly IStyle _default; @@ -68,7 +68,7 @@ public IStyle GetStyle(Data.FeatureDataRow attribute) var val = attribute[_attributeName].ToString(); if (_styleMap.ContainsKey(val)) - return _styleMap[val]; + return _styleMap[val]; return _default; } @@ -112,10 +112,10 @@ public IStyle GetStyle(string value) /// public object Clone() { - var defStyle = (_default is ICloneable) ? (IStyle) ((ICloneable) _default).Clone() : _default; + var defStyle = (_default is ICloneable) ? (IStyle)((ICloneable)_default).Clone() : _default; var styleMap = new Dictionary(_styleMap.Count); foreach (var style in _styleMap) - styleMap.Add(_originalValue[style.Key], style.Value is ICloneable ? (IStyle) ((ICloneable) style.Value).Clone() : style.Value); + styleMap.Add(_originalValue[style.Key], style.Value is ICloneable ? (IStyle)((ICloneable)style.Value).Clone() : style.Value); return new UniqueValuesTheme(_attributeName, styleMap, defStyle); } diff --git a/SharpMap/Rendering/VectorRenderer.cs b/SharpMap/Rendering/VectorRenderer.cs index 9a0591d5..8ecf25d0 100644 --- a/SharpMap/Rendering/VectorRenderer.cs +++ b/SharpMap/Rendering/VectorRenderer.cs @@ -15,17 +15,17 @@ // along with SharpMap; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +using NetTopologySuite.Geometries; +using SharpMap.Rendering.Symbolizer; +using SharpMap.Styles; using System; using System.Collections.Generic; using System.Drawing; using System.Drawing.Drawing2D; using System.Linq; using System.Reflection; -using GeoAPI.Geometries; -using SharpMap.Rendering.Symbolizer; -using SharpMap.Styles; -using Point=GeoAPI.Geometries.Coordinate; using System.Runtime.CompilerServices; +using Point = NetTopologySuite.Geometries.Point; namespace SharpMap.Rendering { @@ -56,7 +56,7 @@ static VectorRenderer() /// Map reference /// Offset by which line will be moved to right [MethodImpl(MethodImplOptions.Synchronized)] - public static void DrawMultiLineString(Graphics g, IMultiLineString lines, Pen pen, MapViewport map, float offset) + public static void DrawMultiLineString(Graphics g, MultiLineString lines, Pen pen, MapViewport map, float offset) { DrawMultiLineStringEx(g, lines, pen, map, offset); } @@ -71,12 +71,12 @@ public static void DrawMultiLineString(Graphics g, IMultiLineString lines, Pen p /// Offset by which line will be moved to right /// The area of the map that was affected by the drawing operation [MethodImpl(MethodImplOptions.Synchronized)] - public static RectangleF DrawMultiLineStringEx(Graphics g, IMultiLineString lines, Pen pen, MapViewport map, float offset) + public static RectangleF DrawMultiLineStringEx(Graphics g, MultiLineString lines, Pen pen, MapViewport map, float offset) { var canvasArea = RectangleF.Empty; - for(int i = 0; i < lines.NumGeometries; i++) + for (int i = 0; i < lines.NumGeometries; i++) { - var line = (ILineString) lines[i]; + var line = (LineString)lines[i]; var rect = DrawLineStringEx(g, line, pen, map, offset); canvasArea = rect.ExpandToInclude(canvasArea); } @@ -143,7 +143,7 @@ internal static PointF[] OffsetRight(PointF[] points, float offset) /// Map reference [MethodImpl(MethodImplOptions.Synchronized)] [Obsolete("Not called, will be removed")] - public static void DrawLineString(Graphics g, ILineString line, Pen pen, MapViewport map) + public static void DrawLineString(Graphics g, LineString line, Pen pen, MapViewport map) { DrawLineString(g, line, pen, map, 0f); } @@ -156,7 +156,7 @@ public static void DrawLineString(Graphics g, ILineString line, Pen pen, MapView /// Pen style used for rendering /// Map reference /// Offset by which line will be moved to right - public static void DrawLineString(Graphics g, ILineString line, Pen pen, MapViewport map, float offset) + public static void DrawLineString(Graphics g, LineString line, Pen pen, MapViewport map, float offset) { DrawLineStringEx(g, line, pen, map, offset); } @@ -170,7 +170,7 @@ public static void DrawLineString(Graphics g, ILineString line, Pen pen, MapView /// Map reference /// Offset by which line will be moved to right /// The area of the map that was affected by the drawing of the geometry. - public static RectangleF DrawLineStringEx(Graphics g, ILineString line, Pen pen, MapViewport map, float offset) + public static RectangleF DrawLineStringEx(Graphics g, LineString line, Pen pen, MapViewport map, float offset) { var points = line.TransformToImage(map); if (points.Length < 2) return RectangleF.Empty; @@ -199,7 +199,7 @@ public static RectangleF DrawLineStringEx(Graphics g, ILineString line, Pen pen, /// Specifies whether polygon clipping should be applied /// Map reference [MethodImpl(MethodImplOptions.Synchronized)] - public static void DrawMultiPolygon(Graphics g, IMultiPolygon multiPolygon, Brush brush, Pen pen, bool clip, MapViewport map) + public static void DrawMultiPolygon(Graphics g, MultiPolygon multiPolygon, Brush brush, Pen pen, bool clip, MapViewport map) { DrawMultiPolygonEx(g, multiPolygon, brush, pen, clip, map); } @@ -215,12 +215,12 @@ public static void DrawMultiPolygon(Graphics g, IMultiPolygon multiPolygon, Brus /// Map reference /// The area of the map that was affected by the drawing of the geometry. [MethodImpl(MethodImplOptions.Synchronized)] - public static RectangleF DrawMultiPolygonEx(Graphics g, IMultiPolygon multiPolygon, Brush brush, Pen pen, bool clip, MapViewport map) + public static RectangleF DrawMultiPolygonEx(Graphics g, MultiPolygon multiPolygon, Brush brush, Pen pen, bool clip, MapViewport map) { var canvasArea = RectangleF.Empty; - for (var i = 0; i < multiPolygon.NumGeometries;i++ ) + for (var i = 0; i < multiPolygon.NumGeometries; i++) { - var p = (IPolygon)multiPolygon[i]; + var p = (Polygon)multiPolygon[i]; var rect = DrawPolygonEx(g, p, brush, pen, clip, map); canvasArea = rect.ExpandToInclude(canvasArea); } @@ -237,7 +237,7 @@ public static RectangleF DrawMultiPolygonEx(Graphics g, IMultiPolygon multiPolyg /// Specifies whether polygon clipping should be applied /// Map reference [MethodImpl(MethodImplOptions.Synchronized)] - public static void DrawPolygon(Graphics g, IPolygon pol, Brush brush, Pen pen, bool clip, MapViewport map) + public static void DrawPolygon(Graphics g, Polygon pol, Brush brush, Pen pen, bool clip, MapViewport map) { DrawPolygonEx(g, pol, brush, pen, clip, map); } @@ -252,7 +252,7 @@ public static void DrawPolygon(Graphics g, IPolygon pol, Brush brush, Pen pen, b /// Specifies whether polygon clipping should be applied /// Map reference /// The area of the map that was affected by the drawing of the geometry. - public static RectangleF DrawPolygonEx(Graphics g, IPolygon pol, Brush brush, Pen pen, bool clip, MapViewport map) + public static RectangleF DrawPolygonEx(Graphics g, Polygon pol, Brush brush, Pen pen, bool clip, MapViewport map) { if (pol.ExteriorRing == null) return RectangleF.Empty; @@ -272,7 +272,7 @@ public static RectangleF DrawPolygonEx(Graphics g, IPolygon pol, Brush brush, Pe //Add the interior polygons (holes) if (pol.NumInteriorRings > 0) { - foreach (ILinearRing ring in pol.InteriorRings) + foreach (LinearRing ring in pol.InteriorRings) { points = ring.TransformToImage(map); if (!clip) @@ -352,9 +352,9 @@ public static PointF[] LimitValues(PointF[] vertices, float limit) public static SizeOfStringDelegate SizeOfString { get { return _sizeOfString ?? (_sizeOfString = SizeOfStringCeiling); } - set - { - if (value != null ) + set + { + if (value != null) _sizeOfString = value; } } @@ -382,7 +382,7 @@ public static SizeF SizeOfStringBase(Graphics g, string text, Font font) public static SizeF SizeOfString74(Graphics g, string text, Font font) { var s = g.MeasureString(text, font); - return new SizeF(s.Width * 0.74f+1f, s.Height * 0.74f); + return new SizeF(s.Width * 0.74f + 1f, s.Height * 0.74f); } /// /// Function to get the of a string when rendered with the given font. @@ -472,7 +472,7 @@ public static RectangleF DrawLabelEx(Graphics g, PointF labelPoint, PointF offse rotationPoint = rotationPoint ?? labelPoint; origTrans = g.Transform.Clone(); - + g.TranslateTransform(rotationPoint.Value.X, rotationPoint.Value.Y); g.RotateTransform(rotation); @@ -489,9 +489,9 @@ public static RectangleF DrawLabelEx(Graphics g, PointF labelPoint, PointF offse using (var path = new GraphicsPath()) { - path.AddString(text, font.FontFamily, (int) font.Style, font.Size, + path.AddString(text, font.FontFamily, (int)font.Style, font.Size, new RectangleF(labelPoint, labelSize), - new StringFormat {Alignment = sAlign}); + new StringFormat { Alignment = sAlign }); if (halo != null) { @@ -509,9 +509,9 @@ public static RectangleF DrawLabelEx(Graphics g, PointF labelPoint, PointF offse origTrans.Dispose(); } - if (symTrans == null) + if (symTrans == null) return background; - + var pts = background.ToPointArray(); symTrans.TransformPoints(pts); symTrans.Dispose(); @@ -679,7 +679,7 @@ internal static PointF[] ClipPolygon(PointF[] vertices, int width, int height) /// Symbol offset af scale=1 /// Map reference [MethodImpl(MethodImplOptions.Synchronized)] - public static void DrawPoint(Graphics g, IPoint point, Brush b, float size, PointF offset, MapViewport map) + public static void DrawPoint(Graphics g, Point point, Brush b, float size, PointF offset, MapViewport map) { DrawPointEx(g, point, b, size, offset, map); } @@ -693,7 +693,7 @@ public static void DrawPoint(Graphics g, IPoint point, Brush b, float size, Poin /// Symbol offset af scale=1 /// Map reference [MethodImpl(MethodImplOptions.Synchronized)] - public static RectangleF DrawPointEx(Graphics g, IPoint point, Brush b, float size, PointF offset, MapViewport map) + public static RectangleF DrawPointEx(Graphics g, Point point, Brush b, float size, PointF offset, MapViewport map) { if (point == null) return RectangleF.Empty; @@ -702,10 +702,10 @@ public static RectangleF DrawPointEx(Graphics g, IPoint point, Brush b, float si var width = size; var height = size; - + float minX = (int)pp.X - width / 2 + offset.X; - float minY = (int) pp.Y - height / 2 + offset.Y; - + float minY = (int)pp.Y - height / 2 + offset.Y; + g.FillEllipse(b, minX, minY, width, height); return new RectangleF(minX, minY, width, height); @@ -719,7 +719,7 @@ public static RectangleF DrawPointEx(Graphics g, IPoint point, Brush b, float si /// Symbolizer to decorate point /// Map reference [MethodImpl(MethodImplOptions.Synchronized)] - public static void DrawPoint(IPointSymbolizer symbolizer, Graphics g, IPoint point, MapViewport map) => DrawPointEx(symbolizer, g, point, map); + public static void DrawPoint(IPointSymbolizer symbolizer, Graphics g, Point point, MapViewport map) => DrawPointEx(symbolizer, g, point, map); /// /// Renders a point to the map. @@ -729,13 +729,13 @@ public static RectangleF DrawPointEx(Graphics g, IPoint point, Brush b, float si /// Symbolizer to decorate point /// Map reference [MethodImpl(MethodImplOptions.Synchronized)] - public static RectangleF DrawPointEx(IPointSymbolizer symbolizer, Graphics g, IPoint point, MapViewport map) + public static RectangleF DrawPointEx(IPointSymbolizer symbolizer, Graphics g, Point point, MapViewport map) { if (point == null) - return RectangleF.Empty; + return RectangleF.Empty; symbolizer.Render(map, point, g); - return ((IPointSymbolizerEx)symbolizer).CanvasArea; + return ((IPointSymbolizerEx)symbolizer).CanvasArea; } /// @@ -749,7 +749,7 @@ public static RectangleF DrawPointEx(IPointSymbolizer symbolizer, Graphics g, IP /// Symbol rotation in degrees /// Map reference [MethodImpl(MethodImplOptions.Synchronized)] - public static void DrawPoint(Graphics g, IPoint point, Image symbol, float symbolscale, PointF offset, + public static void DrawPoint(Graphics g, Point point, Image symbol, float symbolscale, PointF offset, float rotation, MapViewport map) => DrawPointEx(g, point, symbol, symbolscale, offset, rotation, map); /// @@ -763,7 +763,7 @@ public static void DrawPoint(Graphics g, IPoint point, Image symbol, float symbo /// Symbol rotation in degrees /// Map reference [MethodImpl(MethodImplOptions.Synchronized)] - public static RectangleF DrawPointEx(Graphics g, IPoint point, Image symbol, float symbolScale, PointF offset, + public static RectangleF DrawPointEx(Graphics g, Point point, Image symbol, float symbolScale, PointF offset, float rotation, MapViewport map) { if (point == null) @@ -779,7 +779,7 @@ public static RectangleF DrawPointEx(Graphics g, IPoint point, Image symbol, flo float left = pp.X - width / 2 + offset.X * symbolScale; float top = pp.Y - height / 2 + offset.Y * symbolScale; - Matrix symTrans = null; + Matrix symTrans = null; Matrix origTrans = null; if (rotation != 0 && !Single.IsNaN(rotation)) @@ -800,16 +800,16 @@ public static RectangleF DrawPointEx(Graphics g, IPoint point, Image symbol, flo { g.DrawImage(symbol, left, top, width, height); } - + if (origTrans != null) { g.Transform = origTrans; origTrans.Dispose(); } - if (symTrans== null) + if (symTrans == null) return new RectangleF(left, top, width, height); - + var pts = new[] { new PointF(left, top), @@ -823,7 +823,7 @@ public static RectangleF DrawPointEx(Graphics g, IPoint point, Image symbol, flo } /// - /// Renders a to the map. + /// Renders a to the map. /// /// Graphics reference /// MultiPoint to render @@ -833,11 +833,11 @@ public static RectangleF DrawPointEx(Graphics g, IPoint point, Image symbol, flo /// Symbol rotation in degrees /// Map reference [MethodImpl(MethodImplOptions.Synchronized)] - public static void DrawMultiPoint(Graphics g, IMultiPoint points, Image symbol, float symbolScale, + public static void DrawMultiPoint(Graphics g, MultiPoint points, Image symbol, float symbolScale, PointF offset, float rotation, MapViewport map) => DrawMultiPointEx(g, points, symbol, symbolScale, offset, rotation, map); /// - /// Renders a to the map. + /// Renders a to the map. /// /// Graphics reference /// MultiPoint to render @@ -847,45 +847,45 @@ public static void DrawMultiPoint(Graphics g, IMultiPoint points, Image symbol, /// Symbol rotation in degrees /// Map reference [MethodImpl(MethodImplOptions.Synchronized)] - public static RectangleF DrawMultiPointEx(Graphics g, IMultiPoint points, Image symbol, float symbolScale, + public static RectangleF DrawMultiPointEx(Graphics g, MultiPoint points, Image symbol, float symbolScale, PointF offset, float rotation, MapViewport map) { var canvasArea = RectangleF.Empty; for (var i = 0; i < points.NumGeometries; i++) { - var rect = DrawPointEx(g, (IPoint) points[i], symbol, symbolScale, offset, rotation, map); - canvasArea = rect.ExpandToInclude(canvasArea); + var rect = DrawPointEx(g, (Point)points[i], symbol, symbolScale, offset, rotation, map); + canvasArea = rect.ExpandToInclude(canvasArea); } return canvasArea; } /// - /// Renders a to the map. + /// Renders a to the map. /// /// Graphics reference /// MultiPoint to render /// Symbolizer to decorate point /// Map reference [MethodImpl(MethodImplOptions.Synchronized)] - public static void DrawMultiPoint(IPointSymbolizer symbolizer, Graphics g, IMultiPoint points, MapViewport map) + public static void DrawMultiPoint(IPointSymbolizer symbolizer, Graphics g, MultiPoint points, MapViewport map) => DrawMultiPointEx(symbolizer, g, points, map); /// - /// Renders a to the map. + /// Renders a to the map. /// /// Graphics reference /// MultiPoint to render /// Symbolizer to decorate point /// Map reference [MethodImpl(MethodImplOptions.Synchronized)] - public static RectangleF DrawMultiPointEx(IPointSymbolizer symbolizer, Graphics g, IMultiPoint points, MapViewport map) + public static RectangleF DrawMultiPointEx(IPointSymbolizer symbolizer, Graphics g, MultiPoint points, MapViewport map) { symbolizer.Render(map, points, g); return ((IPointSymbolizerEx)symbolizer).CanvasArea; } /// - /// Renders a to the map. + /// Renders a to the map. /// /// Graphics reference /// MultiPoint to render @@ -894,11 +894,11 @@ public static RectangleF DrawMultiPointEx(IPointSymbolizer symbolizer, Graphics /// Symbol offset af scale=1 /// Map reference [MethodImpl(MethodImplOptions.Synchronized)] - public static void DrawMultiPoint(Graphics g, IMultiPoint points, Brush brush, float size, PointF offset, MapViewport map) + public static void DrawMultiPoint(Graphics g, MultiPoint points, Brush brush, float size, PointF offset, MapViewport map) => DrawMultiPointEx(g, points, brush, size, offset, map); /// - /// Renders a to the map. + /// Renders a to the map. /// /// Graphics reference /// MultiPoint to render @@ -907,12 +907,12 @@ public static void DrawMultiPoint(Graphics g, IMultiPoint points, Brush brush, f /// Symbol offset af scale=1 /// Map reference [MethodImpl(MethodImplOptions.Synchronized)] - public static RectangleF DrawMultiPointEx(Graphics g, IMultiPoint points, Brush brush, float size, PointF offset, MapViewport map) + public static RectangleF DrawMultiPointEx(Graphics g, MultiPoint points, Brush brush, float size, PointF offset, MapViewport map) { var canvasArea = RectangleF.Empty; for (var i = 0; i < points.NumGeometries; i++) { - var point = (IPoint) points[i]; + var point = (Point)points[i]; var rect = DrawPointEx(g, point, brush, size, offset, map); canvasArea = rect.ExpandToInclude(canvasArea); } @@ -1040,7 +1040,7 @@ internal static RectangleF ToRectangleF(this PointF[] self) /// internal static PointF[] ToPointArray(this RectangleF self) { - return new [] + return new[] { new PointF(self.X, self.Y), new PointF(self.X + self.Width, self.Y), @@ -1074,23 +1074,23 @@ internal static System.Drawing.Point[] ToPointArray(this Rectangle self) /// Either of the arrays could be empty, so must return new array internal static PointF[] Union(this PointF[] self, PointF[] other) { - if (other.Length == 0) + if (other.Length == 0) return self; if (self.Length == 0) return other; - float minX = Math.Min(self.Min(p => p.X), other.Min(p => p.X)); + float minX = Math.Min(self.Min(p => p.X), other.Min(p => p.X)); float maxX = Math.Max(self.Max(p => p.X), other.Max(p => p.X)); float minY = Math.Min(self.Min(p => p.Y), other.Min(p => p.Y)); float maxY = Math.Max(self.Max(p => p.Y), other.Max(p => p.Y)); float width = maxX - minX; float height = maxY - minY; - - return new [] + + return new[] { - new PointF(minX, minY), + new PointF(minX, minY), new PointF(minX + width, minY), new PointF(minX + width, minY + height), new PointF(minX, minY + height), diff --git a/SharpMap/Session.cs b/SharpMap/Session.cs index 83b2d197..5dc1af09 100644 --- a/SharpMap/Session.cs +++ b/SharpMap/Session.cs @@ -1,6 +1,7 @@ -using System; -using Common.Logging; -using GeoAPI; +using Common.Logging; +using NetTopologySuite; +using SharpMap.CoordinateSystems; +using System; namespace SharpMap { @@ -9,8 +10,8 @@ namespace SharpMap /// public class Session : ISession { - private static ICoordinateSystemRepository _repository; - private ICoordinateSystemServices _coordinateSystemServices; + private ICoordinateSystemRepository _repository; + private CoordinateSystemServices _coordinateSystemServices; /// /// Static constructor @@ -28,12 +29,12 @@ static Session() /// /// The geometry services instance /// - public IGeometryServices GeometryServices { get; set; } + public NtsGeometryServices GeometryServices { get; set; } /// /// Gets the coordinate system services instance /// - public ICoordinateSystemServices CoordinateSystemServices + public CoordinateSystemServices CoordinateSystemServices { get { @@ -60,7 +61,7 @@ public ICoordinateSystemRepository CoordinateSystemRepository /// /// The geometry services class /// A reference to this session - public ISession SetGeometryServices(IGeometryServices geometryServices) + public ISession SetGeometryServices(NtsGeometryServices geometryServices) { GeometryServices = geometryServices; return this; @@ -71,7 +72,7 @@ public ISession SetGeometryServices(IGeometryServices geometryServices) /// /// The coordinate system services class /// A reference to this session - public ISession SetCoordinateSystemServices(ICoordinateSystemServices coordinateSystemServices) + public ISession SetCoordinateSystemServices(CoordinateSystemServices coordinateSystemServices) { CoordinateSystemServices = coordinateSystemServices; return this; @@ -100,4 +101,4 @@ public ISession ReadConfiguration() } #endregion } -} \ No newline at end of file +} diff --git a/SharpMap/SharpMap.csproj b/SharpMap/SharpMap.csproj index 0cafd443..45f24081 100644 --- a/SharpMap/SharpMap.csproj +++ b/SharpMap/SharpMap.csproj @@ -24,12 +24,12 @@ - - - - + + + + - + @@ -39,6 +39,10 @@ + + + +