c# - is there something like dbgeometry makevalid in .net 4.5 -


i'm trying calculate area of polyline

    string poly = "polygon ((637604.918432772 2230520.64934531, 637622.257266129 2230419.44632915, 637279.107128549 2230192.04910755, 636765.470527745 2230179.6468564, 636778.005055813 2229861.77192838, 636529.81646905 2229464.29327025, 635813.486592791 2229523.30345774, 636017.385069448 2229974.32341381, 636267.323659164 2230070.32127916, 637035.026966561 2230404.70764784, 637275.265066307 2230401.13408429, 637604.918432772 2230520.64934531, 637604.918432772 2230520.64934531))";      dbgeometry gm = dbgeometry.fromtext(poly, 32637); double area= gm.area.value; // here got error exception has been thrown target of invocation. 

i noticed later reson of error dbgeometry invalid try code in ms sql 2012 give me error when tried

select @gm.makevalid().starea() 

thats worked in sql question there away make geometry valid in .net thank you

i'd agree bojan, unless using entity framework?

the sqlgeometry object has makevalid() function, using example, allowing convert between dbgeography , sqlgeography:

dbgeography geog; sqlgeometry geom = sqlgeometry.stgeomfromwkb(new sqlbytes(geog.asbinary()), 32637); 

however, unless using ef, i'd recommend using sqlgeometry as

  1. there no cast / conversion
  2. sqlgeometry has far more functions available dbgeometry.

hope helps.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -