Thread: [Jts-topo-suite-user] Geometry.union(Geometry) vs Geometry.union()
Brought to you by:
dr_jts
|
From: Xavier N. <xn...@gm...> - 2010-04-12 07:48:55
|
Hello,
Looking at the OpenJUMP code, I have seen that to perform a line
cleaning before a polygonize, the method used is to extract a point
from the lineset to be cleaned and then use the
Geometry.union(Geometry) function.
For example this is the code from IntersectGeometries
public static Collection nodeLines(Collection lines)
{
GeometryFactory fact = new GeometryFactory();
Geometry linesGeom =
fact.createMultiLineString(fact.toLineStringArray(lines));
Geometry unionInput = fact.createMultiLineString(null);
// force the unionInput to be non-empty if possible, to ensure union
is not optimized away
Geometry point = extractPoint(lines);
if (point != null)
unionInput = point;
Geometry noded = linesGeom.union(unionInput);
List nodedList = new ArrayList();
nodedList.add(noded);
return nodedList;
}
But the Geometry class has the method "union" without parameters which
seems to be the choice to do the line cleaning (at least I think that
this is what the documentation says).
After some testing I have found that the method used in OpenJUMP
produces better results. Using the lines resulting from the union
without parameters to do a polygonize some times returns a
TopologyException and this does not happen if the method used is the
union(Geometry).
Are there any tips or conditions that have to be known before use the
union method correctly ?
Xevi.
|
|
From: Martin D. <mb...@re...> - 2010-04-12 16:10:00
|
Xavier,
The recommended approach to union sets of lines together is now to use
the Geometry.union() method. (This wasn't available when the OJ code
was written). This also has the side effect of noding the linestrings
together.
It's puzzling that you're seeing a difference in the results of
union(Point) and union(). They are actually doing exactly the same
thing under the covers! Is it possible for you to provide a test case
which shows this behaviour?
Xavier Naval wrote:
> Hello,
>
> Looking at the OpenJUMP code, I have seen that to perform a line
> cleaning before a polygonize, the method used is to extract a point
> from the lineset to be cleaned and then use the
> Geometry.union(Geometry) function.
> For example this is the code from IntersectGeometries
>
> public static Collection nodeLines(Collection lines)
> {
> GeometryFactory fact = new GeometryFactory();
> Geometry linesGeom =
> fact.createMultiLineString(fact.toLineStringArray(lines));
>
> Geometry unionInput = fact.createMultiLineString(null);
> // force the unionInput to be non-empty if possible, to ensure union
> is not optimized away
> Geometry point = extractPoint(lines);
> if (point != null)
> unionInput = point;
>
> Geometry noded = linesGeom.union(unionInput);
> List nodedList = new ArrayList();
> nodedList.add(noded);
> return nodedList;
> }
>
> But the Geometry class has the method "union" without parameters which
> seems to be the choice to do the line cleaning (at least I think that
> this is what the documentation says).
>
> After some testing I have found that the method used in OpenJUMP
> produces better results. Using the lines resulting from the union
> without parameters to do a polygonize some times returns a
> TopologyException and this does not happen if the method used is the
> union(Geometry).
>
> Are there any tips or conditions that have to be known before use the
> union method correctly ?
>
> Xevi.
>
> ------------------------------------------------------------------------------
> Download Intel® Parallel Studio Eval
> Try the new software tools for yourself. Speed compiling, find bugs
> proactively, and fine-tune applications for parallel performance.
> See why Intel Parallel Studio got high marks during beta.
> http://p.sf.net/sfu/intel-sw-dev
> _______________________________________________
> Jts-topo-suite-user mailing list
> Jts...@li...
> https://lists.sourceforge.net/lists/listinfo/jts-topo-suite-user
>
>
--
Martin Davis
Senior Technical Architect
Refractions Research, Inc.
(250) 383-3022
|
|
From: Sunburned S. <sun...@gm...> - 2010-04-12 22:53:22
|
Xevi,
Can you provide the package in OpenJUMP that contains the code you
speak of? After Martin figures out what is going on I'd like to
refactor the OpenJUMP code to use the Geometry.union method.
Thanks,
The Sunburned Surveyor
On Mon, Apr 12, 2010 at 9:12 AM, Martin Davis <mb...@re...> wrote:
> Xavier,
>
> The recommended approach to union sets of lines together is now to use
> the Geometry.union() method. (This wasn't available when the OJ code
> was written). This also has the side effect of noding the linestrings
> together.
>
> It's puzzling that you're seeing a difference in the results of
> union(Point) and union(). They are actually doing exactly the same
> thing under the covers! Is it possible for you to provide a test case
> which shows this behaviour?
>
> Xavier Naval wrote:
>> Hello,
>>
>> Looking at the OpenJUMP code, I have seen that to perform a line
>> cleaning before a polygonize, the method used is to extract a point
>> from the lineset to be cleaned and then use the
>> Geometry.union(Geometry) function.
>> For example this is the code from IntersectGeometries
>>
>> public static Collection nodeLines(Collection lines)
>> {
>> GeometryFactory fact = new GeometryFactory();
>> Geometry linesGeom =
>> fact.createMultiLineString(fact.toLineStringArray(lines));
>>
>> Geometry unionInput = fact.createMultiLineString(null);
>> // force the unionInput to be non-empty if possible, to ensure union
>> is not optimized away
>> Geometry point = extractPoint(lines);
>> if (point != null)
>> unionInput = point;
>>
>> Geometry noded = linesGeom.union(unionInput);
>> List nodedList = new ArrayList();
>> nodedList.add(noded);
>> return nodedList;
>> }
>>
>> But the Geometry class has the method "union" without parameters which
>> seems to be the choice to do the line cleaning (at least I think that
>> this is what the documentation says).
>>
>> After some testing I have found that the method used in OpenJUMP
>> produces better results. Using the lines resulting from the union
>> without parameters to do a polygonize some times returns a
>> TopologyException and this does not happen if the method used is the
>> union(Geometry).
>>
>> Are there any tips or conditions that have to be known before use the
>> union method correctly ?
>>
>> Xevi.
>>
>> ------------------------------------------------------------------------------
>> Download Intel® Parallel Studio Eval
>> Try the new software tools for yourself. Speed compiling, find bugs
>> proactively, and fine-tune applications for parallel performance.
>> See why Intel Parallel Studio got high marks during beta.
>> http://p.sf.net/sfu/intel-sw-dev
>> _______________________________________________
>> Jts-topo-suite-user mailing list
>> Jts...@li...
>> https://lists.sourceforge.net/lists/listinfo/jts-topo-suite-user
>>
>>
>
> --
> Martin Davis
> Senior Technical Architect
> Refractions Research, Inc.
> (250) 383-3022
>
>
> ------------------------------------------------------------------------------
> Download Intel® Parallel Studio Eval
> Try the new software tools for yourself. Speed compiling, find bugs
> proactively, and fine-tune applications for parallel performance.
> See why Intel Parallel Studio got high marks during beta.
> http://p.sf.net/sfu/intel-sw-dev
> _______________________________________________
> Jts-topo-suite-user mailing list
> Jts...@li...
> https://lists.sourceforge.net/lists/listinfo/jts-topo-suite-user
>
|
|
From: Xevi <xn...@gm...> - 2010-04-13 05:35:54
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta content="text/html; charset=ISO-8859-1" http-equiv="Content-Type"> </head> <body bgcolor="#f8f8ff" text="#000000"> <font face="Tahoma">Hello,<br> <br> I think this code is in various packages, i found it in :<br> <br> org.openjump.core.ui.plugin.tools.IntersectPolygonLayers.java<br> com.vivdsolutions.jump.plugin.edit.PolygonizerPlugIn.java<br> <br> Hope this helps.<br> Xevi.<br> </font> </body> </html> |
|
From: Xevi <xn...@gm...> - 2010-04-13 05:24:22
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta content="text/html; charset=ISO-8859-1" http-equiv="Content-Type"> <title></title> </head> <body bgcolor="#f8f8ff" text="#000000"> Martin,<br> <br> I found this issue with a quite big lineset that comes from a DFX file.<br> I'll try to reduce the lineset before sending it to you.<br> <br> Xevi<br> <br> <br> </body> </html> |
|
From: Martin D. <mb...@re...> - 2010-04-13 15:44:45
|
Ok, that would be great. Xevi wrote: > Martin, > > I found this issue with a quite big lineset that comes from a DFX file. > I'll try to reduce the lineset before sending it to you. > > Xevi > > > > ------------------------------------------------------------------------ > > ------------------------------------------------------------------------------ > Download Intel® Parallel Studio Eval > Try the new software tools for yourself. Speed compiling, find bugs > proactively, and fine-tune applications for parallel performance. > See why Intel Parallel Studio got high marks during beta. > http://p.sf.net/sfu/intel-sw-dev > ------------------------------------------------------------------------ > > _______________________________________________ > Jts-topo-suite-user mailing list > Jts...@li... > https://lists.sourceforge.net/lists/listinfo/jts-topo-suite-user > -- Martin Davis Senior Technical Architect Refractions Research, Inc. (250) 383-3022 |
|
From: Xevi <xn...@gm...> - 2010-06-09 02:32:25
|
Hello, Sorry for the delay on following the thread. With this geometry "01050000000200000001020000000B0000007DEF83EED5A819419ED924AD6A855141EC51B81ED6A81941D7A370AD6A8551410AD7A370E8A819413D0AD7C36A855141D964E3E2E9A81941AD4C1BC56A8551410AD7A370E8A81941B81E85C36A855141F853E3A5E4A8194123DBF9BE6A855141C3F528DCE0A81941BA490CBA6A8551416ABC7413DDA819413108ACB46A8551419A999999D9A819419A9999B16A85514183C0CA21D6A81941D7A370AD6A8551417DEF83EED5A819419ED924AD6A85514101020000000700000033333333CFA81941295C8FA26A855141EC51B81ED6A81941D7A370AD6A8551410AD7A370E8A819413D0AD7C36A8551410AD7A370FBA8194148E17AD46A855141AE47E17A0DA91941C3F528DC6A855141EC51B81E1EA919419A9999D96A85514133333333CFA81941295C8FA26A855141" I found that using Geometry.Union() with this geometry produces a TopologyException, but using Geometry.Union(pt) produces the correct result. Thanks. Xevi Al 13/04/2010 17:47, En/na Martin Davis ha escrit: > Ok, that would be great. > > Xevi wrote: > >> Martin, >> >> I found this issue with a quite big lineset that comes from a DFX file. >> I'll try to reduce the lineset before sending it to you. >> >> Xevi >> > |
|
From: Martin D. <mtn...@te...> - 2010-06-09 03:58:51
|
Interesting case... I'll try and figure out what's going on when I have a bit of time. union() and union(Geometry) use different algorithms, so there may well be a difference in how they handle some robustness issues. These kinds of things are often very gnarly to fix, so don't expect too much.. 8^) If this is really causing a problem for you, it's fairly easy to write a function that will first try union(), and then try\ union(Geometry) if the first one throws a TopologyException. (This might actually end up being the fix...) Martin Xevi wrote: > Hello, > > Sorry for the delay on following the thread. > > With this geometry > > "01050000000200000001020000000B0000007DEF83EED5A819419ED924AD6A855141EC51B81ED6A81941D7A370AD6A8551410AD7A370E8A819413D0AD7C36A855141D964E3E2E9A81941AD4C1BC56A8551410AD7A370E8A81941B81E85C36A855141F853E3A5E4A8194123DBF9BE6A855141C3F528DCE0A81941BA490CBA6A8551416ABC7413DDA819413108ACB46A8551419A999999D9A819419A9999B16A85514183C0CA21D6A81941D7A370AD6A8551417DEF83EED5A819419ED924AD6A85514101020000000700000033333333CFA81941295C8FA26A855141EC51B81ED6A81941D7A370AD6A8551410AD7A370E8A819413D0AD7C36A8551410AD7A370FBA8194148E17AD46A855141AE47E17A0DA91941C3F528DC6A855141EC51B81E1EA919419A9999D96A85514133333333CFA81941295C8FA26A855141" > > I found that using Geometry.Union() with this geometry produces a > TopologyException, but using Geometry.Union(pt) produces the correct result. > > Thanks. > Xevi > > > Al 13/04/2010 17:47, En/na Martin Davis ha escrit: > >> Ok, that would be great. >> >> Xevi wrote: >> >> >>> Martin, >>> >>> I found this issue with a quite big lineset that comes from a DFX file. >>> I'll try to reduce the lineset before sending it to you. >>> >>> Xevi >>> >>> > > ------------------------------------------------------------------------------ > ThinkGeek and WIRED's GeekDad team up for the Ultimate > GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the > lucky parental unit. See the prize list and enter to win: > http://p.sf.net/sfu/thinkgeek-promo > _______________________________________________ > Jts-topo-suite-user mailing list > Jts...@li... > https://lists.sourceforge.net/lists/listinfo/jts-topo-suite-user > > |
|
From: Sorin D. <sd...@wi...> - 2010-06-09 08:20:08
|
Hello, I am wondering where the method Geometry.Union() is defined. In the documentation at the Geometry Class I found only the method Geometry.Union(Geometry otherGeometry). Does the class SnapIfNeededOverlayOp help to avoid TopologyExceptions? Best regards, Sorin -----Ursprüngliche Nachricht----- Von: Martin Davis [mailto:mtn...@te...] Gesendet: Mittwoch, 9. Juni 2010 05:58 Cc: jts...@li... Betreff: Re: [Jts-topo-suite-user]Geometry.union(Geometry) vs Geometry.union() Interesting case... I'll try and figure out what's going on when I have a bit of time. union() and union(Geometry) use different algorithms, so there may well be a difference in how they handle some robustness issues. These kinds of things are often very gnarly to fix, so don't expect too much.. 8^) If this is really causing a problem for you, it's fairly easy to write a function that will first try union(), and then try\ union(Geometry) if the first one throws a TopologyException. (This might actually end up being the fix...) Martin Xevi wrote: > Hello, > > Sorry for the delay on following the thread. > > With this geometry > > "01050000000200000001020000000B0000007DEF83EED5A819419ED924AD6A855141EC51B81 ED6A81941D7A370AD6A8551410AD7A370E8A819413D0AD7C36A855141D964E3E2E9A81941AD4 C1BC56A8551410AD7A370E8A81941B81E85C36A855141F853E3A5E4A8194123DBF9BE6A85514 1C3F528DCE0A81941BA490CBA6A8551416ABC7413DDA819413108ACB46A8551419A999999D9A 819419A9999B16A85514183C0CA21D6A81941D7A370AD6A8551417DEF83EED5A819419ED924A D6A85514101020000000700000033333333CFA81941295C8FA26A855141EC51B81ED6A81941D 7A370AD6A8551410AD7A370E8A819413D0AD7C36A8551410AD7A370FBA8194148E17AD46A855 141AE47E17A0DA91941C3F528DC6A855141EC51B81E1EA919419A9999D96A85514133333333C FA81941295C8FA26A855141" > > I found that using Geometry.Union() with this geometry produces a > TopologyException, but using Geometry.Union(pt) produces the correct result. > > Thanks. > Xevi > > > Al 13/04/2010 17:47, En/na Martin Davis ha escrit: > >> Ok, that would be great. >> >> Xevi wrote: >> >> >>> Martin, >>> >>> I found this issue with a quite big lineset that comes from a DFX file. >>> I'll try to reduce the lineset before sending it to you. >>> >>> Xevi >>> >>> > > ---------------------------------------------------------------------- > -------- ThinkGeek and WIRED's GeekDad team up for the Ultimate > GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the lucky parental > unit. See the prize list and enter to win: > http://p.sf.net/sfu/thinkgeek-promo > _______________________________________________ > Jts-topo-suite-user mailing list > Jts...@li... > https://lists.sourceforge.net/lists/listinfo/jts-topo-suite-user > > ---------------------------------------------------------------------------- -- ThinkGeek and WIRED's GeekDad team up for the Ultimate GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the lucky parental unit. See the prize list and enter to win: http://p.sf.net/sfu/thinkgeek-promo _______________________________________________ Jts-topo-suite-user mailing list Jts...@li... https://lists.sourceforge.net/lists/listinfo/jts-topo-suite-user |
|
From: Martin D. <mb...@re...> - 2010-06-09 15:32:52
|
Geometry.union() was released back in JTS 1.9. You'll need to look at the Javadoc that ships with JTS, or here: http://tsusiatsoftware.net/jts/javadoc/com/vividsolutions/jts/geom/Geometry.html#union() The SnapIfNeededOverlayOp does help to avoid TopologyExceptions. It first tries the core union algorithm, and if a TopologyException is thrown it snaps the geometries together and retries the operation. It isn't 100% robust, but it handles a high percentage of robustness failures. Martin Sorin Dudui wrote: > Hello, > > I am wondering where the method Geometry.Union() is defined. In the > documentation at the Geometry Class I found only the method > Geometry.Union(Geometry otherGeometry). > > Does the class SnapIfNeededOverlayOp help to avoid TopologyExceptions? > > Best regards, > Sorin > > > -----Ursprüngliche Nachricht----- > Von: Martin Davis [mailto:mtn...@te...] > Gesendet: Mittwoch, 9. Juni 2010 05:58 > Cc: jts...@li... > Betreff: Re: [Jts-topo-suite-user]Geometry.union(Geometry) vs > Geometry.union() > > Interesting case... I'll try and figure out what's going on when I have a > bit of time. > > union() and union(Geometry) use different algorithms, so there may well be > a difference in how they handle some robustness issues. These kinds of > things are often very gnarly to fix, so don't expect too much.. 8^) > > If this is really causing a problem for you, it's fairly easy to write a > function that will first try union(), and then try\ union(Geometry) if the > first one throws a TopologyException. (This might actually end up being the > fix...) > > Martin > > Xevi wrote: > >> Hello, >> >> Sorry for the delay on following the thread. >> >> With this geometry >> >> >> > "01050000000200000001020000000B0000007DEF83EED5A819419ED924AD6A855141EC51B81 > ED6A81941D7A370AD6A8551410AD7A370E8A819413D0AD7C36A855141D964E3E2E9A81941AD4 > C1BC56A8551410AD7A370E8A81941B81E85C36A855141F853E3A5E4A8194123DBF9BE6A85514 > 1C3F528DCE0A81941BA490CBA6A8551416ABC7413DDA819413108ACB46A8551419A999999D9A > 819419A9999B16A85514183C0CA21D6A81941D7A370AD6A8551417DEF83EED5A819419ED924A > D6A85514101020000000700000033333333CFA81941295C8FA26A855141EC51B81ED6A81941D > 7A370AD6A8551410AD7A370E8A819413D0AD7C36A8551410AD7A370FBA8194148E17AD46A855 > 141AE47E17A0DA91941C3F528DC6A855141EC51B81E1EA919419A9999D96A85514133333333C > FA81941295C8FA26A855141" > >> I found that using Geometry.Union() with this geometry produces a >> TopologyException, but using Geometry.Union(pt) produces the correct >> > result. > >> Thanks. >> Xevi >> >> >> Al 13/04/2010 17:47, En/na Martin Davis ha escrit: >> >> >>> Ok, that would be great. >>> >>> Xevi wrote: >>> >>> >>> >>>> Martin, >>>> >>>> I found this issue with a quite big lineset that comes from a DFX file. >>>> I'll try to reduce the lineset before sending it to you. >>>> >>>> Xevi >>>> >>>> >>>> >> ---------------------------------------------------------------------- >> -------- ThinkGeek and WIRED's GeekDad team up for the Ultimate >> GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the lucky parental >> unit. See the prize list and enter to win: >> http://p.sf.net/sfu/thinkgeek-promo >> _______________________________________________ >> Jts-topo-suite-user mailing list >> Jts...@li... >> https://lists.sourceforge.net/lists/listinfo/jts-topo-suite-user >> >> >> > > ---------------------------------------------------------------------------- > -- > ThinkGeek and WIRED's GeekDad team up for the Ultimate GeekDad Father's Day > Giveaway. ONE MASSIVE PRIZE to the lucky parental unit. See the prize list > and enter to win: > http://p.sf.net/sfu/thinkgeek-promo > _______________________________________________ > Jts-topo-suite-user mailing list > Jts...@li... > https://lists.sourceforge.net/lists/listinfo/jts-topo-suite-user > > > ------------------------------------------------------------------------------ > ThinkGeek and WIRED's GeekDad team up for the Ultimate > GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the > lucky parental unit. See the prize list and enter to win: > http://p.sf.net/sfu/thinkgeek-promo > _______________________________________________ > Jts-topo-suite-user mailing list > Jts...@li... > https://lists.sourceforge.net/lists/listinfo/jts-topo-suite-user > > -- Martin Davis Senior Technical Architect Refractions Research, Inc. (250) 383-3022 |
|
From: Martin D. <mtn...@te...> - 2010-06-09 04:36:01
|
Ok, turns out that it wasn't such a gnarly problem after all. The problem was that the UnaryUnion wasn't using the more-robust version of union(Geometry). Once that was fixed (which also uncovered a couple of other minor bugs in the snapping code), unary union works fine. This will be commited to SVN tonight, and show up in the next release of JTS. Thanks, Xevi! Xevi wrote: > Hello, > > Sorry for the delay on following the thread. > > With this geometry > > "01050000000200000001020000000B0000007DEF83EED5A819419ED924AD6A855141EC51B81ED6A81941D7A370AD6A8551410AD7A370E8A819413D0AD7C36A855141D964E3E2E9A81941AD4C1BC56A8551410AD7A370E8A81941B81E85C36A855141F853E3A5E4A8194123DBF9BE6A855141C3F528DCE0A81941BA490CBA6A8551416ABC7413DDA819413108ACB46A8551419A999999D9A819419A9999B16A85514183C0CA21D6A81941D7A370AD6A8551417DEF83EED5A819419ED924AD6A85514101020000000700000033333333CFA81941295C8FA26A855141EC51B81ED6A81941D7A370AD6A8551410AD7A370E8A819413D0AD7C36A8551410AD7A370FBA8194148E17AD46A855141AE47E17A0DA91941C3F528DC6A855141EC51B81E1EA919419A9999D96A85514133333333CFA81941295C8FA26A855141" > > I found that using Geometry.Union() with this geometry produces a > TopologyException, but using Geometry.Union(pt) produces the correct result. > > Thanks. > Xevi > > > Al 13/04/2010 17:47, En/na Martin Davis ha escrit: > >> Ok, that would be great. >> >> Xevi wrote: >> >> >>> Martin, >>> >>> I found this issue with a quite big lineset that comes from a DFX file. >>> I'll try to reduce the lineset before sending it to you. >>> >>> Xevi >>> >>> > > ------------------------------------------------------------------------------ > ThinkGeek and WIRED's GeekDad team up for the Ultimate > GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the > lucky parental unit. See the prize list and enter to win: > http://p.sf.net/sfu/thinkgeek-promo > _______________________________________________ > Jts-topo-suite-user mailing list > Jts...@li... > https://lists.sourceforge.net/lists/listinfo/jts-topo-suite-user > > |