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.


On 22/07/2016 9:40 a.m., Phil Scadden wrote:

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.


------------------------------------------------------------------------------
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
[email protected]
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.

------------------------------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/jts-topo-suite-user

Reply via email to