bilaldursun1 / nettopologysuite

Automatically exported from code.google.com/p/nettopologysuite
0 stars 0 forks source link

Exception in Geometry.Union with 2 polygons in WGS84 Geo projection #58

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create 2 polygons in  WGS84 Geo projection (poly1, poly2)
2. Activate poly1.Union.Poly2
3.

What is the expected output?  United geometry.
What do you see instead? Exception ="no outgoing dirEdge found "
Call stack is attached: 

NTS.Geometries.TopologyException occurred
  Message="no outgoing dirEdge found [ (34.5025922837571, 31.5770655272557
, לא מספר) ]"
  Source="NTS"
  StackTrace:
       at NTS.GeometriesGraph.DirectedEdgeStar.LinkResultDirectedEdges() 
in D:\CCViewRoot\Miri_DD_GIS_C2Infra_4.0\C2Infrastructure\C2
Infra.GIS\Sources\NTS\NTS\GeometriesGraph\DirectedEdgeStar.cs:line 248
  InnerException:

ה – stack:
>            NTS.dll!
NTS.GeometriesGraph.DirectedEdgeStar.LinkResultDirectedEdges() Line 249
        C#
             NTS.dll!
NTS.GeometriesGraph.PlanarGraph.LinkResultDirectedEdges
(System.Collections.IList nodes = Count = 6) Line 37 + 0x3d 
bytes            C#
             NTS.dll!NTS.Operation.Overlay.PolygonBuilder.Add
(System.Collections.IList dirEdges = Count = 20, System.Collections.IList 
nodes = Count = 6) Line 50 + 0x8 bytes            C#
             NTS.dll!NTS.Operation.Overlay.PolygonBuilder.Add
(NTS.GeometriesGraph.PlanarGraph graph = 
{NTS.GeometriesGraph.PlanarGraph}) Line 38 + 0x2a bytes           C#
             NTS.dll!NTS.Operation.Overlay.OverlayOp.ComputeOverlay
(NTS.Operation.Overlay.SpatialFunctions opCode = Union) Line 191 + 0xe 
bytes   C#
             NTS.dll!NTS.Operation.Overlay.OverlayOp.GetResultGeometry
(NTS.Operation.Overlay.SpatialFunctions funcCode = Union) Line 135 + 0xb 
bytes           C#
             NTS.dll!NTS.Operation.Overlay.OverlayOp.Overlay
(NTS.Geometries.Geometry geom0 = {POLYGON ((34.4599206749855 
31.5052751195827, 34.4591251183673 31.505876611193, 34.4564127638305 
31.5080004493462, 34.4537439626941 31.5101644632323, 34.4511195275254 
31.5123679963883, 34.4485402576016 31.5146103803175, 34.4460069386666 
31.5168909346892, 34.4435203426915 31.5192089675434, 34.4410812276395 
31.5215637754978, 34.4386903372342 31.5239546439589, 34.4363484007321 
31.5263808473365, 34.4340561326997 31.5288416492612, 34.4318142327941 
31.5313363028058, 34.4523940586416 31.5446327903823, 34.418652699709 
31.5435956152166, 34.418607869166 31.543986448727, 34.4183101561582 
31.5471479227217, 34.41807689871 31.5503133628077, 34.4179081743761 
31.5534818051185, 34.4684965987297 31.5550365336316, 34.4684965987297 
31.5550365336316, 34.5025922837571 31.5770655272557, 34.5025922837571 
31.5770655272557, 34.5422799720196 31.6027074766985, 34.5431747791894 
31.5880715000537, 34.5685729895296 31.5765362132154, 34.55930848337 
31.5578274453506, 34.6065677538988 31.5592798593432, 34.6185283279689 
31.5538476398758, 34.6104027450397 31.5494898172092, 34.5543261354984 
31.5477660790837, 34.5465936184665 31.532151014053, 34.5475930100184 
31.51580439558, 34.5352102504765 31.5091634110899, 34.5295489583641 
31.4977309830554, 34.5480899795286 31.507675678701, 34.5487682794976 
31.4965810173711, 34.6079153103621 31.519202679428, 34.6040625393342 
31.5129853907695, 34.5085166118414 31.4001059322511, 34.5059238988558 
31.4016307845592, 34.5029221486902 31.4034629329153, 34.4999580174807 
31.4053396664381, 34.4970324062088 31.4072604160639, 34.4941462043379 
31.409224599348, 34.491300289545 31.4112316206391, 34.4884955274549 
31.4132808712574, 34.4857327713778 31.4153717296767, 34.4830128620515 
31.4175035617108, 34.4803366273856 31.4196757207029, 34.4777048822103 
31.4218875477197, 34.4751184280291 31.4241383717488, 34.4725780527743 
31.4264275098994, 34.4700845305673 31.4287542676074, 34.4676386214824 
31.4311179388436, 34.4652410713149 31.4335178063254, 34.4628926113528 
31.4359531417319, 34.460593958153 31.4384232059227, 34.4583458133218 
31.4409272491596, 34.4561488632993 31.4434645113319, 34.4540037791487 
31.4460342221845, 34.4519112163495 31.4486356015497, 34.4498718145952 
31.4512678595813, 34.4478861975964 31.4539301969923, 34.4743127616154 
31.4681043966654, 34.4743127616154 31.4681043966654, 34.4993680288455 
31.4815430851126, 34.4979567535991 31.4821983257671, 34.4947577303384 
31.4837459579996, 34.4915906049213 31.4853411206382, 34.4911862850778 
31.4855529654203, 34.4607591078457 31.4692345986305, 34.4596847958284 
31.4695965472927, 34.4562266213771 31.4708216658667, 34.4527938273347 
31.4720982335203, 34.4493874547891 31.4734258634554, 34.4460085369521 
31.4748041533856, 34.4426580988495 31.4762326856563, 34.4599206749855 
31.5052751195827))}, NTS.Geometries.Geometry geom1 = {POLYGON ((
34.5431747791894 31.5880715000537, 34.5456552475145 31.5474995447779, 
34.4838900024857 31.5456009437648, 34.5163702622719 31.6002454992081, 
34.5431747791894 31.5880715000537))}, 
NTS.Operation.Overlay.SpatialFunctions opCode = Union) Line 57 + 0xd 
bytes    C#
             NTS.dll!NTS.Geometries.Geometry.Union(NTS.Geometries.Geometry 
other = {POLYGON ((34.5431747791894 31.5880715000537, 34.5456552475145 
31.5474995447779, 34.4838900024857 31.5456009437648, 34.5163702622719 
31.6002454992081, 34.5431747791894 31.5880715000537))}) Line 942 + 0xd 
bytes      C#
             Scenarios.AppInfra.BL.Elements.dll!
