本文整理汇总了Java中com.vividsolutions.jts.geom.LineString.isEmpty方法的典型用法代码示例。如果您正苦于以下问题:Java LineString.isEmpty方法的具体用法?Java LineString.isEmpty怎么用?Java LineString.isEmpty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.vividsolutions.jts.geom.LineString
的用法示例。
在下文中一共展示了LineString.isEmpty方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addEdge
import com.vividsolutions.jts.geom.LineString; //导入方法依赖的package包/类
/**
* 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 = this.getNode(startPt);
Node nEnd = this.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);
this.add(edge);
}
示例2: addEdge
import com.vividsolutions.jts.geom.LineString; //导入方法依赖的package包/类
/**
* 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 = this.getNode(startCoordinate);
Node endNode = this.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);
this.add(edge);
}
示例3: appendLineStringText
import com.vividsolutions.jts.geom.LineString; //导入方法依赖的package包/类
/**
* 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) {
this.indent(level, writer);
}
writer.write("(");
for (int i = 0; i < lineString.getNumPoints(); i++) {
if (i > 0) {
writer.write(", ");
if (this.coordsPerLine > 0
&& i % this.coordsPerLine == 0) {
this.indent(level + 1, writer);
}
}
this.appendCoordinate(lineString.getCoordinateN(i), writer);
}
writer.write(")");
}
}
示例4: removeCollinearVertices
import com.vividsolutions.jts.geom.LineString; //导入方法依赖的package包/类
/**
* Removes collinear vertices from the provided {@link Polygon}.
*
* @param polygon the instance of a {@link Polygon} to remove collinear vertices from.
* @return a new instance of the provided {@link Polygon} without collinear vertices.
*/
static Polygon removeCollinearVertices(final Polygon polygon) {
if (polygon == null) {
throw new NullPointerException("The provided Polygon is null");
}
// reuse existing factory
final GeometryFactory gf = polygon.getFactory();
// work on the exterior ring
LineString exterior = polygon.getExteriorRing();
LineString shell = removeCollinearVertices(exterior);
if ((shell == null) || shell.isEmpty()) {
return null;
}
// work on the holes
List<LineString> holes = new ArrayList<LineString>();
final int size = polygon.getNumInteriorRing();
for (int i = 0; i < size; i++) {
LineString hole = polygon.getInteriorRingN(i);
hole = removeCollinearVertices(hole);
if ((hole != null) && !hole.isEmpty()) {
holes.add(hole);
}
}
return gf.createPolygon((LinearRing) shell, holes.toArray(new LinearRing[holes.size()]));
}