private Geometry removeDuplicatePoints(Geometry routeGeometry) { List<Coordinate> coords = new ArrayList<Coordinate>(); Coordinate last = null; for (Coordinate c : routeGeometry.getCoordinates()) { if (!c.equals(last)) { last = c; coords.add(c); } } if (coords.size() < 2) { return null; } Coordinate[] coordArray = new Coordinate[coords.size()]; return routeGeometry.getFactory().createLineString(coords.toArray(coordArray)); }
public boolean equals(Object o) { if (o instanceof StreetLocation) { StreetLocation other = (StreetLocation) o; return other.getCoordinate().equals(getCoordinate()); } return false; }
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; } }
/** * Returns true if this edge is trivial - beginning and ending at the same point. */ public boolean isTrivial() { Coordinate fromCoord = this.getFromVertex().getCoordinate(); Coordinate toCoord = this.getToVertex().getCoordinate(); return fromCoord.equals(toCoord); }
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 boolean isEndpoint(OsmVertex ov) { boolean isCandidate = false; Vertex start = null; for (Edge e : ov.getIncoming()) { if (e instanceof StreetEdge && ! (e instanceof AreaEdge)) { StreetEdge se = (StreetEdge) e; if (Arrays.asList(1,2,3).contains(se.getPermission().code)) { isCandidate = true; start = se.getFromVertex(); break; } } } if (isCandidate && start != null) { boolean isEndpoint = true; for (Edge se : ov.getOutgoing()) { if (!se.getToVertex().getCoordinate().equals(start.getCoordinate()) && !(se instanceof AreaEdge)) { isEndpoint = false; } } return isEndpoint; } return false; }
public boolean isClosed() { return pts[0].equals(pts[pts.length - 1]); }
public boolean hasRepeatedPoint(Coordinate[] coord) { for (int i = 1; i < coord.length; i++) { if (coord[i - 1].equals(coord[i]) ) { repeatedCoord = coord[i]; return true; } } return false; } private boolean hasRepeatedPoint(Polygon p)
public boolean isClosed() { return pts[0].equals(pts[pts.length - 1]); } /**
public static Coordinate findDifferentPoint(Coordinate[] coord, Coordinate pt) { for (int i = 0; i < coord.length; i++) { if (! coord[i].equals(pt)) return coord[i]; } return null; }
/** * Returns whether #equals returns true for any two consecutive Coordinates * in the given array. */ public static boolean hasRepeatedPoints(Coordinate[] coord) { for (int i = 1; i < coord.length; i++) { if (coord[i - 1].equals(coord[i]) ) { return true; } } return false; }
public boolean isClosed() { return pts[0].equals(pts[pts.length - 1]); }
nTotal += 2; Coordinate[] pList = lineString.getCoordinates(); boolean reverse = vx1.getCoordinate().equals(pList[0]);
public void closeRing() { if (ptList.size() < 1) return; Coordinate startPt = new Coordinate((Coordinate) ptList.get(0)); Coordinate lastPt = (Coordinate) ptList.get(ptList.size() - 1); Coordinate last2Pt = null; if (ptList.size() >= 2) last2Pt = (Coordinate) ptList.get(ptList.size() - 2); if (startPt.equals(lastPt)) return; ptList.add(startPt); }
private void checkCollapse(Coordinate p0, Coordinate p1, Coordinate p2) { if (p0.equals(p2)) throw new RuntimeException("found non-noded collapse at " + Debug.toLine(p0, p1, p2)); }
/** *@return true if there is an intersection point which is not an endpoint of the segment p0-p1 */ private boolean hasInteriorIntersection(LineIntersector li, Coordinate p0, Coordinate p1) { for (int i = 0; i < li.getIntersectionNum(); i++) { Coordinate intPt = li.getIntersection(i); if (! (intPt.equals(p0) || intPt.equals(p1))) return true; } return false; }
/** * An Edge is collapsed if it is an Area edge and it consists of * two segments which are equal and opposite (eg a zero-width V). */ public boolean isCollapsed() { if (! label.isArea()) return false; if (pts.length != 3) return false; if (pts[0].equals(pts[2]) ) return true; return false; } public Edge getCollapsedEdge()
private void checkEndPtVertexIntersections(Coordinate testPt, Collection segStrings) { for (Iterator i = segStrings.iterator(); i.hasNext(); ) { SegmentString ss = (SegmentString) i.next(); Coordinate[] pts = ss.getCoordinates(); for (int j = 1; j < pts.length - 1; j++) { if (pts[j].equals(testPt)) throw new RuntimeException("found endpt/interior pt intersection at index " + j + " :pt " + testPt); } } }
protected boolean equal(Coordinate a, Coordinate b, double tolerance) { if (tolerance == 0) { return a.equals(b); } return a.distance(b) <= tolerance; }
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); }