use of org.opentripplanner.graph_builder.issues.MissingProjectionInServiceLink in project OpenTripPlanner by opentripplanner.
the class ServiceLinkMapper method addStraightLine.
private void addStraightLine(ServiceLink serviceLink, MutableInt sequenceCounter, MutableDouble distanceCounter, ReadOnlyHierarchicalMap<String, String> quayIdByStopPointRef, ReadOnlyHierarchicalVersionMapById<Quay> quayById, Collection<ShapePoint> shapePoints, FeedScopedId shapePointIdFromJourneyPatternId) {
String fromPointQuayId = quayIdByStopPointRef.lookup(serviceLink.getFromPointRef().getRef());
Quay fromPointQuay = quayById.lookupLastVersionById(fromPointQuayId);
String toPointQuayId = quayIdByStopPointRef.lookup(serviceLink.getToPointRef().getRef());
Quay toPointQuay = quayById.lookupLastVersionById(toPointQuayId);
if (fromPointQuay != null && fromPointQuay.getCentroid() != null && toPointQuay != null && toPointQuay.getCentroid() != null) {
issueStore.add(new MissingProjectionInServiceLink(serviceLink.getId()));
ShapePoint fromShapePoint = new ShapePoint();
fromShapePoint.setShapeId(shapePointIdFromJourneyPatternId);
fromShapePoint.setLat(fromPointQuay.getCentroid().getLocation().getLatitude().doubleValue());
fromShapePoint.setLon(fromPointQuay.getCentroid().getLocation().getLongitude().doubleValue());
fromShapePoint.setSequence(sequenceCounter.toInteger());
fromShapePoint.setDistTraveled(distanceCounter.getValue());
shapePoints.add(fromShapePoint);
sequenceCounter.increment();
ShapePoint toShapePoint = new ShapePoint();
toShapePoint.setShapeId(shapePointIdFromJourneyPatternId);
toShapePoint.setLat(toPointQuay.getCentroid().getLocation().getLatitude().doubleValue());
toShapePoint.setLon(toPointQuay.getCentroid().getLocation().getLongitude().doubleValue());
toShapePoint.setSequence(sequenceCounter.toInteger());
shapePoints.add(toShapePoint);
sequenceCounter.increment();
double distance;
if (serviceLink.getDistance() != null) {
distance = serviceLink.getDistance().doubleValue();
} else {
Coordinate fromCoord = new Coordinate(fromShapePoint.getLon(), fromShapePoint.getLat());
Coordinate toCoord = new Coordinate(toShapePoint.getLon(), toShapePoint.getLat());
distance = SphericalDistanceLibrary.distance(fromCoord, toCoord);
}
distanceCounter.add(distance);
toShapePoint.setDistTraveled(distanceCounter.doubleValue());
} else {
LOG.warn("Ignore service link without projection and missing or unknown quays: " + serviceLink);
}
}
Aggregations