[GIS] Why isn’t valid geometry not valid in NetTopologySuite when close to poles

ccoordinate systemnettopologysuiteopenlayers-2

I have a Polygon which crosses the south pole:

Polygon in WKT:

POLYGON((5.86826073458095 75.6638564054071,-16.5436836399021 63.2220742891438,-19.3664667294083 59.846221066959,-21.7009816876343 56.4249469806136,-23.6790769742369 52.9700261291777,-25.3903613659649 49.4893115487179,-26.8975641104604 45.9882370271908,-28.2457890135821 42.4706937235238,-29.4682588331783 38.9395620194517,-30.5899861803996 35.3970453090933,-31.630184235186 31.8448854932665,-32.6038903163747 28.2845058942699,-33.5230853693438 24.7171076354231,-34.3974830618665 21.1437357309945,-35.235097920163 17.5653249360032,-36.0426631616959 13.9827314320988,-36.8259448200183 10.3967548983886,-37.5899837597522 6.80815365993192,-38.3392875692471 3.21765455357868,-39.0779879379052 -0.374040045499291,-39.8099755194243 -3.96624846033375,-40.5390214169723 -7.55830680566397,-41.2688934869779 -11.1495673752539,-42.0034749866572 -14.7393968944145,-42.746893755425 -18.3271748440658,-43.5036712696367 -21.9122899273912,-44.278903931454 -25.4941353358308,-45.0784929992426 -29.0721003174899,-45.909447175354 -32.645558114512,-46.780293059812 -36.213846909671,-47.701647966567 -39.7762416028947,-48.6870411529217 -43.3319115133841,-49.7541238657166 -46.8798560026433,-50.9265051564415 -50.4188052017007,-52.2366277028469 -53.9470627335416,-53.7304380696443 -57.4622479660316,-55.4752902472004 -60.960856256507,-57.5739735146974 -64.4374691598322,-60.1910293117637 -67.8832485002322,-63.6053872681201 -71.2828461995608,-68.3234045243048 -74.6074769312702,-75.3289981196023 -77.7943686089884,-86.6900534465662 -80.7085557183446,-106.466508019701 -83.0072017934104,-137.471660384609 -83.9399343949619,-168.142998855139 -82.93831462336,172.499462776297 -80.6056412046207,51.3335176218797 -89.5237677724837,-38.5840495672926 -86.5116366536384,-42.0040683719443 -83.0274485267546,-42.8274013155417 -79.5453266210156,-43.0035444063044 -76.0523116952844,-42.917334253526 -72.5396798562258,-42.697949818896 -69.0250062191839,-42.4008670872053 -65.5077449057289,-42.0533899183215 -61.9874560043951,-41.670338636158 -58.4637908672109,-41.2602920462013 -54.9364821865153,-40.8284114298265 -51.4053395233125,-40.3778451376451 -47.870247975915,-39.910479310127 -44.3311678973098,-39.4273617133736 -40.7881352756541,-38.9289507663875 -37.2412619762738,-38.4152654790081 -33.6907357058719,-37.8859761502671 -30.1368196717061,-37.3404576571625 -26.5798516624587,-36.7778177194076 -23.0202428850507,-36.1969072178556 -19.4584768387702,-35.5963164344505 -15.8951075671059,-34.9743593186678 -12.3307588680448,-34.3290462758966 -8.76612330851596,-33.6580452149769 -5.20196287319082,-32.9586293654512 -1.63911024976531,-32.2276096954905 1.92152745183098,-31.4612484461671 5.47896267724487,-30.6551491136678 9.03211742916007,-29.8041161495169 12.5798092697371,-28.9019756079644 16.120730246266,-27.9413441489322 19.6534181565979,-26.9133294556999 23.1762163144254,-25.8071382075058 26.6872181913455,-24.6095580924228 30.1841914502993,-23.3042664371652 33.6644728848271,-21.8708974452426 37.1248226005016,-20.2837701533619 40.5612194847865,-18.5101356399938 43.9685706157486,-16.50773911296 47.3402932700171,-14.2214065316975 50.6677038885502,-11.5782579077352 53.9391116046634,-8.48105249750914 57.1384547629944,-4.79920779006745 60.2432297260212,-0.357592488403802 63.2213436295558,5.07464609178979 66.0264264522405,5.86826073458095 75.6638564054071))

Problem:

When I view it on google earth, it looks and acts fine. But when I try to do an intersecttion with NetTopologySuite (a C# library) it gives me an error basically saying it's an invalid polygon.

geom = (Geometry)swathGeom.Intersection((IGeometry)_WESTERN_HEMISPHERE);

Error:

"found non-noded intersection between LINESTRING(-86.6900534465662
-80.7085557183446, -106.466508019701 -83.0072017934104) and LINESTRING(-168.142998855139 -82.93831462336, 0 -81.7868941512966) [
(-101.975528861504, -82.4852087548192, NaN) ]"

Question:

How can I get NetTopologySuite to see this as a valid polygon so I can perform an intersection? Do I need to do something with projection?

Polygon in Google Earth:

enter image description here
enter image description here

Polygon in OpenLayers:

enter image description here

Best Answer

I've checked a little bit and I can confirm that your polygon isn't valid "as is".
This unit test is ok.

WKTReader reader = new KTReader(GeometryFactory.Default);  
IGeometry g = reader.Read(geomwkt);  
Assert.IsNotNull(g);  
Assert.IsFalse(g.IsValid);  
g = g.Buffer(0);  
Assert.IsTrue(g.IsValid);
Related Question