@artstesh/maps 4.1.26 → 4.1.28

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 (72) hide show
  1. package/dist/esm2020/map/map-plate/layers/image-layer/image-layer-factory.mjs +26 -0
  2. package/dist/esm2020/map/map-plate/layers/image-layer/image-layer.component.mjs +49 -0
  3. package/dist/esm2020/map/map-plate/layers/image-layer/image-layer.settings.mjs +136 -0
  4. package/dist/esm2020/map/map-plate/layers/index.mjs +5 -1
  5. package/dist/esm2020/map/map-plate/layers/raster-tile/raster-tile-layer.component.mjs +49 -0
  6. package/dist/esm2020/map/map-plate/layers/raster-tile/raster-tile-layer.factory.mjs +74 -0
  7. package/dist/esm2020/map/map-plate/layers/raster-tile/raster-tile-layer.settings.mjs +151 -0
  8. package/dist/esm2020/map/map.module.mjs +13 -3
  9. package/dist/esm2020/map/messages/commands/add-image-layer.command.mjs +9 -0
  10. package/dist/esm2020/map/messages/commands/add-raster-tile-command.mjs +9 -0
  11. package/dist/esm2020/map/messages/commands/remove-image-layer.command.mjs +9 -0
  12. package/dist/esm2020/map/messages/commands/remove-raster-tile.command.mjs +9 -0
  13. package/dist/esm2020/map/ol-proxy.mjs +3 -0
  14. package/dist/esm2020/map/public-api.mjs +2 -2
  15. package/dist/esm2020/map/services/map-management.service.mjs +32 -8
  16. package/dist/esm2020/map/services/message-registrator.service.mjs +9 -1
  17. package/dist/esm2020/src/map/map-plate/layers/image-layer/image-layer-factory.mjs +26 -0
  18. package/dist/esm2020/src/map/map-plate/layers/image-layer/image-layer.component.mjs +49 -0
  19. package/dist/esm2020/src/map/map-plate/layers/image-layer/image-layer.settings.mjs +136 -0
  20. package/dist/esm2020/src/map/map-plate/layers/index.mjs +5 -1
  21. package/dist/esm2020/src/map/map-plate/layers/raster-tile/raster-tile-layer.component.mjs +49 -0
  22. package/dist/esm2020/src/map/map-plate/layers/raster-tile/raster-tile-layer.factory.mjs +74 -0
  23. package/dist/esm2020/src/map/map-plate/layers/raster-tile/raster-tile-layer.settings.mjs +151 -0
  24. package/dist/esm2020/src/map/map.module.mjs +13 -3
  25. package/dist/esm2020/src/map/messages/commands/add-image-layer.command.mjs +9 -0
  26. package/dist/esm2020/src/map/messages/commands/add-raster-tile-command.mjs +9 -0
  27. package/dist/esm2020/src/map/messages/commands/remove-image-layer.command.mjs +9 -0
  28. package/dist/esm2020/src/map/messages/commands/remove-raster-tile.command.mjs +9 -0
  29. package/dist/esm2020/src/map/ol-proxy.mjs +3 -0
  30. package/dist/esm2020/src/map/public-api.mjs +2 -2
  31. package/dist/esm2020/src/map/services/map-management.service.mjs +32 -8
  32. package/dist/esm2020/src/map/services/message-registrator.service.mjs +9 -1
  33. package/dist/fesm2015/maps-components-src-map.mjs +532 -10
  34. package/dist/fesm2015/maps-components-src-map.mjs.map +1 -1
  35. package/dist/fesm2015/maps-components.mjs +532 -10
  36. package/dist/fesm2015/maps-components.mjs.map +1 -1
  37. package/dist/fesm2020/maps-components-src-map.mjs +532 -10
  38. package/dist/fesm2020/maps-components-src-map.mjs.map +1 -1
  39. package/dist/fesm2020/maps-components.mjs +532 -10
  40. package/dist/fesm2020/maps-components.mjs.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/package.json +1 -1
  57. package/dist/src/map/map-plate/layers/image-layer/image-layer-factory.d.ts +9 -0
  58. package/dist/src/map/map-plate/layers/image-layer/image-layer.component.d.ts +22 -0
  59. package/dist/src/map/map-plate/layers/image-layer/image-layer.settings.d.ts +97 -0
  60. package/dist/src/map/map-plate/layers/index.d.ts +4 -0
  61. package/dist/src/map/map-plate/layers/raster-tile/raster-tile-layer.component.d.ts +21 -0
  62. package/dist/src/map/map-plate/layers/raster-tile/raster-tile-layer.factory.d.ts +12 -0
  63. package/dist/src/map/map-plate/layers/raster-tile/raster-tile-layer.settings.d.ts +108 -0
  64. package/dist/src/map/map.module.d.ts +4 -2
  65. package/dist/src/map/messages/commands/add-image-layer.command.d.ts +8 -0
  66. package/dist/src/map/messages/commands/add-raster-tile-command.d.ts +8 -0
  67. package/dist/src/map/messages/commands/remove-image-layer.command.d.ts +8 -0
  68. package/dist/src/map/messages/commands/remove-raster-tile.command.d.ts +8 -0
  69. package/dist/src/map/ol-proxy.d.ts +3 -0
  70. package/dist/src/map/public-api.d.ts +1 -1
  71. package/dist/src/map/services/map-management.service.d.ts +1 -1
  72. package/package.json +2 -2
