@opentripplanner/core-utils 9.0.0-alpha.6 → 9.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/esm/query-gen.js +77 -63
- package/esm/query-gen.js.map +1 -1
- package/lib/core-utils.story.d.ts +22 -0
- package/lib/core-utils.story.d.ts.map +1 -0
- package/lib/core-utils.story.js +69 -0
- package/lib/core-utils.story.js.map +1 -0
- package/lib/query-gen.d.ts +15 -8
- package/lib/query-gen.d.ts.map +1 -1
- package/lib/query-gen.js +63 -51
- package/lib/query-gen.js.map +1 -1
- package/package.json +3 -4
- package/src/__tests__/{query-params.js → query-params.ts} +25 -23
- package/src/planQuery.graphql +1 -0
- package/src/query-gen.ts +88 -76
- package/tsconfig.json +2 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/esm/state.js +0 -2
- package/esm/state.js.map +0 -1
- package/lib/state.d.ts +0 -1
- package/lib/state.d.ts.map +0 -1
- package/lib/state.js +0 -2
- package/lib/state.js.map +0 -1
- package/src/state.ts +0 -0
- /package/src/__tests__/__snapshots__/{query-params.js.snap → query-params.ts.snap} +0 -0
package/esm/query-gen.js
CHANGED
|
@@ -5,9 +5,8 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
5
5
|
|
|
6
6
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
7
7
|
|
|
8
|
-
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
9
8
|
import { print } from "graphql";
|
|
10
|
-
var PlanQuery = { kind: "Document", definitions: [{ kind: "OperationDefinition", operation: "query", name: { kind: "Name", value: "PlanQuery" }, variableDefinitions: [{ 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: "toPlace" } }, 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: "time" } }, type: { kind: "NamedType", name: { kind: "Name", value: "String" } }, 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: "wheelchair" } }, type: { kind: "NamedType", name: { kind: "Name", value: "Boolean" } }, 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: "walkReluctance" } }, type: { kind: "NamedType", name: { kind: "Name", value: "Float" } }, directives: [] }, { 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: "intermediatePlaces" } }, type: { kind: "ListType", type: { kind: "NamedType", name: { kind: "Name", value: "InputCoordinates" } } }, 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: "unpreferred" } }, type: { kind: "NamedType", name: { kind: "Name", value: "InputUnpreferred" } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "banned" } }, type: { kind: "NamedType", name: { kind: "Name", value: "InputBanned" } }, directives: [] }], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "plan" }, arguments: [{ kind: "Argument", name: { kind: "Name", value: "fromPlace" }, value: { kind: "Variable", name: { kind: "Name", value: "fromPlace" } } }, { 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: "locale" }, value: { kind: "StringValue", value: "en", block: false } }, { kind: "Argument", name: { kind: "Name", value: "time" }, value: { kind: "Variable", name: { kind: "Name", value: "time" } } }, { kind: "Argument", name: { kind: "Name", value: "date" }, value: { kind: "Variable", name: { kind: "Name", value: "date" } } }, { kind: "Argument", name: { kind: "Name", value: "wheelchair" }, value: { kind: "Variable", name: { kind: "Name", value: "wheelchair" } } }, { 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: "walkReluctance" }, value: { kind: "Variable", name: { kind: "Name", value: "walkReluctance" } } }, { kind: "Argument", name: { kind: "Name", value: "arriveBy" }, value: { kind: "Variable", name: { kind: "Name", value: "arriveBy" } } }, { kind: "Argument", name: { kind: "Name", value: "intermediatePlaces" }, value: { kind: "Variable", name: { kind: "Name", value: "intermediatePlaces" } } }, { kind: "Argument", name: { kind: "Name", value: "preferred" }, value: { kind: "Variable", name: { kind: "Name", value: "preferred" } } }, { kind: "Argument", name: { kind: "Name", value: "unpreferred" }, value: { kind: "Variable", name: { kind: "Name", value: "unpreferred" } } }, { kind: "Argument", name: { kind: "Name", value: "banned" }, value: { kind: "Variable", name: { kind: "Name", value: "banned" } } }], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "itineraries" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "duration" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "endTime" }, 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: "legs" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "distance" }, 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: "mode" }, 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: "startTime" }, 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: "id" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "gtfsId" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "agency" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "name" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "id" }, 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: "alertHeaderText" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "alertDescriptionText" }, 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: "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: "intermediateStops" }, 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", 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: "locationType" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "route" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "shortName" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "color" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "textColor" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "type" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "alerts" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "alertHeaderText" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "alertDescriptionText" }, 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: "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: "vertexType" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "stop" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "code" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "alerts" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "alertHeaderText" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "alertDescriptionText" }, 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: "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: "vertexType" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "stop" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "code" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "alerts" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "alertHeaderText" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "alertDescriptionText" }, 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: "steps" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "distance" }, 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: "absoluteDirection" }, 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: "area" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "alerts" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "alertHeaderText" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "alertDescriptionText" }, 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: "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: [] }] } }] } }] } }] } }] } }] } }], loc: { start: 0, end: 2380, source: { body: "query PlanQuery(\n\t$fromPlace: String!,\n\t$toPlace: String!,\n\t$modes: [TransportMode],\n\t$time: String,\n\t$date: String,\n\t$wheelchair: Boolean,\n\t$bikeReluctance: Float,\n\t$carReluctance: Float,\n\t$walkReluctance: Float,\n\t$arriveBy: Boolean,\n\t$intermediatePlaces: [InputCoordinates],\n\t$preferred: InputPreferred,\n\t$unpreferred: InputUnpreferred,\n\t$banned: InputBanned,\n) {\n\tplan(\n\t\tfromPlace: $fromPlace\n\t\ttoPlace: $toPlace\n\t\ttransportModes: $modes\n\t\tlocale: \"en\",\n\t\ttime: $time,\n\t\tdate: $date,\n\t\twheelchair: $wheelchair,\n\t\tbikeReluctance: $bikeReluctance,\n\t\tcarReluctance: $carReluctance,\n\t\twalkReluctance: $walkReluctance,\n\t\tarriveBy: $arriveBy,\n\t\tintermediatePlaces: $intermediatePlaces,\n\t\tpreferred: $preferred,\n\t\tunpreferred: $unpreferred,\n\t\tbanned: $banned,\n\t) {\n\t\titineraries {\n\t\t\tduration\n\t\t\tendTime\n\t\t\tstartTime\n\t\t\twaitingTime\n\t\t\twalkTime\n\t\t\tlegs {\n\t\t\t\tdistance\n\t\t\t\tduration\n\t\t\t\tendTime\n\t\t\t\tmode\n\t\t\t\trealTime\n\t\t\t\trealtimeState\t\n\t\t\t\tstartTime\n\t\t\t\ttransitLeg\n\t\t\t\ttrip {\n\t\t\t\t\tid\n\t\t\t\t\tgtfsId\n\t\t\t\t}\n\t\t\t\tagency {\n\t\t\t\t\tname\n\t\t\t\t\tid\n\t\t\t\t\ttimezone\n\t\t\t\t\turl\n\t\t\t\t\talerts {\n alertHeaderText\n alertDescriptionText\n alertUrl\n effectiveStartDate\n }\n\t\t\t\t}\n\t\t\t\tlegGeometry {\n\t\t\t\t\tlength\n\t\t\t\t\tpoints\n\t\t\t\t}\n\t\t\t\tintermediateStops {\n\t\t\t\t\tlat\n\t\t\t\t\tlon\n\t\t\t\t\tname\n\t\t\t\t\tstopCode: code\n\t\t\t\t\tstopId: id\n\t\t\t\t\tlocationType\n\t\t\t\t}\n\t\t\t\troute {\n\t\t\t\t\tshortName\n\t\t\t\t\tcolor\n\t\t\t\t\ttextColor\n\t\t\t\t\tid\n\t\t\t\t\ttype\n\t\t\t\t\talerts {\n alertHeaderText\n alertDescriptionText\n alertUrl\n effectiveStartDate\n }\n\t\t\t\t}\n\t\t\t\tfrom {\n\t\t\t\t\tlat\n\t\t\t\t\tlon\n\t\t\t\t\tname\n\t\t\t\t\tvertexType\n\t\t\t\t\tstop {\n\t\t\t\t\t\tid\n\t\t\t\t\t\tcode\n\t\t\t\t\t\talerts {\n\t\t\t\t\t\t\talertHeaderText\n\t\t\t\t\t\t\talertDescriptionText\n\t\t\t\t\t\t\talertUrl\n\t\t\t\t\t\t\teffectiveStartDate\n\t\t\t\t\t\t}\t\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tto {\n\t\t\t\t\tlat\n\t\t\t\t\tlon\n\t\t\t\t\tname\n\t\t\t\t\tvertexType\n\t\t\t\t\tstop {\n\t\t\t\t\t\tid\n\t\t\t\t\t\tcode\n\t\t\t\t\t\talerts {\n\t\t\t\t\t\t\talertHeaderText\n\t\t\t\t\t\t\talertDescriptionText\n\t\t\t\t\t\t\talertUrl\n\t\t\t\t\t\t\teffectiveStartDate\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tsteps {\n\t\t\t\t\tdistance\n\t\t\t\t\tlat\n\t\t\t\t\tlon\n relativeDirection\n absoluteDirection\n stayOn\n streetName\n area\n alerts{\n alertHeaderText\n alertDescriptionText\n alertUrl\n effectiveStartDate\n }\n\t\t\t\t\televationProfile {\n\t\t\t\t\t\tdistance\n\t\t\t\t\t\televation\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n", name: "GraphQL request", locationOffset: { line: 1, column: 1 } } } };
|
|
9
|
+
var PlanQuery = { kind: "Document", definitions: [{ kind: "OperationDefinition", operation: "query", name: { kind: "Name", value: "PlanQuery" }, variableDefinitions: [{ 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: "toPlace" } }, 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: "time" } }, type: { kind: "NamedType", name: { kind: "Name", value: "String" } }, 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: "wheelchair" } }, type: { kind: "NamedType", name: { kind: "Name", value: "Boolean" } }, 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: "walkReluctance" } }, type: { kind: "NamedType", name: { kind: "Name", value: "Float" } }, directives: [] }, { 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: "intermediatePlaces" } }, type: { kind: "ListType", type: { kind: "NamedType", name: { kind: "Name", value: "InputCoordinates" } } }, 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: "unpreferred" } }, type: { kind: "NamedType", name: { kind: "Name", value: "InputUnpreferred" } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "banned" } }, type: { kind: "NamedType", name: { kind: "Name", value: "InputBanned" } }, directives: [] }], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "plan" }, arguments: [{ kind: "Argument", name: { kind: "Name", value: "fromPlace" }, value: { kind: "Variable", name: { kind: "Name", value: "fromPlace" } } }, { 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: "locale" }, value: { kind: "StringValue", value: "en", block: false } }, { kind: "Argument", name: { kind: "Name", value: "time" }, value: { kind: "Variable", name: { kind: "Name", value: "time" } } }, { kind: "Argument", name: { kind: "Name", value: "date" }, value: { kind: "Variable", name: { kind: "Name", value: "date" } } }, { kind: "Argument", name: { kind: "Name", value: "wheelchair" }, value: { kind: "Variable", name: { kind: "Name", value: "wheelchair" } } }, { 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: "walkReluctance" }, value: { kind: "Variable", name: { kind: "Name", value: "walkReluctance" } } }, { kind: "Argument", name: { kind: "Name", value: "arriveBy" }, value: { kind: "Variable", name: { kind: "Name", value: "arriveBy" } } }, { kind: "Argument", name: { kind: "Name", value: "intermediatePlaces" }, value: { kind: "Variable", name: { kind: "Name", value: "intermediatePlaces" } } }, { kind: "Argument", name: { kind: "Name", value: "preferred" }, value: { kind: "Variable", name: { kind: "Name", value: "preferred" } } }, { kind: "Argument", name: { kind: "Name", value: "unpreferred" }, value: { kind: "Variable", name: { kind: "Name", value: "unpreferred" } } }, { kind: "Argument", name: { kind: "Name", value: "banned" }, value: { kind: "Variable", name: { kind: "Name", value: "banned" } } }], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "itineraries" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "duration" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "endTime" }, 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: "legs" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "distance" }, 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: "mode" }, 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: "startTime" }, 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: "id" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "gtfsId" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "agency" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "name" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "id" }, 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: "alertHeaderText" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "alertDescriptionText" }, 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: "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: "intermediateStops" }, 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", 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: "locationType" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "route" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "shortName" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "color" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "textColor" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "type" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "alerts" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "alertHeaderText" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "alertDescriptionText" }, 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: "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: "vertexType" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "stop" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "code" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "alerts" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "alertHeaderText" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "alertDescriptionText" }, 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: "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: "vertexType" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "stop" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "code" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "alerts" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "alertHeaderText" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "alertDescriptionText" }, 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: "steps" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "distance" }, 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: "absoluteDirection" }, 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: "area" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "alerts" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "alertHeaderText" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "alertDescriptionText" }, 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: "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: [] }] } }] } }] } }] } }] } }] } }], loc: { start: 0, end: 2445, source: { body: "query PlanQuery(\n\t$fromPlace: String!,\n\t$toPlace: String!,\n\t$modes: [TransportMode],\n\t$time: String,\n\t$date: String,\n\t$wheelchair: Boolean,\n\t$bikeReluctance: Float,\n\t$carReluctance: Float,\n\t$walkReluctance: Float,\n\t$arriveBy: Boolean,\n\t$intermediatePlaces: [InputCoordinates],\n\t$preferred: InputPreferred,\n\t$unpreferred: InputUnpreferred,\n\t$banned: InputBanned,\n) {\n\tplan(\n\t\tfromPlace: $fromPlace\n\t\ttoPlace: $toPlace\n\t\ttransportModes: $modes\n\t\t# Currently only supporting EN locale, used for times and text\n\t\tlocale: \"en\",\n\t\ttime: $time,\n\t\tdate: $date,\n\t\twheelchair: $wheelchair,\n\t\tbikeReluctance: $bikeReluctance,\n\t\tcarReluctance: $carReluctance,\n\t\twalkReluctance: $walkReluctance,\n\t\tarriveBy: $arriveBy,\n\t\tintermediatePlaces: $intermediatePlaces,\n\t\tpreferred: $preferred,\n\t\tunpreferred: $unpreferred,\n\t\tbanned: $banned,\n\t) {\n\t\titineraries {\n\t\t\tduration\n\t\t\tendTime\n\t\t\tstartTime\n\t\t\twaitingTime\n\t\t\twalkTime\n\t\t\tlegs {\n\t\t\t\tdistance\n\t\t\t\tduration\n\t\t\t\tendTime\n\t\t\t\tmode\n\t\t\t\trealTime\n\t\t\t\trealtimeState\t\n\t\t\t\tstartTime\n\t\t\t\ttransitLeg\n\t\t\t\ttrip {\n\t\t\t\t\tid\n\t\t\t\t\tgtfsId\n\t\t\t\t}\n\t\t\t\tagency {\n\t\t\t\t\tname\n\t\t\t\t\tid\n\t\t\t\t\ttimezone\n\t\t\t\t\turl\n\t\t\t\t\talerts {\n alertHeaderText\n alertDescriptionText\n alertUrl\n effectiveStartDate\n }\n\t\t\t\t}\n\t\t\t\tlegGeometry {\n\t\t\t\t\tlength\n\t\t\t\t\tpoints\n\t\t\t\t}\n\t\t\t\tintermediateStops {\n\t\t\t\t\tlat\n\t\t\t\t\tlon\n\t\t\t\t\tname\n\t\t\t\t\tstopCode: code\n\t\t\t\t\tstopId: id\n\t\t\t\t\tlocationType\n\t\t\t\t}\n\t\t\t\troute {\n\t\t\t\t\tshortName\n\t\t\t\t\tcolor\n\t\t\t\t\ttextColor\n\t\t\t\t\tid\n\t\t\t\t\ttype\n\t\t\t\t\talerts {\n alertHeaderText\n alertDescriptionText\n alertUrl\n effectiveStartDate\n }\n\t\t\t\t}\n\t\t\t\tfrom {\n\t\t\t\t\tlat\n\t\t\t\t\tlon\n\t\t\t\t\tname\n\t\t\t\t\tvertexType\n\t\t\t\t\tstop {\n\t\t\t\t\t\tid\n\t\t\t\t\t\tcode\n\t\t\t\t\t\talerts {\n\t\t\t\t\t\t\talertHeaderText\n\t\t\t\t\t\t\talertDescriptionText\n\t\t\t\t\t\t\talertUrl\n\t\t\t\t\t\t\teffectiveStartDate\n\t\t\t\t\t\t}\t\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tto {\n\t\t\t\t\tlat\n\t\t\t\t\tlon\n\t\t\t\t\tname\n\t\t\t\t\tvertexType\n\t\t\t\t\tstop {\n\t\t\t\t\t\tid\n\t\t\t\t\t\tcode\n\t\t\t\t\t\talerts {\n\t\t\t\t\t\t\talertHeaderText\n\t\t\t\t\t\t\talertDescriptionText\n\t\t\t\t\t\t\talertUrl\n\t\t\t\t\t\t\teffectiveStartDate\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tsteps {\n\t\t\t\t\tdistance\n\t\t\t\t\tlat\n\t\t\t\t\tlon\n relativeDirection\n absoluteDirection\n stayOn\n streetName\n area\n alerts{\n alertHeaderText\n alertDescriptionText\n alertUrl\n effectiveStartDate\n }\n\t\t\t\t\televationProfile {\n\t\t\t\t\t\tdistance\n\t\t\t\t\t\televation\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n", name: "GraphQL request", locationOffset: { line: 1, column: 1 } } } };
|
|
11
10
|
|
|
12
11
|
/**
|
|
13
12
|
* Mode Settings can contain additional modes to add to the query,
|
|
@@ -36,9 +35,7 @@ export function extractAdditionalModes(modeSettings, enabledModes) {
|
|
|
36
35
|
}).addTransportMode;
|
|
37
36
|
|
|
38
37
|
if (transportMode) {
|
|
39
|
-
return [].concat(_toConsumableArray(prev), [
|
|
40
|
-
return o.value === cur.value;
|
|
41
|
-
}).addTransportMode]);
|
|
38
|
+
return [].concat(_toConsumableArray(prev), [transportMode]);
|
|
42
39
|
}
|
|
43
40
|
}
|
|
44
41
|
|
|
@@ -64,6 +61,11 @@ function combinations(array) {
|
|
|
64
61
|
})
|
|
65
62
|
);
|
|
66
63
|
}
|
|
64
|
+
/**
|
|
65
|
+
* This constant maps all the transport mode to a broader mode type,
|
|
66
|
+
* which is used to determine the valid combinations of modes used in query generation.
|
|
67
|
+
*/
|
|
68
|
+
|
|
67
69
|
|
|
68
70
|
export var SIMPLIFICATIONS = {
|
|
69
71
|
AIRPLANE: "TRANSIT",
|
|
@@ -82,23 +84,67 @@ export var SIMPLIFICATIONS = {
|
|
|
82
84
|
TRAM: "TRANSIT",
|
|
83
85
|
TRANSIT: "TRANSIT",
|
|
84
86
|
WALK: "WALK"
|
|
85
|
-
};
|
|
87
|
+
}; // Inclusion of "TRANSIT" alone automatically implies "WALK" in OTP
|
|
88
|
+
|
|
89
|
+
var VALID_COMBOS = [["WALK"], ["PERSONAL"], ["TRANSIT", "SHARED"], ["WALK", "SHARED"], ["TRANSIT"], ["TRANSIT", "PERSONAL"], ["TRANSIT", "CAR"]];
|
|
90
|
+
var BANNED_TOGETHER = ["SCOOTER", "BICYCLE"];
|
|
86
91
|
export var TRANSIT_SUBMODES = Object.keys(SIMPLIFICATIONS).filter(function (mode) {
|
|
87
92
|
return SIMPLIFICATIONS[mode] === "TRANSIT" && mode !== "TRANSIT";
|
|
88
93
|
});
|
|
89
94
|
export var TRANSIT_SUBMODES_AND_TRANSIT = Object.keys(SIMPLIFICATIONS).filter(function (mode) {
|
|
90
95
|
return SIMPLIFICATIONS[mode] === "TRANSIT";
|
|
91
96
|
});
|
|
97
|
+
|
|
98
|
+
function isCombinationValid(combo, queryTransitSubmodes) {
|
|
99
|
+
if (combo.length === 0) return false; // All current qualifiers currently simplify to "SHARED"
|
|
100
|
+
|
|
101
|
+
var simplifiedModes = Array.from(new Set(combo.map(function (c) {
|
|
102
|
+
return c.qualifier ? "SHARED" : SIMPLIFICATIONS[c.mode];
|
|
103
|
+
}))); // Ensure that if we have one transit mode, then we include ALL transit modes
|
|
104
|
+
|
|
105
|
+
if (simplifiedModes.includes("TRANSIT")) {
|
|
106
|
+
// Don't allow TRANSIT along with any other submodes
|
|
107
|
+
if (queryTransitSubmodes.length && combo.find(function (c) {
|
|
108
|
+
return c.mode === "TRANSIT";
|
|
109
|
+
})) {
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if (combo.reduce(function (prev, cur) {
|
|
114
|
+
if (queryTransitSubmodes.includes(cur.mode)) {
|
|
115
|
+
return prev - 1;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return prev;
|
|
119
|
+
}, queryTransitSubmodes.length) !== 0) {
|
|
120
|
+
return false;
|
|
121
|
+
} // Continue to the other checks
|
|
122
|
+
|
|
123
|
+
} // OTP doesn't support multiple non-walk modes
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
if (BANNED_TOGETHER.every(function (m) {
|
|
127
|
+
return combo.find(function (c) {
|
|
128
|
+
return c.mode === m;
|
|
129
|
+
});
|
|
130
|
+
})) return false;
|
|
131
|
+
return !!VALID_COMBOS.find(function (vc) {
|
|
132
|
+
return simplifiedModes.every(function (m) {
|
|
133
|
+
return vc.includes(m);
|
|
134
|
+
}) && vc.every(function (m) {
|
|
135
|
+
return simplifiedModes.includes(m);
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
}
|
|
92
139
|
/**
|
|
93
|
-
* Generates list of queries for OTP to get a comprehensive
|
|
140
|
+
* Generates a list of queries for OTP to get a comprehensive
|
|
94
141
|
* set of results based on the modes input.
|
|
95
142
|
* @param params OTP Query Params
|
|
96
143
|
* @returns Set of parameters to generate queries
|
|
97
144
|
*/
|
|
98
145
|
|
|
146
|
+
|
|
99
147
|
export function generateCombinations(params) {
|
|
100
|
-
var VALID_COMBOS = [["WALK"], ["PERSONAL"], ["TRANSIT", "SHARED"], ["WALK", "SHARED"], ["TRANSIT"], ["TRANSIT", "PERSONAL"], ["TRANSIT", "CAR"]];
|
|
101
|
-
var BANNED_TOGETHER = ["SCOOTER", "BICYCLE"];
|
|
102
148
|
var completeModeList = [].concat(_toConsumableArray(extractAdditionalModes(params.modeSettings, params.modes)), _toConsumableArray(params.modes)); // List of the transit *submodes* that are included in the input params
|
|
103
149
|
|
|
104
150
|
var queryTransitSubmodes = completeModeList.filter(function (mode) {
|
|
@@ -107,75 +153,43 @@ export function generateCombinations(params) {
|
|
|
107
153
|
return mode.mode;
|
|
108
154
|
});
|
|
109
155
|
return combinations(completeModeList).filter(function (combo) {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
var simplifiedModes = Array.from(new Set(combo.map(function (c) {
|
|
113
|
-
return c.qualifier ? "SHARED" : SIMPLIFICATIONS[c.mode];
|
|
114
|
-
}))); // Ensure that if we have one transit mode, then we include ALL transit modes
|
|
115
|
-
|
|
116
|
-
if (simplifiedModes.includes("TRANSIT")) {
|
|
117
|
-
// Don't allow TRANSIT along with any other submodes
|
|
118
|
-
if (queryTransitSubmodes.length && combo.find(function (c) {
|
|
119
|
-
return c.mode === "TRANSIT";
|
|
120
|
-
})) {
|
|
121
|
-
return false;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
if (combo.reduce(function (prev, cur) {
|
|
125
|
-
if (queryTransitSubmodes.includes(cur.mode)) {
|
|
126
|
-
return prev - 1;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
return prev;
|
|
130
|
-
}, queryTransitSubmodes.length) !== 0) {
|
|
131
|
-
return false;
|
|
132
|
-
} // Continue to the other checks
|
|
133
|
-
|
|
134
|
-
} // OTP doesn't support multiple non-walk modes
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
if (BANNED_TOGETHER.every(function (m) {
|
|
138
|
-
return combo.find(function (c) {
|
|
139
|
-
return c.mode === m;
|
|
140
|
-
});
|
|
141
|
-
})) return false;
|
|
142
|
-
return !!VALID_COMBOS.find(function (vc) {
|
|
143
|
-
return simplifiedModes.every(function (m) {
|
|
144
|
-
return vc.includes(m);
|
|
145
|
-
}) && vc.every(function (m) {
|
|
146
|
-
return simplifiedModes.includes(m);
|
|
147
|
-
});
|
|
148
|
-
});
|
|
156
|
+
return isCombinationValid(combo, queryTransitSubmodes);
|
|
149
157
|
}).map(function (combo) {
|
|
150
158
|
return _objectSpread(_objectSpread({}, params), {}, {
|
|
151
159
|
modes: combo
|
|
152
160
|
});
|
|
153
161
|
});
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
from =
|
|
159
|
-
|
|
160
|
-
|
|
162
|
+
}
|
|
163
|
+
export function generateOtp2Query(_ref) {
|
|
164
|
+
var arriveBy = _ref.arriveBy,
|
|
165
|
+
date = _ref.date,
|
|
166
|
+
from = _ref.from,
|
|
167
|
+
modes = _ref.modes,
|
|
168
|
+
modeSettings = _ref.modeSettings,
|
|
169
|
+
time = _ref.time,
|
|
170
|
+
to = _ref.to;
|
|
171
|
+
// This extracts the values from the mode settings to key value pairs
|
|
161
172
|
var modeSettingValues = modeSettings.reduce(function (prev, cur) {
|
|
162
173
|
prev[cur.key] = cur.value;
|
|
163
174
|
return prev;
|
|
164
175
|
}, {});
|
|
165
|
-
var
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
176
|
+
var bikeReluctance = modeSettingValues.bikeReluctance,
|
|
177
|
+
carReluctance = modeSettingValues.carReluctance,
|
|
178
|
+
walkReluctance = modeSettingValues.walkReluctance,
|
|
179
|
+
wheelchair = modeSettingValues.wheelchair;
|
|
169
180
|
return {
|
|
170
181
|
query: print(PlanQuery),
|
|
171
182
|
variables: {
|
|
183
|
+
arriveBy: arriveBy,
|
|
184
|
+
bikeReluctance: bikeReluctance,
|
|
185
|
+
carReluctance: carReluctance,
|
|
186
|
+
date: date,
|
|
172
187
|
fromPlace: "".concat(from.name, "::").concat(from.lat, ",").concat(from.lon, "}"),
|
|
188
|
+
modes: modes,
|
|
189
|
+
time: time,
|
|
173
190
|
toPlace: "".concat(to.name, "::").concat(to.lat, ",").concat(to.lon, "}"),
|
|
174
|
-
modes: params.modes,
|
|
175
191
|
walkReluctance: walkReluctance,
|
|
176
|
-
wheelchair: wheelchair
|
|
177
|
-
bikeReluctance: bikeReluctance,
|
|
178
|
-
carReluctance: carReluctance
|
|
192
|
+
wheelchair: wheelchair
|
|
179
193
|
}
|
|
180
194
|
};
|
|
181
195
|
}
|
package/esm/query-gen.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/query-gen.ts"],"names":["print","extractAdditionalModes","modeSettings","enabledModes","reduce","prev","cur","map","m","mode","includes","applicableMode","type","addTransportMode","value","transportMode","options","find","o","combinations","array","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","TRANSIT_SUBMODES","Object","keys","TRANSIT_SUBMODES_AND_TRANSIT","generateCombinations","params","VALID_COMBOS","BANNED_TOGETHER","completeModeList","modes","queryTransitSubmodes","combo","simplifiedModes","from","Set","c","qualifier","every","vc","generateOtp2Query","to","modeSettingValues","key","walkReluctance","wheelchair","bikeReluctance","carReluctance","query","PlanQuery","variables","fromPlace","name","lat","lon","toPlace"],"mappings":";;;;;;;AAAA;AACA,SAASA,KAAT,QAAsB,SAAtB;;;AAqBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,sBAAT,CACLC,YADK,EAELC,YAFK,EAGiB;AACtB,SAAOD,YAAY,CAACE,MAAb,CAAqC,UAACC,IAAD,EAAOC,GAAP,EAAe;AACzD;AACA,QAAI,CAACH,YAAY,CAACI,GAAb,CAAiB,UAAAC,CAAC;AAAA,aAAIA,CAAC,CAACC,IAAN;AAAA,KAAlB,EAA8BC,QAA9B,CAAuCJ,GAAG,CAACK,cAA3C,CAAL,EAAiE;AAC/D,aAAON,IAAP;AACD,KAJwD,CAMzD;;;AACA,QAAIC,GAAG,CAACM,IAAJ,KAAa,UA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,iBALJ,CAEEG,UAFF;AAAA,MAGEC,cAHF,GAKIJ,iBALJ,CAGEI,cAHF;AAAA,MAIEC,aAJF,GAKIL,iBALJ,CAIEK,aAJF;AAOA,SAAO;AACLC,IAAAA,KAAK,EAAExE,KAAK,CAACyE,SAAD,CADP;AAELC,IAAAA,SAAS,EAAE;AACTC,MAAAA,SAAS,YAAKjB,IAAI,CAACkB,IAAV,eAAmBlB,IAAI,CAACmB,GAAxB,cAA+BnB,IAAI,CAACoB,GAApC,MADA;AAETC,MAAAA,OAAO,YAAKd,EAAE,CAACW,IAAR,eAAiBX,EAAE,CAACY,GAApB,cAA2BZ,EAAE,CAACa,GAA9B,MAFE;AAGTxB,MAAAA,KAAK,EAAEJ,MAAM,CAACI,KAHL;AAITc,MAAAA,cAAc,EAAdA,cAJS;AAKTC,MAAAA,UAAU,EAAVA,UALS;AAMTC,MAAAA,cAAc,EAAdA,cANS;AAOTC,MAAAA,aAAa,EAAbA;AAPS;AAFN,GAAP;AAYD","sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\nimport { print } from \"graphql\";\nimport {\n ModeSetting,\n ModeSettingValues,\n TransportMode\n} from \"@opentripplanner/types\";\nimport { LonLatOutput } from \"@conveyal/lonlat\";\nimport PlanQuery from \"./planQuery.graphql\";\n\ntype OTPQueryParams = {\n to: LonLatOutput & { name?: string };\n from: LonLatOutput & { name?: string };\n modes: Array<TransportMode>;\n modeSettings: ModeSetting[];\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): Array<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, mode must be enabled and have a transport mode in it\n if (cur.type === \"CHECKBOX\" && cur.addTransportMode && cur.value) {\n return [...prev, cur.addTransportMode];\n }\n if (cur.type === \"DROPDOWN\") {\n const transportMode = cur.options.find(o => o.value === cur.value)\n .addTransportMode;\n if (transportMode) {\n return [\n ...prev,\n cur.options.find(o => o.value === cur.value).addTransportMode\n ];\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\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\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\n/**\n * Generates 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 VALID_COMBOS = [\n [\"WALK\"],\n [\"PERSONAL\"],\n [\"TRANSIT\", \"SHARED\"],\n [\"WALK\", \"SHARED\"],\n [\"TRANSIT\"],\n [\"TRANSIT\", \"PERSONAL\"],\n [\"TRANSIT\", \"CAR\"]\n ];\n\n const BANNED_TOGETHER = [\"SCOOTER\", \"BICYCLE\"];\n\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 => {\n if (combo.length === 0) return false;\n\n // All current qualifiers currently simplify to \"SHARED\"\n const simplifiedModes = Array.from(\n new Set(\n combo.map(c => (c.qualifier ? \"SHARED\" : SIMPLIFICATIONS[c.mode]))\n )\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 (\n queryTransitSubmodes.length &&\n combo.find(c => c.mode === \"TRANSIT\")\n ) {\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.every(m => combo.find(c => c.mode === m)))\n return false;\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 .map(combo => ({ ...params, modes: combo }));\n}\n\n// eslint-disable-next-line import/prefer-default-export\nexport function generateOtp2Query(params: OTPQueryParams): GraphQLQuery {\n const { to, from, modeSettings } = params;\n\n // This extracts the values from the mode settings to key value pairs\n const modeSettingValues = modeSettings.reduce((prev, cur) => {\n prev[cur.key] = cur.value;\n return prev;\n }, {}) as ModeSettingValues;\n\n const {\n walkReluctance,\n wheelchair,\n bikeReluctance,\n carReluctance\n } = modeSettingValues;\n\n return {\n query: print(PlanQuery),\n variables: {\n fromPlace: `${from.name}::${from.lat},${from.lon}}`,\n toPlace: `${to.name}::${to.lat},${to.lon}}`,\n modes: params.modes,\n walkReluctance,\n wheelchair,\n bikeReluctance,\n carReluctance\n }\n };\n}\n"],"file":"query-gen.js"}
|
|
1
|
+
{"version":3,"sources":["../src/query-gen.ts"],"names":["print","extractAdditionalModes","modeSettings","enabledModes","reduce","prev","cur","map","m","mode","includes","applicableMode","type","addTransportMode","value","transportMode","options","find","o","combinations","array","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","every","vc","generateCombinations","params","completeModeList","modes","generateOtp2Query","arriveBy","date","time","to","modeSettingValues","key","bikeReluctance","carReluctance","walkReluctance","wheelchair","query","PlanQuery","variables","fromPlace","name","lat","lon","toPlace"],"mappings":";;;;;;;AACA,SAASA,KAAT,QAAsB,SAAtB;;;AAwBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,sBAAT,CACLC,YADK,EAELC,YAFK,EAGY;AACjB,SAAOD,YAAY,CAACE,MAAb,CAAqC,UAACC,IAAD,EAAOC,GAAP,EAAe;AACzD;AACA,QAAI,CAACH,YAAY,CAACI,GAAb,CAAiB,UAAAC,CAAC;AAAA,aAAIA,CAAC,CAACC,IAAN;AAAA,KAAlB,EAA8BC,QAA9B,CAA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P,EAAe;AAC3DD,IAAAA,IAAI,CAACC,GAAG,CAACiE,GAAL,CAAJ,GAAgBjE,GAAG,CAACQ,KAApB;AACA,WAAOT,IAAP;AACD,GAHyB,EAGvB,EAHuB,CAA1B;AAKA,MACEmE,cADF,GAKIF,iBALJ,CACEE,cADF;AAAA,MAEEC,aAFF,GAKIH,iBALJ,CAEEG,aAFF;AAAA,MAGEC,cAHF,GAKIJ,iBALJ,CAGEI,cAHF;AAAA,MAIEC,UAJF,GAKIL,iBALJ,CAIEK,UAJF;AAOA,SAAO;AACLC,IAAAA,KAAK,EAAE5E,KAAK,CAAC6E,SAAD,CADP;AAELC,IAAAA,SAAS,EAAE;AACTZ,MAAAA,QAAQ,EAARA,QADS;AAETM,MAAAA,cAAc,EAAdA,cAFS;AAGTC,MAAAA,aAAa,EAAbA,aAHS;AAITN,MAAAA,IAAI,EAAJA,IAJS;AAKTY,MAAAA,SAAS,YAAKxB,IAAI,CAACyB,IAAV,eAAmBzB,IAAI,CAAC0B,GAAxB,cAA+B1B,IAAI,CAAC2B,GAApC,MALA;AAMTlB,MAAAA,KAAK,EAALA,KANS;AAOTI,MAAAA,IAAI,EAAJA,IAPS;AAQTe,MAAAA,OAAO,YAAKd,EAAE,CAACW,IAAR,eAAiBX,EAAE,CAACY,GAApB,cAA2BZ,EAAE,CAACa,GAA9B,MARE;AASTR,MAAAA,cAAc,EAAdA,cATS;AAUTC,MAAAA,UAAU,EAAVA;AAVS;AAFN,GAAP;AAeD","sourcesContent":["import { LonLatOutput } from \"@conveyal/lonlat\";\nimport { print } from \"graphql\";\nimport {\n ModeSetting,\n ModeSettingValues,\n TransportMode\n} from \"@opentripplanner/types\";\n\nimport PlanQuery from \"./planQuery.graphql\";\n\ntype OTPQueryParams = {\n arriveBy: boolean;\n date: string;\n from: LonLatOutput & { name?: string };\n modes: TransportMode[];\n modeSettings: ModeSetting[];\n time: string;\n to: LonLatOutput & { name?: string };\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, mode must be enabled and have a transport mode in it\n if (cur.type === \"CHECKBOX\" && cur.addTransportMode && cur.value) {\n return [...prev, cur.addTransportMode];\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\"];\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.every(m => combo.find(c => c.mode === m))) return false;\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\nexport function generateOtp2Query({\n arriveBy,\n date,\n from,\n modes,\n modeSettings,\n time,\n to\n}: OTPQueryParams): GraphQLQuery {\n // This extracts the values from the mode settings to key value pairs\n const modeSettingValues = modeSettings.reduce((prev, cur) => {\n prev[cur.key] = cur.value;\n return prev;\n }, {}) as ModeSettingValues;\n\n const {\n bikeReluctance,\n carReluctance,\n walkReluctance,\n wheelchair\n } = modeSettingValues;\n\n return {\n query: print(PlanQuery),\n variables: {\n arriveBy,\n bikeReluctance,\n carReluctance,\n date,\n fromPlace: `${from.name}::${from.lat},${from.lon}}`,\n modes,\n time,\n toPlace: `${to.name}::${to.lat},${to.lon}}`,\n walkReluctance,\n wheelchair\n }\n };\n}\n"],"file":"query-gen.js"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
declare const _default: {
|
|
3
|
+
title: string;
|
|
4
|
+
};
|
|
5
|
+
export default _default;
|
|
6
|
+
export declare const RouteColorTester: {
|
|
7
|
+
(): JSX.Element;
|
|
8
|
+
parameters: {
|
|
9
|
+
a11y: {
|
|
10
|
+
config: {
|
|
11
|
+
rules: {
|
|
12
|
+
id: string;
|
|
13
|
+
reviewOnFail: boolean;
|
|
14
|
+
}[];
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
storyshots: {
|
|
18
|
+
disable: boolean;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=core-utils.story.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core-utils.story.d.ts","sourceRoot":"","sources":["../src/core-utils.story.tsx"],"names":[],"mappings":";;;;AAIA,wBAEE;AA2BF,eAAO,MAAM,gBAAgB;QAAO,WAAW;;;;;;;;;;;;;;CAkB9C,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.RouteColorTester = void 0;
|
|
30
|
+
const react_1 = __importStar(require("react"));
|
|
31
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
32
|
+
const route_1 = require("./route");
|
|
33
|
+
exports.default = {
|
|
34
|
+
title: "core-utils"
|
|
35
|
+
};
|
|
36
|
+
const ColorBlock = styled_components_1.default.div `
|
|
37
|
+
background: ${props => props.bg};
|
|
38
|
+
color: ${props => props.fg};
|
|
39
|
+
padding: 10px;
|
|
40
|
+
`;
|
|
41
|
+
const ColorBlockWrapper = styled_components_1.default.div `
|
|
42
|
+
display: flex;
|
|
43
|
+
flex-direction: row;
|
|
44
|
+
gap: 10px;
|
|
45
|
+
`;
|
|
46
|
+
const ColorPair = ({ fg, bg }) => {
|
|
47
|
+
return (react_1.default.createElement(ColorBlockWrapper, null,
|
|
48
|
+
react_1.default.createElement(ColorBlock, { fg: fg, bg: bg }, "Provided color pair"),
|
|
49
|
+
react_1.default.createElement(ColorBlock, { fg: (0, route_1.getMostReadableTextColor)(bg, fg), bg: bg }, "Corrected color pair")));
|
|
50
|
+
};
|
|
51
|
+
const RouteColorTester = () => {
|
|
52
|
+
const [fg, setFg] = (0, react_1.useState)("#333333");
|
|
53
|
+
const [bg, setBg] = (0, react_1.useState)("#cbeb55");
|
|
54
|
+
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
55
|
+
react_1.default.createElement(ColorPair, { bg: bg, fg: fg }),
|
|
56
|
+
react_1.default.createElement("label", null,
|
|
57
|
+
"Foreground Color",
|
|
58
|
+
react_1.default.createElement("input", { onChange: e => setFg(e.target.value), type: "color", value: fg })),
|
|
59
|
+
react_1.default.createElement("label", null,
|
|
60
|
+
"Background Color",
|
|
61
|
+
react_1.default.createElement("input", { onChange: e => setBg(e.target.value), type: "color", value: bg }))));
|
|
62
|
+
};
|
|
63
|
+
exports.RouteColorTester = RouteColorTester;
|
|
64
|
+
// Disable color contrast checking for the uncorrected color pairs
|
|
65
|
+
exports.RouteColorTester.parameters = {
|
|
66
|
+
a11y: { config: { rules: [{ id: "color-contrast", reviewOnFail: true }] } },
|
|
67
|
+
storyshots: { disable: true }
|
|
68
|
+
};
|
|
69
|
+
//# sourceMappingURL=core-utils.story.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core-utils.story.js","sourceRoot":"","sources":["../src/core-utils.story.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAwC;AACxC,0EAAuC;AACvC,mCAAmD;AAEnD,kBAAe;IACb,KAAK,EAAE,YAAY;CACpB,CAAC;AAEF,MAAM,UAAU,GAAG,2BAAM,CAAC,GAAG,CAA4B;gBACzC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE;WACtB,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE;;CAE3B,CAAC;AAEF,MAAM,iBAAiB,GAAG,2BAAM,CAAC,GAAG,CAAA;;;;CAInC,CAAC;AAEF,MAAM,SAAS,GAAG,CAAC,EAAE,EAAE,EAAE,EAAE,EAA8B,EAAE,EAAE;IAC3D,OAAO,CACL,8BAAC,iBAAiB;QAChB,8BAAC,UAAU,IAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,0BAEb;QACb,8BAAC,UAAU,IAAC,EAAE,EAAE,IAAA,gCAAwB,EAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,2BAE3C,CACK,CACrB,CAAC;AACJ,CAAC,CAAC;AAEK,MAAM,gBAAgB,GAAG,GAAgB,EAAE;IAChD,MAAM,CAAC,EAAE,EAAE,KAAK,CAAC,GAAG,IAAA,gBAAQ,EAAC,SAAS,CAAC,CAAC;IACxC,MAAM,CAAC,EAAE,EAAE,KAAK,CAAC,GAAG,IAAA,gBAAQ,EAAC,SAAS,CAAC,CAAC;IACxC,OAAO,CACL;QACE,8BAAC,SAAS,IAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,GAAc;QAEvC;;YAEE,yCAAO,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,IAAI,EAAC,OAAO,EAAC,KAAK,EAAE,EAAE,GAAI,CACjE;QAER;;YAEE,yCAAO,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,IAAI,EAAC,OAAO,EAAC,KAAK,EAAE,EAAE,GAAI,CACjE,CACP,CACJ,CAAC;AACJ,CAAC,CAAC;AAlBW,QAAA,gBAAgB,oBAkB3B;AACF,kEAAkE;AAClE,wBAAgB,CAAC,UAAU,GAAG;IAC5B,IAAI,EAAE,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,EAAE,gBAAgB,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,EAAE,EAAE;IAC3E,UAAU,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE;CAC9B,CAAC"}
|
package/lib/query-gen.d.ts
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
import { ModeSetting, TransportMode } from "@opentripplanner/types";
|
|
2
1
|
import { LonLatOutput } from "@conveyal/lonlat";
|
|
2
|
+
import { ModeSetting, TransportMode } from "@opentripplanner/types";
|
|
3
3
|
declare type OTPQueryParams = {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
};
|
|
4
|
+
arriveBy: boolean;
|
|
5
|
+
date: string;
|
|
7
6
|
from: LonLatOutput & {
|
|
8
7
|
name?: string;
|
|
9
8
|
};
|
|
10
|
-
modes:
|
|
9
|
+
modes: TransportMode[];
|
|
11
10
|
modeSettings: ModeSetting[];
|
|
11
|
+
time: string;
|
|
12
|
+
to: LonLatOutput & {
|
|
13
|
+
name?: string;
|
|
14
|
+
};
|
|
12
15
|
};
|
|
13
16
|
declare type GraphQLQuery = {
|
|
14
17
|
query: string;
|
|
@@ -21,7 +24,11 @@ declare type GraphQLQuery = {
|
|
|
21
24
|
* @param modeSettings List of mode settings with values populated
|
|
22
25
|
* @returns Additional transport modes to add to query
|
|
23
26
|
*/
|
|
24
|
-
export declare function extractAdditionalModes(modeSettings: ModeSetting[], enabledModes: TransportMode[]):
|
|
27
|
+
export declare function extractAdditionalModes(modeSettings: ModeSetting[], enabledModes: TransportMode[]): TransportMode[];
|
|
28
|
+
/**
|
|
29
|
+
* This constant maps all the transport mode to a broader mode type,
|
|
30
|
+
* which is used to determine the valid combinations of modes used in query generation.
|
|
31
|
+
*/
|
|
25
32
|
export declare const SIMPLIFICATIONS: {
|
|
26
33
|
AIRPLANE: string;
|
|
27
34
|
BICYCLE: string;
|
|
@@ -42,12 +49,12 @@ export declare const SIMPLIFICATIONS: {
|
|
|
42
49
|
export declare const TRANSIT_SUBMODES: string[];
|
|
43
50
|
export declare const TRANSIT_SUBMODES_AND_TRANSIT: string[];
|
|
44
51
|
/**
|
|
45
|
-
* Generates list of queries for OTP to get a comprehensive
|
|
52
|
+
* Generates a list of queries for OTP to get a comprehensive
|
|
46
53
|
* set of results based on the modes input.
|
|
47
54
|
* @param params OTP Query Params
|
|
48
55
|
* @returns Set of parameters to generate queries
|
|
49
56
|
*/
|
|
50
57
|
export declare function generateCombinations(params: OTPQueryParams): OTPQueryParams[];
|
|
51
|
-
export declare function generateOtp2Query(
|
|
58
|
+
export declare function generateOtp2Query({ arriveBy, date, from, modes, modeSettings, time, to }: OTPQueryParams): GraphQLQuery;
|
|
52
59
|
export {};
|
|
53
60
|
//# sourceMappingURL=query-gen.d.ts.map
|
package/lib/query-gen.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query-gen.d.ts","sourceRoot":"","sources":["../src/query-gen.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"query-gen.d.ts","sourceRoot":"","sources":["../src/query-gen.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,OAAO,EACL,WAAW,EAEX,aAAa,EACd,MAAM,wBAAwB,CAAC;AAIhC,aAAK,cAAc,GAAG;IACpB,QAAQ,EAAE,OAAO,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,YAAY,GAAG;QAAE,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACvC,KAAK,EAAE,aAAa,EAAE,CAAC;IACvB,YAAY,EAAE,WAAW,EAAE,CAAC;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,YAAY,GAAG;QAAE,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CACtC,CAAC;AAEF,aAAK,YAAY,GAAG;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CACpC,YAAY,EAAE,WAAW,EAAE,EAC3B,YAAY,EAAE,aAAa,EAAE,GAC5B,aAAa,EAAE,CAoBjB;AAoBD;;;GAGG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;CAgB3B,CAAC;AAeF,eAAO,MAAM,gBAAgB,UAE5B,CAAC;AACF,eAAO,MAAM,4BAA4B,UAExC,CAAC;AA2CF;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,cAAc,GAAG,cAAc,EAAE,CAc7E;AAED,wBAAgB,iBAAiB,CAAC,EAChC,QAAQ,EACR,IAAI,EACJ,IAAI,EACJ,KAAK,EACL,YAAY,EACZ,IAAI,EACJ,EAAE,EACH,EAAE,cAAc,GAAG,YAAY,CA6B/B"}
|