Skip to content

Merge B+R and P+R functionality into vehicle parking - #3480

Merged
flaktack merged 42 commits into
opentripplanner:dev-2.xfrom
realCity:feature/vehicle-parking
Nov 10, 2021
Merged

flaktack merged 42 commits into
opentripplanner:dev-2.xfrom
realCity:feature/vehicle-parking

Conversation

@flaktack

@flaktack flaktack commented May 12, 2021 •

Copy link
Copy Markdown
Contributor

Summary

B+R and P+R functionality is merged into a unified vehicle parking.

Major changes:

  • RoutingRequest#bikeParkAndRide is removed so that only RouteingRequest#parkAndRide is used
  • carParkTime and carParkCost are added to RoutingRequest to match bikeParkTime and bikeParkCost
  • The loading of B+R and P+R data from OSM is combined, so that both work in the same manner. With this nodes are handled for amenity=parking, while areas are handled for amenity=bicycle_parking. The area handling / code is updated to allow linking to inner rings. If present, capacity information is also parsed.
  • Explicit entrances are supported with traversal restrictions (walk-only, car-only), with each entrance having a VehicleParkingEntranceVertex connected to the street network with a StreetVehicleParkingLink. Between entrances (including itself) there are VehicleParkingEdges.
    Before and After pictures of the graph:
    image image

Issue

This is the first part of #3432

closes #3423

Unit tests

The existing tests were updated where needed and BikeParkAndRide and CarParkAndRide tests are added.

Code style

☑️

Documentation

No changes.

Changelog

Not yet - TODO.

@flaktack
flaktack force-pushed the feature/vehicle-parking branch from c041e3e to c7e411b Compare May 17, 2021 12:12

@leonardehrenfried leonardehrenfried left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a few smaller requests but this is a good PR.

@t2gran

t2gran commented May 18, 2021

Copy link
Copy Markdown
Member

Is a VehicleParking either a CarParking or a BikeParking, or could one instance be both? The reason I ask is that the VehicleParking classes have car/bike specific attributes. A cleaner design would put those attributes into separate classes. If the VehicleParking is either or, then you may use inheritance, if not, "part-of" classes like BikeParkingAttributes is needed.

During routing, I expect the super type will simplify the code, but on the API I am not so sure. I don´t know the use cases. An alternative to the suggested implementation is to have a VehicleParking in the internal model, and specific types on the API.

@flaktack
flaktack force-pushed the feature/vehicle-parking branch 2 times, most recently from a4665ca to 6e36b4a Compare May 19, 2021 14:34
@flaktack

Copy link
Copy Markdown
Contributor Author

Is a VehicleParking either a CarParking or a BikeParking, or could one instance be both? The reason I ask is that the VehicleParking classes have car/bike specific attributes. A cleaner design would put those attributes into separate classes. If the VehicleParking is either or, then you may use inheritance, if not, "part-of" classes like BikeParkingAttributes is needed.

One instance could be both, it is allowed to have both car and bicycle parking in one VehicleParking. While some attributes are either bicycle or car specific, I don't see "part-of" classes as simplifying things (and the same goes for restricting a VehicleParking to be bike or car only).

During routing, I expect the super type will simplify the code, but on the API I am not so sure. I don´t know the use cases. An alternative to the suggested implementation is to have a VehicleParking in the internal model, and specific types on the API.

The distinct bikePark and carPark methods were kept in the Legacy GraphQL APIs to avoid too many changes -- I would prefer having the APIs also using a single parking class, with the client being allowed to filter as needed.

I've added commits to restore two of the sandbox APIs to their previous functionality, so that there is no API change.

@flaktack
flaktack marked this pull request as ready for review May 19, 2021 17:33
@flaktack
flaktack requested a review from a team as a code owner May 19, 2021 17:33

@leonardehrenfried leonardehrenfried left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that the two APIs a backwards compatible I approve this.

If someone wants to use the combined vehicle parking then they can use the new entity.

@leonardehrenfried leonardehrenfried left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had a change of heart and would like the legacy graphql API to stay 100% compatible as it would otherwise cause our frontend migration to run into problems.

@leonardehrenfried

Copy link
Copy Markdown
Member

Why do I think that is important? I used to think that we never request the bikePark entity but after having thought it through, I noticed that it's used in places like this: https://github.com/HSLdevcom/digitransit-ui/blob/next/app/component/SummaryPage.js#L697-L700

