@fscharter/flowmap-data 8.0.2-fsc.1
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/dist/FlowmapAggregateAccessors.d.ts +16 -0
- package/dist/FlowmapAggregateAccessors.d.ts.map +1 -0
- package/dist/FlowmapAggregateAccessors.js +53 -0
- package/dist/FlowmapSelectors.d.ts +143 -0
- package/dist/FlowmapSelectors.d.ts.map +1 -0
- package/dist/FlowmapSelectors.js +881 -0
- package/dist/FlowmapState.d.ts +31 -0
- package/dist/FlowmapState.d.ts.map +1 -0
- package/dist/FlowmapState.js +7 -0
- package/dist/cluster/ClusterIndex.d.ts +42 -0
- package/dist/cluster/ClusterIndex.d.ts.map +1 -0
- package/dist/cluster/ClusterIndex.js +166 -0
- package/dist/cluster/cluster.d.ts +51 -0
- package/dist/cluster/cluster.d.ts.map +1 -0
- package/dist/cluster/cluster.js +267 -0
- package/dist/colors.d.ts +103 -0
- package/dist/colors.d.ts.map +1 -0
- package/dist/colors.js +487 -0
- package/dist/getViewStateForLocations.d.ts +23 -0
- package/dist/getViewStateForLocations.d.ts.map +1 -0
- package/dist/getViewStateForLocations.js +54 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +18 -0
- package/dist/provider/FlowmapDataProvider.d.ts +21 -0
- package/dist/provider/FlowmapDataProvider.d.ts.map +1 -0
- package/dist/provider/FlowmapDataProvider.js +22 -0
- package/dist/provider/LocalFlowmapDataProvider.d.ts +31 -0
- package/dist/provider/LocalFlowmapDataProvider.d.ts.map +1 -0
- package/dist/provider/LocalFlowmapDataProvider.js +115 -0
- package/dist/selector-functions.d.ts +10 -0
- package/dist/selector-functions.d.ts.map +1 -0
- package/dist/selector-functions.js +65 -0
- package/dist/time.d.ts +24 -0
- package/dist/time.d.ts.map +1 -0
- package/dist/time.js +131 -0
- package/dist/types.d.ts +120 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +28 -0
- package/dist/util.d.ts +5 -0
- package/dist/util.d.ts.map +1 -0
- package/dist/util.js +16 -0
- package/package.json +48 -0
- package/src/FlowmapAggregateAccessors.ts +76 -0
- package/src/FlowmapSelectors.ts +1539 -0
- package/src/FlowmapState.ts +40 -0
- package/src/cluster/ClusterIndex.ts +261 -0
- package/src/cluster/cluster.ts +394 -0
- package/src/colors.ts +771 -0
- package/src/getViewStateForLocations.ts +86 -0
- package/src/index.ts +19 -0
- package/src/provider/FlowmapDataProvider.ts +81 -0
- package/src/provider/LocalFlowmapDataProvider.ts +185 -0
- package/src/selector-functions.ts +93 -0
- package/src/time.ts +166 -0
- package/src/types.ts +172 -0
- package/src/util.ts +17 -0
- package/tsconfig.json +11 -0
- package/typings.d.ts +1 -0
package/src/types.ts
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Flowmap.gl contributors
|
|
3
|
+
* Copyright (c) 2018-2020 Teralytics
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export type FlowmapData<L, F> = {
|
|
8
|
+
locations: Iterable<L> | undefined;
|
|
9
|
+
flows: Iterable<F> | undefined;
|
|
10
|
+
clusterLevels?: ClusterLevels;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export interface ViewState {
|
|
14
|
+
latitude: number;
|
|
15
|
+
longitude: number;
|
|
16
|
+
zoom: number;
|
|
17
|
+
bearing?: number;
|
|
18
|
+
pitch?: number;
|
|
19
|
+
altitude?: number;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export type FlowAccessor<F, T> = (flow: F) => T; // objectInfo?: AccessorObjectInfo,
|
|
23
|
+
export type LocationAccessor<L, T> = (location: L) => T;
|
|
24
|
+
|
|
25
|
+
export interface FlowAccessors<F> {
|
|
26
|
+
getFlowOriginId: FlowAccessor<F, string | number>;
|
|
27
|
+
getFlowDestId: FlowAccessor<F, string | number>;
|
|
28
|
+
getFlowMagnitude: FlowAccessor<F, number>;
|
|
29
|
+
getFlowTime?: FlowAccessor<F, Date>; // TODO: use number instead of Date
|
|
30
|
+
// getFlowColor?: FlowAccessor<string | undefined>;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface LocationAccessors<L> {
|
|
34
|
+
getLocationId: LocationAccessor<L, string | number>;
|
|
35
|
+
getLocationName?: LocationAccessor<L, string>;
|
|
36
|
+
getLocationLat: LocationAccessor<L, number>;
|
|
37
|
+
getLocationLon: LocationAccessor<L, number>;
|
|
38
|
+
getLocationClusterName?: (locationIds: (string | number)[]) => string;
|
|
39
|
+
// getLocationTotalIn?: LocationAccessor<number>;
|
|
40
|
+
// getLocationTotalOut?: LocationAccessor<number>;
|
|
41
|
+
// getLocationTotalInternal?: LocationAccessor<number>;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export type FlowmapDataAccessors<L, F> = LocationAccessors<L> &
|
|
45
|
+
FlowAccessors<F>;
|
|
46
|
+
|
|
47
|
+
export interface LocationTotals {
|
|
48
|
+
incomingCount: number;
|
|
49
|
+
outgoingCount: number;
|
|
50
|
+
internalCount: number;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// export interface LocationsTotals {
|
|
54
|
+
// incoming: {[id: string]: number};
|
|
55
|
+
// outgoing: {[id: string]: number};
|
|
56
|
+
// internal: {[id: string]: number};
|
|
57
|
+
// }
|
|
58
|
+
|
|
59
|
+
export interface CountByTime {
|
|
60
|
+
time: Date;
|
|
61
|
+
count: number;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export interface ViewportProps {
|
|
65
|
+
width: number;
|
|
66
|
+
height: number;
|
|
67
|
+
latitude: number;
|
|
68
|
+
longitude: number;
|
|
69
|
+
zoom?: number;
|
|
70
|
+
bearing?: number;
|
|
71
|
+
pitch?: number;
|
|
72
|
+
altitude?: number;
|
|
73
|
+
maxZoom?: number;
|
|
74
|
+
minZoom?: number;
|
|
75
|
+
maxPitch?: number;
|
|
76
|
+
minPitch?: number;
|
|
77
|
+
transitionDuration?: number | 'auto';
|
|
78
|
+
transitionInterpolator?: any;
|
|
79
|
+
transitionInterruption?: any;
|
|
80
|
+
transitionEasing?: any;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export interface ClusterNode {
|
|
84
|
+
id: string | number;
|
|
85
|
+
zoom: number;
|
|
86
|
+
lat: number;
|
|
87
|
+
lon: number;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export interface ClusterLevel {
|
|
91
|
+
zoom: number;
|
|
92
|
+
nodes: ClusterNode[];
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export type ClusterLevels = ClusterLevel[];
|
|
96
|
+
|
|
97
|
+
// non-leaf cluster node
|
|
98
|
+
export interface Cluster extends ClusterNode {
|
|
99
|
+
name?: string;
|
|
100
|
+
children: string[];
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export function isCluster(c: ClusterNode): c is Cluster {
|
|
104
|
+
const {children} = c as Cluster;
|
|
105
|
+
return children && children.length > 0;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export function isLocationClusterNode<L>(l: L | ClusterNode): l is ClusterNode {
|
|
109
|
+
const {zoom} = l as ClusterNode;
|
|
110
|
+
return zoom !== undefined;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export interface AggregateFlow {
|
|
114
|
+
origin: string | number;
|
|
115
|
+
dest: string | number;
|
|
116
|
+
count: number;
|
|
117
|
+
aggregate: true;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export function isAggregateFlow(
|
|
121
|
+
flow: Record<string, any>,
|
|
122
|
+
): flow is AggregateFlow {
|
|
123
|
+
return (
|
|
124
|
+
flow &&
|
|
125
|
+
// flow.origin !== undefined &&
|
|
126
|
+
// flow.dest !== undefined &&
|
|
127
|
+
// flow.count !== undefined &&
|
|
128
|
+
(flow.aggregate ? true : false)
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export interface FlowCountsMapReduce<F, T = any> {
|
|
133
|
+
map: (flow: F) => T;
|
|
134
|
+
reduce: (accumulated: T, val: T) => T;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export enum LocationFilterMode {
|
|
138
|
+
ALL = 'ALL',
|
|
139
|
+
INCOMING = 'INCOMING',
|
|
140
|
+
OUTGOING = 'OUTGOING',
|
|
141
|
+
BETWEEN = 'BETWEEN',
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export interface FlowCirclesLayerAttributes {
|
|
145
|
+
length: number;
|
|
146
|
+
attributes: {
|
|
147
|
+
getPosition: LayersDataAttrValues<Float32Array>;
|
|
148
|
+
getColor: LayersDataAttrValues<Uint8Array>;
|
|
149
|
+
getInRadius: LayersDataAttrValues<Float32Array>;
|
|
150
|
+
getOutRadius: LayersDataAttrValues<Float32Array>;
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export interface FlowLinesLayerAttributes {
|
|
155
|
+
length: number;
|
|
156
|
+
attributes: {
|
|
157
|
+
getSourcePosition: LayersDataAttrValues<Float32Array>;
|
|
158
|
+
getTargetPosition: LayersDataAttrValues<Float32Array>;
|
|
159
|
+
getThickness: LayersDataAttrValues<Float32Array>;
|
|
160
|
+
getColor: LayersDataAttrValues<Uint8Array>;
|
|
161
|
+
getEndpointOffsets: LayersDataAttrValues<Float32Array>;
|
|
162
|
+
getStaggering?: LayersDataAttrValues<Float32Array>;
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export interface LayersData {
|
|
167
|
+
circleAttributes: FlowCirclesLayerAttributes;
|
|
168
|
+
lineAttributes: FlowLinesLayerAttributes;
|
|
169
|
+
locationLabels?: string[];
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export type LayersDataAttrValues<T> = {value: T; size: number};
|
package/src/util.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Flowmap.gl contributors
|
|
3
|
+
* Copyright (c) 2018-2020 Teralytics
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import {createSelectorCreator, defaultMemoize} from 'reselect';
|
|
8
|
+
|
|
9
|
+
export const createDebugSelector = createSelectorCreator(defaultMemoize, {
|
|
10
|
+
equalityCheck: (previousVal: any, currentVal: any) => {
|
|
11
|
+
const rv = currentVal === previousVal;
|
|
12
|
+
if (!rv) {
|
|
13
|
+
console.log('Selector param value changed', currentVal);
|
|
14
|
+
}
|
|
15
|
+
return rv;
|
|
16
|
+
},
|
|
17
|
+
});
|
package/tsconfig.json
ADDED
package/typings.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
declare module 'kdbush';
|