@artstesh/maps 8.2.0 → 8.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -9,3 +9,10 @@ The main purpose of the project is to make easier the process of using of [openl
9
9
  ### License
10
10
 
11
11
  This project is licensed under the MIT License
12
+
13
+ ### Support status
14
+
15
+ This line targets Angular 19, which is end-of-life, and is **archived**: it receives no
16
+ further features, fixes, ports, or releases. Migrate to a supported Angular major and
17
+ install the matching `@artstesh/maps` line - see the version support table at
18
+ https://maps.artstesh.ru.
@@ -17,7 +17,7 @@ import { createRegularPolygon, createBox } from 'ol/interaction/Draw';
17
17
  import { Subject, combineLatest } from 'rxjs';
18
18
  import { first, debounceTime, filter, auditTime } from 'rxjs/operators';
19
19
  import { Dictionary } from '@artstesh/collections';
20
- import { Vector, XYZ } from 'ol/source';
20
+ import { Vector, XYZ, GeoTIFF } from 'ol/source';
21
21
  import TileLayer from 'ol/layer/Tile';
22
22
  import OSM from 'ol/source/OSM';
23
23
  import { Vector as Vector$1 } from 'ol/layer';
@@ -26,6 +26,7 @@ import Cluster from 'ol/source/Cluster';
26
26
  import Static from 'ol/source/ImageStatic';
27
27
  import ImageLayer from 'ol/layer/Image';
28
28
  import RasterSource from 'ol/source/Raster';
29
+ import TileLayer$1 from 'ol/layer/WebGLTile';
29
30
  import { NgIf, NgTemplateOutlet } from '@angular/common';
30
31
  import Map from 'ol/Map';
31
32
  import View from 'ol/View';
@@ -997,6 +998,24 @@ class RemoveRasterTileCommand extends PostboyGenericMessage {
997
998
  }
998
999
  }
999
1000
 
1001
+ class RemoveGeotiffTileCommand extends PostboyGenericMessage {
1002
+ layer;
1003
+ static ID = '5545a521-62c4-4b25-a555-ee264258799b';
1004
+ constructor(layer) {
1005
+ super();
1006
+ this.layer = layer;
1007
+ }
1008
+ }
1009
+
1010
+ class AddGeotiffTileCommand extends PostboyGenericMessage {
1011
+ layer;
1012
+ static ID = '80e1b7be-09cd-43de-b11c-e0699a91b287';
1013
+ constructor(layer) {
1014
+ super();
1015
+ this.layer = layer;
1016
+ }
1017
+ }
1018
+
1000
1019
  class MapPostboyService extends PostboyService {
1001
1020
  constructor() {
1002
1021
  super();
@@ -1147,7 +1166,7 @@ class MapStateService {
1147
1166
  if (!this.map)
1148
1167
  return null;
1149
1168
  let [longitude, latitude] = this.map.getView().getCenter();
1150
- const zoom = Math.floor(this.map.getView().getZoom());
1169
+ const zoom = this.map.getView().getZoom();
1151
1170
  const extent = this.map.getView().calculateExtent();
1152
1171
  return { longitude, latitude, zoom, extent };
1153
1172
  }
@@ -1517,6 +1536,8 @@ class MessageRegistratorService extends PostboyAbstractRegistrator {
1517
1536
  this.recordSubject(RemoveRasterTileCommand);
1518
1537
  this.recordSubject(RemoveImageLayerCommand);
1519
1538
  this.recordSubject(AddImageLayerCommand);
1539
+ this.recordSubject(AddGeotiffTileCommand);
1540
+ this.recordSubject(RemoveGeotiffTileCommand);
1520
1541
  this.recordSubject(RemoveTileCommand);
1521
1542
  this.recordSubject(MapClickEvent);
1522
1543
  this.recordSubject(CloseTooltipCommand);
@@ -2812,6 +2833,230 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.19", ngImpo
2812
2833
  type: Input
2813
2834
  }] } });
2814
2835
 
