private static string ToJson(FeatureCollection featureCollection) |
{ |
var jsonSerializer = new NetTopologySuite.IO.GeoJsonSerializer(); |
var jsonStream = new StringWriter(); |
jsonSerializer.Serialize(jsonStream, featureCollection); |
var json = jsonStream.ToInvariantString(); |
return json; |
Can anyone provide me with some assistance I need to convert some polygons and multi-polygons stored in a database to GeoJSON so that I can display them on a Google Map?I have created the code below which currently returns an empty JSON string:public ContentResult Boundaries()
{
ViewIt_V2Entities viewItV2 = new ViewIt_V2Entities();
var geometryQuery = (from shapes in viewItV2.UTLA_Shapes
select shapes.Geometry).ToList();
GeometryConverter geometryConverter = new GeometryConverter();
StringBuilder sb = new StringBuilder();
StringWriter sw = new StringWriter(sb);
JsonWriter jsonWriter = new JsonTextWriter(sw);
JsonSerializer jsonSerializer = new GeoJsonSerializer();
foreach (var geometry in geometryQuery)
{
geometryConverter.WriteJson(jsonWriter, geometry, jsonSerializer);
}
return Content(sb.ToString(), "application/json");
}How to do I go about converting the polygons and multi-polygons to GeoJSON using the NetTopologySuite?Thanks,
Simon
--
You received this message because you are subscribed to the Google Groups "NetTopologySuite" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nettopologysuite+unsubscribe@googlegroups.com.
To post to this group, send email to nettopologysuite@googlegroups.com.
Visit this group at https://groups.google.com/group/nettopologysuite.
For more options, visit https://groups.google.com/d/optout.