@artstesh/maps 1.1.25 → 1.1.27

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 (71) hide show
  1. package/dist/bundles/maps-components-src-map.umd.js +591 -14
  2. package/dist/bundles/maps-components-src-map.umd.js.map +1 -1
  3. package/dist/bundles/maps-components.umd.js +591 -14
  4. package/dist/bundles/maps-components.umd.js.map +1 -1
  5. package/dist/esm2015/map/map-plate/layers/image-layer/image-layer-factory.js +26 -0
  6. package/dist/esm2015/map/map-plate/layers/image-layer/image-layer.component.js +54 -0
  7. package/dist/esm2015/map/map-plate/layers/image-layer/image-layer.settings.js +136 -0
  8. package/dist/esm2015/map/map-plate/layers/index.js +5 -1
  9. package/dist/esm2015/map/map-plate/layers/raster-tile/raster-tile-layer.component.js +54 -0
  10. package/dist/esm2015/map/map-plate/layers/raster-tile/raster-tile-layer.factory.js +74 -0
  11. package/dist/esm2015/map/map-plate/layers/raster-tile/raster-tile-layer.settings.js +151 -0
  12. package/dist/esm2015/map/map.module.js +13 -3
  13. package/dist/esm2015/map/messages/commands/add-image-layer.command.js +9 -0
  14. package/dist/esm2015/map/messages/commands/add-raster-tile-command.js +9 -0
  15. package/dist/esm2015/map/messages/commands/remove-image-layer.command.js +9 -0
  16. package/dist/esm2015/map/messages/commands/remove-raster-tile.command.js +9 -0
  17. package/dist/esm2015/map/ol-proxy.js +3 -0
  18. package/dist/esm2015/map/public-api.js +2 -2
  19. package/dist/esm2015/map/services/map-management.service.js +32 -8
  20. package/dist/esm2015/map/services/message-registrator.service.js +9 -1
  21. package/dist/esm2015/src/map/map-plate/layers/image-layer/image-layer-factory.js +26 -0
  22. package/dist/esm2015/src/map/map-plate/layers/image-layer/image-layer.component.js +54 -0
  23. package/dist/esm2015/src/map/map-plate/layers/image-layer/image-layer.settings.js +136 -0
  24. package/dist/esm2015/src/map/map-plate/layers/index.js +5 -1
  25. package/dist/esm2015/src/map/map-plate/layers/raster-tile/raster-tile-layer.component.js +54 -0
  26. package/dist/esm2015/src/map/map-plate/layers/raster-tile/raster-tile-layer.factory.js +74 -0
  27. package/dist/esm2015/src/map/map-plate/layers/raster-tile/raster-tile-layer.settings.js +151 -0
  28. package/dist/esm2015/src/map/map.module.js +13 -3
  29. package/dist/esm2015/src/map/messages/commands/add-image-layer.command.js +9 -0
  30. package/dist/esm2015/src/map/messages/commands/add-raster-tile-command.js +9 -0
  31. package/dist/esm2015/src/map/messages/commands/remove-image-layer.command.js +9 -0
  32. package/dist/esm2015/src/map/messages/commands/remove-raster-tile.command.js +9 -0
  33. package/dist/esm2015/src/map/ol-proxy.js +3 -0
  34. package/dist/esm2015/src/map/public-api.js +2 -2
  35. package/dist/esm2015/src/map/services/map-management.service.js +32 -8
  36. package/dist/esm2015/src/map/services/message-registrator.service.js +9 -1
  37. package/dist/fesm2015/maps-components-src-map.js +542 -10
  38. package/dist/fesm2015/maps-components-src-map.js.map +1 -1
  39. package/dist/fesm2015/maps-components.js +542 -10
  40. package/dist/fesm2015/maps-components.js.map +1 -1
  41. package/dist/map/map-plate/layers/image-layer/image-layer-factory.d.ts +9 -0
  42. package/dist/map/map-plate/layers/image-layer/image-layer.component.d.ts +22 -0
  43. package/dist/map/map-plate/layers/image-layer/image-layer.settings.d.ts +97 -0
  44. package/dist/map/map-plate/layers/index.d.ts +4 -0
  45. package/dist/map/map-plate/layers/raster-tile/raster-tile-layer.component.d.ts +21 -0
  46. package/dist/map/map-plate/layers/raster-tile/raster-tile-layer.factory.d.ts +12 -0
  47. package/dist/map/map-plate/layers/raster-tile/raster-tile-layer.settings.d.ts +108 -0
  48. package/dist/map/map.module.d.ts +4 -2
  49. package/dist/map/messages/commands/add-image-layer.command.d.ts +8 -0
  50. package/dist/map/messages/commands/add-raster-tile-command.d.ts +8 -0
  51. package/dist/map/messages/commands/remove-image-layer.command.d.ts +8 -0
  52. package/dist/map/messages/commands/remove-raster-tile.command.d.ts +8 -0
  53. package/dist/map/ol-proxy.d.ts +3 -0
  54. package/dist/map/public-api.d.ts +1 -1
  55. package/dist/map/services/map-management.service.d.ts +1 -1
  56. package/dist/src/map/map-plate/layers/image-layer/image-layer-factory.d.ts +9 -0
  57. package/dist/src/map/map-plate/layers/image-layer/image-layer.component.d.ts +22 -0
  58. package/dist/src/map/map-plate/layers/image-layer/image-layer.settings.d.ts +97 -0
  59. package/dist/src/map/map-plate/layers/index.d.ts +4 -0
  60. package/dist/src/map/map-plate/layers/raster-tile/raster-tile-layer.component.d.ts +21 -0
  61. package/dist/src/map/map-plate/layers/raster-tile/raster-tile-layer.factory.d.ts +12 -0
  62. package/dist/src/map/map-plate/layers/raster-tile/raster-tile-layer.settings.d.ts +108 -0
  63. package/dist/src/map/map.module.d.ts +4 -2
  64. package/dist/src/map/messages/commands/add-image-layer.command.d.ts +8 -0
  65. package/dist/src/map/messages/commands/add-raster-tile-command.d.ts +8 -0
  66. package/dist/src/map/messages/commands/remove-image-layer.command.d.ts +8 -0
  67. package/dist/src/map/messages/commands/remove-raster-tile.command.d.ts +8 -0
  68. package/dist/src/map/ol-proxy.d.ts +3 -0
  69. package/dist/src/map/public-api.d.ts +1 -1
  70. package/dist/src/map/services/map-management.service.d.ts +1 -1
  71. package/package.json +2 -2
