@opengeoweb/webmap 19.2.0 → 19.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -1517,23 +1517,27 @@ var getLegendGraphicURLForLayer = function getLegendGraphicURLForLayer(layer, wi
1517
1517
  return undefined;
1518
1518
  }
1519
1519
  try {
1520
- var mapDimURL = getMapDimURL(layer).toString();
1521
- if (mapDimURL) {
1522
- legendURL += "&" + mapDimURL;
1523
- }
1524
- if (layer.sldURL) {
1525
- legendURL += "&SLD=" + encodeURI(layer.sldURL);
1526
- }
1527
- legendURL += '&transparent=true';
1528
- // append width and height parameters when not present
1529
- if (!legendURL.includes('&width=') && !legendURL.includes('&height=')) {
1530
- legendURL += "&width=" + width + "&height=" + height;
1520
+ if (layer.layerType !== LayerType.wmtsMapLayer) {
1521
+ var mapDimURL = getMapDimURL(layer).toString();
1522
+ if (mapDimURL) {
1523
+ legendURL += "&" + mapDimURL;
1524
+ }
1525
+ if (layer.sldURL) {
1526
+ legendURL += "&SLD=" + encodeURI(layer.sldURL);
1527
+ }
1528
+ legendURL += '&transparent=true';
1529
+ // append width and height parameters when not present
1530
+ if (!legendURL.includes('&width=') && !legendURL.includes('&height=')) {
1531
+ legendURL += "&width=" + width + "&height=" + height;
1532
+ }
1531
1533
  }
1532
1534
  } catch (_e) {
1533
1535
  return undefined;
1534
1536
  }
1535
1537
  // Handle WMS extensions
1536
- legendURL += layer.wmsextensions.url;
1538
+ if (layer.layerType !== LayerType.wmtsMapLayer) {
1539
+ legendURL += layer.wmsextensions.url;
1540
+ }
1537
1541
  return legendURL;
1538
1542
  }
1539
1543
  return undefined;
@@ -3783,11 +3787,98 @@ var makeQueryKeyFroMServiceUrl = function makeQueryKeyFroMServiceUrl(serviceUrl)
3783
3787
  * @returns
3784
3788
  */
