@artstesh/maps 6.1.5 → 6.1.7

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.
Files changed (67) hide show
  1. package/dist/esm2022/map/map-plate/layers/image-layer/image-layer-factory.mjs +26 -0
  2. package/dist/esm2022/map/map-plate/layers/image-layer/image-layer.component.mjs +52 -0
  3. package/dist/esm2022/map/map-plate/layers/image-layer/image-layer.settings.mjs +134 -0
  4. package/dist/esm2022/map/map-plate/layers/index.mjs +5 -1
  5. package/dist/esm2022/map/map-plate/layers/raster-tile/raster-tile-layer.component.mjs +52 -0
  6. package/dist/esm2022/map/map-plate/layers/raster-tile/raster-tile-layer.factory.mjs +74 -0
  7. package/dist/esm2022/map/map-plate/layers/raster-tile/raster-tile-layer.settings.mjs +149 -0
  8. package/dist/esm2022/map/map.module.mjs +13 -3
  9. package/dist/esm2022/map/messages/commands/add-image-layer.command.mjs +10 -0
  10. package/dist/esm2022/map/messages/commands/add-raster-tile-command.mjs +10 -0
  11. package/dist/esm2022/map/messages/commands/remove-image-layer.command.mjs +10 -0
  12. package/dist/esm2022/map/messages/commands/remove-raster-tile.command.mjs +10 -0
  13. package/dist/esm2022/map/ol-proxy.mjs +3 -0
  14. package/dist/esm2022/map/public-api.mjs +2 -2
  15. package/dist/esm2022/map/services/map-management.service.mjs +32 -8
  16. package/dist/esm2022/map/services/message-registrator.service.mjs +9 -1
  17. package/dist/esm2022/src/map/map-plate/layers/image-layer/image-layer-factory.mjs +26 -0
  18. package/dist/esm2022/src/map/map-plate/layers/image-layer/image-layer.component.mjs +52 -0
  19. package/dist/esm2022/src/map/map-plate/layers/image-layer/image-layer.settings.mjs +134 -0
  20. package/dist/esm2022/src/map/map-plate/layers/index.mjs +5 -1
  21. package/dist/esm2022/src/map/map-plate/layers/raster-tile/raster-tile-layer.component.mjs +52 -0
  22. package/dist/esm2022/src/map/map-plate/layers/raster-tile/raster-tile-layer.factory.mjs +74 -0
  23. package/dist/esm2022/src/map/map-plate/layers/raster-tile/raster-tile-layer.settings.mjs +149 -0
  24. package/dist/esm2022/src/map/map.module.mjs +13 -3
  25. package/dist/esm2022/src/map/messages/commands/add-image-layer.command.mjs +10 -0
  26. package/dist/esm2022/src/map/messages/commands/add-raster-tile-command.mjs +10 -0
  27. package/dist/esm2022/src/map/messages/commands/remove-image-layer.command.mjs +10 -0
  28. package/dist/esm2022/src/map/messages/commands/remove-raster-tile.command.mjs +10 -0
  29. package/dist/esm2022/src/map/ol-proxy.mjs +3 -0
  30. package/dist/esm2022/src/map/public-api.mjs +2 -2
  31. package/dist/esm2022/src/map/services/map-management.service.mjs +32 -8
  32. package/dist/esm2022/src/map/services/message-registrator.service.mjs +9 -1
  33. package/dist/fesm2022/maps-components-src-map.mjs +538 -10
  34. package/dist/fesm2022/maps-components-src-map.mjs.map +1 -1
  35. package/dist/fesm2022/maps-components.mjs +538 -10
  36. package/dist/fesm2022/maps-components.mjs.map +1 -1
  37. package/dist/map/map-plate/layers/image-layer/image-layer-factory.d.ts +9 -0
  38. package/dist/map/map-plate/layers/image-layer/image-layer.component.d.ts +22 -0
  39. package/dist/map/map-plate/layers/image-layer/image-layer.settings.d.ts +97 -0
  40. package/dist/map/map-plate/layers/index.d.ts +4 -0
  41. package/dist/map/map-plate/layers/raster-tile/raster-tile-layer.component.d.ts +21 -0
  42. package/dist/map/map-plate/layers/raster-tile/raster-tile-layer.factory.d.ts +12 -0
  43. package/dist/map/map-plate/layers/raster-tile/raster-tile-layer.settings.d.ts +108 -0
  44. package/dist/map/map.module.d.ts +4 -2
  45. package/dist/map/messages/commands/add-image-layer.command.d.ts +8 -0
  46. package/dist/map/messages/commands/add-raster-tile-command.d.ts +8 -0
  47. package/dist/map/messages/commands/remove-image-layer.command.d.ts +8 -0
  48. package/dist/map/messages/commands/remove-raster-tile.command.d.ts +8 -0
  49. package/dist/map/ol-proxy.d.ts +3 -0
  50. package/dist/map/public-api.d.ts +1 -1
  51. package/dist/map/services/map-management.service.d.ts +1 -1
  52. package/dist/src/map/map-plate/layers/image-layer/image-layer-factory.d.ts +9 -0
  53. package/dist/src/map/map-plate/layers/image-layer/image-layer.component.d.ts +22 -0
  54. package/dist/src/map/map-plate/layers/image-layer/image-layer.settings.d.ts +97 -0
  55. package/dist/src/map/map-plate/layers/index.d.ts +4 -0
  56. package/dist/src/map/map-plate/layers/raster-tile/raster-tile-layer.component.d.ts +21 -0
  57. package/dist/src/map/map-plate/layers/raster-tile/raster-tile-layer.factory.d.ts +12 -0
  58. package/dist/src/map/map-plate/layers/raster-tile/raster-tile-layer.settings.d.ts +108 -0
  59. package/dist/src/map/map.module.d.ts +4 -2
  60. package/dist/src/map/messages/commands/add-image-layer.command.d.ts +8 -0
  61. package/dist/src/map/messages/commands/add-raster-tile-command.d.ts +8 -0
  62. package/dist/src/map/messages/commands/remove-image-layer.command.d.ts +8 -0
  63. package/dist/src/map/messages/commands/remove-raster-tile.command.d.ts +8 -0
  64. package/dist/src/map/ol-proxy.d.ts +3 -0
  65. package/dist/src/map/public-api.d.ts +1 -1
  66. package/dist/src/map/services/map-management.service.d.ts +1 -1
  67. package/package.json +1 -1
