Skip to content

Commit

Permalink
Deserialize MultiPolygon Array of Empty Coordinates Array
Browse files Browse the repository at this point in the history
  • Loading branch information
dickinsonm committed Mar 25, 2024
1 parent 0721747 commit e501cc8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,15 @@ public static StjParsedCoordinates Parse(ref Utf8JsonReader reader, GeometryFact
reader.AssertToken(JsonTokenType.StartArray);
reader.ReadOrThrow();

if (reader.TokenType == JsonTokenType.EndArray)
{
reader.ReadOrThrow();
if (reader.TokenType == JsonTokenType.EndArray)
{
return default;
}
}

if (reader.TokenType == JsonTokenType.Number)
{
return new StjParsedCoordinates(ParseCoordinateSequence(ref reader, factory));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,18 @@ public void TestReadWithEmptyCoordinatesArray(string type)
Assert.That(geom.IsEmpty);
}


[TestCase("MultiPolygon")]
public void TestReadWithArrayOfEmptyCoordinatesArray(string type)
{
string geoJson = @$"{{ ""type"" : ""{type}"", ""coordinates"": [ [] ] }}";
var options = DefaultOptions;
var geom = Deserialize(geoJson, options);

Assert.That(geom != null);
Assert.That(geom.IsEmpty);
}

[GeoJsonIssueNumber(57)]
[TestCase("{\"type\": \"Point\", \"coordinates\": [], \"bbox\": null}")]
[TestCase("{\"type\": \"LineString\", \"coordinates\": [], \"bbox\": null}")]
Expand Down

0 comments on commit e501cc8

Please sign in to comment.