示例#1
0
 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 "";
 }
示例#2
0
 public int getIndexStop(String selectedStopId) {
   int i = 0;
   for (StopTime stopTime : trip.getStopTimes().values()) {
     if (stopTime.getStopId().equals(selectedStopId)) return i;
     i++;
   }
   return -1;
 }
示例#3
0
 public String getStopId(int pos) {
   int i = 0;
   for (StopTime stopTime : trip.getStopTimes().values()) {
     if (i == pos) return stopTime.getStopId();
     i++;
   }
   return "";
 }
示例#4
0
 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;
 }
示例#5
0
 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 "";
 }
示例#6
0
 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;
 }
示例#7
0
 public void initStops() {
   for (StopTime stopTime : trip.getStopTimes().values())
     stops.get(stopTime.getStopId()).setLinkId(null);
 }
示例#8
0
 public String allStopsWithLink() {
   for (StopTime stopTime : trip.getStopTimes().values())
     if (stops.get(stopTime.getStopId()).getLinkId() == null) return stopTime.getStopId();
   return "";
 }
示例#9
0
 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;
 }