How to return GeoJson from a SQL Server Query using GeoJson.Net in ASP.NET MVC

المشرف العام

Administrator
طاقم الإدارة
Hie i am a novice in mapping. I have a Spatial Table in SQL Server i want to map using either openlayers or leaflet. my problem is i cant figure out how to convert the returned results from my query to geojson.My Linq Query looks like this:

var world = _db.worlds.Select(w => new { w.ID, w.CODE , COUNTRYNAME = w.CNTRY_NAME, COUNTRYPOP = w.POP_CNTRY, w.FIPS, GEOMETRY = w.geom, w.WKT });Tried using GeoJson.Net but its not documented enough for me to understand, but what i know is the geometry that is returned when parsed to text it returnes Well Known Text with Multiple Geometry i.e polygons and multipolygons to be precice.

var geometries = new GeoJSON.Net.Geometry.GeometryCollection(world.WKT);//This is giving an error that world.WKT is not of type IGeometryCollectionAnyone who knows a work around my problem even using other packages that ain't the GeoJson.Net



أكثر...
 
أعلى