Skip to content

Commit 36ebda5

Browse files
committed
Factor out rarely used converter code into seperate projects
ReSharper code modifications Update of some external libraries Begin to wire SharpMap session
1 parent 8346dbf commit 36ebda5

25 files changed

+408
-506
lines changed

Examples/SharpMap.Demo.Wms/SharpMap.Demo.Wms.csproj

+7-3
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@
5858
<HintPath>..\..\packages\NetTopologySuite.1.14\lib\net40-Client\NetTopologySuite.dll</HintPath>
5959
<Private>True</Private>
6060
</Reference>
61-
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
62-
<SpecificVersion>False</SpecificVersion>
63-
<HintPath>..\..\packages\Newtonsoft.Json.6.0.3\lib\net40\Newtonsoft.Json.dll</HintPath>
61+
<Reference Include="Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
62+
<HintPath>..\..\packages\Newtonsoft.Json.7.0.1\lib\net40\Newtonsoft.Json.dll</HintPath>
63+
<Private>True</Private>
6464
</Reference>
6565
<Reference Include="PowerCollections, Version=1.0.0.0, Culture=neutral, PublicKeyToken=2573bf8a1bdddcd5, processorArchitecture=MSIL">
6666
<HintPath>..\..\packages\NetTopologySuite.1.14\lib\net40-Client\PowerCollections.dll</HintPath>
@@ -701,6 +701,10 @@
701701
<Content Include="packages.config" />
702702
</ItemGroup>
703703
<ItemGroup>
704+
<ProjectReference Include="..\..\SharpMap.Converters.GeoJSON\SharpMap.Converters.GeoJSON.csproj">
705+
<Project>{721412e1-5589-4a18-a095-f8e0427bb163}</Project>
706+
<Name>SharpMap.Converters.GeoJSON</Name>
707+
</ProjectReference>
704708
<ProjectReference Include="..\..\SharpMap.Web\SharpMap.Web.csproj">
705709
<Project>{292EF671-4063-4952-8DE0-423DF72A0950}</Project>
706710
<Name>SharpMap.Web</Name>
+5-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
3-
<package id="GeoAPI" version="1.7.4" targetFramework="net45" requireReinstallation="true" />
3+
<package id="GeoAPI" version="1.7.4" targetFramework="net40-Client" />
44
<package id="Microsoft.AspNet.Mvc" version="3.0.50813.1" targetFramework="net45" />
55
<package id="Microsoft.AspNet.Razor" version="1.0.20105.408" targetFramework="net45" />
66
<package id="Microsoft.AspNet.WebPages" version="1.0.20105.408" targetFramework="net45" />
77
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net45" />
8-
<package id="NetTopologySuite" version="1.14" targetFramework="net45" requireReinstallation="true" />
9-
<package id="Newtonsoft.Json" version="6.0.3" targetFramework="net40" />
10-
<package id="ProjNET4GeoAPI" version="1.3.2-pre1" targetFramework="net45" requireReinstallation="true" />
11-
<package id="System.Data.SQLite.Core" version="1.0.94.0" targetFramework="net45" requireReinstallation="true" />
8+
<package id="NetTopologySuite" version="1.14" targetFramework="net40-Client" />
9+
<package id="Newtonsoft.Json" version="7.0.1" targetFramework="net40" />
10+
<package id="ProjNET4GeoAPI" version="1.3.2-pre1" targetFramework="net40-Client" />
11+
<package id="System.Data.SQLite.Core" version="1.0.94.0" targetFramework="net40" />
1212
</packages>

Examples/WinFormSamples/Program.cs

+15-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@
22
using System.Windows.Forms;
33
using System.Threading;
44
using System.Net;
5+
using System.Text;
56
using NetTopologySuite;
7+
using ProjNet;
8+
using ProjNet.CoordinateSystems;
9+
using ProjNet.CoordinateSystems.Transformations;
10+
using SharpMap.CoordinateSystems;
611

