Closed RobDaPraia closed 7 years ago
Just been looking at this, I see your point. I realise this is old now, but do you want to create a PR for this? If you don't I might try and get this in sometime soon
Hi, no need, I created a solution myself
Addressing anyway in #70
If you use the GeoJson library in Azure API app and you use the following code in WebApiConfig to reduce the amount of Json returned by web API:
config.Formatters.JsonFormatter.SerializerSettings.DefaultValueHandling = DefaultValueHandling.Ignore;
Then the Type is not returned for a Point, when the type is "Point" (is default value for GeoJSONObjectType) resulting in an invalid GeoJson format.
You can solve this by using " DefaultValueHandling = DefaultValueHandling.Include)" in GeoJSONObject.cs
[JsonProperty(PropertyName = "type", Required = Required.Always, DefaultValueHandling = DefaultValueHandling.Include)] [JsonConverter(typeof(StringEnumConverter))] public GeoJSONObjectType Type { get; internal set; }
You can test this by adapting the unit tests and addding the " new JsonSerializerSettings { DefaultValueHandling = DefaultValueHandling.Ignore }", example:
public void Can_Serialize_With_Lat_Lon_Alt() { var point = new Point(new GeographicPosition(53.2455662, 90.65464646, 200.4567));