Skip to content
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 plan query that follows the relay connection specification #5185

Merged
merged 174 commits into from
Jun 11, 2024

Conversation

optionsome
Copy link
Member

@optionsome optionsome commented Jun 13, 2023

Summary

Adds a new plan query that follows the relay connection specification and some new features/enhancements compared to the old plan query in the LegacyGraphQLAPI.

Example query:

{
  planConnection(
     dateTime: {
      earliestDeparture: "2023-06-13T14:30+03:00"
    }
    searchWindow: "PT2H30M"
    numberOfItineraries: 5
    origin: {
      location: {
        coordinate: {
          latitude: 10.0
          longitude: 20.0
        }
      }
      label: "Home"
    }
    destination: {
      location: {
        coordinate: {
          latitude: 15.0
          longitude: 25.0
        }
      }
      label: "Work"
    }
    modes: {
      directOnly: false
      transitOnly: false
      direct: [CAR_PARKING]
      transit: {
        access: [CAR_PARKING]
        transfer: [WALK]
        egress: [BICYCLE_RENTAL, WALK]
        transit: [
          {
            mode: TRAM
            cost: {
              reluctance: 1.3
            }
          },
          {
            mode: BUS
          }
        ]
      }
    }
    preferences: {
      accessibility: {
        wheelchair: {
          enabled: true
        }
      }
      street: {
        car: {
          reluctance: 6.5
          rental: {
            allowedNetworks: ["foo", "bar"]
            bannedNetworks: ["foobar"]
          }
          parking: {
            unpreferredCost: 200
            preferred: [{
              select: [{
                tags: ["best-park"]
              }]
            }]
            filters: [{
              not: [{
                tags: ["worst-park"]
              }]
            }]
          }
        }
        bicycle: {
          reluctance: 3.0
          speed: 7.4
          optimization: {
            type: SAFEST_STREETS
          }
          boardCost: 200
          walk: {
            speed: 1.3
            cost: {
              mountDismountCost: 100
              reluctance: 3.5
            }
            mountDismountTime: "PT5S"
          }
          rental: {
            destinationBicyclePolicy: {
              allowKeeping: true
              keepingCost: 300
            }
            allowedNetworks: ["foo", "bar"]
            bannedNetworks: ["foobar"]
          }
          parking: {
            unpreferredCost: 200
            preferred: [{
              select: [{
                tags: ["best-park"]
              }]
            }]
            filters: [{
              not: [{
                tags: ["worst-park"]
              }]
            }]
          }
        }
        walk: {
          speed: 2.4
          reluctance: 1.5
          walkSafetyFactor: 0.5
          boardCost: 200
        }
      }
      transit: {
        board: {
          waitReluctance: 3.2
          slack: "PT1M30S"
        }
        alight: {
          slack: "PT0S"
        }
        transfer: {
          cost: 200
          slack: "PT2M"
          maximumAdditionalTransfers: 2
          maximumTransfers: 5
        }
        timetable: {
          excludeRealTimeUpdates: false
          includePlannedCancellations: false
          includeRealTimeCancellations: true
        }
      }
    }
    locale: "en"
    after: ""
    first: 3
  ) {
    searchDateTime
    routingErrors {
      code
      description
      inputField
    }
    pageInfo {
      hasNextPage
      hasPreviousPage
      startCursor
      endCursor
    }
    edges {
      cursor
      node {
        legs {
          startTime
        }
      }
    }
  }
}

A simple "minimal" query:

{
  planConnection(
    dateTime: {
      earliestDeparture: "2023-06-13T14:30+03:00"
    }
    origin: {
      location: {
        coordinate: {
          latitude: 10.0
          longitude: 20.0
        }
      }
    }
    destination: {
      location: {
        coordinate: {
          latitude: 15.0
          longitude: 25.0
        }
      }
    }
    modes: {
      direct: [CAR_PARKING]
      transit: {
        access: [CAR_PARKING]
        transfer: [WALK]
        egress: [BICYCLE_RENTAL, WALK]
        transit: [
          {
            mode: TRAM
          },
          {
            mode: BUS
          }
        ]
      }
    }
  ) {
    edges {
      node {
        legs {
          startTime
        }
      }
    }
  }
}

Issue

closes #4803

Unit tests

Added

Documentation

Not needed yet

Changelog

Will add for sandbox

@optionsome
Copy link
Member Author

This is still WIP but wanted to open the pr so it's easier for people to make comments about the schema. I will start implementing some things that are less controversial first within this pr.

