Trying to return some pretty simple GeoJSON data. I found NetTopologySuite, and set up a simple FeaturesCollection and tried to serialize it out to a GeoJson string only to get the following error:
"Self referencing loop detected for property 'CoordinateValue' with type 'GeoAPI.Geometries.Coordinate'. Path 'Features[0].Geometry.Coordinates[0]'."
Looking through the class headers, Point uses Coordinate, which does have a Coordinate property so I can see why there would be a circular reference. The thing is, most (if not all) the Geometries seem to use Point, so that would make it impossible to ever serialize anything... unless I'm missing something.
So is this a bug or am I missing something?
Tested with just a Point and got the same error, so here's the code for that:
using NTS = NetTopologySuite;
var ret = new NTS.Geometries.Point(42.9074, -78.7911);
var jsonSerializer = NTS.IO.GeoJsonSerializer.Create();
var sw = new System.IO.StringWriter();
jsonSerializer.Serialize(sw, ret);
var json = sw.ToString();
Create()
method? I don't see it here. – CircumstantialGeoJsonSerializer
, you need to make sure aCoordinateConverter
is passed to it, as is shown here. – Circumstantial