3785
3789
  var handleWMTSGetCapabilities = function handleWMTSGetCapabilities(getCapabilities) {
3786
- var _getCapabilities$Capa;
3787
- var getCapLayer = (_getCapabilities$Capa = getCapabilities.Capabilities) == null || (_getCapabilities$Capa = _getCapabilities$Capa.Contents) == null ? void 0 : _getCapabilities$Capa.Layer;
3790
+ var _getCapabilities$Capa, _getFeatureInfoOperat, _getFeatureInfoGets$, _getCapabilities$Capa2;
3791
+ var toArray = function toArray(value) {
3792
+ if (!value) {
3793
+ return [];
3794
+ }
3795
+ return Array.isArray(value) ? value : [value];
3796
+ };
3797
+ var getOperationByName = function getOperationByName(operations, operationName) {
3798
+ return operations.find(function (operation) {
3799
+ var _operation$attr;
3800
+ return ((_operation$attr = operation.attr) == null ? void 0 : _operation$attr.name) === operationName;
3801
+ });
3802
+ };
3803
+ var getEncodingFromOperation = function getEncodingFromOperation(operationGets) {
3804
+ for (var _iterator2 = _createForOfIteratorHelperLoose(operationGets), _step2; !(_step2 = _iterator2()).done;) {
3805
+ var operationGet = _step2.value;
3806
+ var constraints = toArray(operationGet.Constraint);
3807
+ var encodingConstraint = constraints.find(function (constraint) {
3808
+ var _constraint$attr;
3809
+ return ((_constraint$attr = constraint.attr) == null ? void 0 : _constraint$attr.name) === 'GetEncoding';
3810
+ });
3811
+ if (encodingConstraint) {
3812
+ var _encodingConstraint$A;
3813
+ var allowedValues = toArray((_encodingConstraint$A = encodingConstraint.AllowedValues) == null ? void 0 : _encodingConstraint$A.Value);
3814
+ if (allowedValues.length > 0 && allowedValues[0].value) {
3815
+ return allowedValues[0].value;
3816
+ }
3817
+ }
3818
+ }
3819
+ return undefined;
3820
+ };
3821
+ var getLegendUrlFromStyle = function getLegendUrlFromStyle(style) {
3822
+ var _genericImageLegend$a, _legendUrls$;
3823
+ var normalizeWmtsLegendUrl = function normalizeWmtsLegendUrl(legendUrl) {
3824
+ try {
3825
+ var parsedUrl = new URL(legendUrl);
3826
+ var format = parsedUrl.searchParams.get('FORMAT');
3827
+ if (format) {
3828
+ var decodedFormat = decodeURIComponent(format);
3829
+ if (decodedFormat !== format) {
3830
+ parsedUrl.searchParams.set('FORMAT', decodedFormat);
3831
+ }
3832
+ }
3833
+ return parsedUrl.toString();
3834
+ } catch (_error) {
3835
+ return legendUrl;
3836
+ }
3837
+ };
3838
+ if (!style) {
3839
+ return '';
3840
+ }
3841
+ var legendUrls = toArray(style.LegendURL);
3842
+ if (legendUrls.length === 0) {
3843
+ return '';
3844
+ }
3845
+ var preferredFormats = ['image/svg+xml', 'image/png'];
3846
+ var _loop = function _loop() {
3847
+ var _match$attr;
3848
+ var preferredFormat = _preferredFormats[_i];
3849
+ var match = legendUrls.find(function (legendURL) {
3850
+ var _legendURL$attr;
3851
+ return (legendURL == null || (_legendURL$attr = legendURL.attr) == null ? void 0 : _legendURL$attr.format) === preferredFormat;
3852
+ });
3853
+ if (match != null && (_match$attr = match.attr) != null && _match$attr['xlink:href']) {
3854
+ return {
3855
+ v: normalizeWmtsLegendUrl(match.attr['xlink:href'])
3856
+ };
3857
+ }
3858
+ },
3859
+ _ret;
3860
+ for (var _i = 0, _preferredFormats = preferredFormats; _i < _preferredFormats.length; _i++) {
3861
+ _ret = _loop();
3862
+ if (_ret) return _ret.v;
3863
+ }
3864
+ var genericImageLegend = legendUrls.find(function (legendURL) {
3865
+ var _legendURL$attr2;
3866
+ return legendURL == null || (_legendURL$attr2 = legendURL.attr) == null || (_legendURL$attr2 = _legendURL$attr2.format) == null ? void 0 : _legendURL$attr2.startsWith('image/');
3867
+ });
3868
+ if (genericImageLegend != null && (_genericImageLegend$a = genericImageLegend.attr) != null && _genericImageLegend$a['xlink:href']) {
3869
+ return normalizeWmtsLegendUrl(genericImageLegend.attr['xlink:href']);
3870
+ }
3871
+ return (_legendUrls$ = legendUrls[0]) != null && (_legendUrls$ = _legendUrls$.attr) != null && _legendUrls$['xlink:href'] ? normalizeWmtsLegendUrl(legendUrls[0].attr['xlink:href']) : '';
3872
+ };
3873
+ var operations = toArray((_getCapabilities$Capa = getCapabilities.Capabilities) == null || (_getCapabilities$Capa = _getCapabilities$Capa.OperationsMetadata) == null ? void 0 : _getCapabilities$Capa.Operation);
3874
+ var getFeatureInfoOperation = getOperationByName(operations, 'GetFeatureInfo');
3875
+ var getFeatureInfoGets = toArray(getFeatureInfoOperation == null || (_getFeatureInfoOperat = getFeatureInfoOperation.DCP) == null || (_getFeatureInfoOperat = _getFeatureInfoOperat.HTTP) == null ? void 0 : _getFeatureInfoOperat.Get);
3876
+ var wmtsGetFeatureInfoURL = ((_getFeatureInfoGets$ = getFeatureInfoGets[0]) == null || (_getFeatureInfoGets$ = _getFeatureInfoGets$.attr) == null ? void 0 : _getFeatureInfoGets$['xlink:href']) || '';
3877
+ var wmtsGetFeatureInfoEncoding = getEncodingFromOperation(getFeatureInfoGets) || '';
3878
+ var getCapLayer = (_getCapabilities$Capa2 = getCapabilities.Capabilities) == null || (_getCapabilities$Capa2 = _getCapabilities$Capa2.Contents) == null ? void 0 : _getCapabilities$Capa2.Layer;
3788
3879
  var layers = Array.isArray(getCapLayer) ? getCapLayer : [getCapLayer]; // Can be either array or single object
3789
3880
  return layers.map(function (layer) {
3790
- var _layer$Abstract;
3881
+ var _defaultStyle$Identif, _toArray$find, _layer$Abstract;
3791
3882
  if (!layer) {
3792
3883
  return null;
3793
3884
  }
@@ -3810,13 +3901,51 @@ var handleWMTSGetCapabilities = function handleWMTSGetCapabilities(getCapabiliti
3810
3901
  layerDimensions.push(dimension);
3811
3902
  }
3812
3903
  });
3813
- // Styles are probably not defined for WMTS layers, but we create a default style
3814
- var layerStyles = [{
3815
- name: 'default',
3816
- title: 'default',
3817
- legendURL: '',
3818
- "abstract": ''
3819
- }];
3904
+ var layerStyles = toArray(layer.Style).map(function (style) {
3905
+ var _style$Identifier, _style$Title;
3906
+ var styleName = (style == null || (_style$Identifier = style.Identifier) == null ? void 0 : _style$Identifier.value) || 'default';
3907
+ var styleTitle = (style == null || (_style$Title = style.Title) == null ? void 0 : _style$Title.value) || styleName;
3908
+ return {
3909
+ name: styleName,
3910
+ title: styleTitle,
3911
+ legendURL: getLegendUrlFromStyle(style),
3912
+ "abstract": ''
3913
+ };
3914
+ });
3915
+ if (layerStyles.length === 0) {
3916
+ layerStyles.push({
3917
+ name: 'default',
3918
+ title: 'default',
3919
+ legendURL: '',
3920
+ "abstract": ''
3921
+ });
3922
+ }
3923
+ var defaultStyle = toArray(layer.Style).find(function (style) {
3924
+ var _style$attr;
3925
+ return (style == null || (_style$attr = style.attr) == null ? void 0 : _style$attr.isDefault) === 'true';
3926
+ });
3927
+ if (defaultStyle != null && (_defaultStyle$Identif = defaultStyle.Identifier) != null && _defaultStyle$Identif.value) {
3928
+ var defaultStyleIndex = layerStyles.findIndex(function (style) {
3929
+ var _defaultStyle$Identif2;
3930
+ return style.name === ((_defaultStyle$Identif2 = defaultStyle.Identifier) == null ? void 0 : _defaultStyle$Identif2.value);
3931
+ });
3932
+ if (defaultStyleIndex > 0) {
3933
+ var _layerStyles$splice = layerStyles.splice(defaultStyleIndex, 1),
3934
+ defaultStyleItem = _layerStyles$splice[0];
3935
+ layerStyles.unshift(defaultStyleItem);
3936
+ }
3937
+ }
3938
+ var layerInfoFormats = toArray(layer.InfoFormat).map(function (format) {
3939
+ return (format == null ? void 0 : format.value) || '';
3940
+ }).filter(Boolean);
3941
+ var preferredInfoFormats = ['text/html', 'application/json', 'text/xml'];
3942
+ var layerInfoFormat = preferredInfoFormats.find(function (preferredInfoFormat) {
3943
+ return layerInfoFormats.includes(preferredInfoFormat);
3944
+ }) || layerInfoFormats[0];
3945
+ var tileMatrixSet = (_toArray$find = toArray(layer.TileMatrixSetLink).find(function (tileMatrixSetLink) {
3946
+ var _tileMatrixSetLink$Ti;
3947
+ return !!((_tileMatrixSetLink$Ti = tileMatrixSetLink.TileMatrixSet) != null && _tileMatrixSetLink$Ti.value);
3948
+ })) == null || (_toArray$find = _toArray$find.TileMatrixSet) == null ? void 0 : _toArray$find.value;
3820
3949
  return {
3821
3950
  title: layer.Title.value,
3822
3951
  name: layer.Identifier.value,
@@ -3825,7 +3954,11 @@ var handleWMTSGetCapabilities = function handleWMTSGetCapabilities(getCapabiliti
3825
3954
  path: [],
3826
3955
  styles: layerStyles,
3827
3956
  dimensions: layerDimensions,
3828
- ogctype: OGCTYPE.WMTS
3957
+ ogctype: OGCTYPE.WMTS,
3958
+ wmtsGetFeatureInfoURL: wmtsGetFeatureInfoURL,
3959
+ wmtsGetFeatureInfoEncoding: wmtsGetFeatureInfoEncoding,
3960
+ wmtsInfoFormat: layerInfoFormat,
3961
+ wmtsTileMatrixSet: tileMatrixSet
3829
3962
  };
3830
3963
  }).filter(function (x) {
3831
3964
  return !!x;
@@ -4571,6 +4704,9 @@ var WMLayer = /*#__PURE__*/function () {
4571
4704
  this.getmapURL = undefined;
4572
4705
  this.getfeatureinfoURL = undefined;
4573
4706
  this.getlegendgraphicURL = undefined;
4707
+ this.wmtsGetFeatureInfoEncoding = '';
4708
+ this.wmtsInfoFormat = '';
4709
+ this.wmtsTileMatrixSet = '';
4574
4710
  this.keepOnTop = false;
4575
4711
  this.transparent = true;
4576
4712
  this.hasError = false;
@@ -4753,8 +4889,11 @@ var WMLayer = /*#__PURE__*/function () {
4753
4889
  configureDimensions(layerProps, this);
4754
4890
  configureGeographicBoundingBox(layerProps, this);
4755
4891
  configureStyles(layerProps, this);
4756
- this.getfeatureinfoURL = '';
4757
- this.getlegendgraphicURL = '';
4892
+ this.getfeatureinfoURL = layerProps.wmtsGetFeatureInfoURL || '';
4893
+ this.wmtsGetFeatureInfoEncoding = layerProps.wmtsGetFeatureInfoEncoding || '';
4894
+ this.wmtsInfoFormat = layerProps.wmtsInfoFormat || '';
4895
+ this.wmtsTileMatrixSet = layerProps.wmtsTileMatrixSet || '';
4896
+ this.getlegendgraphicURL = this.legendGraphic || '';
4758
4897
  this.isConfigured = true;
4759
4898
  return _context.a(2, this);
4760
4899
  case 7:
@@ -4790,6 +4929,13 @@ var WMLayer = /*#__PURE__*/function () {
4790
4929
  newLayer.name = this.name;
4791
4930
  newLayer.layerType = this.layerType;
4792
4931
  newLayer.refTimeDimensionMode = this.refTimeDimensionMode;
4932
+ newLayer.currentStyle = this.currentStyle;
4933
+ newLayer.getfeatureinfoURL = this.getfeatureinfoURL;
4934
+ newLayer.getlegendgraphicURL = this.getlegendgraphicURL;
4935
+ newLayer.wmtsGetFeatureInfoEncoding = this.wmtsGetFeatureInfoEncoding;
4936
+ newLayer.wmtsInfoFormat = this.wmtsInfoFormat;
4937
+ newLayer.wmtsTileMatrixSet = this.wmtsTileMatrixSet;
4938
+ newLayer.olSource = this.olSource;
4793
4939
  this.dimensions.forEach(function (dim) {
4794
4940
  newLayer.dimensions.push(dim.clone());
4795
4941
  });
@@ -27,6 +27,9 @@ export default class WMLayer {
27
27
  getmapURL: string;
28
28
  getfeatureinfoURL: string;
29
29
  getlegendgraphicURL: string;
30
+ wmtsGetFeatureInfoEncoding: string;
31
+ wmtsInfoFormat: string;
32
+ wmtsTileMatrixSet: string;
30
33
  keepOnTop: boolean;
31
34
  transparent: boolean;
32
35
  wms130bboxcompatibilitymode: boolean;
@@ -79,6 +79,10 @@ export interface LayerProps {
79
79
  queryable?: boolean;
80
80
  crs?: CoordinateReferenceSystem[];
81
81
  ogctype?: OGCTYPE;
82
+ wmtsGetFeatureInfoURL?: string;
83
+ wmtsGetFeatureInfoEncoding?: string;
84
+ wmtsInfoFormat?: string;
85
+ wmtsTileMatrixSet?: string;
82
86
  }
83
87
  /**
84
88
  * Represents the layers as advertised in the WMS GetCapabilities document
@@ -193,17 +197,78 @@ export interface WMTDimension {
193
197
  value: string;
194
198
  }[];
195
199
  }
200
+ export interface WMTLegendURL {
201
+ attr?: {
202
+ format?: string;
203
+ 'xlink:href'?: string;
204
+ };
205
+ }
206
+ export interface WMTStyle {
207
+ attr?: {
208
+ isDefault?: string;
209
+ };
210
+ Identifier?: {
211
+ value: string;
212
+ };
213
+ Title?: {
214
+ value: string;
215
+ };
216
+ LegendURL?: WMTLegendURL | WMTLegendURL[];
217
+ }
196
218
  export interface WMTLayer {
197
219
  Abstract: {
198
220
  value: string;
199
221
  };
200
- Dimension?: WMTDimension[];
222
+ Dimension?: WMTDimension | WMTDimension[];
201
223
  Identifier: {
202
224
  value: string;
203
225
  };
204
226
  Title: {
205
227
  value: string;
206
228
  };
229
+ Style?: WMTStyle | WMTStyle[];
230
+ InfoFormat?: {
231
+ value: string;
232
+ } | {
233
+ value: string;
234
+ }[];
235
+ TileMatrixSetLink?: {
236
+ TileMatrixSet?: {
237
+ value: string;
238
+ };
239
+ } | {
240
+ TileMatrixSet?: {
241
+ value: string;
242
+ };
243
+ }[];
244
+ }
245
+ export interface WMTOperationConstraint {
246
+ attr?: {
247
+ name?: string;
248
+ };
249
+ AllowedValues?: {
250
+ Value?: {
251
+ value?: string;
252
+ } | {
253
+ value?: string;
254
+ }[];
255
+ };
256
+ }
257
+ export interface WMTOperationGet {
258
+ attr?: {
259
+ 'xlink:href'?: string;
260
+ };
261
+ Constraint?: WMTOperationConstraint | WMTOperationConstraint[];
262
+ }
263
+ export interface WMTOperation {
264
+ attr?: {
265
+ name?: string;
266
+ };
267
+ DCP?: {
268
+ HTTP?: {
269
+ Get?: WMTOperationGet | WMTOperationGet[];
270
+ };
271
+ };
207
272
  }
208
273
  export interface WMTSGetCapabilities {
209
274
  Capabilities?: {
@@ -218,6 +283,9 @@ export interface WMTSGetCapabilities {
218
283
  value: string;
219
284
  };
220
285
  };
286
+ OperationsMetadata?: {
287
+ Operation?: WMTOperation | WMTOperation[];
288
+ };
221
289
  Contents?: {
222
290
  Layer?: WMTLayer | WMTLayer[];
223
291
  };
@@ -99,11 +99,25 @@ export declare const wmtsResponseGetCapabilities: {
99
99
  attr: {};
100
100
  value: string;
101
101
  };
102
+ Title: {
103
+ attr: {};
104
+ value: string;
105
+ };
106
+ LegendURL: {
107
+ attr: {
108
+ format: string;
109
+ 'xlink:href': string;
110
+ };
111
+ }[];
102
112
  };
103
113
  Format: {
104
114
  attr: {};
105
115
  value: string;
106
116
  };
117
+ InfoFormat: {
118
+ attr: {};
119
+ value: string;
120
+ };
107
121
  Dimension: {
108
122
  attr: {};
109
123
  Identifier: {
@@ -197,6 +211,10 @@ export declare const wmtsResponseLayerList: {
197
211
  name: string;
198
212
  path: never[];
199
213
  ogctype: string;
214
+ wmtsGetFeatureInfoEncoding: string;
215
+ wmtsGetFeatureInfoURL: string;
216
+ wmtsInfoFormat: string;
217
+ wmtsTileMatrixSet: string;
200
218
  styles: {
201
219
  abstract: string;
202
220
  legendURL: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengeoweb/webmap",
3
- "version": "19.2.0",
3
+ "version": "19.4.0",
4
4
  "description": "GeoWeb webmap library for the opengeoweb project",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {