@m4l/gclick 0.3.0 → 0.3.1-beta.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/components/Device/slots/DeviceSlots.d.ts +2 -2
- package/components/DeviceLabel/slots/DeviceLabelSlots.d.ts +1 -1
- package/components/VideoTimeLineSelector/slots/VideoTimeLineSelectorSlots.d.ts +2 -2
- package/components/indicators/IndicatorBattery/slots/IndicatorBaterySlots.d.ts +1 -1
- package/components/indicators/IndicatorCSQ/slots/IndicatorCSQSlots.d.ts +1 -1
- package/components/indicators/IndicatorValueAndMagnitude/slots/styled.d.ts +2 -2
- package/components/indicators/IndicatorValueStatus/slots/IndicatorValueStatusSlots.d.ts +1 -1
- package/components/maps/components/GpsMap/contexts/MapContext/index.d.ts +1 -1
- package/components/maps/components/GpsMap/contexts/MapContext/store.js +13 -1
- package/components/maps/components/GpsMap/contexts/MapContext/types.d.ts +54 -1
- package/components/maps/components/GpsMap/hooks/index.d.ts +4 -0
- package/components/maps/components/GpsMap/hooks/useAutoFocus/index.js +3 -2
- package/components/maps/components/GpsMap/hooks/useZoomBasedMarkerFilter/GridDebugVisualization.d.ts +9 -0
- package/components/maps/components/GpsMap/hooks/useZoomBasedMarkerFilter/constants.d.ts +5 -0
- package/components/maps/components/GpsMap/hooks/useZoomBasedMarkerFilter/constants.js +12 -0
- package/components/maps/components/GpsMap/hooks/useZoomBasedMarkerFilter/createPixelPathDecimationFilter/helpers/decimateByConcentrationGrid.d.ts +13 -0
- package/components/maps/components/GpsMap/hooks/useZoomBasedMarkerFilter/createPixelPathDecimationFilter/helpers/decimateByConcentrationGrid.js +57 -0
- package/components/maps/components/GpsMap/hooks/useZoomBasedMarkerFilter/createPixelPathDecimationFilter/helpers/decimateByPixelDistanceAlongPath.d.ts +14 -0
- package/components/maps/components/GpsMap/hooks/useZoomBasedMarkerFilter/createPixelPathDecimationFilter/helpers/decimateByPixelDistanceAlongPath.js +24 -0
- package/components/maps/components/GpsMap/hooks/useZoomBasedMarkerFilter/createPixelPathDecimationFilter/helpers/index.d.ts +2 -0
- package/components/maps/components/GpsMap/hooks/useZoomBasedMarkerFilter/createPixelPathDecimationFilter/helpers/index.js +1 -0
- package/components/maps/components/GpsMap/hooks/useZoomBasedMarkerFilter/createPixelPathDecimationFilter/index.d.ts +64 -0
- package/components/maps/components/GpsMap/hooks/useZoomBasedMarkerFilter/createPixelPathDecimationFilter/index.js +117 -0
- package/components/maps/components/GpsMap/hooks/useZoomBasedMarkerFilter/createPixelPathDecimationFilter/types.d.ts +41 -0
- package/components/maps/components/GpsMap/hooks/useZoomBasedMarkerFilter/kdbush.d.ts +15 -0
- package/components/maps/components/GpsMap/hooks/useZoomBasedMarkerFilter/rbush.d.ts +19 -0
- package/components/maps/components/GpsMap/hooks/useZoomBasedMarkerFilter/types.d.ts +83 -0
- package/components/maps/components/GpsMap/hooks/useZoomBasedMarkerFilter/useFilterDecimation.d.ts +11 -0
- package/components/maps/components/GpsMap/hooks/useZoomBasedMarkerFilter/useFilterDecimation.js +112 -0
- package/components/maps/components/GpsMap/hooks/useZoomBasedMarkerFilter/useGridDebug.d.ts +5 -0
- package/components/maps/components/GpsMap/popups/MapPopupDevice/slots/MapPopupDeviceSlots.d.ts +3 -3
- package/components/maps/components/GpsMap/slots/styled.d.ts +1 -1
- package/components/maps/components/GpsMap/subcomponents/Controls/subcomponents/ButtonsToolsList/subcomponents/MapSourcesTool/slots/styled.d.ts +1 -1
- package/components/maps/components/GpsMap/subcomponents/Controls/subcomponents/ButtonsToolsList/subcomponents/MeasureTool/slots/styled.d.ts +2 -2
- package/components/maps/components/GpsMap/subcomponents/Layers/subcomponents/Layer/index.js +25 -3
- package/formatters/CourseFormatter/slots/CourseFormatterSlots.d.ts +1 -1
- package/index.js +20 -16
- package/not_recognized/index.js +241 -0
- package/package.json +18 -2
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
const ARRAY_TYPES = [
|
|
2
|
+
Int8Array,
|
|
3
|
+
Uint8Array,
|
|
4
|
+
Uint8ClampedArray,
|
|
5
|
+
Int16Array,
|
|
6
|
+
Uint16Array,
|
|
7
|
+
Int32Array,
|
|
8
|
+
Uint32Array,
|
|
9
|
+
Float32Array,
|
|
10
|
+
Float64Array
|
|
11
|
+
];
|
|
12
|
+
const VERSION = 1;
|
|
13
|
+
const HEADER_SIZE = 8;
|
|
14
|
+
class KDBush {
|
|
15
|
+
/**
|
|
16
|
+
* Creates an index from raw `ArrayBuffer` data.
|
|
17
|
+
* @param {ArrayBuffer} data
|
|
18
|
+
*/
|
|
19
|
+
static from(data) {
|
|
20
|
+
if (!(data instanceof ArrayBuffer)) {
|
|
21
|
+
throw new Error("Data must be an instance of ArrayBuffer.");
|
|
22
|
+
}
|
|
23
|
+
const [magic, versionAndType] = new Uint8Array(data, 0, 2);
|
|
24
|
+
if (magic !== 219) {
|
|
25
|
+
throw new Error("Data does not appear to be in a KDBush format.");
|
|
26
|
+
}
|
|
27
|
+
const version = versionAndType >> 4;
|
|
28
|
+
if (version !== VERSION) {
|
|
29
|
+
throw new Error(`Got v${version} data when expected v${VERSION}.`);
|
|
30
|
+
}
|
|
31
|
+
const ArrayType = ARRAY_TYPES[versionAndType & 15];
|
|
32
|
+
if (!ArrayType) {
|
|
33
|
+
throw new Error("Unrecognized array type.");
|
|
34
|
+
}
|
|
35
|
+
const [nodeSize] = new Uint16Array(data, 2, 1);
|
|
36
|
+
const [numItems] = new Uint32Array(data, 4, 1);
|
|
37
|
+
return new KDBush(numItems, nodeSize, ArrayType, data);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Creates an index that will hold a given number of items.
|
|
41
|
+
* @param {number} numItems
|
|
42
|
+
* @param {number} [nodeSize=64] Size of the KD-tree node (64 by default).
|
|
43
|
+
* @param {TypedArrayConstructor} [ArrayType=Float64Array] The array type used for coordinates storage (`Float64Array` by default).
|
|
44
|
+
* @param {ArrayBuffer} [data] (For internal use only)
|
|
45
|
+
*/
|
|
46
|
+
constructor(numItems, nodeSize = 64, ArrayType = Float64Array, data) {
|
|
47
|
+
if (isNaN(numItems) || numItems < 0) throw new Error(`Unpexpected numItems value: ${numItems}.`);
|
|
48
|
+
this.numItems = +numItems;
|
|
49
|
+
this.nodeSize = Math.min(Math.max(+nodeSize, 2), 65535);
|
|
50
|
+
this.ArrayType = ArrayType;
|
|
51
|
+
this.IndexArrayType = numItems < 65536 ? Uint16Array : Uint32Array;
|
|
52
|
+
const arrayTypeIndex = ARRAY_TYPES.indexOf(this.ArrayType);
|
|
53
|
+
const coordsByteSize = numItems * 2 * this.ArrayType.BYTES_PER_ELEMENT;
|
|
54
|
+
const idsByteSize = numItems * this.IndexArrayType.BYTES_PER_ELEMENT;
|
|
55
|
+
const padCoords = (8 - idsByteSize % 8) % 8;
|
|
56
|
+
if (arrayTypeIndex < 0) {
|
|
57
|
+
throw new Error(`Unexpected typed array class: ${ArrayType}.`);
|
|
58
|
+
}
|
|
59
|
+
if (data && data instanceof ArrayBuffer) {
|
|
60
|
+
this.data = data;
|
|
61
|
+
this.ids = new this.IndexArrayType(this.data, HEADER_SIZE, numItems);
|
|
62
|
+
this.coords = new this.ArrayType(this.data, HEADER_SIZE + idsByteSize + padCoords, numItems * 2);
|
|
63
|
+
this._pos = numItems * 2;
|
|
64
|
+
this._finished = true;
|
|
65
|
+
} else {
|
|
66
|
+
this.data = new ArrayBuffer(HEADER_SIZE + coordsByteSize + idsByteSize + padCoords);
|
|
67
|
+
this.ids = new this.IndexArrayType(this.data, HEADER_SIZE, numItems);
|
|
68
|
+
this.coords = new this.ArrayType(this.data, HEADER_SIZE + idsByteSize + padCoords, numItems * 2);
|
|
69
|
+
this._pos = 0;
|
|
70
|
+
this._finished = false;
|
|
71
|
+
new Uint8Array(this.data, 0, 2).set([219, (VERSION << 4) + arrayTypeIndex]);
|
|
72
|
+
new Uint16Array(this.data, 2, 1)[0] = nodeSize;
|
|
73
|
+
new Uint32Array(this.data, 4, 1)[0] = numItems;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Add a point to the index.
|
|
78
|
+
* @param {number} x
|
|
79
|
+
* @param {number} y
|
|
80
|
+
* @returns {number} An incremental index associated with the added item (starting from `0`).
|
|
81
|
+
*/
|
|
82
|
+
add(x, y) {
|
|
83
|
+
const index = this._pos >> 1;
|
|
84
|
+
this.ids[index] = index;
|
|
85
|
+
this.coords[this._pos++] = x;
|
|
86
|
+
this.coords[this._pos++] = y;
|
|
87
|
+
return index;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Perform indexing of the added points.
|
|
91
|
+
*/
|
|
92
|
+
finish() {
|
|
93
|
+
const numAdded = this._pos >> 1;
|
|
94
|
+
if (numAdded !== this.numItems) {
|
|
95
|
+
throw new Error(`Added ${numAdded} items when expected ${this.numItems}.`);
|
|
96
|
+
}
|
|
97
|
+
sort(this.ids, this.coords, this.nodeSize, 0, this.numItems - 1, 0);
|
|
98
|
+
this._finished = true;
|
|
99
|
+
return this;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Search the index for items within a given bounding box.
|
|
103
|
+
* @param {number} minX
|
|
104
|
+
* @param {number} minY
|
|
105
|
+
* @param {number} maxX
|
|
106
|
+
* @param {number} maxY
|
|
107
|
+
* @returns {number[]} An array of indices correponding to the found items.
|
|
108
|
+
*/
|
|
109
|
+
range(minX, minY, maxX, maxY) {
|
|
110
|
+
if (!this._finished) throw new Error("Data not yet indexed - call index.finish().");
|
|
111
|
+
const { ids, coords, nodeSize } = this;
|
|
112
|
+
const stack = [0, ids.length - 1, 0];
|
|
113
|
+
const result = [];
|
|
114
|
+
while (stack.length) {
|
|
115
|
+
const axis = stack.pop() || 0;
|
|
116
|
+
const right = stack.pop() || 0;
|
|
117
|
+
const left = stack.pop() || 0;
|
|
118
|
+
if (right - left <= nodeSize) {
|
|
119
|
+
for (let i = left; i <= right; i++) {
|
|
120
|
+
const x2 = coords[2 * i];
|
|
121
|
+
const y2 = coords[2 * i + 1];
|
|
122
|
+
if (x2 >= minX && x2 <= maxX && y2 >= minY && y2 <= maxY) result.push(ids[i]);
|
|
123
|
+
}
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
126
|
+
const m = left + right >> 1;
|
|
127
|
+
const x = coords[2 * m];
|
|
128
|
+
const y = coords[2 * m + 1];
|
|
129
|
+
if (x >= minX && x <= maxX && y >= minY && y <= maxY) result.push(ids[m]);
|
|
130
|
+
if (axis === 0 ? minX <= x : minY <= y) {
|
|
131
|
+
stack.push(left);
|
|
132
|
+
stack.push(m - 1);
|
|
133
|
+
stack.push(1 - axis);
|
|
134
|
+
}
|
|
135
|
+
if (axis === 0 ? maxX >= x : maxY >= y) {
|
|
136
|
+
stack.push(m + 1);
|
|
137
|
+
stack.push(right);
|
|
138
|
+
stack.push(1 - axis);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return result;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Search the index for items within a given radius.
|
|
145
|
+
* @param {number} qx
|
|
146
|
+
* @param {number} qy
|
|
147
|
+
* @param {number} r Query radius.
|
|
148
|
+
* @returns {number[]} An array of indices correponding to the found items.
|
|
149
|
+
*/
|
|
150
|
+
within(qx, qy, r) {
|
|
151
|
+
if (!this._finished) throw new Error("Data not yet indexed - call index.finish().");
|
|
152
|
+
const { ids, coords, nodeSize } = this;
|
|
153
|
+
const stack = [0, ids.length - 1, 0];
|
|
154
|
+
const result = [];
|
|
155
|
+
const r2 = r * r;
|
|
156
|
+
while (stack.length) {
|
|
157
|
+
const axis = stack.pop() || 0;
|
|
158
|
+
const right = stack.pop() || 0;
|
|
159
|
+
const left = stack.pop() || 0;
|
|
160
|
+
if (right - left <= nodeSize) {
|
|
161
|
+
for (let i = left; i <= right; i++) {
|
|
162
|
+
if (sqDist(coords[2 * i], coords[2 * i + 1], qx, qy) <= r2) result.push(ids[i]);
|
|
163
|
+
}
|
|
164
|
+
continue;
|
|
165
|
+
}
|
|
166
|
+
const m = left + right >> 1;
|
|
167
|
+
const x = coords[2 * m];
|
|
168
|
+
const y = coords[2 * m + 1];
|
|
169
|
+
if (sqDist(x, y, qx, qy) <= r2) result.push(ids[m]);
|
|
170
|
+
if (axis === 0 ? qx - r <= x : qy - r <= y) {
|
|
171
|
+
stack.push(left);
|
|
172
|
+
stack.push(m - 1);
|
|
173
|
+
stack.push(1 - axis);
|
|
174
|
+
}
|
|
175
|
+
if (axis === 0 ? qx + r >= x : qy + r >= y) {
|
|
176
|
+
stack.push(m + 1);
|
|
177
|
+
stack.push(right);
|
|
178
|
+
stack.push(1 - axis);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
return result;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
function sort(ids, coords, nodeSize, left, right, axis) {
|
|
185
|
+
if (right - left <= nodeSize) return;
|
|
186
|
+
const m = left + right >> 1;
|
|
187
|
+
select(ids, coords, m, left, right, axis);
|
|
188
|
+
sort(ids, coords, nodeSize, left, m - 1, 1 - axis);
|
|
189
|
+
sort(ids, coords, nodeSize, m + 1, right, 1 - axis);
|
|
190
|
+
}
|
|
191
|
+
function select(ids, coords, k, left, right, axis) {
|
|
192
|
+
while (right > left) {
|
|
193
|
+
if (right - left > 600) {
|
|
194
|
+
const n = right - left + 1;
|
|
195
|
+
const m = k - left + 1;
|
|
196
|
+
const z = Math.log(n);
|
|
197
|
+
const s = 0.5 * Math.exp(2 * z / 3);
|
|
198
|
+
const sd = 0.5 * Math.sqrt(z * s * (n - s) / n) * (m - n / 2 < 0 ? -1 : 1);
|
|
199
|
+
const newLeft = Math.max(left, Math.floor(k - m * s / n + sd));
|
|
200
|
+
const newRight = Math.min(right, Math.floor(k + (n - m) * s / n + sd));
|
|
201
|
+
select(ids, coords, k, newLeft, newRight, axis);
|
|
202
|
+
}
|
|
203
|
+
const t = coords[2 * k + axis];
|
|
204
|
+
let i = left;
|
|
205
|
+
let j = right;
|
|
206
|
+
swapItem(ids, coords, left, k);
|
|
207
|
+
if (coords[2 * right + axis] > t) swapItem(ids, coords, left, right);
|
|
208
|
+
while (i < j) {
|
|
209
|
+
swapItem(ids, coords, i, j);
|
|
210
|
+
i++;
|
|
211
|
+
j--;
|
|
212
|
+
while (coords[2 * i + axis] < t) i++;
|
|
213
|
+
while (coords[2 * j + axis] > t) j--;
|
|
214
|
+
}
|
|
215
|
+
if (coords[2 * left + axis] === t) swapItem(ids, coords, left, j);
|
|
216
|
+
else {
|
|
217
|
+
j++;
|
|
218
|
+
swapItem(ids, coords, j, right);
|
|
219
|
+
}
|
|
220
|
+
if (j <= k) left = j + 1;
|
|
221
|
+
if (k <= j) right = j - 1;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
function swapItem(ids, coords, i, j) {
|
|
225
|
+
swap(ids, i, j);
|
|
226
|
+
swap(coords, 2 * i, 2 * j);
|
|
227
|
+
swap(coords, 2 * i + 1, 2 * j + 1);
|
|
228
|
+
}
|
|
229
|
+
function swap(arr, i, j) {
|
|
230
|
+
const tmp = arr[i];
|
|
231
|
+
arr[i] = arr[j];
|
|
232
|
+
arr[j] = tmp;
|
|
233
|
+
}
|
|
234
|
+
function sqDist(ax, ay, bx, by) {
|
|
235
|
+
const dx = ax - bx;
|
|
236
|
+
const dy = ay - by;
|
|
237
|
+
return dx * dx + dy * dy;
|
|
238
|
+
}
|
|
239
|
+
export {
|
|
240
|
+
KDBush as K
|
|
241
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@m4l/gclick",
|
|
3
|
-
"version": "0.3.0",
|
|
3
|
+
"version": "0.3.1-beta.0",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"lint-staged": {
|
|
6
6
|
"*.{js,ts,tsx}": "eslint --fix --max-warnings 0 --no-warn-ignored"
|
|
@@ -15,7 +15,23 @@
|
|
|
15
15
|
"@mui/system": "5.16.7",
|
|
16
16
|
"@mui/x-charts": "8.10.2",
|
|
17
17
|
"@mui/x-date-pickers": "6.20.2",
|
|
18
|
-
"lodash-es": "4.17.
|
|
18
|
+
"@types/lodash-es": "^4.17.12",
|
|
19
|
+
"atmosphere.js": "^4.0.0",
|
|
20
|
+
"chart.js": "^4.4.0",
|
|
21
|
+
"chartjs-chart-error-bars": "^4.3.3",
|
|
22
|
+
"eventemitter3": "^4.0.7",
|
|
23
|
+
"fast-equals": "^5.0.1",
|
|
24
|
+
"history": "5.3.0",
|
|
25
|
+
"install": "^0.13.0",
|
|
26
|
+
"jwt-decode": "^4.0.0",
|
|
27
|
+
"kdbush": "^4.0.2",
|
|
28
|
+
"leaflet": "^1.9.4",
|
|
29
|
+
"leaflet-polylinedecorator": "^1.6.0",
|
|
30
|
+
"leaflet.markercluster": "^1.5.3",
|
|
31
|
+
"lodash-es": "^4.17.21",
|
|
32
|
+
"nprogress": "^0.2.0",
|
|
33
|
+
"qrcode.react": "^3.1.0",
|
|
34
|
+
"rbush": "^4.0.1",
|
|
19
35
|
"react": "18.3.1",
|
|
20
36
|
"react-dom": "18.3.1",
|
|
21
37
|
"react-leaflet": "^4.2.1"
|