@leonardehrenfried leonardehrenfried self-requested a review June 13, 2023 09:08
@t2gran t2gran added this to the 2.4 (next release) milestone Jun 13, 2023
Copy link
Member

@t2gran t2gran left a comment

Choose a reason for hiding this comment

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

Some comments

@@ -3248,6 +3439,14 @@ enum AbsoluteDirection {
NORTHWEST
}

input ScooterPreferences {
Copy link
Member

Choose a reason for hiding this comment

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

Are you putting that in just for good measure? I don't think we have that implemented at the moment, isn't it?

Copy link
Member Author

Choose a reason for hiding this comment

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

I added this for two reasons: so it's more clear what settings should be defined when you want to adjust scooter travel and so we can in the future support defining different parameters for cycling/scooter. However, on the downside, what should happen now if both cycling and scooter settings are included.

alight: AlightPreferences
transfer: TransferPreferences
realtime: RealtimePreferences
modes: [TransitModePreference!]
Copy link
Member

Choose a reason for hiding this comment

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

We should probably have a think how to integrate Bartosz's filter API here.

Copy link
Member Author

Choose a reason for hiding this comment

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

True. I'm going to check at some point if I'm missing some other latest features from this API in this new draft or any cool features from the transmodel API.

Copy link
Member

Choose a reason for hiding this comment

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

what is the current thinking about this?

Copy link
Member Author

Choose a reason for hiding this comment

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

I haven't really studied the filter API closely but unless it has major issues, we can port it to this API as is.

@leonardehrenfried
Copy link
Member

I've made lots of comments but I think this is good step in the right direction. Thanks for working on this.

Copy link
Member

@t2gran t2gran left a comment

Choose a reason for hiding this comment

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

This looks good, my last comments are nit-picking and I am happy to approve without fixing them - let me know what you prefere.

@optionsome optionsome requested a review from t2gran June 3, 2024 17:39
Comment on lines +1643 to +1649
directOnly: Boolean = false

"""
Should only the transit search be done and never suggest itineraries that don't
contain any transit legs.
"""
transitOnly: Boolean = false
Copy link
Member

@t2gran t2gran Jun 7, 2024

Choose a reason for hiding this comment

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

We should probably have split the transit search(T) and street search(S) in two queries.

  • T is time dependent and has a search-window, S is most of the time time-shiftable
  • The S result is always first
  • The S is excluded when paging
  • The only reason to have it together is to use the S to prune the T - but we could probably find other ways to do that.

Copy link
Member Author

Choose a reason for hiding this comment

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

Do you mean two graphql queries or queries within OTP? Rerunning the street routing is indeed unnecessary when paging. We have thought about some caching solutions for this previously.

Is this comment related to @leonardehrenfried 's question about where the penalty should belong to?

Copy link
Member

@leonardehrenfried leonardehrenfried left a comment

Choose a reason for hiding this comment

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

The one remaining question I had was where accessEgressPenalty should live. After a bit of deliberation, we decided in today's meeting that we will leave the structure as it is and find a place should we need to add the penalties.

@optionsome optionsome merged commit 7e51eb1 into opentripplanner:dev-2.x Jun 11, 2024
5 checks passed
@optionsome optionsome deleted the plan-connection branch June 11, 2024 11:15
t2gran pushed a commit that referenced this pull request Jun 11, 2024
@optionsome
Copy link
Member Author

Thanks for spending time on reviewing this. We need to decide when we deprecate the old query and remove the deprecation from this one but I think we can wait some weeks at least.

@arnoclr
Copy link

arnoclr commented Oct 27, 2024

Hello, I can't find any mention of this, but where are the old options of plan to ban certain stops or routes in this new planConnection ? https://docs.opentripplanner.org/api/dev-2.x/graphql-gtfs/types/InputBanned

@optionsome
Copy link
Member Author

Hello, I can't find any mention of this, but where are the old options of plan to ban certain stops or routes in this new planConnection ? https://docs.opentripplanner.org/api/dev-2.x/graphql-gtfs/types/InputBanned

If I remember correctly, it isn't implemented yet because we wanted to limit the scope of this pr and we didn't necessarily want to implement it in the same way as it was implemented before. Instead, we want to have some sort of a bit more sophisticated filter structure. You are the second person to ask for this feature in the last couple of weeks. I'll bring this topic up in a developer meeting within a week or two. You can also show up in a meeting if you want and we can discuss this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Plan query that follows the relay connection specification
5 participants