public class City
{
public int Id { get; set; }
public string Name { get; set; }
public Geometry Location { get; set; }
}
我的实体框架实体City
类型具有Geometry
属性。我正在获取如下数据:
public class CitiesController {
public Task<IActionResult> Get(){
var nearbyCities = context.Cities
.Where(c => c.Location.Distance(somePoint) < 100);
response OK(??? geojson string ???);
}
}
所以我想如何使用Npgsql或Nettopologysuite获取Geojson字符串?
您可能需要使用NetTopologySuite.IO.GeoJSON:将从数据库中获取的NetTopologySuite对象传递给GeoJsonSerializer。