LineString out = geometryFactory.createLineString(c); if (reverse) out = (LineString) out.reverse(); return out;
private void treatAndAddUshapeWithinTimeLimits(long maxTime, double userSpeed, ArrayList<LineString> walkShedEdges, Edge edge, long fromTime, long toTime, LineString ls, boolean hasCar) { // check if the u-shape can be traveled within the remaining time long dt = Math.abs(toTime - fromTime); double distanceToMoveInTimeMissing = distanceToMoveInRemainingTime(maxTime, fromTime, dt, userSpeed, edge, hasCar, true); double lineDist = edge.getDistance(); double fraction = (double) distanceToMoveInTimeMissing / (double) lineDist; // get the sub-edge geom LineString subLine = null; if (fraction < 1.0) { // the u-shape is not fully walkable in maxTime subLine = this.getSubLineString(ls, fraction); walkShedEdges.add(subLine); // if it is smaller we need also to calculate the LS from the other side LineString reversedLine = (LineString) ls.reverse(); double distanceToMoveInTimeMissing2 = distanceToMoveInRemainingTime(maxTime, toTime, dt, userSpeed, edge, hasCar, true); double fraction2 = (double) distanceToMoveInTimeMissing2 / (double) lineDist; LineString secondsubLine = this.getSubLineString(reversedLine, fraction2); ; walkShedEdges.add(secondsubLine); } else { // the whole u-shape is within the time // add only once walkShedEdges.add(ls); } }
} else { inputLS = (LineString) ls.reverse(); double distanceToWalkInTimeMissing = distanceToMoveInRemainingTime( maxTime, toTime, dt, userSpeed, edge, hasCar,
private void setGeometry(LineString geometry) { this.compactGeometry = CompactLineString.compactLineString(fromv.getLon(), fromv.getLat(), tov.getLon(), tov.getLat(), isBack() ? (LineString)geometry.reverse() : geometry, isBack()); }
LineString reversed = (LineString) geom.reverse(); StreetEdge backStreet = edgeFactory.createEdge(endIntersection, startIntersection, reversed, new NonLocalizedString(name), length, permissions.second, true);
area.getPermission(), false, this); forward.setStreetClass(area.getStreetClass()); AreaEdge backward = new AreaEdge(to, from, (LineString) line.reverse(), area.getRawName(), length, area.getPermission(), true, this); backward.setStreetClass(area.getStreetClass());
LineString backGeometry = (LineString) geometry.reverse(); StreetEdge street = null, backStreet = null; double length = this.getGeometryLengthMeters(geometry);
(LineString) line.reverse(), name, length, areaPermissions, true, edgeList); backStreet.setCarSpeed(carSpeed);
private Geometry reverse(Geometry linear) { if (linear instanceof LineString) return ((LineString) linear).reverse(); if (linear instanceof MultiLineString) return ((MultiLineString) linear).reverse(); Assert.shouldNeverReachHere("non-linear geometry encountered"); return null; } /**
private static LineString reverseWindingOrder(LineString vertices) { return (LineString) vertices.reverse(); }
public Geometry reverse() { return lineString.reverse(); }
/** * Returns a line string cursor based on the opposite walking direction. * * @return */ public LineStringCursor reverse() { return new LineStringCursor((LineString) lineString.reverse()); }
private Geometry reverse(Geometry linear) { if (linear instanceof LineString) return ((LineString) linear).reverse(); if (linear instanceof MultiLineString) return ((MultiLineString) linear).reverse(); Assert.shouldNeverReachHere("non-linear geometry encountered"); return null; } /**
public static Coordinate pointOnLine(LineString line, boolean end) { Coordinate[] coords = end ? line.reverse().getCoordinates() : line.getCoordinates(); double distanceSoFar = 0; int coordIndex = 1; while (distanceSoFar < 10 && coordIndex < coords.length) { distanceSoFar += GeometryUtils.distance(coords[coordIndex - 1].x, coords[coordIndex - 1].y, coords[coordIndex].x, coords[coordIndex].y); coordIndex++; } return coords[coordIndex - 1]; } }
public static Coordinate pointOnLine(LineString line, boolean end) { Coordinate[] coords = end ? line.reverse().getCoordinates() : line.getCoordinates(); double distanceSoFar = 0; int coordIndex = 1; while (distanceSoFar < 10 && coordIndex < coords.length) { distanceSoFar += GeometryUtils.distance(coords[coordIndex - 1].x, coords[coordIndex - 1].y, coords[coordIndex].x, coords[coordIndex].y); coordIndex++; } return coords[coordIndex - 1]; } }
/** * Reverse the LineString to be oriented counter-clockwise. * @param lineString * @return */ private static LineString getCounterClockWise(final LineString lineString) { final Coordinate c0 = lineString.getCoordinateN(0); final Coordinate c1 = lineString.getCoordinateN(1); final Coordinate c2 = lineString.getCoordinateN(2); lineString.apply(new UpdateZCoordinateSequenceFilter(0, 3)); if (CGAlgorithms.computeOrientation(c0, c1, c2) == CGAlgorithms.COUNTERCLOCKWISE) { return lineString; } else { return (LineString) lineString.reverse(); } }
/** * Reverse the LineString to be oriented counter-clockwise. * @param lineString * @return */ private static LineString getCounterClockWise(final LineString lineString) { final Coordinate c0 = lineString.getCoordinateN(0); final Coordinate c1 = lineString.getCoordinateN(1); final Coordinate c2 = lineString.getCoordinateN(2); lineString.apply(new UpdateZCoordinateSequenceFilter(0, 3)); if (CGAlgorithms.computeOrientation(c0, c1, c2) == CGAlgorithms.COUNTERCLOCKWISE) { return lineString; } else { return (LineString) lineString.reverse(); } }
/** * Reverse the LineString to be oriented clockwise. * All NaN z values are replaced by a zero value. * @param lineString * @return */ private static LineString getClockWise(final LineString lineString) { final Coordinate c0 = lineString.getCoordinateN(0); final Coordinate c1 = lineString.getCoordinateN(1); final Coordinate c2 = lineString.getCoordinateN(2); lineString.apply(new UpdateZCoordinateSequenceFilter(0, 3)); if (CGAlgorithms.computeOrientation(c0, c1, c2) == CGAlgorithms.CLOCKWISE) { return lineString; } else { return (LineString) lineString.reverse(); } }
/** * Reverse the LineString to be oriented clockwise. * All NaN z values are replaced by a zero value. * @param lineString * @return */ private static LineString getClockWise(final LineString lineString) { final Coordinate c0 = lineString.getCoordinateN(0); final Coordinate c1 = lineString.getCoordinateN(1); final Coordinate c2 = lineString.getCoordinateN(2); lineString.apply(new UpdateZCoordinateSequenceFilter(0, 3)); if (CGAlgorithms.computeOrientation(c0, c1, c2) == CGAlgorithms.CLOCKWISE) { return lineString; } else { return (LineString) lineString.reverse(); } }
/** Create a nice Polygon from the given Polygon. Will ensure that shells are * clockwise and holes are counter-clockwise. * @param p The Polygon to make "nice". * @return The "nice" Polygon. */ public static Polygon makeGoodShapePolygon(Polygon p) { LinearRing outer; LinearRing[] holes = new LinearRing[p.getNumInteriorRing()]; Coordinate[] coords; coords = p.getExteriorRing().getCoordinates(); if (CGAlgorithms.isCCW(coords)) { outer = (LinearRing) p.getExteriorRing().reverse(); } else { outer = (LinearRing) p.getExteriorRing(); } for (int t = 0, tt = p.getNumInteriorRing(); t < tt; t++) { coords = p.getInteriorRingN(t).getCoordinates(); if (!(CGAlgorithms.isCCW(coords))) { holes[t] = (LinearRing) p.getInteriorRingN(t).reverse(); } else { holes[t] = (LinearRing) p.getInteriorRingN(t); } } return FACTORY.createPolygon(outer, holes); }