Serializing/Deserializing 与 NetTopologySuite 的 GeoJson IO 库的往返揭示了一个潜在的错误
Serializing/Deserializing a roundtrip with NetTopologySuite's IO Library for GeoJson reveals a potential bug
我在使用 NetTopologySuite 的 GeoJsonReader 反序列化 Feature 对象时遇到问题。特别是,我收到以下异常(乍一看似乎很简单,所以请继续阅读):
An unhandled exception of type 'System.ArgumentException' occurred in Newtonsoft.Json.dll. Additional information: Expected token '{' not found.
仅进行一次简单的往返会导致此异常:
public static string DoIt( Feature feature )
{
GeoJsonWriter writer = new GeoJsonWriter();
var geoJson = writer.Write(feature);
GeoJsonReader reader = new GeoJsonReader();
var deserializedFeature = reader.Read<Feature>(geoJson );
}
在这种情况下,geoJson 非常简单:
"{\"type\":\"Feature\",\"geometry\":{\"type\":\"Polygon\",\"coordinates\":[[[-104.50348159865847,40.891762392617345],[-104.50348672999991,40.891415817000279],[-104.50355999200002,40.887782408000135],[-104.5036332529998,40.884149000000093],[-104.50845260799991,40.884357883000121],[-104.51307160051412,40.884558081989375],[-104.51307160051412,40.891762392617345],[-104.50348159865847,40.891762392617345]]]},\"properties\":null}"
请让我知道我做错了什么。顺便说一下,我使用的是 NetTopologySuite 1.14、NetTopologySuite.IO.GeoJSON 1.14 和 Json.Net 9.0.1.
这实际上是一个错误。
代码已修复,请参阅 #120
我在使用 NetTopologySuite 的 GeoJsonReader 反序列化 Feature 对象时遇到问题。特别是,我收到以下异常(乍一看似乎很简单,所以请继续阅读):
An unhandled exception of type 'System.ArgumentException' occurred in Newtonsoft.Json.dll. Additional information: Expected token '{' not found.
仅进行一次简单的往返会导致此异常:
public static string DoIt( Feature feature )
{
GeoJsonWriter writer = new GeoJsonWriter();
var geoJson = writer.Write(feature);
GeoJsonReader reader = new GeoJsonReader();
var deserializedFeature = reader.Read<Feature>(geoJson );
}
在这种情况下,geoJson 非常简单:
"{\"type\":\"Feature\",\"geometry\":{\"type\":\"Polygon\",\"coordinates\":[[[-104.50348159865847,40.891762392617345],[-104.50348672999991,40.891415817000279],[-104.50355999200002,40.887782408000135],[-104.5036332529998,40.884149000000093],[-104.50845260799991,40.884357883000121],[-104.51307160051412,40.884558081989375],[-104.51307160051412,40.891762392617345],[-104.50348159865847,40.891762392617345]]]},\"properties\":null}"
请让我知道我做错了什么。顺便说一下,我使用的是 NetTopologySuite 1.14、NetTopologySuite.IO.GeoJSON 1.14 和 Json.Net 9.0.1.
这实际上是一个错误。 代码已修复,请参阅 #120