我尝试通过代码排除停止路由。 我创建了gtfs实时警报
public class ServiceAlertStop {
GtfsRealtime.FeedMessage feedMessage;
public GtfsRealtime.FeedMessage config(){
GtfsRealtime.FeedMessage.Builder feedMessageBuilder =
GtfsRealtime.FeedMessage.newBuilder();
GtfsRealtime.FeedHeader.Builder header =
GtfsRealtime.FeedHeader.newBuilder();
header.setTimestamp(System.currentTimeMillis());
header.setIncrementality(GtfsRealtime.FeedHeader.
Incrementality.FULL_DATASET);
header.setGtfsRealtimeVersion("1.0");
feedMessageBuilder.setHeader(header);
GtfsRealtime.FeedEntity.Builder entity =
GtfsRealtime.FeedEntity.newBuilder();
entity.setId("0");
GtfsRealtime.Alert.Builder alert = GtfsRealtime.Alert.newBuilder();
alert.setCause(GtfsRealtime.Alert.Cause.UNKNOWN_CAUSE);
alert.setEffect(GtfsRealtime.Alert.Effect.STOP_MOVED);
GtfsRealtime.TimeRange.Builder activePeriod =
alert.addActivePeriodBuilder();
activePeriod.setStart(System.currentTimeMillis());
activePeriod.setEnd(System.currentTimeMillis() + 172800000);
GtfsRealtime.TranslatedString.Builder translatedString =
GtfsRealtime.TranslatedString.newBuilder();
GtfsRealtime.TranslatedString.Translation.Builder translation =
GtfsRealtime.TranslatedString.Translation.newBuilder();
translation.setLanguage("en");
translation.setText("Stop is closed!");
translatedString.addTranslation(translation);
alert.setDescriptionText(translatedString);
alert.setHeaderText(translatedString);
GtfsRealtime.EntitySelector.Builder entitySelector =
alert.addInformedEntityBuilder();
entitySelector.setStopId("22126");
entity.setAlert(alert);
feedMessageBuilder.addEntity(entity);
feedMessage = feedMessageBuilder.build();
return feedMessage;
}
public void run(Graph graph){
AlertsUpdateHandler updateHandler = new AlertsUpdateHandler();
updateHandler.setEarlyStart(1);
updateHandler.setFeedId("1");
updateHandler.setAlertPatchService(new AlertPatchServiceImpl(graph));
updateHandler.setFuzzyTripMatcher(new
GtfsRealtimeFuzzyTripMatcher(graph.index));
updateHandler.update(feedMessage);
}
}
我的警报的ASCII表示
header {
gtfs_realtime_version: "1.0"
incrementality: FULL_DATASET
timestamp: 1493520112381
}
entity {
id: "0"
alert {
active_period {
start: 1493520112415
end: 1493692912415
}
informed_entity {
stop_id: "22126"
}
cause: UNKNOWN_CAUSE
effect: STOP_MOVED
header_text {
translation {
text: "Stop is closed!"
language: "en"
}
}
description_text {
translation {
text: "Stop is closed!"
language: "en"
}
}
}
}
然后我在构建图之后在otp中加载它,在类OTPMain.java中
ServiceAlertStop serviceAlertStop = new ServiceAlertStop();
serviceAlertStop.config();
serviceAlertStop.run(graphService.getRouter().graph);
之后我没有收到错误,但是当我开始计划旅行时,这个停止(22126)也存在于新路线中((我需要otp不要使用此停止。是否可以排除停止路由代码?
答案 0 :(得分:0)
如果您使用OpenTripPlanner API进行旅行计划,则会有一个“禁止停止”#S;并且' bannedStopsHard'您可以在plan API call中设置的参数将强制路由器忽略停止。