712
namespace WinFormSamples
813
{
@@ -14,7 +19,16 @@ internal static class Program
1419
[STAThread]
1520
private static void Main()
1621
{
17-
GeoAPI.GeometryServiceProvider.Instance = new NtsGeometryServices();
22+
var gss = new NtsGeometryServices();
23+
var css = new SharpMap.CoordinateSystems.CoordinateSystemServices(
24+
new CoordinateSystemFactory(Encoding.ASCII),
25+
new CoordinateTransformationFactory());
26+
27+
GeoAPI.GeometryServiceProvider.Instance = gss;
28+
Session.Instance.SetGeometryServices(gss)
29+
.SetCoordinateSystemServices(css)
30+
.SetCoordinateSystemRepository(css);
31+
1832
Application.EnableVisualStyles();
1933
Application.SetCompatibleTextRenderingDefault(false);
2034
Application.Run(new DlgSamplesMenu());
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("SharpMap.Converters.GeoJSON")]
9+
[assembly: AssemblyDescription("GeoJSON Converter for SharpMap")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("SharpMap - Team")]
12+
[assembly: AssemblyProduct("SharpMap.Converters.GeoJSON")]
13+
[assembly: AssemblyCopyright("Copyright © 2008-2016 SharpMap - Team")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid("721412e1-5589-4a18-a095-f8e0427bb163")]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{721412E1-5589-4A18-A095-F8E0427BB163}</ProjectGuid>
8+
<OutputType>Library</OutputType>
9+
<AppDesignerFolder>Properties</AppDesignerFolder>
10+
<RootNamespace>SharpMap.Converters</RootNamespace>
11+
<AssemblyName>SharpMap.Converters.GeoJSON</AssemblyName>
12+
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
13+
<FileAlignment>512</FileAlignment>
14+
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
15+
</PropertyGroup>
16+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
17+
<DebugSymbols>true</DebugSymbols>
18+
<DebugType>full</DebugType>
19+
<Optimize>false</Optimize>
20+
<OutputPath>bin\Debug\</OutputPath>
21+
<DefineConstants>DEBUG;TRACE</DefineConstants>
22+
<ErrorReport>prompt</ErrorReport>
23+
<WarningLevel>4</WarningLevel>
24+
</PropertyGroup>
25+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
26+
<DebugType>pdbonly</DebugType>
27+
<Optimize>true</Optimize>
28+
<OutputPath>bin\Release\</OutputPath>
29+
<DefineConstants>TRACE</DefineConstants>
30+
<ErrorReport>prompt</ErrorReport>
31+
<WarningLevel>4</WarningLevel>
32+
</PropertyGroup>
33+
<ItemGroup>
34+
<Reference Include="GeoAPI, Version=1.7.4.0, Culture=neutral, PublicKeyToken=a1a0da7def465678, processorArchitecture=MSIL">
35+
<HintPath>..\packages\GeoAPI.1.7.4\lib\net40-client\GeoAPI.dll</HintPath>
36+
<Private>True</Private>
37+
</Reference>
38+
<Reference Include="Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
39+
<HintPath>..\packages\Newtonsoft.Json.7.0.1\lib\net40\Newtonsoft.Json.dll</HintPath>
40+
<Private>True</Private>
41+
</Reference>
42+
<Reference Include="System" />
43+
<Reference Include="System.Core" />
44+
<Reference Include="System.Xml.Linq" />
45+
<Reference Include="System.Data.DataSetExtensions" />
46+
<Reference Include="System.Data" />
47+
<Reference Include="System.Xml" />
48+
</ItemGroup>
49+
<ItemGroup>
50+
<Compile Include="..\SharedAssemblyVersion.cs">
51+
<Link>Properties\SharedAssemblyVersion.cs</Link>
52+
</Compile>
53+
<Compile Include="GeoJSON\GeoJSON.cs" />
54+
<Compile Include="GeoJSON\GeoJSONHelper.cs" />
55+
<Compile Include="GeoJSON\GeoJSONWriter.cs" />
56+
<Compile Include="Properties\AssemblyInfo.cs" />
57+
</ItemGroup>
58+
<ItemGroup>
59+
<ProjectReference Include="..\SharpMap\SharpMap.csproj">
60+
<Project>{c83777fc-aabb-47d9-911f-d76255d4d541}</Project>
61+
<Name>SharpMap</Name>
62+
</ProjectReference>
63+
</ItemGroup>
64+
<ItemGroup>
65+
<None Include="packages.config" />
66+
</ItemGroup>
67+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
68+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
69+
Other similar extension points exist, see Microsoft.Common.targets.
70+
<Target Name="BeforeBuild">
71+
</Target>
72+
<Target Name="AfterBuild">
73+
</Target>
74+
-->
75+
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<packages>
3+
<package id="GeoAPI" version="1.7.4" targetFramework="net40-client" />
4+
<package id="Newtonsoft.Json" version="7.0.1" targetFramework="net40-client" />
5+
</packages>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("SharpMap.Converters.Spatialite")]
9+
[assembly: AssemblyDescription("A Converter for SpatiaLite geometries")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("SharpMap - Team")]
12+
[assembly: AssemblyProduct("SharpMap.Converters.Spatialite")]
13+
[assembly: AssemblyCopyright("Copyright © 2008-2016 SharpMap - Team")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid("e4182b07-6955-434b-904c-15abea5f7409")]
24+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{E4182B07-6955-434B-904C-15ABEA5F7409}</ProjectGuid>
8+
<OutputType>Library</OutputType>
9+
<AppDesignerFolder>Properties</AppDesignerFolder>
10+
<RootNamespace>SharpMap.Converters</RootNamespace>
11+
<AssemblyName>SharpMap.Converters.Spatialite</AssemblyName>
12+
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
13+
<FileAlignment>512</FileAlignment>
14+
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
15+
</PropertyGroup>
16+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
17+
<DebugSymbols>true</DebugSymbols>
18+
<DebugType>full</DebugType>
19+
<Optimize>false</Optimize>
20+
<OutputPath>bin\Debug\</OutputPath>
21+
<DefineConstants>DEBUG;TRACE</DefineConstants>
22+
<ErrorReport>prompt</ErrorReport>
23+
<WarningLevel>4</WarningLevel>
24+
</PropertyGroup>
25+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
26+
<DebugType>pdbonly</DebugType>
27+
<Optimize>true</Optimize>
28+
<OutputPath>bin\Release\</OutputPath>
29+
<DefineConstants>TRACE</DefineConstants>
30+
<ErrorReport>prompt</ErrorReport>
31+
<WarningLevel>4</WarningLevel>
32+
</PropertyGroup>
33+
<ItemGroup>
34+
<Reference Include="GeoAPI, Version=1.7.4.0, Culture=neutral, PublicKeyToken=a1a0da7def465678, processorArchitecture=MSIL">
35+
<HintPath>..\packages\GeoAPI.1.7.4\lib\net40-client\GeoAPI.dll</HintPath>
36+
<Private>True</Private>
37+
</Reference>
38+
<Reference Include="System" />
39+
<Reference Include="System.Core" />
40+
</ItemGroup>
41+
<ItemGroup>
42+
<Compile Include="..\SharedAssemblyVersion.cs">
43+
<Link>Properties\SharedAssemblyVersion.cs</Link>
44+
</Compile>
45+
<Compile Include="Properties\AssemblyInfo.cs" />
46+
<Compile Include="SpatiaLite\GeometryFromSpatiaLite.cs" />
47+
</ItemGroup>
48+
<ItemGroup>
49+
<None Include="packages.config" />
50+
</ItemGroup>
51+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
52+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
53+
Other similar extension points exist, see Microsoft.Common.targets.
54+
<Target Name="BeforeBuild">
55+
</Target>
56+
<Target Name="AfterBuild">
57+
</Target>
58+
-->
59+
</Project>