2836
+ class GeotiffTileLayerSettings {
2837
+ /**
2838
+ * The maximum source data value. Rendered values are scaled from 0 to 1 based on the configured min and max.
2839
+ *
2840
+ * @type {number | undefined}
2841
+ * @default undefined
2842
+ */
2843
+ max = undefined;
2844
+ /**
2845
+ * The minimum source data value. Rendered values are scaled from 0 to 1 based on the configured min and max.
2846
+ *
2847
+ * @type {number | undefined}
2848
+ * @default undefined
2849
+ */
2850
+ min = undefined;
2851
+ /**
2852
+ * Represents the URL of the tif.
2853
+ * @typedef {string} url
2854
+ *
2855
+ * @example
2856
+ * 'https://example.ex/geotiff.tif'
2857
+ */
2858
+ url = '';
2859
+ /**
2860
+ * Style to apply to the layer.
2861
+ *
2862
+ * @type {Style | undefined}
2863
+ */
2864
+ style;
2865
+ /**
2866
+ * The opacity of an element.
2867
+ *
2868
+ * @type {number}
2869
+ * @default 0.6
2870
+ */
2871
+ opacity = 0.6;
2872
+ /**
2873
+ * The priority of showing - layers with higher zIndex cover others in case of collisions
2874
+ */
2875
+ zIndex = 1;
2876
+ /**
2877
+ * Represents the size of a block in a specific context, typically used to define dimensions or capacity.
2878
+ *
2879
+ * Optional property that, if defined, specifies the numerical value for the block size.
2880
+ *
2881
+ * @type {number|undefined}
2882
+ */
2883
+ blockSize = undefined;
2884
+ /**
2885
+ * Creates a copy of the given tile layer settings.
2886
+ *
2887
+ * @param {GeotiffTileLayerSettings} model - The tile layer settings to be copied.
2888
+ * @return {GeotiffTileLayerSettings} - A new instance of GeotiffTileLayerSettings with the same properties as the model.
2889
+ */
2890
+ static copy(model) {
2891
+ const result = new GeotiffTileLayerSettings();
2892
+ result.max = model.max;
2893
+ result.min = model.min;
2894
+ result.zIndex = model.zIndex;
2895
+ result.style = model.style;
2896
+ result.blockSize = model.blockSize;
2897
+ result.opacity = model.opacity;
2898
+ result.url = model.url;
2899
+ return result;
2900
+ }
2901
+ /**
2902
+ * Sets the URL of the GeotiffTileLayerSettings object.
2903
+ *
2904
+ * @param {string} url - The URL to be set.
2905
+ * @return {GeotiffTileLayerSettings} - The updated GeotiffTileLayerSettings object.
2906
+ */
2907
+ setUrl(url) {
2908
+ return GeotiffTileLayerSettings.copy({ ...this, url });
2909
+ }
2910
+ /**
2911
+ * Updates the style settings for the GeotiffTileLayerSettings and returns a new instance with the updated style.
2912
+ *
2913
+ * @param {Style} [style] - An optional style object that defines the new style settings.
2914
+ * @return {GeotiffTileLayerSettings} A new instance of GeotiffTileLayerSettings with the updated style.
2915
+ */
2916
+ setStyle(style) {
2917
+ return GeotiffTileLayerSettings.copy({ ...this, style });
2918
+ }
2919
+ /**
2920
+ * Sets the maximum value for the GeotiffTileLayerSettings.
2921
+ *
2922
+ * @param {number} max - The maximum value to set.
2923
+ * @return {GeotiffTileLayerSettings} A new instance of GeotiffTileLayerSettings with the updated maximum value.
2924
+ */
2925
+ setMax(max) {
2926
+ return GeotiffTileLayerSettings.copy({ ...this, max: max });
2927
+ }
2928
+ /**
2929
+ * Sets the z-index for the GeotiffTileLayerSettings.
2930
+ *
2931
+ * @param {number} zIndex - The new z-index to be assigned.
2932
+ * @return {GeotiffTileLayerSettings} A new GeotiffTileLayerSettings instance with the updated z-index.
2933
+ */
2934
+ setZIndex(zIndex) {
2935
+ return GeotiffTileLayerSettings.copy({ ...this, zIndex });
2936
+ }
2937
+ /**
2938
+ * Sets the minimum value for the GeotiffTileLayerSettings.
2939
+ *
2940
+ * @param {number} min - The new minimum value to be set.
2941
+ * @return {GeotiffTileLayerSettings} A new instance of GeotiffTileLayerSettings with the updated minimum value.
2942
+ */
2943
+ setMin(min) {
2944
+ return GeotiffTileLayerSettings.copy({ ...this, min: min });
2945
+ }
2946
+ /**
2947
+ * Sets the opacity of the GeotiffTileLayerSettings.
2948
+ *
2949
+ * @param {number} opacity - The opacity value to set. Must be a number between 0 and 1.
2950
+ * @return {GeotiffTileLayerSettings} - A new instance of GeotiffTileLayerSettings with the opacity set.
2951
+ */
2952
+ setOpacity(opacity) {
2953
+ return GeotiffTileLayerSettings.copy({ ...this, opacity });
2954
+ }
2955
+ /**
2956
+ * Sets the block size for the GeoTIFF tile layer.
2957
+ *
2958
+ * @param {number} blockSize - The size of the block to be set. This value typically defines the number of pixels for determining how data is grouped in tiles.
2959
+ * @return {GeotiffTileLayerSettings} A new instance of `GeotiffTileLayerSettings` with the updated block size.
2960
+ */
2961
+ setBlockSize(blockSize) {
2962
+ return GeotiffTileLayerSettings.copy({ ...this, blockSize });
2963
+ }
2964
+ /**
2965
+ * Checks if the current instance of GeotiffTileLayerSettings is equal to the given model.
2966
+ * @param {GeotiffTileLayerSettings} model - The model to compare against.
2967
+ * @return {boolean} - True if all properties of the current instance matches the properties of the model;
2968
+ * otherwise, false.
2969
+ */
2970
+ isSame(model) {
2971
+ if (this.max !== model.max)
2972
+ return false;
2973
+ if (this.min !== model.min)
2974
+ return false;
2975
+ if (this.zIndex !== model.zIndex)
2976
+ return false;
2977
+ if (this.url !== model.url)
2978
+ return false;
2979
+ if (this.style !== model.style)
2980
+ return false;
2981
+ if (this.blockSize !== model.blockSize)
2982
+ return false;
2983
+ if (this.opacity !== model.opacity)
2984
+ return false;
2985
+ return true;
2986
+ }
2987
+ }
2988
+
2989
+ class GeotiffTileLayerFactory {
2990
+ build(settings) {
2991
+ const source = new GeoTIFF({
2992
+ sources: [
2993
+ {
2994
+ url: settings.url,
2995
+ min: settings.min,
2996
+ max: settings.max,
2997
+ },
2998
+ ],
2999
+ sourceOptions: { blockSize: settings.blockSize },
3000
+ });
3001
+ return new TileLayer$1({
3002
+ style: settings.style,
3003
+ source: source,
3004
+ zIndex: settings.zIndex,
3005
+ opacity: settings.opacity,
3006
+ });
3007
+ }
3008
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.19", ngImport: i0, type: GeotiffTileLayerFactory, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
3009
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.19", ngImport: i0, type: GeotiffTileLayerFactory, providedIn: 'root' });
3010
+ }
3011
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.19", ngImport: i0, type: GeotiffTileLayerFactory, decorators: [{
3012
+ type: Injectable,
3013
+ args: [{
3014
+ providedIn: 'root',
3015
+ }]
3016
+ }] });
3017
+
3018
+ class GeotiffTileLayerComponent extends DestructibleComponent {
3019
+ postboy;
3020
+ factory;
3021
+ layer;
3022
+ constructor(postboy, factory) {
3023
+ super();
3024
+ this.postboy = postboy;
3025
+ this.factory = factory;
3026
+ }
3027
+ _settings = new GeotiffTileLayerSettings();
3028
+ set settings(value) {
3029
+ if (!value || this._settings.isSame(value))
3030
+ return;
3031
+ this._settings = value;
3032
+ this.initLayer();
3033
+ }
3034
+ ngOnInit() {
3035
+ this.postboy
3036
+ .sub(MapRenderedEvent)
3037
+ .pipe(filter((m) => !!m), first())
3038
+ .subscribe((m) => this.initLayer());
3039
+ }
3040
+ onDestroy = () => this.removeLayer();
3041
+ initLayer() {
3042
+ this.removeLayer();
3043
+ this.layer = this.factory.build(this._settings);
3044
+ this.postboy.fire(new AddGeotiffTileCommand(this.layer));
3045
+ }
3046
+ removeLayer() {
3047
+ if (this.layer)
3048
+ this.postboy.fire(new RemoveGeotiffTileCommand(this.layer));
3049
+ }
3050
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.19", ngImport: i0, type: GeotiffTileLayerComponent, deps: [{ token: MapPostboyService }, { token: GeotiffTileLayerFactory }], target: i0.ɵɵFactoryTarget.Component });
3051
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.19", type: GeotiffTileLayerComponent, isStandalone: true, selector: "lib-geotiff-tile-layer", inputs: { settings: "settings" }, usesInheritance: true, ngImport: i0, template: '', isInline: true });
3052
+ }
3053
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.19", ngImport: i0, type: GeotiffTileLayerComponent, decorators: [{
3054
+ type: Component,
3055
+ args: [{ selector: 'lib-geotiff-tile-layer', imports: [], template: '' }]
3056
+ }], ctorParameters: () => [{ type: MapPostboyService }, { type: GeotiffTileLayerFactory }], propDecorators: { settings: [{
3057
+ type: Input
3058
+ }] } });
3059
+
2815
3060
  class MapPlateFactory {
2816
3061
  build(settings) {
2817
3062
  return new Map({
@@ -3505,5 +3750,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.19", ngImpo
3505
3750
  * Generated bundle index. Do not edit.
3506
3751
  */
3507
3752
 
3508
- export { AddControlCommand, CalculateAreaExecutor, CancelDrawingCommand, CancelFeatureModificationCommand, CloseTooltipCommand, ClusterLayerComponent, ClusterLayerSettings, DrawSelectionAreaCommand, DrawingType, FeatureLayerComponent, FeatureLayerSettings, FeatureOutputFormat, FilterFeaturesInAreaExecutor, FilterFeaturesInPointExecutor, FitToFeaturesCommand, FitToPolygonsCommand, GetFeaturesInAreaQuery, GetFeaturesInPointQuery, GetGeometryLengthExecutor, GetMapPositionExecutor, ImageLayerComponent, ImageLayerSettings, MapClickEvent, MapConstants, MapControl, MapControlZoomComponent, MapFeatureHoveredEvent, MapLyrs, MapLyrsLabel, MapMoveEndEvent, MapPlateComponent, MapPointerMoveEvent, MapPostboyService, MapRenderedEvent, MapSettings, MarkerModel, MarkerStyleHelper, MarkersComponent, MessageRegistratorService, ModifyFeatureCommand, OsmTileLayerComponent, PolygonModel, PolygonSelfIntersectionExecutor, PolygonStyleHelper, PolygonsComponent, RasterTileLayerComponent, RasterTileLayerSettings, RemoveControlCommand, SetMapCenterCommand, StartDrawingCommand, StringifyFeatureHelper, TextStyleHelper, TileLayerComponent, TileLayerSettings, TooltipComponent, TooltipSettings, ZoomControlSettings };
3753
+ export { AddControlCommand, CalculateAreaExecutor, CancelDrawingCommand, CancelFeatureModificationCommand, CloseTooltipCommand, ClusterLayerComponent, ClusterLayerSettings, DrawSelectionAreaCommand, DrawingType, FeatureLayerComponent, FeatureLayerSettings, FeatureOutputFormat, FilterFeaturesInAreaExecutor, FilterFeaturesInPointExecutor, FitToFeaturesCommand, FitToPolygonsCommand, GeotiffTileLayerComponent, GeotiffTileLayerSettings, GetFeaturesInAreaQuery, GetFeaturesInPointQuery, GetGeometryLengthExecutor, GetMapPositionExecutor, ImageLayerComponent, ImageLayerSettings, MapClickEvent, MapConstants, MapControl, MapControlZoomComponent, MapFeatureHoveredEvent, MapLyrs, MapLyrsLabel, MapMoveEndEvent, MapPlateComponent, MapPointerMoveEvent, MapPostboyService, MapRenderedEvent, MapSettings, MarkerModel, MarkerStyleHelper, MarkersComponent, MessageRegistratorService, ModifyFeatureCommand, OsmTileLayerComponent, PolygonModel, PolygonSelfIntersectionExecutor, PolygonStyleHelper, PolygonsComponent, RasterTileLayerComponent, RasterTileLayerSettings, RemoveControlCommand, SetMapCenterCommand, StartDrawingCommand, StringifyFeatureHelper, TextStyleHelper, TileLayerComponent, TileLayerSettings, TooltipComponent, TooltipSettings, ZoomControlSettings };
3509
3754
  //# sourceMappingURL=maps-components-src-map.mjs.map