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


Java CoordinateList.size方法代码示例

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


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

示例1: snapVertices

import com.vividsolutions.jts.geom.CoordinateList; //导入方法依赖的package包/类
/**
 * Snap source vertices to vertices in the target.
 *
 * @param srcCoords the points to snap
 * @param snapPts the points to snap to
 */
private void snapVertices(CoordinateList srcCoords, Coordinate[] snapPts) {
    // try snapping vertices
    // if src is a ring then don't snap final vertex
    int end = this.isClosed ? srcCoords.size() - 1 : srcCoords.size();
    for (int i = 0; i < end; i++) {
        Coordinate srcPt = (Coordinate) srcCoords.get(i);
        Coordinate snapVert = this.findSnapForVertex(srcPt, snapPts);
        if (snapVert != null) {
            // update src with snap pt
            srcCoords.set(i, new Coordinate(snapVert));
            // keep final closing point in synch (rings only)
            if (i == 0 && this.isClosed) {
                srcCoords.set(srcCoords.size() - 1, new Coordinate(snapVert));
            }
        }
    }
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:24,代码来源:LineStringSnapper.java

示例2: snapVertices

import com.vividsolutions.jts.geom.CoordinateList; //导入方法依赖的package包/类
/**
 * Snap source vertices to vertices in the target.
 *
 * @param srcCoords the points to snap
 * @param snapPts   the points to snap to
 */
private void snapVertices(CoordinateList srcCoords, Coordinate[] snapPts) {
    // try snapping vertices
    // if src is a ring then don't snap final vertex
    int end = isClosed ? srcCoords.size() - 1 : srcCoords.size();
    for (int i = 0; i < end; i++) {
        Coordinate srcPt = (Coordinate) srcCoords.get(i);
        Coordinate snapVert = findSnapForVertex(srcPt, snapPts);
        if (snapVert != null) {
            // update src with snap pt
            srcCoords.set(i, new Coordinate(snapVert));
            // keep final closing point in synch (rings only)
            if (i == 0 && isClosed)
                srcCoords.set(srcCoords.size() - 1, new Coordinate(snapVert));
        }
    }
}
 
开发者ID:Semantive,项目名称:jts,代码行数:23,代码来源:LineStringSnapper.java

示例3: findSegmentIndexToSnap

import com.vividsolutions.jts.geom.CoordinateList; //导入方法依赖的package包/类
/**
 * Finds a src segment which snaps to (is close to) the given snap point.
 * <p>
 * Only a single segment is selected for snapping.
 * This prevents multiple segments snapping to the same snap vertex,
 * which would almost certainly cause invalid geometry
 * to be created.
 * (The heuristic approach to snapping used here
 * is really only appropriate when
 * snap pts snap to a unique spot on the src geometry.)
 * <p>
 * Also, if the snap vertex occurs as a vertex in the src coordinate list,
 * no snapping is performed.
 *
 * @param snapPt the point to snap to
 * @param srcCoords the source segment coordinates
 * @return the index of the snapped segment
 * or -1 if no segment snaps to the snap point
 */
private int findSegmentIndexToSnap(Coordinate snapPt, CoordinateList srcCoords) {
    double minDist = Double.MAX_VALUE;
    int snapIndex = -1;
    for (int i = 0; i < srcCoords.size() - 1; i++) {
        this.seg.p0 = (Coordinate) srcCoords.get(i);
        this.seg.p1 = (Coordinate) srcCoords.get(i + 1);

        /**
         * Check if the snap pt is equal to one of the segment endpoints.
         *
         * If the snap pt is already in the src list, don't snap at all.
         */
        if (this.seg.p0.equals2D(snapPt) || this.seg.p1.equals2D(snapPt)) {
            if (this.allowSnappingToSourceVertices) {
                continue;
            } else {
                return -1;
            }
        }

        double dist = this.seg.distance(snapPt);
        if (dist < this.snapTolerance && dist < minDist) {
            minDist = dist;
            snapIndex = i;
        }
    }
    return snapIndex;
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:48,代码来源:LineStringSnapper.java

示例4: 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

示例5: computeOctRing

import com.vividsolutions.jts.geom.CoordinateList; //导入方法依赖的package包/类
private Coordinate[] computeOctRing(Coordinate[] inputPts) {
    Coordinate[] octPts = this.computeOctPts(inputPts);
    CoordinateList coordList = new CoordinateList();
    coordList.add(octPts, false);

    // points must all lie in a line
    if (coordList.size() < 3) {
        return null;
    }
    coordList.closeRing();
    return coordList.toCoordinateArray();
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:13,代码来源:ConvexHull.java

示例6: findSegmentIndexToSnap

import com.vividsolutions.jts.geom.CoordinateList; //导入方法依赖的package包/类
/**
 * Finds a src segment which snaps to (is close to) the given snap point.
 * <p/>
 * Only a single segment is selected for snapping.
 * This prevents multiple segments snapping to the same snap vertex,
 * which would almost certainly cause invalid geometry
 * to be created.
 * (The heuristic approach to snapping used here
 * is really only appropriate when
 * snap pts snap to a unique spot on the src geometry.)
 * <p/>
 * Also, if the snap vertex occurs as a vertex in the src coordinate list,
 * no snapping is performed.
 *
 * @param snapPt    the point to snap to
 * @param srcCoords the source segment coordinates
 * @return the index of the snapped segment
 * or -1 if no segment snaps to the snap point
 */
private int findSegmentIndexToSnap(Coordinate snapPt, CoordinateList srcCoords) {
    double minDist = Double.MAX_VALUE;
    int snapIndex = -1;
    for (int i = 0; i < srcCoords.size() - 1; i++) {
        seg.p0 = (Coordinate) srcCoords.get(i);
        seg.p1 = (Coordinate) srcCoords.get(i + 1);

        /**
         * Check if the snap pt is equal to one of the segment endpoints.
         *
         * If the snap pt is already in the src list, don't snap at all.
         */
        if (seg.p0.equals2D(snapPt) || seg.p1.equals2D(snapPt)) {
            if (allowSnappingToSourceVertices)
                continue;
            else
                return -1;
        }

        double dist = seg.distance(snapPt);
        if (dist < snapTolerance && dist < minDist) {
            minDist = dist;
            snapIndex = i;
        }
    }
    return snapIndex;
}
 
开发者ID:Semantive,项目名称:jts,代码行数:47,代码来源:LineStringSnapper.java

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