It will be difficult for us to find all the places where this is used so would it be possible to add a translation layer to emulate the old API?

@hannesj

hannesj commented May 20, 2021

Copy link
Copy Markdown
Contributor

One way would be to add the new types and fields and mark the old fields as deprecated with the @deprecated directive with a suitable removal time. After that, you can check the deprecated fields in the clients using an eslint plugin and remove the deprecated fields in the future.


"""The car parking related to the place"""
carPark: CarPark
carPark: VehicleParking

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In order to keep backwards compatibility with digitransit we need to keep this a CarPark. Can you please change that?


"""The bike parking related to the place"""
bikePark: BikePark
bikePark: VehicleParking

@leonardehrenfried leonardehrenfried May 26, 2021 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In order to keep backwards compatibility with digitransit we need to keep this a BikePark. Can you please change that type and adapt output?

@leonardehrenfried leonardehrenfried left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had a think about it and would like to keep the LegacyGraphQl API 100% compatible.

@leonardehrenfried

Copy link
Copy Markdown
Member

Thanks for the backwards compat.

I'm still seeing errors when createing routes with a VEHICLEPARK vertex type.

Query

curl 'http://localhost:8080/otp/routers/default/index/graphql' -H 'User-Agent: Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:88.0) Gecko/20100101 Firefox/88.0' -H 'Accept: */*' -H 'Accept-Language: en-US,en;q=0.7,de;q=0.3' --compressed -H 'Referer: http://localhost:9090/' -H 'OTPTimeout: 12000' -H 'Content-Type: application/json' -H 'Origin: http://localhost:9090' -H 'DNT: 1' -H 'Connection: keep-alive' -H 'Pragma: no-cache' -H 'Cache-Control: no-cache' --data-raw $'{"id":"SummaryPage_WalkBike_Query","query":"query SummaryPage_WalkBike_Query(\\n  $fromPlace: String\041\\n  $toPlace: String\041\\n  $intermediatePlaces: [InputCoordinates\041]\\n  $date: String\041\\n  $time: String\041\\n  $walkReluctance: Float\\n  $walkBoardCost: Int\\n  $minTransferTime: Int\\n  $walkSpeed: Float\\n  $bikeAndPublicMaxWalkDistance: Float\\n  $wheelchair: Boolean\\n  $ticketTypes: [String]\\n  $bikeandPublicDisableRemainingWeightHeuristic: Boolean\\n  $arriveBy: Boolean\\n  $transferPenalty: Int\\n  $bikeSpeed: Float\\n  $optimize: OptimizeType\\n  $triangle: InputTriangle\\n  $itineraryFiltering: Float\\n  $unpreferred: InputUnpreferred\\n  $locale: String\\n  $shouldMakeWalkQuery: Boolean\041\\n  $shouldMakeBikeQuery: Boolean\041\\n  $shouldMakeCarQuery: Boolean\041\\n  $shouldMakeParkRideQuery: Boolean\041\\n  $showBikeAndPublicItineraries: Boolean\041\\n  $showBikeAndParkItineraries: Boolean\041\\n  $bikeAndPublicModes: [TransportMode\041]\\n  $bikeParkModes: [TransportMode\041]\\n) {\\n  walkPlan: plan(fromPlace: $fromPlace, toPlace: $toPlace, intermediatePlaces: $intermediatePlaces, transportModes: [{mode: WALK}], date: $date, time: $time, walkSpeed: $walkSpeed, wheelchair: $wheelchair, arriveBy: $arriveBy, locale: $locale) @include(if: $shouldMakeWalkQuery) {\\n    ...SummaryPlanContainer_plan\\n    ...ItineraryTab_plan\\n    itineraries {\\n      walkDistance\\n      duration\\n      startTime\\n      endTime\\n      ...ItineraryTab_itinerary\\n      ...SummaryPlanContainer_itineraries\\n      legs {\\n        mode\\n        ...ItineraryLine_legs\\n        legGeometry {\\n          points\\n        }\\n        distance\\n      }\\n    }\\n  }\\n  bikePlan: plan(fromPlace: $fromPlace, toPlace: $toPlace, intermediatePlaces: $intermediatePlaces, transportModes: [{mode: BICYCLE}], date: $date, time: $time, walkSpeed: $walkSpeed, arriveBy: $arriveBy, bikeSpeed: $bikeSpeed, optimize: $optimize, triangle: $triangle, locale: $locale) @include(if: $shouldMakeBikeQuery) {\\n    ...SummaryPlanContainer_plan\\n    ...ItineraryTab_plan\\n    itineraries {\\n      duration\\n      startTime\\n      endTime\\n      ...ItineraryTab_itinerary\\n      ...SummaryPlanContainer_itineraries\\n      legs {\\n        mode\\n        ...ItineraryLine_legs\\n        legGeometry {\\n          points\\n        }\\n        distance\\n      }\\n    }\\n  }\\n  bikeAndPublicPlan: plan(fromPlace: $fromPlace, toPlace: $toPlace, intermediatePlaces: $intermediatePlaces, numItineraries: 6, transportModes: $bikeAndPublicModes, date: $date, time: $time, walkReluctance: $walkReluctance, walkBoardCost: $walkBoardCost, minTransferTime: $minTransferTime, walkSpeed: $walkSpeed, maxWalkDistance: $bikeAndPublicMaxWalkDistance, allowedTicketTypes: $ticketTypes, disableRemainingWeightHeuristic: $bikeandPublicDisableRemainingWeightHeuristic, arriveBy: $arriveBy, transferPenalty: $transferPenalty, bikeSpeed: $bikeSpeed, optimize: $optimize, triangle: $triangle, itineraryFiltering: $itineraryFiltering, unpreferred: $unpreferred, locale: $locale) @include(if: $showBikeAndPublicItineraries) {\\n    ...SummaryPlanContainer_plan\\n    ...ItineraryTab_plan\\n    itineraries {\\n      duration\\n      startTime\\n      endTime\\n      ...ItineraryTab_itinerary\\n      ...SummaryPlanContainer_itineraries\\n      legs {\\n        mode\\n        ...ItineraryLine_legs\\n        transitLeg\\n        legGeometry {\\n          points\\n        }\\n        route {\\n          gtfsId\\n          id\\n        }\\n        trip {\\n          gtfsId\\n          directionId\\n          stoptimesForDate {\\n            scheduledDeparture\\n          }\\n          pattern {\\n            ...RouteLine_pattern\\n            id\\n          }\\n          id\\n        }\\n        distance\\n      }\\n    }\\n  }\\n  bikeParkPlan: plan(fromPlace: $fromPlace, toPlace: $toPlace, intermediatePlaces: $intermediatePlaces, numItineraries: 6, transportModes: $bikeParkModes, date: $date, time: $time, walkReluctance: $walkReluctance, walkBoardCost: $walkBoardCost, minTransferTime: $minTransferTime, walkSpeed: $walkSpeed, maxWalkDistance: $bikeAndPublicMaxWalkDistance, allowedTicketTypes: $ticketTypes, disableRemainingWeightHeuristic: $bikeandPublicDisableRemainingWeightHeuristic, arriveBy: $arriveBy, transferPenalty: $transferPenalty, bikeSpeed: $bikeSpeed, optimize: $optimize, triangle: $triangle, itineraryFiltering: $itineraryFiltering, unpreferred: $unpreferred, locale: $locale) @include(if: $showBikeAndParkItineraries) {\\n    ...SummaryPlanContainer_plan\\n    ...ItineraryTab_plan\\n    itineraries {\\n      duration\\n      startTime\\n      endTime\\n      ...ItineraryTab_itinerary\\n      ...SummaryPlanContainer_itineraries\\n      legs {\\n        mode\\n        ...ItineraryLine_legs\\n        transitLeg\\n        legGeometry {\\n          points\\n        }\\n        route {\\n          gtfsId\\n          id\\n        }\\n        trip {\\n          gtfsId\\n          directionId\\n          stoptimesForDate {\\n            scheduledDeparture\\n          }\\n          pattern {\\n            ...RouteLine_pattern\\n            id\\n          }\\n          id\\n        }\\n        to {\\n          bikePark {\\n            bikeParkId\\n            name\\n            id\\n          }\\n        }\\n        distance\\n      }\\n    }\\n  }\\n  carPlan: plan(fromPlace: $fromPlace, toPlace: $toPlace, intermediatePlaces: $intermediatePlaces, numItineraries: 6, transportModes: [{mode: CAR}], date: $date, time: $time, walkReluctance: $walkReluctance, walkBoardCost: $walkBoardCost, minTransferTime: $minTransferTime, walkSpeed: $walkSpeed, maxWalkDistance: $bikeAndPublicMaxWalkDistance, allowedTicketTypes: $ticketTypes, arriveBy: $arriveBy, transferPenalty: $transferPenalty, bikeSpeed: $bikeSpeed, optimize: $optimize, triangle: $triangle, itineraryFiltering: $itineraryFiltering, unpreferred: $unpreferred, locale: $locale) @include(if: $shouldMakeCarQuery) {\\n    ...SummaryPlanContainer_plan\\n    ...ItineraryTab_plan\\n    itineraries {\\n      duration\\n      startTime\\n      endTime\\n      ...ItineraryTab_itinerary\\n      ...SummaryPlanContainer_itineraries\\n      legs {\\n        startTime\\n        mode\\n        ...ItineraryLine_legs\\n        transitLeg\\n        legGeometry {\\n          points\\n        }\\n        route {\\n          gtfsId\\n          id\\n        }\\n        trip {\\n          gtfsId\\n          directionId\\n          stoptimesForDate {\\n            scheduledDeparture\\n          }\\n          pattern {\\n            ...RouteLine_pattern\\n            id\\n          }\\n          id\\n        }\\n        from {\\n          name\\n          lat\\n          lon\\n        }\\n        to {\\n          name\\n          lat\\n          lon\\n        }\\n        distance\\n      }\\n    }\\n  }\\n  parkRidePlan: plan(fromPlace: $fromPlace, toPlace: $toPlace, intermediatePlaces: $intermediatePlaces, numItineraries: 6, transportModes: [{mode: CAR, qualifier: PARK}, {mode: TRANSIT}], date: $date, time: $time, walkReluctance: $walkReluctance, walkBoardCost: $walkBoardCost, minTransferTime: $minTransferTime, walkSpeed: $walkSpeed, maxWalkDistance: $bikeAndPublicMaxWalkDistance, allowedTicketTypes: $ticketTypes, arriveBy: $arriveBy, transferPenalty: $transferPenalty, bikeSpeed: $bikeSpeed, optimize: $optimize, triangle: $triangle, itineraryFiltering: $itineraryFiltering, unpreferred: $unpreferred, locale: $locale) @include(if: $shouldMakeParkRideQuery) {\\n    ...SummaryPlanContainer_plan\\n    ...ItineraryTab_plan\\n    itineraries {\\n      duration\\n      startTime\\n      endTime\\n      ...ItineraryTab_itinerary\\n      ...SummaryPlanContainer_itineraries\\n      legs {\\n        mode\\n        ...ItineraryLine_legs\\n        transitLeg\\n        legGeometry {\\n          points\\n        }\\n        route {\\n          gtfsId\\n          id\\n        }\\n        trip {\\n          gtfsId\\n          directionId\\n          stoptimesForDate {\\n            scheduledDeparture\\n          }\\n          pattern {\\n            ...RouteLine_pattern\\n            id\\n          }\\n          id\\n        }\\n        to {\\n          carPark {\\n            carParkId\\n            name\\n            id\\n          }\\n          name\\n        }\\n        distance\\n      }\\n    }\\n  }\\n}\\n\\nfragment ItineraryLine_legs on Leg {\\n  mode\\n  rentedBike\\n  startTime\\n  endTime\\n  distance\\n  legGeometry {\\n    points\\n  }\\n  transitLeg\\n  route {\\n    shortName\\n    color\\n    agency {\\n      name\\n      id\\n    }\\n    id\\n  }\\n  from {\\n    lat\\n    lon\\n    name\\n    vertexType\\n    bikeRentalStation {\\n      lat\\n      lon\\n      stationId\\n      networks\\n      bikesAvailable\\n      id\\n    }\\n    stop {\\n      gtfsId\\n      code\\n      platformCode\\n      id\\n    }\\n  }\\n  to {\\n    lat\\n    lon\\n    name\\n    vertexType\\n    bikeRentalStation {\\n      lat\\n      lon\\n      stationId\\n      networks\\n      bikesAvailable\\n      id\\n    }\\n    stop {\\n      gtfsId\\n      code\\n      platformCode\\n      id\\n    }\\n  }\\n  trip {\\n    stoptimes {\\n      stop {\\n        gtfsId\\n        id\\n      }\\n      pickupType\\n    }\\n    id\\n  }\\n  intermediatePlaces {\\n    arrivalTime\\n    stop {\\n      gtfsId\\n      lat\\n      lon\\n      name\\n      code\\n      platformCode\\n      id\\n    }\\n  }\\n}\\n\\nfragment ItinerarySummaryListContainer_itineraries on Itinerary {\\n  walkDistance\\n  startTime\\n  endTime\\n  legs {\\n    alerts {\\n      alertId\\n    }\\n    realTime\\n    realtimeState\\n    transitLeg\\n    startTime\\n    endTime\\n    mode\\n    distance\\n    duration\\n    rentedBike\\n    intermediatePlace\\n    intermediatePlaces {\\n      stop {\\n        zoneId\\n        id\\n      }\\n    }\\n    route {\\n      mode\\n      shortName\\n      color\\n      agency {\\n        name\\n        id\\n      }\\n      alerts {\\n        alertSeverityLevel\\n        effectiveEndDate\\n        effectiveStartDate\\n        trip {\\n          pattern {\\n            code\\n            id\\n          }\\n          id\\n        }\\n        id\\n      }\\n      id\\n    }\\n    trip {\\n      pattern {\\n        code\\n        id\\n      }\\n      stoptimes {\\n        realtimeState\\n        stop {\\n          gtfsId\\n          id\\n        }\\n        pickupType\\n      }\\n      id\\n    }\\n    from {\\n      name\\n      lat\\n      lon\\n      stop {\\n        gtfsId\\n        zoneId\\n        platformCode\\n        alerts {\\n          alertSeverityLevel\\n          effectiveEndDate\\n          effectiveStartDate\\n          id\\n        }\\n        id\\n      }\\n      bikeRentalStation {\\n        bikesAvailable\\n        networks\\n        id\\n      }\\n    }\\n    to {\\n      stop {\\n        gtfsId\\n        zoneId\\n        alerts {\\n          alertSeverityLevel\\n          effectiveEndDate\\n          effectiveStartDate\\n          id\\n        }\\n        id\\n      }\\n      bikePark {\\n        bikeParkId\\n        name\\n        id\\n      }\\n      carPark {\\n        carParkId\\n        name\\n        id\\n      }\\n    }\\n  }\\n}\\n\\nfragment ItineraryTab_itinerary on Itinerary {\\n  walkDistance\\n  duration\\n  startTime\\n  endTime\\n  arrivedAtDestinationWithRentedBicycle\\n  fares {\\n    cents\\n    components {\\n      cents\\n      fareId\\n      routes {\\n        agency {\\n          gtfsId\\n          fareUrl\\n          name\\n          id\\n        }\\n        gtfsId\\n        id\\n      }\\n    }\\n    type\\n  }\\n  legs {\\n    mode\\n    alerts {\\n      alertId\\n      alertDescriptionTextTranslations {\\n        language\\n        text\\n      }\\n    }\\n    ...LegAgencyInfo_leg\\n    from {\\n      lat\\n      lon\\n      name\\n      vertexType\\n      bikeRentalStation {\\n        networks\\n        bikesAvailable\\n        lat\\n        lon\\n        stationId\\n        id\\n      }\\n      stop {\\n        gtfsId\\n        code\\n        platformCode\\n        vehicleMode\\n        zoneId\\n        alerts {\\n          alertSeverityLevel\\n          effectiveEndDate\\n          effectiveStartDate\\n          trip {\\n            pattern {\\n              code\\n              id\\n            }\\n            id\\n          }\\n          alertHeaderText\\n          alertHeaderTextTranslations {\\n            text\\n            language\\n          }\\n          alertUrl\\n          alertUrlTranslations {\\n            text\\n            language\\n          }\\n          id\\n        }\\n        id\\n      }\\n    }\\n    to {\\n      lat\\n      lon\\n      name\\n      vertexType\\n      bikeRentalStation {\\n        lat\\n        lon\\n        stationId\\n        networks\\n        bikesAvailable\\n        id\\n      }\\n      stop {\\n        gtfsId\\n        code\\n        platformCode\\n        zoneId\\n        alerts {\\n          alertSeverityLevel\\n          effectiveEndDate\\n          effectiveStartDate\\n          trip {\\n            pattern {\\n              code\\n              id\\n            }\\n            id\\n          }\\n          alertHeaderText\\n          alertHeaderTextTranslations {\\n            text\\n            language\\n          }\\n          alertUrl\\n          alertUrlTranslations {\\n            text\\n            language\\n          }\\n          id\\n        }\\n        id\\n      }\\n      bikePark {\\n        bikeParkId\\n        name\\n        id\\n      }\\n      carPark {\\n        carParkId\\n        name\\n        id\\n      }\\n    }\\n    legGeometry {\\n      length\\n      points\\n    }\\n    intermediatePlaces {\\n      arrivalTime\\n      stop {\\n        gtfsId\\n        lat\\n        lon\\n        name\\n        code\\n        platformCode\\n        zoneId\\n        id\\n      }\\n    }\\n    realTime\\n    realtimeState\\n    transitLeg\\n    rentedBike\\n    startTime\\n    endTime\\n    interlineWithPreviousLeg\\n    distance\\n    duration\\n    intermediatePlace\\n    route {\\n      shortName\\n      color\\n      gtfsId\\n      longName\\n      desc\\n      agency {\\n        gtfsId\\n        fareUrl\\n        name\\n        phone\\n        id\\n      }\\n      alerts {\\n        alertSeverityLevel\\n        effectiveEndDate\\n        effectiveStartDate\\n        trip {\\n          pattern {\\n            code\\n            id\\n          }\\n          id\\n        }\\n        alertHeaderText\\n        alertHeaderTextTranslations {\\n          text\\n          language\\n        }\\n        alertUrl\\n        alertUrlTranslations {\\n          text\\n          language\\n        }\\n        id\\n      }\\n      id\\n    }\\n    trip {\\n      gtfsId\\n      tripHeadsign\\n      pattern {\\n        code\\n        id\\n      }\\n      stoptimes {\\n        pickupType\\n        realtimeState\\n        stop {\\n          gtfsId\\n          id\\n        }\\n      }\\n      id\\n    }\\n  }\\n}\\n\\nfragment ItineraryTab_plan on Plan {\\n  date\\n}\\n\\nfragment LegAgencyInfo_leg on Leg {\\n  agency {\\n    name\\n    url\\n    fareUrl\\n    id\\n  }\\n}\\n\\nfragment RouteLine_pattern on Pattern {\\n  code\\n  geometry {\\n    lat\\n    lon\\n  }\\n  route {\\n    mode\\n    color\\n    id\\n  }\\n  stops {\\n    lat\\n    lon\\n    name\\n    gtfsId\\n    platformCode\\n    code\\n    ...StopCardHeaderContainer_stop\\n    id\\n  }\\n}\\n\\nfragment StopCardHeaderContainer_stop on Stop {\\n  gtfsId\\n  name\\n  code\\n  desc\\n  zoneId\\n  alerts {\\n    alertSeverityLevel\\n    effectiveEndDate\\n    effectiveStartDate\\n    id\\n  }\\n  lat\\n  lon\\n  stops {\\n    name\\n    desc\\n    id\\n  }\\n}\\n\\nfragment SummaryPlanContainer_itineraries on Itinerary {\\n  ...ItinerarySummaryListContainer_itineraries\\n  endTime\\n  startTime\\n  legs {\\n    mode\\n    to {\\n      bikePark {\\n        bikeParkId\\n        name\\n        id\\n      }\\n    }\\n    ...ItineraryLine_legs\\n    transitLeg\\n    legGeometry {\\n      points\\n    }\\n    route {\\n      gtfsId\\n      id\\n    }\\n    trip {\\n      gtfsId\\n      directionId\\n      stoptimesForDate {\\n        scheduledDeparture\\n      }\\n      pattern {\\n        ...RouteLine_pattern\\n        id\\n      }\\n      id\\n    }\\n  }\\n}\\n\\nfragment SummaryPlanContainer_plan on Plan {\\n  date\\n}\\n","variables":{"fromPlace":"G\xfcltstein::48.57564174138462,8.879270553588869","toPlace":"Ehningen::48.6592556,8.9405097","intermediatePlaces":[],"date":"2021-05-28","time":"17:53:00","walkReluctance":2,"walkBoardCost":600,"minTransferTime":120,"walkSpeed":1.2,"bikeAndPublicMaxWalkDistance":15000,"wheelchair":false,"ticketTypes":null,"bikeandPublicDisableRemainingWeightHeuristic":false,"arriveBy":false,"transferPenalty":0,"bikeSpeed":5.55,"optimize":"TRIANGLE","triangle":{"safetyFactor":0.4,"slopeFactor":0.3,"timeFactor":0.3},"itineraryFiltering":1.5,"unpreferred":{"useUnpreferredRoutesPenalty":1200},"locale":"de","shouldMakeWalkQuery":false,"shouldMakeBikeQuery":true,"shouldMakeCarQuery":true,"shouldMakeParkRideQuery":true,"showBikeAndPublicItineraries":true,"showBikeAndParkItineraries":true,"bikeAndPublicModes":[{"mode":"BICYCLE"},{"mode":"BUS"},{"mode":"RAIL"},{"mode":"SUBWAY"}],"bikeParkModes":[{"mode":"BICYCLE","qualifier":"PARK"},{"mode":"BUS"},{"mode":"RAIL"},{"mode":"SUBWAY"},{"mode":"WALK"}]}}'

