public Point getStartPoint() { if (isEmpty()) { return null; } return getPointN(0); }
public Coordinate getCoordinate() { if (isEmpty()) return null; return points.getCoordinate(0); }
public Point getEndPoint() { if (isEmpty()) { return null; } return getPointN(getNumPoints() - 1); }
protected Envelope computeEnvelopeInternal() { if (isEmpty()) { return new Envelope(); } return points.expandEnvelope(new Envelope()); }
/** * Converts a <code>LineString</code> to <LineString Text> format, then * appends it to the writer. * *@param lineString the <code>LineString</code> to process *@param writer the output writer to append to */ private void appendLineStringText(LineString lineString, int level, boolean doIndent, Writer writer) throws IOException { if (lineString.isEmpty()) { writer.write("EMPTY"); } else { if (doIndent) indent(level, writer); writer.write("("); for (int i = 0; i < lineString.getNumPoints(); i++) { if (i > 0) { writer.write(", "); if (coordsPerLine > 0 && i % coordsPerLine == 0) { indent(level + 1, writer); } } appendCoordinate(lineString.getCoordinateN(i), writer); } writer.write(")"); } }
public boolean isClosed() { if (isEmpty()) { return false; } return getCoordinateN(0).equals2D(getCoordinateN(getNumPoints() - 1)); }
public boolean isEmpty() { return lineString.isEmpty(); }
/** * 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); }
public Coordinate getCoordinate() { if (isEmpty()) return null; return points.getCoordinate(0); }
public Point getStartPoint() { if (isEmpty()) { return null; } return getPointN(0); }
public Point getEndPoint() { if (isEmpty()) { return null; } return getPointN(getNumPoints() - 1); }
/** * Filters linear geometries. * * geom a geometry of any type */ public void filter(Geometry geom) { if (geom instanceof LineString) { LineString line = (LineString) geom; // skip empty geometries if (line.isEmpty()) return; int minSize = ((LineString) line).isClosed() ? 4 : 2; TaggedLineString taggedLine = new TaggedLineString((LineString) line, minSize); linestringMap.put(line, taggedLine); } } }
protected Envelope computeEnvelopeInternal() { if (isEmpty()) { return new Envelope(); } return points.expandEnvelope(new Envelope()); }
private LineString validateRing(LineString ring) { if (ring == null || ring.isEmpty() || ring.getLength() == 0) { return null; } GeometryFactory factory = ring.getFactory(); if (!ring.isClosed()) { List<Coordinate> sources = Arrays.asList(ring.getCoordinates()); List<Coordinate> coordList = new ArrayList<Coordinate>(sources); coordList.add(coordList.get(0)); ring = factory.createLineString(coordList.toArray(new Coordinate[0])); } return factory.createLinearRing(ring.getCoordinateSequence()); }
@Override public double[][] createCoordinates(LineString lineString) throws MarshallException { if (lineString == null) { return null; } else if (lineString.isEmpty()) { return new double[0][0]; } else { int numberOfPoints = lineString.getNumPoints(); double[][] coordinates = new double[numberOfPoints][]; for (int index = 0; index < numberOfPoints; index++) { coordinates[index] = pointConverter.createCoordinates(lineString.getPointN(index)); } return coordinates; } }
public boolean isClosed() { if (isEmpty()) { return false; } return getCoordinateN(0).equals2D(getCoordinateN(getNumPoints() - 1)); }
/** * 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); }