0
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 字符串?

4

1 回答 1

0

您可能需要使用NetTopologySuite.IO.GeoJSON:将您从数据库获得的 NetTopologySuite 对象传递给 GeoJsonSerializer。

这里有一些看起来不错的例子

于 2020-03-21T19:00:24.340 回答