Error

Can't serialize value (/bikeParkPlan/itineraries[0]/legs[3]/from/vertexType) : Invalid input for Enum 'VertexType'. Unknown value 'VEHICLEPARK'

@flaktack

Copy link
Copy Markdown
Contributor Author

I've added a commit to correctly use VertexType.VEHICLEPARKING -- is changing the vertex type in the legacy API from BIKEPARK to VEHICLEPARKING a problem? Should that also remain BIKEPARK?

@leonardehrenfried leonardehrenfried left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested this again with @flaktack's latest changes and I fulfills all the backwards-compatibility guarantees that we expect as the legacy GraphQL API stays almost 100% compatible. Great work!

To answer your question: no the vertex type can stay as it is.

@leonardehrenfried

Copy link
Copy Markdown
Member

I recommend this to be merged.


// Used to explicitly specify the intersection to link to instead of using (x, y)
@EqualsAndHashCode.Exclude
private final transient StreetVertex vertex;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I merged this PR and strangely I'm observing the graph serialization test to fail: https://github.com/mfdz/OpenTripPlanner/runs/2682942115?check_suite_focus=true#step:6:3086

What is the reason to make this field transient?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because when I remove the transient keyword, the test passes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added a commit to explicitly clear the value of VehicleParkingEntrance#vertex, which is used when linking entrances to OSM.

