首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使用Npgsql和OrmLite (使用postgresql、postgis、c#)定义'geography‘类型

如何使用Npgsql和OrmLite (使用postgresql、postgis、c#)定义'geography‘类型
EN

Stack Overflow用户
提问于 2013-06-27 21:04:00
回答 1查看 1K关注 0票数 7

如何在我的C#类模型中定义postgis 'geography‘类型,以便OrmLite可以轻松地将其传递给Postgresql,这样除了可以将空间数据保存到'geography’列之外,我还可以运行空间查询?

EN

回答 1

Stack Overflow用户

发布于 2016-03-25 22:12:33

对于这种情况,最好的库是NetTopologySuite

你可以像这样使用;

代码语言:javascript
复制
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);
           }
        }
   }
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/17343946

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档