@flowmap.gl/data 8.0.0-alpha.0
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/LICENSE +199 -0
- package/dist/FlowMapAggregateAccessors.d.ts +15 -0
- package/dist/FlowMapAggregateAccessors.d.ts.map +1 -0
- package/dist/FlowMapAggregateAccessors.js +43 -0
- package/dist/FlowMapSelectors.d.ts +156 -0
- package/dist/FlowMapSelectors.d.ts.map +1 -0
- package/dist/FlowMapSelectors.js +831 -0
- package/dist/FlowMapState.d.ts +24 -0
- package/dist/FlowMapState.d.ts.map +1 -0
- package/dist/FlowMapState.js +2 -0
- package/dist/cluster/ClusterIndex.d.ts +42 -0
- package/dist/cluster/ClusterIndex.d.ts.map +1 -0
- package/dist/cluster/ClusterIndex.js +178 -0
- package/dist/cluster/cluster.d.ts +31 -0
- package/dist/cluster/cluster.d.ts.map +1 -0
- package/dist/cluster/cluster.js +206 -0
- package/dist/colors.d.ts +103 -0
- package/dist/colors.d.ts.map +1 -0
- package/dist/colors.js +441 -0
- package/dist/getViewStateForLocations.d.ts +16 -0
- package/dist/getViewStateForLocations.d.ts.map +1 -0
- package/dist/getViewStateForLocations.js +30 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -0
- package/dist/provider/FlowMapDataProvider.d.ts +16 -0
- package/dist/provider/FlowMapDataProvider.d.ts.map +1 -0
- package/dist/provider/FlowMapDataProvider.js +17 -0
- package/dist/provider/LocalFlowMapDataProvider.d.ts +20 -0
- package/dist/provider/LocalFlowMapDataProvider.d.ts.map +1 -0
- package/dist/provider/LocalFlowMapDataProvider.js +87 -0
- package/dist/time.d.ts +24 -0
- package/dist/time.d.ts.map +1 -0
- package/dist/time.js +126 -0
- package/dist/types.d.ts +116 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +23 -0
- package/dist/util.d.ts +2 -0
- package/dist/util.d.ts.map +1 -0
- package/dist/util.js +4 -0
- package/package.json +48 -0
- package/src/FlowMapAggregateAccessors.ts +60 -0
- package/src/FlowMapSelectors.ts +1407 -0
- package/src/FlowMapState.ts +26 -0
- package/src/cluster/ClusterIndex.ts +266 -0
- package/src/cluster/cluster.ts +299 -0
- package/src/colors.ts +723 -0
- package/src/getViewStateForLocations.ts +64 -0
- package/src/index.ts +10 -0
- package/src/provider/FlowMapDataProvider.ts +63 -0
- package/src/provider/LocalFlowMapDataProvider.ts +108 -0
- package/src/time.ts +160 -0
- package/src/types.ts +162 -0
- package/src/util.ts +3 -0
- package/tsconfig.json +11 -0
- package/typings.d.ts +1 -0
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@flowmap.gl/data",
|
|
3
|
+
"version": "8.0.0-alpha.0",
|
|
4
|
+
"main": "dist/index.js",
|
|
5
|
+
"module": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"repository": "git@github.com:FlowmapBlue/flowmap.gl.git",
|
|
8
|
+
"author": "Ilya Boyandin <ilya@boyandin.me>",
|
|
9
|
+
"license": "Apache-2.0",
|
|
10
|
+
"scripts": {
|
|
11
|
+
"dev": "tsc --watch",
|
|
12
|
+
"build": "rm -rf dist && tsc"
|
|
13
|
+
},
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"@mapbox/geo-viewport": "^0.5.0",
|
|
16
|
+
"d3-array": "^3.0.2",
|
|
17
|
+
"d3-collection": "^1.0.7",
|
|
18
|
+
"d3-color": "^3.0.1",
|
|
19
|
+
"d3-geo": "^3.0.1",
|
|
20
|
+
"d3-interpolate": "^3.0.1",
|
|
21
|
+
"d3-scale": "^4.0.0",
|
|
22
|
+
"d3-scale-chromatic": "^3.0.0",
|
|
23
|
+
"d3-time": "^3.0.0",
|
|
24
|
+
"d3-time-format": "^4.0.0",
|
|
25
|
+
"kdbush": "^3.0.0",
|
|
26
|
+
"reselect": "^4.0.0",
|
|
27
|
+
"seedrandom": "^3.0.5"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@types/d3-array": "^3.0.1",
|
|
31
|
+
"@types/d3-collection": "^1.0.10",
|
|
32
|
+
"@types/d3-color": "^3.0.2",
|
|
33
|
+
"@types/d3-geo": "^3.0.2",
|
|
34
|
+
"@types/d3-interpolate": "^3.0.1",
|
|
35
|
+
"@types/d3-scale": "^4.0.1",
|
|
36
|
+
"@types/d3-scale-chromatic": "^3.0.0",
|
|
37
|
+
"@types/d3-time": "^3.0.0",
|
|
38
|
+
"@types/d3-time-format": "^4.0.0",
|
|
39
|
+
"@types/geojson": "^7946.0.7",
|
|
40
|
+
"@types/kdbush": "^3.0.0",
|
|
41
|
+
"@types/mapbox__geo-viewport": "^0.4.1",
|
|
42
|
+
"@types/seedrandom": "^3.0.1"
|
|
43
|
+
},
|
|
44
|
+
"gitHead": "1fdf13de65d27b7de34e6b6fa37ab5b249c05aeb",
|
|
45
|
+
"publishConfig": {
|
|
46
|
+
"access": "public"
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AggregateFlow,
|
|
3
|
+
ClusterNode,
|
|
4
|
+
FlowMapDataAccessors,
|
|
5
|
+
isAggregateFlow,
|
|
6
|
+
isCluster,
|
|
7
|
+
isLocationClusterNode,
|
|
8
|
+
} from './types';
|
|
9
|
+
|
|
10
|
+
export default class FlowMapAggregateAccessors<L, F> {
|
|
11
|
+
private accessors: FlowMapDataAccessors<L, F>;
|
|
12
|
+
constructor(accessors: FlowMapDataAccessors<L, F>) {
|
|
13
|
+
this.accessors = accessors;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
setAccessors(accessors: FlowMapDataAccessors<L, F>) {
|
|
17
|
+
this.accessors = accessors;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
getFlowMapDataAccessors() {
|
|
21
|
+
return this.accessors;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
getLocationId = (location: L | ClusterNode): string =>
|
|
25
|
+
isLocationClusterNode(location)
|
|
26
|
+
? location.id
|
|
27
|
+
: this.accessors.getLocationId(location);
|
|
28
|
+
|
|
29
|
+
getLocationName = (location: L | ClusterNode): string =>
|
|
30
|
+
(isLocationClusterNode(location) && isCluster(location)
|
|
31
|
+
? location.name
|
|
32
|
+
: undefined) ?? this.getLocationId(location);
|
|
33
|
+
// ? location.name // TODO getLocationName for locations and clusters
|
|
34
|
+
// : this.accessors.getLocationName
|
|
35
|
+
// ? this.accessors.getLocationName(location)
|
|
36
|
+
// : this.getLocationId(location);
|
|
37
|
+
|
|
38
|
+
getLocationCentroid = (location: L | ClusterNode): [number, number] =>
|
|
39
|
+
isLocationClusterNode(location)
|
|
40
|
+
? location.centroid
|
|
41
|
+
: this.accessors.getLocationCentroid(location);
|
|
42
|
+
|
|
43
|
+
getFlowOriginId = (f: F | AggregateFlow) => {
|
|
44
|
+
return isAggregateFlow(f) ? f.origin : this.accessors.getFlowOriginId(f);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
getFlowDestId = (f: F | AggregateFlow) => {
|
|
48
|
+
return isAggregateFlow(f) ? f.dest : this.accessors.getFlowDestId(f);
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
getFlowMagnitude = (f: F | AggregateFlow) => {
|
|
52
|
+
return isAggregateFlow(f) ? f.count : this.accessors.getFlowMagnitude(f);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
// Note: Aggregate flows have no time
|
|
56
|
+
getFlowTime = (f: F) => {
|
|
57
|
+
const {getFlowTime} = this.accessors;
|
|
58
|
+
return getFlowTime ? getFlowTime(f) : undefined;
|
|
59
|
+
};
|
|
60
|
+
}
|