-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add car ferry functionality #5966
Changes from 7 commits
b70c9d6
3efe676
a555f3d
5afc63c
0f574e8
c644034
54752ba
fe06720
7e1022f
f3e982b
1d36e7c
8c8ad82
39634b5
232eaec
9958ffc
02aaf42
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package org.opentripplanner.apis.gtfs.mapping; | ||
|
||
import javax.annotation.Nonnull; | ||
import org.opentripplanner.apis.gtfs.generated.GraphQLTypes.GraphQLCarsAllowed; | ||
import org.opentripplanner.transit.model.network.CarAccess; | ||
|
||
public class CarsAllowedMapper { | ||
|
||
@Nonnull | ||
public static GraphQLCarsAllowed map(@Nonnull CarAccess carsAllowed) { | ||
habrahamsson-skanetrafiken marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return switch (carsAllowed) { | ||
case UNKNOWN -> GraphQLCarsAllowed.NO_INFORMATION; | ||
case ALLOWED -> GraphQLCarsAllowed.ALLOWED; | ||
case NOT_ALLOWED -> GraphQLCarsAllowed.NOT_ALLOWED; | ||
}; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,7 @@ | |
import org.opentripplanner.street.model.vertex.VehicleParkingEntranceVertex; | ||
import org.opentripplanner.street.search.TraverseMode; | ||
import org.opentripplanner.street.search.TraverseModeSet; | ||
import org.opentripplanner.transit.model.network.CarAccess; | ||
import org.opentripplanner.transit.model.site.GroupStop; | ||
import org.opentripplanner.transit.model.site.RegularStop; | ||
import org.opentripplanner.transit.model.site.StopLocation; | ||
|
@@ -102,6 +103,31 @@ public void linkTransitStops(Graph graph, TransitModel transitModel) { | |
); | ||
} | ||
|
||
// The stops that are used by transit capable of transporting cars need to be connected to the road network (e.g. car ferries). | ||
Set<StopLocation> stopLocationsUsedForCarsAllowedTrips = Set.of(); | ||
stopLocationsUsedForCarsAllowedTrips = | ||
transitModel | ||
.getAllTripPatterns() | ||
.stream() | ||
.filter(t -> | ||
t | ||
.getScheduledTimetable() | ||
.getTripTimes() | ||
.stream() | ||
.anyMatch(tt -> tt.getTrip().getCarsAllowed() == CarAccess.ALLOWED) | ||
) | ||
.flatMap(t -> t.getStops().stream()) | ||
.collect(Collectors.toSet()); | ||
|
||
stopLocationsUsedForCarsAllowedTrips.addAll( | ||
stopLocationsUsedForCarsAllowedTrips | ||
.stream() | ||
.filter(GroupStop.class::isInstance) | ||
.map(GroupStop.class::cast) | ||
.flatMap(g -> g.getChildLocations().stream().filter(RegularStop.class::isInstance)) | ||
.toList() | ||
); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you extract that into a method and convert the line comments to Javadoc? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. actually, can also extract a method for the flex stops? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I created methods for both in the |
||
|
||
for (TransitStopVertex tStop : vertices) { | ||
// Stops with pathways do not need to be connected to the street network, since there are explicit entrances defined for that | ||
if (tStop.hasPathways()) { | ||
|
@@ -116,7 +142,10 @@ public void linkTransitStops(Graph graph, TransitModel transitModel) { | |
StopLinkType linkType = StopLinkType.WALK_ONLY; | ||
|
||
if ( | ||
OTPFeature.FlexRouting.isOn() && stopLocationsUsedForFlexTrips.contains(tStop.getStop()) | ||
( | ||
OTPFeature.FlexRouting.isOn() && stopLocationsUsedForFlexTrips.contains(tStop.getStop()) | ||
) || | ||
stopLocationsUsedForCarsAllowedTrips.contains(tStop.getStop()) | ||
) { | ||
linkType = StopLinkType.WALK_AND_CAR; | ||
} | ||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,22 @@ | ||||||||||||||||||||||||||||
package org.opentripplanner.gtfs.mapping; | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
import org.onebusaway.gtfs.model.Trip; | ||||||||||||||||||||||||||||
import org.opentripplanner.transit.model.network.CarAccess; | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
/** | ||||||||||||||||||||||||||||
* Model car access for GTFS trips. | ||||||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||||||
class CarAccessMapper { | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
public static CarAccess mapForTrip(Trip rhs) { | ||||||||||||||||||||||||||||
int carsAllowed = rhs.getCarsAllowed(); | ||||||||||||||||||||||||||||
switch (carsAllowed) { | ||||||||||||||||||||||||||||
case 1: | ||||||||||||||||||||||||||||
return CarAccess.ALLOWED; | ||||||||||||||||||||||||||||
case 2: | ||||||||||||||||||||||||||||
return CarAccess.NOT_ALLOWED; | ||||||||||||||||||||||||||||
default: | ||||||||||||||||||||||||||||
return CarAccess.UNKNOWN; | ||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I changed it to this |
||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package org.opentripplanner.transit.model.network; | ||
|
||
/** | ||
* GTFS codes: | ||
* 0 = unknown / unspecified, 1 = cars allowed, 2 = cars NOT allowed | ||
habrahamsson-skanetrafiken marked this conversation as resolved.
Show resolved
Hide resolved
|
||
*/ | ||
public enum CarAccess { | ||
UNKNOWN, | ||
NOT_ALLOWED, | ||
ALLOWED, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't seem to be used at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is now removed