@@ -3,6 +3,7 @@ import { Component, Injectable, ChangeDetectionStrategy, Input, ViewChild, NgMod
3
3
  import * as i4 from '@angular/common';
4
4
  import { CommonModule } from '@angular/common';
5
5
  import { Feature, Collection } from 'ol';
6
+ export { Feature } from 'ol';
6
7
  import { Point, LineString } from 'ol/geom';
7
8
  import { GeoJSON, WKT } from 'ol/format';
8
9
  import { getCenter, createEmpty, extend } from 'ol/extent';
@@ -22,6 +23,9 @@ import OSM from 'ol/source/OSM';
22
23
  import { Vector as Vector$1 } from 'ol/layer';
23
24
  import { bbox } from 'ol/loadingstrategy';
24
25
  import Cluster from 'ol/source/Cluster';
26
+ import Static from 'ol/source/ImageStatic';
27
+ import ImageLayer from 'ol/layer/Image';
28
+ import RasterSource from 'ol/source/Raster';
25
29
  import Map from 'ol/Map';
26
30
  import View from 'ol/View';
27
31
  import Overlay from 'ol/Overlay';
@@ -924,6 +928,42 @@ class ZoomControlFactory {
924
928
  }
925
929
  }
926
930
 
931
+ class AddImageLayerCommand extends PostboyGenericMessage {
932
+ layer;
933
+ static ID = '70f9b86f-8bc2-4f28-ae79-a13fc0b1ee5d';
934
+ constructor(layer) {
935
+ super();
936
+ this.layer = layer;
937
+ }
938
+ }
939
+
940
+ class RemoveImageLayerCommand extends PostboyGenericMessage {
941
+ layer;
942
+ static ID = 'c8e7efdb-17ff-4cf9-89be-e688b8de3b95';
943
+ constructor(layer) {
944
+ super();
945
+ this.layer = layer;
946
+ }
947
+ }
948
+
949
+ class AddRasterTileCommand extends PostboyGenericMessage {
950
+ layer;
951
+ static ID = 'd33447fe-eec0-4205-9b5d-0d79ddc74ad7';
952
+ constructor(layer) {
953
+ super();
954
+ this.layer = layer;
955
+ }
956
+ }
957
+
958
+ class RemoveRasterTileCommand extends PostboyGenericMessage {
959
+ layer;
960
+ static ID = 'd1c4bf6a-e2f2-4385-a7a2-cecb525f8939';
961
+ constructor(layer) {
962
+ super();
963
+ this.layer = layer;
964
+ }
965
+ }
966
+
927
967
  class MapPostboyService extends PostboyService {
928
968
  constructor() {
929
969
  super();
@@ -948,27 +988,47 @@ class MapManagementService {
948
988
  this.observeRemoveLayer();
949
989
  this.observePlaceFeatures();
950
990
  this.observeAddTile();
951
- this.observeRemoveTile();
952
991
  this.observeLayerQuery();
953
992
  this.observeFeaturesInArea();
954
993
  this.observeFeaturesInPoint();
994
+ this.observeImageLayer();
955
995
  }
956
- observeRemoveTile() {
996
+ observeLayerQuery() {
997
+ this.postboy.sub(GetLayerQuery).subscribe((ev) => ev.finish(this.layers.take(ev.name)));
998
+ }
999
+ observeAddTile() {
1000
+ this.postboy.sub(AddTileCommand).subscribe((c) => {
1001
+ if (!this.map)
1002
+ return;
1003
+ this.map.addLayer(c.layer);
1004
+ });
957
1005
  this.postboy.sub(RemoveTileCommand).subscribe((c) => {
958
1006
  if (!this.map)
959
1007
  return;
960
1008
  this.map.removeLayer(c.layer);
961
1009
  });
1010
+ this.postboy.sub(AddRasterTileCommand).subscribe((c) => {
1011
+ if (!this.map)
1012
+ return;
1013
+ this.map.addLayer(c.layer);
1014
+ });
1015
+ this.postboy.sub(RemoveRasterTileCommand).subscribe((c) => {
1016
+ if (!this.map)
1017
+ return;
1018
+ this.map.removeLayer(c.layer);
1019
+ });
962
1020
  }
963
- observeLayerQuery() {
964
- this.postboy.sub(GetLayerQuery).subscribe((ev) => ev.finish(this.layers.take(ev.name)));
965
- }
966
- observeAddTile() {
967
- this.postboy.sub(AddTileCommand).subscribe((c) => {
1021
+ observeImageLayer() {
1022
+ this.postboy.sub(AddImageLayerCommand).subscribe((c) => {
968
1023
  if (!this.map)
969
1024
  return;
970
1025
  this.map.addLayer(c.layer);
971
1026
  });
1027
+ this.postboy.sub(RemoveImageLayerCommand).subscribe((c) => {
1028
+ if (!this.map)
1029
+ return;
1030
+ this.map.removeLayer(c.layer);
1031
+ });
972
1032
  }
973
1033
  observeMapRender() {
974
1034
  this.postboy.sub(MapRenderedEvent).subscribe((m) => {
@@ -1419,6 +1479,10 @@ class MessageRegistratorService extends PostboyAbstractRegistrator {
1419
1479
  this.recordSubject(AddLayerCommand);
1420
1480
  this.recordSubject(RemoveLayerCommand);
1421
1481
  this.recordSubject(AddTileCommand);
1482
+ this.recordSubject(AddRasterTileCommand);
1483
+ this.recordSubject(RemoveRasterTileCommand);
1484
+ this.recordSubject(RemoveImageLayerCommand);
1485
+ this.recordSubject(AddImageLayerCommand);
1422
1486
  this.recordSubject(RemoveTileCommand);
1423
1487
  this.recordSubject(MapClickEvent);
1424
1488
  this.recordSubject(CloseTooltipCommand);
@@ -2231,6 +2295,462 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.7", ngImpor
2231
2295
  type: Input
2232
2296
  }] } });
2233
2297
 
2298
+ class ImageLayerSettings {
2299
+ /**
2300
+ * Represents the tiles URL.
2301
+ * @typedef {string} url
2302
+ *
2303
+ * @example
2304
+ * 'https://example.ex/{z}/{x}/{y}.png'
2305
+ */
2306
+ url = '';
2307
+ /**
2308
+ * Use interpolated values when resampling.
2309
+ * By default, linear interpolation is used when resampling.
2310
+ * Set to false to use the nearest neighbor instead.
2311
+ */
2312
+ interpolate = undefined;
2313
+ /**
2314
+ * The projection of the coordinate system.
2315
+ *
2316
+ * @type {string}
2317
+ * @default 'EPSG:3857'
2318
+ */
2319
+ projection = 'EPSG:3857';
2320
+ extent = [0, 0, 0, 0];
2321
+ /**
2322
+ * Additional headers that should be added to each tile request
2323
+ *
2324
+ * @type {Record<string, string>}
2325
+ * @default An empty array
2326
+ */
2327
+ requestHeaders = null;
2328
+ /**
2329
+ * Creates a copy of the given tile layer settings.
2330
+ *
2331
+ * @param {ImageLayerSettings} model - The tile layer settings to be copied.
2332
+ * @return {ImageLayerSettings} - A new instance of ImageLayerSettings with the same properties as the model.
2333
+ */
2334
+ static copy(model) {
2335
+ const result = new ImageLayerSettings();
2336
+ result.interpolate = model.interpolate;
2337
+ result.projection = model.projection;
2338
+ result.extent = model.extent;
2339
+ result.url = model.url;
2340
+ result.requestHeaders = model.requestHeaders;
2341
+ return result;
2342
+ }
2343
+ /**
2344
+ * Sets the URL of the ImageLayerSettings object.
2345
+ *
2346
+ * @param {string} url - The URL to be set.
2347
+ * @return {ImageLayerSettings} - The updated ImageLayerSettings object.
2348
+ */
2349
+ setUrl(url) {
2350
+ return ImageLayerSettings.copy({ ...this, url });
2351
+ }
2352
+ /**
2353
+ * Sets the interpolation state for the image layer settings.
2354
+ *
2355
+ * @param {boolean} [interpolate] - Use interpolated values when resampling.
2356
+ * By default, linear interpolation is used when resampling.
2357
+ * Set to false to use the nearest neighbor instead.
2358
+ * @return {ImageLayerSettings} A new instance of ImageLayerSettings with the updated interpolation setting.
2359
+ */
2360
+ setInterpolate(interpolate) {
2361
+ return ImageLayerSettings.copy({ ...this, interpolate });
2362
+ }
2363
+ setExtent(extent) {
2364
+ return ImageLayerSettings.copy({ ...this, extent });
2365
+ }
2366
+ /**
2367
+ * Sets the requestHeaders of the ImageLayerSettings object.
2368
+ *
2369
+ * @param {Record<string, string>} requestHeaders - The headers which should be provided.
2370
+ * @return {ImageLayerSettings} - The updated ImageLayerSettings object.
2371
+ */
2372
+ setRequestHeaders(requestHeaders) {
2373
+ return ImageLayerSettings.copy({ ...this, requestHeaders });
2374
+ }
2375
+ /**
2376
+ * Sets the maximum zoom level for the tile layer.
2377
+ *
2378
+ * @param {number} maxZoom - The maximum zoom level.
2379
+ * @returns {ImageLayerSettings} - The updated tile layer settings object.
2380
+ */
2381
+ setMaxZoom(maxZoom) {
2382
+ return ImageLayerSettings.copy({ ...this, maxZoom });
2383
+ }
2384
+ /**
2385
+ * Sets the minimum zoom level for the Tile Layer.
2386
+ *
2387
+ * @param {number} minZoom - The minimum zoom level to be set.
2388
+ * @return {ImageLayerSettings} The modified ImageLayerSettings object with the updated minimum zoom level.
2389
+ */
2390
+ setMinZoom(minZoom) {
2391
+ return ImageLayerSettings.copy({ ...this, minZoom });
2392
+ }
2393
+ /**
2394
+ * Sets the opacity of the ImageLayerSettings.
2395
+ *
2396
+ * @param {number} opacity - The opacity value to set. Must be a number between 0 and 1.
2397
+ * @return {ImageLayerSettings} - A new instance of ImageLayerSettings with the opacity set.
2398
+ */
2399
+ setOpacity(opacity) {
2400
+ return ImageLayerSettings.copy({ ...this, opacity });
2401
+ }
2402
+ /**
2403
+ * Sets the projection for the tile layer settings.
2404
+ *
2405
+ * @param {string} projection - The desired projection for the tile layer settings.
2406
+ * @return {ImageLayerSettings} - The updated tile layer settings with the new projection.
2407
+ */
2408
+ setProjection(projection) {
2409
+ return ImageLayerSettings.copy({ ...this, projection });
2410
+ }
2411
+ /**
2412
+ * Checks if the current instance of ImageLayerSettings is equal to the given model.
2413
+ * @param {ImageLayerSettings} model - The model to compare against.
2414
+ * @return {boolean} - True if all properties of the current instance matches the properties of the model;
2415
+ * otherwise, false.
2416
+ */
2417
+ isSame(model) {
2418
+ if (this.url !== model.url)
2419
+ return false;
2420
+ if (this.projection !== model.projection)
2421
+ return false;
2422
+ if (this.extent !== model.extent)
2423
+ return false;
2424
+ if (this.interpolate !== model.interpolate)
2425
+ return false;
2426
+ if (this.requestHeaders !== model.requestHeaders)
2427
+ return false;
2428
+ return true;
2429
+ }
2430
+ }
2431
+
2432
+ class ImageLayerFactory {
2433
+ build(settings) {
2434
+ const source = new Static({
2435
+ url: settings.url,
2436
+ interpolate: settings.interpolate,
2437
+ crossOrigin: 'Anonymous',
2438
+ projection: get(settings.projection),
2439
+ imageExtent: settings.extent,
2440
+ });
2441
+ return new ImageLayer({ source });
2442
+ }
2443
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: ImageLayerFactory, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
2444
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: ImageLayerFactory, providedIn: 'root' });
2445
+ }
2446
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: ImageLayerFactory, decorators: [{
2447
+ type: Injectable,
2448
+ args: [{
2449
+ providedIn: 'root',
2450
+ }]
2451
+ }] });
2452
+
2453
+ class ImageLayerComponent extends DestructibleComponent {
2454
+ postboy;
2455
+ factory;
2456
+ layer;
2457
+ constructor(postboy, factory) {
2458
+ super();
2459
+ this.postboy = postboy;
2460
+ this.factory = factory;
2461
+ }
2462
+ _settings = new ImageLayerSettings();
2463
+ set settings(value) {
2464
+ if (!value || this._settings.isSame(value))
2465
+ return;
2466
+ this._settings = value;
2467
+ this.initLayer();
2468
+ }
2469
+ ngOnInit() {
2470
+ this.postboy
2471
+ .sub(MapRenderedEvent)
2472
+ .pipe(filter((m) => !!m), first())
2473
+ .subscribe((m) => this.initLayer());
2474
+ }
2475
+ onDestroy = () => this.removeLayer();
2476
+ initLayer() {
2477
+ this.removeLayer();
2478
+ this.layer = this.factory.build(this._settings);
2479
+ this.postboy.fire(new AddImageLayerCommand(this.layer));
2480
+ }
2481
+ removeLayer() {
2482
+ if (this.layer)
2483
+ this.postboy.fire(new RemoveImageLayerCommand(this.layer));
2484
+ }
2485
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: ImageLayerComponent, deps: [{ token: MapPostboyService }, { token: ImageLayerFactory }], target: i0.ɵɵFactoryTarget.Component });
2486
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.7", type: ImageLayerComponent, selector: "art-image-layer", inputs: { settings: "settings" }, usesInheritance: true, ngImport: i0, template: '', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
2487
+ }
2488
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: ImageLayerComponent, decorators: [{
2489
+ type: Component,
2490
+ args: [{ selector: 'art-image-layer', template: '', changeDetection: ChangeDetectionStrategy.OnPush }]
2491
+ }], ctorParameters: () => [{ type: MapPostboyService }, { type: ImageLayerFactory }], propDecorators: { settings: [{
2492
+ type: Input
2493
+ }] } });
2494
+
2495
+ class RasterTileLayerSettings {
2496
+ /**
2497
+ * The maximum zoom level for a map view.
2498
+ *
2499
+ * @type {number}
2500
+ * @default 19
2501
+ */
2502
+ maxZoom = 19;
2503
+ /**
2504
+ * The minimum zoom level allowed.
2505
+ *
2506
+ * @type {number}
2507
+ */
2508
+ minZoom = 0;
2509
+ /**
2510
+ * The opacity of an element.
2511
+ *
2512
+ * @type {number}
2513
+ * @default 0.6
2514
+ */
2515
+ opacity = 0.6;
2516
+ /**
2517
+ * Represents the tiles URL.
2518
+ * @typedef {string} url
2519
+ *
2520
+ * @example
2521
+ * 'https://example.ex/{z}/{x}/{y}.png'
2522
+ */
2523
+ url = '';
2524
+ /**
2525
+ * The projection of the coordinate system.
2526
+ *
2527
+ * @type {string}
2528
+ * @default 'EPSG:3857'
2529
+ */
2530
+ projection = 'EPSG:3857';
2531
+ /**
2532
+ * Additional headers that should be added to each tile request
2533
+ *
2534
+ * @type {Record<string, string>}
2535
+ * @default An empty array
2536
+ */
2537
+ requestHeaders = null;
2538
+ operation = (d) => d[0] ?? [];
2539
+ /**
2540
+ * Creates a copy of the given tile layer settings.
2541
+ *
2542
+ * @param {RasterTileLayerSettings} model - The tile layer settings to be copied.
2543
+ * @return {RasterTileLayerSettings} - A new instance of RasterTileLayerSettings with the same properties as the model.
2544
+ */
2545
+ static copy(model) {
2546
+ const result = new RasterTileLayerSettings();
2547
+ result.maxZoom = model.maxZoom;
2548
+ result.minZoom = model.minZoom;
2549
+ result.projection = model.projection;
2550
+ result.opacity = model.opacity;
2551
+ result.url = model.url;
2552
+ result.requestHeaders = model.requestHeaders;
2553
+ result.operation = model.operation;
2554
+ return result;
2555
+ }
2556
+ /**
2557
+ * Sets the URL of the RasterTileLayerSettings object.
2558
+ *
2559
+ * @param {string} url - The URL to be set.
2560
+ * @return {RasterTileLayerSettings} - The updated RasterTileLayerSettings object.
2561
+ */
2562
+ setUrl(url) {
2563
+ return RasterTileLayerSettings.copy({ ...this, url });
2564
+ }
2565
+ /**
2566
+ * Sets the operation to apply on raster tile data.
2567
+ *
2568
+ * @param {function} operation - A function that takes an input of either a two-dimensional array of numbers or an array of ImageData objects and returns either a one-dimensional array of numbers or an ImageData object.
2569
+ * @return {RasterTileLayerSettings} A new instance of RasterTileLayerSettings with the updated operation.
2570
+ */
2571
+ setOperation(operation) {
2572
+ return RasterTileLayerSettings.copy({ ...this, operation });
2573
+ }
2574
+ /**
2575
+ * Sets the requestHeaders of the RasterTileLayerSettings object.
2576
+ *
2577
+ * @param {Record<string, string>} requestHeaders - The headers which should be provided.
2578
+ * @return {RasterTileLayerSettings} - The updated RasterTileLayerSettings object.
2579
+ */
2580
+ setRequestHeaders(requestHeaders) {
2581
+ return RasterTileLayerSettings.copy({ ...this, requestHeaders });
2582
+ }
2583
+ /**
2584
+ * Sets the maximum zoom level for the tile layer.
2585
+ *
2586
+ * @param {number} maxZoom - The maximum zoom level.
2587
+ * @returns {RasterTileLayerSettings} - The updated tile layer settings object.
2588
+ */
2589
+ setMaxZoom(maxZoom) {
2590
+ return RasterTileLayerSettings.copy({ ...this, maxZoom });
2591
+ }
2592
+ /**
2593
+ * Sets the minimum zoom level for the Tile Layer.
2594
+ *
2595
+ * @param {number} minZoom - The minimum zoom level to be set.
2596
+ * @return {RasterTileLayerSettings} The modified RasterTileLayerSettings object with the updated minimum zoom level.
2597
+ */
2598
+ setMinZoom(minZoom) {
2599
+ return RasterTileLayerSettings.copy({ ...this, minZoom });
2600
+ }
2601
+ /**
2602
+ * Sets the opacity of the RasterTileLayerSettings.
2603
+ *
2604
+ * @param {number} opacity - The opacity value to set. Must be a number between 0 and 1.
2605
+ * @return {RasterTileLayerSettings} - A new instance of RasterTileLayerSettings with the opacity set.
2606
+ */
2607
+ setOpacity(opacity) {
2608
+ return RasterTileLayerSettings.copy({ ...this, opacity });
2609
+ }
2610
+ /**
2611
+ * Sets the projection for the tile layer settings.
2612
+ *
2613
+ * @param {string} projection - The desired projection for the tile layer settings.
2614
+ * @return {RasterTileLayerSettings} - The updated tile layer settings with the new projection.
2615
+ */
2616
+ setProjection(projection) {
2617
+ return RasterTileLayerSettings.copy({ ...this, projection });
2618
+ }
2619
+ /**
2620
+ * Checks if the current instance of RasterTileLayerSettings is equal to the given model.
2621
+ * @param {RasterTileLayerSettings} model - The model to compare against.
2622
+ * @return {boolean} - True if all properties of the current instance matches the properties of the model;
2623
+ * otherwise, false.
2624
+ */
2625
+ isSame(model) {
2626
+ if (this.maxZoom !== model.maxZoom)
2627
+ return false;
2628
+ if (this.minZoom !== model.minZoom)
2629
+ return false;
2630
+ if (this.url !== model.url)
2631
+ return false;
2632
+ if (this.projection !== model.projection)
2633
+ return false;
2634
+ if (this.opacity !== model.opacity)
2635
+ return false;
2636
+ if (this.requestHeaders !== model.requestHeaders)
2637
+ return false;
2638
+ if (this.operation !== model.operation)
2639
+ return false;
2640
+ return true;
2641
+ }
2642
+ }
2643
+
2644
+ class RasterTileLayerFactory {
2645
+ build(settings) {
2646
+ const source = new XYZ({
2647
+ tileSize: 256,
2648
+ maxZoom: settings.maxZoom || 14,
2649
+ minZoom: settings.minZoom || 1,
2650
+ projection: get(settings.projection),
2651
+ tileUrlFunction: this.getTileFunc(settings),
2652
+ crossOrigin: 'Anonymous',
2653
+ tileLoadFunction: !!settings.requestHeaders
2654
+ ? (tile, src) => this.tileLoader(tile, src, settings.requestHeaders)
2655
+ : undefined,
2656
+ });
2657
+ const raster = new RasterSource({
2658
+ sources: [source],
2659
+ operationType: 'image',
2660
+ operation: settings.operation,
2661
+ });
2662
+ return new ImageLayer({ source: raster, opacity: settings.opacity });
2663
+ }
2664
+ getTileFunc(settings) {
2665
+ return (tileCoord) => {
2666
+ const zoom = tileCoord[0];
2667
+ const x = tileCoord[1];
2668
+ const y = tileCoord[2];
2669
+ const normalizedCoord = this.getNormalizedCoord({ x: x, y: y }, zoom);
2670
+ const bound = 1 << zoom;
2671
+ return settings.url
2672
+ .replace('{x}', String(normalizedCoord?.x || x))
2673
+ .replace('{z}', String(zoom))
2674
+ .replace('{y}', String(bound - (normalizedCoord?.y || y) - 1));
2675
+ };
2676
+ }
2677
+ tileLoader(tile, src, headers) {
2678
+ const client = new XMLHttpRequest();
2679
+ client.open('GET', src);
2680
+ client.responseType = 'arraybuffer';
2681
+ Object.keys(headers).forEach((k) => client.setRequestHeader(k, headers[k]));
2682
+ client.onload = function () {
2683
+ if (this.response !== undefined) {
2684
+ const arrayBufferView = new Uint8Array(this.response);
2685
+ const blob = new Blob([arrayBufferView], { type: 'image/png' });
2686
+ const urlCreator = window.URL || window.webkitURL;
2687
+ tile.getImage().src = urlCreator.createObjectURL(blob);
2688
+ }
2689
+ };
2690
+ client.send();
2691
+ }
2692
+ getNormalizedCoord(coord, zoom) {
2693
+ const y = coord.y;
2694
+ let x = coord.x;
2695
+ const tileRange = 1 << zoom;
2696
+ if (y < 0 || y >= tileRange)
2697
+ return null;
2698
+ if (x < 0 || x >= tileRange)
2699
+ x = ((x % tileRange) + tileRange) % tileRange;
2700
+ return { x: x, y: y };
2701
+ }
2702
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: RasterTileLayerFactory, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
2703
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: RasterTileLayerFactory, providedIn: 'root' });
2704
+ }
2705
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: RasterTileLayerFactory, decorators: [{
2706
+ type: Injectable,
2707
+ args: [{
2708
+ providedIn: 'root',
2709
+ }]
2710
+ }] });
2711
+
2712
+ class RasterTileLayerComponent extends DestructibleComponent {
2713
+ postboy;
2714
+ factory;
2715
+ layer;
2716
+ constructor(postboy, factory) {
2717
+ super();
2718
+ this.postboy = postboy;
2719
+ this.factory = factory;
2720
+ }
2721
+ _settings = new RasterTileLayerSettings();
2722
+ set settings(value) {
2723
+ if (!value || this._settings.isSame(value))
2724
+ return;
2725
+ this._settings = value;
2726
+ this.initLayer();
2727
+ }
2728
+ ngOnInit() {
2729
+ this.postboy
2730
+ .sub(MapRenderedEvent)
2731
+ .pipe(filter((m) => !!m), first())
2732
+ .subscribe((m) => this.initLayer());
2733
+ }
2734
+ onDestroy = () => this.removeLayer();
2735
+ initLayer() {
2736
+ this.removeLayer();
2737
+ this.layer = this.factory.build(this._settings);
2738
+ this.postboy.fire(new AddRasterTileCommand(this.layer));
2739
+ }
2740
+ removeLayer() {
2741
+ if (this.layer)
2742
+ this.postboy.fire(new RemoveRasterTileCommand(this.layer));
2743
+ }
2744
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: RasterTileLayerComponent, deps: [{ token: MapPostboyService }, { token: RasterTileLayerFactory }], target: i0.ɵɵFactoryTarget.Component });
2745
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.7", type: RasterTileLayerComponent, selector: "art-raster-tile-layer", inputs: { settings: "settings" }, usesInheritance: true, ngImport: i0, template: '', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
2746
+ }
2747
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: RasterTileLayerComponent, decorators: [{
2748
+ type: Component,
2749
+ args: [{ selector: 'art-raster-tile-layer', template: '', changeDetection: ChangeDetectionStrategy.OnPush }]
2750
+ }], ctorParameters: () => [{ type: MapPostboyService }, { type: RasterTileLayerFactory }], propDecorators: { settings: [{
2751
+ type: Input
2752
+ }] } });
2753
+
2234
2754
  class MapPlateFactory {
2235
2755
  build(settings) {
2236
2756
  return new Map({
@@ -2719,14 +3239,18 @@ class MapModule {
2719
3239
  TooltipComponent,
2720
3240
  PolygonsComponent,
2721
3241
  ClusterLayerComponent,
2722
- MapControlZoomComponent], imports: [CommonModule], exports: [MapPlateComponent,
3242
+ MapControlZoomComponent,
3243
+ ImageLayerComponent,
3244
+ RasterTileLayerComponent], imports: [CommonModule], exports: [MapPlateComponent,
2723
3245
  FeatureLayerComponent,
2724
3246
  MarkersComponent,
2725
3247
  TileLayerComponent,
2726
3248
  TooltipComponent,
2727
3249
  PolygonsComponent,
2728
3250
  ClusterLayerComponent,
2729
- MapControlZoomComponent] });
3251
+ MapControlZoomComponent,
3252
+ ImageLayerComponent,
3253
+ RasterTileLayerComponent] });
2730
3254
  static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: MapModule, imports: [CommonModule] });
