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


Java CGAlgorithms.computeOrientation方法代码示例

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


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

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

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

示例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 = 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

示例4: isShallowConcavity

import com.vividsolutions.jts.algorithm.CGAlgorithms; //导入方法依赖的package包/类
private boolean isShallowConcavity(Coordinate p0, Coordinate p1, Coordinate p2, double distanceTol) {
    int orientation = CGAlgorithms.computeOrientation(p0, p1, p2);
    boolean isAngleToSimplify = (orientation == this.angleOrientation);
    if (!isAngleToSimplify) {
        return false;
    }

    double dist = CGAlgorithms.distancePointLine(p1, p0, p2);
    return dist < distanceTol;
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:11,代码来源:BufferInputLineSimplifier.java

示例5: addNextSegment

import com.vividsolutions.jts.algorithm.CGAlgorithms; //导入方法依赖的package包/类
public void addNextSegment(Coordinate p, boolean addStartPoint) {
    // s0-s1-s2 are the coordinates of the previous segment and the current one
    this.s0 = this.s1;
    this.s1 = this.s2;
    this.s2 = p;
    this.seg0.setCoordinates(this.s0, this.s1);
    this.computeOffsetSegment(this.seg0, this.side, this.distance, this.offset0);
    this.seg1.setCoordinates(this.s1, this.s2);
    this.computeOffsetSegment(this.seg1, this.side, this.distance, this.offset1);

    // do nothing if points are equal
    if (this.s1.equals(this.s2)) {
        return;
    }

    int orientation = CGAlgorithms.computeOrientation(this.s0, this.s1, this.s2);
    boolean outsideTurn =
            (orientation == CGAlgorithms.CLOCKWISE && this.side == Position.LEFT)
                    || (orientation == CGAlgorithms.COUNTERCLOCKWISE && this.side == Position.RIGHT);

    if (orientation == 0) { // lines are collinear
        this.addCollinear(addStartPoint);
    } else if (outsideTurn) {
        this.addOutsideTurn(orientation, addStartPoint);
    } else { // inside turn
        this.addInsideTurn(orientation, addStartPoint);
    }
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:29,代码来源:OffsetSegmentGenerator.java

示例6: matchInSameDirection

import com.vividsolutions.jts.algorithm.CGAlgorithms; //导入方法依赖的package包/类
/**
 * The coordinate pairs match if they define line segments lying in the same direction.
 * E.g. the segments are parallel and in the same quadrant
 * (as opposed to parallel and opposite!).
 */
private boolean matchInSameDirection(Coordinate p0, Coordinate p1, Coordinate ep0, Coordinate ep1) {
    if (!p0.equals(ep0)) {
        return false;
    }

    return CGAlgorithms.computeOrientation(p0, p1, ep1) == CGAlgorithms.COLLINEAR
            && Quadrant.quadrant(p0, p1) == Quadrant.quadrant(ep0, ep1);
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:14,代码来源:PlanarGraph.java

示例7: isShallowConcavity

import com.vividsolutions.jts.algorithm.CGAlgorithms; //导入方法依赖的package包/类
private boolean isShallowConcavity(Coordinate p0, Coordinate p1, Coordinate p2, double distanceTol) {
    int orientation = CGAlgorithms.computeOrientation(p0, p1, p2);
    boolean isAngleToSimplify = (orientation == angleOrientation);
    if (!isAngleToSimplify)
        return false;

    double dist = CGAlgorithms.distancePointLine(p1, p0, p2);
    return dist < distanceTol;
}
 
开发者ID:Semantive,项目名称:jts,代码行数:10,代码来源:BufferInputLineSimplifier.java

示例8: findStabbedSegments

import com.vividsolutions.jts.algorithm.CGAlgorithms; //导入方法依赖的package包/类
/**
 * Finds all non-horizontal segments intersecting the stabbing line
 * in the input dirEdge.
 * The stabbing line is the ray to the right of stabbingRayLeftPt.
 *
 * @param stabbingRayLeftPt the left-hand origin of the stabbing line
 * @param stabbedSegments   the current list of {@link DepthSegments} intersecting the stabbing line
 */
private void findStabbedSegments(Coordinate stabbingRayLeftPt,
                                 DirectedEdge dirEdge,
                                 List stabbedSegments) {
    Coordinate[] pts = dirEdge.getEdge().getCoordinates();
    for (int i = 0; i < pts.length - 1; i++) {
        seg.p0 = pts[i];
        seg.p1 = pts[i + 1];
        // ensure segment always points upwards
        if (seg.p0.y > seg.p1.y)
            seg.reverse();

        // skip segment if it is left of the stabbing line
        double maxx = Math.max(seg.p0.x, seg.p1.x);
        if (maxx < stabbingRayLeftPt.x)
            continue;

        // skip horizontal segments (there will be a non-horizontal one carrying the same depth info
        if (seg.isHorizontal())
            continue;

        // skip if segment is above or below stabbing line
        if (stabbingRayLeftPt.y < seg.p0.y || stabbingRayLeftPt.y > seg.p1.y)
            continue;

        // skip if stabbing ray is right of the segment
        if (CGAlgorithms.computeOrientation(seg.p0, seg.p1, stabbingRayLeftPt)
                == CGAlgorithms.RIGHT)
            continue;

        // stabbing line cuts this segment, so record it
        int depth = dirEdge.getDepth(Position.LEFT);
        // if segment direction was flipped, use RHS depth instead
        if (!seg.p0.equals(pts[i]))
            depth = dirEdge.getDepth(Position.RIGHT);
        DepthSegment ds = new DepthSegment(seg, depth);
        stabbedSegments.add(ds);
    }
}
 
开发者ID:Semantive,项目名称:jts,代码行数:47,代码来源:SubgraphDepthLocater.java

示例9: matchInSameDirection

import com.vividsolutions.jts.algorithm.CGAlgorithms; //导入方法依赖的package包/类
/**
 * The coordinate pairs match if they define line segments lying in the same direction.
 * E.g. the segments are parallel and in the same quadrant
 * (as opposed to parallel and opposite!).
 */
private boolean matchInSameDirection(Coordinate p0, Coordinate p1, Coordinate ep0, Coordinate ep1) {
    if (!p0.equals(ep0))
        return false;

    if (CGAlgorithms.computeOrientation(p0, p1, ep1) == CGAlgorithms.COLLINEAR
            && Quadrant.quadrant(p0, p1) == Quadrant.quadrant(ep0, ep1))
        return true;
    return false;
}
 
开发者ID:Semantive,项目名称:jts,代码行数:15,代码来源:PlanarGraph.java

示例10: isShallowConcavity

import com.vividsolutions.jts.algorithm.CGAlgorithms; //导入方法依赖的package包/类
private boolean isShallowConcavity(Coordinate p0, Coordinate p1, Coordinate p2, double distanceTol)
{
  int orientation = CGAlgorithms.computeOrientation(p0, p1, p2);
  boolean isAngleToSimplify = (orientation == angleOrientation);
  if (! isAngleToSimplify)
    return false;
  
  double dist = CGAlgorithms.distancePointLine(p1, p0, p2);
  return dist < distanceTol;
}
 
开发者ID:GitHubDroid,项目名称:geodroid_master_update,代码行数:11,代码来源:BufferInputLineSimplifier.java

示例11: addNextSegment

import com.vividsolutions.jts.algorithm.CGAlgorithms; //导入方法依赖的package包/类
public void addNextSegment(Coordinate p, boolean addStartPoint)
{
  // s0-s1-s2 are the coordinates of the previous segment and the current one
  s0 = s1;
  s1 = s2;
  s2 = p;
  seg0.setCoordinates(s0, s1);
  computeOffsetSegment(seg0, side, distance, offset0);
  seg1.setCoordinates(s1, s2);
  computeOffsetSegment(seg1, side, distance, offset1);

  // do nothing if points are equal
  if (s1.equals(s2)) return;

  int orientation = CGAlgorithms.computeOrientation(s0, s1, s2);
  boolean outsideTurn =
        (orientation == CGAlgorithms.CLOCKWISE        && side == Position.LEFT)
    ||  (orientation == CGAlgorithms.COUNTERCLOCKWISE && side == Position.RIGHT);

  if (orientation == 0) { // lines are collinear
    addCollinear(addStartPoint);
  }
  else if (outsideTurn) 
  {
    addOutsideTurn(orientation, addStartPoint);
  }
  else { // inside turn
    addInsideTurn(orientation, addStartPoint);
  }
}
 
开发者ID:GitHubDroid,项目名称:geodroid_master_update,代码行数:31,代码来源:OffsetSegmentGenerator.java

示例12: removeCollinearVertices

import com.vividsolutions.jts.algorithm.CGAlgorithms; //导入方法依赖的package包/类
/**
 * Removes collinear points from the provided linestring.
 * 
 * @param ls the {@link LineString} to be simplified.
 * @return a new version of the provided {@link LineString} with collinear points removed.
 */
static LineString removeCollinearVertices(final LineString ls) {
    if (ls == null) {
        throw new NullPointerException("The provided linestring is null");
    }

    final int N = ls.getNumPoints();
    final boolean isLinearRing = ls instanceof LinearRing;

    List<Coordinate> retain = new ArrayList<Coordinate>();
    retain.add(ls.getCoordinateN(0));

    int i0 = 0, i1 = 1, i2 = 2;
    Coordinate firstCoord = ls.getCoordinateN(i0);
    Coordinate midCoord;
    Coordinate lastCoord;
    while (i2 < N) {
        midCoord = ls.getCoordinateN(i1);
        lastCoord = ls.getCoordinateN(i2);

        final int orientation = CGAlgorithms
                .computeOrientation(firstCoord, midCoord, lastCoord);
        // Colllinearity test
        if (orientation != CGAlgorithms.COLLINEAR) {
            // add midcoord and change head
            retain.add(midCoord);
            i0 = i1;
            firstCoord = ls.getCoordinateN(i0);
        }
        i1++;
        i2++;
    }
    retain.add(ls.getCoordinateN(N - 1));

    //
    // Return value
    //
    final int size = retain.size();
    // nothing changed?
    if (size == N) {
        // free everything and return original
        retain.clear();

        return ls;
    }

    return isLinearRing ? ls.getFactory()
            .createLinearRing(retain.toArray(new Coordinate[size])) : ls.getFactory()
            .createLineString(retain.toArray(new Coordinate[size]));
}
 
开发者ID:GIScience,项目名称:openrouteservice,代码行数:56,代码来源:JTS.java

示例13: findStabbedSegments

import com.vividsolutions.jts.algorithm.CGAlgorithms; //导入方法依赖的package包/类
/**
 * Finds all non-horizontal segments intersecting the stabbing line
 * in the input dirEdge.
 * The stabbing line is the ray to the right of stabbingRayLeftPt.
 *
 * @param stabbingRayLeftPt the left-hand origin of the stabbing line
 * @param stabbedSegments the current list of {@link DepthSegments} intersecting the stabbing line
 */
private void findStabbedSegments(Coordinate stabbingRayLeftPt,
                                 DirectedEdge dirEdge,
                                 List stabbedSegments) {
    Coordinate[] pts = dirEdge.getEdge().getCoordinates();
    for (int i = 0; i < pts.length - 1; i++) {
        this.seg.p0 = pts[i];
        this.seg.p1 = pts[i + 1];
        // ensure segment always points upwards
        if (this.seg.p0.y > this.seg.p1.y) {
            this.seg.reverse();
        }

        // skip segment if it is left of the stabbing line
        double maxx = Math.max(this.seg.p0.x, this.seg.p1.x);
        if (maxx < stabbingRayLeftPt.x) {
            continue;
        }

        // skip horizontal segments (there will be a non-horizontal one carrying the same depth info
        if (this.seg.isHorizontal()) {
            continue;
        }

        // skip if segment is above or below stabbing line
        if (stabbingRayLeftPt.y < this.seg.p0.y || stabbingRayLeftPt.y > this.seg.p1.y) {
            continue;
        }

        // skip if stabbing ray is right of the segment
        if (CGAlgorithms.computeOrientation(this.seg.p0, this.seg.p1, stabbingRayLeftPt)
                == CGAlgorithms.RIGHT) {
            continue;
        }

        // stabbing line cuts this segment, so record it
        int depth = dirEdge.getDepth(Position.LEFT);
        // if segment direction was flipped, use RHS depth instead
        if (!this.seg.p0.equals(pts[i])) {
            depth = dirEdge.getDepth(Position.RIGHT);
        }
        DepthSegment ds = new DepthSegment(this.seg, depth);
        stabbedSegments.add(ds);
    }
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:53,代码来源:SubgraphDepthLocater.java

示例14: compareAngularDirection

import com.vividsolutions.jts.algorithm.CGAlgorithms; //导入方法依赖的package包/类
/**
 * Implements the total order relation:
 * <p/>
 * The angle of edge a is greater than the angle of edge b,
 * where the angle of an edge is the angle made by
 * the first segment of the edge with the positive x-axis
 * <p/>
 * When applied to a list of edges originating at the same point,
 * this produces a CCW ordering of the edges around the point.
 * <p/>
 * Using the obvious algorithm of computing the angle is not robust,
 * since the angle calculation is susceptible to roundoff error.
 * A robust algorithm is:
 * <ul>
 * <li>First, compare the quadrants the edge vectors lie in.
 * If the quadrants are different,
 * it is trivial to determine which edge has a greater angle.
 * <p/>
 * <li>if the vectors lie in the same quadrant, the
 * {@link CGAlgorithms#computeOrientation(Coordinate, Coordinate, Coordinate)} function
 * can be used to determine the relative orientation of the vectors.
 * </ul>
 */
public int compareAngularDirection(HalfEdge e) {
    double dx = deltaX();
    double dy = deltaY();
    double dx2 = e.deltaX();
    double dy2 = e.deltaY();

    // same vector
    if (dx == dx2 && dy == dy2)
        return 0;

    double quadrant = Quadrant.quadrant(dx, dy);
    double quadrant2 = Quadrant.quadrant(dx2, dy2);

    // if the vectors are in different quadrants, determining the ordering is trivial
    if (quadrant > quadrant2) return 1;
    if (quadrant < quadrant2) 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.orig, e.dest(), dest());
}
 
开发者ID:Semantive,项目名称:jts,代码行数:45,代码来源:HalfEdge.java

示例15: compareDirection

import com.vividsolutions.jts.algorithm.CGAlgorithms; //导入方法依赖的package包/类
/**
 * Returns 1 if this DirectedEdge has a greater angle with the
 * positive x-axis than b", 0 if the DirectedEdges are collinear, and -1 otherwise.
 * <p>
 * Using the obvious algorithm of simply computing the angle is not robust,
 * since the angle calculation is susceptible to roundoff. A robust algorithm
 * is:
 * <ul>
 * <li>first compare the quadrants. If the quadrants are different, it it
 * trivial to determine which vector is "greater".
 * <li>if the vectors lie in the same quadrant, the robust
 * {@link CGAlgorithms#computeOrientation(Coordinate, Coordinate, Coordinate)}
 * function can be used to decide the relative orientation of the vectors.
 * </ul>
 */
public int compareDirection(DirectedEdge e) {
    // 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,代码行数:28,代码来源:DirectedEdge.java


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