private void addLine(Coordinate[] pts) { SegmentString segStr = new BasicSegmentString(pts, null); List segChains = MonotoneChainBuilder.getChains(segStr.getCoordinates(), segStr); for (Iterator i = segChains.iterator(); i.hasNext(); ) { MonotoneChain mc = (MonotoneChain) i.next(); index.insert(mc.getEnvelope(), mc); } }
private void init(Geometry geom) { List lines = LinearComponentExtracter.getLines(geom); for (Iterator i = lines.iterator(); i.hasNext(); ) { LineString line = (LineString) i.next(); Coordinate[] pts = line.getCoordinates(); addLine(pts); } }
private void countSegs( RayCrossingCounter rcc, Envelope rayEnv, List monoChains, MCSegmentCounter mcSegCounter) { for (Iterator i = monoChains.iterator(); i.hasNext(); ) { MonotoneChain mc = (MonotoneChain) i.next(); mc.select(rayEnv, mcSegCounter); // short-circuit if possible if (rcc.isOnSegment()) return; } }
private static Geometry convertSegStrings(Iterator it) { GeometryFactory fact = new GeometryFactory(); List lines = new ArrayList(); while (it.hasNext()) { SegmentString ss = (SegmentString) it.next(); LineString line = fact.createLineString(ss.getCoordinates()); lines.add(line); } return fact.buildGeometry(lines); }
/** * Tests whether any representative point of the test Geometry intersects the target geometry. * Only handles test geometries which are Puntal (dimension 0) * * @param geom a Puntal geometry to test * @return true if any point of the argument intersects the prepared geometry */ protected boolean isAnyTestPointInTarget(Geometry testGeom) { /** * This could be optimized by using the segment index on the lineal target. However, it seems * like the L/P case would be pretty rare in practice. */ PointLocator locator = new PointLocator(); List coords = ComponentCoordinateExtracter.getCoordinates(testGeom); for (Iterator i = coords.iterator(); i.hasNext(); ) { Coordinate p = (Coordinate) i.next(); if (locator.intersects(p, prepLine.getGeometry())) return true; } return false; }
private void computeNodedEdges(List bufferSegStrList, PrecisionModel precisionModel) { Noder noder = getNoder(precisionModel); noder.computeNodes(bufferSegStrList); Collection nodedSegStrings = noder.getNodedSubstrings(); // DEBUGGING ONLY // BufferDebug.saveEdges(nodedEdges, "run" + BufferDebug.runCount + "_nodedEdges"); for (Iterator i = nodedSegStrings.iterator(); i.hasNext(); ) { SegmentString segStr = (SegmentString) i.next(); Label oldLabel = (Label) segStr.getData(); Edge edge = new Edge(segStr.getCoordinates(), new Label(oldLabel)); insertUniqueEdge(edge); } // saveEdges(edgeList.getEdges(), "run" + runCount + "_collapsedEdges"); }
private List createSubgraphs(PlanarGraph graph) { List subgraphList = new ArrayList(); for (Iterator i = graph.getNodes().iterator(); i.hasNext(); ) { Node node = (Node) i.next(); if (!node.isVisited()) { BufferSubgraph subgraph = new BufferSubgraph(); subgraph.create(node); subgraphList.add(subgraph); } } /** * Sort the subgraphs in descending order of their rightmost coordinate. This ensures that when * the Polygons for the subgraphs are built, subgraphs for shells will have been built before * the subgraphs for any holes they contain. */ Collections.sort(subgraphList, Collections.reverseOrder()); return subgraphList; }
/** * Completes the building of the input subgraphs by depth-labelling them, and adds them to the * PolygonBuilder. The subgraph list must be sorted in rightmost-coordinate order. * * @param subgraphList the subgraphs to build * @param polyBuilder the PolygonBuilder which will build the final polygons */ private void buildSubgraphs(List subgraphList, PolygonBuilder polyBuilder) { List processedGraphs = new ArrayList(); for (Iterator i = subgraphList.iterator(); i.hasNext(); ) { BufferSubgraph subgraph = (BufferSubgraph) i.next(); Coordinate p = subgraph.getRightmostCoordinate(); // int outsideDepth = 0; // if (polyBuilder.containsPoint(p)) // outsideDepth = 1; SubgraphDepthLocater locater = new SubgraphDepthLocater(processedGraphs); int outsideDepth = locater.getDepth(p); // try { subgraph.computeDepth(outsideDepth); // } // catch (RuntimeException ex) { // // debugging only // //subgraph.saveDirEdges(); // throw ex; // } subgraph.findResultEdges(); processedGraphs.add(subgraph); polyBuilder.add(subgraph.getDirectedEdges(), subgraph.getNodes()); } }