@opentripplanner/core-utils 12.0.0-alpha.6 → 12.0.0-alpha.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/query-gen.js CHANGED
@@ -10,7 +10,7 @@ exports.TRANSIT_SUBMODES_AND_TRANSIT = exports.TRANSIT_SUBMODES = exports.SIMPLI
10
10
 
11
11
  var _graphql = require("graphql");
12
12
 
13
- var DefaultPlanQuery = { kind: "Document", definitions: [{ kind: "OperationDefinition", operation: "query", name: { kind: "Name", value: "Plan" }, variableDefinitions: [{ kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "arriveBy" } }, type: { kind: "NamedType", name: { kind: "Name", value: "Boolean" } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "banned" } }, type: { kind: "NamedType", name: { kind: "Name", value: "InputBanned" } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "bikeReluctance" } }, type: { kind: "NamedType", name: { kind: "Name", value: "Float" } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "carReluctance" } }, type: { kind: "NamedType", name: { kind: "Name", value: "Float" } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "date" } }, type: { kind: "NamedType", name: { kind: "Name", value: "String" } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "fromPlace" } }, type: { kind: "NonNullType", type: { kind: "NamedType", name: { kind: "Name", value: "String" } } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "modes" } }, type: { kind: "ListType", type: { kind: "NamedType", name: { kind: "Name", value: "TransportMode" } } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "numItineraries" } }, type: { kind: "NamedType", name: { kind: "Name", value: "Int" } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "preferred" } }, type: { kind: "NamedType", name: { kind: "Name", value: "InputPreferred" } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "time" } }, type: { kind: "NamedType", name: { kind: "Name", value: "String" } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "toPlace" } }, type: { kind: "NonNullType", type: { kind: "NamedType", name: { kind: "Name", value: "String" } } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "unpreferred" } }, type: { kind: "NamedType", name: { kind: "Name", value: "InputUnpreferred" } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "walkReluctance" } }, type: { kind: "NamedType", name: { kind: "Name", value: "Float" } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "walkSpeed" } }, type: { kind: "NamedType", name: { kind: "Name", value: "Float" } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "wheelchair" } }, type: { kind: "NamedType", name: { kind: "Name", value: "Boolean" } }, directives: [] }], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "plan" }, arguments: [{ kind: "Argument", name: { kind: "Name", value: "arriveBy" }, value: { kind: "Variable", name: { kind: "Name", value: "arriveBy" } } }, { kind: "Argument", name: { kind: "Name", value: "banned" }, value: { kind: "Variable", name: { kind: "Name", value: "banned" } } }, { kind: "Argument", name: { kind: "Name", value: "bikeReluctance" }, value: { kind: "Variable", name: { kind: "Name", value: "bikeReluctance" } } }, { kind: "Argument", name: { kind: "Name", value: "carReluctance" }, value: { kind: "Variable", name: { kind: "Name", value: "carReluctance" } } }, { kind: "Argument", name: { kind: "Name", value: "date" }, value: { kind: "Variable", name: { kind: "Name", value: "date" } } }, { kind: "Argument", name: { kind: "Name", value: "fromPlace" }, value: { kind: "Variable", name: { kind: "Name", value: "fromPlace" } } }, { kind: "Argument", name: { kind: "Name", value: "locale" }, value: { kind: "StringValue", value: "en", block: false } }, { kind: "Argument", name: { kind: "Name", value: "numItineraries" }, value: { kind: "Variable", name: { kind: "Name", value: "numItineraries" } } }, { kind: "Argument", name: { kind: "Name", value: "preferred" }, value: { kind: "Variable", name: { kind: "Name", value: "preferred" } } }, { kind: "Argument", name: { kind: "Name", value: "time" }, value: { kind: "Variable", name: { kind: "Name", value: "time" } } }, { kind: "Argument", name: { kind: "Name", value: "toPlace" }, value: { kind: "Variable", name: { kind: "Name", value: "toPlace" } } }, { kind: "Argument", name: { kind: "Name", value: "transportModes" }, value: { kind: "Variable", name: { kind: "Name", value: "modes" } } }, { kind: "Argument", name: { kind: "Name", value: "unpreferred" }, value: { kind: "Variable", name: { kind: "Name", value: "unpreferred" } } }, { kind: "Argument", name: { kind: "Name", value: "walkReluctance" }, value: { kind: "Variable", name: { kind: "Name", value: "walkReluctance" } } }, { kind: "Argument", name: { kind: "Name", value: "walkSpeed" }, value: { kind: "Variable", name: { kind: "Name", value: "walkSpeed" } } }, { kind: "Argument", name: { kind: "Name", value: "wheelchair" }, value: { kind: "Variable", name: { kind: "Name", value: "wheelchair" } } }], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "itineraries" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "accessibilityScore" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "duration" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "endTime" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "legs" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "accessibilityScore" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "agency" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "alerts" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "alertDescriptionText" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "alertHeaderText" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "alertUrl" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "effectiveStartDate" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "gtfsId" }, arguments: [], directives: [] }, { kind: "Field", alias: { kind: "Name", value: "id" }, name: { kind: "Name", value: "gtfsId" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "name" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "timezone" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "url" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "alerts" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "alertDescriptionText" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "alertHeaderText" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "alertUrl" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "effectiveStartDate" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "arrivalDelay" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "departureDelay" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "distance" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "dropoffType" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "duration" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "endTime" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "fareProducts" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "product" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "__typename" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "medium" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "name" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "name" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "riderCategory" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "name" }, arguments: [], directives: [] }] } }, { kind: "InlineFragment", typeCondition: { kind: "NamedType", name: { kind: "Name", value: "DefaultFareProduct" } }, directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "price" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "amount" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "currency" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "code" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "digits" }, arguments: [], directives: [] }] } }] } }] } }] } }] } }, { kind: "Field", name: { kind: "Name", value: "from" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "lat" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "lon" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "name" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "rentalVehicle" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "network" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "stop" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "alerts" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "alertDescriptionText" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "alertHeaderText" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "alertUrl" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "effectiveStartDate" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "code" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "gtfsId" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "lat" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "lon" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "vertexType" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "headsign" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "interlineWithPreviousLeg" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "intermediateStops" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "lat" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "locationType" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "lon" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "name" }, arguments: [], directives: [] }, { kind: "Field", alias: { kind: "Name", value: "stopCode" }, name: { kind: "Name", value: "code" }, arguments: [], directives: [] }, { kind: "Field", alias: { kind: "Name", value: "stopId" }, name: { kind: "Name", value: "id" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "legGeometry" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "length" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "points" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "mode" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "pickupBookingInfo" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "earliestBookingTime" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "daysPrior" }, arguments: [], directives: [] }] } }] } }, { kind: "Field", name: { kind: "Name", value: "pickupType" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "realTime" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "realtimeState" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "rentedBike" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "rideHailingEstimate" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "arrival" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "maxPrice" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "amount" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "currency" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "code" }, arguments: [], directives: [] }] } }] } }, { kind: "Field", name: { kind: "Name", value: "minPrice" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "amount" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "currency" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "code" }, arguments: [], directives: [] }] } }] } }, { kind: "Field", name: { kind: "Name", value: "provider" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }] } }] } }, { kind: "Field", name: { kind: "Name", value: "route" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "alerts" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "alertDescriptionText" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "alertHeaderText" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "alertUrl" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "effectiveStartDate" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "color" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "gtfsId" }, arguments: [], directives: [] }, { kind: "Field", alias: { kind: "Name", value: "id" }, name: { kind: "Name", value: "gtfsId" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "longName" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "shortName" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "textColor" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "type" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "startTime" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "steps" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "absoluteDirection" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "alerts" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "alertDescriptionText" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "alertHeaderText" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "alertUrl" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "effectiveStartDate" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "area" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "distance" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "elevationProfile" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "distance" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "elevation" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "lat" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "lon" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "relativeDirection" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "stayOn" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "streetName" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "to" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "lat" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "lon" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "name" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "rentalVehicle" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "network" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "stop" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "alerts" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "alertDescriptionText" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "alertHeaderText" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "alertUrl" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "effectiveStartDate" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "code" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "gtfsId" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "lat" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "lon" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "vertexType" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "transitLeg" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "trip" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "arrivalStoptime" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "stop" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "gtfsId" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "stopPosition" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "departureStoptime" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "stop" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "gtfsId" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "stopPosition" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "gtfsId" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }] } }] } }, { kind: "Field", name: { kind: "Name", value: "startTime" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "waitingTime" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "walkTime" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "routingErrors" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "code" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "description" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "inputField" }, arguments: [], directives: [] }] } }] } }] } }], loc: { start: 0, end: 4915, source: { body: "query Plan(\n $arriveBy: Boolean\n $banned: InputBanned\n $bikeReluctance: Float\n $carReluctance: Float\n $date: String\n $fromPlace: String!\n $modes: [TransportMode]\n $numItineraries: Int\n $preferred: InputPreferred\n $time: String\n $toPlace: String!\n $unpreferred: InputUnpreferred\n $walkReluctance: Float\n $walkSpeed: Float\n $wheelchair: Boolean\n) {\n plan(\n arriveBy: $arriveBy\n banned: $banned\n bikeReluctance: $bikeReluctance\n carReluctance: $carReluctance\n date: $date\n fromPlace: $fromPlace\n # Currently only supporting EN locale, used for times and text\n locale: \"en\"\n numItineraries: $numItineraries\n preferred: $preferred\n time: $time\n toPlace: $toPlace\n transportModes: $modes\n unpreferred: $unpreferred\n walkReluctance: $walkReluctance\n walkSpeed: $walkSpeed\n wheelchair: $wheelchair\n ) {\n itineraries {\n accessibilityScore\n duration\n endTime\n legs {\n accessibilityScore\n agency {\n alerts {\n alertDescriptionText\n alertHeaderText\n alertUrl\n effectiveStartDate\n id\n }\n gtfsId\n id: gtfsId\n name\n timezone\n url\n }\n alerts {\n alertDescriptionText\n alertHeaderText\n alertUrl\n effectiveStartDate\n id\n }\n arrivalDelay\n departureDelay\n distance\n dropoffType\n duration\n endTime\n fareProducts {\n id\n product {\n __typename\n id\n medium {\n id\n name\n }\n name\n riderCategory {\n id\n name\n }\n ... on DefaultFareProduct {\n price {\n amount\n currency {\n code\n digits\n }\n }\n }\n }\n }\n from {\n lat\n lon\n name\n rentalVehicle {\n id\n network\n }\n stop {\n alerts {\n alertDescriptionText\n alertHeaderText\n alertUrl\n effectiveStartDate\n id\n }\n code\n gtfsId\n id\n lat\n lon\n }\n vertexType\n }\n headsign\n interlineWithPreviousLeg\n intermediateStops {\n lat\n locationType\n lon\n name\n stopCode: code\n stopId: id\n }\n legGeometry {\n length\n points\n }\n mode\n pickupBookingInfo {\n earliestBookingTime {\n daysPrior\n }\n }\n pickupType\n realTime\n realtimeState\n rentedBike\n rideHailingEstimate {\n arrival\n maxPrice {\n amount\n currency {\n code\n }\n }\n minPrice {\n amount\n currency {\n code\n }\n }\n provider {\n id\n }\n }\n route {\n alerts {\n alertDescriptionText\n alertHeaderText\n alertUrl\n effectiveStartDate\n id\n }\n color\n gtfsId\n id: gtfsId\n longName\n shortName\n textColor\n type\n }\n startTime\n steps {\n absoluteDirection\n alerts {\n alertDescriptionText\n alertHeaderText\n alertUrl\n effectiveStartDate\n id\n }\n area\n distance\n elevationProfile {\n distance\n elevation\n }\n lat\n lon\n relativeDirection\n stayOn\n streetName\n }\n to {\n lat\n lon\n name\n rentalVehicle {\n id\n network\n }\n stop {\n alerts {\n alertDescriptionText\n alertHeaderText\n alertUrl\n effectiveStartDate\n id\n }\n code\n gtfsId\n id\n lat\n lon\n }\n vertexType\n }\n transitLeg\n trip {\n arrivalStoptime {\n stop {\n gtfsId\n id\n }\n stopPosition\n }\n departureStoptime {\n stop {\n gtfsId\n id\n }\n stopPosition\n }\n gtfsId\n id\n }\n }\n startTime\n waitingTime\n walkTime\n }\n routingErrors {\n code\n description\n inputField\n }\n }\n}\n", name: "GraphQL request", locationOffset: { line: 1, column: 1 } } } };
13
+ var DefaultPlanQuery = { kind: "Document", definitions: [{ kind: "OperationDefinition", operation: "query", name: { kind: "Name", value: "Plan" }, variableDefinitions: [{ kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "arriveBy" } }, type: { kind: "NamedType", name: { kind: "Name", value: "Boolean" } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "banned" } }, type: { kind: "NamedType", name: { kind: "Name", value: "InputBanned" } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "bikeReluctance" } }, type: { kind: "NamedType", name: { kind: "Name", value: "Float" } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "carReluctance" } }, type: { kind: "NamedType", name: { kind: "Name", value: "Float" } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "date" } }, type: { kind: "NamedType", name: { kind: "Name", value: "String" } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "fromPlace" } }, type: { kind: "NonNullType", type: { kind: "NamedType", name: { kind: "Name", value: "String" } } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "modes" } }, type: { kind: "ListType", type: { kind: "NamedType", name: { kind: "Name", value: "TransportMode" } } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "numItineraries" } }, type: { kind: "NamedType", name: { kind: "Name", value: "Int" } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "preferred" } }, type: { kind: "NamedType", name: { kind: "Name", value: "InputPreferred" } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "time" } }, type: { kind: "NamedType", name: { kind: "Name", value: "String" } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "toPlace" } }, type: { kind: "NonNullType", type: { kind: "NamedType", name: { kind: "Name", value: "String" } } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "unpreferred" } }, type: { kind: "NamedType", name: { kind: "Name", value: "InputUnpreferred" } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "walkReluctance" } }, type: { kind: "NamedType", name: { kind: "Name", value: "Float" } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "walkSpeed" } }, type: { kind: "NamedType", name: { kind: "Name", value: "Float" } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "wheelchair" } }, type: { kind: "NamedType", name: { kind: "Name", value: "Boolean" } }, directives: [] }], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "plan" }, arguments: [{ kind: "Argument", name: { kind: "Name", value: "arriveBy" }, value: { kind: "Variable", name: { kind: "Name", value: "arriveBy" } } }, { kind: "Argument", name: { kind: "Name", value: "banned" }, value: { kind: "Variable", name: { kind: "Name", value: "banned" } } }, { kind: "Argument", name: { kind: "Name", value: "bikeReluctance" }, value: { kind: "Variable", name: { kind: "Name", value: "bikeReluctance" } } }, { kind: "Argument", name: { kind: "Name", value: "carReluctance" }, value: { kind: "Variable", name: { kind: "Name", value: "carReluctance" } } }, { kind: "Argument", name: { kind: "Name", value: "date" }, value: { kind: "Variable", name: { kind: "Name", value: "date" } } }, { kind: "Argument", name: { kind: "Name", value: "fromPlace" }, value: { kind: "Variable", name: { kind: "Name", value: "fromPlace" } } }, { kind: "Argument", name: { kind: "Name", value: "locale" }, value: { kind: "StringValue", value: "en", block: false } }, { kind: "Argument", name: { kind: "Name", value: "numItineraries" }, value: { kind: "Variable", name: { kind: "Name", value: "numItineraries" } } }, { kind: "Argument", name: { kind: "Name", value: "preferred" }, value: { kind: "Variable", name: { kind: "Name", value: "preferred" } } }, { kind: "Argument", name: { kind: "Name", value: "time" }, value: { kind: "Variable", name: { kind: "Name", value: "time" } } }, { kind: "Argument", name: { kind: "Name", value: "toPlace" }, value: { kind: "Variable", name: { kind: "Name", value: "toPlace" } } }, { kind: "Argument", name: { kind: "Name", value: "transportModes" }, value: { kind: "Variable", name: { kind: "Name", value: "modes" } } }, { kind: "Argument", name: { kind: "Name", value: "unpreferred" }, value: { kind: "Variable", name: { kind: "Name", value: "unpreferred" } } }, { kind: "Argument", name: { kind: "Name", value: "walkReluctance" }, value: { kind: "Variable", name: { kind: "Name", value: "walkReluctance" } } }, { kind: "Argument", name: { kind: "Name", value: "walkSpeed" }, value: { kind: "Variable", name: { kind: "Name", value: "walkSpeed" } } }, { kind: "Argument", name: { kind: "Name", value: "wheelchair" }, value: { kind: "Variable", name: { kind: "Name", value: "wheelchair" } } }], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "itineraries" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "accessibilityScore" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "duration" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "endTime" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "legs" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "accessibilityScore" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "agency" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "alerts" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "alertDescriptionText" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "alertHeaderText" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "alertUrl" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "effectiveStartDate" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "gtfsId" }, arguments: [], directives: [] }, { kind: "Field", alias: { kind: "Name", value: "id" }, name: { kind: "Name", value: "gtfsId" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "name" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "timezone" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "url" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "alerts" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "alertDescriptionText" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "alertHeaderText" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "alertUrl" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "effectiveStartDate" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "arrivalDelay" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "departureDelay" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "distance" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "dropoffType" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "duration" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "endTime" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "fareProducts" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "product" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "__typename" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "medium" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "name" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "name" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "riderCategory" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "name" }, arguments: [], directives: [] }] } }, { kind: "InlineFragment", typeCondition: { kind: "NamedType", name: { kind: "Name", value: "DefaultFareProduct" } }, directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "price" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "amount" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "currency" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "code" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "digits" }, arguments: [], directives: [] }] } }] } }] } }] } }] } }, { kind: "Field", name: { kind: "Name", value: "from" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "lat" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "lon" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "name" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "rentalVehicle" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "network" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "stop" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "alerts" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "alertDescriptionText" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "alertHeaderText" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "alertUrl" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "effectiveStartDate" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "code" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "gtfsId" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "lat" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "lon" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "vertexType" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "headsign" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "interlineWithPreviousLeg" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "intermediateStops" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "lat" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "locationType" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "lon" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "name" }, arguments: [], directives: [] }, { kind: "Field", alias: { kind: "Name", value: "stopCode" }, name: { kind: "Name", value: "code" }, arguments: [], directives: [] }, { kind: "Field", alias: { kind: "Name", value: "stopId" }, name: { kind: "Name", value: "id" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "legGeometry" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "length" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "points" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "mode" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "pickupBookingInfo" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "earliestBookingTime" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "daysPrior" }, arguments: [], directives: [] }] } }] } }, { kind: "Field", name: { kind: "Name", value: "pickupType" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "realTime" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "realtimeState" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "rentedBike" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "rideHailingEstimate" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "arrival" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "maxPrice" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "amount" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "currency" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "code" }, arguments: [], directives: [] }] } }] } }, { kind: "Field", name: { kind: "Name", value: "minPrice" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "amount" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "currency" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "code" }, arguments: [], directives: [] }] } }] } }, { kind: "Field", name: { kind: "Name", value: "provider" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }] } }] } }, { kind: "Field", name: { kind: "Name", value: "route" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "alerts" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "alertDescriptionText" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "alertHeaderText" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "alertUrl" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "effectiveStartDate" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "color" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "gtfsId" }, arguments: [], directives: [] }, { kind: "Field", alias: { kind: "Name", value: "id" }, name: { kind: "Name", value: "gtfsId" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "longName" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "shortName" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "textColor" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "type" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "startTime" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "steps" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "absoluteDirection" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "alerts" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "alertDescriptionText" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "alertHeaderText" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "alertUrl" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "effectiveStartDate" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "area" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "distance" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "elevationProfile" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "distance" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "elevation" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "lat" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "lon" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "relativeDirection" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "stayOn" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "streetName" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "to" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "lat" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "lon" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "name" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "rentalVehicle" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "network" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "stop" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "alerts" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "alertDescriptionText" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "alertHeaderText" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "alertUrl" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "effectiveStartDate" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "code" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "gtfsId" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "lat" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "lon" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "vertexType" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "transitLeg" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "trip" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "arrivalStoptime" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "stop" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "gtfsId" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "stopPosition" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "departureStoptime" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "stop" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "gtfsId" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "stopPosition" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "gtfsId" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }] } }] } }, { kind: "Field", name: { kind: "Name", value: "startTime" }, arguments: [], directives: [] }, { kind: "Field", alias: { kind: "Name", value: "transfers" }, name: { kind: "Name", value: "numberOfTransfers" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "waitingTime" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "walkTime" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "routingErrors" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "code" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "description" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "inputField" }, arguments: [], directives: [] }] } }] } }] } }], loc: { start: 0, end: 4950, source: { body: "query Plan(\n $arriveBy: Boolean\n $banned: InputBanned\n $bikeReluctance: Float\n $carReluctance: Float\n $date: String\n $fromPlace: String!\n $modes: [TransportMode]\n $numItineraries: Int\n $preferred: InputPreferred\n $time: String\n $toPlace: String!\n $unpreferred: InputUnpreferred\n $walkReluctance: Float\n $walkSpeed: Float\n $wheelchair: Boolean\n) {\n plan(\n arriveBy: $arriveBy\n banned: $banned\n bikeReluctance: $bikeReluctance\n carReluctance: $carReluctance\n date: $date\n fromPlace: $fromPlace\n # Currently only supporting EN locale, used for times and text\n locale: \"en\"\n numItineraries: $numItineraries\n preferred: $preferred\n time: $time\n toPlace: $toPlace\n transportModes: $modes\n unpreferred: $unpreferred\n walkReluctance: $walkReluctance\n walkSpeed: $walkSpeed\n wheelchair: $wheelchair\n ) {\n itineraries {\n accessibilityScore\n duration\n endTime\n legs {\n accessibilityScore\n agency {\n alerts {\n alertDescriptionText\n alertHeaderText\n alertUrl\n effectiveStartDate\n id\n }\n gtfsId\n id: gtfsId\n name\n timezone\n url\n }\n alerts {\n alertDescriptionText\n alertHeaderText\n alertUrl\n effectiveStartDate\n id\n }\n arrivalDelay\n departureDelay\n distance\n dropoffType\n duration\n endTime\n fareProducts {\n id\n product {\n __typename\n id\n medium {\n id\n name\n }\n name\n riderCategory {\n id\n name\n }\n ... on DefaultFareProduct {\n price {\n amount\n currency {\n code\n digits\n }\n }\n }\n }\n }\n from {\n lat\n lon\n name\n rentalVehicle {\n id\n network\n }\n stop {\n alerts {\n alertDescriptionText\n alertHeaderText\n alertUrl\n effectiveStartDate\n id\n }\n code\n gtfsId\n id\n lat\n lon\n }\n vertexType\n }\n headsign\n interlineWithPreviousLeg\n intermediateStops {\n lat\n locationType\n lon\n name\n stopCode: code\n stopId: id\n }\n legGeometry {\n length\n points\n }\n mode\n pickupBookingInfo {\n earliestBookingTime {\n daysPrior\n }\n }\n pickupType\n realTime\n realtimeState\n rentedBike\n rideHailingEstimate {\n arrival\n maxPrice {\n amount\n currency {\n code\n }\n }\n minPrice {\n amount\n currency {\n code\n }\n }\n provider {\n id\n }\n }\n route {\n alerts {\n alertDescriptionText\n alertHeaderText\n alertUrl\n effectiveStartDate\n id\n }\n color\n gtfsId\n id: gtfsId\n longName\n shortName\n textColor\n type\n }\n startTime\n steps {\n absoluteDirection\n alerts {\n alertDescriptionText\n alertHeaderText\n alertUrl\n effectiveStartDate\n id\n }\n area\n distance\n elevationProfile {\n distance\n elevation\n }\n lat\n lon\n relativeDirection\n stayOn\n streetName\n }\n to {\n lat\n lon\n name\n rentalVehicle {\n id\n network\n }\n stop {\n alerts {\n alertDescriptionText\n alertHeaderText\n alertUrl\n effectiveStartDate\n id\n }\n code\n gtfsId\n id\n lat\n lon\n }\n vertexType\n }\n transitLeg\n trip {\n arrivalStoptime {\n stop {\n gtfsId\n id\n }\n stopPosition\n }\n departureStoptime {\n stop {\n gtfsId\n id\n }\n stopPosition\n }\n gtfsId\n id\n }\n }\n startTime\n transfers: numberOfTransfers\n waitingTime\n walkTime\n }\n routingErrors {\n code\n description\n inputField\n }\n }\n}\n", name: "GraphQL request", locationOffset: { line: 1, column: 1 } } } };
14
14
 
