當前位置: 首頁>>代碼示例>>Java>>正文


Java LineString.isEmpty方法代碼示例

本文整理匯總了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);
}
 
開發者ID:gegy1000,項目名稱:Earth,代碼行數:28,代碼來源:PolygonizeGraph.java

示例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);
}
 
開發者ID:gegy1000,項目名稱:Earth,代碼行數:32,代碼來源:LineMergeGraph.java

示例3: appendLineStringText

import com.vividsolutions.jts.geom.LineString; //導入方法依賴的package包/類
/**
 * Converts a <code>LineString</code> to &lt;LineString Text&gt; 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(")");
    }
}
 
開發者ID:gegy1000,項目名稱:Earth,代碼行數:30,代碼來源:WKTWriter.java

示例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()]));
}
 
開發者ID:GIScience,項目名稱:openrouteservice,代碼行數:35,代碼來源:JTS.java


注:本文中的com.vividsolutions.jts.geom.LineString.isEmpty方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。