是否要从实体获取Geojson字符串?

问题描述 投票:0回答:1
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字符串?

entity-framework-core geospatial npgsql nettopologysuite
1个回答
0
投票

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

Here are some decent-looking examples

© www.soinside.com 2019 - 2024. All rights reserved.