Skip to content

Commit

Permalink
fix(paths): Filter out -1 path indexes indicating no route
Browse files Browse the repository at this point in the history
  • Loading branch information
trevorgerhardt committed Apr 27, 2018
1 parent 3799aee commit c7176c8
Show file tree
Hide file tree
Showing 10 changed files with 6,359 additions and 261 deletions.
4 changes: 2 additions & 2 deletions flow-typed/npm/@conveyal/woonerf_vx.x.x.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// flow-typed signature: de6ad7291f1046762626ff4efebe7579
// flow-typed version: <<STUB>>/@conveyal/woonerf_v^3.0.0/flow_v0.68.0
// flow-typed signature: e0a703eb3faee57cff6e77935e87146e
// flow-typed version: <<STUB>>/@conveyal/woonerf_v^3.0.1/flow_v0.68.0

/**
* This is an autogenerated libdef stub for:
Expand Down
18 changes: 9 additions & 9 deletions flow-typed/npm/lodash_v4.x.x.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// flow-typed signature: 2d6372509af898546ea7b44735f2557d
// flow-typed version: 8c150a1c24/lodash_v4.x.x/flow_>=v0.63.x
// flow-typed signature: 213ae107c05372e2489e50a054136496
// flow-typed version: 08e518e6e8/lodash_v4.x.x/flow_>=v0.63.x

declare module "lodash" {
declare type __CurriedFunction1<A, R, AA: A> = (...r: [AA]) => R;
Expand Down Expand Up @@ -1622,7 +1622,7 @@ declare module "lodash/fp" {
// Array
chunk<T>(size: number): (array: Array<T>) => Array<Array<T>>;
chunk<T>(size: number, array: Array<T>): Array<Array<T>>;
compact<T, N: T>(array: Array<N>): Array<T>;
compact<T, N: ?T>(array?: ?$ReadOnlyArray<N>): Array<T>;
concat<T, U, A: Array<T> | T, B: Array<U> | U>(
base: A
): (elements: B) => Array<T | U>;
Expand Down Expand Up @@ -2980,12 +2980,12 @@ declare module "lodash/fp" {
accumulator: any,
collection: Object | $ReadOnlyArray<any>
): any;
unset(path: Array<string> | string): (object: Object) => boolean;
unset(path: Array<string> | string, object: Object): boolean;
dissoc(path: Array<string> | string): (object: Object) => boolean;
dissoc(path: Array<string> | string, object: Object): boolean;
dissocPath(path: Array<string> | string): (object: Object) => boolean;
dissocPath(path: Array<string> | string, object: Object): boolean;
unset(path: Array<string> | string): (object: Object) => Object;
unset(path: Array<string> | string, object: Object): Object;
dissoc(path: Array<string> | string): (object: Object) => Object;
dissoc(path: Array<string> | string, object: Object): Object;
dissocPath(path: Array<string> | string): (object: Object) => Object;
dissocPath(path: Array<string> | string, object: Object): Object;
update(
path: string[] | string
): ((updater: Function) => (object: Object) => Object) &
Expand Down
4 changes: 2 additions & 2 deletions flow-typed/npm/mastarm_vx.x.x.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// flow-typed signature: dae1a3eeaff12208f12cc9e20c2b8ac2
// flow-typed version: <<STUB>>/mastarm_v^4.1.0/flow_v0.68.0
// flow-typed signature: e0ad3938a8da7b7c7fdca95b7600fcbe
// flow-typed version: <<STUB>>/mastarm_v^4.1.1/flow_v0.68.0

/**
* This is an autogenerated libdef stub for:
Expand Down
35 changes: 35 additions & 0 deletions flow-typed/npm/prop-types_v15.x.x.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// flow-typed signature: d9a983bb1ac458a256c31c139047bdbb
// flow-typed version: 927687984d/prop-types_v15.x.x/flow_>=v0.41.x

type $npm$propTypes$ReactPropsCheckType = (
props: any,
propName: string,
componentName: string,
href?: string) => ?Error;

declare module 'prop-types' {
declare var array: React$PropType$Primitive<Array<any>>;
declare var bool: React$PropType$Primitive<boolean>;
declare var func: React$PropType$Primitive<Function>;
declare var number: React$PropType$Primitive<number>;
declare var object: React$PropType$Primitive<Object>;
declare var string: React$PropType$Primitive<string>;
declare var symbol: React$PropType$Primitive<Symbol>;
declare var any: React$PropType$Primitive<any>;
declare var arrayOf: React$PropType$ArrayOf;
declare var element: React$PropType$Primitive<any>; /* TODO */
declare var instanceOf: React$PropType$InstanceOf;
declare var node: React$PropType$Primitive<any>; /* TODO */
declare var objectOf: React$PropType$ObjectOf;
declare var oneOf: React$PropType$OneOf;
declare var oneOfType: React$PropType$OneOfType;
declare var shape: React$PropType$Shape;

