D. Reagan
D. Reagan

Reputation: 1092

Serializing/Deserializing a roundtrip with NetTopologySuite's IO Library for GeoJson reveals a potential bug

I'm having trouble using NetTopologySuite's GeoJsonReader to deserialize Feature objects. In particular, I'm receiving the following exception (which at first glance seems straightforward, so please read on):

An unhandled exception of type 'System.ArgumentException' occurred in Newtonsoft.Json.dll. Additional information: Expected token '{' not found.

Just doing a simple round-trip results in this exception:

 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 );

}

in this case, geoJson is pretty straightforward:

"{\"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}"

Please let me know what I'm doing wrong. By the way, I'm using NetTopologySuite 1.14, NetTopologySuite.IO.GeoJSON 1.14, & Json.Net 9.0.1.

Upvotes: 1

Views: 2002

Answers (1)

D_Guidi
D_Guidi

Reputation: 698

this is actually a bug. code fixed, see #120

Upvotes: 2

Related Questions