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


Java CGAlgorithms类代码示例

本文整理汇总了Java中com.vividsolutions.jts.algorithm.CGAlgorithms的典型用法代码示例。如果您正苦于以下问题:Java CGAlgorithms类的具体用法?Java CGAlgorithms怎么用?Java CGAlgorithms使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: ensureOrientation

import com.vividsolutions.jts.algorithm.CGAlgorithms; //导入依赖的package包/类
public Coordinate[] ensureOrientation(
		final int desiredOrientation, final Coordinate... coord) {
	if (coord.length == 0) {
		return coord;
	}

	final int orientation = CGAlgorithms.isCCW(coord) ? CGAlgorithms.COUNTERCLOCKWISE
			: CGAlgorithms.CLOCKWISE;

	if (orientation != desiredOrientation) {
		final Coordinate[] reverse = (Coordinate[]) coord.clone();
		reverse(reverse);

		return reverse;
	}

	return coord;
}
 
开发者ID:geowe,项目名称:sig-seguimiento-vehiculos,代码行数:19,代码来源:CoordinateUtil.java

示例2: checkShellInsideHole

import com.vividsolutions.jts.algorithm.CGAlgorithms; //导入依赖的package包/类
/**
 * This routine checks to see if a shell is properly contained in a hole.
 * It assumes that the edges of the shell and hole do not
 * properly intersect.
 *
 * @return <code>null</code> if the shell is properly contained, or
 * a Coordinate which is not inside the hole if it is not
 */