@@ -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';
@@ -866,6 +870,38 @@ class ZoomControlFactory {
866
870
  }
867
871
  }
868
872
 
873
+ class AddImageLayerCommand extends PostboyGenericMessage {
874
+ constructor(layer) {
875
+ super();
876
+ this.layer = layer;
877
+ }
878
+ }
879
+ AddImageLayerCommand.ID = '70f9b86f-8bc2-4f28-ae79-a13fc0b1ee5d';
880
+
881
+ class RemoveImageLayerCommand extends PostboyGenericMessage {
882
+ constructor(layer) {
883
+ super();
884
+ this.layer = layer;
885
+ }
886
+ }
887
+ RemoveImageLayerCommand.ID = 'c8e7efdb-17ff-4cf9-89be-e688b8de3b95';
888
+
889
+ class AddRasterTileCommand extends PostboyGenericMessage {
890
+ constructor(layer) {
891
+ super();
892
+ this.layer = layer;
893
+ }
894
+ }
895
+ AddRasterTileCommand.ID = 'd33447fe-eec0-4205-9b5d-0d79ddc74ad7';
896
+
897
+ class RemoveRasterTileCommand extends PostboyGenericMessage {
898
+ constructor(layer) {
899
+ super();
900
+ this.layer = layer;
901
+ }
902
+ }
903
+ RemoveRasterTileCommand.ID = 'd1c4bf6a-e2f2-4385-a7a2-cecb525f8939';
904
+
869
905
  class MapPostboyService extends PostboyService {
870
906
  constructor() {
871
907
  super();
@@ -893,27 +929,47 @@ class MapManagementService {
893
929
  this.observeRemoveLayer();
894
930
  this.observePlaceFeatures();
895
931
  this.observeAddTile();
896
- this.observeRemoveTile();
897
932
  this.observeLayerQuery();
898
933
  this.observeFeaturesInArea();
899
934
  this.observeFeaturesInPoint();
935
+ this.observeImageLayer();
936
+ }
937
+ observeLayerQuery() {
938
+ this.postboy.sub(GetLayerQuery).subscribe((ev) => ev.finish(this.layers.take(ev.name)));
900
939
  }
901
- observeRemoveTile() {
940
+ observeAddTile() {
941
+ this.postboy.sub(AddTileCommand).subscribe((c) => {
942
+ if (!this.map)
943
+ return;
944
+ this.map.addLayer(c.layer);
945
+ });
902
946
  this.postboy.sub(RemoveTileCommand).subscribe((c) => {
903
947
  if (!this.map)
904
948
  return;
905
949
  this.map.removeLayer(c.layer);
906
950
  });
951
+ this.postboy.sub(AddRasterTileCommand).subscribe((c) => {
952
+ if (!this.map)
953
+ return;
954
+ this.map.addLayer(c.layer);
955
+ });
956
+ this.postboy.sub(RemoveRasterTileCommand).subscribe((c) => {
957
+ if (!this.map)
958
+ return;
959
+ this.map.removeLayer(c.layer);
960
+ });
907
961
  }
908
- observeLayerQuery() {
909
- this.postboy.sub(GetLayerQuery).subscribe((ev) => ev.finish(this.layers.take(ev.name)));
910
- }
911
- observeAddTile() {
912
- this.postboy.sub(AddTileCommand).subscribe((c) => {
962
+ observeImageLayer() {
963
+ this.postboy.sub(AddImageLayerCommand).subscribe((c) => {
913
964
  if (!this.map)
914
965
  return;
915
966
  this.map.addLayer(c.layer);
916
967
  });
968
+ this.postboy.sub(RemoveImageLayerCommand).subscribe((c) => {
969
+ if (!this.map)
970
+ return;
971
+ this.map.removeLayer(c.layer);
972
+ });
917
973
  }
918
974
  observeMapRender() {
919
975
  this.postboy.sub(MapRenderedEvent).subscribe((m) => {
@@ -1345,6 +1401,10 @@ class MessageRegistratorService extends PostboyAbstractRegistrator {
1345
1401
  this.recordSubject(AddLayerCommand);
1346
1402
  this.recordSubject(RemoveLayerCommand);
1347
1403
  this.recordSubject(AddTileCommand);
1404
+ this.recordSubject(AddRasterTileCommand);
1405
+ this.recordSubject(RemoveRasterTileCommand);
1406
+ this.recordSubject(RemoveImageLayerCommand);
1407
+ this.recordSubject(AddImageLayerCommand);
1348
1408
  this.recordSubject(RemoveTileCommand);
1349
1409
  this.recordSubject(MapClickEvent);
1350
1410
  this.recordSubject(CloseTooltipCommand);
@@ -2131,6 +2191,460 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImpo
2131
2191
  type: Input
2132
2192
  }] } });
2133
2193
 
2194
+ class ImageLayerSettings {
2195
+ constructor() {
2196
+ /**
2197
+ * Represents the tiles URL.
2198
+ * @typedef {string} url
2199
+ *
2200
+ * @example
2201
+ * 'https://example.ex/{z}/{x}/{y}.png'
2202
+ */
2203
+ this.url = '';
2204
+ /**
2205
+ * Use interpolated values when resampling.
2206
+ * By default, linear interpolation is used when resampling.
2207
+ * Set to false to use the nearest neighbor instead.
2208
+ */
2209
+ this.interpolate = undefined;
2210
+ /**
2211
+ * The projection of the coordinate system.
2212
+ *
2213
+ * @type {string}
2214
+ * @default 'EPSG:3857'
2215
+ */
2216
+ this.projection = 'EPSG:3857';
2217
+ this.extent = [0, 0, 0, 0];
2218
+ /**
2219
+ * Additional headers that should be added to each tile request
2220
+ *
2221
+ * @type {Record<string, string>}
2222
+ * @default An empty array
2223
+ */
2224
+ this.requestHeaders = null;
2225
+ }
2226
+ /**
2227
+ * Creates a copy of the given tile layer settings.
2228
+ *
2229
+ * @param {ImageLayerSettings} model - The tile layer settings to be copied.
2230
+ * @return {ImageLayerSettings} - A new instance of ImageLayerSettings with the same properties as the model.
2231
+ */
2232
+ static copy(model) {
2233
+ const result = new ImageLayerSettings();
2234
+ result.interpolate = model.interpolate;
2235
+ result.projection = model.projection;
2236
+ result.extent = model.extent;
2237
+ result.url = model.url;
2238
+ result.requestHeaders = model.requestHeaders;
2239
+ return result;
2240
+ }
2241
+ /**
2242
+ * Sets the URL of the ImageLayerSettings object.
2243
+ *
2244
+ * @param {string} url - The URL to be set.
2245
+ * @return {ImageLayerSettings} - The updated ImageLayerSettings object.
2246
+ */
2247
+ setUrl(url) {
2248
+ return ImageLayerSettings.copy({ ...this, url });
2249
+ }
2250
+ /**
2251
+ * Sets the interpolation state for the image layer settings.
2252
+ *
2253
+ * @param {boolean} [interpolate] - Use interpolated values when resampling.
2254
+ * By default, linear interpolation is used when resampling.
2255
+ * Set to false to use the nearest neighbor instead.
2256
+ * @return {ImageLayerSettings} A new instance of ImageLayerSettings with the updated interpolation setting.
2257
+ */
2258
+ setInterpolate(interpolate) {
2259
+ return ImageLayerSettings.copy({ ...this, interpolate });
2260
+ }
2261
+ setExtent(extent) {
2262
+ return ImageLayerSettings.copy({ ...this, extent });
2263
+ }
2264
+ /**
2265
+ * Sets the requestHeaders of the ImageLayerSettings object.
2266
+ *
2267
+ * @param {Record<string, string>} requestHeaders - The headers which should be provided.
2268
+ * @return {ImageLayerSettings} - The updated ImageLayerSettings object.
2269
+ */
2270
+ setRequestHeaders(requestHeaders) {
2271
+ return ImageLayerSettings.copy({ ...this, requestHeaders });
2272
+ }
2273
+ /**
2274
+ * Sets the maximum zoom level for the tile layer.
2275
+ *
2276
+ * @param {number} maxZoom - The maximum zoom level.
2277
+ * @returns {ImageLayerSettings} - The updated tile layer settings object.
2278
+ */
2279
+ setMaxZoom(maxZoom) {
2280
+ return ImageLayerSettings.copy({ ...this, maxZoom });
2281
+ }
2282
+ /**
2283
+ * Sets the minimum zoom level for the Tile Layer.
2284
+ *
2285
+ * @param {number} minZoom - The minimum zoom level to be set.
2286
+ * @return {ImageLayerSettings} The modified ImageLayerSettings object with the updated minimum zoom level.
2287
+ */
2288
+ setMinZoom(minZoom) {
2289
+ return ImageLayerSettings.copy({ ...this, minZoom });
2290
+ }
2291
+ /**
2292
+ * Sets the opacity of the ImageLayerSettings.
2293
+ *
2294
+ * @param {number} opacity - The opacity value to set. Must be a number between 0 and 1.
2295
+ * @return {ImageLayerSettings} - A new instance of ImageLayerSettings with the opacity set.
2296
+ */
2297
+ setOpacity(opacity) {
2298
+ return ImageLayerSettings.copy({ ...this, opacity });
2299
+ }
2300
+ /**
2301
+ * Sets the projection for the tile layer settings.
2302
+ *
2303
+ * @param {string} projection - The desired projection for the tile layer settings.
2304
+ * @return {ImageLayerSettings} - The updated tile layer settings with the new projection.
2305
+ */
2306
+ setProjection(projection) {
2307
+ return ImageLayerSettings.copy({ ...this, projection });
2308
+ }
2309
+ /**
2310
+ * Checks if the current instance of ImageLayerSettings is equal to the given model.
2311
+ * @param {ImageLayerSettings} model - The model to compare against.
2312
+ * @return {boolean} - True if all properties of the current instance matches the properties of the model;
2313
+ * otherwise, false.
2314
+ */
2315
+ isSame(model) {
2316
+ if (this.url !== model.url)
2317
+ return false;
2318
+ if (this.projection !== model.projection)
2319
+ return false;
2320
+ if (this.extent !== model.extent)
2321
+ return false;
2322
+ if (this.interpolate !== model.interpolate)
2323
+ return false;
2324
+ if (this.requestHeaders !== model.requestHeaders)
2325
+ return false;
2326
+ return true;
2327
+ }
2328
+ }
2329
+
2330
+ class ImageLayerFactory {
2331
+ build(settings) {
2332
+ const source = new Static({
2333
+ url: settings.url,
2334
+ interpolate: settings.interpolate,
2335
+ crossOrigin: 'Anonymous',
2336
+ projection: get(settings.projection),
2337
+ imageExtent: settings.extent,
2338
+ });
2339
+ return new ImageLayer({ source });
2340
+ }
2341
+ }
2342
+ ImageLayerFactory.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: ImageLayerFactory, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
2343
+ ImageLayerFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: ImageLayerFactory, providedIn: 'root' });
2344
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: ImageLayerFactory, decorators: [{
2345
+ type: Injectable,
2346
+ args: [{
2347
+ providedIn: 'root',
2348
+ }]
2349
+ }] });
2350
+
2351
+ class ImageLayerComponent extends DestructibleComponent {
2352
+ constructor(postboy, factory) {
2353
+ super();
2354
+ this.postboy = postboy;
2355
+ this.factory = factory;
2356
+ this._settings = new ImageLayerSettings();
2357
+ this.onDestroy = () => this.removeLayer();
2358
+ }
2359
+ set settings(value) {
2360
+ if (!value || this._settings.isSame(value))
2361
+ return;
2362
+ this._settings = value;
2363
+ this.initLayer();
2364
+ }
2365
+ ngOnInit() {
2366
+ this.postboy
2367
+ .sub(MapRenderedEvent)
2368
+ .pipe(filter((m) => !!m), first())
2369
+ .subscribe((m) => this.initLayer());
2370
+ }
2371
+ initLayer() {
2372
+ this.removeLayer();
2373
+ this.layer = this.factory.build(this._settings);
2374
+ this.postboy.fire(new AddImageLayerCommand(this.layer));
2375
+ }
2376
+ removeLayer() {
2377
+ if (this.layer)
2378
+ this.postboy.fire(new RemoveImageLayerCommand(this.layer));
2379
+ }
2380
+ }
2381
+ ImageLayerComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: ImageLayerComponent, deps: [{ token: MapPostboyService }, { token: ImageLayerFactory }], target: i0.ɵɵFactoryTarget.Component });
2382
+ ImageLayerComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.10", type: ImageLayerComponent, selector: "art-image-layer", inputs: { settings: "settings" }, usesInheritance: true, ngImport: i0, template: '', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
2383
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: ImageLayerComponent, decorators: [{
2384
+ type: Component,
2385
+ args: [{ selector: 'art-image-layer', template: '', changeDetection: ChangeDetectionStrategy.OnPush }]
2386
+ }], ctorParameters: function () { return [{ type: MapPostboyService }, { type: ImageLayerFactory }]; }, propDecorators: { settings: [{
2387
+ type: Input
2388
+ }] } });
2389
+
2390
+ class RasterTileLayerSettings {
2391
+ constructor() {
2392
+ /**
2393
+ * The maximum zoom level for a map view.
2394
+ *
2395
+ * @type {number}
2396
+ * @default 19
2397
+ */
2398
+ this.maxZoom = 19;
2399
+ /**
2400
+ * The minimum zoom level allowed.
2401
+ *
2402
+ * @type {number}
2403
+ */
2404
+ this.minZoom = 0;
2405
+ /**
2406
+ * The opacity of an element.
2407
+ *
2408
+ * @type {number}
2409
+ * @default 0.6
2410
+ */
2411
+ this.opacity = 0.6;
2412
+ /**
2413
+ * Represents the tiles URL.
2414
+ * @typedef {string} url
2415
+ *
2416
+ * @example
2417
+ * 'https://example.ex/{z}/{x}/{y}.png'
2418
+ */
2419
+ this.url = '';
2420
+ /**
2421
+ * The projection of the coordinate system.
2422
+ *
2423
+ * @type {string}
2424
+ * @default 'EPSG:3857'
2425
+ */
2426
+ this.projection = 'EPSG:3857';
2427
+ /**
2428
+ * Additional headers that should be added to each tile request
2429
+ *
2430
+ * @type {Record<string, string>}
2431
+ * @default An empty array
2432
+ */
2433
+ this.requestHeaders = null;
2434
+ this.operation = (d) => d[0] ?? [];
2435
+ }
2436
+ /**
2437
+ * Creates a copy of the given tile layer settings.
2438
+ *
2439
+ * @param {RasterTileLayerSettings} model - The tile layer settings to be copied.
2440
+ * @return {RasterTileLayerSettings} - A new instance of RasterTileLayerSettings with the same properties as the model.
2441
+ */
2442
+ static copy(model) {
2443
+ const result = new RasterTileLayerSettings();
2444
+ result.maxZoom = model.maxZoom;
2445
+ result.minZoom = model.minZoom;
2446
+ result.projection = model.projection;
2447
+ result.opacity = model.opacity;
2448
+ result.url = model.url;
2449
+ result.requestHeaders = model.requestHeaders;
2450
+ result.operation = model.operation;
2451
+ return result;
2452
+ }
2453
+ /**
2454
+ * Sets the URL of the RasterTileLayerSettings object.
2455
+ *
2456
+ * @param {string} url - The URL to be set.
2457
+ * @return {RasterTileLayerSettings} - The updated RasterTileLayerSettings object.
2458
+ */
2459
+ setUrl(url) {
2460
+ return RasterTileLayerSettings.copy({ ...this, url });
2461
+ }
2462
+ /**
2463
+ * Sets the operation to apply on raster tile data.
2464
+ *
2465
+ * @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.
2466
+ * @return {RasterTileLayerSettings} A new instance of RasterTileLayerSettings with the updated operation.
2467
+ */
2468
+ setOperation(operation) {
2469
+ return RasterTileLayerSettings.copy({ ...this, operation });
2470
+ }
2471
+ /**
2472
+ * Sets the requestHeaders of the RasterTileLayerSettings object.
2473
+ *
2474
+ * @param {Record<string, string>} requestHeaders - The headers which should be provided.
2475
+ * @return {RasterTileLayerSettings} - The updated RasterTileLayerSettings object.
2476
+ */
2477
+ setRequestHeaders(requestHeaders) {
2478
+ return RasterTileLayerSettings.copy({ ...this, requestHeaders });
2479
+ }
2480
+ /**
2481
+ * Sets the maximum zoom level for the tile layer.
2482
+ *
2483
+ * @param {number} maxZoom - The maximum zoom level.
2484
+ * @returns {RasterTileLayerSettings} - The updated tile layer settings object.
2485
+ */
2486
+ setMaxZoom(maxZoom) {
2487
+ return RasterTileLayerSettings.copy({ ...this, maxZoom });
2488
+ }
2489
+ /**
2490
+ * Sets the minimum zoom level for the Tile Layer.
2491
+ *
2492
+ * @param {number} minZoom - The minimum zoom level to be set.
2493
+ * @return {RasterTileLayerSettings} The modified RasterTileLayerSettings object with the updated minimum zoom level.
2494
+ */
2495
+ setMinZoom(minZoom) {
2496
+ return RasterTileLayerSettings.copy({ ...this, minZoom });
2497
+ }
2498
+ /**
2499
+ * Sets the opacity of the RasterTileLayerSettings.
2500
+ *
2501
+ * @param {number} opacity - The opacity value to set. Must be a number between 0 and 1.
2502
+ * @return {RasterTileLayerSettings} - A new instance of RasterTileLayerSettings with the opacity set.
2503
+ */
2504
+ setOpacity(opacity) {
2505
+ return RasterTileLayerSettings.copy({ ...this, opacity });
2506
+ }
2507
+ /**
2508
+ * Sets the projection for the tile layer settings.
2509
+ *
2510
+ * @param {string} projection - The desired projection for the tile layer settings.
2511
+ * @return {RasterTileLayerSettings} - The updated tile layer settings with the new projection.
2512
+ */
2513
+ setProjection(projection) {
2514
+ return RasterTileLayerSettings.copy({ ...this, projection });
2515
+ }
2516
+ /**
2517
+ * Checks if the current instance of RasterTileLayerSettings is equal to the given model.
2518
+ * @param {RasterTileLayerSettings} model - The model to compare against.
2519
+ * @return {boolean} - True if all properties of the current instance matches the properties of the model;
2520
+ * otherwise, false.
2521
+ */
2522
+ isSame(model) {
2523
+ if (this.maxZoom !== model.maxZoom)
2524
+ return false;
2525
+ if (this.minZoom !== model.minZoom)
2526
+ return false;
2527
+ if (this.url !== model.url)
2528
+ return false;
2529
+ if (this.projection !== model.projection)
2530
+ return false;
2531
+ if (this.opacity !== model.opacity)
2532
+ return false;
2533
+ if (this.requestHeaders !== model.requestHeaders)
2534
+ return false;
2535
+ if (this.operation !== model.operation)
2536
+ return false;
2537
+ return true;
2538
+ }
2539
+ }
2540
+
2541
+ class RasterTileLayerFactory {
2542
+ build(settings) {
2543
+ const source = new XYZ({
2544
+ tileSize: 256,
2545
+ maxZoom: settings.maxZoom || 14,
2546
+ minZoom: settings.minZoom || 1,
2547
+ projection: get(settings.projection),
2548
+ tileUrlFunction: this.getTileFunc(settings),
2549
+ crossOrigin: 'Anonymous',
2550
+ tileLoadFunction: !!settings.requestHeaders
2551
+ ? (tile, src) => this.tileLoader(tile, src, settings.requestHeaders)
2552
+ : undefined,
2553
+ });
2554
+ const raster = new RasterSource({
2555
+ sources: [source],
2556
+ operationType: 'image',
2557
+ operation: settings.operation,
2558
+ });
2559
+ return new ImageLayer({ source: raster, opacity: settings.opacity });
2560
+ }
2561
+ getTileFunc(settings) {
2562
+ return (tileCoord) => {
2563
+ const zoom = tileCoord[0];
2564
+ const x = tileCoord[1];
2565
+ const y = tileCoord[2];
2566
+ const normalizedCoord = this.getNormalizedCoord({ x: x, y: y }, zoom);
2567
+ const bound = 1 << zoom;
2568
+ return settings.url
2569
+ .replace('{x}', String(normalizedCoord?.x || x))
2570
+ .replace('{z}', String(zoom))
2571
+ .replace('{y}', String(bound - (normalizedCoord?.y || y) - 1));
2572
+ };
2573
+ }
2574
+ tileLoader(tile, src, headers) {
2575
+ const client = new XMLHttpRequest();
2576
+ client.open('GET', src);
2577
+ client.responseType = 'arraybuffer';
2578
+ Object.keys(headers).forEach((k) => client.setRequestHeader(k, headers[k]));
2579
+ client.onload = function () {
2580
+ if (this.response !== undefined) {
2581
+ const arrayBufferView = new Uint8Array(this.response);
2582
+ const blob = new Blob([arrayBufferView], { type: 'image/png' });
2583
+ const urlCreator = window.URL || window.webkitURL;
2584
+ tile.getImage().src = urlCreator.createObjectURL(blob);
2585
+ }
2586
+ };
2587
+ client.send();
2588
+ }
2589
+ getNormalizedCoord(coord, zoom) {
2590
+ const y = coord.y;
2591
+ let x = coord.x;
2592
+ const tileRange = 1 << zoom;
2593
+ if (y < 0 || y >= tileRange)
2594
+ return null;
2595
+ if (x < 0 || x >= tileRange)
2596
+ x = ((x % tileRange) + tileRange) % tileRange;
2597
+ return { x: x, y: y };
2598
+ }
2599
+ }
2600
+ RasterTileLayerFactory.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: RasterTileLayerFactory, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
2601
+ RasterTileLayerFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: RasterTileLayerFactory, providedIn: 'root' });
2602
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: RasterTileLayerFactory, decorators: [{
2603
+ type: Injectable,
2604
+ args: [{
2605
+ providedIn: 'root',
2606
+ }]
2607
+ }] });
2608
+
2609
+ class RasterTileLayerComponent extends DestructibleComponent {
2610
+ constructor(postboy, factory) {
2611
+ super();
2612
+ this.postboy = postboy;
2613
+ this.factory = factory;
2614
+ this._settings = new RasterTileLayerSettings();
2615
+ this.onDestroy = () => this.removeLayer();
2616
+ }
2617
+ set settings(value) {
2618
+ if (!value || this._settings.isSame(value))
2619
+ return;
2620
+ this._settings = value;
2621
+ this.initLayer();
2622
+ }
2623
+ ngOnInit() {
2624
+ this.postboy
2625
+ .sub(MapRenderedEvent)
2626
+ .pipe(filter((m) => !!m), first())
2627
+ .subscribe((m) => this.initLayer());
2628
+ }
2629
+ initLayer() {
2630
+ this.removeLayer();
2631
+ this.layer = this.factory.build(this._settings);
2632
+ this.postboy.fire(new AddRasterTileCommand(this.layer));
2633
+ }
2634
+ removeLayer() {
2635
+ if (this.layer)
2636
+ this.postboy.fire(new RemoveRasterTileCommand(this.layer));
2637
+ }
2638
+ }
2639
+ RasterTileLayerComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: RasterTileLayerComponent, deps: [{ token: MapPostboyService }, { token: RasterTileLayerFactory }], target: i0.ɵɵFactoryTarget.Component });
2640
+ RasterTileLayerComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.10", type: RasterTileLayerComponent, selector: "art-raster-tile-layer", inputs: { settings: "settings" }, usesInheritance: true, ngImport: i0, template: '', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
2641
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: RasterTileLayerComponent, decorators: [{
2642
+ type: Component,
2643
+ args: [{ selector: 'art-raster-tile-layer', template: '', changeDetection: ChangeDetectionStrategy.OnPush }]
2644
+ }], ctorParameters: function () { return [{ type: MapPostboyService }, { type: RasterTileLayerFactory }]; }, propDecorators: { settings: [{
2645
+ type: Input
2646
+ }] } });
2647
+
2134
2648
  class MapPlateFactory {
2135
2649
  build(settings) {
2136
2650
  return new Map({
@@ -2605,14 +3119,18 @@ MapModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.
2605
3119
  TooltipComponent,
2606
3120
  PolygonsComponent,
2607
3121
  ClusterLayerComponent,
2608
- MapControlZoomComponent], imports: [CommonModule], exports: [MapPlateComponent,
3122
+ MapControlZoomComponent,
3123
+ ImageLayerComponent,
3124
+ RasterTileLayerComponent], imports: [CommonModule], exports: [MapPlateComponent,
2609
3125
  FeatureLayerComponent,
2610
3126
  MarkersComponent,
2611
3127
  TileLayerComponent,
2612
3128
  TooltipComponent,
2613
3129
  PolygonsComponent,
2614
3130
  ClusterLayerComponent,
2615
- MapControlZoomComponent] });
3131
+ MapControlZoomComponent,
3132
+ ImageLayerComponent,
3133
+ RasterTileLayerComponent] });
2616
3134
  MapModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapModule, imports: [CommonModule] });
2617
3135
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: MapModule, decorators: [{
2618
3136
  type: NgModule,
@@ -2629,6 +3147,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImpo
2629
3147
  PolygonsComponent,
2630
3148
  ClusterLayerComponent,
2631
3149
  MapControlZoomComponent,
3150
+ ImageLayerComponent,
3151
+ RasterTileLayerComponent,
2632
3152
  ],
2633
3153
  exports: [
2634
3154
  MapPlateComponent,
@@ -2639,6 +3159,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImpo
2639
3159
  PolygonsComponent,
2640
3160
  ClusterLayerComponent,
2641
3161
  MapControlZoomComponent,
3162
+ ImageLayerComponent,
3163
+ RasterTileLayerComponent,
2642
3164
  ],
2643
3165
  }]
2644
3166
  }] });
@@ -2839,5 +3361,5 @@ class StringifyFeatureHelper {
2839
3361
  * Generated bundle index. Do not edit.
2840
3362
  */
2841
3363
 
2842
- 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 };
3364
+ 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 };
2843
3365
  //# sourceMappingURL=maps-components.mjs.map