Class EdgeSetNoder

 1  
 2  
 3 /*
 4  * Copyright (c) 2016 Vivid Solutions.
 5  *
 6  * All rights reserved. This program and the accompanying materials
 7  * are made available under the terms of the Eclipse Public License 2.0
 8  * and Eclipse Distribution License v. 1.0 which accompanies this distribution.
 9  * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v20.html
10  * and the Eclipse Distribution License is available at
11  *
12  * http://www.eclipse.org/org/documents/edl-v10.php.
13  */
14 package org.locationtech.jts.operation.overlay;
15  
16 import java.util.ArrayList;
17 import java.util.Iterator;
18 import java.util.List;
19  
20 import org.locationtech.jts.algorithm.LineIntersector;
21 import org.locationtech.jts.geomgraph.Edge;
22 import org.locationtech.jts.geomgraph.index.EdgeSetIntersector;
23 import org.locationtech.jts.geomgraph.index.SegmentIntersector;
24 import org.locationtech.jts.geomgraph.index.SimpleMCSweepLineIntersector;
25  
26 /**
27  * Nodes a set of edges.
28  * Takes one or more sets of edges and constructs a
29  * new set of edges consisting of all the split edges created by
30  * noding the input edges together
31  * @version 1.7
32  */
33 public class EdgeSetNoder {
34  
35   private LineIntersector li;
36   private List inputEdges = new ArrayList();
37  
38   public EdgeSetNoder(LineIntersector li) {
39     this.li = li;
40   }
41  
42   public void addEdges(List edges)
43   {
44     inputEdges.addAll(edges);
45   }
46  
47   public List getNodedEdges()
48   {
49     EdgeSetIntersector esi = new SimpleMCSweepLineIntersector();
50     SegmentIntersector si = new SegmentIntersector(li, truefalse);
51     esi.computeIntersections(inputEdges, si, true);
52 //Debug.println("has proper int = " + si.hasProperIntersection());
53  
54     List splitEdges = new ArrayList();
55     for (Iterator i = inputEdges.iterator(); i.hasNext(); ) {
56       Edge e = (Edge) i.next();
57       e.getEdgeIntersectionList().addSplitEdges(splitEdges);
58     }
59     return splitEdges;
60   }
61 }
62