@@ -3,6 +3,7 @@ import { Component, Injectable, ChangeDetectionStrategy, Input, ViewChild, NgMod
3
3
  import * as i6 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';
@@ -867,6 +871,38 @@ class ZoomControlFactory {
867
871
  }
868
872
  }
869
873
 
874
+ class AddImageLayerCommand extends PostboyGenericMessage {
875
+ constructor(layer) {
876
+ super();
877
+ this.layer = layer;
878
+ }
879
+ }
880
+ AddImageLayerCommand.ID = '70f9b86f-8bc2-4f28-ae79-a13fc0b1ee5d';
881
+
882
+ class RemoveImageLayerCommand extends PostboyGenericMessage {
883
+ constructor(layer) {
884
+ super();
885
+ this.layer = layer;
886
+ }
887
+ }
888
+ RemoveImageLayerCommand.ID = 'c8e7efdb-17ff-4cf9-89be-e688b8de3b95';
889
+
890
+ class AddRasterTileCommand extends PostboyGenericMessage {
891
+ constructor(layer) {
892
+ super();
893
+ this.layer = layer;
894
+ }
895
+ }
896
+ AddRasterTileCommand.ID = 'd33447fe-eec0-4205-9b5d-0d79ddc74ad7';
897
+
898
+ class RemoveRasterTileCommand extends PostboyGenericMessage {
899
+ constructor(layer) {
900
+ super();
901
+ this.layer = layer;
902
+ }
903
+ }
904
+ RemoveRasterTileCommand.ID = 'd1c4bf6a-e2f2-4385-a7a2-cecb525f8939';
905
+
870
906
  class MapPostboyService extends PostboyService {
871
907
  constructor() {
872
908
  super();
@@ -894,27 +930,47 @@ class MapManagementService {
894
930
  this.observeRemoveLayer();
895
931
  this.observePlaceFeatures();
896
932
  this.observeAddTile();
897
- this.observeRemoveTile();
898
933
  this.observeLayerQuery();
899
934
  this.observeFeaturesInArea();
900
935
  this.observeFeaturesInPoint();
936
+ this.observeImageLayer();
937
+ }
938
+ observeLayerQuery() {
939
+ this.postboy.sub(GetLayerQuery).subscribe((ev) => ev.finish(this.layers.take(ev.name)));
901
940
  }
902
- observeRemoveTile() {
941
+ observeAddTile() {
942
+ this.postboy.sub(AddTileCommand).subscribe((c) => {
943
+ if (!this.map)
944
+ return;
945
+ this.map.addLayer(c.layer);
946
+ });
903
947
  this.postboy.sub(RemoveTileCommand).subscribe((c) => {
904
948
  if (!this.map)
905
949
  return;
906
950
  this.map.removeLayer(c.layer);
907
951
  });
952
+ this.postboy.sub(AddRasterTileCommand).subscribe((c) => {
953
+ if (!this.map)
954
+ return;
955
+ this.map.addLayer(c.layer);
956
+ });
957
+ this.postboy.sub(RemoveRasterTileCommand).subscribe((c) => {
958
+ if (!this.map)
959
+ return;
960
+ this.map.removeLayer(c.layer);
961
+ });
908
962
  }
909
- observeLayerQuery() {
910
- this.postboy.sub(GetLayerQuery).subscribe((ev) => ev.finish(this.layers.take(ev.name)));
911
- }
912
- observeAddTile() {
913
- this.postboy.sub(AddTileCommand).subscribe((c) => {
963
+ observeImageLayer() {
964
+ this.postboy.sub(AddImageLayerCommand).subscribe((c) => {
914
965
  if (!this.map)
915
966
  return;
916
967
  this.map.addLayer(c.layer);
917
968
  });
969
+ this.postboy.sub(RemoveImageLayerCommand).subscribe((c) => {
970
+ if (!this.map)
971
+ return;
972
+ this.map.removeLayer(c.layer);
973
+ });
918
974
  }
919
975
  observeMapRender() {
920
976
  this.postboy.sub(MapRenderedEvent).subscribe((m) => {
@@ -1361,6 +1417,10 @@ class MessageRegistratorService extends PostboyAbstractRegistrator {
1361
1417
  this.recordSubject(AddLayerCommand);
1362
1418
  this.recordSubject(RemoveLayerCommand);
1363
1419
  this.recordSubject(AddTileCommand);
1420
+ this.recordSubject(AddRasterTileCommand);
1421
+ this.recordSubject(RemoveRasterTileCommand);
1422
+ this.recordSubject(RemoveImageLayerCommand);
1423
+ this.recordSubject(AddImageLayerCommand);
1364
1424
  this.recordSubject(RemoveTileCommand);
1365
1425
  this.recordSubject(MapClickEvent);
1366
1426
  this.recordSubject(CloseTooltipCommand);
@@ -2172,6 +2232,470 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImpo
2172
2232
  type: Input
2173
2233
  }] } });
2174
2234
 
2235
+ class ImageLayerSettings {
2236
+ constructor() {
2237
+ /**
2238
+ * Represents the tiles URL.
2239
+ * @typedef {string} url
2240
+ *
2241
+ * @example
2242
+ * 'https://example.ex/{z}/{x}/{y}.png'
2243
+ */
2244
+ this.url = '';
2245
+ /**
2246
+ * Use interpolated values when resampling.
2247
+ * By default, linear interpolation is used when resampling.
2248
+ * Set to false to use the nearest neighbor instead.
2249
+ */
2250
+ this.interpolate = undefined;
2251
+ /**
2252
+ * The projection of the coordinate system.
2253
+ *
2254
+ * @type {string}
2255
+ * @default 'EPSG:3857'
2256
+ */
2257
+ this.projection = 'EPSG:3857';
2258
+ this.extent = [0, 0, 0, 0];
2259
+ /**
2260
+ * Additional headers that should be added to each tile request
2261
+ *
2262
+ * @type {Record<string, string>}
2263
+ * @default An empty array
2264
+ */
2265
+ this.requestHeaders = null;
2266
+ }
2267
+ /**
2268
+ * Creates a copy of the given tile layer settings.
2269
+ *
2270
+ * @param {ImageLayerSettings} model - The tile layer settings to be copied.
2271
+ * @return {ImageLayerSettings} - A new instance of ImageLayerSettings with the same properties as the model.
2272
+ */
2273
+ static copy(model) {
2274
+ const result = new ImageLayerSettings();
2275
+ result.interpolate = model.interpolate;
2276
+ result.projection = model.projection;
2277
+ result.extent = model.extent;
2278
+ result.url = model.url;
2279
+ result.requestHeaders = model.requestHeaders;
2280
+ return result;
2281
+ }
2282
+ /**
2283
+ * Sets the URL of the ImageLayerSettings object.
2284
+ *
2285
+ * @param {string} url - The URL to be set.
2286
+ * @return {ImageLayerSettings} - The updated ImageLayerSettings object.
2287
+ */
2288
+ setUrl(url) {
2289
+ return ImageLayerSettings.copy(Object.assign(Object.assign({}, this), { url }));
2290
+ }
2291
+ /**
2292
+ * Sets the interpolation state for the image layer settings.
2293
+ *
2294
+ * @param {boolean} [interpolate] - Use interpolated values when resampling.
2295
+ * By default, linear interpolation is used when resampling.
2296
+ * Set to false to use the nearest neighbor instead.
2297
+ * @return {ImageLayerSettings} A new instance of ImageLayerSettings with the updated interpolation setting.
2298
+ */
2299
+ setInterpolate(interpolate) {
2300
+ return ImageLayerSettings.copy(Object.assign(Object.assign({}, this), { interpolate }));
2301
+ }
2302
+ setExtent(extent) {
2303
+ return ImageLayerSettings.copy(Object.assign(Object.assign({}, this), { extent }));
2304
+ }
2305
+ /**
2306
+ * Sets the requestHeaders of the ImageLayerSettings object.
2307
+ *
2308
+ * @param {Record<string, string>} requestHeaders - The headers which should be provided.
2309
+ * @return {ImageLayerSettings} - The updated ImageLayerSettings object.
2310
+ */
2311
+ setRequestHeaders(requestHeaders) {
2312
+ return ImageLayerSettings.copy(Object.assign(Object.assign({}, this), { requestHeaders }));
2313
+ }
2314
+ /**
2315
+ * Sets the maximum zoom level for the tile layer.
2316
+ *
2317
+ * @param {number} maxZoom - The maximum zoom level.
2318
+ * @returns {ImageLayerSettings} - The updated tile layer settings object.
2319
+ */
2320
+ setMaxZoom(maxZoom) {
2321
+ return ImageLayerSettings.copy(Object.assign(Object.assign({}, this), { maxZoom }));
2322
+ }
2323
+ /**
2324
+ * Sets the minimum zoom level for the Tile Layer.
2325
+ *
2326
+ * @param {number} minZoom - The minimum zoom level to be set.
2327
+ * @return {ImageLayerSettings} The modified ImageLayerSettings object with the updated minimum zoom level.
2328
+ */
2329
+ setMinZoom(minZoom) {
2330
+ return ImageLayerSettings.copy(Object.assign(Object.assign({}, this), { minZoom }));
2331
+ }
2332
+ /**
2333
+ * Sets the opacity of the ImageLayerSettings.
2334
+ *
2335
+ * @param {number} opacity - The opacity value to set. Must be a number between 0 and 1.
2336
+ * @return {ImageLayerSettings} - A new instance of ImageLayerSettings with the opacity set.
2337
+ */
2338
+ setOpacity(opacity) {
2339
+ return ImageLayerSettings.copy(Object.assign(Object.assign({}, this), { opacity }));
2340
+ }
2341
+ /**
2342
+ * Sets the projection for the tile layer settings.
2343
+ *
2344
+ * @param {string} projection - The desired projection for the tile layer settings.
2345
+ * @return {ImageLayerSettings} - The updated tile layer settings with the new projection.
2346
+ */
2347
+ setProjection(projection) {
2348
+ return ImageLayerSettings.copy(Object.assign(Object.assign({}, this), { projection }));
2349
+ }
2350
+ /**
2351
+ * Checks if the current instance of ImageLayerSettings is equal to the given model.
2352
+ * @param {ImageLayerSettings} model - The model to compare against.
2353
+ * @return {boolean} - True if all properties of the current instance matches the properties of the model;
2354
+ * otherwise, false.
2355
+ */
2356
+ isSame(model) {
2357
+ if (this.url !== model.url)
2358
+ return false;
2359
+ if (this.projection !== model.projection)
2360
+ return false;
2361
+ if (this.extent !== model.extent)
2362
+ return false;
2363
+ if (this.interpolate !== model.interpolate)
2364
+ return false;
2365
+ if (this.requestHeaders !== model.requestHeaders)
2366
+ return false;
2367
+ return true;
2368
+ }
2369
+ }
2370
+
2371
+ class ImageLayerFactory {
2372
+ build(settings) {
2373
+ const source = new Static({
2374
+ url: settings.url,
2375
+ interpolate: settings.interpolate,
2376
+ crossOrigin: 'Anonymous',
2377
+ projection: get(settings.projection),
2378
+ imageExtent: settings.extent,
2379
+ });
2380
+ return new ImageLayer({ source });
2381
+ }
2382
+ }
2383
+ ImageLayerFactory.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ImageLayerFactory, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
2384
+ ImageLayerFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ImageLayerFactory, providedIn: 'root' });
2385
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ImageLayerFactory, decorators: [{
2386
+ type: Injectable,
2387
+ args: [{
2388
+ providedIn: 'root',
2389
+ }]
2390
+ }] });
2391
+
2392
+ class ImageLayerComponent extends DestructibleComponent {
2393
+ constructor(postboy, factory) {
2394
+ super();
2395
+ this.postboy = postboy;
2396
+ this.factory = factory;
2397
+ this._settings = new ImageLayerSettings();
2398
+ this.onDestroy = () => this.removeLayer();
2399
+ }
2400
+ set settings(value) {
2401
+ if (!value || this._settings.isSame(value))
2402
+ return;
2403
+ this._settings = value;
2404
+ this.initLayer();
2405
+ }
2406
+ ngOnInit() {
2407
+ this.postboy
2408
+ .sub(MapRenderedEvent)
2409
+ .pipe(filter((m) => !!m), first())
2410
+ .subscribe((m) => this.initLayer());
2411
+ }
2412
+ initLayer() {
2413
+ this.removeLayer();
2414
+ this.layer = this.factory.build(this._settings);
2415
+ this.postboy.fire(new AddImageLayerCommand(this.layer));
2416
+ }
2417
+ removeLayer() {
2418
+ if (this.layer)
2419
+ this.postboy.fire(new RemoveImageLayerCommand(this.layer));
2420
+ }
2421
+ }
2422
+ ImageLayerComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ImageLayerComponent, deps: [{ token: MapPostboyService }, { token: ImageLayerFactory }], target: i0.ɵɵFactoryTarget.Component });
2423
+ ImageLayerComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.17", type: ImageLayerComponent, selector: "art-image-layer", inputs: { settings: "settings" }, usesInheritance: true, ngImport: i0, template: '', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
2424
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ImageLayerComponent, decorators: [{
2425
+ type: Component,
2426
+ args: [{
2427
+ selector: 'art-image-layer',
2428
+ template: '',
2429
+ styleUrls: [],
2430
+ changeDetection: ChangeDetectionStrategy.OnPush,
2431
+ }]
2432
+ }], ctorParameters: function () { return [{ type: MapPostboyService }, { type: ImageLayerFactory }]; }, propDecorators: { settings: [{
2433
+ type: Input
2434
+ }] } });
2435
+
2436
+ class RasterTileLayerSettings {
2437
+ constructor() {
2438
+ /**
2439
+ * The maximum zoom level for a map view.
2440
+ *
2441
+ * @type {number}
2442
+ * @default 19
2443
+ */
2444
+ this.maxZoom = 19;
2445
+ /**
2446
+ * The minimum zoom level allowed.
2447
+ *
2448
+ * @type {number}
2449
+ */
2450
+ this.minZoom = 0;
2451
+ /**
2452
+ * The opacity of an element.
2453
+ *
2454
+ * @type {number}
2455
+ * @default 0.6
2456
+ */
2457
+ this.opacity = 0.6;
2458
+ /**
2459
+ * Represents the tiles URL.
2460
+ * @typedef {string} url
2461
+ *
2462
+ * @example
2463
+ * 'https://example.ex/{z}/{x}/{y}.png'
2464
+ */
2465
+ this.url = '';
2466
+ /**
2467
+ * The projection of the coordinate system.
2468
+ *
2469
+ * @type {string}
2470
+ * @default 'EPSG:3857'
2471
+ */
2472
+ this.projection = 'EPSG:3857';
2473
+ /**
2474
+ * Additional headers that should be added to each tile request
2475
+ *
2476
+ * @type {Record<string, string>}
2477
+ * @default An empty array
2478
+ */
2479
+ this.requestHeaders = null;
2480
+ this.operation = (d) => { var _a; return (_a = d[0]) !== null && _a !== void 0 ? _a : []; };
2481
+ }
2482
+ /**
2483
+ * Creates a copy of the given tile layer settings.
2484
+ *
2485
+ * @param {RasterTileLayerSettings} model - The tile layer settings to be copied.
2486
+ * @return {RasterTileLayerSettings} - A new instance of RasterTileLayerSettings with the same properties as the model.
2487
+ */
2488
+ static copy(model) {
2489
+ const result = new RasterTileLayerSettings();
2490
+ result.maxZoom = model.maxZoom;
2491
+ result.minZoom = model.minZoom;
2492
+ result.projection = model.projection;
2493
+ result.opacity = model.opacity;
2494
+ result.url = model.url;
2495
+ result.requestHeaders = model.requestHeaders;
2496
+ result.operation = model.operation;
2497
+ return result;
2498
+ }
2499
+ /**
2500
+ * Sets the URL of the RasterTileLayerSettings object.
2501
+ *
2502
+ * @param {string} url - The URL to be set.
2503
+ * @return {RasterTileLayerSettings} - The updated RasterTileLayerSettings object.
2504
+ */
2505
+ setUrl(url) {
2506
+ return RasterTileLayerSettings.copy(Object.assign(Object.assign({}, this), { url }));
2507
+ }
2508
+ /**
2509
+ * Sets the operation to apply on raster tile data.
2510
+ *
2511
+ * @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.
2512
+ * @return {RasterTileLayerSettings} A new instance of RasterTileLayerSettings with the updated operation.
2513
+ */
2514
+ setOperation(operation) {
2515
+ return RasterTileLayerSettings.copy(Object.assign(Object.assign({}, this), { operation }));
2516
+ }
2517
+ /**
2518
+ * Sets the requestHeaders of the RasterTileLayerSettings object.
2519
+ *
2520
+ * @param {Record<string, string>} requestHeaders - The headers which should be provided.
2521
+ * @return {RasterTileLayerSettings} - The updated RasterTileLayerSettings object.
2522
+ */
2523
+ setRequestHeaders(requestHeaders) {
2524
+ return RasterTileLayerSettings.copy(Object.assign(Object.assign({}, this), { requestHeaders }));
2525
+ }
2526
+ /**
2527
+ * Sets the maximum zoom level for the tile layer.
2528
+ *
2529
+ * @param {number} maxZoom - The maximum zoom level.
2530
+ * @returns {RasterTileLayerSettings} - The updated tile layer settings object.
2531
+ */
2532
+ setMaxZoom(maxZoom) {
2533
+ return RasterTileLayerSettings.copy(Object.assign(Object.assign({}, this), { maxZoom }));
2534
+ }
2535
+ /**
2536
+ * Sets the minimum zoom level for the Tile Layer.
2537
+ *
2538
+ * @param {number} minZoom - The minimum zoom level to be set.
2539
+ * @return {RasterTileLayerSettings} The modified RasterTileLayerSettings object with the updated minimum zoom level.
2540
+ */
2541
+ setMinZoom(minZoom) {
2542
+ return RasterTileLayerSettings.copy(Object.assign(Object.assign({}, this), { minZoom }));
2543
+ }
2544
+ /**
2545
+ * Sets the opacity of the RasterTileLayerSettings.
2546
+ *
2547
+ * @param {number} opacity - The opacity value to set. Must be a number between 0 and 1.
2548
+ * @return {RasterTileLayerSettings} - A new instance of RasterTileLayerSettings with the opacity set.
2549
+ */
2550
+ setOpacity(opacity) {
2551
+ return RasterTileLayerSettings.copy(Object.assign(Object.assign({}, this), { opacity }));
2552
+ }
2553
+ /**
2554
+ * Sets the projection for the tile layer settings.
2555
+ *
2556
+ * @param {string} projection - The desired projection for the tile layer settings.
2557
+ * @return {RasterTileLayerSettings} - The updated tile layer settings with the new projection.
2558
+ */
2559
+ setProjection(projection) {
2560
+ return RasterTileLayerSettings.copy(Object.assign(Object.assign({}, this), { projection }));
2561
+ }
2562
+ /**
2563
+ * Checks if the current instance of RasterTileLayerSettings is equal to the given model.
2564
+ * @param {RasterTileLayerSettings} model - The model to compare against.
2565
+ * @return {boolean} - True if all properties of the current instance matches the properties of the model;
2566
+ * otherwise, false.
2567
+ */
2568
+ isSame(model) {
2569
+ if (this.maxZoom !== model.maxZoom)
2570
+ return false;
2571
+ if (this.minZoom !== model.minZoom)
2572
+ return false;
2573
+ if (this.url !== model.url)
2574
+ return false;
2575
+ if (this.projection !== model.projection)
2576
+ return false;
2577
+ if (this.opacity !== model.opacity)
2578
+ return false;
2579
+ if (this.requestHeaders !== model.requestHeaders)
2580
+ return false;
2581
+ if (this.operation !== model.operation)
2582
+ return false;
2583
+ return true;
2584
+ }
2585
+ }
2586
+
2587
+ class RasterTileLayerFactory {
2588
+ build(settings) {
2589
+ const source = new XYZ({
2590
+ tileSize: 256,
2591
+ maxZoom: settings.maxZoom || 14,
2592
+ minZoom: settings.minZoom || 1,
2593
+ projection: get(settings.projection),
2594
+ tileUrlFunction: this.getTileFunc(settings),
2595
+ crossOrigin: 'Anonymous',
2596
+ tileLoadFunction: !!settings.requestHeaders
2597
+ ? (tile, src) => this.tileLoader(tile, src, settings.requestHeaders)
2598
+ : undefined,
2599
+ });
2600
+ const raster = new RasterSource({
2601
+ sources: [source],
2602
+ operationType: 'image',
2603
+ operation: settings.operation,
2604
+ });
2605
+ return new ImageLayer({ source: raster, opacity: settings.opacity });
2606
+ }
2607
+ getTileFunc(settings) {
2608
+ return (tileCoord) => {
2609
+ const zoom = tileCoord[0];
2610
+ const x = tileCoord[1];
2611
+ const y = tileCoord[2];
2612
+ const normalizedCoord = this.getNormalizedCoord({ x: x, y: y }, zoom);
2613
+ const bound = 1 << zoom;
2614
+ return settings.url
2615
+ .replace('{x}', String((normalizedCoord === null || normalizedCoord === void 0 ? void 0 : normalizedCoord.x) || x))
2616
+ .replace('{z}', String(zoom))
2617
+ .replace('{y}', String(bound - ((normalizedCoord === null || normalizedCoord === void 0 ? void 0 : normalizedCoord.y) || y) - 1));
2618
+ };
2619
+ }
2620
+ tileLoader(tile, src, headers) {
2621
+ const client = new XMLHttpRequest();
2622
+ client.open('GET', src);
2623
+ client.responseType = 'arraybuffer';
2624
+ Object.keys(headers).forEach((k) => client.setRequestHeader(k, headers[k]));
2625
+ client.onload = function () {
2626
+ if (this.response !== undefined) {
2627
+ const arrayBufferView = new Uint8Array(this.response);
2628
+ const blob = new Blob([arrayBufferView], { type: 'image/png' });
2629
+ const urlCreator = window.URL || window.webkitURL;
2630
+ tile.getImage().src = urlCreator.createObjectURL(blob);
2631
+ }
2632
+ };
2633
+ client.send();
2634
+ }
2635
+ getNormalizedCoord(coord, zoom) {
2636
+ const y = coord.y;
2637
+ let x = coord.x;
2638
+ const tileRange = 1 << zoom;
2639
+ if (y < 0 || y >= tileRange)
2640
+ return null;
2641
+ if (x < 0 || x >= tileRange)
2642
+ x = ((x % tileRange) + tileRange) % tileRange;
2643
+ return { x: x, y: y };
2644
+ }
2645
+ }
2646
+ RasterTileLayerFactory.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: RasterTileLayerFactory, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
2647
+ RasterTileLayerFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: RasterTileLayerFactory, providedIn: 'root' });
2648
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: RasterTileLayerFactory, decorators: [{
2649
+ type: Injectable,
2650
+ args: [{
2651
+ providedIn: 'root',
2652
+ }]
2653
+ }] });
2654
+
2655
+ class RasterTileLayerComponent extends DestructibleComponent {
2656
+ constructor(postboy, factory) {
2657
+ super();
2658
+ this.postboy = postboy;
2659
+ this.factory = factory;
2660
+ this._settings = new RasterTileLayerSettings();
2661
+ this.onDestroy = () => this.removeLayer();
2662
+ }
2663
+ set settings(value) {
2664
+ if (!value || this._settings.isSame(value))
2665
+ return;
2666
+ this._settings = value;
2667
+ this.initLayer();
2668
+ }
2669
+ ngOnInit() {
2670
+ this.postboy
2671
+ .sub(MapRenderedEvent)
2672
+ .pipe(filter((m) => !!m), first())
2673
+ .subscribe((m) => this.initLayer());
2674
+ }
2675
+ initLayer() {
2676
+ this.removeLayer();
2677
+ this.layer = this.factory.build(this._settings);
2678
+ this.postboy.fire(new AddRasterTileCommand(this.layer));
2679
+ }
2680
+ removeLayer() {
2681
+ if (this.layer)
2682
+ this.postboy.fire(new RemoveRasterTileCommand(this.layer));
2683
+ }
2684
+ }
2685
+ RasterTileLayerComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: RasterTileLayerComponent, deps: [{ token: MapPostboyService }, { token: RasterTileLayerFactory }], target: i0.ɵɵFactoryTarget.Component });
2686
+ RasterTileLayerComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.17", type: RasterTileLayerComponent, selector: "art-raster-tile-layer", inputs: { settings: "settings" }, usesInheritance: true, ngImport: i0, template: '', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
2687
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: RasterTileLayerComponent, decorators: [{
2688
+ type: Component,
2689
+ args: [{
2690
+ selector: 'art-raster-tile-layer',
2691
+ template: '',
2692
+ styleUrls: [],
2693
+ changeDetection: ChangeDetectionStrategy.OnPush,
2694
+ }]
2695
+ }], ctorParameters: function () { return [{ type: MapPostboyService }, { type: RasterTileLayerFactory }]; }, propDecorators: { settings: [{
2696
+ type: Input
2697
+ }] } });
2698
+
2175
2699
  class MapPlateFactory {
2176
2700
  build(settings) {
2177
2701
  return new Map({
@@ -2675,14 +3199,18 @@ MapModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.
2675
3199
  TooltipComponent,
2676
3200
  PolygonsComponent,
2677
3201
  ClusterLayerComponent,
2678
- MapControlZoomComponent], imports: [CommonModule], exports: [MapPlateComponent,
3202
+ MapControlZoomComponent,
3203
+ ImageLayerComponent,
3204
+ RasterTileLayerComponent], imports: [CommonModule], exports: [MapPlateComponent,
2679
3205
  FeatureLayerComponent,
2680
3206
  MarkersComponent,
2681
3207
  TileLayerComponent,
2682
3208
  TooltipComponent,
2683
3209
  PolygonsComponent,
2684
3210
  ClusterLayerComponent,
2685
- MapControlZoomComponent] });
3211
+ MapControlZoomComponent,
3212
+ ImageLayerComponent,
3213
+ RasterTileLayerComponent] });
2686
3214
  MapModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MapModule, imports: [[CommonModule]] });
2687
3215
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MapModule, decorators: [{
2688
3216
  type: NgModule,
@@ -2699,6 +3227,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImpo
2699
3227
  PolygonsComponent,
2700
3228
  ClusterLayerComponent,
2701
3229
  MapControlZoomComponent,
3230
+ ImageLayerComponent,
3231
+ RasterTileLayerComponent,
2702
3232
  ],
2703
3233
  exports: [
2704
3234
  MapPlateComponent,
@@ -2709,6 +3239,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImpo
2709
3239
  PolygonsComponent,
2710
3240
  ClusterLayerComponent,
2711
3241
  MapControlZoomComponent,
3242
+ ImageLayerComponent,
3243
+ RasterTileLayerComponent,
2712
3244
  ],
2713
3245
  }]
2714
3246
  }] });
@@ -2905,5 +3437,5 @@ class StringifyFeatureHelper {
2905
3437
  * Generated bundle index. Do not edit.
2906
3438
  */
2907
3439
 
2908
- 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 };
3440
+ 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 };
2909
3441
  //# sourceMappingURL=maps-components-src-map.js.map