Skip to content

Commit af46c9b

Browse files
author
Jörg Battermann
committed
Some more abstraction
1 parent 84050f4 commit af46c9b

24 files changed

Lines changed: 490 additions & 260 deletions
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6+
<ProductVersion>8.0.30703</ProductVersion>
7+
<SchemaVersion>2.0</SchemaVersion>
8+
<ProjectGuid>{6C93B314-9208-4684-B873-172F7EC81689}</ProjectGuid>
9+
<OutputType>Library</OutputType>
10+
<AppDesignerFolder>Properties</AppDesignerFolder>
11+
<RootNamespace>GeoJSON.Net.Tests</RootNamespace>
12+
<AssemblyName>GeoJSON.Net.Tests</AssemblyName>
13+
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
14+
<FileAlignment>512</FileAlignment>
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="System" />
35+
<Reference Include="System.Core" />
36+
<Reference Include="Microsoft.CSharp" />
37+
<Reference Include="xunit">
38+
<HintPath>..\dependencies\xunit.dll</HintPath>
39+
</Reference>
40+
</ItemGroup>
41+
<ItemGroup>
42+
<Compile Include="Properties\AssemblyInfo.cs" />
43+
</ItemGroup>
44+
<ItemGroup>
45+
<ProjectReference Include="..\GeoJSON.Net\GeoJSON.Net.csproj">
46+
<Project>{7C0D45ED-681E-4DEC-9910-BAE1211E4889}</Project>
47+
<Name>GeoJSON.Net</Name>
48+
</ProjectReference>
49+
</ItemGroup>
50+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
51+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
52+
Other similar extension points exist, see Microsoft.Common.targets.
53+
<Target Name="BeforeBuild">
54+
</Target>
55+
<Target Name="AfterBuild">
56+
</Target>
57+
-->
58+
</Project>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// --------------------------------------------------------------------------------------------------------------------
2+
// <copyright file="AssemblyInfo.cs" company="Jörg Battermann">
3+
// Copyright © Jörg Battermann 2011
4+
// </copyright>
5+
// <summary>
6+
// AssemblyInfo.cs
7+
// </summary>
8+
// --------------------------------------------------------------------------------------------------------------------
9+
10+
using System.Reflection;
11+
using System.Runtime.InteropServices;
12+
13+
[assembly: AssemblyTitle("GeoJSON.Net.Tests")]
14+
[assembly: AssemblyDescription("Unit tests for the GeoJSON.Net library")]
15+
[assembly: AssemblyConfiguration("")]
16+
[assembly: AssemblyCompany("Jörg Battermann")]
17+
[assembly: AssemblyProduct("GeoJSON.Net.Tests")]
18+
[assembly: AssemblyCopyright("Copyright © Jörg Battermann 2011")]
19+
[assembly: AssemblyTrademark("")]
20+
[assembly: AssemblyCulture("")]
21+
22+
[assembly: ComVisible(false)]
23+
24+
[assembly: AssemblyVersion("0.0.0.1")]
25+
26+
[assembly: Guid("94688f28-e983-417d-8e6e-96d4c687e085")]
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<StyleCopSettings Version="4.3">
2+
<Analyzers>
3+
<Analyzer AnalyzerId="Microsoft.StyleCop.CSharp.DocumentationRules">
4+
<AnalyzerSettings>
5+
<StringProperty Name="CompanyName">Jörg Battermann</StringProperty>
6+
<StringProperty Name="Copyright">Copyright © Jörg Battermann 2011</StringProperty>
7+
</AnalyzerSettings>
8+
</Analyzer>
9+
</Analyzers>
10+
</StyleCopSettings>

src/GeoJSON.Net.sln

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
99
README = README
1010
EndProjectSection
1111
EndProject
12+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GeoJSON.Net.Tests", "GeoJSON.Net.Tests\GeoJSON.Net.Tests.csproj", "{6C93B314-9208-4684-B873-172F7EC81689}"
13+
EndProject
1214
Global
1315
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1416
Debug|Any CPU = Debug|Any CPU
@@ -19,6 +21,10 @@ Global
1921
{7C0D45ED-681E-4DEC-9910-BAE1211E4889}.Debug|Any CPU.Build.0 = Debug|Any CPU
2022
{7C0D45ED-681E-4DEC-9910-BAE1211E4889}.Release|Any CPU.ActiveCfg = Release|Any CPU
2123
{7C0D45ED-681E-4DEC-9910-BAE1211E4889}.Release|Any CPU.Build.0 = Release|Any CPU
24+
{6C93B314-9208-4684-B873-172F7EC81689}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
25+
{6C93B314-9208-4684-B873-172F7EC81689}.Debug|Any CPU.Build.0 = Debug|Any CPU
26+
{6C93B314-9208-4684-B873-172F7EC81689}.Release|Any CPU.ActiveCfg = Release|Any CPU
27+
{6C93B314-9208-4684-B873-172F7EC81689}.Release|Any CPU.Build.0 = Release|Any CPU
2228
EndGlobalSection
2329
GlobalSection(SolutionProperties) = preSolution
2430
HideSolutionNode = FALSE

