当前位置: 首页>>代码示例>>Java>>正文


Java CoordinateList.addAll方法代码示例

本文整理汇总了Java中com.vividsolutions.jts.geom.CoordinateList.addAll方法的典型用法代码示例。如果您正苦于以下问题:Java CoordinateList.addAll方法的具体用法?Java CoordinateList.addAll怎么用?Java CoordinateList.addAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.vividsolutions.jts.geom.CoordinateList的用法示例。


在下文中一共展示了CoordinateList.addAll方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getVoronoiCellPolygon

import com.vividsolutions.jts.geom.CoordinateList; //导入方法依赖的package包/类
/**
     * Gets the Voronoi cell around a site specified
     * by the origin of a QuadEdge.
     * <p>
     * The userData of the polygon is set to be the {@link Coordinate}
     * of the site.  This allows attaching external
     * data associated with the site to this cell polygon.
     *
     * @param qe a quadedge originating at the cell site
     * @param geomFact a factory for building the polygon
     * @return a polygon indicating the cell extent
     */
    public Polygon getVoronoiCellPolygon(QuadEdge qe, GeometryFactory geomFact) {
        List cellPts = new ArrayList();
        QuadEdge startQE = qe;
        do {
//    	Coordinate cc = circumcentre(qe);
            // use previously computed circumcentre
            Coordinate cc = qe.rot().orig().getCoordinate();
            cellPts.add(cc);

            // move to next triangle CW around vertex
            qe = qe.oPrev();
        } while (qe != startQE);

        CoordinateList coordList = new CoordinateList();
        coordList.addAll(cellPts, false);
        coordList.closeRing();

        if (coordList.size() < 4) {
            System.out.println(coordList);
            coordList.add(coordList.get(coordList.size() - 1), true);
        }

        Coordinate[] pts = coordList.toCoordinateArray();
        Polygon cellPoly = geomFact.createPolygon(geomFact.createLinearRing(pts), null);

        Vertex v = startQE.orig();
        cellPoly.setUserData(v.getCoordinate());
        return cellPoly;
    }
 
开发者ID:gegy1000,项目名称:Earth,代码行数:42,代码来源:QuadEdgeSubdivision.java

示例2: computeLine

import com.vividsolutions.jts.geom.CoordinateList; //导入方法依赖的package包/类
/**
 * Assumes input is valid (e.g. start <= end)
 *
 * @param start
 * @param end
 * @return a linear geometry
 */
private LineString computeLine(LinearLocation start, LinearLocation end) {
    Coordinate[] coordinates = this.line.getCoordinates();
    CoordinateList newCoordinates = new CoordinateList();

    int startSegmentIndex = start.getSegmentIndex();
    if (start.getSegmentFraction() > 0.0) {
        startSegmentIndex += 1;
    }
    int lastSegmentIndex = end.getSegmentIndex();
    if (end.getSegmentFraction() == 1.0) {
        lastSegmentIndex += 1;
    }
    if (lastSegmentIndex >= coordinates.length) {
        lastSegmentIndex = coordinates.length - 1;
    }
    // not needed - LinearLocation values should always be correct
    //Assert.isTrue(end.getSegmentFraction() <= 1.0, "invalid segment fraction value");

    if (!start.isVertex()) {
        newCoordinates.add(start.getCoordinate(this.line));
    }
    newCoordinates.addAll(Arrays.asList(coordinates).subList(startSegmentIndex, lastSegmentIndex + 1));
    if (!end.isVertex()) {
        newCoordinates.add(end.getCoordinate(this.line));
    }

    // ensure there is at least one coordinate in the result
    if (newCoordinates.size() <= 0) {
        newCoordinates.add(start.getCoordinate(this.line));
    }

    Coordinate[] newCoordinateArray = newCoordinates.toCoordinateArray();
    /**
     * Ensure there is enough coordinates to build a valid line.
     * Make a 2-point line with duplicate coordinates, if necessary.
     * There will always be at least one coordinate in the coordList.
     */
    if (newCoordinateArray.length <= 1) {
        newCoordinateArray = new Coordinate[] { newCoordinateArray[0], newCoordinateArray[0] };
    }
    return this.line.getFactory().createLineString(newCoordinateArray);
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:50,代码来源:ExtractLineByLocation.java


注:本文中的com.vividsolutions.jts.geom.CoordinateList.addAll方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。