public boolean matchesBackward(CoordinateSequence cs0, CoordinateSequence cs1) { if (cs0.size() != cs1.size()) return false; int maxIdx = cs0.size() - 1; for (int i = 0; i <= maxIdx; i++) if (!cs0.getCoordinate(i).equals(cs1.getCoordinate(maxIdx - i))) return false; return true; }
private static double[] getLengthsFromElevation(CoordinateSequence elev) { double trueLength = 0; double flatLength = 0; double lastX = elev.getX(0); double lastY = elev.getY(0); for (int i = 1; i < elev.size(); ++i) { Coordinate c = elev.getCoordinate(i); double x = c.x - lastX; double y = c.y - lastY; trueLength += Math.sqrt(x * x + y * y); flatLength += x; lastX = c.x; lastY = c.y; } return new double[] { trueLength, flatLength }; }
private static int checkRepeatedPoints2d(LineString lineString) { int repeatedPoints = 0; final CoordinateSequence coordSeq = lineString.getCoordinateSequence(); Coordinate nextCoord = null, prevCoord; for(int i = 0; i < coordSeq.size(); ++i) { prevCoord = nextCoord; nextCoord = coordSeq.getCoordinate(i); if(nextCoord.equals(prevCoord)) { ++repeatedPoints; } } return repeatedPoints; } }
/** * Compact an elevation profile onto a var-len int packed form (Dlugosz coding). * * @param profile The elevation profile to compact * @return The compacted format */ public static byte[] compactElevationProfile(CoordinateSequence elevation) { if (elevation == null) return null; int oix = 0; int oiy = 0; int[] coords = new int[elevation.size() * 2]; for (int i = 0; i < elevation.size(); i++) { /* * Note: We should do the rounding *before* the delta to prevent rounding errors from * accumulating on long line strings. */ Coordinate c = elevation.getCoordinate(i); int ix = (int) Math.round(c.x * FIXED_FLOAT_MULT); int iy = (int) Math.round(c.y * FIXED_FLOAT_MULT); int dix = ix - oix; int diy = iy - oiy; coords[i * 2] = dix; coords[i * 2 + 1] = diy; oix = ix; oiy = iy; } return DlugoszVarLenIntPacker.pack(coords); }
nextCoord = nextCoordSeq.getCoordinate(0); nextCoord.setOrdinate(0, cursor.x); nextCoord.setOrdinate(1, cursor.y); ); nextCoord = nextCoordSeq.getCoordinate(lineToIndex + 1); nextCoord.setOrdinate(0, cursor.x); nextCoord.setOrdinate(1, cursor.y);
); nextCoord = coordSeq.getCoordinate(coordIndex++); nextCoord.setOrdinate(0, cursor.x); nextCoord.setOrdinate(1, cursor.y);
nextCoord = nextCoordSeq.getCoordinate(0); nextCoord.setOrdinate(0, cursor.x); nextCoord.setOrdinate(1, cursor.y); ); nextCoord = nextCoordSeq.getCoordinate(lineToIndex + 1); nextCoord.setOrdinate(0, cursor.x); nextCoord.setOrdinate(1, cursor.y); nextCoord = nextCoordSeq.getCoordinate(nextCoordSeq.size() - 1); nextCoord.setOrdinate(0, nextCoordSeq.getOrdinate(0, 0)); nextCoord.setOrdinate(1, nextCoordSeq.getOrdinate(0, 1));
public Coordinate getCoordinate(int index) { return pts.getCoordinate(start + index); }
public Coordinate getCoordinateN(int n) { return points.getCoordinate(n); }
private double computePointLineDistance(Coordinate pt, FacetSequence facetSeq) { double minDistance = Double.MAX_VALUE; for (int i = facetSeq.start; i < facetSeq.end - 1; i++) { facetSeq.pts.getCoordinate(i, q0); facetSeq.pts.getCoordinate(i + 1, q1); double dist = CGAlgorithms.distancePointLine(pt, q0, q1); if (dist == 0.0) return 0.0; if (dist < minDistance) { minDistance = dist; } } return minDistance; }
public void filter(CoordinateSequence seq, int i) { // compare to vertex checkVertexDistance(seq.getCoordinate(i)); // compare to segment, if this is one if (i > 0) { checkSegmentDistance(seq.getCoordinate(i - 1), seq.getCoordinate(i)); } }
public Coordinate getCoordinate() { if (isEmpty()) return null; return points.getCoordinate(0); }
public void filter(CoordinateSequence seq, int i) { if (i == 0) return; hasSegment = p0.equals2D(seq.getCoordinate(i-1)) && p1.equals2D(seq.getCoordinate(i)); }
public Coordinate getCoordinate() { return coordinates.size() != 0 ? coordinates.getCoordinate(0): null; }
public Point getPointN(int n) { return getFactory().createPoint(points.getCoordinate(n)); }
public void filter(CoordinateSequence seq, int index) { if (index == 0) return; Coordinate p0 = seq.getCoordinate(index - 1); Coordinate p1 = seq.getCoordinate(index); Coordinate midPt = new Coordinate( (p0.x + p1.x)/2, (p0.y + p1.y)/2); minPtDist.initialize(); DistanceToPointFinder.computeDistance(geom, midPt, minPtDist); maxPtDist.setMaximum(minPtDist); }
private void checkIntersectionWithSegments(LineString testLine) { CoordinateSequence seq1 = testLine.getCoordinateSequence(); for (int j = 1; j < seq1.size(); j++) { seq1.getCoordinate(j - 1, p0); seq1.getCoordinate(j, p1); if (rectIntersector.intersects(p0, p1)) { hasIntersection = true; return; } } }
public void apply(CoordinateFilter filter) { for (int i = 0; i < points.size(); i++) { filter.filter(points.getCoordinate(i)); } }
public static ExtendedCoordinate[] copy(CoordinateSequence coordSeq) { ExtendedCoordinate[] copy = new ExtendedCoordinate[coordSeq.size()]; for (int i = 0; i < coordSeq.size(); i++) { copy[i] = new ExtendedCoordinate(coordSeq.getCoordinate(i)); } return copy; }
public LinearRing createLinearRing(CoordinateSequence cs) { if (cs.getCoordinate(0).equals(cs.getCoordinate(cs.size() - 1))) return super.createLinearRing(cs); // add a new coordinate to close the ring CoordinateSequenceFactory csFact = getCoordinateSequenceFactory(); CoordinateSequence csNew = csFact.create(cs.size() + 1, cs.getDimension()); CoordinateSequences.copy(cs, 0, csNew, 0, cs.size()); CoordinateSequences.copyCoord(csNew, 0, csNew, csNew.size() - 1); return super.createLinearRing(csNew); }