I am trying to use the pie shape example, and at the following line of the example:
MultipolygonShape intersectionMultiPolygonShape = circleShape.GetIntersection(polygonShape);
I get the following error:
- base {GisSharpBlog.NetTopologySuite.Geometries.TopologyException: side location conflict [ (-130970.066202713, 374.467085059732, NaN) ]
at GisSharpBlog.NetTopologySuite.GeometriesGraph.EdgeEndStar.PropagateSideLabels(Int32 geomIndex)
at GisSharpBlog.NetTopologySuite.GeometriesGraph.EdgeEndStar.ComputeLabelling(GeometryGraph[] geom)
at GisSharpBlog.NetTopologySuite.GeometriesGraph.DirectedEdgeStar.ComputeLabelling(GeometryGraph[] geom)
at GisSharpBlog.NetTopologySuite.Operation.Overlay.OverlayOp.ComputeLabelling()
at GisSharpBlog.NetTopologySuite.Operation.Overlay.OverlayOp.ComputeOverlay(SpatialFunction opCode)
at GisSharpBlog.NetTopologySuite.Operation.Overlay.OverlayOp.GetResultGeometry(SpatialFunction funcCode)
at GisSharpBlog.NetTopologySuite.Operation.Overlay.OverlayOp.Overlay(IGeometry geom0, IGeometry geom1, SpatialFunction opCode)
at GisSharpBlog.NetTopologySuite.Operation.Overlay.Snap.SnapOverlayOp.GetResultGeometry(SpatialFunction opCode)
at GisSharpBlog.NetTopologySuite.Operation.Overlay.Snap.SnapOverlayOp.Overlay(IGeometry g0, IGeometry g1, SpatialFunction opCode)
at GisSharpBlog.NetTopologySuite.Operation.Overlay.Snap.SnapIfNeededOverlayOp.GetResultGeometry(SpatialFunction opCode)
at GisSharpBlog.NetTopologySuite.Operation.Overlay.Snap.SnapIfNeededOverlayOp.Overlay(IGeometry g0, IGeometry g1, SpatialFunction opCode)
at GisSharpBlog.NetTopologySuite.Geometries.Geometry.Intersection(IGeometry other)
at ThinkGeo.MapSuite.Core.AreaBaseShape.GetIntersectionCore(AreaBaseShape targetShape)
at ThinkGeo.MapSuite.Core.AreaBaseShape.GetIntersection(AreaBaseShape targetShape)} System.ApplicationException {GisSharpBlog.NetTopologySuite.Geometries.TopologyException}.
CIRCLESHAPE is : "POLYGON((-9568154.06620271 5107062.46708506,-9568154.08895115 5107065.24758748,-9568154.15719038 5107068.0273455,-9568154.27090213 5107070.80561489,-9568154.43005596 5107073.58165186,-9568154.63460925
5107076.3547132,-9568154.88450725 5107079.12405648,-9568155.17968304 5107081.88894028,-9568155.52005761 5107084.64862439,-9568155.90553983 5107087.40236996,-9568156.33602649 5107090.14943975,-9568156.81140235 5107092.88909831,-9568157.33154012 5107095.62061215,-9568157.89630057 5107098.34325,-9568158.50553249 5107101.05628293,-9568159.15907277 5107103.7589846,-9568159.85674645 5107106.45063143,-9568160.59836673 5107109.1305028,-9568161.38373508 5107111.79788124,-9568162.21264123 5107114.45205264,-9568163.08486326 5107117.0923064,-9568164.00016765 5107119.71793568,-9568164.95830936 5107122.32823751,-9568165.95903187 5107124.92251307,-9568167.00206727 5107127.5000678,-9568168.0871363 5107130.06021162,-9568169.21394846 5107132.60225913,-9568170.38220209 5107135.12552976,-9568171.59158441 5107137.62934797,-9568172.84177164 5107140.11304342,-9568174.13242907 5107142.57595117,-9568175.46321117 5107145.01741185,-9568176.83376166 5107147.4367718,-9568178.24371359 5107149.83338331,-9568179.69268951 5107152.20660475,-9568181.18030147 5107154.55580075,-9568182.70615121 5107156.88034238,-9568184.26983023 5107159.1796073,-9568185.87091988 5107161.45297993,-9568187.50899152 5107163.69985165,-9568189.18360659 5107165.9196209,-9568190.89431677 5107168.11169341,-9568192.64066405 5107170.27548231,-9568194.4221809 5107172.41040829,-9568196.23839035 5107174.51589978,-9568198.08880617 5107176.5913931,-9568199.97293295 5107178.63633258,-9568201.89026627 5107180.65017074,-9568203.84029282 5107182.63236844,-9568205.82249051 5107184.58239498,-9568207.83632867 5107186.4997283,-9568209.88126815 5107188.38385508,-9568211.95676147 5107190.2342709,-9568214.06225296 5107192.05048035,-9568216.19717894 5107193.83199719,-9568218.36096784 5107195.57834448,-9568220.55304035 5107197.28905465,-9568222.7728096 5107198.96366973,-9568225.01968132 5107200.60174137,-9568227.29305395 5107202.20283102,-9568229.59231887 5107203.76651004,-9568231.91686049 5107205.29235978,-9568234.2660565 5107206.77997174,-9568236.63927794 5107208.22894766,-9568239.03588945 5107209.63889959,-9568241.4552494 5107211.00945008,-9568243.89671008 5107212.34023218,-9568246.35961783 5107213.63088961,-9568248.84331328 5107214.88107684,-9568251.34713149 5107216.09045916,-9568253.87040212 5107217.25871279,-9568256.41244963 5107218.38552495,-9568258.97259345 5107219.47059398,-9568261.55014818 5107220.51362937,-9568264.14442374 5107221.51435188,-9568266.75472557 5107222.4724936,-9568269.38035485 5107223.38779799,-9568272.02060861 5107224.26002002,-9568274.67478001 5107225.08892617,-9568277.34215845 5107225.87429452,-9568280.02202982 5107226.6159148,-9568282.71367665 5107227.31358848,-9568285.41637832 5107227.96712876,-9568288.12941125 5107228.57636068,-9568290.8520491 5107229.14112113,-9568293.58356294 5107229.6612589,-9568296.3232215 5107230.13663476,-9568299.07029129 5107230.56712142,-9568301.82403686 5107230.95260364,-9568304.58372097 5107231.29297821,-9568307.34860477 5107231.588154,-9568310.11794805 5107231.838052,-9568312.89100938 5107232.04260529,-9568315.66704636 5107232.20175912,-9568318.44531575 5107232.31547087,-9568321.22507377 5107232.3837101,-9568324.00557619 5107232.40645854,-9568326.78607861 5107232.3837101,-9568329.56583663 5107232.31547087,-9568332.34410602 5107232.20175912,-9568335.12014299 5107232.04260529,-9568337.89320433 5107231.838052,-9568340.66254761 5107231.588154,-9568343.42743141 5107231.29297821,-9568346.18711552 5107230.95260364,-9568348.94086109 5107230.56712142,-9568351.68793088 5107230.13663476,-9568354.42758944 5107229.6612589,-9568357.15910328 5107229.14112113,-9568359.88174113 5107228.57636068,-9568362.59477406 5107227.96712876,-9568365.29747573 5107227.31358848,-9568367.98912256 5107226.6159148,-9568370.66899393 5107225.87429452,-9568373.33637237 5107225.08892617,-9568375.99054377 5107224.26002002,-9568378.63079753 5107223.38779799,-9568381.25642681 5107222.4724936,-9568383.86672864 5107221.51435188,-9568386.4610042 5107220.51362937,-9568389.03855892 5107219.47059398,-9568391.59870275 5107218.38552495,-9568394.14075026 5107217.25871279,-9568396.66402089 5107216.09045916,-9568399.1678391 5107214.88107684,-9568401.65153455 5107213.63088961,-9568404.1144423 5107212.34023218,-9568406.55590297 5107211.00945008,-9568408.97526293 5107209.63889959,-9568411.37187444 5107208.22894766,-9568413.74509588 5107206.77997174,-9568416.09429188 5107205.29235978,-9568418.41883351 5107203.76651004,-9568420.71809843 5107202.20283102,-9568422.99147106 5107200.60174137,-9568425.23834278 5107198.96366973,-9568427.45811203 5107197.28905465,-9568429.65018454 5107195.57834448,-9568431.81397344 5107193.83199719,-9568433.94889942 5107192.05048035,-9568436.05439091 5107190.2342709,-9568438.12988423 5107188.38385508,-9568440.17482371 5107186.4997283,-9568442.18866187 5107184.58239498,-9568444.17085956 5107182.63236844,-9568446.12088611 5107180.65017074,-9568448.03821943 5107178.63633258,-9568449.92234621 5107176.5913931,-9568451.77276203 5107174.51589978,-9568453.58897148 5107172.41040829,-9568455.37048833 5107170.27548231,-9568457.11683561 5107168.11169341,-9568458.82754578 5107165.9196209,-9568460.50216086 5107163.69985165,-9568462.1402325 5107161.45297993,-9568463.74132215 5107159.1796073,-9568465.30500117 5107156.88034238,-9568466.83085091 5107154.55580075,-9568468.31846287 5107152.20660475,-9568469.76743879 5107149.83338331,-9568471.17739072 5107147.4367718,-9568472.54794121 5107145.01741185,-9568473.87872331 5107142.57595117,-9568475.16938074 5107140.11304342,-9568476.41956797 5107137.62934797,-9568477.62895029 5107135.12552976,-9568478.79720392 5107132.60225913,-9568479.92401608 5107130.06021162,-9568481.00908511 5107127.5000678,-9568482.0521205 5107124.92251307,-9568483.05284302 5107122.32823751,-9568484.01098473 5107119.71793568,-9568484.92628912 5107117.0923064,-9568485.79851115 5107114.45205264,-9568486.6274173 5107111.79788124,-9568487.41278565 5107109.1305028,-9568488.15440593 5107106.45063143,-9568488.85207961 5107103.7589846,-9568489.50561989 5107101.05628293,-9568490.11485181 5107098.34325,-9568490.67961226 5107095.62061215,-9568491.19975003 5107092.88909831,-9568491.67512589 5107090.14943975,-9568492.10561255 5107087.40236996,-9568492.49109477 5107084.64862439,-9568492.83146934 5107081.88894028,-9568493.12664513 5107079.12405648,-9568493.37654313 5107076.3547132,-9568493.58109642 5107073.58165186,-9568493.74025025 5107070.80561489,-9568493.853962 5107068.0273455,-9568493.92220123 5107065.24758748,-9568493.94494967 5107062.46708506,-9568493.92220123 5107059.68658264,-9568493.853962 5107056.90682462,-9568493.74025025 5107054.12855523,-9568493.58109642 5107051.35251825,-9568493.37654313 5107048.57945692,-9568493.12664513 5107045.81011364,-9568492.83146934 5107043.04522984,-9568492.49109477 5107040.28554573,-9568492.10561255 5107037.53180016,-9568491.67512589 5107034.78473037,-9568491.19975003 5107032.04507181,-9568490.67961226 5107029.31355796,-9568490.11485181 5107026.59092012,-9568489.50561989 5107023.87788719,-9568488.85207961 5107021.17518552,-9568488.15440593 5107018.48353869,-9568487.41278565 5107015.80366732,-9568486.6274173 5107013.13628888,-9568485.79851115 5107010.48211748,-9568484.92628912 5107007.84186372,-9568484.01098473 5107005.21623444,-9568483.05284302 5107002.60593261,-9568482.0521205 5107000.01165705,-9568481.00908511 5106997.43410232,-9568479.92401608 5106994.8739585,-9568478.79720392 5106992.33191099,-9568477.62895029 5106989.80864036,-9568476.41956797 5106987.30482215,-9568475.16938074 5106984.8211267,-9568473.87872331 5106982.35821894,-9568472.54794121 5106979.91675827,-9568471.17739072 5106977.49739832,-9568469.76743879 5106975.10078681,-9568468.31846287 5106972.72756537,-9568466.83085091 5106970.37836936,-9568465.30500117 5106968.05382774,-9568463.74132215 5106965.75456282,-9568462.1402325 5106963.48119019,-9568460.50216086 5106961.23431847,-9568458.82754578 5106959.01454922,-9568457.11683561 5106956.82247671,-9568455.37048833 5106954.65868781,-9568453.58897148 5106952.52376183,-9568451.77276203 5106950.41827034,-9568449.92234621 5106948.34277702,-9568448.03821943 5106946.29783754,-9568446.12088611 5106944.28399938,-9568444.17085956 5106942.30180168,-9568442.18866187 5106940.35177514,-9568440.17482371 5106938.43444182,-9568438.12988423 5106936.55031504,-9568436.05439091 5106934.69989922,-9568433.94889942 5106932.88368977,-9568431.81397344 5106931.10217293,-9568429.65018454 5106929.35582564,-9568427.45811203 5106927.64511547,-9568425.23834278 5106925.97050039,-9568422.99147106 5106924.33242875,-9568420.71809843 5106922.7313391,-9568418.41883351 5106921.16766008,-9568416.09429188 5106919.64181034,-9568413.74509588 5106918.15419838,-9568411.37187444 5106916.70522246,-9568408.97526293 5106915.29527053,-9568406.55590297 5106913.92472004,-9568404.1144423 5106912.59393794,-9568401.65153455 5106911.30328051,-9568399.1678391 5106910.05309328,-9568396.66402089 5106908.84371096,-9568394.14075026 5106907.67545733,-9568391.59870275 5106906.54864517,-9568389.03855892 5106905.46357614,-9568386.4610042 5106904.42054075,-9568383.86672864 5106903.41981823,-9568381.25642681 5106902.46167652,-9568378.63079753 5106901.54637213,-9568375.99054377 5106900.6741501,-9568373.33637237 5106899.84524395,-9568370.66899393 5106899.0598756,-9568367.98912256 5106898.31825532,-9568365.29747573 5106897.62058164,-9568362.59477406 5106896.96704136,-9568359.88174113 5106896.35780944,-9568357.15910328 5106895.79304899,-9568354.42758944 5106895.27291122,-9568351.68793088 5106894.79753536,-9568348.94086109 5106894.3670487,-9568346.18711552 5106893.98156648,-9568343.42743141 5106893.64119191,-9568340.66254761 5106893.34601612,-9568337.89320433 5106893.09611812,-9568335.12014299 5106892.89156483,-9568332.34410602 5106892.732411,-9568329.56583663 5106892.61869925,-9568326.78607861 5106892.55046002,-9568324.00557619 5106892.52771158,-9568321.22507377 5106892.55046002,-9568318.44531575 5106892.61869925,-9568315.66704636 5106892.732411,-9568312.89100938 5106892.89156483,-9568310.11794805 5106893.09611812,-9568307.34860477 5106893.34601612,-9568304.58372097 5106893.64119191,-9568301.82403686 5106893.98156648,-9568299.07029129 5106894.3670487,-9568296.3232215 5106894.79753536,-9568293.58356294 5106895.27291122,-9568290.8520491 5106895.79304899,-9568288.12941125 5106896.35780944,-9568285.41637832 5106896.96704136,-9568282.71367665 5106897.62058164,-9568280.02202982 5106898.31825532,-9568277.34215845 5106899.0598756,-9568274.67478001 5106899.84524395,-9568272.02060861 5106900.6741501,-9568269.38035485 5106901.54637213,-9568266.75472557 5106902.46167652,-9568264.14442374 5106903.41981823,-9568261.55014818 5106904.42054075,-9568258.97259345 5106905.46357614,-9568256.41244963 5106906.54864517,-9568253.87040212 5106907.67545733,-9568251.34713149 5106908.84371096,-9568248.84331328 5106910.05309328,-9568246.35961783 5106911.30328051,-9568243.89671008 5106912.59393794,-9568241.4552494 5106913.92472004,-9568239.03588945 5106915.29527053,-9568236.63927794 5106916.70522246,-9568234.2660565 5106918.15419838,-9568231.91686049 5106919.64181034,-9568229.59231887 5106921.16766008,-9568227.29305395 5106922.7313391,-9568225.01968132 5106924.33242875,-9568222.7728096 5106925.97050039,-9568220.55304035 5106927.64511547,-9568218.36096784 5106929.35582564,-9568216.19717894 5106931.10217293,-9568214.06225296 5106932.88368977,-9568211.95676147 5106934.69989922,-9568209.88126815 5106936.55031504,-9568207.83632867 5106938.43444182,-9568205.82249051 5106940.35177514,-9568203.84029282 5106942.30180168,-9568201.89026627 5106944.28399938,-9568199.97293295 5106946.29783754,-9568198.08880617 5106948.34277702,-9568196.23839035 5106950.41827034,-9568194.4221809 5106952.52376183,-9568192.64066405 5106954.65868781,-9568190.89431677 5106956.82247671,-9568189.18360659 5106959.01454922,-9568187.50899152 5106961.23431847,-9568185.87091988 5106963.48119019,-9568184.26983023 5106965.75456282,-9568182.70615121 5106968.05382774,-9568181.18030147 5106970.37836936,-9568179.69268951 5106972.72756537,-9568178.24371359 5106975.10078681,-9568176.83376166 5106977.49739832,-9568175.46321117 5106979.91675827,-9568174.13242907 5106982.35821894,-9568172.84177164 5106984.8211267,-9568171.59158441 5106987.30482215,-9568170.38220209 5106989.80864036,-9568169.21394846 5106992.33191099,-9568168.0871363 5106994.8739585,-9568167.00206727 5106997.43410232,-9568165.95903187 5107000.01165705,-9568164.95830936 5107002.60593261,-9568164.00016765 5107005.21623444,-9568163.08486326 5107007.84186372,-9568162.21264123 5107010.48211748,-9568161.38373508 5107013.13628888,-9568160.59836673 5107015.80366732,-9568159.85674645 5107018.48353869,-9568159.15907277 5107021.17518552,-9568158.50553249 5107023.87788719,-9568157.89630057 5107026.59092012,-9568157.33154012 5107029.31355796,-9568156.81140235 5107032.04507181,-9568156.33602649 5107034.78473037,-9568155.90553983 5107037.53180016,-9568155.52005761 5107040.28554573,-9568155.17968304 5107043.04522984,-9568154.88450725 5107045.81011364,-9568154.63460925 5107048.57945692,-9568154.43005596 5107051.35251825,-9568154.27090213 5107054.12855523,-9568154.15719038 5107056.90682462,-9568154.08895115 5107059.68658264,-9568154.06620271 5107062.46708506))"
POLYGONSHAPE is: "POLYGON((-9568324.00557619 5107062.46708506,-9567984.12682943 5107062.46708506,-9568324.00557619 5106722.58833811,-9568663.88429997 5107062.46708506,-9568294.38345267 5107401.04950623,-9567984.12682943 5107062.46708506,-9568324.00557619 5107062.46708506))" string
INTERSECTIONMULTIPOLYGONSHAPE: base-above exception; Coordinate-{(-130970.066202713, 374.467085059732, NaN)}; pt-{(-130970.066202713, 374.467085059732, NaN)}
Error using .GetIntersection
Hi Scott,
I can recreate the exception easily. I checked the WKT and found there might be some coordinates wrong in polygonShape. I reviewed the polygonShape’s wkt with an online tool and got the below result:
Online Tool: dev.openlayers.org/releases/OpenLayers-2.13.1/examples/vector-formats.html
We can see it seems a line in the polygon and it will make it invalid to do the intersection. Once you can make sure it’s an invalid polygon shape, I think there is a way to make it valid. We can follow the below codes:
PolygonShape circleShape = new PolygonShape(“POLYGON((-9568154.06620271 5107062.46708…”);
PolygonShape polygonShape = new PolygonShape(“POLYGON((-9568324.00557619 5107062.4670850…”);
Feature polygonFeature = new Feature(polygonShape);
if (polygonFeature.CanMakeValid)
{
polygonFeature = polygonFeature.MakeValid();
}
MultipolygonShape intersectionMultiPolygonShape = circleShape.GetIntersection((PolygonShape)polygonFeature.GetShape());
After the repair, we can see the “line” was removed.
One more thing we need to notice is, in order to use the MakeValid method, we need to copy the specified dll “Microsoft.SqlServer.Types.dll” to the application folder. We can find the dll under installationPath=> Developer Reference=>WPF Desktop Edition( - Strong Named)
Hope it helps.
Thanks,
That was what i needed. thanks.
Scott,
Good to hear it works.
If any questions, do hesitate to let us know.
Thanks,
Johnny