The test fails due to #3910 modifying the builtin Portland graph to serialize bike rental stations and park and ride places. ObjectDiffer doesn't ignore transient fields, and so the missing transient value is caught after loading the graph and comparing it to the version in-memory.

}

private VehicleParking getVehicleParking(DataFetchingEnvironment environment) {
FeedScopedId vehiclePlaceId = getSource(environment).place.stopId;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think stopId is the correct field to use here. It should be vehicleParkId but that doesn't seem to exist.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this would be fixed in a subsequent PR of this branch:
https://github.com/realCity/OpenTripPlanner/commits/feature/vehicle-parking-api

@t2gran t2gran left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I read trough this looking for code smells. I only found a few minor things. The main thing is that we want to remove lombok in the near future, so starting to use it here seems to be a bit unnecessary. I think this is big PR with many code changes, but instead of going through it in detail to verify everything I would like to merge it. I have added the Entur test label, so we make sure we include this PR in our next release at Entur - so we can test it.

@optionsome optionsome left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reviewed the legacy graphql api changes and quickly tested this.

if (o instanceof Agency) { return schema.getObjectType("Agency"); }
if (o instanceof TransitAlert) { return schema.getObjectType("Alert"); }
if (o instanceof BikePark) { return schema.getObjectType("BikePark"); }
if (o instanceof VehicleParking) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably also take into account the possibility that there is a CarPark fragment and return that in that case. I think it would be best to check if the object has car or bicycle places and return the appropriate schema. There is a line in this file commented out for CarPark, it can be removed.

@flaktack flaktack Nov 4, 2021 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated the handling here to preserve compatibility with BikePark / CarPark being preferred if specified in the request.

GraphQLSchema schema = environment.getSchema();

if (o instanceof BikePark) { return schema.getObjectType("BikePark"); }
if (o instanceof VehicleParking) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as with the NodeInterfaceTypeResolver.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've used the same logic as in NodeInterfaceTypeResolver, but since StreetGraphFinder doesn't handle B+R/P+R nodes is has no effect.

};
}

