gpt4 book ai didi

entity-framework - DbGeography 多边形获得点数

转载 作者:行者123 更新时间:2023-12-04 08:34:37 25 4
gpt4 key购买 nike

我有一个多边形作为 Sys.Geography 类型保存在 SQL Server 2012 数据库上。如何获得多边形的所有点?

我正在考虑使用 AsText() 方法并解析字符串,但也许有更好的选择?

最佳答案

找到了一个方法,这里是一个扩展方法:

public static IEnumerable<MyEntityWithLatAndLng> GetPointsFromPolygon(this System.Data.Entity.Spatial.DbGeography geo)
{
for (int i = 1; i < geo.PointCount; i++)
{
var p = geo.PointAt(i);
yield return new MyEntityWithLatAndLng(){ Latitude = p.Latitude.Value, Longitude = p.Longitude.Value };
}
}

关于entity-framework - DbGeography 多边形获得点数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25374130/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com