15
15
  /**
16
16
  * Mode Settings can contain additional modes to add to the query,
@@ -81,6 +81,7 @@ const SIMPLIFICATIONS = {
81
81
  RAIL: "TRANSIT",
82
82
  SCOOTER: "PERSONAL",
83
83
  SUBWAY: "TRANSIT",
84
+ TROLLEYBUS: "TRANSIT",
84
85
  TRAM: "TRANSIT",
85
86
  TRANSIT: "TRANSIT",
86
87
  WALK: "WALK"
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/query-gen.ts"],"names":["extractAdditionalModes","modeSettings","enabledModes","reduce","prev","cur","map","m","mode","includes","applicableMode","type","addTransportMode","value","newTransportModes","Array","isArray","transportMode","options","find","o","combinations","array","length","fill","e1","i","filter","e2","j","SIMPLIFICATIONS","AIRPLANE","BICYCLE","BUS","CABLE_CAR","CAR","FERRY","FLEX","FUNICULAR","GONDOLA","RAIL","SCOOTER","SUBWAY","TRAM","TRANSIT","WALK","VALID_COMBOS","BANNED_TOGETHER","TRANSIT_SUBMODES","Object","keys","TRANSIT_SUBMODES_AND_TRANSIT","isCombinationValid","combo","queryTransitSubmodes","simplifiedModes","from","Set","c","qualifier","vc","every","generateCombinations","params","completeModeList","modes","generateOtp2Query","arriveBy","banned","date","numItineraries","preferred","time","to","planQuery","DefaultPlanQuery","modeSettingValues","inverseKey","high","low","key","truthValue","falseValue","bikeReluctance","carReluctance","walkSpeed","walkReluctance","wheelchair","query","variables","fromPlace","name","lat","lon","toPlace"],"mappings":";;;;;;;;;;AACA;;;;AAyCA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,sBAAT,CACLC,YADK,EAELC,YAFK,EAGY;AACjB,SAAOD,YAAY,CAACE,MAAb,CAAqC,CAACC,IAA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AACkB,IAAK,KAAIlB,EAAE,CAACmB,GAAI,IAAGnB,EAAE,CAACoB,GAAI,GAXhC;AAYTP,MAAAA,cAZS;AAaTD,MAAAA,SAbS;AAcTE,MAAAA;AAdS;AAFN,GAAP;AAmBD","sourcesContent":["import { LonLatOutput } from \"@conveyal/lonlat\";\nimport { print } from \"graphql\";\nimport {\n ModeSetting,\n ModeSettingValues,\n TransportMode\n} from \"@opentripplanner/types\";\n\nimport DefaultPlanQuery from \"./planQuery.graphql\";\n\ntype InputBanned = {\n routes?: string;\n agencies?: string;\n trips?: string;\n stops?: string;\n stopsHard?: string;\n};\n\ntype InputPreferred = {\n routes?: string;\n agencies?: string;\n unpreferredCost?: string;\n};\n\ntype OTPQueryParams = {\n arriveBy: boolean;\n date?: string;\n from: LonLatOutput & { name?: string };\n modes: TransportMode[];\n modeSettings: ModeSetting[];\n time?: string;\n numItineraries?: number;\n to: LonLatOutput & { name?: string };\n banned?: InputBanned;\n preferred?: InputPreferred;\n};\n\ntype GraphQLQuery = {\n query: string;\n variables: Record<string, unknown>;\n};\n\n/**\n * Mode Settings can contain additional modes to add to the query,\n * this function extracts those additional modes from the settings\n * and returns them in an array.\n * @param modeSettings List of mode settings with values populated\n * @returns Additional transport modes to add to query\n */\nexport function extractAdditionalModes(\n modeSettings: ModeSetting[],\n enabledModes: TransportMode[]\n): TransportMode[] {\n return modeSettings.reduce<TransportMode[]>((prev, cur) => {\n // First, ensure that the mode associated with this setting is even enabled\n if (!enabledModes.map(m => m.mode).includes(cur.applicableMode)) {\n return prev;\n }\n\n // In checkboxes (or submode checkboxes), mode must be enabled and have a transport mode in it\n if (\n (cur.type === \"CHECKBOX\" || cur.type === \"SUBMODE\") &&\n cur.addTransportMode &&\n cur.value\n ) {\n const newTransportModes = Array.isArray(cur.addTransportMode)\n ? cur.addTransportMode\n : [cur.addTransportMode];\n return [...prev, ...newTransportModes];\n }\n if (cur.type === \"DROPDOWN\") {\n const transportMode = cur.options.find(o => o.value === cur.value)\n ?.addTransportMode;\n if (transportMode) {\n return [...prev, transportMode];\n }\n }\n return prev;\n }, []);\n}\n\n/**\n * Generates every possible mathematical subset of the input TransportModes.\n * Uses code from:\n * https://stackoverflow.com/questions/5752002/find-all-possible-subset-combos-in-an-array\n * @param array Array of input transport modes\n * @returns 2D array representing every possible subset of transport modes from input\n */\nfunction combinations(array: TransportMode[]): TransportMode[][] {\n if (!array) return [];\n return (\n // eslint-disable-next-line no-bitwise\n new Array(1 << array.length)\n .fill(null)\n // eslint-disable-next-line no-bitwise\n .map((e1, i) => array.filter((e2, j) => i & (1 << j)))\n );\n}\n\n/**\n * This constant maps all the transport mode to a broader mode type,\n * which is used to determine the valid combinations of modes used in query generation.\n */\nexport const SIMPLIFICATIONS = {\n AIRPLANE: \"TRANSIT\",\n BICYCLE: \"PERSONAL\",\n BUS: \"TRANSIT\",\n CABLE_CAR: \"TRANSIT\",\n CAR: \"CAR\",\n FERRY: \"TRANSIT\",\n FLEX: \"SHARED\", // TODO: this allows FLEX+WALK. Is this reasonable?\n FUNICULAR: \"TRANSIT\",\n GONDOLA: \"TRANSIT\",\n RAIL: \"TRANSIT\",\n SCOOTER: \"PERSONAL\",\n SUBWAY: \"TRANSIT\",\n TRAM: \"TRANSIT\",\n TRANSIT: \"TRANSIT\",\n WALK: \"WALK\"\n};\n\n// Inclusion of \"TRANSIT\" alone automatically implies \"WALK\" in OTP\nconst VALID_COMBOS = [\n [\"WALK\"],\n [\"PERSONAL\"],\n [\"TRANSIT\", \"SHARED\"],\n [\"WALK\", \"SHARED\"],\n [\"TRANSIT\"],\n [\"TRANSIT\", \"PERSONAL\"],\n [\"TRANSIT\", \"CAR\"]\n];\n\nconst BANNED_TOGETHER = [\"SCOOTER\", \"BICYCLE\", \"CAR\"];\n\nexport const TRANSIT_SUBMODES = Object.keys(SIMPLIFICATIONS).filter(\n mode => SIMPLIFICATIONS[mode] === \"TRANSIT\" && mode !== \"TRANSIT\"\n);\nexport const TRANSIT_SUBMODES_AND_TRANSIT = Object.keys(SIMPLIFICATIONS).filter(\n mode => SIMPLIFICATIONS[mode] === \"TRANSIT\"\n);\n\nfunction isCombinationValid(\n combo: TransportMode[],\n queryTransitSubmodes: string[]\n): boolean {\n if (combo.length === 0) return false;\n\n // All current qualifiers currently simplify to \"SHARED\"\n const simplifiedModes = Array.from(\n new Set(combo.map(c => (c.qualifier ? \"SHARED\" : SIMPLIFICATIONS[c.mode])))\n );\n\n // Ensure that if we have one transit mode, then we include ALL transit modes\n if (simplifiedModes.includes(\"TRANSIT\")) {\n // Don't allow TRANSIT along with any other submodes\n if (queryTransitSubmodes.length && combo.find(c => c.mode === \"TRANSIT\")) {\n return false;\n }\n\n if (\n combo.reduce((prev, cur) => {\n if (queryTransitSubmodes.includes(cur.mode)) {\n return prev - 1;\n }\n return prev;\n }, queryTransitSubmodes.length) !== 0\n ) {\n return false;\n }\n // Continue to the other checks\n }\n\n // OTP doesn't support multiple non-walk modes\n if (BANNED_TOGETHER.filter(m => combo.find(c => c.mode === m)).length > 1) {\n return false;\n }\n\n return !!VALID_COMBOS.find(\n vc =>\n simplifiedModes.every(m => vc.includes(m)) &&\n vc.every(m => simplifiedModes.includes(m))\n );\n}\n\n/**\n * Generates a list of queries for OTP to get a comprehensive\n * set of results based on the modes input.\n * @param params OTP Query Params\n * @returns Set of parameters to generate queries\n */\nexport function generateCombinations(params: OTPQueryParams): OTPQueryParams[] {\n const completeModeList = [\n ...extractAdditionalModes(params.modeSettings, params.modes),\n ...params.modes\n ];\n\n // List of the transit *submodes* that are included in the input params\n const queryTransitSubmodes = completeModeList\n .filter(mode => TRANSIT_SUBMODES.includes(mode.mode))\n .map(mode => mode.mode);\n\n return combinations(completeModeList)\n .filter(combo => isCombinationValid(combo, queryTransitSubmodes))\n .map(combo => ({ ...params, modes: combo }));\n}\n\n/**\n * Generates a query for OTP GraphQL API based on parameters.\n * @param param0 OTP2 Parameters for the query\n * @param planQuery Override the default query for OTP\n * @returns A fully formed query+variables ready to be sent to GraphQL backend\n */\nexport function generateOtp2Query(\n {\n arriveBy,\n banned,\n date,\n from,\n modes,\n modeSettings,\n numItineraries,\n preferred,\n time,\n to\n }: OTPQueryParams,\n planQuery = DefaultPlanQuery\n): GraphQLQuery {\n // This extracts the values from the mode settings to key value pairs\n const modeSettingValues = modeSettings.reduce((prev, cur) => {\n if (cur.type === \"SLIDER\" && cur.inverseKey) {\n prev[cur.inverseKey] = cur.high - cur.value + cur.low;\n }\n prev[cur.key] = cur.value;\n\n // If we assign a value on true, return the value (or null) instead of a boolean.\n if (cur.type === \"CHECKBOX\" && cur.truthValue) {\n prev[cur.key] =\n cur.value === true ? cur.truthValue : cur.falseValue ?? null;\n }\n return prev;\n }, {}) as ModeSettingValues;\n\n const {\n bikeReluctance,\n carReluctance,\n walkSpeed,\n walkReluctance,\n wheelchair\n } = modeSettingValues;\n\n return {\n query: print(planQuery),\n variables: {\n arriveBy,\n banned,\n bikeReluctance,\n carReluctance,\n date,\n fromPlace: `${from.name}::${from.lat},${from.lon}}`,\n modes,\n numItineraries,\n preferred,\n time,\n toPlace: `${to.name}::${to.lat},${to.lon}}`,\n walkReluctance,\n walkSpeed,\n wheelchair\n }\n };\n}\n"],"file":"query-gen.js"}
1
+ {"version":3,"sources":["../src/query-gen.ts"],"names":["extractAdditionalModes","modeSettings","enabledModes","reduce","prev","cur","map","m","mode","includes","applicableMode","type","addTransportMode","value","newTransportModes","Array","isArray","transportMode","options","find","o","combinations","array","length","fill","e1","i","filter","e2","j","SIMPLIFICATIONS","AIRPLANE","BICYCLE","BUS","CABLE_CAR","CAR","FERRY","FLEX","FUNICULAR","GONDOLA","RAIL","SCOOTER","SUBWAY","TROLLEYBUS","TRAM","TRANSIT","WALK","VALID_COMBOS","BANNED_TOGETHER","TRANSIT_SUBMODES","Object","keys","TRANSIT_SUBMODES_AND_TRANSIT","isCombinationValid","combo","queryTransitSubmodes","simplifiedModes","from","Set","c","qualifier","vc","every","generateCombinations","params","completeModeList","modes","generateOtp2Query","arriveBy","banned","date","numItineraries","preferred","time","to","planQuery","DefaultPlanQuery","modeSettingValues","inverseKey","high","low","key","truthValue","falseValue","bikeReluctance","carReluctance","walkSpeed","walkReluctance","wheelchair","query","variables","fromPlace","name","lat","lon","toPlace"],"mappings":";;;;;;;;;;AACA;;;;AAyCA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,sBAAT,CACLC,YADK,EAELC,YAFK,EAGY;AACjB,SAAOD,YAAY,CAACE,MAAb,CAAqC,CAACC,IAAD,EAAOC,GAAP,KAAe;AACzD;AACA,QAAI,CAACH,YAAY,CAACI,GAAb,CAAiBC,CAAC,IAAIA,CAAC,CAACC,IAAxB,EAA8BC,QAA9B,CAAuCJ,GAAG,CAACK,cAA3C,CAAL,EAAiE;AAC/D,aAAON,IAAP;AACD,KAJwD,CAMzD;;;AACA,QACE,CAACC,GAAG,CAACM,IAAJ,KAAa,UAAb,IAA2BN,GAAG,CAACM,IAAJ,KAAa,SAAzC,KACAN,GAAG,CAACO,gBADJ,IAEAP,GAAG,CAACQ,KAHN,EAIE;AACA,YAAMC,iBAAiB,GAAGC,KAAK,CAACC,OAAN,CAAcX,GAAG,CAACO,gBAAlB,IACtBP,GAAG,CAACO,gBADkB,GAEtB,CAACP,GAAG,CAACO,gBAAL,CAFJ;AAGA,aAAO,CAAC,GAAGR,IAAJ,EAAU,GAAGU,iBAAb,CAAP;AACD;;AACD,QAAIT,GAAG,CAACM,IAAJ,KAAa,UAAjB,EAA6B;AAAA;;AAC3B,YAAMM,aAAa,wBAAGZ,GAAG,CAACa,OAAJ,CAAYC,IAAZ,CAAiBC,CAAC,IAAIA,CAAC,CAACP,KAAF,KAAYR,GAAG,CAACQ,KAAtC,CAAH,sDAAG,kBAClBD,gBADJ;;AAEA,UAAIK,aAAJ,EAAmB;AACjB,eAAO,CAAC,GAAGb,IAAJ,EAAUa,aAAV,CAAP;AACD;AACF;;AACD,WAAOb,IAAP;AACD,GAzBM,EAyBJ,EAzBI,CAAP;AA0BD;AAED;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AAE;AACTtB,MAAAA,QADS;AAETC,MAAAA,MAFS;AAGTe,MAAAA,cAHS;AAITC,MAAAA,aAJS;AAKTf,MAAAA,IALS;AAMTqB,MAAAA,SAAS,EAAG,GAAElC,IAAI,CAACmC,IAAK,KAAInC,IAAI,CAACoC,GAAI,IAAGpC,IAAI,CAACqC,GAAI,GANxC;AAOT5B,MAAAA,KAPS;AAQTK,MAAAA,cARS;AASTC,MAAAA,SATS;AAUTC,MAAAA,IAVS;AAWTsB,MAAAA,OAAO,EAAG,GAAErB,EAAE,CAACkB,IAAK,KAAIlB,EAAE,CAACmB,GAAI,IAAGnB,EAAE,CAACoB,GAAI,GAXhC;AAYTP,MAAAA,cAZS;AAaTD,MAAAA,SAbS;AAcTE,MAAAA;AAdS;AAFN,GAAP;AAmBD","sourcesContent":["import { LonLatOutput } from \"@conveyal/lonlat\";\nimport { print } from \"graphql\";\nimport {\n ModeSetting,\n ModeSettingValues,\n TransportMode\n} from \"@opentripplanner/types\";\n\nimport DefaultPlanQuery from \"./planQuery.graphql\";\n\ntype InputBanned = {\n routes?: string;\n agencies?: string;\n trips?: string;\n stops?: string;\n stopsHard?: string;\n};\n\ntype InputPreferred = {\n routes?: string;\n agencies?: string;\n unpreferredCost?: string;\n};\n\ntype OTPQueryParams = {\n arriveBy: boolean;\n date?: string;\n from: LonLatOutput & { name?: string };\n modes: TransportMode[];\n modeSettings: ModeSetting[];\n time?: string;\n numItineraries?: number;\n to: LonLatOutput & { name?: string };\n banned?: InputBanned;\n preferred?: InputPreferred;\n};\n\ntype GraphQLQuery = {\n query: string;\n variables: Record<string, unknown>;\n};\n\n/**\n * Mode Settings can contain additional modes to add to the query,\n * this function extracts those additional modes from the settings\n * and returns them in an array.\n * @param modeSettings List of mode settings with values populated\n * @returns Additional transport modes to add to query\n */\nexport function extractAdditionalModes(\n modeSettings: ModeSetting[],\n enabledModes: TransportMode[]\n): TransportMode[] {\n return modeSettings.reduce<TransportMode[]>((prev, cur) => {\n // First, ensure that the mode associated with this setting is even enabled\n if (!enabledModes.map(m => m.mode).includes(cur.applicableMode)) {\n return prev;\n }\n\n // In checkboxes (or submode checkboxes), mode must be enabled and have a transport mode in it\n if (\n (cur.type === \"CHECKBOX\" || cur.type === \"SUBMODE\") &&\n cur.addTransportMode &&\n cur.value\n ) {\n const newTransportModes = Array.isArray(cur.addTransportMode)\n ? cur.addTransportMode\n : [cur.addTransportMode];\n return [...prev, ...newTransportModes];\n }\n if (cur.type === \"DROPDOWN\") {\n const transportMode = cur.options.find(o => o.value === cur.value)\n ?.addTransportMode;\n if (transportMode) {\n return [...prev, transportMode];\n }\n }\n return prev;\n }, []);\n}\n\n/**\n * Generates every possible mathematical subset of the input TransportModes.\n * Uses code from:\n * https://stackoverflow.com/questions/5752002/find-all-possible-subset-combos-in-an-array\n * @param array Array of input transport modes\n * @returns 2D array representing every possible subset of transport modes from input\n */\nfunction combinations(array: TransportMode[]): TransportMode[][] {\n if (!array) return [];\n return (\n // eslint-disable-next-line no-bitwise\n new Array(1 << array.length)\n .fill(null)\n // eslint-disable-next-line no-bitwise\n .map((e1, i) => array.filter((e2, j) => i & (1 << j)))\n );\n}\n\n/**\n * This constant maps all the transport mode to a broader mode type,\n * which is used to determine the valid combinations of modes used in query generation.\n */\nexport const SIMPLIFICATIONS = {\n AIRPLANE: \"TRANSIT\",\n BICYCLE: \"PERSONAL\",\n BUS: \"TRANSIT\",\n CABLE_CAR: \"TRANSIT\",\n CAR: \"CAR\",\n FERRY: \"TRANSIT\",\n FLEX: \"SHARED\", // TODO: this allows FLEX+WALK. Is this reasonable?\n FUNICULAR: \"TRANSIT\",\n GONDOLA: \"TRANSIT\",\n RAIL: \"TRANSIT\",\n SCOOTER: \"PERSONAL\",\n SUBWAY: \"TRANSIT\",\n TROLLEYBUS: \"TRANSIT\",\n TRAM: \"TRANSIT\",\n TRANSIT: \"TRANSIT\",\n WALK: \"WALK\"\n};\n\n// Inclusion of \"TRANSIT\" alone automatically implies \"WALK\" in OTP\nconst VALID_COMBOS = [\n [\"WALK\"],\n [\"PERSONAL\"],\n [\"TRANSIT\", \"SHARED\"],\n [\"WALK\", \"SHARED\"],\n [\"TRANSIT\"],\n [\"TRANSIT\", \"PERSONAL\"],\n [\"TRANSIT\", \"CAR\"]\n];\n\nconst BANNED_TOGETHER = [\"SCOOTER\", \"BICYCLE\", \"CAR\"];\n\nexport const TRANSIT_SUBMODES = Object.keys(SIMPLIFICATIONS).filter(\n mode => SIMPLIFICATIONS[mode] === \"TRANSIT\" && mode !== \"TRANSIT\"\n);\nexport const TRANSIT_SUBMODES_AND_TRANSIT = Object.keys(SIMPLIFICATIONS).filter(\n mode => SIMPLIFICATIONS[mode] === \"TRANSIT\"\n);\n\nfunction isCombinationValid(\n combo: TransportMode[],\n queryTransitSubmodes: string[]\n): boolean {\n if (combo.length === 0) return false;\n\n // All current qualifiers currently simplify to \"SHARED\"\n const simplifiedModes = Array.from(\n new Set(combo.map(c => (c.qualifier ? \"SHARED\" : SIMPLIFICATIONS[c.mode])))\n );\n\n // Ensure that if we have one transit mode, then we include ALL transit modes\n if (simplifiedModes.includes(\"TRANSIT\")) {\n // Don't allow TRANSIT along with any other submodes\n if (queryTransitSubmodes.length && combo.find(c => c.mode === \"TRANSIT\")) {\n return false;\n }\n\n if (\n combo.reduce((prev, cur) => {\n if (queryTransitSubmodes.includes(cur.mode)) {\n return prev - 1;\n }\n return prev;\n }, queryTransitSubmodes.length) !== 0\n ) {\n return false;\n }\n // Continue to the other checks\n }\n\n // OTP doesn't support multiple non-walk modes\n if (BANNED_TOGETHER.filter(m => combo.find(c => c.mode === m)).length > 1) {\n return false;\n }\n\n return !!VALID_COMBOS.find(\n vc =>\n simplifiedModes.every(m => vc.includes(m)) &&\n vc.every(m => simplifiedModes.includes(m))\n );\n}\n\n/**\n * Generates a list of queries for OTP to get a comprehensive\n * set of results based on the modes input.\n * @param params OTP Query Params\n * @returns Set of parameters to generate queries\n */\nexport function generateCombinations(params: OTPQueryParams): OTPQueryParams[] {\n const completeModeList = [\n ...extractAdditionalModes(params.modeSettings, params.modes),\n ...params.modes\n ];\n\n // List of the transit *submodes* that are included in the input params\n const queryTransitSubmodes = completeModeList\n .filter(mode => TRANSIT_SUBMODES.includes(mode.mode))\n .map(mode => mode.mode);\n\n return combinations(completeModeList)\n .filter(combo => isCombinationValid(combo, queryTransitSubmodes))\n .map(combo => ({ ...params, modes: combo }));\n}\n\n/**\n * Generates a query for OTP GraphQL API based on parameters.\n * @param param0 OTP2 Parameters for the query\n * @param planQuery Override the default query for OTP\n * @returns A fully formed query+variables ready to be sent to GraphQL backend\n */\nexport function generateOtp2Query(\n {\n arriveBy,\n banned,\n date,\n from,\n modes,\n modeSettings,\n numItineraries,\n preferred,\n time,\n to\n }: OTPQueryParams,\n planQuery = DefaultPlanQuery\n): GraphQLQuery {\n // This extracts the values from the mode settings to key value pairs\n const modeSettingValues = modeSettings.reduce((prev, cur) => {\n if (cur.type === \"SLIDER\" && cur.inverseKey) {\n prev[cur.inverseKey] = cur.high - cur.value + cur.low;\n }\n prev[cur.key] = cur.value;\n\n // If we assign a value on true, return the value (or null) instead of a boolean.\n if (cur.type === \"CHECKBOX\" && cur.truthValue) {\n prev[cur.key] =\n cur.value === true ? cur.truthValue : cur.falseValue ?? null;\n }\n return prev;\n }, {}) as ModeSettingValues;\n\n const {\n bikeReluctance,\n carReluctance,\n walkSpeed,\n walkReluctance,\n wheelchair\n } = modeSettingValues;\n\n return {\n query: print(planQuery),\n variables: {\n arriveBy,\n banned,\n bikeReluctance,\n carReluctance,\n date,\n fromPlace: `${from.name}::${from.lat},${from.lon}}`,\n modes,\n numItineraries,\n preferred,\n time,\n toPlace: `${to.name}::${to.lat},${to.lon}}`,\n walkReluctance,\n walkSpeed,\n wheelchair\n }\n };\n}\n"],"file":"query-gen.js"}
@@ -1 +1 @@
1
- {"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../src/route.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,KAAK,EAA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E,MAAM,EACd,QAAQ,EAAE,MAAM,GAAG,MAAM,EACzB,gBAAgB,EAAE,eAAe,EAAE,GAClC,eAAe,CAQjB;AAED;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CACvC,GAAG,EAAE,GAAG,EACR,gBAAgB,EAAE,eAAe,EAAE,GAClC,eAAe,CAQjB;AAED;;;;;;;;;GASG;AACH,wBAAgB,8BAA8B,CAC5C,KAAK,EAAE,KAAK,EACZ,gBAAgB,EAAE,eAAe,EAAE,GAClC,eAAe,CAkBjB;AA4MD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,0BAA0B,CACxC,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,KAAK,KAAK,MAAM,OAI1B,MAAM,KAAK,MAAM,KAAG,MAAM,CAatC;AAED;;;;;;;;;GASG;AACH,wBAAgB,yBAAyB,CACvC,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,KAAK,KAAK,MAAM,OAE1B,MAAM,KAAK,MAAM,KAAG,MAAM,CAatC;AAqCD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,mBAAmB,CACjC,gBAAgB,EAAE,eAAe,EAAE,GAClC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,KAAK,MAAM,CAUlC;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,wBAAwB,CACtC,eAAe,EAAE,MAAM,EACvB,iBAAiB,CAAC,EAAE,MAAM,GACzB,MAAM,CA2BR"}
package/lib/route.js CHANGED
@@ -174,6 +174,7 @@ function getSortValues(getterFn, a, b) {
174
174
  const modeComparatorValue = {
175
175
  SUBWAY: 1,
176
176
  TRAM: 2,
177
+ TROLLEYBUS: 9,
177
178
  RAIL: 3,
178
179
  GONDOLA: 4,
179
180
  FERRY: 5,
@@ -205,8 +206,9 @@ const routeTypeComparatorValue = {
205
206
  // associate them with bus/rail.
206
207
  11: modeComparatorValue.BUS,
207
208
  // - Trolleybus.
208
- 12: modeComparatorValue.RAIL // - Monorail.
209
-
209
+ 12: modeComparatorValue.RAIL,
210
+ // - Monorail.
211
+ 13: modeComparatorValue.TROLLEYBUS
210
212
  }; // Gets a comparator value for a given route's type (OTP mode).
211
213
  // Note: JSDoc format not used to avoid bug in documentationjs.
212
214
  // ttps://github.com/documentationjs/documentation/issues/372
package/lib/route.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/route.ts"],"names":["getTransitOperatorFromFeedIdAndAgencyId","feedId","agencyId","transitOperators","find","transitOperator","getTransitOperatorFromLeg","leg","routeId","split","getTransitOperatorFromOtpRoute","route","id","agency","END_OF_LIST_COMPARATOR_VALUE","getTransitOperatorComparatorValue","length","name","agencyName","order","makeTransitOperatorComparator","a","b","aVal","bVal","getSortValues","getterFn","modeComparatorValue","SUBWAY","TRAM","RAIL","GONDOLA","FERRY","CABLE_CAR","FUNICULAR","BUS","routeTypeComparatorValue","getRouteTypeComparatorValue","Error","mode","type","console","warn","routeTypeComparator","startsWithAlphabeticCharacter","val","firstCharCode","charCodeAt","alphabeticShortNameComparator","aStartsWithAlphabeticCharacter","shortName","bStartsWithAlphabeticCharacter","makeNumericValueComparator","objGetterFn","isNaN","makeStringValueComparator","getRouteSortOrderValue","undefined","makeMultiCriteriaSort","criteria","i","curCriteriaComparatorValue","makeRouteComparator","obj","sortOrder","parseInt","longName","getMostReadableTextColor","backgroundColor","proposedTextColor","startsWith","fgLuminance","luminance","bgLuminance","Math","abs"],"mappings":";;;;;;;;;;;;;;;AACA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,uCAAT,CACLC,MADK,EAELC,QAFK,EAGLC,gBAHK,EAIY;AACjB,SACEA,gBAAgB,CAACC,IAAjB,CACEC,eAAe,IACbA,eAAe,CAACJ,MAAhB,KAA2BA,MAA3B,IACAI,eAAe,CAACH,QAAhB,KAA6BA,QAHjC,KAIK,IALP;AAOD;AAED;AACA;AACA;AACA;AACA;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ACQ,GAAG,IAAIA,GAAG,CAACb,SAAZ,CANC,EAO1BK,yBAAyB,CAACQ,GAAG,IAAIA,GAAG,CAACG,QAAZ,CAPC,CAA5B;AASD;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASC,wBAAT,CACLC,eADK,EAELC,iBAFK,EAGG;AACR;AACA,MAAI,CAACD,eAAL,EAAsBA,eAAe,GAAG,SAAlB;AACtB,MAAI,CAACC,iBAAL,EAAwBA,iBAAiB,GAAG,SAApB;;AAExB,MAAI,CAACD,eAAe,CAACE,UAAhB,CAA2B,GAA3B,CAAL,EAAsC;AACpCF,IAAAA,eAAe,GAAI,IAAGA,eAAgB,EAAtC;AACD;;AACD,MAAI,CAACC,iBAAiB,CAACC,UAAlB,CAA6B,GAA7B,CAAL,EAAwC;AACtCD,IAAAA,iBAAiB,GAAI,IAAGA,iBAAkB,EAA1C;AACD,GAVO,CAYR;AACA;;;AACA,QAAME,WAAW,GAAG,uBAAOF,iBAAP,EAA0BG,SAA1B,EAApB;AACA,QAAMC,WAAW,GAAG,uBAAOL,eAAP,EAAwBI,SAAxB,EAApB;;AACA,MACEC,WAAW,GAAGF,WAAd,GAA4B,IAA5B,IACAE,WAAW,GAAGF,WAAd,GAA4B,IAD5B,IAEAG,IAAI,CAACC,GAAL,CAASF,WAAW,GAAGF,WAAvB,IAAsC,GAHxC,EAIE;AACA,WAAOF,iBAAP;AACD,GAtBO,CAwBR;AACA;;;AACA,SAAO,uBAAOD,eAAP,EAAwBI,SAAxB,KAAsC,GAAtC,GAA4C,SAA5C,GAAwD,SAA/D;AACD","sourcesContent":["import { Leg, Route, TransitOperator } from \"@opentripplanner/types\";\nimport chroma from \"chroma-js\";\n/**\n * Returns the transit operator (if an exact match is found) from the transit\n * operators config value. It is critical to use both the feedId and agencyId in\n * this method because it is possible in OTP for there to be a duplicate\n * agencyId in separate feeds.\n *\n * @param {string} feedId The feedId that this transit agency belongs to\n * @param {string} agencyId The agencyId of the transit agency\n * @param {array} transitOperators The transitOperators list from the config\n * @return {object} The transitOperator if a match was found or null if no match\n * was found\n */\nexport function getTransitOperatorFromFeedIdAndAgencyId(\n feedId: string,\n agencyId: string | number,\n transitOperators: TransitOperator[]\n): TransitOperator {\n return (\n transitOperators.find(\n transitOperator =>\n transitOperator.feedId === feedId &&\n transitOperator.agencyId === agencyId\n ) || null\n );\n}\n\n/**\n * Looks up an operator from the provided leg.\n *\n * @param {object} leg The Itinerary Leg from which to find the transit\n * operator\n * @param {object} transitOperators transitOperators from config.\n * @return {object} the operator if one was found or null if no match was found\n */\nexport function getTransitOperatorFromLeg(\n leg: Leg,\n transitOperators: TransitOperator[]\n): TransitOperator {\n if (!leg.routeId || !leg.agencyId) return null;\n const feedId = leg.routeId.split(\":\")[0];\n return getTransitOperatorFromFeedIdAndAgencyId(\n feedId,\n leg.agencyId,\n transitOperators\n );\n}\n\n/**\n * Looks up an operator from the provided configuration given an OTP route.\n * NOTE: this assumes the use of the OTP Route model or a modified OTP\n * RouteShort model (such as the one found in the IBI fork of OTP) that also\n * returns the agencyId.\n *\n * @param {object} route Either an OTP Route or RouteShort model\n * @param {array} transitOperators transitOperators from config\n * @return {object} the operator if one was found or null if no match was found\n */\nexport function getTransitOperatorFromOtpRoute(\n route: Route,\n transitOperators: TransitOperator[]\n): TransitOperator {\n if (!route.id) return null;\n const feedId = route.id.split(\":\")[0];\n let agencyId: string | number;\n if (route.agency) {\n // This is returned in the OTP Route model\n agencyId = route.agency.id;\n } else if (route.agencyId) {\n // This is returned in the OTP RouteShort model (such as in the IBI fork)\n agencyId = route.agencyId;\n } else {\n return null;\n }\n return getTransitOperatorFromFeedIdAndAgencyId(\n feedId,\n agencyId,\n transitOperators\n );\n}\n\n// The functions below are for enhanced route sorting functions for the route\n// viewer on OTP-react-redux.\n// They address route ordering issues discussed in\n// https://github.com/opentripplanner/otp-react-redux/pull/123 and\n// https://github.com/opentripplanner/otp-react-redux/pull/124.\n\n/**\n * A large comparator value that can safely be used in mathematical sort\n * comparisons to place things at the end of lists\n */\nconst END_OF_LIST_COMPARATOR_VALUE = 999999999999;\n\n/**\n * Returns a transit operator comparator value given a route and an optional\n * transitOperators config value. This function will do its best to handle all\n * kinds of input data as certain deployments of an implementing webapp may have\n * incomplete data and certain versions of OTP might not have a modified\n * implementation of the RouteShort model.\n *\n * @param {object} route Either an OTP Route or RouteShort model\n * @param {array} transitOperators transitOperators from config\n * @return {mixed} this could return a string value (the route's agency name) if\n * the transitOperators value is not defined. Otherwise an integer will be\n * returned.\n */\nfunction getTransitOperatorComparatorValue(\n route: Route,\n transitOperators: TransitOperator[]\n): number | string {\n // if the transitOperators is undefined or has zero length, use the route's\n // agency name as the comparator value\n if (!transitOperators || transitOperators.length === 0) {\n // OTP Route\n if (route.agency) return route.agency.name;\n // OTP RouteShort (base OTP repo or IBI fork)\n if (route.agencyName) return route.agencyName;\n // shouldn't happen as agency names will be defined\n return \"zzz\";\n }\n\n // find operator associated with route\n const transitOperator = getTransitOperatorFromOtpRoute(\n route,\n transitOperators\n );\n\n // if transit operator not found, return infinity\n if (!transitOperator) return END_OF_LIST_COMPARATOR_VALUE;\n\n // return the transit operator's sort value or END_OF_LIST_COMPARATOR_VALUE if\n // the sort value is not a number\n return typeof transitOperator.order === \"number\"\n ? transitOperator.order\n : END_OF_LIST_COMPARATOR_VALUE;\n}\n\n/**\n * Calculates the sort comparator value given two routes based off of the\n * route's agency and provided transitOperators config data.\n */\nfunction makeTransitOperatorComparator(transitOperators: TransitOperator[]) {\n return (a: Route, b: Route) => {\n const aVal = getTransitOperatorComparatorValue(a, transitOperators);\n const bVal = getTransitOperatorComparatorValue(b, transitOperators);\n if (typeof aVal === \"string\") {\n // happens when transitOperators is undefined. Both aVal are guaranteed to\n // be strings. Make a string comparison.\n if (aVal < bVal) return -1;\n if (aVal > bVal) return 1;\n return 0;\n }\n // @ts-expect-error transitOperators are defined and therefore a numeric value is guaranteed\n // to be returned\n return aVal - bVal;\n };\n}\n\n/**\n * Gets the desired sort values according to an optional getter function. If the\n * getter function is not defined, the original sort values are returned.\n */\nfunction getSortValues(\n getterFn: (item: unknown) => unknown,\n a: unknown,\n b: unknown\n) {\n let aVal: unknown;\n let bVal: unknown;\n if (typeof getterFn === \"function\") {\n aVal = getterFn(a);\n bVal = getterFn(b);\n } else {\n aVal = a;\n bVal = b;\n }\n return { aVal, bVal };\n}\n\n// Lookup for the sort values associated with various OTP modes.\n// Note: JSDoc format not used to avoid bug in documentationjs.\n// https://github.com/documentationjs/documentation/issues/372\nconst modeComparatorValue = {\n SUBWAY: 1,\n TRAM: 2,\n RAIL: 3,\n GONDOLA: 4,\n FERRY: 5,\n CABLE_CAR: 6,\n FUNICULAR: 7,\n BUS: 8\n};\n\n// Lookup that maps route types to the OTP mode sort values.\n// Note: JSDoc format not used to avoid bug in documentationjs.\n// https://github.com/documentationjs/documentation/issues/372\nconst routeTypeComparatorValue = {\n 0: modeComparatorValue.TRAM, // - Tram, Streetcar, Light rail.\n 1: modeComparatorValue.SUBWAY, // - Subway, Metro.\n 2: modeComparatorValue.RAIL, // - Rail. Used for intercity or long-distance travel.\n 3: modeComparatorValue.BUS, // - Bus.\n 4: modeComparatorValue.FERRY, // - Ferry.\n 5: modeComparatorValue.CABLE_CAR, // - Cable tram.\n 6: modeComparatorValue.GONDOLA, // - Gondola, etc.\n 7: modeComparatorValue.FUNICULAR, // - Funicular.\n // TODO: 11 and 12 are not a part of OTP as of 2019-02-14, but for now just\n // associate them with bus/rail.\n 11: modeComparatorValue.BUS, // - Trolleybus.\n 12: modeComparatorValue.RAIL // - Monorail.\n};\n\n// Gets a comparator value for a given route's type (OTP mode).\n// Note: JSDoc format not used to avoid bug in documentationjs.\n// ttps://github.com/documentationjs/documentation/issues/372\nfunction getRouteTypeComparatorValue(route: Route): number {\n // For some strange reason, the short route response in OTP returns the\n // string-based modes, but the long route response returns the\n // integer route type. This attempts to account for both of those cases.\n if (!route) throw new Error(`Route is undefined. ${route}`);\n if (typeof modeComparatorValue[route.mode] !== \"undefined\") {\n return modeComparatorValue[route.mode];\n }\n if (typeof routeTypeComparatorValue[route.type] !== \"undefined\") {\n return routeTypeComparatorValue[route.type];\n }\n // Default the comparator value to a large number (placing the route at the\n // end of the list).\n // eslint-disable-next-line no-console\n console.warn(\"no mode/route type found for route\", route);\n return END_OF_LIST_COMPARATOR_VALUE;\n}\n\n/**\n * Calculates the sort comparator value given two routes based off of route type\n * (OTP mode).\n */\nfunction routeTypeComparator(a: Route, b: Route): number {\n return getRouteTypeComparatorValue(a) - getRouteTypeComparatorValue(b);\n}\n\n/**\n * Determines whether a value is a string that starts with an alphabetic\n * ascii character.\n */\nfunction startsWithAlphabeticCharacter(val: unknown): boolean {\n if (typeof val === \"string\" && val.length > 0) {\n const firstCharCode = val.charCodeAt(0);\n return (\n (firstCharCode >= 65 && firstCharCode <= 90) ||\n (firstCharCode >= 97 && firstCharCode <= 122)\n );\n }\n return false;\n}\n\n/**\n * Sorts routes based off of whether the shortName begins with an alphabetic\n * character. Routes with shortn that do start with an alphabetic character will\n * be prioritized over those that don't.\n */\nfunction alphabeticShortNameComparator(a: Route, b: Route): number {\n const aStartsWithAlphabeticCharacter = startsWithAlphabeticCharacter(\n a.shortName\n );\n const bStartsWithAlphabeticCharacter = startsWithAlphabeticCharacter(\n b.shortName\n );\n\n if (aStartsWithAlphabeticCharacter && bStartsWithAlphabeticCharacter) {\n // both start with an alphabetic character, return equivalence\n return 0;\n }\n // a does start with an alphabetic character, but b does not. Prioritize a\n if (aStartsWithAlphabeticCharacter) return -1;\n // b does start with an alphabetic character, but a does not. Prioritize b\n if (bStartsWithAlphabeticCharacter) return 1;\n // neither route has a shortName that starts with an alphabetic character.\n // Return equivalence\n return 0;\n}\n\n/**\n * Checks whether an appropriate comparison of numeric values can be made for\n * sorting purposes. If both values are not valid numbers according to the\n * isNaN check, then this function returns undefined which indicates that a\n * secondary sorting criteria should be used instead. If one value is valid and\n * the other is not, then the valid value will be given sorting priority. If\n * both values are valid numbers, the difference is obtained as the sort value.\n *\n * An optional argument can be provided which will be used to obtain the\n * comparison value from the comparison function arguments.\n *\n * IMPORTANT: the comparison values must be numeric values or at least be\n * attempted to be converted to numeric values! If one of the arguments is\n * something crazy like an empty string, unexpected behavior will occur because\n * JavaScript.\n *\n * @param {function} [objGetterFn] An optional function to obtain the\n * comparison value from the comparator function arguments\n */\nexport function makeNumericValueComparator(\n objGetterFn?: (item: Route) => number\n) {\n /* Note: Using the global version of isNaN (the Number version behaves differently. */\n /* eslint-disable no-restricted-globals */\n return (a: number, b: number): number => {\n const { aVal, bVal } = getSortValues(objGetterFn, a, b);\n if (typeof aVal !== \"number\" || typeof bVal !== \"number\") return 0;\n\n // if both values aren't valid numbers, use the next sort criteria\n if (isNaN(aVal) && isNaN(bVal)) return 0;\n // b is a valid number, b gets priority\n if (isNaN(aVal)) return 1;\n // a is a valid number, a gets priority\n if (isNaN(bVal)) return -1;\n // a and b are valid numbers, return the sort value\n return aVal - bVal;\n };\n}\n\n/**\n * Create a comparator function that compares string values. The comparison\n * values feed to the sort comparator function are assumed to be objects that\n * will have either undefined, null or string values at the given key. If one\n * object has undefined, null or an empty string, but the other does have a\n * string with length > 0, then that string will get priority.\n *\n * @param {function} [objGetterFn] An optional function to obtain the\n * comparison value from the comparator function arguments\n */\nexport function makeStringValueComparator(\n objGetterFn?: (item: Route) => string\n) {\n return (a: string, b: string): number => {\n const { aVal, bVal } = getSortValues(objGetterFn, a, b);\n // both a and b are uncomparable strings, return equivalent value\n if (!aVal && !bVal) return 0;\n // a is not a comparable string, b gets priority\n if (!aVal) return 1;\n // b is not a comparable string, a gets priority\n if (!bVal) return -1;\n // a and b are comparable strings, return the sort value\n if (aVal < bVal) return -1;\n if (aVal > bVal) return 1;\n return 0;\n };\n}\n\n/**\n * OpenTripPlanner sets the routeSortOrder to -999 by default. So, if that value\n * is encountered, assume that it actually means that the routeSortOrder is not\n * set in the GTFS.\n *\n * See https://github.com/opentripplanner/OpenTripPlanner/issues/2938\n * Also see https://github.com/opentripplanner/otp-react-redux/issues/122\n */\nfunction getRouteSortOrderValue(val: number): number {\n return val === -999 ? undefined : val;\n}\n\n/**\n * Create a multi-criteria sort comparator function composed of other sort\n * comparator functions. Each comparator function will be ran in the order given\n * until a non-zero comparison value is obtained which is then immediately\n * returned. If all comparison functions return equivalence, then the values\n * are assumed to be equivalent.\n */\nfunction makeMultiCriteriaSort(\n ...criteria: ((a: unknown, b: unknown) => number)[]\n) {\n return (a: number, b: number): number => {\n for (let i = 0; i < criteria.length; i++) {\n const curCriteriaComparatorValue = criteria[i](a, b);\n // if the comparison objects are not equivalent, return the value obtained\n // in this current criteria comparison\n if (curCriteriaComparatorValue !== 0) {\n return curCriteriaComparatorValue;\n }\n }\n return 0;\n };\n}\n\n/**\n * Creates a sort comparator function to compares routes for the purposes of\n * sorting and displaying in a user interface. This takes in a single optional\n * argument which should be a list of transitOperators as defined in the config\n * file. Due to GTFS feeds having varying levels of data quality, a multi-\n * criteria sort is needed to account for various differences. The criteria\n * included here are each applied to the routes in the order listed. If a given\n * sort criterion yields equivalence (e.g., two routes have the short name\n * \"20\"), the comparator falls back onto the next sort criterion (e.g., long\n * name). The sort operates on the following values (in order):\n *\n * 1. Transit Operator. The transit operator will be attempted to be obtained\n * for each route. If no argument is provided when creating this comparator\n * function, then routes will be sorted by their agency's name. If an\n * argument is provided and a match is found based off of the route's feed_id\n * and agency_id and a transitOperator's feed_id and agency_id, then the\n * field transitOperator.order will be used as the comparator value as long\n * as it is numeric. If it is not numeric, a value is returned indicating\n * that this transit operator should be placed at the end of the list.\n * 2. sortOrder. Routes that do not have a valid sortOrder will be placed\n * beneath those that do.\n * 3. route type (OTP mode). See routeTypeComparator code for prioritization of\n * route types.\n * 4. shortNames that begin with alphabetic characters. shortNames that do not\n * start with alphabetic characters will be place beneath those that do.\n * 5. shortName as integer. shortNames that cannot be parsed as integers will\n * be placed beneath those that are valid.\n * 6. shortName as string. Routes without shortNames will be placed beneath\n * those with shortNames.\n * 7. longName as string.\n */\nexport function makeRouteComparator(\n transitOperators: TransitOperator[]\n): (a: number, b: number) => number {\n return makeMultiCriteriaSort(\n makeTransitOperatorComparator(transitOperators),\n makeNumericValueComparator(obj => getRouteSortOrderValue(obj.sortOrder)),\n routeTypeComparator,\n alphabeticShortNameComparator,\n makeNumericValueComparator(obj => parseInt(obj.shortName, 10)),\n makeStringValueComparator(obj => obj.shortName),\n makeStringValueComparator(obj => obj.longName)\n );\n}\n\n/**\n * Tests if a pair of colors is readable. If it is, that readable color is returned.\n * If it is not, a more appropriate alternative is returned.\n *\n * Uses algorithm based on combined luminance. Values have been derived from\n * looking at real agency color pairings. These pairings are difficult to\n * generate for, as some colors see both white and black used by different agencies.\n *\n * This method therefore can accept multiple colors (including black and white) for the same background color.\n *\n * @param backgroundColor A hex string, usually the \"routeColor\"\n * @param proposedTextColor A hex string, usually the \"routeTextColor\"\n */\nexport function getMostReadableTextColor(\n backgroundColor: string,\n proposedTextColor?: string\n): string {\n // Sometimes input will defy the method signature. Therefore we need extra fallbacks\n if (!backgroundColor) backgroundColor = \"#333333\";\n if (!proposedTextColor) proposedTextColor = \"#ffffff\";\n\n if (!backgroundColor.startsWith(\"#\")) {\n backgroundColor = `#${backgroundColor}`;\n }\n if (!proposedTextColor.startsWith(\"#\")) {\n proposedTextColor = `#${proposedTextColor}`;\n }\n\n // Check if proposed color is readable\n // Luminance thresholds have been selected based on actual transit agency colors\n const fgLuminance = chroma(proposedTextColor).luminance();\n const bgLuminance = chroma(backgroundColor).luminance();\n if (\n bgLuminance + fgLuminance < 1.41 &&\n bgLuminance + fgLuminance > 0.25 &&\n Math.abs(bgLuminance - fgLuminance) > 0.2\n ) {\n return proposedTextColor;\n }\n\n // Return black or white based on luminance of background color\n // When generating colors, white is preferred.\n return chroma(backgroundColor).luminance() < 0.4 ? \"#ffffff\" : \"#000000\";\n}\n"],"file":"route.js"}
1
+ {"version":3,"sources":["../src/route.ts"],"names":["getTransitOperatorFromFeedIdAndAgencyId","feedId","agencyId","transitOperators","find","transitOperator","getTransitOperatorFromLeg","leg","routeId","split","getTransitOperatorFromOtpRoute","route","id","agency","END_OF_LIST_COMPARATOR_VALUE","getTransitOperatorComparatorValue","length","name","agencyName","order","makeTransitOperatorComparator","a","b","aVal","bVal","getSortValues","getterFn","modeComparatorValue","SUBWAY","TRAM","TROLLEYBUS","RAIL","GONDOLA","FERRY","CABLE_CAR","FUNICULAR","BUS","routeTypeComparatorValue","getRouteTypeComparatorValue","Error","mode","type","console","warn","routeTypeComparator","startsWithAlphabeticCharacter","val","firstCharCode","charCodeAt","alphabeticShortNameComparator","aStartsWithAlphabeticCharacter","shortName","bStartsWithAlphabeticCharacter","makeNumericValueComparator","objGetterFn","isNaN","makeStringValueComparator","getRouteSortOrderValue","undefined","makeMultiCriteriaSort","criteria","i","curCriteriaComparatorValue","makeRouteComparator","obj","sortOrder","parseInt","longName","getMostReadableTextColor","backgroundColor","proposedTextColor","startsWith","fgLuminance","luminance","bgLuminance","Math","abs"],"mappings":";;;;;;;;;;;;;;;AACA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,uCAAT,CACLC,MADK,EAELC,QAFK,EAGLC,gBAHK,EAIY;AACjB,SACEA,gBAAgB,CAACC,IAAjB,CACEC,eAAe,IACbA,eAAe,CAACJ,MAAhB,KAA2BA,MAA3B,IACAI,eAAe,CAACH,QAAhB,KAA6BA,QAHjC,KAIK,IALP;AAOD;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASI,yBAAT,CACLC,GADK,EAELJ,gBAFK,EAGY;AACjB,MAAI,CAACI,GAAG,CAACC,OAAL,IAAgB,CAACD,GAAG,CAACL,QAAzB,EAAmC,OAAO,IAAP;AACnC,QAAMD,MAAM,GAAGM,GAAG,CAACC,OAAJ,CAAYC,KAAZ,CAAkB,GAAlB,EAAuB,CAAvB,CAAf;AACA,SAAOT,uCAAuC,CAC5CC,MAD4C,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,EAGG;AACR;AACA,MAAI,CAACD,eAAL,EAAsBA,eAAe,GAAG,SAAlB;AACtB,MAAI,CAACC,iBAAL,EAAwBA,iBAAiB,GAAG,SAApB;;AAExB,MAAI,CAACD,eAAe,CAACE,UAAhB,CAA2B,GAA3B,CAAL,EAAsC;AACpCF,IAAAA,eAAe,GAAI,IAAGA,eAAgB,EAAtC;AACD;;AACD,MAAI,CAACC,iBAAiB,CAACC,UAAlB,CAA6B,GAA7B,CAAL,EAAwC;AACtCD,IAAAA,iBAAiB,GAAI,IAAGA,iBAAkB,EAA1C;AACD,GAVO,CAYR;AACA;;;AACA,QAAME,WAAW,GAAG,uBAAOF,iBAAP,EAA0BG,SAA1B,EAApB;AACA,QAAMC,WAAW,GAAG,uBAAOL,eAAP,EAAwBI,SAAxB,EAApB;;AACA,MACEC,WAAW,GAAGF,WAAd,GAA4B,IAA5B,IACAE,WAAW,GAAGF,WAAd,GAA4B,IAD5B,IAEAG,IAAI,CAACC,GAAL,CAASF,WAAW,GAAGF,WAAvB,IAAsC,GAHxC,EAIE;AACA,WAAOF,iBAAP;AACD,GAtBO,CAwBR;AACA;;;AACA,SAAO,uBAAOD,eAAP,EAAwBI,SAAxB,KAAsC,GAAtC,GAA4C,SAA5C,GAAwD,SAA/D;AACD","sourcesContent":["import { Leg, Route, TransitOperator } from \"@opentripplanner/types\";\nimport chroma from \"chroma-js\";\n/**\n * Returns the transit operator (if an exact match is found) from the transit\n * operators config value. It is critical to use both the feedId and agencyId in\n * this method because it is possible in OTP for there to be a duplicate\n * agencyId in separate feeds.\n *\n * @param {string} feedId The feedId that this transit agency belongs to\n * @param {string} agencyId The agencyId of the transit agency\n * @param {array} transitOperators The transitOperators list from the config\n * @return {object} The transitOperator if a match was found or null if no match\n * was found\n */\nexport function getTransitOperatorFromFeedIdAndAgencyId(\n feedId: string,\n agencyId: string | number,\n transitOperators: TransitOperator[]\n): TransitOperator {\n return (\n transitOperators.find(\n transitOperator =>\n transitOperator.feedId === feedId &&\n transitOperator.agencyId === agencyId\n ) || null\n );\n}\n\n/**\n * Looks up an operator from the provided leg.\n *\n * @param {object} leg The Itinerary Leg from which to find the transit\n * operator\n * @param {object} transitOperators transitOperators from config.\n * @return {object} the operator if one was found or null if no match was found\n */\nexport function getTransitOperatorFromLeg(\n leg: Leg,\n transitOperators: TransitOperator[]\n): TransitOperator {\n if (!leg.routeId || !leg.agencyId) return null;\n const feedId = leg.routeId.split(\":\")[0];\n return getTransitOperatorFromFeedIdAndAgencyId(\n feedId,\n leg.agencyId,\n transitOperators\n );\n}\n\n/**\n * Looks up an operator from the provided configuration given an OTP route.\n * NOTE: this assumes the use of the OTP Route model or a modified OTP\n * RouteShort model (such as the one found in the IBI fork of OTP) that also\n * returns the agencyId.\n *\n * @param {object} route Either an OTP Route or RouteShort model\n * @param {array} transitOperators transitOperators from config\n * @return {object} the operator if one was found or null if no match was found\n */\nexport function getTransitOperatorFromOtpRoute(\n route: Route,\n transitOperators: TransitOperator[]\n): TransitOperator {\n if (!route.id) return null;\n const feedId = route.id.split(\":\")[0];\n let agencyId: string | number;\n if (route.agency) {\n // This is returned in the OTP Route model\n agencyId = route.agency.id;\n } else if (route.agencyId) {\n // This is returned in the OTP RouteShort model (such as in the IBI fork)\n agencyId = route.agencyId;\n } else {\n return null;\n }\n return getTransitOperatorFromFeedIdAndAgencyId(\n feedId,\n agencyId,\n transitOperators\n );\n}\n\n// The functions below are for enhanced route sorting functions for the route\n// viewer on OTP-react-redux.\n// They address route ordering issues discussed in\n// https://github.com/opentripplanner/otp-react-redux/pull/123 and\n// https://github.com/opentripplanner/otp-react-redux/pull/124.\n\n/**\n * A large comparator value that can safely be used in mathematical sort\n * comparisons to place things at the end of lists\n */\nconst END_OF_LIST_COMPARATOR_VALUE = 999999999999;\n\n/**\n * Returns a transit operator comparator value given a route and an optional\n * transitOperators config value. This function will do its best to handle all\n * kinds of input data as certain deployments of an implementing webapp may have\n * incomplete data and certain versions of OTP might not have a modified\n * implementation of the RouteShort model.\n *\n * @param {object} route Either an OTP Route or RouteShort model\n * @param {array} transitOperators transitOperators from config\n * @return {mixed} this could return a string value (the route's agency name) if\n * the transitOperators value is not defined. Otherwise an integer will be\n * returned.\n */\nfunction getTransitOperatorComparatorValue(\n route: Route,\n transitOperators: TransitOperator[]\n): number | string {\n // if the transitOperators is undefined or has zero length, use the route's\n // agency name as the comparator value\n if (!transitOperators || transitOperators.length === 0) {\n // OTP Route\n if (route.agency) return route.agency.name;\n // OTP RouteShort (base OTP repo or IBI fork)\n if (route.agencyName) return route.agencyName;\n // shouldn't happen as agency names will be defined\n return \"zzz\";\n }\n\n // find operator associated with route\n const transitOperator = getTransitOperatorFromOtpRoute(\n route,\n transitOperators\n );\n\n // if transit operator not found, return infinity\n if (!transitOperator) return END_OF_LIST_COMPARATOR_VALUE;\n\n // return the transit operator's sort value or END_OF_LIST_COMPARATOR_VALUE if\n // the sort value is not a number\n return typeof transitOperator.order === \"number\"\n ? transitOperator.order\n : END_OF_LIST_COMPARATOR_VALUE;\n}\n\n/**\n * Calculates the sort comparator value given two routes based off of the\n * route's agency and provided transitOperators config data.\n */\nfunction makeTransitOperatorComparator(transitOperators: TransitOperator[]) {\n return (a: Route, b: Route) => {\n const aVal = getTransitOperatorComparatorValue(a, transitOperators);\n const bVal = getTransitOperatorComparatorValue(b, transitOperators);\n if (typeof aVal === \"string\") {\n // happens when transitOperators is undefined. Both aVal are guaranteed to\n // be strings. Make a string comparison.\n if (aVal < bVal) return -1;\n if (aVal > bVal) return 1;\n return 0;\n }\n // @ts-expect-error transitOperators are defined and therefore a numeric value is guaranteed\n // to be returned\n return aVal - bVal;\n };\n}\n\n/**\n * Gets the desired sort values according to an optional getter function. If the\n * getter function is not defined, the original sort values are returned.\n */\nfunction getSortValues(\n getterFn: (item: unknown) => unknown,\n a: unknown,\n b: unknown\n) {\n let aVal: unknown;\n let bVal: unknown;\n if (typeof getterFn === \"function\") {\n aVal = getterFn(a);\n bVal = getterFn(b);\n } else {\n aVal = a;\n bVal = b;\n }\n return { aVal, bVal };\n}\n\n// Lookup for the sort values associated with various OTP modes.\n// Note: JSDoc format not used to avoid bug in documentationjs.\n// https://github.com/documentationjs/documentation/issues/372\nconst modeComparatorValue = {\n SUBWAY: 1,\n TRAM: 2,\n TROLLEYBUS: 9,\n RAIL: 3,\n GONDOLA: 4,\n FERRY: 5,\n CABLE_CAR: 6,\n FUNICULAR: 7,\n BUS: 8\n};\n\n// Lookup that maps route types to the OTP mode sort values.\n// Note: JSDoc format not used to avoid bug in documentationjs.\n// https://github.com/documentationjs/documentation/issues/372\nconst routeTypeComparatorValue = {\n 0: modeComparatorValue.TRAM, // - Tram, Streetcar, Light rail.\n 1: modeComparatorValue.SUBWAY, // - Subway, Metro.\n 2: modeComparatorValue.RAIL, // - Rail. Used for intercity or long-distance travel.\n 3: modeComparatorValue.BUS, // - Bus.\n 4: modeComparatorValue.FERRY, // - Ferry.\n 5: modeComparatorValue.CABLE_CAR, // - Cable tram.\n 6: modeComparatorValue.GONDOLA, // - Gondola, etc.\n 7: modeComparatorValue.FUNICULAR, // - Funicular.\n // TODO: 11 and 12 are not a part of OTP as of 2019-02-14, but for now just\n // associate them with bus/rail.\n 11: modeComparatorValue.BUS, // - Trolleybus.\n 12: modeComparatorValue.RAIL, // - Monorail.\n 13: modeComparatorValue.TROLLEYBUS\n};\n\n// Gets a comparator value for a given route's type (OTP mode).\n// Note: JSDoc format not used to avoid bug in documentationjs.\n// ttps://github.com/documentationjs/documentation/issues/372\nfunction getRouteTypeComparatorValue(route: Route): number {\n // For some strange reason, the short route response in OTP returns the\n // string-based modes, but the long route response returns the\n // integer route type. This attempts to account for both of those cases.\n if (!route) throw new Error(`Route is undefined. ${route}`);\n if (typeof modeComparatorValue[route.mode] !== \"undefined\") {\n return modeComparatorValue[route.mode];\n }\n if (typeof routeTypeComparatorValue[route.type] !== \"undefined\") {\n return routeTypeComparatorValue[route.type];\n }\n // Default the comparator value to a large number (placing the route at the\n // end of the list).\n // eslint-disable-next-line no-console\n console.warn(\"no mode/route type found for route\", route);\n return END_OF_LIST_COMPARATOR_VALUE;\n}\n\n/**\n * Calculates the sort comparator value given two routes based off of route type\n * (OTP mode).\n */\nfunction routeTypeComparator(a: Route, b: Route): number {\n return getRouteTypeComparatorValue(a) - getRouteTypeComparatorValue(b);\n}\n\n/**\n * Determines whether a value is a string that starts with an alphabetic\n * ascii character.\n */\nfunction startsWithAlphabeticCharacter(val: unknown): boolean {\n if (typeof val === \"string\" && val.length > 0) {\n const firstCharCode = val.charCodeAt(0);\n return (\n (firstCharCode >= 65 && firstCharCode <= 90) ||\n (firstCharCode >= 97 && firstCharCode <= 122)\n );\n }\n return false;\n}\n\n/**\n * Sorts routes based off of whether the shortName begins with an alphabetic\n * character. Routes with shortn that do start with an alphabetic character will\n * be prioritized over those that don't.\n */\nfunction alphabeticShortNameComparator(a: Route, b: Route): number {\n const aStartsWithAlphabeticCharacter = startsWithAlphabeticCharacter(\n a.shortName\n );\n const bStartsWithAlphabeticCharacter = startsWithAlphabeticCharacter(\n b.shortName\n );\n\n if (aStartsWithAlphabeticCharacter && bStartsWithAlphabeticCharacter) {\n // both start with an alphabetic character, return equivalence\n return 0;\n }\n // a does start with an alphabetic character, but b does not. Prioritize a\n if (aStartsWithAlphabeticCharacter) return -1;\n // b does start with an alphabetic character, but a does not. Prioritize b\n if (bStartsWithAlphabeticCharacter) return 1;\n // neither route has a shortName that starts with an alphabetic character.\n // Return equivalence\n return 0;\n}\n\n/**\n * Checks whether an appropriate comparison of numeric values can be made for\n * sorting purposes. If both values are not valid numbers according to the\n * isNaN check, then this function returns undefined which indicates that a\n * secondary sorting criteria should be used instead. If one value is valid and\n * the other is not, then the valid value will be given sorting priority. If\n * both values are valid numbers, the difference is obtained as the sort value.\n *\n * An optional argument can be provided which will be used to obtain the\n * comparison value from the comparison function arguments.\n *\n * IMPORTANT: the comparison values must be numeric values or at least be\n * attempted to be converted to numeric values! If one of the arguments is\n * something crazy like an empty string, unexpected behavior will occur because\n * JavaScript.\n *\n * @param {function} [objGetterFn] An optional function to obtain the\n * comparison value from the comparator function arguments\n */\nexport function makeNumericValueComparator(\n objGetterFn?: (item: Route) => number\n) {\n /* Note: Using the global version of isNaN (the Number version behaves differently. */\n /* eslint-disable no-restricted-globals */\n return (a: number, b: number): number => {\n const { aVal, bVal } = getSortValues(objGetterFn, a, b);\n if (typeof aVal !== \"number\" || typeof bVal !== \"number\") return 0;\n\n // if both values aren't valid numbers, use the next sort criteria\n if (isNaN(aVal) && isNaN(bVal)) return 0;\n // b is a valid number, b gets priority\n if (isNaN(aVal)) return 1;\n // a is a valid number, a gets priority\n if (isNaN(bVal)) return -1;\n // a and b are valid numbers, return the sort value\n return aVal - bVal;\n };\n}\n\n/**\n * Create a comparator function that compares string values. The comparison\n * values feed to the sort comparator function are assumed to be objects that\n * will have either undefined, null or string values at the given key. If one\n * object has undefined, null or an empty string, but the other does have a\n * string with length > 0, then that string will get priority.\n *\n * @param {function} [objGetterFn] An optional function to obtain the\n * comparison value from the comparator function arguments\n */\nexport function makeStringValueComparator(\n objGetterFn?: (item: Route) => string\n) {\n return (a: string, b: string): number => {\n const { aVal, bVal } = getSortValues(objGetterFn, a, b);\n // both a and b are uncomparable strings, return equivalent value\n if (!aVal && !bVal) return 0;\n // a is not a comparable string, b gets priority\n if (!aVal) return 1;\n // b is not a comparable string, a gets priority\n if (!bVal) return -1;\n // a and b are comparable strings, return the sort value\n if (aVal < bVal) return -1;\n if (aVal > bVal) return 1;\n return 0;\n };\n}\n\n/**\n * OpenTripPlanner sets the routeSortOrder to -999 by default. So, if that value\n * is encountered, assume that it actually means that the routeSortOrder is not\n * set in the GTFS.\n *\n * See https://github.com/opentripplanner/OpenTripPlanner/issues/2938\n * Also see https://github.com/opentripplanner/otp-react-redux/issues/122\n */\nfunction getRouteSortOrderValue(val: number): number {\n return val === -999 ? undefined : val;\n}\n\n/**\n * Create a multi-criteria sort comparator function composed of other sort\n * comparator functions. Each comparator function will be ran in the order given\n * until a non-zero comparison value is obtained which is then immediately\n * returned. If all comparison functions return equivalence, then the values\n * are assumed to be equivalent.\n */\nfunction makeMultiCriteriaSort(\n ...criteria: ((a: unknown, b: unknown) => number)[]\n) {\n return (a: number, b: number): number => {\n for (let i = 0; i < criteria.length; i++) {\n const curCriteriaComparatorValue = criteria[i](a, b);\n // if the comparison objects are not equivalent, return the value obtained\n // in this current criteria comparison\n if (curCriteriaComparatorValue !== 0) {\n return curCriteriaComparatorValue;\n }\n }\n return 0;\n };\n}\n\n/**\n * Creates a sort comparator function to compares routes for the purposes of\n * sorting and displaying in a user interface. This takes in a single optional\n * argument which should be a list of transitOperators as defined in the config\n * file. Due to GTFS feeds having varying levels of data quality, a multi-\n * criteria sort is needed to account for various differences. The criteria\n * included here are each applied to the routes in the order listed. If a given\n * sort criterion yields equivalence (e.g., two routes have the short name\n * \"20\"), the comparator falls back onto the next sort criterion (e.g., long\n * name). The sort operates on the following values (in order):\n *\n * 1. Transit Operator. The transit operator will be attempted to be obtained\n * for each route. If no argument is provided when creating this comparator\n * function, then routes will be sorted by their agency's name. If an\n * argument is provided and a match is found based off of the route's feed_id\n * and agency_id and a transitOperator's feed_id and agency_id, then the\n * field transitOperator.order will be used as the comparator value as long\n * as it is numeric. If it is not numeric, a value is returned indicating\n * that this transit operator should be placed at the end of the list.\n * 2. sortOrder. Routes that do not have a valid sortOrder will be placed\n * beneath those that do.\n * 3. route type (OTP mode). See routeTypeComparator code for prioritization of\n * route types.\n * 4. shortNames that begin with alphabetic characters. shortNames that do not\n * start with alphabetic characters will be place beneath those that do.\n * 5. shortName as integer. shortNames that cannot be parsed as integers will\n * be placed beneath those that are valid.\n * 6. shortName as string. Routes without shortNames will be placed beneath\n * those with shortNames.\n * 7. longName as string.\n */\nexport function makeRouteComparator(\n transitOperators: TransitOperator[]\n): (a: number, b: number) => number {\n return makeMultiCriteriaSort(\n makeTransitOperatorComparator(transitOperators),\n makeNumericValueComparator(obj => getRouteSortOrderValue(obj.sortOrder)),\n routeTypeComparator,\n alphabeticShortNameComparator,\n makeNumericValueComparator(obj => parseInt(obj.shortName, 10)),\n makeStringValueComparator(obj => obj.shortName),\n makeStringValueComparator(obj => obj.longName)\n );\n}\n\n/**\n * Tests if a pair of colors is readable. If it is, that readable color is returned.\n * If it is not, a more appropriate alternative is returned.\n *\n * Uses algorithm based on combined luminance. Values have been derived from\n * looking at real agency color pairings. These pairings are difficult to\n * generate for, as some colors see both white and black used by different agencies.\n *\n * This method therefore can accept multiple colors (including black and white) for the same background color.\n *\n * @param backgroundColor A hex string, usually the \"routeColor\"\n * @param proposedTextColor A hex string, usually the \"routeTextColor\"\n */\nexport function getMostReadableTextColor(\n backgroundColor: string,\n proposedTextColor?: string\n): string {\n // Sometimes input will defy the method signature. Therefore we need extra fallbacks\n if (!backgroundColor) backgroundColor = \"#333333\";\n if (!proposedTextColor) proposedTextColor = \"#ffffff\";\n\n if (!backgroundColor.startsWith(\"#\")) {\n backgroundColor = `#${backgroundColor}`;\n }\n if (!proposedTextColor.startsWith(\"#\")) {\n proposedTextColor = `#${proposedTextColor}`;\n }\n\n // Check if proposed color is readable\n // Luminance thresholds have been selected based on actual transit agency colors\n const fgLuminance = chroma(proposedTextColor).luminance();\n const bgLuminance = chroma(backgroundColor).luminance();\n if (\n bgLuminance + fgLuminance < 1.41 &&\n bgLuminance + fgLuminance > 0.25 &&\n Math.abs(bgLuminance - fgLuminance) > 0.2\n ) {\n return proposedTextColor;\n }\n\n // Return black or white based on luminance of background color\n // When generating colors, white is preferred.\n return chroma(backgroundColor).luminance() < 0.4 ? \"#ffffff\" : \"#000000\";\n}\n"],"file":"route.js"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opentripplanner/core-utils",
3
- "version": "12.0.0-alpha.6",
3
+ "version": "12.0.0-alpha.8",
4
4
  "description": "Core functionality that is shared among numerous UI components",
5
5
  "engines": {
6
6
  "node": ">=13"
@@ -214,6 +214,16 @@ describe("query-gen", () => {
214
214
  ["BUS", "RAIL", "GONDOLA", "TRAM", "TRANSIT"],
215
215
  [["BUS", "RAIL", "GONDOLA", "TRAM"]]
216
216
  );
217
+ expectModes(
218
+ // Trolleybus exists
219
+ ["TROLLEYBUS", "TRANSIT"],
220
+ [["TROLLEYBUS"]]
221
+ );
222
+ expectModes(
223
+ // Trolleybus exists
224
+ ["TROLLEYBUS", "BUS", "TRANSIT"],
225
+ [["TROLLEYBUS", "BUS"]]
226
+ );
217
227
  expectModes(
218
228
  // Transit is required to enable other transit submodes
219
229
  ["TRANSIT"],
package/src/itinerary.ts CHANGED
@@ -19,6 +19,7 @@ import turfAlong from "@turf/along";
19
19
  // All OTP transit modes
20
20
  export const transitModes = [
21
21
  "TRAM",
22
+ "TROLLEYBUS",
22
23
  "BUS",
23
24
  "SUBWAY",
24
25
  "FERRY",
@@ -178,6 +179,7 @@ export function getMapColor(mode: string): string {
178
179
  if (mode === "SUBWAY") return "#e60000";
179
180
  if (mode === "RAIL") return "#b00";
180
181
  if (mode === "BUS") return "#080";
182
+ if (mode === "TROLLEYBUS") return "#080";
181
183
  if (mode === "TRAM") return "#800";
182
184
  if (mode === "FERRY") return "#008";
183
185
  if (mode === "CAR") return "#444";
@@ -489,6 +491,7 @@ const CARBON_INTENSITY_DEFAULTS = {
489
491
  bicycle: 0.017,
490
492
  car: 0.162,
491
493
  tram: 0.066,
494
+ trolleybus: 0.066,
492
495
  subway: 0.066,
493
496
  rail: 0.066,
494
497
  bus: 0.09,