Tanya,

The union executes fine in the JTS TestBuilder, using UnaryUnion (Geometry.union()). Geometry.union() is the recommended way to perform this operation. The WKT I used is below.

I notice however that the output you supplied is missing a final closing coordinate, and when that is added it indeed looks incorrect like the image you showed. This makes me wonder if it's not JTS that's the problem, but something in the input/output module of your code.

As I said, if you can supply the WKT for the geometries that go into the union, and the WKT for the output immediately after, that will confirm if it's a JTS problem, or elsewhere.

Martin

Input of 5 polygons:

GEOMETRYCOLLECTION (POLYGON ((584068.9 269250.38, 584069.5 269262, 584073.4 269274.06, 584078.7 269284.72, 584086.5 269294.62, 584096 269302.84, 584108.1 269305.62, 584124.8 269305.28, 584142.56 269302.44, 584156.75 269298.2, 584169.06 269292.25, 584176.2 269286.84, 584186.1 269276.2, 584196.4 269262.34, 584209.5 269244.62, 584220.4 269232.1, 584229.75 269229.03, 584243.2 269225.47, 584254 269226.8, 584260.25 269234.7, 584266.6 269241.44, 584271.25 269252.78, 584270.2 269262.72, 584265.9 269267.7, 584261.06 269272.2, 584255.6 269283.62, 584245.3 269302.44, 584239.6 269322.3, 584237.2 269336.12, 584238.06 269345.3, 584237.9 269354.22, 584233.6 269369.47, 584224.75 269377.28, 584219.75 269384.72, 584218.4 269392.53, 584218.4 269404.22, 584232.75 269422.53, 584299.4 269394.25, 584393.1 269373.6, 584397.1 269369.12, 584401.06 269363.44, 584403.2 269349.97, 584400.3 269330.47, 584393.56 269312, 584384.7 269297.12, 584374.9 269280.44, 584372.4 269268.75, 584367.75 269248.53, 584362.44 269234, 584358.94 269219.12, 584355.7 269208.8, 584354.3 269194.97, 584352.2 269171.94, 584349 269154.2, 584345.94 269140.12, 584334.44 269130.06, 584315.6 269121.9, 584302.1 269117.66, 584291.1 269115.38, 584279.8 269114.12, 584260.3 269116.6, 584233.4 269122.28, 584200.7 269129.38, 584179.7 269135.4, 584151.44 269143.56, 584126.56 269154.2, 584103.06 269166.06, 584082.44 269195.56, 584068.9 269250.38)), POLYGON ((584374.2 269114.8, 584368.6 269105.75, 584365.8 269098.3, 584364.6 269087.38, 584363.7 269076.94, 584367.44 269065.06, 584377.9 269052.06, 584390.2 269039.5, 584404.4 269031.6, 584417.6 269028.34, 584429.75 269027.4, 584440.75 269028, 584450.7 269032.28, 584457.9 269036.72, 584463 269042.97, 584466.5 269060.4, 584463.94 269070.88, 584460.44 269083.9, 584458.56 269089.94, 584456.7 269098.3, 584452.75 269106.7, 584448.3 269113.88, 584443.7 269118.3, 584438.3 269121.56, 584427.2 269123.88, 584413.7 269125.75, 584401.4 269125.97, 584389.6 269124.56, 584379.06 269119.47, 584374.2 269114.8)), POLYGON ((584830.7 269050.66, 584821.4 269051.53, 584812.9 269054.72, 584805.7 269058.75, 584799.2 269063.72, 584794.1 269070.16, 584790.6 269078.78, 584787.06 269091.38, 584786.8 269106.1, 584787.5 269125.5, 584790.94 269142.47, 584796.75 269154.34, 584802.4 269161.94, 584804.7 269171.22, 584803.6 269178.84, 584802.1 269184.47, 584799.1 269187.94, 584794.7 269190.78, 584790 269191.66, 584785.06 269191.66, 584780.3 269190.78, 584775.44 269189.3, 584767.94 269187.84, 584760.06 269187.84, 584751.75 269188.53, 584745.94 269190.1, 584739.2 269193, 584735.9 269195.66, 584732.2 269198.62, 584728.2 269202, 584723.6 269201.6, 584716.7 269197.75, 584711.5 269193.25, 584709.25 269188.75, 584703 269183.34, 584693.3 269178.62, 584684.06 269176.8, 584675.75 269177.28, 584668.1 269177.72, 584658.7 269183.62, 584652.5 269190.16, 584645.6 269199.66, 584640.4 269204.25, 584633.2 269205.56, 584626.3 269202.94, 584622.2 269192.03, 584619.94 269181.56, 584619.94 269171.12, 584621.75 269152.94, 584621.75 269135.66, 584620.4 269121.1, 584617.7 269106.53, 584614.94 269098.8, 584609.5 269098.34, 584598.1 269100.2, 584587.6 269105.2, 584579 269112.9, 584575.4 269120.2, 584573.1 269131.56, 584572.6 269143.84, 584572.6 269156.1, 584574.44 269169.28, 584574.94 269183.38, 584574 269198.4, 584569.94 269214.3, 584565.8 269229.78, 584559 269252.5, 584557.2 269264.34, 584555.4 269278.88, 584558.1 269304.8, 584563.1 269323, 584571.3 269333.44, 584611.3 269325.25, 584620.75 269317.97, 584627.9 269310.53, 584632.94 269302.8, 584637.7 269297.44, 584642.2 269293.28, 584646.6 269291.2, 584653.2 269289.72, 584660.94 269289.12, 584671.3 269288.8, 584679.06 269289.4, 584685.9 269290.72, 584693.5 269292.4, 584698.75 269295.97, 584715.7 269292.38, 584718.25 269284.97, 584725.94 269280.25, 584732.2 269280.47, 584738.06 269283.84, 584751.4 269287.06, 584773.4 269277.47, 584780.4 269275.16, 584791.6 269275.56, 584799.06 269275.56, 584806.06 269276.62, 584811.56 269276.62, 584823.44 269273.66, 584833.8 269272.12, 584964.6 269254.8, 584973.3 269252.47, 584982.25 269251.22, 584991.75 269248.66, 584987.3 269234.03, 584981.56 269218.12, 584973.6 269208.56, 584968.56 269202.84, 584963.44 269198.06, 584956.44 269194.25, 584949.75 269191.7, 584939.9 269189.16, 584928.44 269188.84, 584915 269192.56, 584903.3 269197.5, 584894.5 269201.34, 584887.75 269205.16, 584882.4 269206.28, 584876.4 269206.6, 584871.56 269206.72, 584866.9 269205.38, 584864.1 269202.5, 584862.8 269197.28, 584863.06 269189.62, 584864.4 269180.88, 584865.94 269173.38, 584868.44 269162.88, 584872 269151.38, 584874.06 269139.9, 584875.9 269128.9, 584875.06 269115.2, 584872.94 269103.28, 584869.3 269089.78, 584864.4 269077.62, 584859.56 269066.53, 584855.4 269060.78, 584850 269056.06, 584839.44 269051.78, 584830.7 269050.66)), POLYGON ((584318.4 269092.28, 584314.94 269098.5, 584314.7 269109, 584316.4 269118.34, 584322.6 269129.4, 584330.25 269136.47, 584337.06 269142.72, 584338.75 269149.5, 584342.1 269166.78, 584348.4 269178.12, 584364.8 269190.56, 584378.4 269195.7, 584388.3 269200.5, 584402.5 269210.97, 584412.7 269214.94, 584420.9 269216.9, 584430.8 269216.9, 584437.6 269216.06, 584449.5 269214.66, 584460.8 269214.94, 584471.9 269212.38, 584481.5 269208.12, 584494.56 269203.3, 584508.1 269195.12, 584517.5 269183.78, 584526.25 269169.62, 584534.2 269151.22, 584537.9 269143, 584541.9 269137.03, 584544.94 269129.7, 584545.5 269120.62, 584544.1 269114.66, 584541.9 269111.53, 584533.4 269107.6, 584521.2 269105.6, 584508.7 269104.75, 584497.6 269105.03, 584488.9 269104.2, 584480.7 269103.62, 584471 269103.34, 584458.56 269104.75, 584449.5 269107, 584439.3 269109, 584429.4 269109.28, 584419.5 269110.97, 584406.44 269110.7, 584396.8 269108.44, 584386.9 269104.47, 584377.56 269099.94, 584366.8 269095.4, 584357.1 269090.6, 584345.25 269088.03, 584333.4 269087.47, 584324 269089.44, 584318.4 269092.28)), POLYGON ((584634.1 269182.97, 584643.3 269186.34, 584659.56 269186.84, 584670.75 269183.94, 584674.6 269180.34, 584677.8 269175.78, 584679.9 269167.6, 584680.75 269158.47, 584681.44 269144.56, 584681.44 269133.84, 584681.6 269123.22, 584681.2 269113.56, 584679.2 269100.6, 584675.06 269088.7, 584672.1 269084.4, 584665.6 269081.78, 584661.2 269081, 584656.1 269081.66, 584645.2 269084.2, 584635.2 269088.06, 584628.8 269091.94, 584623.7 269095.44, 584618.3 269105.6, 584615.1 269120.62, 584614.44 269135.7, 584615.4 269147.53, 584617.2 269156.66, 584621.06 269166.9, 584627.7 269177.38, 584634.1 269182.97)))

On 8/9/2013 12:58 AM, Richmond, Tanya wrote:
Hi Martin
I'm sorry, but I cannot work out how to reply directly on the forum -- do I need a logon? Anyway, I have attached a text file which has the information about the polygon co-ordinates. I hope this helps. I am in the UK and these co-ordinates are UK map references (Northings/Eastings).
Please let me know if you need any further information.
Best Wishes
Tanya


------------------------------------------------------------------------------
Get 100% visibility into Java/.NET code with AppDynamics Lite!
It's a free troubleshooting tool designed for production.
Get down to code-level detail for bottlenecks, with <2% overhead. 
Download for free and get started troubleshooting in minutes. 
http://pubads.g.doubleclick.net/gampad/clk?id=48897031&iu=/4140/ostg.clktrk
_______________________________________________
Jts-topo-suite-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jts-topo-suite-user

Reply via email to