Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/GeoJSON.Text/Converters/CrsConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace GeoJSON.Text.Converters
/// <summary>
/// Converts <see cref="ICRSObject"/> types to and from JSON.
/// </summary>
public class CrsConverter : JsonConverter<object>
public class CrsConverter : JsonConverter<ICRSObject>
{
public override bool HandleNull => true;

Expand Down Expand Up @@ -41,7 +41,7 @@ public override bool CanConvert(Type objectType)
/// or
/// CRS must have a "type" property
/// </exception>
public override object Read(
public override ICRSObject Read(
ref Utf8JsonReader reader,
Type type,
JsonSerializerOptions options)
Expand Down Expand Up @@ -106,7 +106,8 @@ public override object Read(
}
}

return new NotSupportedException(string.Format("Type {0} unexpected.", crsType));
//return new NotSupportedException(string.Format("Type {0} unexpected.", crsType));
return null;
}

/// <summary>
Expand All @@ -118,7 +119,7 @@ public override object Read(
/// <exception cref="System.ArgumentOutOfRangeException"></exception>
public override void Write(
Utf8JsonWriter writer,
object crsValue,
ICRSObject crsValue,
JsonSerializerOptions options)
{
var value = (ICRSObject)crsValue;
Expand Down
1 change: 0 additions & 1 deletion src/GeoJSON.Text/Feature/Feature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ public Feature(IGeometryObject geometry, TProps properties, string id = null)

[JsonPropertyName("type")]
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
[JsonConverter(typeof(JsonStringEnumConverter))]
public override GeoJSONObjectType Type => GeoJSONObjectType.Feature;

[JsonPropertyName( "id")]
Expand Down
2 changes: 0 additions & 2 deletions src/GeoJSON.Text/Feature/FeatureCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ public FeatureCollection(List<Feature> features)

[JsonPropertyName("type")]
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
[JsonConverter(typeof(JsonStringEnumConverter))]
public override GeoJSONObjectType Type => GeoJSONObjectType.FeatureCollection;

/// <summary>
Expand Down Expand Up @@ -156,7 +155,6 @@ public FeatureCollection(List<Feature<IGeometryObject, TProps>> features)

[JsonPropertyName("type")]
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
[JsonConverter(typeof(JsonStringEnumConverter))]
public override GeoJSONObjectType Type => GeoJSONObjectType.FeatureCollection;

/// <summary>
Expand Down
1 change: 0 additions & 1 deletion src/GeoJSON.Text/GeoJSONObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ public abstract class GeoJSONObject : IGeoJSONObject, IEqualityComparer<GeoJSONO
/// </summary>
[JsonPropertyName("type")]
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
[JsonConverter(typeof(JsonStringEnumConverter))]
public abstract GeoJSONObjectType Type { get; }


Expand Down
6 changes: 6 additions & 0 deletions src/GeoJSON.Text/GeoJSONObjectType.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
// Copyright © Joerg Battermann 2014, Matt Hunt 2017

using System.Runtime.Serialization;
using System.Text.Json.Serialization;

namespace GeoJSON.Text
{
/// <summary>
/// Defines the GeoJSON Objects types.
/// </summary>
#if NET8_0_OR_GREATER
[JsonConverter(typeof(JsonStringEnumConverter<GeoJSONObjectType>))]
#else
[JsonConverter(typeof(JsonStringEnumConverter))]
#endif
public enum GeoJSONObjectType
{
/// <summary>
Expand Down
1 change: 0 additions & 1 deletion src/GeoJSON.Text/Geometry/GeometryCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ public GeometryCollection(IEnumerable<IGeometryObject> geometries)

[JsonPropertyName("type")]
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
[JsonConverter(typeof(JsonStringEnumConverter))]
public override GeoJSONObjectType Type => GeoJSONObjectType.GeometryCollection;

/// <summary>
Expand Down
1 change: 0 additions & 1 deletion src/GeoJSON.Text/Geometry/IGeometryObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ public interface IGeometryObject
/// The type of the object.
/// </value>
[JsonPropertyName("type")]
[JsonConverter(typeof(JsonStringEnumConverter))]
GeoJSONObjectType Type { get; }
}
}
1 change: 0 additions & 1 deletion src/GeoJSON.Text/Geometry/LineString.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ public LineString(IEnumerable<IPosition> coordinates)

[JsonPropertyName("type")]
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
[JsonConverter(typeof(JsonStringEnumConverter))]
public override GeoJSONObjectType Type => GeoJSONObjectType.LineString;

/// <summary>
Expand Down
1 change: 0 additions & 1 deletion src/GeoJSON.Text/Geometry/MultiLineString.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ public MultiLineString(IEnumerable<IEnumerable<IEnumerable<double>>> coordinates

[JsonPropertyName("type")]
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
[JsonConverter(typeof(JsonStringEnumConverter))]
public override GeoJSONObjectType Type => GeoJSONObjectType.MultiLineString;

/// <summary>
Expand Down
1 change: 0 additions & 1 deletion src/GeoJSON.Text/Geometry/MultiPoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ public MultiPoint(IEnumerable<IEnumerable<double>> coordinates)

[JsonPropertyName("type")]
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
[JsonConverter(typeof(JsonStringEnumConverter))]
public override GeoJSONObjectType Type => GeoJSONObjectType.MultiPoint;

/// <summary>
Expand Down
1 change: 0 additions & 1 deletion src/GeoJSON.Text/Geometry/MultiPolygon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ public MultiPolygon(IEnumerable<IEnumerable<IEnumerable<IEnumerable<double>>>> c

[JsonPropertyName("type")]
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
[JsonConverter(typeof(JsonStringEnumConverter))]
public override GeoJSONObjectType Type => GeoJSONObjectType.MultiPolygon;

/// <summary>
Expand Down
1 change: 0 additions & 1 deletion src/GeoJSON.Text/Geometry/Point.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public Point(IPosition coordinates)

[JsonPropertyName("type")]
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
[JsonConverter(typeof(JsonStringEnumConverter))]
public override GeoJSONObjectType Type => GeoJSONObjectType.Point;

/// <summary>
Expand Down
1 change: 0 additions & 1 deletion src/GeoJSON.Text/Geometry/Polygon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ public Polygon(IEnumerable<IEnumerable<IEnumerable<double>>> coordinates)

[JsonPropertyName("type")]
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
[JsonConverter(typeof(JsonStringEnumConverter))]
public override GeoJSONObjectType Type => GeoJSONObjectType.Polygon;

/// <summary>
Expand Down
Loading