本文整理汇总了Java中com.vividsolutions.jts.algorithm.CGAlgorithms.CLOCKWISE属性的典型用法代码示例。如果您正苦于以下问题:Java CGAlgorithms.CLOCKWISE属性的具体用法?Java CGAlgorithms.CLOCKWISE怎么用?Java CGAlgorithms.CLOCKWISE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.vividsolutions.jts.algorithm.CGAlgorithms
的用法示例。
在下文中一共展示了CGAlgorithms.CLOCKWISE属性的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ensureOrientation
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;
}
示例2: findRightmostEdgeAtVertex
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;
}
}
示例3: simplify
/**
* 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();
}
示例4: addFillet
/**
* 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);
}
示例5: findRightmostEdgeAtVertex
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;
}
}
示例6: simplify
/**
* 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();
}
示例7: simplify
/**
* 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();
}
示例8: addFillet
/**
* 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;
}
segList.addPt(p0);
addFillet(p, startAngle, endAngle, direction, radius);
segList.addPt(p1);
}
示例9: addNextSegment
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);
}
}
示例10: addNextSegment
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);
}
}