I want to convert geom
(geometry
) datatype to GeoJSON. How could I do that?
For example, the geometry in WKT:
POLYGON((4552
I think, you can produce geojson at server side when you get data from Sql Server.
You should examine GeoJSON.Net and similar question
var modelF = new List();
foreach (DataRow dr in ds.Tables[0].Rows)
{
var point = new GeoJSON.Net.Geometry.Point(new GeoJSON.Net.Geometry.GeographicPosition(Convert.ToDouble(dr["latitude"].ToString()), Convert.ToDouble(dr["longitude"].ToString())));
var featureProperties = new Dictionary { };
foreach (DataColumn dataColumn in ds.Tables[0].Columns)
{
featureProperties.Add(dataColumn.ColumnName, dr[dataColumn].ToString());
}
modelF.Add(new GeoJSON.Net.Feature.Feature(point, featureProperties));
}
var fcol = new FeatureCollection(modelF);
var serializedData = JsonConvert.SerializeObject(fcol, Formatting.Indented, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver(), NullValueHandling = NullValueHandling.Ignore });
return serializedData;
have a goo day.