Hi I am trying to parse the response from a OSM webservice into feature collection using GeoJson.Net
I am new to GeoJSON and not able to identify how to do so:
The Json response can be find here. The code I have written is:
System.IO.StreamReader file = new System.IO.StreamReader(filepath);
string content = file.ReadToEnd();
file.Close();
dynamic deserialized = JsonConvert.DeserializeObject(content);
List<Feature> lstGeoLocation = new List<Feature>();
foreach (JObject item in deserialized.features)
{
//var feature = new Feature();
var geom = item.Property("geometry").Value;
}
But this will be plain JSON parsing and there might be a better way to parse the same.
I also tried NetTopologySuite JSON extension but when i use following code it gives me exception
"Expected token 'type' not found."
System.IO.StreamReader file = new System.IO.StreamReader(filepath);
string content = file.ReadToEnd();
file.Close();
var reader = new NetTopologySuite.IO.GeoJsonReader();
var featureCollection = reader.Read <NetTopologySuite.Features.FeatureCollection>(content);