Package org.onebusaway.uk.network_rail.cif

Examples of org.onebusaway.uk.network_rail.cif.TimepointElement


    }
    int stanox = Integer.parseInt(body.getLocStanox());
    trainInstance.setLastStanox(time, stanox);

    List<TimepointElement> timepoints = trainInstance.getTimepointForStanox(stanox);
    TimepointElement timepoint = null;
    if (!timepoints.isEmpty()) {
      _statisticsService.incrementUnknownStanoxCount();
      timepoint = getBestTimepointForTrainMovement(timepoints, body);
    }

    if (body.getActualTimestamp() != null
        && !body.getActualTimestamp().isEmpty()
        && body.getPlannedTimestamp() != null
        && !body.getPlannedTimestamp().isEmpty()) {
      long actualTimestamp = Long.parseLong(body.getActualTimestamp());
      long plannedTimestamp = Long.parseLong(body.getPlannedTimestamp());
      int scheduleDeviation = (int) ((actualTimestamp - plannedTimestamp) / 1000);
      trainInstance.setScheduleDeviation(scheduleDeviation);
    } else if (timepoint != null) {
      long expectedTime = getTimeForTimepoint(trainInstance, timepoint);
      int scheduleDeviation = (int) ((time - expectedTime) / 1000);
      trainInstance.setScheduleDeviation(scheduleDeviation);
    }

    if (body.getPlatform() != null && timepoint != null) {
      String platform = body.getPlatform().trim();
      if (!platform.isEmpty() && !platform.equals(timepoint.getPlatform())) {
        _statisticsService.incrementPlatformChange();
      }
    }
  }
View Full Code Here


    List<TimepointElement> timepoints = schedule.getTimepoints();
    if (timepoints.isEmpty()) {
      return false;
    }

    TimepointElement firstTimepoint = timepoints.get(0);
    long firstTime = getTimeForTimepoint(trainInstance, firstTimepoint);
    TimepointElement lastTimepoint = timepoints.get(timepoints.size() - 1);
    long lastTime = getTimeForTimepoint(trainInstance, lastTimepoint);
    if (time <= firstTime) {
      if (firstTime - time < _timepointMatchThreshold
          && hasStanoxAreaMatch(firstTimepoint, stanoxAreaIds)) {
        return true;
      }
    } else if (time >= lastTime) {
      if (time - lastTime < _timepointMatchThreshold
          && hasStanoxAreaMatch(lastTimepoint, stanoxAreaIds)) {
        return true;
      }
    } else {
      for (int i = 0; i < timepoints.size() - 1; ++i) {
        TimepointElement from = timepoints.get(i);
        TimepointElement to = timepoints.get(i + 1);
        long fromTime = getTimeForTimepoint(trainInstance, from);
        long toTime = getTimeForTimepoint(trainInstance, to);
        if (fromTime <= time && time <= toTime) {
          return hasStanoxAreaMatch(from, stanoxAreaIds)
              || hasStanoxAreaMatch(to, stanoxAreaIds);
View Full Code Here

    if (body.getLocStanox() == null) {
      _statisticsService.incrementEmptyLocStanoxCount();
    }
    int stanox = Integer.parseInt(body.getLocStanox());
    TimepointElement timepoint = null; // what?
    if (timepoint == null) {
      _statisticsService.incrementUnknownStanoxCount();
      return;
    }

    if (body.getPlatform() != null) {
      String platform = body.getPlatform().trim();
      if (!platform.isEmpty() && !platform.equals(timepoint.getPlatform())) {
        _statisticsService.incrementPlatformChange();
      }
    }

    _narrativeService.addMessage(instance, "movement: stanox=" + stanox
        + " tiploc=" + timepoint.getTiploc());

    if (body.getActualTimestamp().isEmpty()
        || body.getPlannedTimestamp().isEmpty()) {
      return;
    }

    long actualTimestamp = Long.parseLong(body.getActualTimestamp());
    long plannedTimestamp = Long.parseLong(body.getPlannedTimestamp());
    int delay = (int) ((actualTimestamp - plannedTimestamp) / 1000);

    StopTimeEvent.Builder departure = StopTimeEvent.newBuilder();
    departure.setDelay(delay);

    StopTimeUpdate.Builder stopTimeUpdate = StopTimeUpdate.newBuilder();
    stopTimeUpdate.setStopId(timepoint.getTiploc());
    stopTimeUpdate.setDeparture(departure);

    instance.setStopTimeUpdate(stopTimeUpdate.build());
  }
View Full Code Here

TOP

Related Classes of org.onebusaway.uk.network_rail.cif.TimepointElement

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.