SharpMap/Converters/SpatiaLite/GeometryFromSpatiaLite.cs SharpMap.Converters.Spatialite/SpatiaLite/GeometryFromSpatiaLite.cs

+7-17
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,8 @@
1717

1818
using System;
1919
using System.Collections.Generic;
20-
using System.Linq;
21-
using System.Text;
22-
using System.IO;
23-
using GeoAPI.Geometries;
2420

25-
namespace SharpMap.Converters.SpatiaLite
21+
namespace SharpMap.Converters
2622
{
2723
/// <summary>
2824
/// Converter of SpatiaLite geometries to NTS
@@ -38,7 +34,7 @@ public class GeometryFromSpatiaLite
3834
/// <param name="spatialliteGeom">The geometry blob</param>
3935
/// <param name="factory">The factory to create the result geometry</param>
4036
/// <returns>A geometry</returns>
41-
public static IGeometry Parse(byte[] spatialliteGeom, IGeometryFactory factory)
37+
public static GeoAPI.Geometries.IGeometry Parse(byte[] spatialliteGeom, GeoAPI.Geometries.IGeometryFactory factory)
4238
{
4339
var nBytes = spatialliteGeom.Length;
4440
if (spatialliteGeom.Length < 44
@@ -143,13 +139,9 @@ public static IGeometry Parse(byte[] spatialliteGeom, IGeometryFactory factory)
143139
return null;
144140
}
145141

146-
private static GeoAPI.Geometries.IPolygon ReadPolygon(byte[] geom, ref int idx, bool isLittleEndian, IGeometryFactory factory)
142+
private static GeoAPI.Geometries.IPolygon ReadPolygon(byte[] geom, ref int idx, bool isLittleEndian, GeoAPI.Geometries.IGeometryFactory factory)
147143
{
148-
double[] adfTuple = new double[2];
149-
int nRings;
150-
151-
152-
nRings = ReadUInt32(geom,ref idx, isLittleEndian);
144+
var nRings = ReadUInt32(geom,ref idx, isLittleEndian);
153145

154146
if (nRings < 1 || nRings > Int32.MaxValue / (2 * 8))
155147
throw new ApplicationException("Currupt SpatialLite geom");
@@ -165,18 +157,16 @@ private static GeoAPI.Geometries.IPolygon ReadPolygon(byte[] geom, ref int idx,
165157
holes = new List<GeoAPI.Geometries.ILinearRing>();
166158
for (int i = 1; i < lineStrings.Count; i++)
167159
{
168-
holes.Add(new NetTopologySuite.Geometries.LinearRing(lineStrings[i].Coordinates));
160+
holes.Add(factory.CreateLinearRing(lineStrings[i].Coordinates));
169161
}
170162
}
171163
return factory.CreatePolygon(shell, holes == null ? null : holes.ToArray());
172164
}
173165

174-
private static GeoAPI.Geometries.ILineString ReadLineString(byte[] geom, ref int idx, bool isLittleEndian, IGeometryFactory factory)
166+
private static GeoAPI.Geometries.ILineString ReadLineString(byte[] geom, ref int idx, bool isLittleEndian, GeoAPI.Geometries.IGeometryFactory factory)
175167
{
176-
double[] adfTuple = new double[2];
177-
int nPointCount;
178168
int iPoint;
179-
nPointCount = ReadUInt32(geom, ref idx, isLittleEndian);
169+
var nPointCount = ReadUInt32(geom, ref idx, isLittleEndian);
180170

181171
if (nPointCount < 0 || nPointCount > Int32.MaxValue / (2 * 8))
182172
throw new ApplicationException("Currupt SpatialLite geom");
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<packages>
3+
<package id="GeoAPI" version="1.7.4" targetFramework="net40" />
4+
</packages>

SharpMap.Web/SharpMap.Web.csproj

+6-2
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@
6464
<HintPath>..\packages\GeoAPI.1.7.4\lib\net40-client\GeoAPI.dll</HintPath>
6565
<Private>True</Private>
6666
</Reference>
67-
<Reference Include="Newtonsoft.Json">
68-
<HintPath>..\packages\Newtonsoft.Json.6.0.3\lib\net40\Newtonsoft.Json.dll</HintPath>
67+
<Reference Include="Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
68+
<HintPath>..\packages\Newtonsoft.Json.7.0.1\lib\net40\Newtonsoft.Json.dll</HintPath>
6969
<Private>True</Private>
7070
</Reference>
7171
<Reference Include="System" />
@@ -109,6 +109,10 @@
109109
</Target>
110110
-->
111111
<ItemGroup>
112+
<ProjectReference Include="..\SharpMap.Converters.GeoJSON\SharpMap.Converters.GeoJSON.csproj">
113+
<Project>{721412e1-5589-4a18-a095-f8e0427bb163}</Project>
114+
<Name>SharpMap.Converters.GeoJSON</Name>
115+
</ProjectReference>
112116
<ProjectReference Include="..\SharpMap\SharpMap.csproj">
113117
<Project>{C83777FC-AABB-47D9-911F-D76255D4D541}</Project>
114118
<Name>SharpMap</Name>

SharpMap.Web/packages.config

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
33
<package id="GeoAPI" version="1.7.4" targetFramework="net40" />
4-
<package id="Newtonsoft.Json" version="6.0.3" targetFramework="net40" />
4+
<package id="Newtonsoft.Json" version="7.0.1" targetFramework="net40" />
55
</packages>

0 commit comments

Comments
 (0)