private Coordinate checkShellInsideHole(LinearRing shell, LinearRing hole, GeometryGraph graph) {
    Coordinate[] shellPts = shell.getCoordinates();
    Coordinate[] holePts = hole.getCoordinates();
    // TODO: improve performance of this - by sorting pointlists for instance?
    Coordinate shellPt = findPtNotNode(shellPts, hole, graph);
    // if point is on shell but not hole, check that the shell is inside the hole
    if (shellPt != null) {
        boolean insideHole = CGAlgorithms.isPointInRing(shellPt, holePts);
        if (!insideHole) {
            return shellPt;
        }
    }
    Coordinate holePt = findPtNotNode(holePts, shell, graph);
    // if point is on hole but not shell, check that the hole is outside the shell
    if (holePt != null) {
        boolean insideShell = CGAlgorithms.isPointInRing(holePt, shellPts);
        if (insideShell) {
            return holePt;
        }
        return null;
    }
    Assert.shouldNeverReachHere("points in shell and hole appear to be equal");
    return null;
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:33,代码来源:IsValidOp.java

示例3: findRightmostEdgeAtVertex

import com.vividsolutions.jts.algorithm.CGAlgorithms; //导入依赖的package包/类
private void findRightmostEdgeAtVertex() {
    /**
     * The rightmost point is an interior vertex, so it has a segment on either side of it.
     * If these segments are both above or below the rightmost point, we need to
     * determine their relative orientation to decide which is rightmost.
     */
    Coordinate[] pts = this.minDe.getEdge().getCoordinates();
    Assert.isTrue(this.minIndex > 0 && this.minIndex < pts.length, "rightmost point expected to be interior vertex of edge");
    Coordinate pPrev = pts[this.minIndex - 1];
    Coordinate pNext = pts[this.minIndex + 1];
    int orientation = CGAlgorithms.computeOrientation(this.minCoord, pNext, pPrev);
    boolean usePrev = false;
    // both segments are below min point
    if (pPrev.y < this.minCoord.y && pNext.y < this.minCoord.y
            && orientation == CGAlgorithms.COUNTERCLOCKWISE) {
        usePrev = true;
    } else if (pPrev.y > this.minCoord.y && pNext.y > this.minCoord.y
            && orientation == CGAlgorithms.CLOCKWISE) {
        usePrev = true;
    }
    // if both segments are on the same side, do nothing - either is safe
    // to select as a rightmost segment
    if (usePrev) {
        this.minIndex = this.minIndex - 1;
    }
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:27,代码来源:RightmostEdgeFinder.java

示例4: simplify

import com.vividsolutions.jts.algorithm.CGAlgorithms; //导入依赖的package包/类
/**
 * Simplify the input coordinate list.
 * If the distance tolerance is positive,
 * concavities on the LEFT side of the line are simplified.
 * If the supplied distance tolerance is negative,
 * concavities on the RIGHT side of the line are simplified.
 *
 * @param distanceTol simplification distance tolerance to use
 * @return the simplified coordinate list
 */
public Coordinate[] simplify(double distanceTol) {
    this.distanceTol = Math.abs(distanceTol);
    if (distanceTol < 0) {
        this.angleOrientation = CGAlgorithms.CLOCKWISE;
    }

    // rely on fact that boolean array is filled with false value
    this.isDeleted = new byte[this.inputLine.length];

    boolean isChanged;
    do {
        isChanged = this.deleteShallowConcavities();
    } while (isChanged);

    return this.collapseLine();
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:27,代码来源:BufferInputLineSimplifier.java

示例5: addPolygonRing

import com.vividsolutions.jts.algorithm.CGAlgorithms; //导入依赖的package包/类
/**
 * Adds an offset curve for a polygon ring.
 * The side and left and right topological location arguments
 * assume that the ring is oriented CW.
 * If the ring is in the opposite orientation,
 * the left and right locations must be interchanged and the side flipped.
 *
 * @param coord the coordinates of the ring (must not contain repeated points)
 * @param offsetDistance the distance at which to create the buffer
 * @param side the side of the ring on which to construct the buffer line
 * @param cwLeftLoc the location on the L side of the ring (if it is CW)
 * @param cwRightLoc the location on the R side of the ring (if it is CW)
 */
private void addPolygonRing(Coordinate[] coord, double offsetDistance, int side, int cwLeftLoc, int cwRightLoc) {
    // don't bother adding ring if it is "flat" and will disappear in the output
    if (offsetDistance == 0.0 && coord.length < LinearRing.MINIMUM_VALID_SIZE) {
        return;
    }

    int leftLoc = cwLeftLoc;
    int rightLoc = cwRightLoc;
    if (coord.length >= LinearRing.MINIMUM_VALID_SIZE
            && CGAlgorithms.isCCW(coord)) {
        leftLoc = cwRightLoc;
        rightLoc = cwLeftLoc;
        side = Position.opposite(side);
    }
    Coordinate[] curve = this.curveBuilder.getRingCurve(coord, side, offsetDistance);
    this.addCurve(curve, leftLoc, rightLoc);
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:31,代码来源:OffsetCurveSetBuilder.java

示例6: addFillet

import com.vividsolutions.jts.algorithm.CGAlgorithms; //导入依赖的package包/类
/**
 * Add points for a circular fillet around a reflex corner.
 * Adds the start and end points
 *
 * @param p base point of curve
 * @param p0 start point of fillet curve
 * @param p1 endpoint of fillet curve
 * @param direction the orientation of the fillet
 * @param radius the radius of the fillet
 */
private void addFillet(Coordinate p, Coordinate p0, Coordinate p1, int direction, double radius) {
    double dx0 = p0.x - p.x;
    double dy0 = p0.y - p.y;
    double startAngle = Math.atan2(dy0, dx0);
    double dx1 = p1.x - p.x;
    double dy1 = p1.y - p.y;
    double endAngle = Math.atan2(dy1, dx1);

    if (direction == CGAlgorithms.CLOCKWISE) {
        if (startAngle <= endAngle) {
            startAngle += 2.0 * Math.PI;
        }
    } else {    // direction == COUNTERCLOCKWISE
        if (startAngle >= endAngle) {
            startAngle -= 2.0 * Math.PI;
        }
    }
    this.segList.addPt(p0);
    this.addFillet(p, startAngle, endAngle, direction, radius);
    this.segList.addPt(p1);
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:32,代码来源:OffsetSegmentGenerator.java

示例7: computeMinDistance

import com.vividsolutions.jts.algorithm.CGAlgorithms; //导入依赖的package包/类
private void computeMinDistance(LineString line, Point pt,
                                GeometryLocation[] locGeom) {
    if (line.getEnvelopeInternal().distance(pt.getEnvelopeInternal())
            > this.minDistance) {
        return;
    }
    Coordinate[] coord0 = line.getCoordinates();
    Coordinate coord = pt.getCoordinate();
    // brute force approach!
    for (int i = 0; i < coord0.length - 1; i++) {
        double dist = CGAlgorithms.distancePointLine(
                coord, coord0[i], coord0[i + 1]);
        if (dist < this.minDistance) {
            this.minDistance = dist;
            LineSegment seg = new LineSegment(coord0[i], coord0[i + 1]);
            Coordinate segClosestPoint = seg.closestPoint(coord);
            locGeom[0] = new GeometryLocation(line, i, segClosestPoint);
            locGeom[1] = new GeometryLocation(pt, 0, coord);
        }
        if (this.minDistance <= this.terminateDistance) {
            return;
        }
    }
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:25,代码来源:DistanceOp.java

示例8: computeLineLineDistance

import com.vividsolutions.jts.algorithm.CGAlgorithms; //导入依赖的package包/类
private double computeLineLineDistance(FacetSequence facetSeq) {
    // both linear - compute minimum segment-segment distance
    double minDistance = Double.MAX_VALUE;

    for (int i = this.start; i < this.end - 1; i++) {
        for (int j = facetSeq.start; j < facetSeq.end - 1; j++) {
            this.pts.getCoordinate(i, this.p0);
            this.pts.getCoordinate(i + 1, this.p1);
            facetSeq.pts.getCoordinate(j, this.q0);
            facetSeq.pts.getCoordinate(j + 1, this.q1);

            double dist = CGAlgorithms.distanceLineLine(this.p0, this.p1, this.q0, this.q1);
            if (dist == 0.0) {
                return 0.0;
            }
            if (dist < minDistance) {
                minDistance = dist;
            }
        }
    }
    return minDistance;
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:23,代码来源:FacetSequence.java

示例9: computePointLineDistance

import com.vividsolutions.jts.algorithm.CGAlgorithms; //导入依赖的package包/类
private double computePointLineDistance(Coordinate pt, FacetSequence facetSeq) {
    double minDistance = Double.MAX_VALUE;

    for (int i = facetSeq.start; i < facetSeq.end - 1; i++) {
        facetSeq.pts.getCoordinate(i, this.q0);
        facetSeq.pts.getCoordinate(i + 1, this.q1);
        double dist = CGAlgorithms.distancePointLine(pt, this.q0, this.q1);
        if (dist == 0.0) {
            return 0.0;
        }
        if (dist < minDistance) {
            minDistance = dist;
        }
    }
    return minDistance;
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:17,代码来源:FacetSequence.java

示例10: segmentDistance

import com.vividsolutions.jts.algorithm.CGAlgorithms; //导入依赖的package包/类
private double segmentDistance(FacetSequence fs1, FacetSequence fs2) {
    for (int i1 = 0; i1 < fs1.size(); i1++) {
        for (int i2 = 1; i2 < fs2.size(); i2++) {

            Coordinate p = fs1.getCoordinate(i1);

            Coordinate seg0 = fs2.getCoordinate(i2 - 1);
            Coordinate seg1 = fs2.getCoordinate(i2);

            if (!(p.equals2D(seg0) || p.equals2D(seg1))) {
                double d = CGAlgorithms.distancePointLine(p, seg0, seg1);
                if (d < this.minDist) {
                    this.minDist = d;
                    this.updatePts(p, seg0, seg1);
                    if (d == 0.0) {
                        return d;
                    }
                }
            }
        }
    }
    return this.minDist;
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:24,代码来源:MinimumClearance.java

示例11: containsPoint

import com.vividsolutions.jts.algorithm.CGAlgorithms; //导入依赖的package包/类
/**
 * This method will cause the ring to be computed.
 * It will also check any holes, if they have been assigned.
 */
public boolean containsPoint(Coordinate p) {
    LinearRing shell = this.getLinearRing();
    Envelope env = shell.getEnvelopeInternal();
    if (!env.contains(p)) {
        return false;
    }
    if (!CGAlgorithms.isPointInRing(p, shell.getCoordinates())) {
        return false;
    }

    for (Object hole1 : holes) {
        EdgeRing hole = (EdgeRing) hole1;
        if (hole.containsPoint(p)) {
            return false;
        }
    }
    return true;
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:23,代码来源:EdgeRing.java

示例12: compareDirection

import com.vividsolutions.jts.algorithm.CGAlgorithms; //导入依赖的package包/类
/**
 * Implements the total order relation:
 * <p>
 * a has a greater angle with the positive x-axis than b
 * <p>
 * Using the obvious algorithm of simply computing the angle is not robust,
 * since the angle calculation is obviously susceptible to roundoff.
 * A robust algorithm is:
 * - first compare the quadrant.  If the quadrants
 * are different, it it trivial to determine which vector is "greater".
 * - if the vectors lie in the same quadrant, the computeOrientation function
 * can be used to decide the relative orientation of the vectors.
 */
public int compareDirection(EdgeEnd e) {
    if (this.dx == e.dx && this.dy == e.dy) {
        return 0;
    }
    // if the rays are in different quadrants, determining the ordering is trivial
    if (this.quadrant > e.quadrant) {
        return 1;
    }
    if (this.quadrant < e.quadrant) {
        return -1;
    }
    // vectors are in the same quadrant - check relative orientation of direction vectors
    // this is > e if it is CCW of e
    return CGAlgorithms.computeOrientation(e.p0, e.p1, this.p1);
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:29,代码来源:EdgeEnd.java

示例13: findRightmostEdgeAtVertex

import com.vividsolutions.jts.algorithm.CGAlgorithms; //导入依赖的package包/类
private void findRightmostEdgeAtVertex() {
    /**
     * The rightmost point is an interior vertex, so it has a segment on either side of it.
     * If these segments are both above or below the rightmost point, we need to
     * determine their relative orientation to decide which is rightmost.
     */
    Coordinate[] pts = minDe.getEdge().getCoordinates();
    Assert.isTrue(minIndex > 0 && minIndex < pts.length, "rightmost point expected to be interior vertex of edge");
    Coordinate pPrev = pts[minIndex - 1];
    Coordinate pNext = pts[minIndex + 1];
    int orientation = CGAlgorithms.computeOrientation(minCoord, pNext, pPrev);
    boolean usePrev = false;
    // both segments are below min point
    if (pPrev.y < minCoord.y && pNext.y < minCoord.y
            && orientation == CGAlgorithms.COUNTERCLOCKWISE) {
        usePrev = true;
    } else if (pPrev.y > minCoord.y && pNext.y > minCoord.y
            && orientation == CGAlgorithms.CLOCKWISE) {
        usePrev = true;
    }
    // if both segments are on the same side, do nothing - either is safe
    // to select as a rightmost segment
    if (usePrev) {
        minIndex = minIndex - 1;
    }
}
 
开发者ID:Semantive,项目名称:jts,代码行数:27,代码来源:RightmostEdgeFinder.java

示例14: simplify

import com.vividsolutions.jts.algorithm.CGAlgorithms; //导入依赖的package包/类
/**
 * Simplify the input coordinate list.
 * If the distance tolerance is positive,
 * concavities on the LEFT side of the line are simplified.
 * If the supplied distance tolerance is negative,
 * concavities on the RIGHT side of the line are simplified.
 *
 * @param distanceTol simplification distance tolerance to use
 * @return the simplified coordinate list
 */
public Coordinate[] simplify(double distanceTol) {
    this.distanceTol = Math.abs(distanceTol);
    if (distanceTol < 0)
        angleOrientation = CGAlgorithms.CLOCKWISE;

    // rely on fact that boolean array is filled with false value
    isDeleted = new byte[inputLine.length];

    boolean isChanged = false;
    do {
        isChanged = deleteShallowConcavities();
    } while (isChanged);

    return collapseLine();
}
 
开发者ID:Semantive,项目名称:jts,代码行数:26,代码来源:BufferInputLineSimplifier.java

示例15: addPolygonRing

import com.vividsolutions.jts.algorithm.CGAlgorithms; //导入依赖的package包/类
/**
 * Adds an offset curve for a polygon ring.
 * The side and left and right topological location arguments
 * assume that the ring is oriented CW.
 * If the ring is in the opposite orientation,
 * the left and right locations must be interchanged and the side flipped.
 *
 * @param coord          the coordinates of the ring (must not contain repeated points)
 * @param offsetDistance the distance at which to create the buffer
 * @param side           the side of the ring on which to construct the buffer line
 * @param cwLeftLoc      the location on the L side of the ring (if it is CW)
 * @param cwRightLoc     the location on the R side of the ring (if it is CW)
 */
private void addPolygonRing(Coordinate[] coord, double offsetDistance, int side, int cwLeftLoc, int cwRightLoc) {
    // don't bother adding ring if it is "flat" and will disappear in the output
    if (offsetDistance == 0.0 && coord.length < LinearRing.MINIMUM_VALID_SIZE)
        return;

    int leftLoc = cwLeftLoc;
    int rightLoc = cwRightLoc;
    if (coord.length >= LinearRing.MINIMUM_VALID_SIZE
            && CGAlgorithms.isCCW(coord)) {
        leftLoc = cwRightLoc;
        rightLoc = cwLeftLoc;
        side = Position.opposite(side);
    }
    Coordinate[] curve = curveBuilder.getRingCurve(coord, side, offsetDistance);
    addCurve(curve, leftLoc, rightLoc);
}
 
开发者ID:Semantive,项目名称:jts,代码行数:30,代码来源:OffsetCurveSetBuilder.java


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