Discussion:
[Jts-topo-suite-user] Further issues with polygonizer - union to fix self-intersecting rings does Topologyexception despite low precision.
Phil Scadden
2016-07-21 21:40:26 UTC
Permalink
I reduced precision in the geometryFactory in attempt to make the
polygonizer work. Now I have problem with TopologyException with union
when trying to fix self-intersecting rings.

My code for dealing with self intersecting rings...

private static boolean addLineString(LineString lineString,
Polygonizer polygonizer){
GeometryFactory gf = lineString.getFactory();
if(lineString instanceof LinearRing){
lineString =
gf.createLineString(lineString.getCoordinateSequence());
}
// unioning the linestring with the point makes any self
intersections explicit.
Point point = gf.createPoint(lineString.getCoordinateN(0));
Geometry toAdd = lineString.union(point);
Coordinate[] c = toAdd.getCoordinates();
if (c[0].equals(c[c.length-1])) {
//Add result to polygonizer
// System.out.println(toAdd.toText());
polygonizer.add(toAdd);
return true;
} else {
// if the ring consists of point a,b,c,a where a-b-c are essentially
colinear, then union destroys the ring - discard it
System.out.println("Straight line detected: " +
toAdd.toText());
return false;
}
}

lineString.union(point) produces topography exception:
"/found non-noded intersection between LINESTRING ( 1566269.0 5566171.0,
1566550.0 5566381.0 ) and LINESTRING ( 1566565.0 5566390.0, 1566266.0
5566169.0 ) [ (1566295.5094339622, 5566190.811320755, NaN) ]"

/These two lines are nearly parallel, and do intersect. I am working
with 7 digits of precision in the input coordinates and can hardly see
how it is reasonable to reduce precision further. Is there a better way to

Notice: This email and any attachments are confidential.
If received in error please destroy and immediately notify us.
Do not copy or disclose the contents.
Phil Scadden
2016-07-21 23:10:45 UTC
Permalink
I managed to make some progress on this by perturbing points if union
failed. However, when the full list of validated linearRings are feed
into the polygonizer, it still crashes the polygonizer as before. It
crashes in the 1.14 JTS Testbuilder as well.

I have hundreds of these meshes to process.
Post by Phil Scadden
I reduced precision in the geometryFactory in attempt to make the
polygonizer work. Now I have problem with TopologyException with union
when trying to fix self-intersecting rings.
My code for dealing with self intersecting rings...
private static boolean addLineString(LineString lineString,
Polygonizer polygonizer){
GeometryFactory gf = lineString.getFactory();
if(lineString instanceof LinearRing){
lineString =
gf.createLineString(lineString.getCoordinateSequence());
}
// unioning the linestring with the point makes any self
intersections explicit.
Point point = gf.createPoint(lineString.getCoordinateN(0));
Geometry toAdd = lineString.union(point);
Coordinate[] c = toAdd.getCoordinates();
if (c[0].equals(c[c.length-1])) {
//Add result to polygonizer
// System.out.println(toAdd.toText());
polygonizer.add(toAdd);
return true;
} else {
// if the ring consists of point a,b,c,a where a-b-c are essentially
colinear, then union destroys the ring - discard it
System.out.println("Straight line detected: " +
toAdd.toText());
return false;
}
}
"/found non-noded intersection between LINESTRING ( 1566269.0
5566171.0, 1566550.0 5566381.0 ) and LINESTRING ( 1566565.0 5566390.0,
1566266.0 5566169.0 ) [ (1566295.5094339622, 5566190.811320755, NaN) ]"
/These two lines are nearly parallel, and do intersect. I am working
with 7 digits of precision in the input coordinates and can hardly see
how it is reasonable to reduce precision further. Is there a better way to
Notice: This email and any attachments are confidential. If received
in error please destroy and immediately notify us. Do not copy or
disclose the contents.
------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are
consuming the most bandwidth. Provides multi-vendor support for NetFlow,
J-Flow, sFlow and other flows. Make informed decisions using capacity planning
reports.http://sdm.link/zohodev2dev
_______________________________________________
Jts-topo-suite-user mailing list
https://lists.sourceforge.net/lists/listinfo/jts-topo-suite-user
--
Phil Scadden, Senior Scientist GNS Science Ltd 764 Cumberland St,
Private Bag 1930, Dunedin, New Zealand Ph +64 3 4799663, fax +64 3 477 5232

