@artstesh/maps 11.0.0 → 11.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/fesm2022/maps-components-src-map.mjs +150 -2
- package/dist/fesm2022/maps-components-src-map.mjs.map +1 -1
- package/dist/fesm2022/maps-components.mjs +150 -2
- package/dist/fesm2022/maps-components.mjs.map +1 -1
- package/dist/package.json +2 -2
- package/dist/types/maps-components-src-map.d.ts +109 -2
- package/dist/types/maps-components.d.ts +109 -2
- package/package.json +18 -8
|
@@ -16,7 +16,6 @@ import { Draw, Modify, Translate, defaults } from 'ol/interaction';
|
|
|
16
16
|
import { createRegularPolygon, createBox } from 'ol/interaction/Draw';
|
|
17
17
|
import { Subject, combineLatest } from 'rxjs';
|
|
18
18
|
import { first, debounceTime, filter, auditTime } from 'rxjs/operators';
|
|
19
|
-
import { Dictionary } from '@artstesh/collections';
|
|
20
19
|
import { Vector, XYZ, GeoTIFF } from 'ol/source';
|
|
21
20
|
import TileLayer from 'ol/layer/Tile';
|
|
22
21
|
import OSM from 'ol/source/OSM';
|
|
@@ -310,6 +309,155 @@ class MapControl extends Control {
|
|
|
310
309
|
}
|
|
311
310
|
}
|
|
312
311
|
|
|
312
|
+
/**
|
|
313
|
+
* A generic class representing a dictionary structure with key-value pairs.
|
|
314
|
+
* Provides utilities for adding, updating, removing, and iterating over elements.
|
|
315
|
+
*
|
|
316
|
+
* @template T The type of values in the dictionary.
|
|
317
|
+
*/
|
|
318
|
+
class Dictionary {
|
|
319
|
+
collection = {};
|
|
320
|
+
_keys = new Set();
|
|
321
|
+
/**
|
|
322
|
+
* Creates a shallow copy of the given dictionary, optionally applying
|
|
323
|
+
* a transformation function to each element during the cloning process.
|
|
324
|
+
*
|
|
325
|
+
* @param {Dictionary<T>} dic - The dictionary to be cloned.
|
|
326
|
+
* @param {(e: T, k: string) => T} [action] - An optional transformation function
|
|
327
|
+
* that is called for each element. The function takes the element value and
|
|
328
|
+
* its key as arguments and returns the modified value.
|
|
329
|
+
* @return {Dictionary<T>} A new dictionary that is a clone of the input dictionary
|
|
330
|
+
* with transformations applied if the action function is provided.
|
|
331
|
+
*/
|
|
332
|
+
static clone(dic, action) {
|
|
333
|
+
return Dictionary.create(dic.collection, action);
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* Creates a Dictionary instance from the given array of elements.
|
|
337
|
+
*
|
|
338
|
+
* @param {T[]} list - An array of elements to be converted into a Dictionary.
|
|
339
|
+
* @param {(e: T) => string} id - A function that produces a unique identifier for each element in the array.
|
|
340
|
+
* @return {Dictionary<T>} A Dictionary where the keys are unique identifiers derived from the elements of the array, and the values are the corresponding elements.
|
|
341
|
+
*/
|
|
342
|
+
static fromList(list, id) {
|
|
343
|
+
const result = new Dictionary();
|
|
344
|
+
list.forEach((e) => result.put(id(e), e));
|
|
345
|
+
return result;
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* Creates a new Dictionary instance from a given Record, optionally applying an action to each element.
|
|
349
|
+
*
|
|
350
|
+
* @param {Record<string, T>} dic The input dictionary object.
|
|
351
|
+
* @param {(e: T, k: string) => T} [action] An optional callback function to transform each element.
|
|
352
|
+
* The function receives the value and key of each element.
|
|
353
|
+
* @return {Dictionary<T>} A new Dictionary instance populated with the elements from the input dictionary,
|
|
354
|
+
* potentially transformed by the action callback if provided.
|
|
355
|
+
*/
|
|
356
|
+
static create(dic, action) {
|
|
357
|
+
const result = new Dictionary();
|
|
358
|
+
Object.entries(dic).forEach(([key, value]) => {
|
|
359
|
+
result.put(key, action ? action(value, key) : value);
|
|
360
|
+
});
|
|
361
|
+
return result;
|
|
362
|
+
}
|
|
363
|
+
/**
|
|
364
|
+
* Retrieves all the keys as an array of strings from the internal data structure.
|
|
365
|
+
*
|
|
366
|
+
* @return {string[]} An array containing the keys.
|
|
367
|
+
*/
|
|
368
|
+
get keys() {
|
|
369
|
+
return Array.from(this._keys);
|
|
370
|
+
}
|
|
371
|
+
/**
|
|
372
|
+
* Retrieves the number of key-value pairs currently stored.
|
|
373
|
+
*
|
|
374
|
+
* @return {number} The current size of the collection.
|
|
375
|
+
*/
|
|
376
|
+
get size() {
|
|
377
|
+
return this._keys.size;
|
|
378
|
+
}
|
|
379
|
+
/**
|
|
380
|
+
* Finds and returns the first element in the collection that satisfies the provided predicate function.
|
|
381
|
+
*
|
|
382
|
+
* @param {function(T): boolean} predicate - A function used to test each element of the collection. Returns `true` to select the element, `false` otherwise.
|
|
383
|
+
* @return {T | null} The first element in the collection that satisfies the predicate, or `null` if no such element is found.
|
|
384
|
+
*/
|
|
385
|
+
find(predicate) {
|
|
386
|
+
let result = null;
|
|
387
|
+
this.forEach((e) => {
|
|
388
|
+
if (result === null && predicate(e))
|
|
389
|
+
result = e;
|
|
390
|
+
});
|
|
391
|
+
return result;
|
|
392
|
+
}
|
|
393
|
+
/**
|
|
394
|
+
* Checks if a given key exists within the dictionary.
|
|
395
|
+
*
|
|
396
|
+
* @param {string} key - The key to check for existence in the collection.
|
|
397
|
+
* @returns {boolean} True if the key exists, false otherwise.
|
|
398
|
+
*/
|
|
399
|
+
has = (key) => this._keys.has(key);
|
|
400
|
+
/**
|
|
401
|
+
* Retrieves the value associated with the specified key from the collection if it exists.
|
|
402
|
+
*
|
|
403
|
+
* @param {string} key - The key whose associated value is to be retrieved.
|
|
404
|
+
* @return {T | null} The value associated with the specified key, or null if the key does not exist.
|
|
405
|
+
*/
|
|
406
|
+
take(key) {
|
|
407
|
+
return this._keys.has(key) ? this.collection[key] : null;
|
|
408
|
+
}
|
|
409
|
+
/**
|
|
410
|
+
* Adds or updates a value associated with the specified key in the collection.
|
|
411
|
+
* If the value is null or undefined, removes the key from the collection.
|
|
412
|
+
*
|
|
413
|
+
* @param {string} key - The key to associate with the value in the collection.
|
|
414
|
+
* @param {T | null} [value] - The value to store in the collection. If null or undefined, the key will be removed.
|
|
415
|
+
* @return {void} Does not return a value.
|
|
416
|
+
*/
|
|
417
|
+
put(key, value) {
|
|
418
|
+
if (value == null)
|
|
419
|
+
return this.rmv(key);
|
|
420
|
+
this.collection[key] = value;
|
|
421
|
+
this._keys.add(key);
|
|
422
|
+
}
|
|
423
|
+
/**
|
|
424
|
+
* Removes a specified key and its associated value from the collection.
|
|
425
|
+
*
|
|
426
|
+
* @param {string} key - The key to be removed from the collection.
|
|
427
|
+
* @return {void} Does not return a value.
|
|
428
|
+
*/
|
|
429
|
+
rmv(key) {
|
|
430
|
+
if (!this._keys.has(key))
|
|
431
|
+
return;
|
|
432
|
+
delete this.collection[key];
|
|
433
|
+
this._keys.delete(key);
|
|
434
|
+
}
|
|
435
|
+
/**
|
|
436
|
+
* Adds a new entry or updates an existing entry in the collection based on the provided key.
|
|
437
|
+
* If the key already exists, it fetches the current value, applies the action, and replaces the value.
|
|
438
|
+
* If the key does not exist, it uses the action to create a new value and adds it.
|
|
439
|
+
*
|
|
440
|
+
* @param {string} key - The key associated with the value to add or update.
|
|
441
|
+
* @param {(current: T | null) => T} action - A function that takes the current value (if any) and returns the new value to be stored.
|
|
442
|
+
* @return {void} - Does not return a value.
|
|
443
|
+
*/
|
|
444
|
+
addOrUpdate(key, action) {
|
|
445
|
+
this.put(key, action(this.take(key)));
|
|
446
|
+
}
|
|
447
|
+
/**
|
|
448
|
+
* Iterates over each element in the collection and executes the provided callback function.
|
|
449
|
+
*
|
|
450
|
+
* @param {function(T, number): void} callback - A function that is called for each element of the collection.
|
|
451
|
+
* It takes two arguments: the current element's value and the index.
|
|
452
|
+
* @return {void} This method does not return a value.
|
|
453
|
+
*/
|
|
454
|
+
forEach(callback) {
|
|
455
|
+
Array.from(this._keys).forEach((key, index) => {
|
|
456
|
+
callback(this.collection[key], index);
|
|
457
|
+
});
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
|
|
313
461
|
class DestructibleComponent {
|
|
314
462
|
subs = [];
|
|
315
463
|
onDestroy;
|
|
@@ -3798,5 +3946,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.6", ngImpor
|
|
|
3798
3946
|
* Generated bundle index. Do not edit.
|
|
3799
3947
|
*/
|
|
3800
3948
|
|
|
3801
|
-
export { AddControlCommand, CalculateAreaExecutor, CancelDrawingCommand, CancelFeatureModificationCommand, CloseTooltipCommand, ClusterLayerComponent, ClusterLayerSettings, DrawSelectionAreaCommand, DrawingType, FeatureLayerComponent, FeatureLayerSettings, FeatureOutputFormat, FilterFeaturesInAreaExecutor, FilterFeaturesInPointExecutor, FitToFeaturesCommand, FitToPolygonsCommand, GeotiffTileLayerComponent, GeotiffTileLayerSettings, GetFeaturesInAreaQuery, GetFeaturesInPointQuery, GetGeometryLengthExecutor, GetMapPositionExecutor, ImageLayerComponent, ImageLayerSettings, MapClickEvent, MapConstants, MapControl, MapControlZoomComponent, MapFeatureHoveredEvent, MapLyrs, MapLyrsLabel, MapMoveEndEvent, MapPlateComponent, MapPointerMoveEvent, MapPostboyService, MapRenderedEvent, MapSettings, MarkerModel, MarkerStyleHelper, MarkersComponent, MessageRegistratorService, ModifyFeatureCommand, OsmTileLayerComponent, PolygonModel, PolygonSelfIntersectionExecutor, PolygonStyleHelper, PolygonsComponent, RasterTileLayerComponent, RasterTileLayerSettings, RemoveControlCommand, SetMapCenterCommand, StartDrawingCommand, StringifyFeatureHelper, TextStyleHelper, TileLayerComponent, TileLayerSettings, TooltipComponent, TooltipSettings, ZoomControlSettings };
|
|
3949
|
+
export { AddControlCommand, CalculateAreaExecutor, CancelDrawingCommand, CancelFeatureModificationCommand, CloseTooltipCommand, ClusterLayerComponent, ClusterLayerSettings, Dictionary, DrawSelectionAreaCommand, DrawingType, FeatureLayerComponent, FeatureLayerSettings, FeatureOutputFormat, FilterFeaturesInAreaExecutor, FilterFeaturesInPointExecutor, FitToFeaturesCommand, FitToPolygonsCommand, GeotiffTileLayerComponent, GeotiffTileLayerSettings, GetFeaturesInAreaQuery, GetFeaturesInPointQuery, GetGeometryLengthExecutor, GetMapPositionExecutor, ImageLayerComponent, ImageLayerSettings, MapClickEvent, MapConstants, MapControl, MapControlZoomComponent, MapFeatureHoveredEvent, MapLyrs, MapLyrsLabel, MapMoveEndEvent, MapPlateComponent, MapPointerMoveEvent, MapPostboyService, MapRenderedEvent, MapSettings, MarkerModel, MarkerStyleHelper, MarkersComponent, MessageRegistratorService, ModifyFeatureCommand, OsmTileLayerComponent, PolygonModel, PolygonSelfIntersectionExecutor, PolygonStyleHelper, PolygonsComponent, RasterTileLayerComponent, RasterTileLayerSettings, RemoveControlCommand, SetMapCenterCommand, StartDrawingCommand, StringifyFeatureHelper, TextStyleHelper, TileLayerComponent, TileLayerSettings, TooltipComponent, TooltipSettings, ZoomControlSettings };
|
|
3802
3950
|
//# sourceMappingURL=maps-components.mjs.map
|