加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

如何使用Npgsql和OrmLite定义’geography’类型(使用postgresql,

发布时间:2020-12-13 16:13:56 所属栏目:百科 来源:网络整理
导读:如何在我的C#类模型中定义postgis’geography’类型,以便OrmLite可以轻松地将其传递给 Postgresql,这样我除了将空间数据保存到’geography’列之外还可以运行空间查询? 对于这种情况,最好的图书馆是 NetTopologySuite; 你可以像这样使用; protected GisShar
如何在我的C#类模型中定义postgis’geography’类型,以便OrmLite可以轻松地将其传递给 Postgresql,这样我除了将空间数据保存到’geography’列之外还可以运行空间查询?
对于这种情况,最好的图书馆是 NetTopologySuite;

你可以像这样使用;

protected GisSharpBlog.NetTopologySuite.Geometries.Geometry _geom;
public GisSharpBlog.NetTopologySuite.Geometries.Geometry Geom
   {
      get { return _geom; }
      set { _geom = value; }
   }

protected string _geomwkt;
public virtual string GeomWKT
   {
     get
       {
         if (this.Geom != null)
             return this.Geom.ToText();
         else
             return "";
       }
     set
       {
         string wktString = value;
         if (string.IsNullOrEmpty(wktString))
             _geom = null;
         else
           {
             var fact = new GeometryFactory();
              var wktreader = new WKTReader(fact);
              _geom = (Geometry)wktreader.Read(wktString);
           }
        }
   }

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读