Notice: This email and any attachments are confidential.
If received in error please destroy and immediately notify us.
Do not copy or disclose the contents.
Landon Blake
2016-07-25 16:05:31 UTC
Permalink
Phil:

I had trouble downloading your sample data file. Could you send it to me
directly?

Also, if you could attach a screenshot showing one of the figures you are
trying to polygonize...that might help you get an answer from another JTS
user.

Landon
Post by Phil Scadden
I managed to make some progress on this by perturbing points if union
failed. However, when the full list of validated linearRings are feed into
the polygonizer, it still crashes the polygonizer as before. It crashes in
the 1.14 JTS Testbuilder as well.
I have hundreds of these meshes to process.
I reduced precision in the geometryFactory in attempt to make the
polygonizer work. Now I have problem with TopologyException with union when
trying to fix self-intersecting rings.
My code for dealing with self intersecting rings...
private static boolean addLineString(LineString lineString,
Polygonizer polygonizer){
GeometryFactory gf = lineString.getFactory();
if(lineString instanceof LinearRing){
lineString =
gf.createLineString(lineString.getCoordinateSequence());
}
// unioning the linestring with the point makes any self
intersections explicit.
Point point = gf.createPoint(lineString.getCoordinateN(0));
Geometry toAdd = lineString.union(point);
Coordinate[] c = toAdd.getCoordinates();
if (c[0].equals(c[c.length-1])) {
//Add result to polygonizer
// System.out.println(toAdd.toText());
polygonizer.add(toAdd);
return true;
} else {
// if the ring consists of point a,b,c,a where a-b-c are essentially
colinear, then union destroys the ring - discard it
System.out.println("Straight line detected: " +
toAdd.toText());
return false;
}
}
"
*found non-noded intersection between LINESTRING ( 1566269.0 5566171.0,
1566550.0 5566381.0 ) and LINESTRING ( 1566565.0 5566390.0, 1566266.0
5566169.0 ) [ (1566295.5094339622, 5566190.811320755, NaN) ]" *These two
lines are nearly parallel, and do intersect. I am working with 7 digits of
precision in the input coordinates and can hardly see how it is reasonable
to reduce precision further. Is there a better way to
Notice: This email and any attachments are confidential. If received in
error please destroy and immediately notify us. Do not copy or disclose the
contents.
------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are
consuming the most bandwidth. Provides multi-vendor support for NetFlow,
J-Flow, sFlow and other flows. Make informed decisions using capacity planning
reports.http://sdm.link/zohodev2dev
_______________________________________________
--
Phil Scadden, Senior Scientist GNS Science Ltd 764 Cumberland St, Private
Bag 1930, Dunedin, New Zealand Ph +64 3 4799663, fax +64 3 477 5232
Notice: This email and any attachments are confidential. If received in
error please destroy and immediately notify us. Do not copy or disclose the
contents.
------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are
consuming the most bandwidth. Provides multi-vendor support for NetFlow,
J-Flow, sFlow and other flows. Make informed decisions using capacity planning
reports.http://sdm.link/zohodev2dev
_______________________________________________
Jts-topo-suite-user mailing list
https://lists.sourceforge.net/lists/listinfo/jts-topo-suite-user
Phil Scadden
2016-07-25 21:26:31 UTC
Permalink
Thanks very much for trying that. I dont know what happened to that
file, but in meantime I have studied the problem pretty carefully in
testbuilder. The mesh topology from which this is extracted is created
with a scale of 8. (smallest division of metre is 0.125 and everything
is multiples of 0.125). Rounding up loses topological expression,
resulting in lines with spikes (eg (0 0) (3 0) (3 9) (3 0) (5 0) instead
of (0 3) (3 0) (3.125 9) (3.25 0) (5 0) )

So it appears part of issue is due to using a precisionmodel that was
too low rather than too high. I have changed to precisionmodel(1000)
(because using 8 causes .125 to be rounded to .12) and so far I am
making better progress. union plus polygonizer is allowing me to sort
out self-intersecting polygons. I am still getting the odd topoException
from near-collinear lines intersecting but I think "nudging" one of the
verticies at random and trying again is working. I am also working on
building filter to eliminate some artifacts. I will try the polygonizer
again on the cleaned up data set when I have that working.


Notice: This email and any attachments are confidential.
If received in error please destroy and immediately notify us.
Do not copy or disclose the contents.

Loading...