gpt4 book ai didi

c# - 在 SqlGeometry 和 DbGeometry 之间转换

转载 作者:太空狗 更新时间:2023-10-29 20:05:18 25 4
gpt4 key购买 nike

SqlGeometry 和 DbGeometry 之间有没有简单的转换方法?我正在使用一个流行的 sql 空间帮助程序库,其中的所有函数都需要 SqlGeometry。但是,当我针对 ESRI ArcSDE 要素类使用 Entity Framework 时,Shape 字段作为 DbGeometry 返回。我无法使用该 DbGeometry 类型调用任何我想要的方法(例如 LocateAlongGeom)。也许有一种方法可以将其序列化为二进制或文本,然后将其作为 SqlGeometry 读回?

最佳答案

//Convert from SqlGeometry to DbGeometry 
SqlGeometry sqlGeo = ...
DbGeometry dbGeo = DbGeometry.FromBinary(sqlGeo.STAsBinary().Buffer);

//Convert from DBGeometry to SqlGeometry
SqlGeometry sqlGeo2 = SqlGeometry.STGeomFromWKB(new SqlBytes(dbGeo.AsBinary()), 0);

关于c# - 在 SqlGeometry 和 DbGeometry 之间转换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15485945/

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