0
public class City
{
    public int Id { get; set; }
    public string Name { get; set; }
    public Geometry Location { get; set; }
}

My entity framework entity City type has a Geometry property. I am getting data like following:

public class CitiesController {

   public Task<IActionResult> Get(){
       var nearbyCities = context.Cities
                  .Where(c => c.Location.Distance(somePoint) < 100);

       response OK(??? geojson string ???);
   }
}

So I want how can I get Geojson string using Npgsql or Nettopologysuite?

barteloma
  • 6,403
  • 14
  • 79
  • 173

1 Answers1

0

You likely need to use the NetTopologySuite.IO.GeoJSON: pass the NetTopologySuite objects you get from the database to GeoJsonSerializer.

Here are some decent-looking examples.

Shay Rojansky
  • 15,357
  • 2
  • 40
  • 69