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


Java CGAlgorithms.isCCW方法代码示例

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


在下文中一共展示了CGAlgorithms.isCCW方法的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: 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

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

示例4: computeRing

import com.vividsolutions.jts.algorithm.CGAlgorithms; //导入方法依赖的package包/类
/**
     * Compute a LinearRing from the point list previously collected.
     * Test if the ring is a hole (i.e. if it is CCW) and set the hole flag
     * accordingly.
     */
    public void computeRing() {
        if (this.ring != null) {
            return;   // don't compute more than once
        }
        Coordinate[] coord = new Coordinate[this.pts.size()];
        for (int i = 0; i < this.pts.size(); i++) {
            coord[i] = (Coordinate) this.pts.get(i);
        }
        this.ring = this.geometryFactory.createLinearRing(coord);
        this.isHole = CGAlgorithms.isCCW(this.ring.getCoordinates());
//Debug.println( (isHole ? "hole - " : "shell - ") + WKTWriter.toLineString(new CoordinateArraySequence(ring.getCoordinates())));
    }
 
开发者ID:gegy1000,项目名称:Earth,代码行数:18,代码来源:EdgeRing.java

示例5: addPolygonRing

import com.vividsolutions.jts.algorithm.CGAlgorithms; //导入方法依赖的package包/类
/**
 * Adds a polygon ring to the graph.
 * Empty rings are ignored.
 * <p>
 * The 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.
 */