@Override

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this removed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merge artifact, I've restored it.

"""
state: VehicleParkingState

bicyclePlaces: Boolean

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Descriptions missing for fields here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added the missing documentation.


anyCarPlaces: Boolean

carPlaces: Boolean

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this should renamed to something like normalCarPlaces so it can be understood that it doesn't include wheelchairAccessibleCarPlaces. I don't have a strong opinion on this but I think it's easy to miss that there is also this anyCarPlaces field that might be what the developer is actually looking for. However, a case where a park would have wheelchair accessible car places but no regular places sounds unlikely.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In Herrenberg (where this is used) there are several wheelchair only parking places.

I've updated the comments to maybe be a bit cleaner.

}

type VehicleParkingSpaces {
bicycleSpaces: Int

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add descriptions.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added the missing documentation.

"""TRANSIT"""
TRANSIT

"""BIKEPARK"""

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This breaks backwards compatability a bit. We could leave this as it was with the BIKEPARK and PARKANDRIDE, and add a new type with those replaced with VEHICLEPARKING (and at the same time rename BIKESHARE as VEHICLERENTAL). Although, I'm not quite sure what are all the use cases for this vertexType. Maybe it makes sense to be able to differentiate between bike and car parks based on this value but in theory, now they can have both cars and bicycles.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PARKANDRIDE is not present in VertexTypes, so it wouldn't have been returned in the API. I've renamed VEHICLERENTAL to BIKEPARK which should preserve the backward compatibility.

@optionsome optionsome left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Just one more thing I forgot yesterday, you could mark the fields and queries that use BikePark/CarPark as deprecated in the schema and suggest that the VehicleParking counterpart should be used.

@optionsome optionsome left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found some new things that should be fixed. Sorry, I should have noticed these earlier...


"""The bike parking related to the place"""
bikePark: BikePark
bikePark: BikePark @deprecated("bikePark is deprecated. Use vehicleParking instead.")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The schema build fails currently. I think you have to add "reason:" prefix to the deprecation comments.

Suggested change
bikePark: BikePark @deprecated("bikePark is deprecated. Use vehicleParking instead.")
bikePark: BikePark @deprecated(reason: "bikePark is deprecated. Use vehicleParking instead.")

@Override
public DataFetcher<String> bikeParkId() {
return environment -> getSource(environment).id;
return environment -> getSource(environment).getId().toString();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realized that maybe we should return the ids without the "feed id" in these legacy bikepark/carpark types like we have done with the BikeRentalStation vs VehicleRentalStation for backward compatibility.


@Override
public DataFetcher<String> carParkId() {
return environment -> getSource(environment).getId().toString();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as with the bikeParkId.


if (vehicleParkingService == null) { return null; }

var carParkId = FeedScopedId.parseId(args.getLegacyGraphQLId());

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again here I think we shouldn't use the feed scoped version of the id.

if (vehicleParkingService == null) { return null; }

return vehicleRentalStationService
var bikeParkId = FeedScopedId.parseId(args.getLegacyGraphQLId());

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't use the feedscoped id here.


if (!idList.isEmpty()) {
Map<String, VehicleParking> carParkMap = vehicleParkingService.getCarParks()
.collect(Collectors.toMap(station -> station.getId().toString(), station -> station));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forgot the carParks query also had ids parameter so this needs to be changed as well.

@optionsome optionsome left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything looks good now at least from the legacy graphql api point of view and I like the refactoring overall.

@leonardehrenfried leonardehrenfried left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've been running this in production for a few months now and are also satisfied.

@flaktack
flaktack merged commit 0c7264c into opentripplanner:dev-2.x Nov 10, 2021
t2gran pushed a commit that referenced this pull request Nov 10, 2021
@leonardehrenfried

Copy link
Copy Markdown
Member

🍾

@flaktack
flaktack deleted the feature/vehicle-parking branch November 10, 2021 16:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Entur Test This is currently being tested at Entur !New Feature A functional feature targeting the end user. !Technical Debt Improve code quality, no functional changes.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Merge Park & Ride with Bike & Ride for generic "Vehicle Parking" functionality

7 participants