本文整理汇总了Java中net.java.pathfinder.api.TransitPath类的典型用法代码示例。如果您正苦于以下问题:Java TransitPath类的具体用法?Java TransitPath怎么用?Java TransitPath使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TransitPath类属于net.java.pathfinder.api包,在下文中一共展示了TransitPath类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fetchRoutesForSpecification
import net.java.pathfinder.api.TransitPath; //导入依赖的package包/类
@Override
public List<Itinerary> fetchRoutesForSpecification(
RouteSpecification routeSpecification) {
// The RouteSpecification is picked apart and adapted to the external API.
String origin = routeSpecification.getOrigin().getUnLocode().getIdString();
String destination = routeSpecification.getDestination().getUnLocode()
.getIdString();
List<TransitPath> transitPaths = graphTraversalResource.findShortestPath(origin, destination, null);
// .queryParam("origin", origin)
// .queryParam("destination", destination)
// .request(MediaType.APPLICATION_JSON_TYPE)
// .get(new GenericType<List<TransitPath>>() {
// });
// The returned result is then translated back into our domain model.
List<Itinerary> itineraries = new ArrayList<>();
for (TransitPath transitPath : transitPaths) {
Itinerary itinerary = toItinerary(transitPath);
// Use the specification to safe-guard against invalid itineraries
if (routeSpecification.isSatisfiedBy(itinerary)) {
itineraries.add(itinerary);
} else {
log.log(Level.FINE,
"Received itinerary that did not satisfy the route specification");
}
}
return itineraries;
}
示例2: toItinerary
import net.java.pathfinder.api.TransitPath; //导入依赖的package包/类
private Itinerary toItinerary(TransitPath transitPath) {
List<Leg> legs = new ArrayList<>(transitPath.getTransitEdges().size());
for (TransitEdge edge : transitPath.getTransitEdges()) {
legs.add(toLeg(edge));
}
return new Itinerary(legs);
}
示例3: fetchRoutesForSpecification
import net.java.pathfinder.api.TransitPath; //导入依赖的package包/类
@Override
public List<Itinerary> fetchRoutesForSpecification(
RouteSpecification routeSpecification) {
// The RouteSpecification is picked apart and adapted to the external API.
String origin = routeSpecification.getOrigin().getUnLocode().getIdString();
String destination = routeSpecification.getDestination().getUnLocode()
.getIdString();
List<TransitPath> transitPaths = graphTraversalResource
.queryParam("origin", origin)
.queryParam("destination", destination)
.request(MediaType.APPLICATION_JSON_TYPE)
.get(new GenericType<List<TransitPath>>() {
});
// The returned result is then translated back into our domain model.
List<Itinerary> itineraries = new ArrayList<>();
for (TransitPath transitPath : transitPaths) {
Itinerary itinerary = toItinerary(transitPath);
// Use the specification to safe-guard against invalid itineraries
if (routeSpecification.isSatisfiedBy(itinerary)) {
itineraries.add(itinerary);
} else {
log.log(Level.FINE,
"Received itinerary that did not satisfy the route specification");
}
}
return itineraries;
}