2731
3255
  }
2732
3256
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: MapModule, decorators: [{
@@ -2744,6 +3268,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.7", ngImpor
2744
3268
  PolygonsComponent,
2745
3269
  ClusterLayerComponent,
2746
3270
  MapControlZoomComponent,
3271
+ ImageLayerComponent,
3272
+ RasterTileLayerComponent,
2747
3273
  ],
2748
3274
  exports: [
2749
3275
  MapPlateComponent,
@@ -2754,6 +3280,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.7", ngImpor
2754
3280
  PolygonsComponent,
2755
3281
  ClusterLayerComponent,
2756
3282
  MapControlZoomComponent,
3283
+ ImageLayerComponent,
3284
+ RasterTileLayerComponent,
2757
3285
  ],
2758
3286
  }]
2759
3287
  }] });
@@ -2950,5 +3478,5 @@ class StringifyFeatureHelper {
2950
3478
  * Generated bundle index. Do not edit.
2951
3479
  */
2952
3480
 
2953
- export { AddControlCommand, CalculateAreaExecutor, CancelDrawingCommand, CancelFeatureModificationCommand, CloseTooltipCommand, ClusterLayerComponent, ClusterLayerSettings, DrawSelectionAreaCommand, DrawingType, FeatureLayerComponent, FeatureLayerSettings, FeatureOutputFormat, FilterFeaturesInAreaExecutor, FilterFeaturesInPointExecutor, FitToFeaturesCommand, FitToPolygonsCommand, GetFeaturesInAreaQuery, GetFeaturesInPointQuery, GetMapPositionExecutor, MapClickEvent, MapConstants, MapControl, MapControlZoomComponent, MapFeatureHoveredEvent, MapLyrs, MapLyrsLabel, MapModule, MapMoveEndEvent, MapPlateComponent, MapPointerMoveEvent, MapPostboyService, MapRenderedEvent, MapSettings, MarkerModel, MarkerStyleHelper, MarkersComponent, MessageRegistratorService, ModifyFeatureCommand, OsmTileLayerComponent, PolygonModel, PolygonSelfIntersectionExecutor, PolygonStyleHelper, PolygonsComponent, RemoveControlCommand, SetMapCenterCommand, StartDrawingCommand, StringifyFeatureHelper, TextStyleHelper, TileLayerComponent, TileLayerSettings, TooltipComponent, TooltipSettings, ZoomControlSettings };
3481
+ export { AddControlCommand, CalculateAreaExecutor, CancelDrawingCommand, CancelFeatureModificationCommand, CloseTooltipCommand, ClusterLayerComponent, ClusterLayerSettings, DrawSelectionAreaCommand, DrawingType, FeatureLayerComponent, FeatureLayerSettings, FeatureOutputFormat, FilterFeaturesInAreaExecutor, FilterFeaturesInPointExecutor, FitToFeaturesCommand, FitToPolygonsCommand, GetFeaturesInAreaQuery, GetFeaturesInPointQuery, GetMapPositionExecutor, ImageLayerComponent, ImageLayerSettings, MapClickEvent, MapConstants, MapControl, MapControlZoomComponent, MapFeatureHoveredEvent, MapLyrs, MapLyrsLabel, MapModule, 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 };
2954
3482
  //# sourceMappingURL=maps-components-src-map.mjs.map