当前位置: 首页>>代码示例>>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;未经允许,请勿转载。