本文整理汇总了Java中com.vividsolutions.jts.geom.CoordinateArrays.removeRepeatedPoints方法的典型用法代码示例。如果您正苦于以下问题:Java CoordinateArrays.removeRepeatedPoints方法的具体用法?Java CoordinateArrays.removeRepeatedPoints怎么用?Java CoordinateArrays.removeRepeatedPoints使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.vividsolutions.jts.geom.CoordinateArrays
的用法示例。
在下文中一共展示了CoordinateArrays.removeRepeatedPoints方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addEdge
import com.vividsolutions.jts.geom.CoordinateArrays; //导入方法依赖的package包/类
/**
* Add a {@link LineString} forming an edge of the polygon graph.
*
* @param line the line to add
*/
public void addEdge(LineString line) {
if (line.isEmpty()) {
return;
}
Coordinate[] linePts = CoordinateArrays.removeRepeatedPoints(line.getCoordinates());
if (linePts.length < 2) {
return;
}
Coordinate startPt = linePts[0];
Coordinate endPt = linePts[linePts.length - 1];
Node nStart = this.getNode(startPt);
Node nEnd = this.getNode(endPt);
DirectedEdge de0 = new PolygonizeDirectedEdge(nStart, nEnd, linePts[1], true);
DirectedEdge de1 = new PolygonizeDirectedEdge(nEnd, nStart, linePts[linePts.length - 2], false);
Edge edge = new PolygonizeEdge(line);
edge.setDirectedEdges(de0, de1);
this.add(edge);
}
示例2: addEdge
import com.vividsolutions.jts.geom.CoordinateArrays; //导入方法依赖的package包/类
/**
* Adds an Edge, DirectedEdges, and Nodes for the given LineString representation
* of an edge.
* Empty lines or lines with all coordinates equal are not added.
*
* @param lineString the linestring to add to the graph
*/
public void addEdge(LineString lineString) {
if (lineString.isEmpty()) {
return;
}
Coordinate[] coordinates = CoordinateArrays.removeRepeatedPoints(lineString.getCoordinates());
// don't add lines with all coordinates equal
if (coordinates.length <= 1) {
return;
}
Coordinate startCoordinate = coordinates[0];
Coordinate endCoordinate = coordinates[coordinates.length - 1];
Node startNode = this.getNode(startCoordinate);
Node endNode = this.getNode(endCoordinate);
DirectedEdge directedEdge0 = new LineMergeDirectedEdge(startNode, endNode,
coordinates[1], true);
DirectedEdge directedEdge1 = new LineMergeDirectedEdge(endNode, startNode,
coordinates[coordinates.length - 2], false);
Edge edge = new LineMergeEdge(lineString);
edge.setDirectedEdges(directedEdge0, directedEdge1);
this.add(edge);
}
示例3: addLineString
import com.vividsolutions.jts.geom.CoordinateArrays; //导入方法依赖的package包/类
private void addLineString(LineString line) {
Coordinate[] coord = CoordinateArrays.removeRepeatedPoints(line.getCoordinates());
if (coord.length < 2) {
this.hasTooFewPoints = true;
this.invalidPoint = coord[0];
return;
}
// add the edge for the LineString
// line edges do not have locations for their left and right sides
Edge e = new Edge(coord, new Label(this.argIndex, Location.INTERIOR));
this.lineEdgeMap.put(line, e);
this.insertEdge(e);
/**
* Add the boundary points of the LineString, if any.
* Even if the LineString is closed, add both points as if they were endpoints.
* This allows for the case that the node already exists and is a boundary point.
*/
Assert.isTrue(coord.length >= 2, "found LineString with single point");
this.insertBoundaryPoint(this.argIndex, coord[0]);
this.insertBoundaryPoint(this.argIndex, coord[coord.length - 1]);
}
示例4: addEdge
import com.vividsolutions.jts.geom.CoordinateArrays; //导入方法依赖的package包/类
/**
* Add a {@link LineString} forming an edge of the polygon graph.
*
* @param line the line to add
*/
public void addEdge(LineString line) {
if (line.isEmpty()) {
return;
}
Coordinate[] linePts = CoordinateArrays.removeRepeatedPoints(line.getCoordinates());
if (linePts.length < 2) {
return;
}
Coordinate startPt = linePts[0];
Coordinate endPt = linePts[linePts.length - 1];
Node nStart = getNode(startPt);
Node nEnd = getNode(endPt);
DirectedEdge de0 = new PolygonizeDirectedEdge(nStart, nEnd, linePts[1], true);
DirectedEdge de1 = new PolygonizeDirectedEdge(nEnd, nStart, linePts[linePts.length - 2], false);
Edge edge = new PolygonizeEdge(line);
edge.setDirectedEdges(de0, de1);
add(edge);
}
示例5: addEdge
import com.vividsolutions.jts.geom.CoordinateArrays; //导入方法依赖的package包/类
/**
* Adds an Edge, DirectedEdges, and Nodes for the given LineString representation
* of an edge.
* Empty lines or lines with all coordinates equal are not added.
*
* @param lineString the linestring to add to the graph
*/
public void addEdge(LineString lineString) {
if (lineString.isEmpty()) {
return;
}
Coordinate[] coordinates = CoordinateArrays.removeRepeatedPoints(lineString.getCoordinates());
// don't add lines with all coordinates equal
if (coordinates.length <= 1) return;
Coordinate startCoordinate = coordinates[0];
Coordinate endCoordinate = coordinates[coordinates.length - 1];
Node startNode = getNode(startCoordinate);
Node endNode = getNode(endCoordinate);
DirectedEdge directedEdge0 = new LineMergeDirectedEdge(startNode, endNode,
coordinates[1], true);
DirectedEdge directedEdge1 = new LineMergeDirectedEdge(endNode, startNode,
coordinates[coordinates.length - 2], false);
Edge edge = new LineMergeEdge(lineString);
edge.setDirectedEdges(directedEdge0, directedEdge1);
add(edge);
}
示例6: addEdge
import com.vividsolutions.jts.geom.CoordinateArrays; //导入方法依赖的package包/类
/**
* Adds an Edge, DirectedEdges, and Nodes for the given LineString representation
* of an edge.
* Empty lines or lines with all coordinates equal are not added.
*
* @param lineString the linestring to add to the graph
*/
public void addEdge(LineString lineString) {
if (lineString.isEmpty()) { return; }
Coordinate[] coordinates = CoordinateArrays.removeRepeatedPoints(lineString.getCoordinates());
// don't add lines with all coordinates equal
if (coordinates.length <= 1) return;
Coordinate startCoordinate = coordinates[0];
Coordinate endCoordinate = coordinates[coordinates.length - 1];
Node startNode = getNode(startCoordinate);
Node endNode = getNode(endCoordinate);
DirectedEdge directedEdge0 = new LineMergeDirectedEdge(startNode, endNode,
coordinates[1], true);
DirectedEdge directedEdge1 = new LineMergeDirectedEdge(endNode, startNode,
coordinates[coordinates.length - 2], false);
Edge edge = new LineMergeEdge(lineString);
edge.setDirectedEdges(directedEdge0, directedEdge1);
add(edge);
}
示例7: addLineString
import com.vividsolutions.jts.geom.CoordinateArrays; //导入方法依赖的package包/类
private void addLineString(LineString line) {
// a zero or negative width buffer of a line/point is empty
if (this.distance <= 0.0 && !this.curveBuilder.getBufferParameters().isSingleSided()) {
return;
}
Coordinate[] coord = CoordinateArrays.removeRepeatedPoints(line.getCoordinates());
Coordinate[] curve = this.curveBuilder.getLineCurve(coord, this.distance);
this.addCurve(curve, Location.EXTERIOR, Location.INTERIOR);
// TESTING
//Coordinate[] curveTrim = BufferCurveLoopPruner.prune(curve);
//addCurve(curveTrim, Location.EXTERIOR, Location.INTERIOR);
}
示例8: buildIndex
import com.vividsolutions.jts.geom.CoordinateArrays; //导入方法依赖的package包/类
private void buildIndex() {
//Envelope env = ring.getEnvelopeInternal();
this.tree = new Bintree();
Coordinate[] pts = CoordinateArrays.removeRepeatedPoints(this.ring.getCoordinates());
List mcList = MonotoneChainBuilder.getChains(pts);
for (Object aMcList : mcList) {
MonotoneChain mc = (MonotoneChain) aMcList;
Envelope mcEnv = mc.getEnvelope();
this.interval.min = mcEnv.getMinY();
this.interval.max = mcEnv.getMaxY();
this.tree.insert(this.interval, mc);
}
}
示例9: scale
import com.vividsolutions.jts.geom.CoordinateArrays; //导入方法依赖的package包/类
private Coordinate[] scale(Coordinate[] pts) {
Coordinate[] roundPts = new Coordinate[pts.length];
for (int i = 0; i < pts.length; i++) {
roundPts[i] = new Coordinate(
Math.round((pts[i].x - this.offsetX) * this.scaleFactor),
Math.round((pts[i].y - this.offsetY) * this.scaleFactor),
pts[i].z
);
}
Coordinate[] roundPtsNoDup = CoordinateArrays.removeRepeatedPoints(roundPts);
return roundPtsNoDup;
}
示例10: addPolygonRing
import com.vividsolutions.jts.geom.CoordinateArrays; //导入方法依赖的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);
}
示例11: scale
import com.vividsolutions.jts.geom.CoordinateArrays; //导入方法依赖的package包/类
private Coordinate[] scale(Coordinate[] pts) {
Coordinate[] roundPts = new Coordinate[pts.length];
for (int i = 0; i < pts.length; i++) {
roundPts[i] = new Coordinate(
Math.round((pts[i].x - offsetX) * scaleFactor),
Math.round((pts[i].y - offsetY) * scaleFactor),
pts[i].z
);
}
Coordinate[] roundPtsNoDup = CoordinateArrays.removeRepeatedPoints(roundPts);
return roundPtsNoDup;
}
示例12: addPolygon
import com.vividsolutions.jts.geom.CoordinateArrays; //导入方法依赖的package包/类
private void addPolygon(Polygon p) {
double offsetDistance = this.distance;
int offsetSide = Position.LEFT;
if (this.distance < 0.0) {
offsetDistance = -this.distance;
offsetSide = Position.RIGHT;
}
LinearRing shell = (LinearRing) p.getExteriorRing();
Coordinate[] shellCoord = CoordinateArrays.removeRepeatedPoints(shell.getCoordinates());
// optimization - don't bother computing buffer
// if the polygon would be completely eroded
if (this.distance < 0.0 && this.isErodedCompletely(shell, this.distance)) {
return;
}
// don't attemtp to buffer a polygon with too few distinct vertices
if (this.distance <= 0.0 && shellCoord.length < 3) {
return;
}
this.addPolygonRing(
shellCoord,
offsetDistance,
offsetSide,
Location.EXTERIOR,
Location.INTERIOR);
for (int i = 0; i < p.getNumInteriorRing(); i++) {
LinearRing hole = (LinearRing) p.getInteriorRingN(i);
Coordinate[] holeCoord = CoordinateArrays.removeRepeatedPoints(hole.getCoordinates());
// optimization - don't bother computing buffer for this hole
// if the hole would be completely covered
if (this.distance > 0.0 && this.isErodedCompletely(hole, -this.distance)) {
continue;
}
// Holes are topologically labelled opposite to the shell, since
// the interior of the polygon lies on their opposite side
// (on the left, if the hole is oriented CCW)
this.addPolygonRing(
holeCoord,
offsetDistance,
Position.opposite(offsetSide),
Location.INTERIOR,
Location.EXTERIOR);
}
}