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/