private void addPolygonRing(LinearRing lr, int cwLeft, int cwRight) {
    // don't bother adding empty holes
    if (lr.isEmpty()) {
        return;
    }

    Coordinate[] coord = CoordinateArrays.removeRepeatedPoints(lr.getCoordinates());

    if (coord.length < 4) {
        this.hasTooFewPoints = true;
        this.invalidPoint = coord[0];
        return;
    }

    int left = cwLeft;
    int right = cwRight;
    if (CGAlgorithms.isCCW(coord)) {
        left = cwRight;
        right = cwLeft;
    }
    Edge e = new Edge(coord,
            new Label(this.argIndex, Location.BOUNDARY, left, right));
    this.lineEdgeMap.put(lr, e);

    this.insertEdge(e);
    // insert the endpoint as a node, to mark that it is on the boundary
    this.insertPoint(this.argIndex, coord[0], Location.BOUNDARY);
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:37,代码来源:GeometryGraph.java

示例6: normalize

import com.vividsolutions.jts.algorithm.CGAlgorithms; //导入方法依赖的package包/类
private void normalize(LinearRing ring, boolean clockwise) {
    if (ring.isEmpty()) {
        return;
    }
    Coordinate[] uniqueCoordinates = new Coordinate[ring.getCoordinates().length - 1];
    System.arraycopy(ring.getCoordinates(), 0, uniqueCoordinates, 0, uniqueCoordinates.length);
    Coordinate minCoordinate = CoordinateArrays.minCoordinate(ring.getCoordinates());
    CoordinateArrays.scroll(uniqueCoordinates, minCoordinate);
    System.arraycopy(uniqueCoordinates, 0, ring.getCoordinates(), 0, uniqueCoordinates.length);
    ring.getCoordinates()[uniqueCoordinates.length] = uniqueCoordinates[0];
    if (CGAlgorithms.isCCW(ring.getCoordinates()) == clockwise) {
        CoordinateArrays.reverse(ring.getCoordinates());
    }
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:15,代码来源:Polygon.java

示例7: isClockwise

import com.vividsolutions.jts.algorithm.CGAlgorithms; //导入方法依赖的package包/类
public static boolean isClockwise(ILineString line) {
  Geometry geom = null;
  try {
    geom = AdapterFactory.toGeometry(new GeometryFactory(), line);
  } catch (Exception e) {
    e.printStackTrace();
  }
  if (CGAlgorithms.isCCW(geom.getCoordinates()))
    return false;
  return true;
}
 
开发者ID:IGNF,项目名称:geoxygene,代码行数:12,代码来源:JTSAlgorithms.java

示例8: isCCW

import com.vividsolutions.jts.algorithm.CGAlgorithms; //导入方法依赖的package包/类
private static boolean isCCW(Coordinate[] oldCoordinates) {
	Coordinate[] coordinates = new Coordinate[oldCoordinates.length+1];
	int i=0;
	for(Coordinate coordinate : oldCoordinates) {
		coordinates[i++] = coordinate;
	}
	
	coordinates[coordinates.length-1] = coordinates[0]; 
	return CGAlgorithms.isCCW(coordinates);
}
 
开发者ID:PDOK,项目名称:gml3-jts,代码行数:11,代码来源:ArcUtils.java

示例9: convertPolygonPatch

import com.vividsolutions.jts.algorithm.CGAlgorithms; //导入方法依赖的package包/类
/**
 * <p>convertPolygonPatch.</p>
 *
 * @param polygonPatch a {@link net.opengis.gml.v_3_1_1.PolygonPatchType} object.
 * @return a {@link com.vividsolutions.jts.geom.Polygon} object.
 * @throws nl.pdok.gml3.exceptions.GeometryException if any.
 */
public Polygon convertPolygonPatch(PolygonPatchType polygonPatch)
		throws GeometryException {
	if(polygonPatch.getExterior() == null) {
		throw new InvalidGeometryException(GeometryValidationErrorType.POLYGON_HAS_NO_EXTERIOR, null);
	}
	
	AbstractRingPropertyType abstractRing = polygonPatch.getExterior().getValue();
	LinearRing exteriorShell = gmlToLineConvertor.translateAbstractRing(abstractRing);
	if (!CGAlgorithms.isCCW(exteriorShell.getCoordinates())) {
		throw new InvalidGeometryException(
				GeometryValidationErrorType.OUTER_RING_IS_NOT_CCW, null);
	}

	LinearRing[] innerRings = new LinearRing[polygonPatch.getInterior().size()];
	for (int i = 0; i < polygonPatch.getInterior().size(); i++) {
		innerRings[i] = gmlToLineConvertor.translateAbstractRing(polygonPatch.getInterior()
				.get(i).getValue());
		if (CGAlgorithms.isCCW(innerRings[i].getCoordinates())) {
			throw new InvalidGeometryException(
					GeometryValidationErrorType.INNER_RING_IS_CCW, null);
		}

	}

	return geometryFactory.createPolygon(exteriorShell, innerRings);
}
 
开发者ID:PDOK,项目名称:gml3-jts,代码行数:34,代码来源:GMLToSurfaceConvertor.java

示例10: convertPolygonPatch

import com.vividsolutions.jts.algorithm.CGAlgorithms; //导入方法依赖的package包/类
/**
 * <p>convertPolygonPatch.</p>
 *
 * @param polygonPatch a {@link net.opengis.gml.v_3_2_1.PolygonPatchType} object.
 * @return a {@link com.vividsolutions.jts.geom.Polygon} object.
 * @throws nl.pdok.gml3.exceptions.GeometryException if any.
 */
public Polygon convertPolygonPatch(PolygonPatchType polygonPatch)
        throws GeometryException {
    if (polygonPatch.getExterior() == null) {
        throw new InvalidGeometryException(GeometryValidationErrorType.POLYGON_HAS_NO_EXTERIOR, null);
    }

    AbstractRingPropertyType abstractRing = polygonPatch.getExterior();
    LinearRing exteriorShell = gmlToLineConvertor.translateAbstractRing(abstractRing);
    if (!CGAlgorithms.isCCW(exteriorShell.getCoordinates())) {

        // Try to reverse it and try again
        exteriorShell = reverseRing(exteriorShell);
        if (!CGAlgorithms.isCCW(exteriorShell.getCoordinates())) {
            throw new InvalidGeometryException(
                    GeometryValidationErrorType.OUTER_RING_IS_NOT_CCW, null);
        }
    }

    LinearRing[] innerRings = new LinearRing[polygonPatch.getInterior().size()];
    for (int i = 0; i < polygonPatch.getInterior().size(); i++) {
        innerRings[i] = gmlToLineConvertor.translateAbstractRing(polygonPatch.getInterior()
                .get(i));
        if (CGAlgorithms.isCCW(innerRings[i].getCoordinates())) {
            throw new InvalidGeometryException(
                    GeometryValidationErrorType.INNER_RING_IS_CCW, null);
        }

    }

    return geometryFactory.createPolygon(exteriorShell, innerRings);
}
 
开发者ID:PDOK,项目名称:gml3-jts,代码行数:39,代码来源:GML321ToSurfaceConvertor.java

示例11: computeRing

import com.vividsolutions.jts.algorithm.CGAlgorithms; //导入方法依赖的package包/类
/**
     * Compute a LinearRing from the point list previously collected.
     * Test if the ring is a hole (i.e. if it is CCW) and set the hole flag
     * accordingly.
     */
    public void computeRing() {
        if (ring != null) return;   // don't compute more than once
        Coordinate[] coord = new Coordinate[pts.size()];
        for (int i = 0; i < pts.size(); i++) {
            coord[i] = (Coordinate) pts.get(i);
        }
        ring = geometryFactory.createLinearRing(coord);
        isHole = CGAlgorithms.isCCW(ring.getCoordinates());
//Debug.println( (isHole ? "hole - " : "shell - ") + WKTWriter.toLineString(new CoordinateArraySequence(ring.getCoordinates())));
    }
 
开发者ID:Semantive,项目名称:jts,代码行数:16,代码来源:EdgeRing.java

示例12: addPolygonRing

import com.vividsolutions.jts.algorithm.CGAlgorithms; //导入方法依赖的package包/类
/**
 * Adds a polygon ring to the graph.
 * Empty rings are ignored.
 * <p/>
 * The 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.
 */
private void addPolygonRing(LinearRing lr, int cwLeft, int cwRight) {
    // don't bother adding empty holes
    if (lr.isEmpty()) return;

    Coordinate[] coord = CoordinateArrays.removeRepeatedPoints(lr.getCoordinates());

    if (coord.length < 4) {
        hasTooFewPoints = true;
        invalidPoint = coord[0];
        return;
    }

    int left = cwLeft;
    int right = cwRight;
    if (CGAlgorithms.isCCW(coord)) {
        left = cwRight;
        right = cwLeft;
    }
    Edge e = new Edge(coord,
            new Label(argIndex, Location.BOUNDARY, left, right));
    lineEdgeMap.put(lr, e);

    insertEdge(e);
    // insert the endpoint as a node, to mark that it is on the boundary
    insertPoint(argIndex, coord[0], Location.BOUNDARY);
}
 
开发者ID:Semantive,项目名称:jts,代码行数:35,代码来源:GeometryGraph.java

示例13: computeRing

import com.vividsolutions.jts.algorithm.CGAlgorithms; //导入方法依赖的package包/类
/**
   * Compute a LinearRing from the point list previously collected.
   * Test if the ring is a hole (i.e. if it is CCW) and set the hole flag
   * accordingly.
   */
  public void computeRing()
  {
    if (ring != null) return;   // don't compute more than once
    Coordinate[] coord = new Coordinate[pts.size()];
    for (int i = 0; i < pts.size(); i++) {
      coord[i] = (Coordinate) pts.get(i);
    }
    ring = geometryFactory.createLinearRing(coord);
    isHole = CGAlgorithms.isCCW(ring.getCoordinates());
//Debug.println( (isHole ? "hole - " : "shell - ") + WKTWriter.toLineString(new CoordinateArraySequence(ring.getCoordinates())));
  }
 
开发者ID:GitHubDroid,项目名称:geodroid_master_update,代码行数:17,代码来源:EdgeRing.java

示例14: isCCW

import com.vividsolutions.jts.algorithm.CGAlgorithms; //导入方法依赖的package包/类
@Override
public boolean isCCW()
{
  Coordinate[] coordinates = new Coordinate[getNumPoints()];
  for (int i = 0; i < getNumPoints(); i++)
  {
    Point pt = getPoint(i);
    coordinates[i] = new Coordinate(pt.getX(), pt.getY());
  }

  return CGAlgorithms.isCCW(coordinates);
}
 
开发者ID:ngageoint,项目名称:mrgeo,代码行数:13,代码来源:LinearRingImpl.java

示例15: createShpPolygon

import com.vividsolutions.jts.algorithm.CGAlgorithms; //导入方法依赖的package包/类
/**
 * make sure outer ring is CCW and holes are CW
 * 
 * @param p
 *          polygon to check
 */
static Polygon createShpPolygon(Polygon p) {
  LinearRing outer;
  LinearRing[] holes = new LinearRing[p.getNumInteriorRing()];
  Coordinate[] coords;

  if (p.isEmpty())
    return p;

  coords = p.getExteriorRing().getCoordinates();

  if (CGAlgorithms.isCCW(coords)) {
    outer = reverseRing((LinearRing) p.getExteriorRing());
  } else {
    outer = (LinearRing) p.getExteriorRing();
  }

  for (int t = 0; t < p.getNumInteriorRing(); t++) {
    coords = p.getInteriorRingN(t).getCoordinates();

    if (!(CGAlgorithms.isCCW(coords))) {
      holes[t] = reverseRing((LinearRing) p.getInteriorRingN(t));
    } else {
      holes[t] = (LinearRing) p.getInteriorRingN(t);
    }
  }

  return new Polygon(outer, holes, new PrecisionModel(), 0);
}
 
开发者ID:dr-jts,项目名称:jeql,代码行数:35,代码来源:ShapeGeometryBuilder.java


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