private Coordinate[] scale(Coordinate[] pts) { Coordinate[] roundPts = new Coordinate[pts.length]; for (int i = 0; i < pts.length; i++) { roundPts[i] = new Coordinate( Math.round((pts[i].x - offsetX) * scaleFactor), Math.round((pts[i].y - offsetY) * scaleFactor), pts[i].getZ() ); } Coordinate[] roundPtsNoDup = CoordinateArrays.removeRepeatedPoints(roundPts); return roundPtsNoDup; }
public static void createSegments(final LineString geom, final List<LineString> result) throws SQLException { Coordinate[] coords = CoordinateArrays.removeRepeatedPoints(geom.getCoordinates()); for (int j = 0; j < coords.length - 1; j++) { LineString lineString = GEOMETRY_FACTORY.createLineString( new Coordinate[]{coords[j], coords[j + 1]}); result.add(lineString); } }
private void addLineString(LineString line) { // a zero or negative width buffer of a line/point is empty if (distance <= 0.0 && ! curveBuilder.getBufferParameters().isSingleSided()) return; Coordinate[] coord = CoordinateArrays.removeRepeatedPoints(line.getCoordinates()); Coordinate[] curve = curveBuilder.getLineCurve(coord, distance); addCurve(curve, Location.EXTERIOR, Location.INTERIOR); // TESTING //Coordinate[] curveTrim = BufferCurveLoopPruner.prune(curve); //addCurve(curveTrim, Location.EXTERIOR, Location.INTERIOR); }
private void addLineString(LineString line) { Coordinate[] coord = CoordinateArrays.removeRepeatedPoints(line.getCoordinates()); if (coord.length < 2) { hasTooFewPoints = true; invalidPoint = coord[0]; return; } // add the edge for the LineString // line edges do not have locations for their left and right sides Edge e = new Edge(coord, new Label(argIndex, Location.INTERIOR)); lineEdgeMap.put(line, e); insertEdge(e); /** * Add the boundary points of the LineString, if any. * Even if the LineString is closed, add both points as if they were endpoints. * This allows for the case that the node already exists and is a boundary point. */ Assert.isTrue(coord.length >= 2, "found LineString with single point"); insertBoundaryPoint(argIndex, coord[0]); insertBoundaryPoint(argIndex, coord[coord.length - 1]); }
Coordinate[] shellCoord = CoordinateArrays.removeRepeatedPoints(shell.getCoordinates()); Coordinate[] holeCoord = CoordinateArrays.removeRepeatedPoints(hole.getCoordinates());
Coordinate[] coord = CoordinateArrays.removeRepeatedPoints(lr.getCoordinates());
/** * Add a {@link LineString} forming an edge of the polygon graph. * @param line the line to add */ public void addEdge(LineString line) { if (line.isEmpty()) { return; } Coordinate[] linePts = CoordinateArrays.removeRepeatedPoints(line.getCoordinates()); if (linePts.length < 2) { return; } Coordinate startPt = linePts[0]; Coordinate endPt = linePts[linePts.length - 1]; Node nStart = getNode(startPt); Node nEnd = getNode(endPt); DirectedEdge de0 = new PolygonizeDirectedEdge(nStart, nEnd, linePts[1], true); DirectedEdge de1 = new PolygonizeDirectedEdge(nEnd, nStart, linePts[linePts.length - 2], false); Edge edge = new PolygonizeEdge(line); edge.setDirectedEdges(de0, de1); add(edge); }
/** * Adds an Edge, DirectedEdges, and Nodes for the given LineString representation * of an edge. * Empty lines or lines with all coordinates equal are not added. * * @param lineString the linestring to add to the graph */ public void addEdge(LineString lineString) { if (lineString.isEmpty()) { return; } Coordinate[] coordinates = CoordinateArrays.removeRepeatedPoints(lineString.getCoordinates()); // don't add lines with all coordinates equal if (coordinates.length <= 1) return; Coordinate startCoordinate = coordinates[0]; Coordinate endCoordinate = coordinates[coordinates.length - 1]; Node startNode = getNode(startCoordinate); Node endNode = getNode(endCoordinate); DirectedEdge directedEdge0 = new LineMergeDirectedEdge(startNode, endNode, coordinates[1], true); DirectedEdge directedEdge1 = new LineMergeDirectedEdge(endNode, startNode, coordinates[coordinates.length - 2], false); Edge edge = new LineMergeEdge(lineString); edge.setDirectedEdges(directedEdge0, directedEdge1); add(edge); }