declare function checkPropTypes<V>(
propTypes: $Subtype<{[_: $Keys<V>]: $npm$propTypes$ReactPropsCheckType}>,
values: V,
location: string,
componentName: string,
getStack: ?(() => ?string)
) : void;
}
107 changes: 83 additions & 24 deletions flow-typed/npm/react-redux_v5.x.x.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// flow-typed signature: a2c406bd25fca4586c361574e555202d
// flow-typed version: dcd1531faf/react-redux_v5.x.x/flow_>=v0.62.0
// flow-typed signature: 16b40ff613d36712444ef20fb107de7c
// flow-typed version: be6cfc6753/react-redux_v5.x.x/flow_>=v0.62.0

import type { Dispatch, Store } from "redux";

Expand Down Expand Up @@ -28,10 +28,11 @@ declare module "react-redux" {
RSP = Returned state props
RDP = Returned dispatch props
RMP = Returned merge props
CP = Props for returned component
Com = React Component
*/

declare type MapStateToProps<SP: Object, RSP: Object> = (state: Object, props: SP) => RSP;
declare type MapStateToProps<S: Object, SP: Object, RSP: Object> = (state: S, props: SP) => RSP;

declare type MapDispatchToProps<A, OP: Object, RDP: Object> = (dispatch: Dispatch<A>, ownProps: OP) => RDP;

Expand All @@ -53,46 +54,104 @@ declare module "react-redux" {

declare type OmitDispatch<Component> = $Diff<Component, {dispatch: Dispatch<*>}>;

declare export function connect<Com: ComponentType<*>, DP: Object, RSP: Object>(
mapStateToProps: MapStateToProps<DP, RSP>,
declare export function connect<
Com: ComponentType<*>,
S: Object,
DP: Object,
RSP: Object,
CP: $Diff<OmitDispatch<ElementConfig<Com>>, RSP>
>(
mapStateToProps: MapStateToProps<S, DP, RSP>,
mapDispatchToProps?: null
): (component: Com) => ComponentType<$Diff<OmitDispatch<ElementConfig<Com>>, RSP> & DP>;
): (component: Com) => ComponentType<CP & DP>;

declare export function connect<Com: ComponentType<*>>(
mapStateToProps?: null,
mapDispatchToProps?: null
): (component: Com) => ComponentType<OmitDispatch<ElementConfig<Com>>>;

declare export function connect<Com: ComponentType<*>, A, DP: Object, SP: Object, RSP: Object, RDP: Object>(
mapStateToProps: MapStateToProps<SP, RSP>,
declare export function connect<
Com: ComponentType<*>,
A,
S: Object,
DP: Object,
SP: Object,
RSP: Object,
RDP: Object,
CP: $Diff<$Diff<ElementConfig<Com>, RSP>, RDP>
>(
mapStateToProps: MapStateToProps<S, SP, RSP>,
mapDispatchToProps: MapDispatchToProps<A, DP, RDP>
): (component: Com) => ComponentType<$Diff<$Diff<ElementConfig<Com>, RSP>, RDP> & SP & DP>;

declare export function connect<Com: ComponentType<*>, A, OP: Object, DP: Object,PR: Object>(
): (component: Com) => ComponentType<CP & SP & DP>;

declare export function connect<
Com: ComponentType<*>,
A,
OP: Object,
DP: Object,
PR: Object,
CP: $Diff<ElementConfig<Com>, DP>
>(
mapStateToProps?: null,
mapDispatchToProps: MapDispatchToProps<A, OP, DP>
): (Com) => ComponentType<$Diff<ElementConfig<Com>, DP> & OP>;
): (Com) => ComponentType<CP & OP>;

declare export function connect<Com: ComponentType<*>, MDP: Object>(
declare export function connect<
Com: ComponentType<*>,
MDP: Object
>(
mapStateToProps?: null,
mapDispatchToProps: MDP
): (component: Com) => ComponentType<$Diff<ElementConfig<Com>, MDP>>;

declare export function connect<Com: ComponentType<*>, SP: Object, RSP: Object, MDP: Object>(
mapStateToProps: MapStateToProps<SP, RSP>,
declare export function connect<
Com: ComponentType<*>,
S: Object,
SP: Object,
RSP: Object,
MDP: Object,
CP: $Diff<ElementConfig<Com>, RSP>
>(
mapStateToProps: MapStateToProps<S, SP, RSP>,
mapDispatchToPRops: MDP
): (component: Com) => ComponentType<$Diff<$Diff<ElementConfig<Com>, RSP>, MDP> & SP>;

declare export function connect<Com: ComponentType<*>, A, DP: Object, SP: Object, RSP: Object, RDP: Object, MP: Object, RMP: Object>(
mapStateToProps: MapStateToProps<SP, RSP>,
): (component: Com) => ComponentType<$Diff<CP, MDP> & SP>;

declare export function connect<
Com: ComponentType<*>,
A,
S: Object,
DP: Object,
SP: Object,
RSP: Object,
RDP: Object,
MP: Object,
RMP: Object,
CP: $Diff<ElementConfig<Com>, RMP>
>(
mapStateToProps: MapStateToProps<S, SP, RSP>,
mapDispatchToProps: ?MapDispatchToProps<A, DP, RDP>,
mergeProps: MergeProps<RSP, RDP, MP, RMP>
): (component: Com) => ComponentType<$Diff<ElementConfig<Com>, RMP> & SP & DP & MP>;

declare export function connect<Com: ComponentType<*>, A, DP: Object, SP: Object, RSP: Object, RDP: Object, MP: Object, RMP: Object>(
mapStateToProps: ?MapStateToProps<SP, RSP>,
): (component: Com) => ComponentType<CP & SP & DP & MP>;

declare export function connect<Com: ComponentType<*>,
A,
S: Object,
DP: Object,
SP: Object,
RSP: Object,
RDP: Object,
MP: Object,
RMP: Object
>(
mapStateToProps: ?MapStateToProps<S, SP, RSP>,
mapDispatchToProps: ?MapDispatchToProps<A, DP, RDP>,
mergeProps: ?MergeProps<RSP, RDP, MP, RMP>,
options: ConnectOptions<*, SP & DP & MP, RSP, RMP>
options: ConnectOptions<S, SP & DP & MP, RSP, RMP>
): (component: Com) => ComponentType<$Diff<ElementConfig<Com>, RMP> & SP & DP & MP>;

declare export default {
Provider: typeof Provider,
createProvider: typeof createProvider,
connect: typeof connect,
};
}
39 changes: 27 additions & 12 deletions flow-typed/npm/redux-actions_v2.x.x.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// flow-typed signature: 7e15adce10779b8fb956eeb8c0c83512
// flow-typed version: 56da885f85/redux-actions_v2.x.x/flow_>=v0.39.x
// flow-typed signature: e2c7590c6650a080179505dfc8b95673
// flow-typed version: 1febbeccad/redux-actions_v2.x.x/flow_>=v0.39.x

declare module "redux-actions" {
/*
Expand Down Expand Up @@ -29,28 +29,28 @@ declare module "redux-actions" {
declare function createAction<T, P>(
type: T,
$?: empty // hack to force Flow to not use this signature when more than one argument is given
): (payload: P, ...rest: any[]) => { type: T, payload: P, error?: boolean };
): {(payload: P, ...rest: any[]): { type: T, payload: P, error?: boolean }, +toString: () => T};

declare function createAction<T, A, P>(
type: T,
payloadCreator: (...rest: A) => P,
$?: empty
): (...rest: A) => { type: T, payload: P, error?: boolean };
): {(...rest: A): { type: T, payload: P, error?: boolean }, +toString: () => T};

declare function createAction<T, A, P, M>(
type: T,
payloadCreator: (...rest: A) => P,
metaCreator: (...rest: A) => M
): (...rest: A) => { type: T, payload: P, error?: boolean, meta: M };
): {(...rest: A): { type: T, payload: P, error?: boolean, meta: M }, +toString: () => T};

declare function createAction<T, P, M>(
type: T,
payloadCreator: null | void,
metaCreator: (payload: P, ...rest: any[]) => M
): (
payload: P,
...rest: any[]
) => { type: T, payload: P, error?: boolean, meta: M };
): {(
payload: P,
...rest: any[]
): { type: T, payload: P, error?: boolean, meta: M }, +toString: () => T};

// `createActions` is quite difficult to write a type for. Maybe try not to
// use this one?
Expand All @@ -60,7 +60,22 @@ declare module "redux-actions" {
): Object;
declare function createActions(...identityActions: string[]): Object;

/*
* The semantics of the reducer (i.e. ReduxReducer<S, A>) returned by either
* `handleAction` or `handleActions` are actually different from the semantics
* of the reducer (i.e. Reducer<S, A>) that are consumed by either `handleAction`
* or `handleActions`.
*
* Reducers (i.e. Reducer<S, A>) consumed by either `handleAction` or `handleActions`
* are assumed to be given the actual `State` type, since internally,
* `redux-actions` will perform the action type matching for us, and will always
* provide the expected state type.
*
* The reducers returned by either `handleAction` or `handleActions` will be
* compatible with the `redux` library.
*/
declare type Reducer<S, A> = (state: S, action: A) => S;
declare type ReduxReducer<S, A> = (state: S | void, action: A) => S;

declare type ReducerMap<S, A> =
| { next: Reducer<S, A> }
Expand All @@ -73,7 +88,7 @@ declare module "redux-actions" {
* `handleActions`. For example:
*
* import { type Reducer } from 'redux'
* import { createAction, handleAction, type Action } from 'redux-actions'
* import { createAction, handleAction, type ActionType } from 'redux-actions'
*
* const increment = createAction(INCREMENT, (count: number) => count)
*
Expand All @@ -92,14 +107,14 @@ declare module "redux-actions" {
type: Type,
reducer: ReducerDefinition<State, Action>,
defaultState: State
): Reducer<State, Action>;
): ReduxReducer<State, Action>;

declare function handleActions<State, Action>(
reducers: {
[key: string]: Reducer<State, Action> | ReducerMap<State, Action>
},
defaultState?: State
): Reducer<State, Action>;
): ReduxReducer<State, Action>;

declare function combineActions(
...types: (string | Symbol | Function)[]
Expand Down
7 changes: 2 additions & 5 deletions flow-typed/npm/reselect_v3.x.x.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
// flow-typed signature: 7242133add1d3bd16fc3e9d648152c63
// flow-typed version: 00301f0d29/reselect_v3.x.x/flow_>=v0.47.x

// flow-typed signature: 0199525b667f385f2e61dbeae3215f21
// flow-typed version: b43dff3e0e/reselect_v3.x.x/flow_>=v0.28.x
// flow-typed signature: 2edb237794225741adeedad554db362f
// flow-typed version: 1133e1a0c3/reselect_v3.x.x/flow_>=v0.47.x

declare module "reselect" {
declare type Selector<-TState, TProps, TResult> =
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"jsolines": "^1.0.2",
"leaflet": "^1.3.1",
"lodash": "^4.17.5",
"mastarm": "^4.1.1",
"prop-types": "^15.6.1",
"react": "^16.3.1",
"react-dom": "^16.3.1",
Expand Down
10 changes: 7 additions & 3 deletions src/utils/create-transitive-routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,19 @@ export default function createTransitiveRoutesForNetwork (
place_lat: end.position.lat
}
]

debugger;
// Get the targetPathIndexes
const baseIndex = network.pathsPerTarget * coordinateToIndex(end.position, network)

// Don't use native slice here as `targets` is a TypedArray and that will force conversion to TypedArray values
const targetPathIndexes = uniq(slice(network.targets, baseIndex, baseIndex + network.pathsPerTarget))
const targetPathIndexes = uniq(slice(
network.targets,
baseIndex,
baseIndex + network.pathsPerTarget
)).filter(tpi => tpi !== -1) // some destinations will not have any paths

// Cannot reach the destination
if (targetPathIndexes.findIndex(p => p !== -1) === -1) {
if (targetPathIndexes.length === 0) {
return {
...td,
places,
Expand Down
Loading

0 comments on commit c7176c8

Please sign in to comment.