public String allStopsWithCorrectLink() { for (StopTime stopTime : trip.getStopTimes().values()) { Stop stop = stops.get(stopTime.getStopId()); Link link = network.getLinks().get(Id.create(stop.getLinkId(), Link.class)); Point2D fromPoint = new Point2D(link.getFromNode().getCoord().getX(), link.getFromNode().getCoord().getY()); Point2D toPoint = new Point2D(link.getToNode().getCoord().getX(), link.getToNode().getCoord().getY()); Line2D linkLine = new Line2D(fromPoint, toPoint); Point2D point = new Point2D(stop.getPoint().getX(), stop.getPoint().getY()); if (!linkLine.isNearestInside(point)) { int pos = getLinkPosition(link.getId().toString()); if (pos == -1) return stopTime.getStopId(); if (pos == links.size() - 1 || pos == 0) return ""; Link link2 = links.get(pos + 1); fromPoint = new Point2D( link2.getFromNode().getCoord().getX(), link2.getFromNode().getCoord().getY()); toPoint = new Point2D(link2.getToNode().getCoord().getX(), link2.getToNode().getCoord().getY()); Line2D linkLine2 = new Line2D(fromPoint, toPoint); if (!(linkLine.getPointPosition(point).equals(Line2D.PointPosition.AFTER) && linkLine2.getPointPosition(point).equals(Line2D.PointPosition.BEFORE))) return stopTime.getStopId(); } } return ""; }
public int getIndexStop(String selectedStopId) { int i = 0; for (StopTime stopTime : trip.getStopTimes().values()) { if (stopTime.getStopId().equals(selectedStopId)) return i; i++; } return -1; }
public String getStopId(int pos) { int i = 0; for (StopTime stopTime : trip.getStopTimes().values()) { if (i == pos) return stopTime.getStopId(); i++; } return ""; }
public Collection<Link> getStopLinks() { Collection<Link> links = new ArrayList<Link>(); for (StopTime stopTime : trip.getStopTimes().values()) { String linkId = stops.get(stopTime.getStopId()).getLinkId(); if (linkId != null) links.add(network.getLinks().get(Id.create(linkId, Link.class))); } return links; }
public String allStopsWithInRouteLink() { for (StopTime stopTime : trip.getStopTimes().values()) { Stop stop = stops.get(stopTime.getStopId()); Link link = network.getLinks().get(Id.createLinkId(stop.getLinkId())); // Link link = network.getLinks().get(stop.getLinkId()); if (!links.contains(link)) return stopTime.getStopId(); } return ""; }
public String getIdNearestStop(double x, double y) { Coord coord = new Coord(x, y); String nearest = ""; double nearestDistance = Double.POSITIVE_INFINITY; for (StopTime stopTime : trip.getStopTimes().values()) { double distance = CoordUtils.calcEuclideanDistance(stops.get(stopTime.getStopId()).getPoint(), coord); if (distance < nearestDistance) { nearest = stopTime.getStopId(); nearestDistance = distance; } } return nearest; }
public void initStops() { for (StopTime stopTime : trip.getStopTimes().values()) stops.get(stopTime.getStopId()).setLinkId(null); }
public String allStopsWithLink() { for (StopTime stopTime : trip.getStopTimes().values()) if (stops.get(stopTime.getStopId()).getLinkId() == null) return stopTime.getStopId(); return ""; }
public Collection<Coord> getStopPoints() { Collection<Coord> points = new ArrayList<Coord>(); for (StopTime stopTime : trip.getStopTimes().values()) points.add(stops.get(stopTime.getStopId()).getPoint()); return points; }