src/GeoJSON.Net/Converters/PositionConverter.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@
1010
namespace GeoJSON.Net.Converters
1111
{
1212
using System;
13+
using System.Collections.Generic;
1314

14-
using GeoJSON.Net;
1515
using GeoJSON.Net.Exceptions;
1616
using GeoJSON.Net.Geometry;
1717

1818
using Newtonsoft.Json;
1919
using Newtonsoft.Json.Linq;
2020

2121
/// <summary>
22-
/// Converter to read and write the <see cref="Position" /> type.
22+
/// Converter to read and write the <see cref="GeographicPosition" /> type.
2323
/// </summary>
2424
public class PositionConverter : JsonConverter
2525
{
@@ -59,10 +59,10 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist
5959
}
6060
catch (Exception ex)
6161
{
62-
throw new ParsingException("Could not parse SimpleGeo Response. (Latitude or Longitude missing from Point geometry?)", ex);
62+
throw new ParsingException("Could not parse GeoJSON Response. (Latitude or Longitude missing from Point geometry?)", ex);
6363
}
6464

65-
return new Position(latitude, longitude);
65+
return new List<IPosition> { new GeographicPosition(latitude, longitude) };
6666
}
6767

6868
/// <summary>
@@ -74,7 +74,7 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist
7474
/// </returns>
7575
public override bool CanConvert(Type objectType)
7676
{
77-
return objectType == typeof(Position);
77+
return objectType == typeof(GeographicPosition);
7878
}
7979
}
8080
}

src/GeoJSON.Net/GeoJSON.Net.csproj

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,19 +51,22 @@
5151
<Compile Include="CoordinateReferenceSystem\ICRSObject.cs" />
5252
<Compile Include="CoordinateReferenceSystem\NamedCRS.cs" />
5353
<Compile Include="GeoJSONObject.cs" />
54+
<Compile Include="Geometry\GeometryCollection.cs" />
55+
<Compile Include="Geometry\ProjectedPosition.cs" />
56+
<Compile Include="Geometry\IPosition.cs" />
5457
<Compile Include="Geometry\MultiLineString.cs" />
55-
<Compile Include="Geometry\GeometryType.cs" />
5658
<Compile Include="Geometry\LineString.cs" />
5759
<Compile Include="Geometry\MultiPoint.cs" />
5860
<Compile Include="GeoJSONObjectType.cs" />
59-
<Compile Include="Geometry\Position.cs" />
61+
<Compile Include="Geometry\GeographicPosition.cs" />
6062
<Compile Include="Exceptions\ParsingException.cs" />
6163
<Compile Include="Feature\Feature.cs" />
6264
<Compile Include="Feature\FeatureCollection.cs" />
6365
<Compile Include="Geometry\IGeometryObject.cs" />
6466
<Compile Include="Geometry\MultiPolygon.cs" />
6567
<Compile Include="Geometry\Point.cs" />
6668
<Compile Include="Geometry\Polygon.cs" />
69+
<Compile Include="Geometry\Position.cs" />
6770
<Compile Include="IGeoJSONObject.cs" />
6871
<Compile Include="Properties\AssemblyInfo.cs" />
6972
</ItemGroup>

src/GeoJSON.Net/GeoJSONObject.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,11 @@ namespace GeoJSON.Net
1818
public abstract class GeoJSONObject : IGeoJSONObject
1919
{
2020
/// <summary>
21-
/// Gets the type of the Geometry Object.
21+
/// Gets the (mandatory) type of the <see cref="http://geojson.org/geojson-spec.html#geojson-objects">GeoJSON Object</see>.
2222
/// </summary>
23+
/// <value>
24+
/// The type of the object.
25+
/// </value>
2326
[JsonProperty(PropertyName = "type", Required = Required.Always)]
2427
public GeoJSONObjectType Type { get; internal set; }
2528

@@ -29,7 +32,7 @@ public abstract class GeoJSONObject : IGeoJSONObject
2932
/// <value>
3033
/// The Coordinate Reference System Objects.
3134
/// </value>
32-
[JsonProperty(PropertyName = "crs")]
35+
[JsonProperty(PropertyName = "crs", Required = Required.AllowNull)]
3336
public CoordinateReferenceSystem.ICRSObject CRS { get; set; }
3437

3538
/// <summary>
@@ -42,7 +45,7 @@ public abstract class GeoJSONObject : IGeoJSONObject
4245
/// In addition, the coordinate reference system for the bbox is assumed to match the coordinate reference
4346
/// system of the GeoJSON object of which it is a member.
4447
/// </value>
45-
[JsonProperty(PropertyName = "bbox")]
48+
[JsonProperty(PropertyName = "bbox", Required = Required.AllowNull)]
4649
public double[] BoundingBoxes { get; set; }
4750
}
4851
}

src/GeoJSON.Net/GeoJSONObjectType.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,9 @@
99

1010
namespace GeoJSON.Net
1111
{
12-
using System;
13-
1412
/// <summary>
1513
/// Defines the GeoJSON Objects types as defined in the <see cref="http://geojson.org/geojson-spec.html#geojson-objects">geojson.org v1.0 spec</see>.
1614
/// </summary>
17-
[Flags]
1815
public enum GeoJSONObjectType
1916
{
2017
/// <summary>

0 commit comments

Comments
 (0)