Coordinate[] pts = CoordinateArrays.toCoordinateArray(ptList); return pts;
public static CoordinateList unique(Coordinate[] coords) { Coordinate[] coordsCopy = CoordinateArrays.copyDeep(coords); Arrays.sort(coordsCopy); CoordinateList coordList = new CoordinateList(coordsCopy, false); return coordList; }
private static int geomPointsLen(Coordinate[] pts) { int n = pts.length; // don't process the last point of a ring twice if (CoordinateArrays.isRing(pts)) n = pts.length - 1; return n; }
Coordinate[] nonNullPts = CoordinateArrays.removeNull(newPts); Coordinate[] finalPts = nonNullPts; if (nonNullPts.length > 1 && ! nonNullPts[nonNullPts.length - 1].equals2D(nonNullPts[0])) { Coordinate[] ringPts = new Coordinate[nonNullPts.length + 1]; CoordinateArrays.copyDeep(nonNullPts, 0, ringPts, 0, nonNullPts.length); ringPts[ringPts.length-1] = new Coordinate(ringPts[0]); finalPts = ringPts;
} else if (g.getType() == Geobuf.Data.Geometry.Type.POLYGON) { Coordinate[] coords = getAllCoordinates(g); if (!CoordinateArrays.isRing(coords)) { Coordinate[] closedCoords = new Coordinate[coords.length + 1]; CoordinateArrays.copyDeep(coords, 0, closedCoords, 0, coords.length); closedCoords[closedCoords.length - 1] = coords[0]; coords = closedCoords; int end = start + numberOfCoordinates * dimension; Coordinate[] coords = getCoordinates(g, start, end); if (!CoordinateArrays.isRing(coords)) { Coordinate[] closedCoords = new Coordinate[coords.length + 1]; CoordinateArrays.copyDeep(coords, 0, closedCoords, 0, coords.length); closedCoords[closedCoords.length - 1] = coords[0]; coords = closedCoords;
public void testIntersection_coords_emptyEnvelope() { assertTrue(CoordinateArrays.equals( CoordinateArrays.intersection(COORDS_1, new Envelope()), COORDS_EMPTY ) ); } }
public Coordinate[] getOffsetCurve(Coordinate[] inputPts, double distance) { this.distance = distance; // a zero width offset curve is empty if (distance == 0.0) return null; boolean isRightSide = distance < 0.0; double posDistance = Math.abs(distance); OffsetSegmentGenerator segGen = getSegGen(posDistance); if (inputPts.length <= 1) { computePointCurve(inputPts[0], segGen); } else { computeOffsetCurve(inputPts, isRightSide, segGen); } Coordinate[] curvePts = segGen.getCoordinates(); // for right side line is traversed in reverse direction, so have to reverse generated line if (isRightSide) CoordinateArrays.reverse(curvePts); return curvePts; }
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].getZ() ); } Coordinate[] roundPtsNoDup = CoordinateArrays.removeRepeatedPoints(roundPts); return roundPtsNoDup; }
testPt = CoordinateArrays.ptNotInList(testRing.getCoordinates(), tryShellRing.getCoordinates()); boolean isContained = false; if (PointLocation.isInRing(testPt, tryShellRing.getCoordinates()) )
private void testQuery(KdTree index, Envelope queryEnv, Coordinate[] expectedCoord) { Coordinate[] result = KdTree.toCoordinates(index.query(queryEnv)); Arrays.sort(result); Arrays.sort(expectedCoord); assertTrue("Result count = " + result.length + ", expected count = " + expectedCoord.length, result.length == expectedCoord.length); boolean isMatch = CoordinateArrays.equals(result, expectedCoord); assertTrue("Expected result coordinates not found", isMatch); }
@Override public Coordinate[] edit(Coordinate[] paramArrayOfCoordinate, Geometry paramGeometry) { if (!this.polygon.intersects(paramGeometry)) { return paramArrayOfCoordinate; } Coordinate[] arrayOfCoordinate1 = new Coordinate[paramArrayOfCoordinate.length]; int j = 0; for (Coordinate coordinate : paramArrayOfCoordinate) { if (!this.polygon.contains(GF.createPoint(coordinate))) { arrayOfCoordinate1[(j++)] = coordinate; } } Coordinate[] arrayOfCoordinate2 = CoordinateArrays.removeNull(arrayOfCoordinate1); Coordinate[] localObject = arrayOfCoordinate2; if (((paramGeometry instanceof LinearRing)) && (arrayOfCoordinate2.length > 1) && (!arrayOfCoordinate2[(arrayOfCoordinate2.length - 1)].equals2D(arrayOfCoordinate2[0]))) { Coordinate[] arrayOfCoordinate3 = new Coordinate[arrayOfCoordinate2.length + 1]; CoordinateArrays.copyDeep(arrayOfCoordinate2, 0, arrayOfCoordinate3, 0, arrayOfCoordinate2.length); arrayOfCoordinate3[(arrayOfCoordinate3.length - 1)] = new Coordinate(arrayOfCoordinate3[0]); localObject = arrayOfCoordinate3; } return localObject; } }
public void testIntersection_envelopeDisjoint() { assertTrue(CoordinateArrays.equals( CoordinateArrays.intersection(COORDS_1, new Envelope(10, 20, 10, 20)), COORDS_EMPTY ) ); } public void testIntersection_empty_envelope()
private Coordinate[] getCoordinates() { if (coordinates == null) { int forwardDirectedEdges = 0; int reverseDirectedEdges = 0; CoordinateList coordinateList = new CoordinateList(); for (Iterator i = directedEdges.iterator(); i.hasNext();) { LineMergeDirectedEdge directedEdge = (LineMergeDirectedEdge) i.next(); if (directedEdge.getEdgeDirection()) { forwardDirectedEdges++; } else { reverseDirectedEdges++; } coordinateList.add(((LineMergeEdge) directedEdge.getEdge()).getLine() .getCoordinates(), false, directedEdge.getEdgeDirection()); } coordinates = coordinateList.toCoordinateArray(); if (reverseDirectedEdges > forwardDirectedEdges) { CoordinateArrays.reverse(coordinates); } } return coordinates; }
public static void createSegments(final LineString geom, final List<LineString> result) throws SQLException { Coordinate[] coords = CoordinateArrays.removeRepeatedPoints(geom.getCoordinates()); for (int j = 0; j < coords.length - 1; j++) { LineString lineString = GEOMETRY_FACTORY.createLineString( new Coordinate[]{coords[j], coords[j + 1]}); result.add(lineString); } }
testPt = CoordinateArrays.ptNotInList(testRing.getCoordinates(), tryShellRing.getCoordinates()); boolean isContained = false; if (PointLocation.isInRing(testPt, tryShellRing.getCoordinates()) )
private void testQuery(KdTree index, Envelope queryEnv, boolean includeRepeated, Coordinate[] expectedCoord) { Coordinate[] result = KdTree.toCoordinates(index.query(queryEnv), includeRepeated); Arrays.sort(result); Arrays.sort(expectedCoord); assertTrue("Result count = " + result.length + ", expected count = " + expectedCoord.length, result.length == expectedCoord.length); boolean isMatch = CoordinateArrays.equals(result, expectedCoord); assertTrue("Expected result coordinates not found", isMatch); }
public Coordinate[] getVertices() { return CoordinateArrays.toCoordinateArray(adjVerts); }
public void testIntersection_empty_envelope() { assertTrue(CoordinateArrays.equals( CoordinateArrays.intersection(COORDS_EMPTY, new Envelope(1, 2, 1, 2)), COORDS_EMPTY ) ); } public void testIntersection_coords_emptyEnvelope()
private void addLineString(LineString line) { // a zero or negative width buffer of a line/point is empty if (distance <= 0.0 && ! curveBuilder.getBufferParameters().isSingleSided()) return; Coordinate[] coord = CoordinateArrays.removeRepeatedPoints(line.getCoordinates()); Coordinate[] curve = curveBuilder.getLineCurve(coord, distance); addCurve(curve, Location.EXTERIOR, Location.INTERIOR); // TESTING //Coordinate[] curveTrim = BufferCurveLoopPruner.prune(curve); //addCurve(curveTrim, Location.EXTERIOR, Location.INTERIOR); }