Scenarios.AppInfra.BL.Elements.GRDS.CalculateIntersection() Line 282 + 0x2
f bytes          C#

What version of the product are you using? 
On what operating system? win xp

Thanks Miri

Original issue reported on code.google.com by miri.vil...@gmail.com on 23 Feb 2010 at 6:21

GoogleCodeExporter commented 9 years ago
I am a newbi about to attempt this very operation in same projection. Any news 
on 
this would be great. Is there any example code? Thanks, Chris.

Original comment by c.seed%n...@gtempaccount.com on 25 Feb 2010 at 4:42

GoogleCodeExporter commented 9 years ago
this looks not a bug but a topology problem.
as fist step try to verify if your geometry is valid (i.e.call 
Geometry.IsValid) and if 
it isn't, call Geometry.Buffer(o) to force topology validation.
By the way, use the google group for any kind of support question:
http://groups.google.com/group/nettopologysuite

Original comment by diegogu...@gmail.com on 25 Feb 2010 at 4:46

GoogleCodeExporter commented 9 years ago
Thanks, I'll check it. The geometry is a result of a difference operation. How 
can 
Buffer(0) fix the topology and why Geometry.Difference makes it invalid?

Thanks again

Miri

Original comment by miri.vil...@gmail.com on 25 Feb 2010 at 6:08

GoogleCodeExporter commented 9 years ago
nice questions to answer in the googlegroup :)

Original comment by diegogu...@gmail.com on 25 Feb 2010 at 6:45

GoogleCodeExporter commented 9 years ago
The both geometries  are valid. It's not a topology problem. I also called 
Buffer(0) 
but it didn't help. I got the same exception.
What do you think the problem is?

Thanks

Original comment by miri.vil...@gmail.com on 1 Mar 2010 at 6:46

GoogleCodeExporter commented 9 years ago
Hello
A attach a test case where one of the geometroes were actually not valid. 
Geom.Buffer
(0) maked it valid. Nut still union failed and I got the exception.

Attached test case

Thanks Miri

Original comment by miri.vil...@gmail.com on 4 Mar 2010 at 10:07

Attachments:

GoogleCodeExporter commented 9 years ago
thanks for the unittest, I take a look as soon as possible

Original comment by diegogu...@gmail.com on 4 Mar 2010 at 10:37

GoogleCodeExporter commented 9 years ago
Just one thing. Instead  const string wkt2 =
                "4326@POLYGON ((34.89504284421 30.4639917561117, 34.8974881525283 
30.4235194508906, 34.8362388038152 30.4216169690234, 34.8683403196915 
30.4762662772922, 34.89504284421 30.4639917561117))";

write

 const string wkt2 =
                "POLYGON ((34.89504284421 30.4639917561117, 34.8974881525283 
30.4235194508906, 34.8362388038152 30.4216169690234, 34.8683403196915 
30.4762662772922, 34.89504284421 30.4639917561117))";

- remove SRID and @. We inherited from Writer and Reader to add SRID.

Thanks

Miri

Original comment by miri.vil...@gmail.com on 4 Mar 2010 at 6:38

GoogleCodeExporter commented 9 years ago
I've tested your code and it works using trunk version:
http://code.google.com/p/nettopologysuite/source/browse/trunk/NetTopologySuite.S
amples.
Console/Tests/Various/Issue58Tests.cs?spec=svn492&r=492
please take a look and verify if I've made some mistakes.

Original comment by diegogu...@gmail.com on 5 Mar 2010 at 8:20

GoogleCodeExporter commented 9 years ago
Hi attached file with test that fails and throws an exception on Union

Thanks

Miri

Original comment by miri.vil...@gmail.com on 17 Mar 2010 at 6:33

Attachments:

GoogleCodeExporter commented 9 years ago
as expected, it works using the trunk

Original comment by diegogu...@gmail.com on 17 Mar 2010 at 7:53

GoogleCodeExporter commented 9 years ago
10X, Maybe I am using older version.
I downloaded version 1.7.3 build 416 from March 2009. Is this the latest 
version for 
download?

Miri

Original comment by miri.vil...@gmail.com on 17 Mar 2010 at 7:10

GoogleCodeExporter commented 9 years ago
try with the attached release

Original comment by diegogu...@gmail.com on 17 Mar 2010 at 10:22

Attachments:

GoogleCodeExporter commented 9 years ago
Thanks again I'll try it

Miri

Original comment by miri.vil...@gmail.com on 18 Mar 2010 at 2:41