Skip to content

Commit 6718441

Browse files
Merge pull request #73 from GeoJSON-Net/rfc7946
Rfc7946
2 parents a454667 + c5621b9 commit 6718441

21 files changed

Lines changed: 97 additions & 98 deletions

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
#GeoJSON.NET [![NuGet Version](http://img.shields.io/nuget/v/GeoJSON.NET.svg?style=flat)](https://www.nuget.org/packages/GeoJSON.NET/) [![Build status](https://ci.appveyor.com/api/projects/status/i5afnui06gqco0wi)](https://ci.appveyor.com/project/GeojsonNet/geojson-net)
22

3-
GeoJSON.Net is a .NET library for the [GeoJSON v1.0 specificaton](http://geojson.org/geojson-spec.html) and it uses and provides [Newtonsoft Json.NET](http://json.codeplex.com) converters for serialization and deserialization of GeoJSON data.
3+
GeoJSON.Net is a .NET library for the [RFC 7946 The GeoJSON Format](https://tools.ietf.org/html/rfc7946) and it uses and provides [Newtonsoft Json.NET](http://json.codeplex.com) converters for serialization and deserialization of GeoJSON data.
44

55

66
##Installation & Usage
77
Well all you basically have to do is install the [GeoJSON.Net](https://www.nuget.org/packages/GeoJSON.Net/) NuGet package:
88

99
`PM> Install-Package GeoJSON.Net`
1010

11+
To deserialize a json string:
12+
13+
`var geoJsonObject = JsonConvert.DeserializeObject<Point>(json);`
14+
1115
That's all there is. Really. From there on you can go ahead and (De-)Serialize GeoJSON using the provided [converters](https://github.com/GeoJSON-Net/GeoJSON.Net/tree/master/src/GeoJSON.Net/Converters) - see [the Tests for example usage](https://github.com/GeoJSON-Net/GeoJSON.Net/tree/master/src/GeoJSON.Net.Tests).
1216

1317

src/GeoJSON.Net/CoordinateReferenceSystem/CRSBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ public override int GetHashCode()
136136
}
137137
else
138138
{
139-
toString = $"{item.Key}:{item.Value.ToString()}";
139+
toString = $"{item.Key}:{item.Value}";
140140
}
141141
hashCode = (hashCode * 397) ^ toString.GetHashCode();
142142
}

src/GeoJSON.Net/CoordinateReferenceSystem/CRSType.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
// Copyright © Joerg Battermann 2014
44
// </copyright>
55
// <summary>
6-
// Defines the GeoJSON Coordinate Reference System Objects (CRS) types as defined in the <see cref="http://geojson.org/geojson-spec.html#coordinate-reference-system-objects">geojson.org v1.0 spec</see>.
6+
// Defines the GeoJSON Coordinate Reference System Objects (CRS) types originally defined in the <see cref="http://geojson.org/geojson-spec.html#coordinate-reference-system-objects">geojson.org v1.0 spec</see>.
7+
// The current spec <see cref="https://tools.ietf.org/html/rfc7946#section-4" removes the CRS type, but allows to be left in for backwards compatibility.
78
// </summary>
89
// --------------------------------------------------------------------------------------------------------------------
910

@@ -13,7 +14,6 @@ namespace GeoJSON.Net.CoordinateReferenceSystem
1314
{
1415
/// <summary>
1516
/// Defines the GeoJSON Coordinate Reference System Objects (CRS) types as defined in the
16-
/// <see cref="http://geojson.org/geojson-spec.html#coordinate-reference-system-objects">geojson.org v1.0 spec</see>.
1717
/// </summary>
1818
public enum CRSType
1919
{
@@ -24,13 +24,13 @@ public enum CRSType
2424
Unspecified,
2525

2626
/// <summary>
27-
/// Defines the <see cref="http://geojson.org/geojson-spec.html#named-crs">Named</see> CRS type.
27+
/// Defines the Named CRS type.
2828
/// </summary>
2929
[EnumMember(Value = "name")]
3030
Name,
3131

3232
/// <summary>
33-
/// Defines the <see cref="http://geojson.org/geojson-spec.html#linked-crs">Linked</see> CRS type.
33+
/// Defines the Linked CRS type.
3434
/// </summary>
3535
[EnumMember(Value = "link")]
3636
Link

src/GeoJSON.Net/CoordinateReferenceSystem/DefaultCRS.cs

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
// Copyright © Joerg Battermann 2014
44
// </copyright>
55
// <summary>
6-
// Defines the <see cref="http://geojson.org/geojson-spec.html#coordinate-reference-system-objects">default CRS</see> type.
6+
// Defines the GeoJSON Coordinate Reference System Objects (CRS) types originally defined in the <see cref="http://geojson.org/geojson-spec.html#coordinate-reference-system-objects">geojson.org v1.0 spec</see>.
7+
// The current spec <see cref="https://tools.ietf.org/html/rfc7946#section-4" removes the CRS type, but allows to be left in for backwards compatibility.
78
// </summary>
89
// --------------------------------------------------------------------------------------------------------------------
910

@@ -12,15 +13,10 @@ namespace GeoJSON.Net.CoordinateReferenceSystem
1213
/// <summary>
1314
/// The default CRS is a geographic coordinate reference system,
1415
/// using the WGS84 datum, and with longitude and latitude units of decimal degrees.
15-
/// see http://geojson.org/geojson-spec.html#coordinate-reference-system-objects
16+
/// see https://tools.ietf.org/html/rfc7946#section-4
1617
/// </summary>
1718
public class DefaultCRS : NamedCRS
1819
{
19-
/// <summary>
20-
/// The CRS
21-
/// </summary>
22-
private static readonly DefaultCRS Crs = new DefaultCRS();
23-
2420
/// <summary>
2521
/// Initializes a new instance of the <see cref="DefaultCRS" /> class.
2622
/// </summary>
@@ -35,9 +31,6 @@ private DefaultCRS()
3531
/// <value>
3632
/// The instance.
3733
/// </value>
38-
public static DefaultCRS Instance
39-
{
40-
get { return Crs; }
41-
}
34+
public static DefaultCRS Instance { get; } = new DefaultCRS();
4235
}
4336
}

src/GeoJSON.Net/CoordinateReferenceSystem/LinkedCRS.cs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
// Copyright © Joerg Battermann 2014
44
// </copyright>
55
// <summary>
6-
// Defines the <see cref="http://geojson.org/geojson-spec.html#named-crs">Linked CRS type</see>.
6+
// Defines the <see cref="http://geojson.org/geojson-spec.html#named-crs">Linked CRS type</see>.
7+
// The current spec <see cref="https://tools.ietf.org/html/rfc7946#section-4" removes the CRS type, but allows to be left in for backwards compatibility.
78
// </summary>
89
// --------------------------------------------------------------------------------------------------------------------
910

@@ -21,24 +22,22 @@ public class LinkedCRS : CRSBase, ICRSObject
2122
/// Initializes a new instance of the <see cref="LinkedCRS" /> class.
2223
/// </summary>
2324
/// <param name="href">
24-
/// The mandatory <see cref="http://geojson.org/geojson-spec.html#linked-crs">href</see> member must be
25-
/// a dereferenceable URI.
25+
/// The mandatory href member must be a dereferenceable URI.
2626
/// </param>
2727
/// <param name="type">
28-
/// The optional type member will be put in the properties Dictionary as specified in the
29-
/// <see cref="http://geojson.org/geojson-spec.html#linked-crs">GeoJSON spec</see>.
28+
/// The optional type member will be put in the properties Dictionary
3029
/// </param>
3130
public LinkedCRS(string href, string type = "")
3231
{
3332
if (href == null)
3433
{
35-
throw new ArgumentNullException("href");
34+
throw new ArgumentNullException(nameof(href));
3635
}
3736

3837
Uri uri;
3938
if (href.Length == 0 || !Uri.TryCreate(href, UriKind.RelativeOrAbsolute, out uri))
4039
{
41-
throw new ArgumentException("must be a dereferenceable URI", "href");
40+
throw new ArgumentException("must be a dereferenceable URI", nameof(href));
4241
}
4342

4443
Properties = new Dictionary<string, object> { { "href", href } };
@@ -55,12 +54,10 @@ public LinkedCRS(string href, string type = "")
5554
/// Initializes a new instance of the <see cref="LinkedCRS" /> class.
5655
/// </summary>
5756
/// <param name="href">
58-
/// The mandatory <see cref="http://geojson.org/geojson-spec.html#linked-crs">href</see> member must be
59-
/// a dereferenceable URI.
57+
/// The mandatory href member must be a dereferenceable URI.
6058
/// </param>
6159
/// <param name="type">
62-
/// The optional type member will be put in the properties Dictionary as specified in the
63-
/// <see cref="http://geojson.org/geojson-spec.html#linked-crs">GeoJSON spec</see>.
60+
/// The optional type member will be put in the properties Dictionary
6461
/// </param>
6562
public LinkedCRS(Uri href, string type = "") : this(href != null ? href.ToString() : null, type)
6663
{

src/GeoJSON.Net/CoordinateReferenceSystem/NamedCRS.cs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,38 +3,37 @@
33
// Copyright © Joerg Battermann 2014
44
// </copyright>
55
// <summary>
6-
// Defines the <see cref="http://geojson.org/geojson-spec.html#named-crs">Named CRS type</see>.
6+
// Defines the <see cref="http://geojson.org/geojson-spec.html#named-crs">Named CRS type</see>.
7+
// The current spec <see cref="https://tools.ietf.org/html/rfc7946#section-4" removes the CRS type, but allows to be left in for backwards compatibility.
78
// </summary>
89
// --------------------------------------------------------------------------------------------------------------------
9-
1010
using System;
1111
using System.Collections.Generic;
1212

1313
namespace GeoJSON.Net.CoordinateReferenceSystem
1414
{
1515
/// <summary>
16-
/// Defines the <see cref="http://geojson.org/geojson-spec.html#named-crs">Named CRS type</see>.
16+
/// Defines the Named CRS type.
1717
/// </summary>
1818
public class NamedCRS : CRSBase, ICRSObject
1919
{
2020
/// <summary>
2121
/// Initializes a new instance of the <see cref="NamedCRS" /> class.
2222
/// </summary>
2323
/// <param name="name">
24-
/// The mandatory <see cref="http://geojson.org/geojson-spec.html#named-crs">name</see>
25-
/// member must be a string identifying a coordinate reference system. OGC CRS URNs such as
24+
/// The mandatory name member must be a string identifying a coordinate reference system. OGC CRS URNs such as
2625
/// 'urn:ogc:def:crs:OGC:1.3:CRS84' shall be preferred over legacy identifiers such as 'EPSG:4326'.
2726
/// </param>
2827
public NamedCRS(string name)
2928
{
3029
if (name == null)
3130
{
32-
throw new ArgumentNullException("name");
31+
throw new ArgumentNullException(nameof(name));
3332
}
3433

3534
if (name.Length == 0)
3635
{
37-
throw new ArgumentException("must be specified", "name");
36+
throw new ArgumentException("must be specified", nameof(name));
3837
}
3938

4039
Properties = new Dictionary<string, object> { { "name", name } };

src/GeoJSON.Net/Feature/Feature.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
namespace GeoJSON.Net.Feature
1919
{
2020
/// <summary>
21-
/// A GeoJSON <see cref="http://geojson.org/geojson-spec.html#feature-objects">Feature Object</see>.
21+
/// A GeoJSON <see cref="https://tools.ietf.org/html/rfc7946#section-3.2">Feature Object</see>.
2222
/// </summary>
2323
public class Feature : GeoJSONObject, IEqualityComparer<Feature>, IEquatable<Feature>
2424
{

src/GeoJSON.Net/GeoJSONObject.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
using System.Runtime.Serialization;
1212
using GeoJSON.Net.Converters;
1313
using GeoJSON.Net.CoordinateReferenceSystem;
14-
using GeoJSON.Net.Geometry;
1514
using Newtonsoft.Json;
1615
using Newtonsoft.Json.Converters;
1716
using System.Collections.Generic;
@@ -34,7 +33,7 @@ protected GeoJSONObject()
3433

3534
/// <summary>
3635
/// Gets or sets the (optional)
37-
/// <see cref="http://geojson.org/geojson-spec.html#coordinate-reference-system-objects">Bounding Boxes</see>.
36+
/// <see cref="https://tools.ietf.org/html/rfc7946#section-5">Bounding Boxes</see>.
3837
/// </summary>
3938
/// <value>
4039
/// The value of <see cref="BoundingBoxes" /> must be a 2*n array where n is the number of dimensions represented in
@@ -49,7 +48,7 @@ protected GeoJSONObject()
4948

5049
/// <summary>
5150
/// Gets or sets the (optional)
52-
/// <see cref="http://geojson.org/geojson-spec.html#coordinate-reference-system-objects">
51+
/// <see cref="https://tools.ietf.org/html/rfc7946#section-4">
5352
/// Coordinate Reference System
5453
/// Object.
5554
/// </see>
@@ -65,7 +64,7 @@ protected GeoJSONObject()
6564

6665
/// <summary>
6766
/// Gets the (mandatory) type of the
68-
/// <see cref="http://geojson.org/geojson-spec.html#geojson-objects">GeoJSON Object</see>.
67+
/// <see cref="https://tools.ietf.org/html/rfc7946#section-3">GeoJSON Object</see>.
6968
/// </summary>
7069
/// <value>
7170
/// The type of the object.

src/GeoJSON.Net/GeoJSONObjectType.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,59 +3,59 @@
33
// Copyright © Joerg Battermann 2014
44
// </copyright>
55
// <summary>
6-
// 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>.
6+
// Defines the GeoJSON Objects types as defined in the <see cref="https://tools.ietf.org/html/rfc7946#section-3">RFC 7946</see>.
77
// </summary>
88
// --------------------------------------------------------------------------------------------------------------------
99

1010
namespace GeoJSON.Net
1111
{
1212
/// <summary>
13-
/// 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>.
13+
/// Defines the GeoJSON Objects types as defined in the <see cref="https://tools.ietf.org/html/rfc7946#section-3">RFC 7946</see>.
1414
/// </summary>
1515
public enum GeoJSONObjectType
1616
{
1717
/// <summary>
18-
/// Defines the <see cref="http://geojson.org/geojson-spec.html#point">Point</see> type.
18+
/// Defines the <see cref="https://tools.ietf.org/html/rfc7946#section-3.1.2">Point</see> type.
1919
/// </summary>
2020
Point,
2121

2222
/// <summary>
23-
/// Defines the <see cref="http://geojson.org/geojson-spec.html#multipoint">MultiPoint</see> type.
23+
/// Defines the <see cref="https://tools.ietf.org/html/rfc7946#section-3.1.3">MultiPoint</see> type.
2424
/// </summary>
2525
MultiPoint,
2626

2727
/// <summary>
28-
/// Defines the <see cref="http://geojson.org/geojson-spec.html#linestring">LineString</see> type.
28+
/// Defines the <see cref="https://tools.ietf.org/html/rfc7946#section-3.1.4">LineString</see> type.
2929
/// </summary>
3030
LineString,
3131

3232
/// <summary>
33-
/// Defines the <see cref="http://geojson.org/geojson-spec.html#multilinestring">MultiLineString</see> type.
33+
/// Defines the <see chref="https://tools.ietf.org/html/rfc7946#section-3.1.5">MultiLineString</see> type.
3434
/// </summary>
3535
MultiLineString,
3636

3737
/// <summary>
38-
/// Defines the <see cref="http://geojson.org/geojson-spec.html#polygon">Polygon</see> type.
38+
/// Defines the <see cref="https://tools.ietf.org/html/rfc7946#section-3.1.6">Polygon</see> type.
3939
/// </summary>
4040
Polygon,
4141

4242
/// <summary>
43-
/// Defines the <see cref="http://geojson.org/geojson-spec.html#multipolygon">MultiPolygon</see> type.
43+
/// Defines the <see cref="https://tools.ietf.org/html/rfc7946#section-3.1.7">MultiPolygon</see> type.
4444
/// </summary>
4545
MultiPolygon,
4646

4747
/// <summary>
48-
/// Defines the <see cref="http://geojson.org/geojson-spec.html#geometry-collection">GeometryCollection</see> type.
48+
/// Defines the <see cref="https://tools.ietf.org/html/rfc7946#section-3.1.8">GeometryCollection</see> type.
4949
/// </summary>
5050
GeometryCollection,
5151

5252
/// <summary>
53-
/// Defines the <see cref="http://geojson.org/geojson-spec.html#feature-objects">Feature</see> type.
53+
/// Defines the <see cref="https://tools.ietf.org/html/rfc7946#section-3.2">Feature</see> type.
5454
/// </summary>
5555
Feature,
5656

5757
/// <summary>
58-
/// Defines the <see cref="http://geojson.org/geojson-spec.html#feature-collection-objects">FeatureCollection</see> type.
58+
/// Defines the <see cref="https://tools.ietf.org/html/rfc7946#section-3.3">FeatureCollection</see> type.
5959
/// </summary>
6060
FeatureCollection
6161
}

src/GeoJSON.Net/Geometry/GeographicPosition.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// Copyright © Joerg Battermann 2014
44
// </copyright>
55
// <summary>
6-
// Defines the Geographic Position type a.k.a. <see cref="http://geojson.org/geojson-spec.html#positions">Geographic Coordinate Reference System</see>.
6+
// Defines the Geographic Position type <see cref="https://tools.ietf.org/html/rfc7946#section-3.1.1">GeographicPosition</see>.
77
// </summary>
88
// --------------------------------------------------------------------------------------------------------------------
99

@@ -15,8 +15,8 @@
1515
namespace GeoJSON.Net.Geometry
1616
{
1717
/// <summary>
18-
/// Defines the Geographic Position type a.k.a.
19-
/// <see cref="http://geojson.org/geojson-spec.html#positions">Geographic Coordinate Reference System</see>.
18+
/// Defines the Geographic Position type
19+
/// <see cref="https://tools.ietf.org/html/rfc7946#section-3.1.1">Position</see>.
2020
/// </summary>
2121
public class GeographicPosition : Position, IEqualityComparer<GeographicPosition>, IEquatable<GeographicPosition>
2222
{
@@ -140,10 +140,10 @@ public double Longitude
140140
private double?[] Coordinates { get; set; }
141141

142142
/// <summary>
143-
/// Returns a <see cref="System.String" /> that represents this instance.
143+
/// Returns a <see cref="string" /> that represents this instance.
144144
/// </summary>
145145
/// <returns>
146-
/// A <see cref="System.String" /> that represents this instance.
146+
/// A <see cref="string" /> that represents this instance.
147147
/// </returns>
148148
public override string ToString()
149149
{

0 commit comments

Comments
 (0)