From 61bb15a5d3ee645c915d46305df24b08763963e8 Mon Sep 17 00:00:00 2001 From: Diego Guidi Date: Wed, 3 Aug 2022 09:42:00 +0200 Subject: [PATCH 01/10] cleaned sharpmap.core + geojson --- Examples/DemoWinForm/DemoWinForm.csproj | 4 + Examples/DemoWinForm/MainForm.cs | 8 +- .../ExampleCodeSnippets/ClipLabelPosition.cs | 2 +- Examples/ExampleCodeSnippets/CreatingData.cs | 10 +- .../ExampleCodeSnippets.csproj | 5 +- .../ExampleCodeSnippets/GeoJsonExample.cs | 2 +- .../LengthIndexedLineSample.cs | 10 +- .../ExampleCodeSnippets/LineSymbolizerTest.cs | 16 +- Examples/ExampleCodeSnippets/NtsTests.cs | 2 +- .../PolygonSymbolizerTest.cs | 2 +- .../ExampleCodeSnippets/ProjectionExamples.cs | 10 +- .../ExampleCodeSnippets/ReadXmlExample.cs | 4 +- .../ExampleCodeSnipplets.VB.vbproj | 4 + .../Controllers/BuildingsController.cs | 2 +- .../Controllers/ProcessController.cs | 82 +- .../Controllers/UtfGridController.cs | 2 +- .../Handlers/StdJsonMapHandler.cs | 4 +- .../Plugins/GraphicsPathBuilder.cs | 24 +- .../SharpMap.Demo.Wms/Plugins/Utf8Grid.cs | 2 +- .../SharpMap.Demo.Wms.csproj | 53 +- Examples/SharpMap.Demo.Wms/Web.config | 74 +- Examples/SharpMap.Demo.Wms/packages.config | 25 +- Examples/WPFSamples/WPFSamples.csproj | 4 + Examples/WinFormSamples/Form2.cs | 4 +- .../WinFormSamples/FormDemoDrawGeometries.cs | 4 +- .../FormInteractiveVectorLayerRendering.cs | 2 +- .../FormMovingObjectOverTileLayer.cs | 4 +- .../Samples/SpatiaLiteSample.cs | 4 +- .../WinFormSamples/Samples/TileLayerSample.cs | 2 +- Examples/WinFormSamples/WinFormSamples.csproj | 4 + .../GeoJSON/GeoJSON.cs | 20 +- .../GeoJSON/GeoJSONHelper.cs | 4 +- .../GeoJSON/GeoJSONWriter.cs | 80 +- .../SharpMap.Converters.GeoJSON.csproj | 8 +- .../SharpMap.Converters.Spatialite.csproj | 4 + .../SpatiaLite/GeometryFromSpatiaLite.cs | 18 +- ...arpMap.CoordinateSystems.DotSpatial.csproj | 6 +- .../DotSpatialCoordinateTransformation.cs | 2 +- .../DotSpatialMathTransform.cs | 4 +- .../Converter/FileGdbGeometryConverter.cs | 44 +- .../FileGdbProvider.cs | 8 +- .../SharpMap.Data.Providers.FileGdb.csproj | 4 + .../Geometry/GpkgStandardBinary.cs | 2 +- .../GpkgProvider.cs | 8 +- .../SharpMap.Data.Providers.GeoPackage.csproj | 6 +- .../KmlFileFeaturesExporter.cs | 16 +- SharpMap.Data.Providers.Kml/KmlProvider.cs | 26 +- .../SharpMap.Data.Providers.Kml.csproj | 4 + .../Oracle.UDT/sdogeometry.cs | 4 +- .../OracleSpatial.cs | 2 +- ...arpMap.Data.Providers.OracleSpatial.csproj | 4 + .../Data/Providers/DataTablePoint.cs | 8 +- .../Data/Providers/ManagedSpatiaLite.cs | 16 +- .../Data/Providers/NtsProvider.cs | 2 +- .../Data/Providers/OgrProvider.cs | 18 +- SharpMap.Extensions/Data/Providers/Oracle.cs | 2 +- SharpMap.Extensions/Data/Providers/PostGIS.cs | 16 +- .../Data/Providers/SpatiaLite.cs | 14 +- SharpMap.Extensions/Data/Providers/SqlLite.cs | 2 +- SharpMap.Extensions/Layers/GdalRasterLayer.cs | 10 +- .../Layers/GdalRasterLayerCachingProxy.cs | 2 +- .../SharpMap.Extensions.csproj | 18 +- .../SharpMap.Layers.BruTile.csproj | 8 +- SharpMap.Layers.HeatLayer/HeatLayer.cs | 2 +- .../SharpMap.Layers.HeatLayer.csproj | 4 + .../SharpMap.Serialization.csproj | 4 + .../SqlGeographyConverter.cs | 22 +- .../SqlGeometryConverter.cs | 20 +- .../Data/Providers/SqlServer2008Ex.cs | 2 +- .../Geometries/SpatialOperationsEx.cs | 2 +- .../Geometries/SpatialRelationsEx.cs | 2 +- .../SharpMap.SqlServerSpatialObjects.csproj | 4 + SharpMap.UI.WPF/SharpMap.UI.WPF.csproj | 4 + SharpMap.UI.WPF/SharpMapHost.cs | 10 +- SharpMap.UI/Forms/MapBox.cs | 6 +- .../ToolBar/MapDigitizeGeometriesToolStrip.cs | 6 +- SharpMap.UI/Forms/WktGeometryCreator.cs | 4 +- SharpMap.UI/SharpMap.UI.csproj | 4 + ...SharpMap.Utilities.Indexing.SbnTree.csproj | 4 + SharpMap.Web/SharpMap.Web.csproj | 6 +- SharpMap.Web/Web/Wms/WmsServer.cs | 2 +- SharpMap/Base/DisposableObject.cs | 8 +- .../WellKnownBinary/GeometryFromWKB.cs | 78 +- .../WellKnownBinary/GeometryToWKB.cs | 131 +- .../WellKnownText/GeometryFromWKT.cs | 57 +- .../Converters/WellKnownText/GeometryToWKT.cs | 76 +- .../WellKnownText/SpatialReference.cs | 8 +- .../WellKnownText/WKTStreamTokenizer.cs | 2 +- .../CoordinateSystemExtensions.cs | 45 +- .../CoordinateSystemServices.cs | 50 +- .../ICoordinateSystemRepository.cs | 13 +- .../Transformations/GeometryTransform.cs | 99 +- SharpMap/Data/FeatureDataSet.cs | 75 +- SharpMap/Data/Providers/BaseProvider.cs | 73 +- .../Database/SharpMapFeatureColumn.cs | 5 +- .../Providers/Database/SpatialDbProvider.cs | 50 +- .../Providers/Database/SpatialDbUtility.cs | 15 +- SharpMap/Data/Providers/DbPoint.cs | 10 +- SharpMap/Data/Providers/DbTwoPointLine.cs | 8 +- SharpMap/Data/Providers/DbaseReader.cs | 88 +- SharpMap/Data/Providers/FilterProvider.cs | 12 +- .../Data/Providers/GeometryFeatureProvider.cs | 24 +- SharpMap/Data/Providers/GeometryProvider.cs | 46 +- SharpMap/Data/Providers/IProvider.cs | 11 +- SharpMap/Data/Providers/IProviderBase.cs | 10 +- .../Data/Providers/IProviderConfiguration.cs | 4 +- SharpMap/Data/Providers/MsSql.cs | 42 +- SharpMap/Data/Providers/MsSqlSpatial.cs | 50 +- .../Providers/PreparedGeometryProvider.cs | 18 +- SharpMap/Data/Providers/ShapeFile.cs | 1135 +++++++++-------- SharpMap/Data/Providers/ShapeFileHeader.cs | 16 +- SharpMap/Data/Providers/ShapeFileIndex.cs | 20 +- SharpMap/Data/Providers/ShapeType.cs | 28 +- SharpMap/Data/Providers/SqlServer2008.cs | 32 +- SharpMap/Data/Providers/WFSClient.cs | 55 +- SharpMap/Drawing/Color.cs | 2 +- SharpMap/Drawing/Matrix.cs | 12 +- SharpMap/Drawing/Point.cs | 7 +- SharpMap/Geometries/GeoAPIEx.cs | 46 +- SharpMap/ISession.cs | 18 +- SharpMap/Layers/AsyncLayerProxyLayer.cs | 42 +- SharpMap/Layers/GdiImageLayer.cs | 51 +- SharpMap/Layers/GdiImageLayerProxy.cs | 20 +- SharpMap/Layers/IAsyncLayer.cs | 4 +- SharpMap/Layers/ICanQueryLayer.cs | 4 +- SharpMap/Layers/ILayer.cs | 10 +- SharpMap/Layers/ILayerEx.cs | 2 +- SharpMap/Layers/ILayersContainer.cs | 5 +- SharpMap/Layers/LabelLayer.cs | 144 +-- SharpMap/Layers/Layer.cs | 65 +- SharpMap/Layers/LayerCollection.cs | 2 +- SharpMap/Layers/LayerGroup.cs | 30 +- .../Symbolizer/AnyGeometryVectorLayer.cs | 18 +- SharpMap/Layers/Symbolizer/BaseVectorLayer.cs | 22 +- .../Layers/Symbolizer/LinealVectorLayer.cs | 6 +- .../Layers/Symbolizer/PolygonalVectorLayer.cs | 8 +- .../Layers/Symbolizer/PuntalVectorLayer.cs | 4 +- SharpMap/Layers/TiledWmsLayer.cs | 38 +- SharpMap/Layers/VariableLayerCollection.cs | 2 +- SharpMap/Layers/VectorLayer.cs | 84 +- SharpMap/Layers/WmsLayer.cs | 22 +- SharpMap/Map/Map.cs | 108 +- SharpMap/Map/MapViewport.cs | 20 +- SharpMap/Map/MapViewportGuard.cs | 16 +- SharpMap/Rendering/Decoration/Disclaimer.cs | 15 +- SharpMap/Rendering/Decoration/EyeOfSight.cs | 22 +- .../Decoration/Graticule/Graticule.cs | 141 +- .../Decoration/Graticule/GraticuleStyle.cs | 46 +- .../Rendering/Decoration/MapDecoration.cs | 16 +- .../Decoration/MapDecorationAnchorFlags.cs | 6 +- SharpMap/Rendering/Decoration/NorthArrow.cs | 30 +- .../Rendering/Decoration/ScaleBar/ScaleBar.cs | 22 +- .../Rendering/Decoration/ScaleBar/Unit.cs | 2 +- SharpMap/Rendering/Label.cs | 76 +- SharpMap/Rendering/LabelCollisionDetection.cs | 4 +- SharpMap/Rendering/LayerCollectionRenderer.cs | 22 +- .../Rendering/Symbolizer/BaseSymbolizer.cs | 2 +- .../Symbolizer/BasicLineSymbolizer.cs | 13 +- .../Symbolizer/BasicPolygonSymbolizer.cs | 41 +- .../Symbolizer/CachedLineSymbolizer.cs | 19 +- .../Symbolizer/CharacterPointSymbolizer.cs | 28 +- .../Symbolizer/CohenSutherlandLineClipping.cs | 38 +- .../Symbolizer/GeometrySymbolizer.cs | 26 +- .../Rendering/Symbolizer/ILineSymbolizer.cs | 5 +- .../Rendering/Symbolizer/IPointSymbolizer.cs | 5 +- .../Symbolizer/IPointSymbolizerEx.cs | 2 +- .../Symbolizer/IPolygonSymbolizer.cs | 4 +- .../Rendering/Symbolizer/LineSymbolizer.cs | 17 +- .../Symbolizer/ListPointSymbolizer.cs | 9 +- .../Symbolizer/PathPointSymbolizer.cs | 20 +- .../Rendering/Symbolizer/PointSymbolizer.cs | 8 +- .../Rendering/Symbolizer/PolygonSymbolizer.cs | 15 +- .../Symbolizer/RasterPointSymbolizer.cs | 10 +- SharpMap/Rendering/Symbolizer/Utility.cs | 18 +- .../Rendering/Symbolizer/WarpPathToPath.cs | 8 +- .../Symbolizer/WarpedLineSymbolizer.cs | 46 +- SharpMap/Rendering/TextOnPath.cs | 70 +- SharpMap/Rendering/Thematics/ColorBlend.cs | 52 +- SharpMap/Rendering/Thematics/CustomTheme.cs | 6 +- SharpMap/Rendering/Thematics/FontSizeTheme.cs | 16 +- SharpMap/Rendering/Thematics/GradientTheme.cs | 20 +- SharpMap/Rendering/Thematics/ITheme.cs | 2 +- .../Rendering/Thematics/UniqueValuesTheme.cs | 10 +- SharpMap/Rendering/VectorRenderer.cs | 127 +- SharpMap/Session.cs | 18 +- SharpMap/SharpMap.csproj | 14 +- SharpMap/Styles/GroupStyle.cs | 2 +- SharpMap/Styles/LabelStyle.cs | 18 +- SharpMap/Styles/SldConverter.cs | 22 +- SharpMap/Styles/Style.cs | 2 +- SharpMap/Styles/VectorStyle.cs | 19 +- SharpMap/Utilities/GeoSpatialMath.cs | 22 +- SharpMap/Utilities/Indexing/BinaryTree.cs | 25 +- .../Utilities/Indexing/SpatialIndexing.cs | 36 +- SharpMap/Utilities/LeastSquaresTransform.cs | 88 +- SharpMap/Utilities/LineOffset.cs | 4 +- SharpMap/Utilities/ScaleCalculations.cs | 4 +- SharpMap/Utilities/Surrogates.Brushes.cs | 8 +- SharpMap/Utilities/Surrogates.Helper.cs | 4 +- SharpMap/Utilities/Surrogates.cs | 50 +- SharpMap/Utilities/Transform.cs | 21 +- SharpMap/Utilities/Wfs/FeatureTypeInfo.cs | 11 +- SharpMap/Utilities/Wfs/GeometryFactories.cs | 177 +-- SharpMap/Utilities/Wfs/HttpClientUtil.cs | 6 +- SharpMap/Utilities/Wfs/IWFS_TextResources.cs | 2 +- SharpMap/Utilities/Wfs/IXPathQueryManager.cs | 6 +- SharpMap/Utilities/Wfs/OGCFilter_FE1_1_0.cs | 20 +- .../Utilities/Wfs/WFS_1_0_0_TextResources.cs | 2 +- .../Utilities/Wfs/WFS_1_1_0_TextResources.cs | 9 +- SharpMap/Utilities/Wfs/XPathQueryManager.cs | 12 +- .../Wfs/XPathQueryManager_DecoratorBase.cs | 2 +- SharpMap/Web/IClient.cs | 4 +- SharpMap/Web/OgcException.cs | 4 +- SharpMap/Web/Wcs/Capabilities.cs | 4 - SharpMap/Web/Wcs/Client.cs | 4 +- SharpMap/Web/WebUtilities.cs | 22 +- SharpMap/Web/Wfs/Capabilities.cs | 14 +- SharpMap/Web/Wfs/Client.cs | 24 +- SharpMap/Web/Wms/Client.cs | 61 +- .../Web/Wms/SpatialReferencedBoundingBox.cs | 4 +- SharpMap/Web/Wms/Tiling/ITileCache.cs | 4 +- .../Web/Wms/Tiling/TileCacheFileStorage.cs | 5 +- SharpMap/Web/Wms/Tiling/TileExtents.cs | 22 +- SharpMap/Web/Wms/Tiling/TileSet.cs | 8 +- UnitTests/Converters/SqlServer2008.cs | 4 +- UnitTests/Converters/WKB/WKBTests.cs | 6 +- UnitTests/Converters/WKT/WktGeometryTests.cs | 56 +- .../Data/Providers/DataTablePointTests.cs | 2 +- .../Data/Providers/DbPointProviderTest.cs | 2 +- UnitTests/Data/Providers/DbTests.cs | 2 +- .../Providers/DbTwoPointLineProviderTest.cs | 2 +- UnitTests/Data/Providers/GeoPackageTest.cs | 4 +- .../Providers/GeometryFeatureProviderTest.cs | 2 +- .../Data/Providers/OleDbPointProviderTest.cs | 2 +- UnitTests/Layers/Layer_AffectedAreaTest.cs | 4 +- UnitTests/MapDecorationTest.cs | 2 +- UnitTests/MapTest.cs | 10 +- .../CohenSutherlandLineClippingTest.cs | 2 +- .../Symbolizer/PolygonSymbolizerTest.cs | 2 +- UnitTests/TestData/CreatingData.cs | 10 +- UnitTests/UnitTests.csproj | 9 +- 241 files changed, 3061 insertions(+), 2962 deletions(-) diff --git a/Examples/DemoWinForm/DemoWinForm.csproj b/Examples/DemoWinForm/DemoWinForm.csproj index 01500ab5..e2108d4d 100644 --- a/Examples/DemoWinForm/DemoWinForm.csproj +++ b/Examples/DemoWinForm/DemoWinForm.csproj @@ -37,4 +37,8 @@ + + + + diff --git a/Examples/DemoWinForm/MainForm.cs b/Examples/DemoWinForm/MainForm.cs index cc058361..11b40896 100644 --- a/Examples/DemoWinForm/MainForm.cs +++ b/Examples/DemoWinForm/MainForm.cs @@ -90,7 +90,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,7 +157,7 @@ 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++) @@ -177,7 +177,7 @@ 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++) @@ -200,7 +200,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++) diff --git a/Examples/ExampleCodeSnippets/ClipLabelPosition.cs b/Examples/ExampleCodeSnippets/ClipLabelPosition.cs index d7b00d46..faafe65f 100644 --- a/Examples/ExampleCodeSnippets/ClipLabelPosition.cs +++ b/Examples/ExampleCodeSnippets/ClipLabelPosition.cs @@ -5,7 +5,7 @@ /// public class ClipLabelPosition { - private GeoAPI.Geometries.IGeometry _clip; + private GeoAPI.Geometries.Geometry _clip; private GeoAPI.Geometries.Prepared.IPreparedGeometry _prepClip; /// diff --git a/Examples/ExampleCodeSnippets/CreatingData.cs b/Examples/ExampleCodeSnippets/CreatingData.cs index 8c4e250f..eece8cd2 100644 --- a/Examples/ExampleCodeSnippets/CreatingData.cs +++ b/Examples/ExampleCodeSnippets/CreatingData.cs @@ -86,7 +86,7 @@ public static SharpMap.Data.FeatureDataTable CreatePointFeatureDataTableFromArra public static class ShapeFactory { - public static GeoAPI.Geometries.ILinearRing CreateRectangle(GeoAPI.Geometries.IGeometryFactory factory, + public static GeoAPI.Geometries.LinearRing CreateRectangle(GeoAPI.Geometries.GeometryFactory factory, GeoAPI.Geometries.Coordinate leftTop, GeoAPI.Geometries.Coordinate rightBottom) { var pts = new[] @@ -100,7 +100,7 @@ public static GeoAPI.Geometries.ILinearRing CreateRectangle(GeoAPI.Geometries.IG return factory.CreateLinearRing(pts); } - public static GeoAPI.Geometries.ILinearRing CreateRectangle(GeoAPI.Geometries.IGeometryFactory factory, + public static GeoAPI.Geometries.LinearRing CreateRectangle(GeoAPI.Geometries.GeometryFactory factory, GeoAPI.Geometries.Coordinate center, System.Drawing.SizeF size) { var wh = new System.Drawing.SizeF(size.Width * 0.5f, size.Height * 0.5f); @@ -110,13 +110,13 @@ public static GeoAPI.Geometries.ILinearRing CreateRectangle(GeoAPI.Geometries.IG return CreateRectangle(factory, lt, rb); } - public static GeoAPI.Geometries.ILinearRing CreateEllipse(GeoAPI.Geometries.IGeometryFactory factory, + public static GeoAPI.Geometries.LinearRing CreateEllipse(GeoAPI.Geometries.GeometryFactory factory, GeoAPI.Geometries.Coordinate center, System.Drawing.SizeF size) { return CreateEllipse(factory, center, size, 12); } - public static GeoAPI.Geometries.ILinearRing CreateEllipse(GeoAPI.Geometries.IGeometryFactory factory, + public static GeoAPI.Geometries.LinearRing CreateEllipse(GeoAPI.Geometries.GeometryFactory factory, GeoAPI.Geometries.Coordinate center, System.Drawing.SizeF size, int segmentsPerQuadrant) { const double piHalf = System.Math.PI * 0.5d; @@ -138,7 +138,7 @@ public static GeoAPI.Geometries.ILinearRing CreateEllipse(GeoAPI.Geometries.IGeo public class TestShapeFactory { - public static readonly GeoAPI.Geometries.IGeometryFactory Factory = + public static readonly GeoAPI.Geometries.GeometryFactory Factory = new NetTopologySuite.Geometries.GeometryFactory(new NetTopologySuite.Geometries.PrecisionModel(1000)); [NUnit.Framework.Test] diff --git a/Examples/ExampleCodeSnippets/ExampleCodeSnippets.csproj b/Examples/ExampleCodeSnippets/ExampleCodeSnippets.csproj index b8005dc1..37c9d582 100644 --- a/Examples/ExampleCodeSnippets/ExampleCodeSnippets.csproj +++ b/Examples/ExampleCodeSnippets/ExampleCodeSnippets.csproj @@ -16,7 +16,6 @@ - @@ -29,4 +28,8 @@ + + + + diff --git a/Examples/ExampleCodeSnippets/GeoJsonExample.cs b/Examples/ExampleCodeSnippets/GeoJsonExample.cs index 9bb156b8..40523c2c 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/LengthIndexedLineSample.cs b/Examples/ExampleCodeSnippets/LengthIndexedLineSample.cs index 79fff1d5..024b852a 100644 --- a/Examples/ExampleCodeSnippets/LengthIndexedLineSample.cs +++ b/Examples/ExampleCodeSnippets/LengthIndexedLineSample.cs @@ -5,8 +5,8 @@ namespace ExampleCodeSnippets [NUnit.Framework.TestFixture] public class LengthIndexedLineSample { -public GeoAPI.Geometries.IMultiLineString SplitLineString( - GeoAPI.Geometries.ILineString lineString, +public GeoAPI.Geometries.MultiLineString SplitLineString( + GeoAPI.Geometries.LineString lineString, System.Double length) { if (lineString == null || lineString.IsEmpty) @@ -16,13 +16,13 @@ public GeoAPI.Geometries.IMultiLineString SplitLineString( //var ntsLine = (NetTopologySuite.Geometries.LineString) // SharpMap.Converters.NTS.GeometryConverter.ToNTSGeometry(lineString, gf); - var ret = new System.Collections.Generic.List(); + 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) + var tmpLine = (GeoAPI.Geometries.LineString) lil.ExtractLine(currentLength, currentLength + length); ret.Add(tmpLine); currentLength += length; @@ -42,4 +42,4 @@ public void TestLengthIndexedLine() 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..dac9de92 100644 --- a/Examples/ExampleCodeSnippets/LineSymbolizerTest.cs +++ b/Examples/ExampleCodeSnippets/LineSymbolizerTest.cs @@ -26,7 +26,7 @@ public StreetDirectionSymbolizer() /// /// /// - private void OnRenderInternal(SharpMap.MapViewport map, GeoAPI.Geometries.ILineString lineString, + private void OnRenderInternal(SharpMap.MapViewport map, GeoAPI.Geometries.LineString lineString, System.Drawing.Graphics graphics) { @@ -36,7 +36,7 @@ private void OnRenderInternal(SharpMap.MapViewport map, GeoAPI.Geometries.ILineS { 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); + var arrow = (GeoAPI.Geometries.LineString) lil.ExtractLine(start, end); RenderArrow(map, graphics, arrow); @@ -48,7 +48,7 @@ private void OnRenderInternal(SharpMap.MapViewport map, GeoAPI.Geometries.ILineS while (offset + ArrowLength < lineString.Length) { - var arrow = (GeoAPI.Geometries.ILineString) lil.ExtractLine(offset, offset + ArrowLength); + var arrow = (GeoAPI.Geometries.LineString) lil.ExtractLine(offset, offset + ArrowLength); RenderArrow(map, graphics, arrow); offset += RepeatInterval; } @@ -61,7 +61,7 @@ private void OnRenderInternal(SharpMap.MapViewport map, GeoAPI.Geometries.ILineS /// The map /// The graphics object /// The arrow - private void RenderArrow(SharpMap.MapViewport map, System.Drawing.Graphics graphics, GeoAPI.Geometries.ILineString arrow) + private void RenderArrow(SharpMap.MapViewport map, System.Drawing.Graphics graphics, GeoAPI.Geometries.LineString arrow) { var pts = new System.Drawing.PointF[arrow.Coordinates.Length]; for (var i = 0; i < pts.Length; i++) @@ -95,16 +95,16 @@ public override void Begin(System.Drawing.Graphics g, SharpMap.MapViewport map, public void Render(SharpMap.MapViewport map, GeoAPI.Geometries.ILineal geometry, System.Drawing.Graphics graphics) { - if (geometry is GeoAPI.Geometries.IMultiLineString) + if (geometry is GeoAPI.Geometries.MultiLineString) { - var mls = (GeoAPI.Geometries.IMultiLineString) geometry; + var mls = (GeoAPI.Geometries.MultiLineString) geometry; for (var i = 0; i < mls.Count; i++) { - OnRenderInternal(map, (GeoAPI.Geometries.ILineString) mls.GetGeometryN(i), graphics); + OnRenderInternal(map, (GeoAPI.Geometries.LineString) mls.GetGeometryN(i), graphics); } return; } - OnRenderInternal(map, (GeoAPI.Geometries.ILineString) geometry, graphics); + OnRenderInternal(map, (GeoAPI.Geometries.LineString) geometry, graphics); } protected override void ReleaseManagedResources() diff --git a/Examples/ExampleCodeSnippets/NtsTests.cs b/Examples/ExampleCodeSnippets/NtsTests.cs index 1d0521fc..0f125992 100644 --- a/Examples/ExampleCodeSnippets/NtsTests.cs +++ b/Examples/ExampleCodeSnippets/NtsTests.cs @@ -22,7 +22,7 @@ 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)), diff --git a/Examples/ExampleCodeSnippets/PolygonSymbolizerTest.cs b/Examples/ExampleCodeSnippets/PolygonSymbolizerTest.cs index a186d33a..34001272 100644 --- a/Examples/ExampleCodeSnippets/PolygonSymbolizerTest.cs +++ b/Examples/ExampleCodeSnippets/PolygonSymbolizerTest.cs @@ -12,7 +12,7 @@ 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, GeoAPI.Geometries.Polygon polygon, System.Drawing.Graphics g) { var pt = polygon.Centroid; g.RenderingOrigin = diff --git a/Examples/ExampleCodeSnippets/ProjectionExamples.cs b/Examples/ExampleCodeSnippets/ProjectionExamples.cs index 1ceacf0c..00467dda 100644 --- a/Examples/ExampleCodeSnippets/ProjectionExamples.cs +++ b/Examples/ExampleCodeSnippets/ProjectionExamples.cs @@ -110,7 +110,7 @@ public AffineCoordinateTransformation2D(double[,] matrix) #region Overrides of MathTransform - public override GeoAPI.CoordinateSystems.Transformations.IMathTransform Inverse() + public override GeoAPI.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 +201,7 @@ public long AuthorityCode get { throw new System.NotImplementedException(); } } - public GeoAPI.CoordinateSystems.Transformations.IMathTransform MathTransform + public GeoAPI.CoordinateSystems.Transformations.MathTransform MathTransform { get { return this; } } @@ -262,7 +262,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; + GeoAPI.Geometries.Point smpt = (GeoAPI.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 +369,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 GeoAPI.Geometries.Point(0, 0), + new GeoAPI.Geometries.Point(matrix.OffsetX, matrix.OffsetY)); */ //Create Affine diff --git a/Examples/ExampleCodeSnippets/ReadXmlExample.cs b/Examples/ExampleCodeSnippets/ReadXmlExample.cs index 9357326e..6a021c96 100644 --- a/Examples/ExampleCodeSnippets/ReadXmlExample.cs +++ b/Examples/ExampleCodeSnippets/ReadXmlExample.cs @@ -8,8 +8,8 @@ public class ReadXmlExample /// /// the xml string /// Coordinates - public static System.Collections.Generic.IEnumerable PointsFromXml( - GeoAPI.Geometries.IGeometryFactory factory, + public static System.Collections.Generic.IEnumerable PointsFromXml( + GeoAPI.Geometries.GeometryFactory factory, System.IO.Stream xml) { foreach (var coordinate in CoordinatesFromXml(xml)) diff --git a/Examples/ExampleCodeSnipplets.VB/ExampleCodeSnipplets.VB.vbproj b/Examples/ExampleCodeSnipplets.VB/ExampleCodeSnipplets.VB.vbproj index eaccd23e..ab03e1a5 100644 --- a/Examples/ExampleCodeSnipplets.VB/ExampleCodeSnipplets.VB.vbproj +++ b/Examples/ExampleCodeSnipplets.VB/ExampleCodeSnipplets.VB.vbproj @@ -36,5 +36,9 @@ + + + + diff --git a/Examples/SharpMap.Demo.Wms/Controllers/BuildingsController.cs b/Examples/SharpMap.Demo.Wms/Controllers/BuildingsController.cs index 0934fbc6..7cd1000f 100644 --- a/Examples/SharpMap.Demo.Wms/Controllers/BuildingsController.cs +++ b/Examples/SharpMap.Demo.Wms/Controllers/BuildingsController.cs @@ -73,7 +73,7 @@ public JsonResult GetData(float w, float n, float e, float s, int z) 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/ProcessController.cs b/Examples/SharpMap.Demo.Wms/Controllers/ProcessController.cs index f9fbd36c..595be27d 100644 --- a/Examples/SharpMap.Demo.Wms/Controllers/ProcessController.cs +++ b/Examples/SharpMap.Demo.Wms/Controllers/ProcessController.cs @@ -22,50 +22,50 @@ 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); + 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) throw new ArgumentNullException("coll"); @@ -77,21 +77,21 @@ 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; } } @@ -99,30 +99,30 @@ private static IEnumerable DoClean(IGeometryCollection coll) [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"); @@ -136,7 +136,7 @@ public static IGeometry Polygonize(IGeometry geometry) 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,18 +146,18 @@ 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); } @@ -165,17 +165,17 @@ private static IEnumerable DoSplit(IGeometryCollection coll, ILineStr 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..16bb8d2e 100644 --- a/Examples/SharpMap.Demo.Wms/Controllers/UtfGridController.cs +++ b/Examples/SharpMap.Demo.Wms/Controllers/UtfGridController.cs @@ -74,7 +74,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; diff --git a/Examples/SharpMap.Demo.Wms/Handlers/StdJsonMapHandler.cs b/Examples/SharpMap.Demo.Wms/Handlers/StdJsonMapHandler.cs index 5caac04b..05852d29 100644 --- a/Examples/SharpMap.Demo.Wms/Handlers/StdJsonMapHandler.cs +++ b/Examples/SharpMap.Demo.Wms/Handlers/StdJsonMapHandler.cs @@ -16,7 +16,7 @@ namespace SharpMap.Demo.Wms.Handlers using SharpMap.Layers; using SharpMap.Web.Wms; - using Geometry = GeoAPI.Geometries.IGeometry; + using Geometry = GeoAPI.Geometries.Geometry; using BoundingBox = GeoAPI.Geometries.Envelope; public class StdJsonMapHandler : AbstractStdMapHandler @@ -103,7 +103,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; diff --git a/Examples/SharpMap.Demo.Wms/Plugins/GraphicsPathBuilder.cs b/Examples/SharpMap.Demo.Wms/Plugins/GraphicsPathBuilder.cs index 6f29674f..f24f3479 100644 --- a/Examples/SharpMap.Demo.Wms/Plugins/GraphicsPathBuilder.cs +++ b/Examples/SharpMap.Demo.Wms/Plugins/GraphicsPathBuilder.cs @@ -27,31 +27,31 @@ public GraphicsPathBuilder(RectangleF bounds, Size size) 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"); diff --git a/Examples/SharpMap.Demo.Wms/Plugins/Utf8Grid.cs b/Examples/SharpMap.Demo.Wms/Plugins/Utf8Grid.cs index c1d8c4ed..245bef9f 100644 --- a/Examples/SharpMap.Demo.Wms/Plugins/Utf8Grid.cs +++ b/Examples/SharpMap.Demo.Wms/Plugins/Utf8Grid.cs @@ -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)) diff --git a/Examples/SharpMap.Demo.Wms/SharpMap.Demo.Wms.csproj b/Examples/SharpMap.Demo.Wms/SharpMap.Demo.Wms.csproj index 69545110..962f284b 100644 --- a/Examples/SharpMap.Demo.Wms/SharpMap.Demo.Wms.csproj +++ b/Examples/SharpMap.Demo.Wms/SharpMap.Demo.Wms.csproj @@ -65,26 +65,39 @@ ..\..\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\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\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.Memory.4.5.5\lib\net461\System.Memory.dll - - ..\..\packages\System.Drawing.Common.4.6.0\lib\net461\System.Drawing.Common.dll + + + ..\..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll + + + ..\..\packages\System.Runtime.CompilerServices.Unsafe.4.5.3\lib\net461\System.Runtime.CompilerServices.Unsafe.dll @@ -95,34 +108,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 +767,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..95f181d4 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..3376633d 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.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..0a6c2186 100644 --- a/SharpMap/Layers/TiledWmsLayer.cs +++ b/SharpMap/Layers/TiledWmsLayer.cs @@ -16,6 +16,12 @@ // 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 GeoAPI.Geometries; +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 +32,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 +51,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 +258,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 +286,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 +336,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 +395,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 +477,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..ef48a20f 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..61ba3391 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 { @@ -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..5697628d 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 GeoAPI.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 GeoAPI.NetTopologySuite.NtsGeometryServices.Instance"); + var instance = NetTopologySuite.NtsGeometryServices.Instance; if (instance == null) { _logger.Debug("Returned null"); @@ -101,14 +97,14 @@ static Map() 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 GeoAPI.NetTopologySuite.NtsGeometryServices.Instance"); + Trace.WriteLine("Trying to access GeoAPI.NetTopologySuite.NtsGeometryServices.Instance"); + if (GeoAPI.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 = + GeoAPI.NetTopologySuite.NtsGeometryServices.Instance = ntsApiGeometryServices.GetProperty("Instance").GetValue(null, null) as GeoAPI.IGeometryServices; } @@ -119,7 +115,7 @@ 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 = + GeoAPI.NetTopologySuite.NtsGeometryServices.Instance = ntsApiGeometryServices.GetProperty("Instance").GetValue(null, null) as GeoAPI.IGeometryServices; } @@ -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 = NetTopologySuite.NtsGeometryServices.Instance.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..8956e891 100644 --- a/SharpMap/Rendering/Decoration/Graticule/Graticule.cs +++ b/SharpMap/Rendering/Decoration/Graticule/Graticule.cs @@ -1,17 +1,18 @@ -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.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 +41,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 +62,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 +136,7 @@ public Graticule() GraticuleLineStyle.Continuous, true, GraticuleBorders.LeftBottom) { - SecondaryPen = {DashStyle = DashStyle.Dash} + SecondaryPen = { DashStyle = DashStyle.Dash } }; GcsGraticuleStyle = new GraticuleStyle(GraticuleStyle.GraticuleTheme.Subtle, @@ -170,7 +171,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 +223,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 +235,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 +378,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 +399,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 +585,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 +641,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 +726,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 +765,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 +776,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 +856,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 +890,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 +930,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 +939,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 +973,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 +1000,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 +1068,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 +1082,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 +1098,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 +1186,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 +1221,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 +1233,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 +1257,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 +1268,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 +1309,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..df204f77 100644 --- a/SharpMap/Rendering/Symbolizer/BasicLineSymbolizer.cs +++ b/SharpMap/Rendering/Symbolizer/BasicLineSymbolizer.cs @@ -1,6 +1,7 @@ +using GeoAPI.Geometries; +using NetTopologySuite.Geometries; using System; using System.Drawing; -using GeoAPI.Geometries; namespace SharpMap.Rendering.Symbolizer { @@ -17,7 +18,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 +27,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 +47,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 +61,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 +69,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..735db479 100644 --- a/SharpMap/Rendering/Symbolizer/BasicPolygonSymbolizer.cs +++ b/SharpMap/Rendering/Symbolizer/BasicPolygonSymbolizer.cs @@ -1,6 +1,7 @@ +using GeoAPI.Geometries; +using NetTopologySuite.Geometries; using System; using System.Drawing; -using GeoAPI.Geometries; namespace SharpMap.Rendering.Symbolizer { @@ -49,12 +50,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 +64,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 +72,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 +127,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 +141,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 +158,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 +197,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..157ee12f 100644 --- a/SharpMap/Rendering/Symbolizer/CachedLineSymbolizer.cs +++ b/SharpMap/Rendering/Symbolizer/CachedLineSymbolizer.cs @@ -1,9 +1,10 @@ +using GeoAPI.Geometries; +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 +72,7 @@ protected override void ReleaseManagedResources() Fill.Dispose(); if (Pattern != null) Pattern.Dispose(); - + base.ReleaseManagedResources(); } @@ -106,7 +107,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 +126,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 +157,7 @@ protected override void ReleaseManagedResources() if (_fallback != null) _fallback.Dispose(); - + base.ReleaseManagedResources(); } @@ -200,13 +201,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 +258,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..cd0e7cb5 100644 --- a/SharpMap/Rendering/Symbolizer/LineSymbolizer.cs +++ b/SharpMap/Rendering/Symbolizer/LineSymbolizer.cs @@ -1,6 +1,7 @@ +using GeoAPI.Geometries; +using NetTopologySuite.Geometries; using System.Drawing; using System.Drawing.Drawing2D; -using GeoAPI.Geometries; //using KnownColor = System.Drawing.KnownColor namespace SharpMap.Rendering.Symbolizer @@ -33,9 +34,9 @@ protected override void ReleaseManagedResources() { CheckDisposed(); - if (Line != null) + if (Line != null) Line.Dispose(); - + base.ReleaseManagedResources(); } @@ -47,17 +48,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 +67,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 +76,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..8ed282c0 100644 --- a/SharpMap/Rendering/Symbolizer/PolygonSymbolizer.cs +++ b/SharpMap/Rendering/Symbolizer/PolygonSymbolizer.cs @@ -1,6 +1,7 @@ +using GeoAPI.Geometries; +using NetTopologySuite.Geometries; using System.Drawing; using System.Drawing.Drawing2D; -using GeoAPI.Geometries; using Point = System.Drawing.Point; namespace SharpMap.Rendering.Symbolizer @@ -63,17 +64,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 +83,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 +117,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..e527159d 100644 --- a/SharpMap/Rendering/VectorRenderer.cs +++ b/SharpMap/Rendering/VectorRenderer.cs @@ -15,17 +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 GeoAPI.Geometries; +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 +57,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 +72,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 +144,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 +157,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 +171,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 +200,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 +216,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 +238,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 +253,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 +273,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 +353,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 +383,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 +473,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 +490,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 +510,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 +680,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 +694,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 +703,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 +720,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 +730,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 +750,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 +764,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 +780,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 +801,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 +824,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 +834,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 +848,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 +895,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 +908,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 +1041,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 +1075,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..50ace727 100644 --- a/SharpMap/Session.cs +++ b/SharpMap/Session.cs @@ -1,6 +1,8 @@ -using System; -using Common.Logging; +using Common.Logging; using GeoAPI; +using NetTopologySuite; +using ProjNet; +using System; namespace SharpMap { @@ -10,7 +12,7 @@ namespace SharpMap public class Session : ISession { private static ICoordinateSystemRepository _repository; - private ICoordinateSystemServices _coordinateSystemServices; + private CoordinateSystemServices _coordinateSystemServices; /// /// Static constructor @@ -28,12 +30,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 +62,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 +73,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 +102,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 @@ + + + +