7

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

4

1 回答 1

0

对于这种情况,最好的库是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);
           }
        }
   }
于 2016-03-25T14:12:32.620 回答