@kepler.gl/utils 3.3.0-alpha.21 → 3.3.0-alpha.23
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/camera-tour.d.ts +2 -1
- package/dist/cjs/camera-tour.js +82 -18
- package/dist/cjs/camera-tour.js.map +1 -1
- package/dist/cjs/data-scale-utils.js +12 -2
- package/dist/cjs/data-scale-utils.js.map +1 -1
- package/dist/cjs/data-utils.js +16 -2
- package/dist/cjs/data-utils.js.map +1 -1
- package/dist/cjs/effect-utils.js +2 -2
- package/dist/cjs/effect-utils.js.map +1 -1
- package/dist/cjs/filter-utils.js +4 -2
- package/dist/cjs/filter-utils.js.map +1 -1
- package/dist/cjs/index.js +22 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/layer-histogram.js +264 -0
- package/dist/cjs/layer-histogram.js.map +1 -0
- package/dist/cjs/plot.js +385 -34
- package/dist/cjs/plot.js.map +1 -1
- package/dist/esm/camera-tour.js +82 -18
- package/dist/esm/camera-tour.js.map +1 -1
- package/dist/esm/data-scale-utils.js +12 -2
- package/dist/esm/data-scale-utils.js.map +1 -1
- package/dist/esm/data-utils.js +16 -2
- package/dist/esm/data-utils.js.map +1 -1
- package/dist/esm/effect-utils.js +2 -2
- package/dist/esm/effect-utils.js.map +1 -1
- package/dist/esm/filter-utils.js +4 -2
- package/dist/esm/filter-utils.js.map +1 -1
- package/dist/esm/index.js +2 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/layer-histogram.js +259 -0
- package/dist/esm/layer-histogram.js.map +1 -0
- package/dist/esm/plot.js +386 -36
- package/dist/esm/plot.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/layer-histogram.d.ts +16 -0
- package/dist/plot.d.ts +19 -6
- package/package.json +4 -4
package/dist/esm/camera-tour.js
CHANGED
|
@@ -57,10 +57,58 @@ var shortestRotation = function shortestRotation(from, to) {
|
|
|
57
57
|
return ((to % 360 - from % 360 + 540) % 360 + 360) % 360 - 180;
|
|
58
58
|
};
|
|
59
59
|
|
|
60
|
+
/** Shared velocity at a waypoint, in camera units per millisecond. */
|
|
61
|
+
function velocityAtStop(stops, index) {
|
|
62
|
+
var velocity = {
|
|
63
|
+
longitude: 0,
|
|
64
|
+
latitude: 0,
|
|
65
|
+
zoom: 0,
|
|
66
|
+
bearing: 0,
|
|
67
|
+
pitch: 0
|
|
68
|
+
};
|
|
69
|
+
var previous = stops[index - 1];
|
|
70
|
+
var stop = stops[index];
|
|
71
|
+
var next = stops[index + 1];
|
|
72
|
+
if (!previous || !next || stop.holdDurationMs > 0 || previous.travelDurationMs === 0 || stop.travelDurationMs === 0) return velocity;
|
|
73
|
+
var incoming = [shortestRotation(previous.camera.longitude, stop.camera.longitude), stop.camera.latitude - previous.camera.latitude];
|
|
74
|
+
var outgoing = [shortestRotation(stop.camera.longitude, next.camera.longitude), next.camera.latitude - stop.camera.latitude];
|
|
75
|
+
var incomingLength = Math.hypot.apply(Math, incoming);
|
|
76
|
+
var outgoingLength = Math.hypot.apply(Math, outgoing);
|
|
77
|
+
var speed = Math.min(incomingLength / previous.travelDurationMs, outgoingLength / stop.travelDurationMs);
|
|
78
|
+
if (incomingLength > 0 && outgoingLength > 0 && Number.isFinite(speed)) {
|
|
79
|
+
// Bisect the travel directions and cap speed at the slower neighboring leg.
|
|
80
|
+
// Each equivalent Bezier handle stays within one third of its leg's length;
|
|
81
|
+
// corners round gently, while coincident points and reversals cannot loop.
|
|
82
|
+
velocity.longitude = (incoming[0] / incomingLength + outgoing[0] / outgoingLength) * (speed / 2);
|
|
83
|
+
velocity.latitude = (incoming[1] / incomingLength + outgoing[1] / outgoingLength) * (speed / 2);
|
|
84
|
+
// Keep both neighboring Bezier handles inside the valid latitude range.
|
|
85
|
+
var latitudeDirection = Math.sign(velocity.latitude);
|
|
86
|
+
velocity.latitude = latitudeDirection * Math.min(Math.abs(velocity.latitude), 3 * (90 - latitudeDirection * stop.camera.latitude) / stop.travelDurationMs, 3 * (90 + latitudeDirection * stop.camera.latitude) / previous.travelDurationMs);
|
|
87
|
+
}
|
|
88
|
+
var _iterator2 = _createForOfIteratorHelper(['zoom', 'bearing', 'pitch']),
|
|
89
|
+
_step2;
|
|
90
|
+
try {
|
|
91
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
92
|
+
var key = _step2.value;
|
|
93
|
+
var before = (key === 'bearing' ? shortestRotation(previous.camera[key], stop.camera[key]) : stop.camera[key] - previous.camera[key]) / previous.travelDurationMs;
|
|
94
|
+
var after = (key === 'bearing' ? shortestRotation(stop.camera[key], next.camera[key]) : next.camera[key] - stop.camera[key]) / stop.travelDurationMs;
|
|
95
|
+
// Scalar values must stay between their endpoints, including at reversals.
|
|
96
|
+
var slope = Math.sign(before) === Math.sign(after) ? Math.sign(before) * Math.min(Math.abs(before), Math.abs(after)) : 0;
|
|
97
|
+
velocity[key] = Number.isFinite(slope) ? slope : 0;
|
|
98
|
+
}
|
|
99
|
+
} catch (err) {
|
|
100
|
+
_iterator2.e(err);
|
|
101
|
+
} finally {
|
|
102
|
+
_iterator2.f();
|
|
103
|
+
}
|
|
104
|
+
return velocity;
|
|
105
|
+
}
|
|
106
|
+
|
|
60
107
|
/**
|
|
61
108
|
* Evaluate an authored tour at elapsed milliseconds, without clocks or rendering state.
|
|
62
109
|
* Holds precede travel; boundaries belong to the next stop and zero-length travel is a cut.
|
|
63
|
-
*
|
|
110
|
+
* Bounded cubic travel shares velocity through zero-hold stops, easing to rest at holds,
|
|
111
|
+
* cuts and tour endpoints. Longitude/bearing take the shortest rotation (180° ties go west).
|
|
64
112
|
* Time clamps to the tour; NaN means its start. The final hold contributes to duration.
|
|
65
113
|
*/
|
|
66
114
|
export function evaluateCameraTour(tour, elapsedMs) {
|
|
@@ -68,24 +116,40 @@ export function evaluateCameraTour(tour, elapsedMs) {
|
|
|
68
116
|
if (!normalized) return null;
|
|
69
117
|
var stops = normalized.stops;
|
|
70
118
|
var remaining = Number.isNaN(elapsedMs) ? 0 : Math.max(0, elapsedMs);
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
if (remaining < stop.travelDurationMs) {
|
|
76
|
-
var fraction = remaining / stop.travelDurationMs;
|
|
77
|
-
var eased = fraction * fraction * (3 - 2 * fraction);
|
|
78
|
-
var from = stop.camera;
|
|
79
|
-
var to = stops[index + 1].camera;
|
|
80
|
-
return {
|
|
81
|
-
longitude: from.longitude + shortestRotation(from.longitude, to.longitude) * eased,
|
|
82
|
-
latitude: from.latitude + (to.latitude - from.latitude) * eased,
|
|
83
|
-
zoom: from.zoom * (1 - eased) + to.zoom * eased,
|
|
84
|
-
bearing: from.bearing + shortestRotation(from.bearing, to.bearing) * eased,
|
|
85
|
-
pitch: from.pitch + (to.pitch - from.pitch) * eased
|
|
119
|
+
var _loop = function _loop() {
|
|
120
|
+
var stop = stops[index];
|
|
121
|
+
if (remaining < stop.holdDurationMs) return {
|
|
122
|
+
v: _objectSpread({}, stop.camera)
|
|
86
123
|
};
|
|
87
|
-
|
|
88
|
-
|
|
124
|
+
remaining -= stop.holdDurationMs;
|
|
125
|
+
if (remaining < stop.travelDurationMs) {
|
|
126
|
+
var fraction = remaining / stop.travelDurationMs;
|
|
127
|
+
var eased = fraction * fraction * (3 - 2 * fraction);
|
|
128
|
+
var from = stop.camera;
|
|
129
|
+
var to = stops[index + 1].camera;
|
|
130
|
+
var startVelocity = velocityAtStop(stops, index);
|
|
131
|
+
var endVelocity = velocityAtStop(stops, index + 1);
|
|
132
|
+
var startWeight = fraction * Math.pow(1 - fraction, 2) * stop.travelDurationMs;
|
|
133
|
+
var endWeight = Math.pow(fraction, 2) * (1 - fraction) * stop.travelDurationMs;
|
|
134
|
+
var offset = function offset(key) {
|
|
135
|
+
return startVelocity[key] * startWeight - endVelocity[key] * endWeight;
|
|
136
|
+
};
|
|
137
|
+
return {
|
|
138
|
+
v: {
|
|
139
|
+
longitude: from.longitude + shortestRotation(from.longitude, to.longitude) * eased + offset('longitude'),
|
|
140
|
+
latitude: from.latitude + (to.latitude - from.latitude) * eased + offset('latitude'),
|
|
141
|
+
zoom: from.zoom * (1 - eased) + to.zoom * eased + offset('zoom'),
|
|
142
|
+
bearing: from.bearing + shortestRotation(from.bearing, to.bearing) * eased + offset('bearing'),
|
|
143
|
+
pitch: from.pitch + (to.pitch - from.pitch) * eased + offset('pitch')
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
remaining -= stop.travelDurationMs;
|
|
148
|
+
},
|
|
149
|
+
_ret;
|
|
150
|
+
for (var index = 0; index < stops.length - 1; index++) {
|
|
151
|
+
_ret = _loop();
|
|
152
|
+
if (_ret) return _ret.v;
|
|
89
153
|
}
|
|
90
154
|
return _objectSpread({}, stops[stops.length - 1].camera);
|
|
91
155
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"camera-tour.js","names":["getCameraSnapshot","validDuration","value","Number","isFinite","MAX_SAFE_INTEGER","durationOfStops","stops","reduce","total","stop","index","holdDurationMs","length","travelDurationMs","normalizeCameraTour","_typeof","Array","isArray","ids","Set","_iterator","_createForOfIteratorHelper","_step","s","n","done","id","trim","has","name","camera","add","push","err","e","f","getCameraTourDuration","tour","_normalizeCameraTour","shortestRotation","from","to","evaluateCameraTour","elapsedMs","normalized","remaining","isNaN","Math","max","_objectSpread","fraction","eased","longitude","latitude","zoom","bearing","pitch"],"sources":["../../src/camera-tour.ts"],"sourcesContent":["// SPDX-License-Identifier: MIT\n// Copyright contributors to the kepler.gl project\n\nimport {CameraSnapshot, CameraTour, CameraTourStop} from '@kepler.gl/types';\nimport {getCameraSnapshot} from './camera-utils';\n\nconst validDuration = (value: unknown): value is number =>\n typeof value === 'number' &&\n Number.isFinite(value) &&\n value >= 0 &&\n value <= Number.MAX_SAFE_INTEGER;\n\nconst durationOfStops = (stops: CameraTourStop[]) =>\n stops.reduce(\n (total, stop, index) =>\n total + stop.holdDurationMs + (index < stops.length - 1 ? stop.travelDurationMs : 0),\n 0\n );\n\n/** Validate imported stops and copy authored fields, omitting empty or unsafe tours. */\nexport function normalizeCameraTour(value: unknown): CameraTour | null {\n if (!value || typeof value !== 'object' || !Array.isArray((value as CameraTour).stops))\n return null;\n const ids = new Set<string>();\n const stops: CameraTourStop[] = [];\n for (const stop of (value as CameraTour).stops) {\n if (\n !stop ||\n typeof stop.id !== 'string' ||\n !stop.id.trim() ||\n ids.has(stop.id) ||\n typeof stop.name !== 'string' ||\n !validDuration(stop.holdDurationMs) ||\n !validDuration(stop.travelDurationMs)\n )\n continue;\n const camera = getCameraSnapshot(stop.camera);\n if (!camera) continue;\n ids.add(stop.id);\n stops.push({\n id: stop.id,\n name: stop.name,\n camera,\n holdDurationMs: stop.holdDurationMs,\n travelDurationMs: stop.travelDurationMs\n });\n }\n return stops.length && durationOfStops(stops) <= Number.MAX_SAFE_INTEGER ? {stops} : null;\n}\n\nexport function getCameraTourDuration(tour: CameraTour | null | undefined): number {\n return durationOfStops(normalizeCameraTour(tour)?.stops || []);\n}\n\nconst shortestRotation = (from: number, to: number) =>\n (((((to % 360) - (from % 360) + 540) % 360) + 360) % 360) - 180;\n\n/**\n * Evaluate an authored tour at elapsed milliseconds, without clocks or rendering state.\n * Holds precede travel; boundaries belong to the next stop and zero-length travel is a cut.\n * Travel uses smoothstep easing and the shortest longitude/bearing rotation (180° ties go west).\n * Time clamps to the tour; NaN means its start. The final hold contributes to duration.\n */\nexport function evaluateCameraTour(\n tour: CameraTour | null | undefined,\n elapsedMs: number\n): CameraSnapshot | null {\n const normalized = normalizeCameraTour(tour);\n if (!normalized) return null;\n const {stops} = normalized;\n let remaining = Number.isNaN(elapsedMs) ? 0 : Math.max(0, elapsedMs);\n for (let index = 0; index < stops.length - 1; index++) {\n const stop = stops[index];\n if (remaining < stop.holdDurationMs) return {...stop.camera};\n remaining -= stop.holdDurationMs;\n if (remaining < stop.travelDurationMs) {\n const fraction = remaining / stop.travelDurationMs;\n const eased = fraction * fraction * (3 - 2 * fraction);\n const from = stop.camera;\n const to = stops[index + 1].camera;\n return {\n longitude: from.longitude + shortestRotation(from.longitude, to.longitude) * eased,\n latitude: from.latitude + (to.latitude - from.latitude) * eased,\n zoom: from.zoom * (1 - eased) + to.zoom * eased,\n bearing: from.bearing + shortestRotation(from.bearing, to.bearing) * eased,\n pitch: from.pitch + (to.pitch - from.pitch) * eased\n };\n }\n remaining -= stop.travelDurationMs;\n }\n return {...stops[stops.length - 1].camera};\n}\n"],"mappings":";;;;;;;AAAA;AACA;;AAGA,SAAQA,iBAAiB,QAAO,gBAAgB;AAEhD,IAAMC,aAAa,GAAG,SAAhBA,aAAaA,CAAIC,KAAc;EAAA,OACnC,OAAOA,KAAK,KAAK,QAAQ,IACzBC,MAAM,CAACC,QAAQ,CAACF,KAAK,CAAC,IACtBA,KAAK,IAAI,CAAC,IACVA,KAAK,IAAIC,MAAM,CAACE,gBAAgB;AAAA;AAElC,IAAMC,eAAe,GAAG,SAAlBA,eAAeA,CAAIC,KAAuB;EAAA,OAC9CA,KAAK,CAACC,MAAM,CACV,UAACC,KAAK,EAAEC,IAAI,EAAEC,KAAK;IAAA,OACjBF,KAAK,GAAGC,IAAI,CAACE,cAAc,IAAID,KAAK,GAAGJ,KAAK,CAACM,MAAM,GAAG,CAAC,GAAGH,IAAI,CAACI,gBAAgB,GAAG,CAAC,CAAC;EAAA,GACtF,CACF,CAAC;AAAA;;AAEH;AACA,OAAO,SAASC,mBAAmBA,CAACb,KAAc,EAAqB;EACrE,IAAI,CAACA,KAAK,IAAIc,OAAA,CAAOd,KAAK,MAAK,QAAQ,IAAI,CAACe,KAAK,CAACC,OAAO,CAAEhB,KAAK,CAAgBK,KAAK,CAAC,EACpF,OAAO,IAAI;EACb,IAAMY,GAAG,GAAG,IAAIC,GAAG,CAAS,CAAC;EAC7B,IAAMb,KAAuB,GAAG,EAAE;EAAC,IAAAc,SAAA,GAAAC,0BAAA,CACfpB,KAAK,CAAgBK,KAAK;IAAAg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AAI,GAAG/B,IAAI,CAACqB,MAAM;MACxB,IAAMW,EAAE,GAAGnC,KAAK,CAACI,KAAK,GAAG,CAAC,CAAC,CAACoB,MAAM;MAClC,OAAO;QACLsB,SAAS,EAAEZ,IAAI,CAACY,SAAS,GAAGb,gBAAgB,CAACC,IAAI,CAACY,SAAS,EAAEX,EAAE,CAACW,SAAS,CAAC,GAAGD,KAAK;QAClFE,QAAQ,EAAEb,IAAI,CAACa,QAAQ,GAAG,CAACZ,EAAE,CAACY,QAAQ,GAAGb,IAAI,CAACa,QAAQ,IAAIF,KAAK;QAC/DG,IAAI,EAAEd,IAAI,CAACc,IAAI,IAAI,CAAC,GAAGH,KAAK,CAAC,GAAGV,EAAE,CAACa,IAAI,GAAGH,KAAK;QAC/CI,OAAO,EAAEf,IAAI,CAACe,OAAO,GAAGhB,gBAAgB,CAACC,IAAI,CAACe,OAAO,EAAEd,EAAE,CAACc,OAAO,CAAC,GAAGJ,KAAK;QAC1EK,KAAK,EAAEhB,IAAI,CAACgB,KAAK,GAAG,CAACf,EAAE,CAACe,KAAK,GAAGhB,IAAI,CAACgB,KAAK,IAAIL;MAChD,CAAC;IACH;IACAN,SAAS,IAAIpC,IAAI,CAACI,gBAAgB;EACpC;EACA,OAAAoC,aAAA,KAAW3C,KAAK,CAACA,KAAK,CAACM,MAAM,GAAG,CAAC,CAAC,CAACkB,MAAM;AAC3C","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"camera-tour.js","names":["getCameraSnapshot","validDuration","value","Number","isFinite","MAX_SAFE_INTEGER","durationOfStops","stops","reduce","total","stop","index","holdDurationMs","length","travelDurationMs","normalizeCameraTour","_typeof","Array","isArray","ids","Set","_iterator","_createForOfIteratorHelper","_step","s","n","done","id","trim","has","name","camera","add","push","err","e","f","getCameraTourDuration","tour","_normalizeCameraTour","shortestRotation","from","to","velocityAtStop","velocity","longitude","latitude","zoom","bearing","pitch","previous","next","incoming","outgoing","incomingLength","Math","hypot","apply","outgoingLength","speed","min","latitudeDirection","sign","abs","_iterator2","_step2","key","before","after","slope","evaluateCameraTour","elapsedMs","normalized","remaining","isNaN","max","_loop","v","_objectSpread","fraction","eased","startVelocity","endVelocity","startWeight","pow","endWeight","offset","_ret"],"sources":["../../src/camera-tour.ts"],"sourcesContent":["// SPDX-License-Identifier: MIT\n// Copyright contributors to the kepler.gl project\n\nimport {CameraSnapshot, CameraTour, CameraTourStop} from '@kepler.gl/types';\nimport {getCameraSnapshot} from './camera-utils';\n\nconst validDuration = (value: unknown): value is number =>\n typeof value === 'number' &&\n Number.isFinite(value) &&\n value >= 0 &&\n value <= Number.MAX_SAFE_INTEGER;\n\nconst durationOfStops = (stops: CameraTourStop[]) =>\n stops.reduce(\n (total, stop, index) =>\n total + stop.holdDurationMs + (index < stops.length - 1 ? stop.travelDurationMs : 0),\n 0\n );\n\n/** Validate imported stops and copy authored fields, omitting empty or unsafe tours. */\nexport function normalizeCameraTour(value: unknown): CameraTour | null {\n if (!value || typeof value !== 'object' || !Array.isArray((value as CameraTour).stops))\n return null;\n const ids = new Set<string>();\n const stops: CameraTourStop[] = [];\n for (const stop of (value as CameraTour).stops) {\n if (\n !stop ||\n typeof stop.id !== 'string' ||\n !stop.id.trim() ||\n ids.has(stop.id) ||\n typeof stop.name !== 'string' ||\n !validDuration(stop.holdDurationMs) ||\n !validDuration(stop.travelDurationMs)\n )\n continue;\n const camera = getCameraSnapshot(stop.camera);\n if (!camera) continue;\n ids.add(stop.id);\n stops.push({\n id: stop.id,\n name: stop.name,\n camera,\n holdDurationMs: stop.holdDurationMs,\n travelDurationMs: stop.travelDurationMs\n });\n }\n return stops.length && durationOfStops(stops) <= Number.MAX_SAFE_INTEGER ? {stops} : null;\n}\n\nexport function getCameraTourDuration(tour: CameraTour | null | undefined): number {\n return durationOfStops(normalizeCameraTour(tour)?.stops || []);\n}\n\nconst shortestRotation = (from: number, to: number) =>\n (((((to % 360) - (from % 360) + 540) % 360) + 360) % 360) - 180;\n\n/** Shared velocity at a waypoint, in camera units per millisecond. */\nfunction velocityAtStop(stops: CameraTourStop[], index: number): CameraSnapshot {\n const velocity = {longitude: 0, latitude: 0, zoom: 0, bearing: 0, pitch: 0};\n const previous = stops[index - 1];\n const stop = stops[index];\n const next = stops[index + 1];\n if (\n !previous ||\n !next ||\n stop.holdDurationMs > 0 ||\n previous.travelDurationMs === 0 ||\n stop.travelDurationMs === 0\n )\n return velocity;\n\n const incoming = [\n shortestRotation(previous.camera.longitude, stop.camera.longitude),\n stop.camera.latitude - previous.camera.latitude\n ];\n const outgoing = [\n shortestRotation(stop.camera.longitude, next.camera.longitude),\n next.camera.latitude - stop.camera.latitude\n ];\n const incomingLength = Math.hypot(...incoming);\n const outgoingLength = Math.hypot(...outgoing);\n const speed = Math.min(\n incomingLength / previous.travelDurationMs,\n outgoingLength / stop.travelDurationMs\n );\n if (incomingLength > 0 && outgoingLength > 0 && Number.isFinite(speed)) {\n // Bisect the travel directions and cap speed at the slower neighboring leg.\n // Each equivalent Bezier handle stays within one third of its leg's length;\n // corners round gently, while coincident points and reversals cannot loop.\n velocity.longitude =\n (incoming[0] / incomingLength + outgoing[0] / outgoingLength) * (speed / 2);\n velocity.latitude = (incoming[1] / incomingLength + outgoing[1] / outgoingLength) * (speed / 2);\n // Keep both neighboring Bezier handles inside the valid latitude range.\n const latitudeDirection = Math.sign(velocity.latitude);\n velocity.latitude =\n latitudeDirection *\n Math.min(\n Math.abs(velocity.latitude),\n (3 * (90 - latitudeDirection * stop.camera.latitude)) / stop.travelDurationMs,\n (3 * (90 + latitudeDirection * stop.camera.latitude)) / previous.travelDurationMs\n );\n }\n\n for (const key of ['zoom', 'bearing', 'pitch'] as const) {\n const before =\n (key === 'bearing'\n ? shortestRotation(previous.camera[key], stop.camera[key])\n : stop.camera[key] - previous.camera[key]) / previous.travelDurationMs;\n const after =\n (key === 'bearing'\n ? shortestRotation(stop.camera[key], next.camera[key])\n : next.camera[key] - stop.camera[key]) / stop.travelDurationMs;\n // Scalar values must stay between their endpoints, including at reversals.\n const slope =\n Math.sign(before) === Math.sign(after)\n ? Math.sign(before) * Math.min(Math.abs(before), Math.abs(after))\n : 0;\n velocity[key] = Number.isFinite(slope) ? slope : 0;\n }\n return velocity;\n}\n\n/**\n * Evaluate an authored tour at elapsed milliseconds, without clocks or rendering state.\n * Holds precede travel; boundaries belong to the next stop and zero-length travel is a cut.\n * Bounded cubic travel shares velocity through zero-hold stops, easing to rest at holds,\n * cuts and tour endpoints. Longitude/bearing take the shortest rotation (180° ties go west).\n * Time clamps to the tour; NaN means its start. The final hold contributes to duration.\n */\nexport function evaluateCameraTour(\n tour: CameraTour | null | undefined,\n elapsedMs: number\n): CameraSnapshot | null {\n const normalized = normalizeCameraTour(tour);\n if (!normalized) return null;\n const {stops} = normalized;\n let remaining = Number.isNaN(elapsedMs) ? 0 : Math.max(0, elapsedMs);\n for (let index = 0; index < stops.length - 1; index++) {\n const stop = stops[index];\n if (remaining < stop.holdDurationMs) return {...stop.camera};\n remaining -= stop.holdDurationMs;\n if (remaining < stop.travelDurationMs) {\n const fraction = remaining / stop.travelDurationMs;\n const eased = fraction * fraction * (3 - 2 * fraction);\n const from = stop.camera;\n const to = stops[index + 1].camera;\n const startVelocity = velocityAtStop(stops, index);\n const endVelocity = velocityAtStop(stops, index + 1);\n const startWeight = fraction * (1 - fraction) ** 2 * stop.travelDurationMs;\n const endWeight = fraction ** 2 * (1 - fraction) * stop.travelDurationMs;\n const offset = (key: keyof CameraSnapshot) =>\n startVelocity[key] * startWeight - endVelocity[key] * endWeight;\n return {\n longitude:\n from.longitude +\n shortestRotation(from.longitude, to.longitude) * eased +\n offset('longitude'),\n latitude: from.latitude + (to.latitude - from.latitude) * eased + offset('latitude'),\n zoom: from.zoom * (1 - eased) + to.zoom * eased + offset('zoom'),\n bearing:\n from.bearing + shortestRotation(from.bearing, to.bearing) * eased + offset('bearing'),\n pitch: from.pitch + (to.pitch - from.pitch) * eased + offset('pitch')\n };\n }\n remaining -= stop.travelDurationMs;\n }\n return {...st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,KAAA;IAAA,IAAAW,IAAA,SAAAA,IAAA,CAAAV,CAAA;EAAA;EA6BrD,OAAAC,aAAA,KAAWvE,KAAK,CAACA,KAAK,CAACM,MAAM,GAAG,CAAC,CAAC,CAACkB,MAAM;AAC3C","ignoreList":[]}
|
|
@@ -38,12 +38,22 @@ export function getJenksDomain(data, valueAccessor, k) {
|
|
|
38
38
|
return naturalBreaks(values, k);
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
// Preserve lexical ordering for strings and mixed domains, but do not stringify
|
|
42
|
+
// numeric categories before assigning sequential palette positions.
|
|
43
|
+
function sortOrdinalValues(values) {
|
|
44
|
+
return values.every(function (value) {
|
|
45
|
+
return typeof value === 'number' && !Number.isNaN(value);
|
|
46
|
+
}) ? values.sort(function (a, b) {
|
|
47
|
+
return Number(a) - Number(b);
|
|
48
|
+
}) : values.sort();
|
|
49
|
+
}
|
|
50
|
+
|
|
41
51
|
/**
|
|
42
52
|
* return ordinal domain for a data container
|
|
43
53
|
*/
|
|
44
54
|
export function getOrdinalDomain(dataContainer, valueAccessor) {
|
|
45
55
|
var values = dataContainer.mapIndex(valueAccessor);
|
|
46
|
-
return unique(values).filter(notNullorUndefined)
|
|
56
|
+
return sortOrdinalValues(unique(values).filter(notNullorUndefined));
|
|
47
57
|
}
|
|
48
58
|
|
|
49
59
|
/**
|
|
@@ -282,7 +292,7 @@ export function getVisualChannelScaleByZoom(_ref3) {
|
|
|
282
292
|
* Get categorical colorMap from colors and domain (unique values)
|
|
283
293
|
*/
|
|
284
294
|
export function getCategoricalColorMap(colors, domain) {
|
|
285
|
-
var uniqueValues = unique(domain)
|
|
295
|
+
var uniqueValues = sortOrdinalValues(unique(domain));
|
|
286
296
|
var colorMap = colors.map(function (color) {
|
|
287
297
|
return [null, color];
|
|
288
298
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-scale-utils.js","names":["bisectLeft","quantileSorted","d3Quantile","extent","uniq","moment","notNullorUndefined","toArray","ALL_FIELD_TYPES","SCALE_FUNC","SCALE_TYPES","NO_VALUE_COLOR","isRgbColor","rgbToHex","hexToRgb","formatNumber","isNumber","reverseFormatNumber","unique","getTimeWidgetHintFormatter","naturalBreaks","isPlainObject","getQuantileDomain","data","valueAccessor","sortFunc","values","map","filter","sort","getJenksDomain","k","getOrdinalDomain","dataContainer","mapIndex","getLinearDomain","range","d","i","undefined","getLogDomain","_getLinearDomain","_getLinearDomain2","_slicedToArray","d0","d1","isDomainStops","domain","Array","isArray","stops","z","isDomainQuantile","quantiles","getThresholdsFromQuantiles","buckets","thresholds","Number","isFinite","length","position","push","getDomainStepsbyZoom","steps","Math","max","getScaleFunction","scale","fixed","scaleFunction","scaleType","getThresholdLabels","labelFormat","genLength","invert","invertExtent","inputs","label","concat","getScaleLabels","customScaleLabelFormat","n","getQuantLegends","thresholdLabelFormat","type","labels","jenks","index","_objectSpread","getOrdinalLegends","datum","defaultFormat","getTimeLabelFormat","formatter","val","utc","format","getQuantLabelFormat","fieldType","timestamp","getLegendOfScale","_ref","byZoom","ordinal","customOrdinal","string","formatLabel","getLayerColorScale","_ref2","layer","getColorScale","initializeLayerColorMap","visualChannel","config","visConfig","field","colorBreaks","colorBreaksToColorMap","getVisualChannelScaleByZoom","_ref3","_scale","mapState","_layer$meta","meta","getZoom","zoom","getCategoricalColorMap","colors","uniqueValues","colorMap","color","lastIndex","assignCount","min","aggregatedValues","value","apply","_toConsumableArray","colorMapToCategoricalColorBreaks","_ref4","_ref5","colorBreaksToCategoricalColorMap","cb","colorBreak","colorMapToColorBreaks","_ref6","_ref7","Infinity","isNumericColorBreaks","Boolean","getHistogramDomain","_ref8","aggregatedBins","columnStats","dataset","fieldValueAccessor","domainMin","POSITIVE_INFINITY","domainMax","NEGATIVE_INFINITY","nValid","domainSum","Object","forEach","bin","mean","allIndexes","x","histogramMean","resetCategoricalColorMapByIndex","newColorMap","cm","selectRestCategoricalColorMapByIndex","uniqValueDict","fromEntries","v","rest","keys","removeCategoricalValueFromColorMap","item","currentUniqueValues","updatedUniqueValues","addCategoricalValuesToColorMap","items","includes","getCategoricalColorScale","colorDomain","colorRange","useRgb","arguments","cMap","unknown","initCustomPaletteByCustomScale","_ref9","ordinalDomain","customPaletteName","name","reuseColorMap","customPalette","category"],"sources":["../../src/data-scale-utils.ts"],"sourcesContent":["// SPDX-License-Identifier: MIT\n// Copyright contributors to the kepler.gl project\n\nimport {bisectLeft, quantileSorted as d3Quantile, extent} from 'd3-array';\nimport uniq from 'es-toolkit/compat/uniq';\nimport moment from 'moment';\n\nimport {notNullorUndefined, toArray} from '@kepler.gl/common-utils';\nimport {ALL_FIELD_TYPES, SCALE_FUNC, SCALE_TYPES, NO_VALUE_COLOR} from '@kepler.gl/constants';\n// import {FilterProps, KeplerTable} from '@kepler.gl/layers';\nimport {\n AggregatedBin,\n ColorMap,\n ColorRange,\n HexColor,\n KeplerLayer as Layer,\n MapState,\n VisualChannel,\n VisualChannelDomain,\n RGBColor,\n RGBAColor,\n ColorUI,\n Field\n} from '@kepler.gl/types';\n\nimport {isRgbColor, rgbToHex, hexToRgb} from './color-utils';\nimport {DataContainerInterface} from './data-container-interface';\nimport {formatNumber, isNumber, reverseFormatNumber, unique} from './data-utils';\nimport {getTimeWidgetHintFormatter} from './filter-utils';\nimport naturalBreaks from './jenks';\nimport {isPlainObject} from './utils';\n\nexport type ColorBreak = {\n data: HexColor;\n label: string;\n range: number[];\n inputs: number[];\n};\nexport type ColorBreakOrdinal = {\n data: HexColor;\n label: string | number | string[] | number[] | null;\n};\n\nexport type D3ScaleFunction = Record<string, any> & ((x: any) => any);\n\n// TODO isolate types - depends on @kepler.gl/layers\ntype FilterProps = any;\ntype KeplerTable = any;\n\nexport type LabelFormat = (n: number, type?: string) => string;\ntype dataValueAccessor = <T>(param: T) => T;\ntype dataContainerValueAccessor = (d: {index: number}, dc: DataContainerInterface) => any;\ntype sort = (a: any, b: any) => any;\n/**\n * return quantile domain for an array of data\n */\nexport function getQuantileDomain(\n data: any[],\n valueAccessor?: dataValueAccessor,\n sortFunc?: sort\n): number[] {\n const values = typeof valueAccessor === 'function' ? data.map(valueAccessor) : data;\n\n return values.filter(notNullorUndefined).sort(sortFunc);\n}\n\n/**\n * Return Jenks natural-break thresholds for an array of data.\n * `k` is the number of color classes (range length).\n */\nexport function getJenksDomain(\n data: any[],\n valueAccessor: dataValueAccessor | undefined,\n k: number\n): number[] {\n const values =\n typeof valueAccessor === 'function'\n ? data.map(valueAccessor).filter(isNumber)\n : data.filter(isNumber);\n\n return naturalBreaks(values, k);\n}\n\n/**\n * return ordinal domain for a data container\n */\nexport function getOrdinalDomain(\n dataContainer: DataContainerInterface,\n valueAccessor: dataContainerValueAccessor\n): string[] {\n const values = dataContainer.mapIndex(valueAccessor);\n\n return unique(values).filter(notNullorUndefined).sort();\n}\n\n/**\n * return linear domain for an array of data\n */\nexport function getLinearDomain(\n data: number[],\n valueAccessor?: dataValueAccessor\n): [number, number] {\n const range = typeof valueAccessor === 'function' ? extent(data, valueAccessor) : extent(data);\n return range.map((d: undefined | number, i: number) => (d === undefined ? i : d)) as [\n number,\n number\n ];\n}\n\n/**\n * return linear domain for an array of data. A log scale domain cannot contain 0\n */\nexport function getLogDomain(data: any[], valueAccessor: dataValueAccessor): [number, number] {\n const [d0, d1] = getLinearDomain(data, valueAccessor);\n return [d0 === 0 ? 1e-5 : d0, d1];\n}\n\nexport type DomainStops = {\n stops: number[];\n z: number[];\n};\n\n/**\n * whether field domain is stops\n */\nexport function isDomainStops(domain: unknown): domain is DomainStops {\n return isPlainObject(domain) && Array.isArray(domain.stops) && Array.isArray(domain.z);\n}\n\nexport type DomainQuantiles = {\n quantiles: number[];\n z: number[];\n};\n\n/**\n * whether field domain is quantiles\n */\nexport function isDomainQuantile(domain: any): domain is DomainQuantiles {\n return isPlainObject(domain) && Array.isArray(domain.quantiles) && Array.isArray(domain.z);\n}\n\n/**\n * get the domain at zoom\n */\nexport function getThresholdsFromQuantiles(\n quantiles: number[],\n buckets: number\n): (number | undefined)[] {\n const thresholds = [];\n if (!Number.isFinite(buckets) || buckets < 1) {\n return [quantiles[0], quantiles[quantiles.length - 1]];\n }\n for (let i = 1; i < buckets; i++) {\n // position in sorted array\n const position = i / buckets;\n // @ts-ignore\n thresholds.push(d3Quantile(quantiles, position));\n }\n\n return thresholds;\n}\n\n/**\n * get the domain at zoom\n */\nexport function getDomainStepsbyZoom(domain: any[], steps: number[], z: number): any {\n const i = bisectLeft(steps, z);\n\n if (steps[i] === z) {\n // If z is an integer value exactly matching a step, return the corresponding domain\n return domain[i];\n }\n // Otherwise, return the next coarsest domain\n return domain[Math.max(i - 1, 0)];\n}\n\n/**\n * Get d3 scale function\n */\nexport function getScaleFunction(\n scale: string,\n range: any[] | IterableIterator<any>,\n domain: (number | undefined)[] | string[] | IterableIterator<any>,\n fixed?: boolean\n): D3ScaleFunction {\n const scaleFunction = SCALE_FUNC[fixed ? 'linear' : scale]()\n .domain(domain)\n .range(fixed ? domain : range);\n scaleFunction.scaleType = fixed ? 'linear' : scale;\n return scaleFunction;\n}\n\n/**\n * Get threshold scale color labels\n */\nfunction getThresholdLabels(\n scale: D3ScaleFunction,\n labelFormat: LabelFormat\n): Omit<ColorBreak, 'data'>[] {\n const genLength = scale.range().length;\n return scale.range().map((d, i) => {\n const invert = scale.invertExtent(d);\n const inputs = [\n i === 0 ? null : reverseFormatNumber(labelFormat(invert[0])),\n i === genLength - 1 ? null : reverseFormatNumber(labelFormat(invert[1]))\n ];\n return {\n // raw value\n range: invert,\n // formatted value\n inputs,\n label:\n i === 0\n ? `Less than ${labelFormat(invert[1])}`\n : i === genLength - 1\n ? `${labelFormat(invert[0])} or more`\n : `${labelFormat(invert[0])} to ${labelFormat(invert[1])}`\n };\n });\n}\n\n/**\n * Get linear / quant scale color labels\n */\nfunction getScaleLabels(\n scale: D3ScaleFunction,\n labelFormat: LabelFormat\n): Omit<ColorBreak, 'data'>[] {\n return scale.range().map(d => {\n // @ts-ignore\n const invert = scale.invertExtent(d);\n const inputs = [\n reverseFormatNumber(labelFormat(invert[0])),\n reverseFormatNumber(labelFormat(invert[1]))\n ];\n\n return {\n label: `${labelFormat(invert[0])} to ${labelFormat(invert[1])}`,\n // raw value\n range: invert,\n // formatted value\n inputs\n };\n });\n}\n\nconst customScaleLabelFormat = n => (n || n === 0 ? formatNumber(n, 'real') : 'no value');\n/**\n * Get linear / quant scale color breaks\n */\nexport function getQuantLegends(scale: D3ScaleFunction, labelFormat: LabelFormat): ColorBreak[] {\n if (typeof scale.invertExtent !== 'function') {\n return [];\n }\n const thresholdLabelFormat = (n, type) =>\n n || n === 0 ? (labelFormat ? labelFormat(n) : formatNumber(n, type)) : 'no value';\n const labels =\n scale.scaleType === 'threshold' || scale.scaleType === SCALE_TYPES.jenks\n ? getThresholdLabels(scale, thresholdLabelFormat)\n : scale.scaleType === 'custom'\n ? getThresholdLabels(scale, customScaleLabelFormat)\n : getScaleLabels(scale, labelFormat);\n\n const data = scale.range();\n\n return labels.map((label, index) => ({\n data: Array.isArray(data[index]) ? rgbToHex(data[index] as RGBColor) : data[index],\n ...label\n }));\n}\n\n/**\n * Get ordinal color scale legends\n */\nexport function getOrdinalLegends(scale: D3ScaleFunction): ColorBreakOrdinal[] {\n const domain = scale.domain();\n const labels = scale.domain();\n const data = domain.map(scale);\n\n return data.map((datum, index) => ({\n data: isRgbColor(datum) ? rgbToHex(datum) : datum,\n label: labels[index]\n }));\n}\n\nconst defaultFormat = d => d;\n\nconst getTimeLabelFormat = domain => {\n const formatter = getTimeWidgetHintFormatter(domain);\n return val => moment.utc(val).format(formatter);\n};\n\nexport function getQuantLabelFormat(domain, fieldType) {\n // quant scale can only be assigned to linear Fields: real, timestamp, integer\n return fieldType === ALL_FIELD_TYPES.timestamp\n ? getTimeLabelFormat(domain)\n : !fieldType\n ? defaultFormat\n : n => (isNumber(n) ? formatNumber(n, fieldType) : 'no value');\n}\n\n/**\n * Get legends for scale\n */\nexport function getLegendOfScale({\n scale,\n scaleType,\n labelFormat,\n fieldType\n}: {\n scale?: D3ScaleFunction | null;\n scaleType: string;\n labelFormat?: LabelFormat;\n fieldType: string | null | undefined;\n}): ColorBreak[] | ColorBreakOrdinal[] {\n if (!scale || scale.byZoom) {\n return [];\n }\n if (\n scaleType === SCALE_TYPES.ordinal ||\n scaleType === SCALE_TYPES.customOrdinal ||\n fieldType === ALL_FIELD_TYPES.string\n ) {\n return getOrdinalLegends(scale);\n }\n\n const formatLabel = labelFormat || getQuantLabelFormat(scale.domain(), fieldType);\n if (scaleType === SCALE_TYPES.jenks) {\n scale.scaleType = SCALE_TYPES.jenks;\n }\n\n return getQuantLegends(scale, formatLabel);\n}\n\n/**\n * Get color scale function\n */\nexport function getLayerColorScale({\n range,\n domain,\n scaleType,\n layer\n}: {\n range: ColorRange | null | undefined;\n domain: VisualChannelDomain;\n scaleType: string;\n layer: Layer;\n isFixed?: boolean;\n}): D3ScaleFunction | null {\n if (range && domain && scaleType) {\n return layer.getColorScale(scaleType, domain, range);\n }\n return null;\n}\n\n/**\n * Convert colorRange.colorMap into color breaks UI input\n */\nexport function initializeLayerColorMap(layer: Layer, visualChannel: VisualChannel): ColorMap {\n const domain = layer.config[visualChannel.domain];\n const range = layer.config.visConfig[visualChannel.range];\n const scaleType = layer.config[visualChannel.scale];\n const field = layer.config[visualChannel.field];\n\n const scale = getLayerColorScale({\n range,\n domain,\n scaleType,\n layer\n });\n\n const colorBreaks = getLegendOfScale({\n scale: scale?.byZoom ? scale(0) : scale,\n scaleType,\n fieldType: field.type\n });\n return colorBreaksToColorMap(colorBreaks);\n}\n\n/**\n * Get visual chanel scale function if it's based on zoom\n */\nexport function getVisualChannelScaleByZoom({\n scale,\n layer,\n mapState\n}: {\n scale: D3ScaleFunction | null;\n layer: Layer;\n mapState?: MapState;\n}): D3ScaleFunction | null {\n if (scale?.byZoom) {\n const z = layer.meta?.getZoom ? layer.meta.getZoom(mapState) : mapState?.zoom;\n scale = Number.isFinite(z) ? scale(z) : null;\n }\n return scale;\n}\n\n/**\n * Get categorical colorMap from colors and domain (unique values)\n */\nexport function getCategoricalColorMap(\n colors: string[],\n domain: (string | number | string[] | number[] | null)[]\n): any {\n const uniqueValues = unique(domain).sort();\n const colorMap = colors.map(color => [null, color]);\n\n if (colors.length === 0 || uniqueValues.length === 0) {\n return colorMap;\n }\n\n const lastIndex = colors.length - 1;\n const assignCount = Math.min(lastIndex, uniqueValues.length);\n\n // Assign first values one-to-one up to the penultimate color (if any)\n for (let i = 0; i < assignCount; i++) {\n // @ts-ignore tuple\n colorMap[i][0] = uniqueValues[i];\n }\n\n if (uniqueValues.length > colors.length) {\n // Aggregate the rest (including the value that would have gone to last color)\n // Build aggregated array incrementally to match legacy behavior\n const aggregatedValues: any[] = [];\n for (let i = lastIndex; i < uniqueValues.length; i++) {\n const value = uniqueValues[i];\n if (Array.isArray(value)) {\n // Spread array elements to match legacy flattening behavior\n aggregatedValues.push(...(value as any[]));\n } else {\n aggregatedValues.push(value);\n }\n }\n // @ts-ignore tuple\n colorMap[lastIndex][0] = aggregatedValues;\n } else if (uniqueValues.length === colors.length) {\n // Exactly one per color\n // @ts-ignore tuple\n colorMap[lastIndex][0] = uniqueValues[lastIndex];\n }\n\n // @ts-ignore tuple\n return colorMap;\n}\n\n/**\n * Get categorical colorBreaks from colorMap\n */\nexport function colorMapToCategoricalColorBreaks(\n colorMap?: ColorMap | null\n): ColorBreakOrdinal[] | null {\n if (!colorMap) {\n return null;\n }\n const colorBreaks = colorMap.map(([value, color]) => {\n return {\n data: color,\n label: value\n };\n });\n\n return colorBreaks;\n}\n\n/**\n * create categorical colorMap from colorBreaks\n */\nexport function colorBreaksToCategoricalColorMap(colorBreaks: ColorBreakOrdinal[]): ColorMap {\n // colorMap: [string | string[], hexstring]\n const colors = uniq(colorBreaks.map(cb => cb.data));\n const values = uniq(colorBreaks.map(cb => cb.label));\n\n return getCategoricalColorMap(colors, values);\n}\n\n/**\n * Convert color breaks UI input into colorRange.colorMap\n */\nexport function colorBreaksToColorMap(colorBreaks: ColorBreak[] | ColorBreakOrdinal[]): ColorMap {\n const colorMap = colorBreaks.map((colorBreak, i) => {\n // [value, hex]\n return [\n colorBreak.inputs\n ? i === colorBreaks.length - 1\n ? null // last\n : colorBreak.inputs[1]\n : colorBreak.label,\n colorBreak.data\n ];\n });\n\n // @ts-ignore tuple\n return colorMap;\n}\n\n/**\n * Convert colorRange.colorMap into color breaks UI input\n */\nexport function colorMapToColorBreaks(colorMap?: ColorMap | null): ColorBreak[] | null {\n if (!colorMap) {\n return null;\n }\n const colorBreaks = colorMap.map(([value, color], i) => {\n const range =\n i === 0\n ? // first\n [-Infinity, value]\n : // last\n i === colorMap.length - 1\n ? [colorMap[i - 1][0], Infinity]\n : // else\n [colorMap[i - 1][0], value];\n return {\n data: color,\n range,\n inputs: range,\n label:\n // first\n i === 0\n ? `Less than ${value}`\n : // last\n i === colorMap.length - 1\n ? `${colorMap[i - 1][0]} or more`\n : `${colorMap[i - 1][0]} to ${value}`\n };\n });\n\n // @ts-ignore implement conversion for ordinal\n return colorBreaks;\n}\n\n/**\n * Whether color breaks is for numeric field\n */\nexport function isNumericColorBreaks(colorBreaks: unknown): colorBreaks is ColorBreak[] {\n return Boolean(Array.isArray(colorBreaks) && colorBreaks.length && colorBreaks[0].inputs);\n}\n\n// return domainMin, domainMax, histogramMean\nexport function getHistogramDomain({\n aggregatedBins,\n columnStats,\n dataset,\n fieldValueAccessor\n}: {\n aggregatedBins?: Record<number, AggregatedBin>;\n columnStats?: FilterProps['columnStats'];\n dataset?: KeplerTable;\n fieldValueAccessor: (idx: unknown) => number;\n}) {\n let domainMin = Number.POSITIVE_INFINITY;\n let domainMax = Number.NEGATIVE_INFINITY;\n let nValid = 0;\n let domainSum = 0;\n\n if (aggregatedBins) {\n Object.values(aggregatedBins).forEach(bin => {\n const val = bin.value;\n if (isNumber(val)) {\n if (val < domainMin) domainMin = val;\n if (val > domainMax) domainMax = val;\n domainSum += val;\n nValid += 1;\n }\n });\n } else {\n if (columnStats && columnStats.quantiles && columnStats.mean) {\n // no need to recalcuate min/max/mean if its already in columnStats\n return [\n columnStats.quantiles[0].value,\n columnStats.quantiles[columnStats.quantiles.length - 1].value,\n columnStats.mean\n ];\n }\n if (dataset && fieldValueAccessor) {\n dataset.allIndexes.forEach(x => {\n const val = fieldValueAccessor(x);\n if (isNumber(val)) {\n if (val < domainMin) domainMin = val;\n if (val > domainMax) domainMax = val;\n domainSum += val;\n nValid += 1;\n }\n });\n }\n }\n const histogramMean = nValid > 0 ? domainSum / nValid : 0;\n return [nValid > 0 ? domainMin : 0, nValid > 0 ? domainMax : 0, histogramMean];\n}\n\nexport function resetCategoricalColorMapByIndex(colorMap: ColorMap, index: number): any {\n if (!colorMap) {\n return colorMap;\n }\n const newColorMap = colorMap.map((cm, i) => {\n if (i === index) {\n return [null, cm[1]];\n }\n return cm;\n });\n return newColorMap;\n}\n\n/**\n * select rest categorical values for a colorMap by its index\n */\nexport function selectRestCategoricalColorMapByIndex(\n colorMap: ColorMap | null,\n index: number,\n uniqueValues?: number[] | string[]\n): ColorMap | undefined | null {\n if (!colorMap || !uniqueValues) {\n return colorMap;\n }\n\n // find unique values that has not been used in current colorMap\n const uniqValueDict = Object.fromEntries(uniqueValues.map(val => [val, false]));\n colorMap.forEach(cm => {\n toArray(cm[0]).forEach(v => {\n if (notNullorUndefined(v)) uniqValueDict[v] = true;\n });\n });\n const rest = Object.keys(uniqValueDict).filter(v => !uniqValueDict[v]);\n\n // use the not used unique values in the selected color map\n const newColorMap = colorMap.map((cm, i) => {\n if (i === index) {\n return [[...rest, ...toArray(cm[0])], cm[1]];\n }\n return cm;\n }) as ColorMap;\n\n return newColorMap;\n}\n\n/**\n * remove a categorical value from a colorMap by its index\n */\nexport function removeCategoricalValueFromColorMap(\n colorMap: ColorMap | null | undefined,\n item: number | string,\n index: number\n): ColorMap | null | undefined {\n if (!colorMap) {\n return colorMap;\n }\n const newColorMap = colorMap.map((cm, i) => {\n if (i === index) {\n if (!notNullorUndefined(cm[0])) {\n return [null, cm[1]];\n }\n const currentUniqueValues = toArray(cm[0]);\n const updatedUniqueValues = currentUniqueValues.filter(v => v !== item);\n return [updatedUniqueValues, cm[1]];\n }\n return cm;\n }) as ColorMap;\n\n return newColorMap;\n}\n\n/**\n * add categorical values (from multisel dropdown) to a colorMap by its index\n */\nexport function addCategoricalValuesToColorMap(\n colorMap: ColorMap,\n items: (string | number)[],\n index: number\n): ColorMap {\n if (!colorMap) {\n return colorMap;\n }\n\n const newColorMap = colorMap.map((cm, i) => {\n if (i === index) {\n if (!notNullorUndefined(cm[0])) {\n return [items, cm[1]];\n }\n const currentUniqueValues = toArray(cm[0]);\n const updatedUniqueValues = uniq(currentUniqueValues.concat(items));\n return [updatedUniqueValues, cm[1]];\n }\n // remove value from other colorMap\n const currentUniqueValues = cm[0];\n if (Array.isArray(currentUniqueValues)) {\n const updatedUniqueValues: string[] | number[] = (currentUniqueValues as any[]).filter(\n v => !items.includes(v)\n );\n return [updatedUniqueValues, cm[1]];\n } else if (notNullorUndefined(currentUniqueValues) && items.includes(currentUniqueValues)) {\n return [null, cm[1]];\n }\n\n return cm;\n }) as ColorMap;\n\n return newColorMap;\n}\n\n/**\n * get a color scale func for categorical (custom ordinal) scale\n */\nexport function getCategoricalColorScale(\n colorDomain: number[] | string[],\n colorRange: ColorRange,\n useRgb = true\n): (categoryValue: string | number) => RGBColor | RGBAColor {\n const cMap = colorRange.colorMap\n ? colorRange.colorMap\n : getCategoricalColorMap(colorRange.colors, colorDomain);\n\n const range: number[][] = [];\n const domain: string[] = [];\n cMap.forEach(cm => {\n if (Array.isArray(cm[0])) {\n cm[0].forEach(val => {\n domain.push(val);\n range.push(useRgb ? hexToRgb(cm[1]) : cm[1]);\n });\n } else {\n domain.push(cm[0]);\n range.push(useRgb ? hexToRgb(cm[1]) : cm[1]);\n }\n });\n\n const scale = getScaleFunction(SCALE_TYPES.customOrdinal, range, domain, false);\n scale.unknown(NO_VALUE_COLOR);\n return scale as any;\n}\n\n/**\n * initialize customPalette by custom scale or customOrdinal scale\n */\nexport function initCustomPaletteByCustomScale({\n scale,\n field,\n ordinalDomain,\n range,\n colorBreaks\n}: {\n scale: string;\n field?: Field;\n ordinalDomain?: number[] | string[];\n range: ColorRange;\n colorBreaks: ColorBreakOrdinal[] | null;\n}): ColorUI['customPalette'] {\n const customPaletteName = `color.customPalette.${scale}.${field?.name || 'point-count'}`;\n // reuse range.colorMap if the field and scale not changed\n const reuseColorMap = range.colorMap && range.name === customPaletteName && range.type === scale;\n const colorMap = reuseColorMap\n ? range.colorMap\n : scale === SCALE_TYPES.customOrdinal && ordinalDomain\n ? getCategoricalColorMap(range.colors, ordinalDomain)\n : colorBreaks && isNumericColorBreaks(colorBreaks)\n ? colorBreaksToColorMap(colorBreaks)\n : null;\n const colors = reuseColorMap ? range.colors : colorMap ? colorMap.map(cm => cm[1]) : range.colors;\n\n // update custom breaks\n const customPalette: ColorUI['customPalette'] = {\n category: 'Custom',\n name: customPaletteName,\n type: scale,\n colorMap,\n colors: colors || []\n };\n\n return customPalette;\n}\n"],"mappings":";;;;;AAAA;AACA;;AAEA,SAAQA,UAAU,EAAEC,cAAc,IAAIC,UAAU,EAAEC,MAAM,QAAO,UAAU;AACzE,OAAOC,IAAI,MAAM,wBAAwB;AACzC,OAAOC,MAAM,MAAM,QAAQ;AAE3B,SAAQC,kBAAkB,EAAEC,OAAO,QAAO,yBAAyB;AACnE,SAAQC,eAAe,EAAEC,UAAU,EAAEC,WAAW,EAAEC,cAAc,QAAO,sBAAsB;AAC7F;;AAgBA,SAAQC,UAAU,EAAEC,QAAQ,EAAEC,QAAQ,QAAO,eAAe;AAE5D,SAAQC,YAAY,EAAEC,QAAQ,EAAEC,mBAAmB,EAAEC,MAAM,QAAO,cAAc;AAChF,SAAQC,0BAA0B,QAAO,gBAAgB;AACzD,OAAOC,aAAa,MAAM,SAAS;AACnC,SAAQC,aAAa,QAAO,SAAS;;AAerC;;AAQA;AACA;AACA;AACA,OAAO,SAASC,iBAAiBA,CA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,KAAI,aAAa,CAAE;EACxF;EACA,IAAMC,aAAa,GAAGjK,KAAK,CAAC6F,QAAQ,IAAI7F,KAAK,CAACgK,IAAI,KAAKD,iBAAiB,IAAI/J,KAAK,CAACgD,IAAI,KAAKjB,KAAK;EAChG,IAAM8D,QAAQ,GAAGoE,aAAa,GAC1BjK,KAAK,CAAC6F,QAAQ,GACd9D,KAAK,KAAKzD,WAAW,CAAC8F,aAAa,IAAI0F,aAAa,GACpDpE,sBAAsB,CAAC1F,KAAK,CAAC2F,MAAM,EAAEmE,aAAa,CAAC,GACnD9E,WAAW,IAAIgC,oBAAoB,CAAChC,WAAW,CAAC,GAChDC,qBAAqB,CAACD,WAAW,CAAC,GAClC,IAAI;EACR,IAAMW,MAAM,GAAGsE,aAAa,GAAGjK,KAAK,CAAC2F,MAAM,GAAGE,QAAQ,GAAGA,QAAQ,CAACtG,GAAG,CAAC,UAAAgJ,EAAE;IAAA,OAAIA,EAAE,CAAC,CAAC,CAAC;EAAA,EAAC,GAAGvI,KAAK,CAAC2F,MAAM;;EAEjG;EACA,IAAMuE,aAAuC,GAAG;IAC9CC,QAAQ,EAAE,QAAQ;IAClBH,IAAI,EAAED,iBAAiB;IACvB/G,IAAI,EAAEjB,KAAK;IACX8D,QAAQ,EAARA,QAAQ;IACRF,MAAM,EAAEA,MAAM,IAAI;EACpB,CAAC;EAED,OAAOuE,aAAa;AACtB","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"data-scale-utils.js","names":["bisectLeft","quantileSorted","d3Quantile","extent","uniq","moment","notNullorUndefined","toArray","ALL_FIELD_TYPES","SCALE_FUNC","SCALE_TYPES","NO_VALUE_COLOR","isRgbColor","rgbToHex","hexToRgb","formatNumber","isNumber","reverseFormatNumber","unique","getTimeWidgetHintFormatter","naturalBreaks","isPlainObject","getQuantileDomain","data","valueAccessor","sortFunc","values","map","filter","sort","getJenksDomain","k","sortOrdinalValues","every","value","Number","isNaN","a","b","getOrdinalDomain","dataContainer","mapIndex","getLinearDomain","range","d","i","undefined","getLogDomain","_getLinearDomain","_getLinearDomain2","_slicedToArray","d0","d1","isDomainStops","domain","Array","isArray","stops","z","isDomainQuantile","quantiles","getThresholdsFromQuantiles","buckets","thresholds","isFinite","length","position","push","getDomainStepsbyZoom","steps","Math","max","getScaleFunction","scale","fixed","scaleFunction","scaleType","getThresholdLabels","labelFormat","genLength","invert","invertExtent","inputs","label","concat","getScaleLabels","customScaleLabelFormat","n","getQuantLegends","thresholdLabelFormat","type","labels","jenks","index","_objectSpread","getOrdinalLegends","datum","defaultFormat","getTimeLabelFormat","formatter","val","utc","format","getQuantLabelFormat","fieldType","timestamp","getLegendOfScale","_ref","byZoom","ordinal","customOrdinal","string","formatLabel","getLayerColorScale","_ref2","layer","getColorScale","initializeLayerColorMap","visualChannel","config","visConfig","field","colorBreaks","colorBreaksToColorMap","getVisualChannelScaleByZoom","_ref3","_scale","mapState","_layer$meta","meta","getZoom","zoom","getCategoricalColorMap","colors","uniqueValues","colorMap","color","lastIndex","assignCount","min","aggregatedValues","apply","_toConsumableArray","colorMapToCategoricalColorBreaks","_ref4","_ref5","colorBreaksToCategoricalColorMap","cb","colorBreak","colorMapToColorBreaks","_ref6","_ref7","Infinity","isNumericColorBreaks","Boolean","getHistogramDomain","_ref8","aggregatedBins","columnStats","dataset","fieldValueAccessor","domainMin","POSITIVE_INFINITY","domainMax","NEGATIVE_INFINITY","nValid","domainSum","Object","forEach","bin","mean","allIndexes","x","histogramMean","resetCategoricalColorMapByIndex","newColorMap","cm","selectRestCategoricalColorMapByIndex","uniqValueDict","fromEntries","v","rest","keys","removeCategoricalValueFromColorMap","item","currentUniqueValues","updatedUniqueValues","addCategoricalValuesToColorMap","items","includes","getCategoricalColorScale","colorDomain","colorRange","useRgb","arguments","cMap","unknown","initCustomPaletteByCustomScale","_ref9","ordinalDomain","customPaletteName","name","reuseColorMap","customPalette","category"],"sources":["../../src/data-scale-utils.ts"],"sourcesContent":["// SPDX-License-Identifier: MIT\n// Copyright contributors to the kepler.gl project\n\nimport {bisectLeft, quantileSorted as d3Quantile, extent} from 'd3-array';\nimport uniq from 'es-toolkit/compat/uniq';\nimport moment from 'moment';\n\nimport {notNullorUndefined, toArray} from '@kepler.gl/common-utils';\nimport {ALL_FIELD_TYPES, SCALE_FUNC, SCALE_TYPES, NO_VALUE_COLOR} from '@kepler.gl/constants';\n// import {FilterProps, KeplerTable} from '@kepler.gl/layers';\nimport {\n AggregatedBin,\n ColorMap,\n ColorRange,\n HexColor,\n KeplerLayer as Layer,\n MapState,\n VisualChannel,\n VisualChannelDomain,\n RGBColor,\n RGBAColor,\n ColorUI,\n Field\n} from '@kepler.gl/types';\n\nimport {isRgbColor, rgbToHex, hexToRgb} from './color-utils';\nimport {DataContainerInterface} from './data-container-interface';\nimport {formatNumber, isNumber, reverseFormatNumber, unique} from './data-utils';\nimport {getTimeWidgetHintFormatter} from './filter-utils';\nimport naturalBreaks from './jenks';\nimport {isPlainObject} from './utils';\n\nexport type ColorBreak = {\n data: HexColor;\n label: string;\n range: number[];\n inputs: number[];\n};\nexport type ColorBreakOrdinal = {\n data: HexColor;\n label: string | number | string[] | number[] | null;\n};\n\nexport type D3ScaleFunction = Record<string, any> & ((x: any) => any);\n\n// TODO isolate types - depends on @kepler.gl/layers\ntype FilterProps = any;\ntype KeplerTable = any;\n\nexport type LabelFormat = (n: number, type?: string) => string;\ntype dataValueAccessor = <T>(param: T) => T;\ntype dataContainerValueAccessor = (d: {index: number}, dc: DataContainerInterface) => any;\ntype sort = (a: any, b: any) => any;\n/**\n * return quantile domain for an array of data\n */\nexport function getQuantileDomain(\n data: any[],\n valueAccessor?: dataValueAccessor,\n sortFunc?: sort\n): number[] {\n const values = typeof valueAccessor === 'function' ? data.map(valueAccessor) : data;\n\n return values.filter(notNullorUndefined).sort(sortFunc);\n}\n\n/**\n * Return Jenks natural-break thresholds for an array of data.\n * `k` is the number of color classes (range length).\n */\nexport function getJenksDomain(\n data: any[],\n valueAccessor: dataValueAccessor | undefined,\n k: number\n): number[] {\n const values =\n typeof valueAccessor === 'function'\n ? data.map(valueAccessor).filter(isNumber)\n : data.filter(isNumber);\n\n return naturalBreaks(values, k);\n}\n\n// Preserve lexical ordering for strings and mixed domains, but do not stringify\n// numeric categories before assigning sequential palette positions.\nfunction sortOrdinalValues<T>(values: T[]): T[] {\n return values.every(value => typeof value === 'number' && !Number.isNaN(value))\n ? values.sort((a, b) => Number(a) - Number(b))\n : values.sort();\n}\n\n/**\n * return ordinal domain for a data container\n */\nexport function getOrdinalDomain(\n dataContainer: DataContainerInterface,\n valueAccessor: dataContainerValueAccessor\n): string[] {\n const values = dataContainer.mapIndex(valueAccessor);\n\n return sortOrdinalValues(unique(values).filter(notNullorUndefined));\n}\n\n/**\n * return linear domain for an array of data\n */\nexport function getLinearDomain(\n data: number[],\n valueAccessor?: dataValueAccessor\n): [number, number] {\n const range = typeof valueAccessor === 'function' ? extent(data, valueAccessor) : extent(data);\n return range.map((d: undefined | number, i: number) => (d === undefined ? i : d)) as [\n number,\n number\n ];\n}\n\n/**\n * return linear domain for an array of data. A log scale domain cannot contain 0\n */\nexport function getLogDomain(data: any[], valueAccessor: dataValueAccessor): [number, number] {\n const [d0, d1] = getLinearDomain(data, valueAccessor);\n return [d0 === 0 ? 1e-5 : d0, d1];\n}\n\nexport type DomainStops = {\n stops: number[];\n z: number[];\n};\n\n/**\n * whether field domain is stops\n */\nexport function isDomainStops(domain: unknown): domain is DomainStops {\n return isPlainObject(domain) && Array.isArray(domain.stops) && Array.isArray(domain.z);\n}\n\nexport type DomainQuantiles = {\n quantiles: number[];\n z: number[];\n};\n\n/**\n * whether field domain is quantiles\n */\nexport function isDomainQuantile(domain: any): domain is DomainQuantiles {\n return isPlainObject(domain) && Array.isArray(domain.quantiles) && Array.isArray(domain.z);\n}\n\n/**\n * get the domain at zoom\n */\nexport function getThresholdsFromQuantiles(\n quantiles: number[],\n buckets: number\n): (number | undefined)[] {\n const thresholds = [];\n if (!Number.isFinite(buckets) || buckets < 1) {\n return [quantiles[0], quantiles[quantiles.length - 1]];\n }\n for (let i = 1; i < buckets; i++) {\n // position in sorted array\n const position = i / buckets;\n // @ts-ignore\n thresholds.push(d3Quantile(quantiles, position));\n }\n\n return thresholds;\n}\n\n/**\n * get the domain at zoom\n */\nexport function getDomainStepsbyZoom(domain: any[], steps: number[], z: number): any {\n const i = bisectLeft(steps, z);\n\n if (steps[i] === z) {\n // If z is an integer value exactly matching a step, return the corresponding domain\n return domain[i];\n }\n // Otherwise, return the next coarsest domain\n return domain[Math.max(i - 1, 0)];\n}\n\n/**\n * Get d3 scale function\n */\nexport function getScaleFunction(\n scale: string,\n range: any[] | IterableIterator<any>,\n domain: (number | undefined)[] | string[] | IterableIterator<any>,\n fixed?: boolean\n): D3ScaleFunction {\n const scaleFunction = SCALE_FUNC[fixed ? 'linear' : scale]()\n .domain(domain)\n .range(fixed ? domain : range);\n scaleFunction.scaleType = fixed ? 'linear' : scale;\n return scaleFunction;\n}\n\n/**\n * Get threshold scale color labels\n */\nfunction getThresholdLabels(\n scale: D3ScaleFunction,\n labelFormat: LabelFormat\n): Omit<ColorBreak, 'data'>[] {\n const genLength = scale.range().length;\n return scale.range().map((d, i) => {\n const invert = scale.invertExtent(d);\n const inputs = [\n i === 0 ? null : reverseFormatNumber(labelFormat(invert[0])),\n i === genLength - 1 ? null : reverseFormatNumber(labelFormat(invert[1]))\n ];\n return {\n // raw value\n range: invert,\n // formatted value\n inputs,\n label:\n i === 0\n ? `Less than ${labelFormat(invert[1])}`\n : i === genLength - 1\n ? `${labelFormat(invert[0])} or more`\n : `${labelFormat(invert[0])} to ${labelFormat(invert[1])}`\n };\n });\n}\n\n/**\n * Get linear / quant scale color labels\n */\nfunction getScaleLabels(\n scale: D3ScaleFunction,\n labelFormat: LabelFormat\n): Omit<ColorBreak, 'data'>[] {\n return scale.range().map(d => {\n // @ts-ignore\n const invert = scale.invertExtent(d);\n const inputs = [\n reverseFormatNumber(labelFormat(invert[0])),\n reverseFormatNumber(labelFormat(invert[1]))\n ];\n\n return {\n label: `${labelFormat(invert[0])} to ${labelFormat(invert[1])}`,\n // raw value\n range: invert,\n // formatted value\n inputs\n };\n });\n}\n\nconst customScaleLabelFormat = n => (n || n === 0 ? formatNumber(n, 'real') : 'no value');\n/**\n * Get linear / quant scale color breaks\n */\nexport function getQuantLegends(scale: D3ScaleFunction, labelFormat: LabelFormat): ColorBreak[] {\n if (typeof scale.invertExtent !== 'function') {\n return [];\n }\n const thresholdLabelFormat = (n, type) =>\n n || n === 0 ? (labelFormat ? labelFormat(n) : formatNumber(n, type)) : 'no value';\n const labels =\n scale.scaleType === 'threshold' || scale.scaleType === SCALE_TYPES.jenks\n ? getThresholdLabels(scale, thresholdLabelFormat)\n : scale.scaleType === 'custom'\n ? getThresholdLabels(scale, customScaleLabelFormat)\n : getScaleLabels(scale, labelFormat);\n\n const data = scale.range();\n\n return labels.map((label, index) => ({\n data: Array.isArray(data[index]) ? rgbToHex(data[index] as RGBColor) : data[index],\n ...label\n }));\n}\n\n/**\n * Get ordinal color scale legends\n */\nexport function getOrdinalLegends(scale: D3ScaleFunction): ColorBreakOrdinal[] {\n const domain = scale.domain();\n const labels = scale.domain();\n const data = domain.map(scale);\n\n return data.map((datum, index) => ({\n data: isRgbColor(datum) ? rgbToHex(datum) : datum,\n label: labels[index]\n }));\n}\n\nconst defaultFormat = d => d;\n\nconst getTimeLabelFormat = domain => {\n const formatter = getTimeWidgetHintFormatter(domain);\n return val => moment.utc(val).format(formatter);\n};\n\nexport function getQuantLabelFormat(domain, fieldType) {\n // quant scale can only be assigned to linear Fields: real, timestamp, integer\n return fieldType === ALL_FIELD_TYPES.timestamp\n ? getTimeLabelFormat(domain)\n : !fieldType\n ? defaultFormat\n : n => (isNumber(n) ? formatNumber(n, fieldType) : 'no value');\n}\n\n/**\n * Get legends for scale\n */\nexport function getLegendOfScale({\n scale,\n scaleType,\n labelFormat,\n fieldType\n}: {\n scale?: D3ScaleFunction | null;\n scaleType: string;\n labelFormat?: LabelFormat;\n fieldType: string | null | undefined;\n}): ColorBreak[] | ColorBreakOrdinal[] {\n if (!scale || scale.byZoom) {\n return [];\n }\n if (\n scaleType === SCALE_TYPES.ordinal ||\n scaleType === SCALE_TYPES.customOrdinal ||\n fieldType === ALL_FIELD_TYPES.string\n ) {\n return getOrdinalLegends(scale);\n }\n\n const formatLabel = labelFormat || getQuantLabelFormat(scale.domain(), fieldType);\n if (scaleType === SCALE_TYPES.jenks) {\n scale.scaleType = SCALE_TYPES.jenks;\n }\n\n return getQuantLegends(scale, formatLabel);\n}\n\n/**\n * Get color scale function\n */\nexport function getLayerColorScale({\n range,\n domain,\n scaleType,\n layer\n}: {\n range: ColorRange | null | undefined;\n domain: VisualChannelDomain;\n scaleType: string;\n layer: Layer;\n isFixed?: boolean;\n}): D3ScaleFunction | null {\n if (range && domain && scaleType) {\n return layer.getColorScale(scaleType, domain, range);\n }\n return null;\n}\n\n/**\n * Convert colorRange.colorMap into color breaks UI input\n */\nexport function initializeLayerColorMap(layer: Layer, visualChannel: VisualChannel): ColorMap {\n const domain = layer.config[visualChannel.domain];\n const range = layer.config.visConfig[visualChannel.range];\n const scaleType = layer.config[visualChannel.scale];\n const field = layer.config[visualChannel.field];\n\n const scale = getLayerColorScale({\n range,\n domain,\n scaleType,\n layer\n });\n\n const colorBreaks = getLegendOfScale({\n scale: scale?.byZoom ? scale(0) : scale,\n scaleType,\n fieldType: field.type\n });\n return colorBreaksToColorMap(colorBreaks);\n}\n\n/**\n * Get visual chanel scale function if it's based on zoom\n */\nexport function getVisualChannelScaleByZoom({\n scale,\n layer,\n mapState\n}: {\n scale: D3ScaleFunction | null;\n layer: Layer;\n mapState?: MapState;\n}): D3ScaleFunction | null {\n if (scale?.byZoom) {\n const z = layer.meta?.getZoom ? layer.meta.getZoom(mapState) : mapState?.zoom;\n scale = Number.isFinite(z) ? scale(z) : null;\n }\n return scale;\n}\n\n/**\n * Get categorical colorMap from colors and domain (unique values)\n */\nexport function getCategoricalColorMap(\n colors: string[],\n domain: (string | number | string[] | number[] | null)[]\n): any {\n const uniqueValues = sortOrdinalValues(unique(domain));\n const colorMap = colors.map(color => [null, color]);\n\n if (colors.length === 0 || uniqueValues.length === 0) {\n return colorMap;\n }\n\n const lastIndex = colors.length - 1;\n const assignCount = Math.min(lastIndex, uniqueValues.length);\n\n // Assign first values one-to-one up to the penultimate color (if any)\n for (let i = 0; i < assignCount; i++) {\n // @ts-ignore tuple\n colorMap[i][0] = uniqueValues[i];\n }\n\n if (uniqueValues.length > colors.length) {\n // Aggregate the rest (including the value that would have gone to last color)\n // Build aggregated array incrementally to match legacy behavior\n const aggregatedValues: any[] = [];\n for (let i = lastIndex; i < uniqueValues.length; i++) {\n const value = uniqueValues[i];\n if (Array.isArray(value)) {\n // Spread array elements to match legacy flattening behavior\n aggregatedValues.push(...(value as any[]));\n } else {\n aggregatedValues.push(value);\n }\n }\n // @ts-ignore tuple\n colorMap[lastIndex][0] = aggregatedValues;\n } else if (uniqueValues.length === colors.length) {\n // Exactly one per color\n // @ts-ignore tuple\n colorMap[lastIndex][0] = uniqueValues[lastIndex];\n }\n\n // @ts-ignore tuple\n return colorMap;\n}\n\n/**\n * Get categorical colorBreaks from colorMap\n */\nexport function colorMapToCategoricalColorBreaks(\n colorMap?: ColorMap | null\n): ColorBreakOrdinal[] | null {\n if (!colorMap) {\n return null;\n }\n const colorBreaks = colorMap.map(([value, color]) => {\n return {\n data: color,\n label: value\n };\n });\n\n return colorBreaks;\n}\n\n/**\n * create categorical colorMap from colorBreaks\n */\nexport function colorBreaksToCategoricalColorMap(colorBreaks: ColorBreakOrdinal[]): ColorMap {\n // colorMap: [string | string[], hexstring]\n const colors = uniq(colorBreaks.map(cb => cb.data));\n const values = uniq(colorBreaks.map(cb => cb.label));\n\n return getCategoricalColorMap(colors, values);\n}\n\n/**\n * Convert color breaks UI input into colorRange.colorMap\n */\nexport function colorBreaksToColorMap(colorBreaks: ColorBreak[] | ColorBreakOrdinal[]): ColorMap {\n const colorMap = colorBreaks.map((colorBreak, i) => {\n // [value, hex]\n return [\n colorBreak.inputs\n ? i === colorBreaks.length - 1\n ? null // last\n : colorBreak.inputs[1]\n : colorBreak.label,\n colorBreak.data\n ];\n });\n\n // @ts-ignore tuple\n return colorMap;\n}\n\n/**\n * Convert colorRange.colorMap into color breaks UI input\n */\nexport function colorMapToColorBreaks(colorMap?: ColorMap | null): ColorBreak[] | null {\n if (!colorMap) {\n return null;\n }\n const colorBreaks = colorMap.map(([value, color], i) => {\n const range =\n i === 0\n ? // first\n [-Infinity, value]\n : // last\n i === colorMap.length - 1\n ? [colorMap[i - 1][0], Infinity]\n : // else\n [colorMap[i - 1][0], value];\n return {\n data: color,\n range,\n inputs: range,\n label:\n // first\n i === 0\n ? `Less than ${value}`\n : // last\n i === colorMap.length - 1\n ? `${colorMap[i - 1][0]} or more`\n : `${colorMap[i - 1][0]} to ${value}`\n };\n });\n\n // @ts-ignore implement conversion for ordinal\n return colorBreaks;\n}\n\n/**\n * Whether color breaks is for numeric field\n */\nexport function isNumericColorBreaks(colorBreaks: unknown): colorBreaks is ColorBreak[] {\n return Boolean(Array.isArray(colorBreaks) && colorBreaks.length && colorBreaks[0].inputs);\n}\n\n// return domainMin, domainMax, histogramMean\nexport function getHistogramDomain({\n aggregatedBins,\n columnStats,\n dataset,\n fieldValueAccessor\n}: {\n aggregatedBins?: Record<number, AggregatedBin>;\n columnStats?: FilterProps['columnStats'];\n dataset?: KeplerTable;\n fieldValueAccessor: (idx: unknown) => number;\n}) {\n let domainMin = Number.POSITIVE_INFINITY;\n let domainMax = Number.NEGATIVE_INFINITY;\n let nValid = 0;\n let domainSum = 0;\n\n if (aggregatedBins) {\n Object.values(aggregatedBins).forEach(bin => {\n const val = bin.value;\n if (isNumber(val)) {\n if (val < domainMin) domainMin = val;\n if (val > domainMax) domainMax = val;\n domainSum += val;\n nValid += 1;\n }\n });\n } else {\n if (columnStats && columnStats.quantiles && columnStats.mean) {\n // no need to recalcuate min/max/mean if its already in columnStats\n return [\n columnStats.quantiles[0].value,\n columnStats.quantiles[columnStats.quantiles.length - 1].value,\n columnStats.mean\n ];\n }\n if (dataset && fieldValueAccessor) {\n dataset.allIndexes.forEach(x => {\n const val = fieldValueAccessor(x);\n if (isNumber(val)) {\n if (val < domainMin) domainMin = val;\n if (val > domainMax) domainMax = val;\n domainSum += val;\n nValid += 1;\n }\n });\n }\n }\n const histogramMean = nValid > 0 ? domainSum / nValid : 0;\n return [nValid > 0 ? domainMin : 0, nValid > 0 ? domainMax : 0, histogramMean];\n}\n\nexport function resetCategoricalColorMapByIndex(colorMap: ColorMap, index: number): any {\n if (!colorMap) {\n return colorMap;\n }\n const newColorMap = colorMap.map((cm, i) => {\n if (i === index) {\n return [null, cm[1]];\n }\n return cm;\n });\n return newColorMap;\n}\n\n/**\n * select rest categorical values for a colorMap by its index\n */\nexport function selectRestCategoricalColorMapByIndex(\n colorMap: ColorMap | null,\n index: number,\n uniqueValues?: number[] | string[]\n): ColorMap | undefined | null {\n if (!colorMap || !uniqueValues) {\n return colorMap;\n }\n\n // find unique values that has not been used in current colorMap\n const uniqValueDict = Object.fromEntries(uniqueValues.map(val => [val, false]));\n colorMap.forEach(cm => {\n toArray(cm[0]).forEach(v => {\n if (notNullorUndefined(v)) uniqValueDict[v] = true;\n });\n });\n const rest = Object.keys(uniqValueDict).filter(v => !uniqValueDict[v]);\n\n // use the not used unique values in the selected color map\n const newColorMap = colorMap.map((cm, i) => {\n if (i === index) {\n return [[...rest, ...toArray(cm[0])], cm[1]];\n }\n return cm;\n }) as ColorMap;\n\n return newColorMap;\n}\n\n/**\n * remove a categorical value from a colorMap by its index\n */\nexport function removeCategoricalValueFromColorMap(\n colorMap: ColorMap | null | undefined,\n item: number | string,\n index: number\n): ColorMap | null | undefined {\n if (!colorMap) {\n return colorMap;\n }\n const newColorMap = colorMap.map((cm, i) => {\n if (i === index) {\n if (!notNullorUndefined(cm[0])) {\n return [null, cm[1]];\n }\n const currentUniqueValues = toArray(cm[0]);\n const updatedUniqueValues = currentUniqueValues.filter(v => v !== item);\n return [updatedUniqueValues, cm[1]];\n }\n return cm;\n }) as ColorMap;\n\n return newColorMap;\n}\n\n/**\n * add categorical values (from multisel dropdown) to a colorMap by its index\n */\nexport function addCategoricalValuesToColorMap(\n colorMap: ColorMap,\n items: (string | number)[],\n index: number\n): ColorMap {\n if (!colorMap) {\n return colorMap;\n }\n\n const newColorMap = colorMap.map((cm, i) => {\n if (i === index) {\n if (!notNullorUndefined(cm[0])) {\n return [items, cm[1]];\n }\n const currentUniqueValues = toArray(cm[0]);\n const updatedUniqueValues = uniq(currentUniqueValues.concat(items));\n return [updatedUniqueValues, cm[1]];\n }\n // remove value from other colorMap\n const currentUniqueValues = cm[0];\n if (Array.isArray(currentUniqueValues)) {\n const updatedUniqueValues: string[] | number[] = (currentUniqueValues as any[]).filter(\n v => !items.includes(v)\n );\n return [updatedUniqueValues, cm[1]];\n } else if (notNullorUndefined(currentUniqueValues) && items.includes(currentUniqueValues)) {\n return [null, cm[1]];\n }\n\n return cm;\n }) as ColorMap;\n\n return newColorMap;\n}\n\n/**\n * get a color scale func for categorical (custom ordinal) scale\n */\nexport function getCategoricalColorScale(\n colorDomain: number[] | string[],\n colorRange: ColorRange,\n useRgb = true\n): (categoryValue: string | number) => RGBColor | RGBAColor {\n const cMap = colorRange.colorMap\n ? colorRange.colorMap\n : getCategoricalColorMap(colorRange.colors, colorDomain);\n\n const range: number[][] = [];\n const domain: string[] = [];\n cMap.forEach(cm => {\n if (Array.isArray(cm[0])) {\n cm[0].forEach(val => {\n domain.push(val);\n range.push(useRgb ? hexToRgb(cm[1]) : cm[1]);\n });\n } else {\n domain.push(cm[0]);\n range.push(useRgb ? hexToRgb(cm[1]) : cm[1]);\n }\n });\n\n const scale = getScaleFunction(SCALE_TYPES.customOrdinal, range, domain, false);\n scale.unknown(NO_VALUE_COLOR);\n return scale as any;\n}\n\n/**\n * initialize customPalette by custom scale or customOrdinal scale\n */\nexport function initCustomPaletteByCustomScale({\n scale,\n field,\n ordinalDomain,\n range,\n colorBreaks\n}: {\n scale: string;\n field?: Field;\n ordinalDomain?: number[] | string[];\n range: ColorRange;\n colorBreaks: ColorBreakOrdinal[] | null;\n}): ColorUI['customPalette'] {\n const customPaletteName = `color.customPalette.${scale}.${field?.name || 'point-count'}`;\n // reuse range.colorMap if the field and scale not changed\n const reuseColorMap = range.colorMap && range.name === customPaletteName && range.type === scale;\n const colorMap = reuseColorMap\n ? range.colorMap\n : scale === SCALE_TYPES.customOrdinal && ordinalDomain\n ? getCategoricalColorMap(range.colors, ordinalDomain)\n : colorBreaks && isNumericColorBreaks(colorBreaks)\n ? colorBreaksToColorMap(colorBreaks)\n : null;\n const colors = reuseColorMap ? range.colors : colorMap ? colorMap.map(cm => cm[1]) : range.colors;\n\n // update custom breaks\n const customPalette: ColorUI['customPalette'] = {\n category: 'Custom',\n name: customPaletteName,\n type: scale,\n colorMap,\n colors: colors || []\n };\n\n return customPalette;\n}\n"],"mappings":";;;;;AAAA;AACA;;AAEA,SAAQA,UAAU,EAAEC,cAAc,IAAIC,UAAU,EAAEC,MAAM,QAAO,UAAU;AACzE,OAAOC,IAAI,MAAM,wBAAwB;AACzC,OAAOC,MAAM,MAAM,QAAQ;AAE3B,SAAQC,kBAAkB,EAAEC,OAAO,QAAO,yBAAyB;AACnE,SAAQC,eAAe,EAAEC,UAAU,EAAEC,WAAW,EAAEC,cAAc,QAAO,sBAAsB;AAC7F;;AAgBA,SAAQC,UAAU,EAAEC,QAAQ,EAAEC,QAAQ,QAAO,eAAe;AAE5D,SAAQC,YAAY,EAAEC,QAAQ,EAAEC,mBAAmB,EAAEC,MAAM,QAAO,cAAc;AAChF,SAAQC,0BAA0B,QAAO,gBAAgB;AACzD,OAAOC,aAAa,MAAM,SAAS;AACnC,SAAQC,aAAa,QAAO,SAAS;;AAerC;;AAQA;AACA;AACA;AACA,OAAO,SAASC,iBAAiBA,CAC/BC,IAAW,EACXC,aAAiC,EACjCC,QAAe,EACL;EAC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/esm/data-utils.js
CHANGED
|
@@ -8,6 +8,7 @@ var _FIELD_DISPLAY_FORMAT;
|
|
|
8
8
|
import assert from 'assert';
|
|
9
9
|
import { format as d3Format } from 'd3-format';
|
|
10
10
|
import moment from 'moment-timezone';
|
|
11
|
+
import { StructRow } from 'apache-arrow';
|
|
11
12
|
import { convertGeoArrowGeometryToGeoJSON } from '@loaders.gl/gis';
|
|
12
13
|
import { ALL_FIELD_TYPES, TOOLTIP_FORMATS, TOOLTIP_FORMAT_TYPES, TOOLTIP_KEY } from '@kepler.gl/constants';
|
|
13
14
|
import { notNullorUndefined } from '@kepler.gl/common-utils';
|
|
@@ -272,10 +273,23 @@ export function uint8ArrayToHex(data) {
|
|
|
272
273
|
export var FIELD_DISPLAY_FORMAT = (_FIELD_DISPLAY_FORMAT = {}, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_FIELD_DISPLAY_FORMAT, ALL_FIELD_TYPES.string, defaultFormatter), ALL_FIELD_TYPES.timestamp, defaultFormatter), ALL_FIELD_TYPES.integer, defaultFormatter), ALL_FIELD_TYPES.real, defaultFormatter), ALL_FIELD_TYPES["boolean"], defaultFormatter), ALL_FIELD_TYPES.date, defaultFormatter), ALL_FIELD_TYPES.geojson, function (d) {
|
|
273
274
|
return typeof d === 'string' ? d : isPlainObject(d) ? JSON.stringify(d) : Array.isArray(d) ? "[".concat(String(d), "]") : '';
|
|
274
275
|
}), ALL_FIELD_TYPES.geoarrow, function (data, field) {
|
|
276
|
+
var _field$metadata;
|
|
277
|
+
if (data instanceof StructRow && (field === null || field === void 0 || (_field$metadata = field.metadata) === null || _field$metadata === void 0 ? void 0 : _field$metadata.get('ARROW:extension:name')) === 'geoarrow.point') {
|
|
278
|
+
var _data$toJSON = data.toJSON(),
|
|
279
|
+
x = _data$toJSON.x,
|
|
280
|
+
y = _data$toJSON.y,
|
|
281
|
+
z = _data$toJSON.z;
|
|
282
|
+
var coordinates = [x, y];
|
|
283
|
+
if (z != null) coordinates.push(z);
|
|
284
|
+
return JSON.stringify({
|
|
285
|
+
type: 'Point',
|
|
286
|
+
coordinates: coordinates
|
|
287
|
+
});
|
|
288
|
+
}
|
|
275
289
|
if (isArrowVector(data)) {
|
|
276
290
|
try {
|
|
277
|
-
var _field$
|
|
278
|
-
var encoding = field === null || field === void 0 || (_field$
|
|
291
|
+
var _field$metadata2;
|
|
292
|
+
var encoding = field === null || field === void 0 || (_field$metadata2 = field.metadata) === null || _field$metadata2 === void 0 ? void 0 : _field$metadata2.get('ARROW:extension:name');
|
|
279
293
|
if (encoding) {
|
|
280
294
|
var geometry = convertGeoArrowGeometryToGeoJSON(data, encoding);
|
|
281
295
|
return JSON.stringify(geometry);
|