How to define 'geography' type using Npgsql and OrmLite (using postgresql, postgis, c#)
Asked Answered
C

1

7

How do I define a postgis 'geography' type in my C# class model so that OrmLite can easily pass it through to Postgresql so I can run spatial queries in addition to saving spatial data to the 'geography' column?

Cheerleader answered 27/6, 2013 at 13:3 Comment(0)
M
0

The best library is NetTopologySuite for this case;

you can use like this;

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);
           }
        }
   }
Middlebreaker answered 25/3, 2016 at 14:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.