Select to view content in your preferred language

Convert Geometry to WKT/WKB in silverlight

12210
10
05-03-2011 11:29 AM
NaveenMaram
Emerging Contributor
Hi All,

I am trying to save the Geometry point collection as WKT string in the database. could some one help me in this. or even help links will be usefull.


Thanks,
Naveen Maram.
0 Kudos
10 Replies
JustinCornell
Occasional Contributor

There is not a ToPolygon() method.  You need to make an extension method if you want and it would be something simple.  Using the two points to construct a polygon.  Below is not tested or probably not even the correct syntax, but it should give you the jest of what needs to happen.  Just remember to always close your polygon (last and first point are the same). Also remember to construct your polygon in a counterclockwise method to make the area within the points inclusive. Otherwise clockwise means that is exclusive area, basically a hole.

Hope this helps.

var e = extent;

var poly = new List<Point>();

poly.Add(new Point(e.MinX, e.MinY, e.SpatialReference));

poly.Add(new Point(e.MaxX, e.MinY, e.SpatialReference));

poly.Add(new Point(e.MaxX, e.MaxY, e.SpatialReference));

poly.Add(new Point(E.MinX, e.MaxY, e.SpatialReference));

poly.Add(new Point(e.MinX, e.MinY, e.SpatialReference));//close the polygon

0 Kudos