Skip to content

Commit

Permalink
fix: Replace logical OR with nullish coalescing when setting opacity
Browse files Browse the repository at this point in the history
  • Loading branch information
FilipLeitner authored and jmacura committed Nov 26, 2024
1 parent 53a768f commit 41b4030
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion projects/hslayers/services/add-data/url/arcgis.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ export class HsUrlArcGisService implements HsUrlTypeServiceModel {
: await this.calcAllLayersExtent(layers, options);

const layerParams = {
opacity: options.opacity || 1,
opacity: options.opacity ?? 1,
properties: {
title: options.title,
name: options.title,
Expand Down
2 changes: 1 addition & 1 deletion projects/hslayers/services/add-data/url/wfs.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ export class HsUrlWfsService implements HsUrlTypeServiceModel {
layerExtent: layerExtent,
}),
renderOrder: null,
opacity: options.opacity || 1,
opacity: options.opacity ?? 1,
//Used to determine whether its URL WFS service when saving to compositions
});
if (this.hsAddDataCommonService.layerToSelect) {
Expand Down
2 changes: 1 addition & 1 deletion projects/hslayers/services/add-data/url/wmts.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ export class HsUrlWmtsService implements HsUrlTypeServiceModel {
getLayer(layer, options: LayerOptions): Layer<Source> {
try {
const wmts = new Tile({
opacity: options.opacity || 1,
opacity: options.opacity ?? 1,
extent: this.getWMTSExtent(layer.Identifier),
className: options?.greyscale ? 'ol-layer hs-greyscale' : 'ol-layer',
properties: {
Expand Down
16 changes: 8 additions & 8 deletions projects/hslayers/services/compositions/layer-parser.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export class HsCompositionsLayerParserService {
style: style,
path: lyr_def.path,
fromComposition: true,
opacity: parseFloat(lyr_def.opacity) || 1,
opacity: parseFloat(lyr_def.opacity) ?? 1,
},
});
newLayer[0].setVisible(lyr_def.visibility);
Expand All @@ -94,7 +94,7 @@ export class HsCompositionsLayerParserService {
base: lyr_def.base,
greyscale: lyr_def.greyscale,
fromComposition: true,
opacity: parseFloat(lyr_def.opacity) || 1,
opacity: parseFloat(lyr_def.opacity) ?? 1,
},
});
newLayer[0].setVisible(lyr_def.visibility);
Expand Down Expand Up @@ -155,7 +155,7 @@ export class HsCompositionsLayerParserService {
dimensions: lyr_def.dimensions,
legends: legends,
path: lyr_def.path,
opacity: parseFloat(lyr_def.opacity) || 1,
opacity: parseFloat(lyr_def.opacity) ?? 1,
source,
subLayers: lyr_def.subLayers,
className: lyr_def.greyscale ? 'ol-layer hs-greyscale' : 'ol-layer',
Expand Down Expand Up @@ -187,7 +187,7 @@ export class HsCompositionsLayerParserService {
base: lyr_def.base,
greyscale: lyr_def.greyscale,
fromComposition: true,
opacity: parseFloat(lyr_def.opacity) || 1,
opacity: parseFloat(lyr_def.opacity) ?? 1,
},
});
newLayer[0].setVisible(lyr_def.visibility);
Expand Down Expand Up @@ -219,7 +219,7 @@ export class HsCompositionsLayerParserService {
const new_layer = new Tile({
maxResolution: lyr_def.maxResolution || Infinity,
minResolution: lyr_def.minResolution || 0,
opacity: parseFloat(lyr_def.opacity) || 1,
opacity: parseFloat(lyr_def.opacity) ?? 1,
source,
className: lyr_def.greyscale ? 'ol-layer hs-greyscale' : 'ol-layer',
properties: {
Expand Down Expand Up @@ -264,7 +264,7 @@ export class HsCompositionsLayerParserService {
maxResolution: lyr_def.maxResolution || Infinity,
minResolution: lyr_def.minResolution || 0,
className: lyr_def.greyscale ? 'ol-layer hs-greyscale' : 'ol-layer',
opacity: parseFloat(lyr_def.opacity) || 1,
opacity: parseFloat(lyr_def.opacity) ?? 1,
source,
properties: {
title: lyr_def.title,
Expand Down Expand Up @@ -316,7 +316,7 @@ export class HsCompositionsLayerParserService {
definition,
},
source: src,
opacity: parseFloat(lyr_def.opacity) || 1,
opacity: parseFloat(lyr_def.opacity) ?? 1,
style: style,
});
lyr.setVisible(lyr_def.visibility);
Expand Down Expand Up @@ -353,7 +353,7 @@ export class HsCompositionsLayerParserService {
}
}
const options: HsVectorLayerOptions = {
opacity: parseFloat(lyr_def.opacity) || 1,
opacity: parseFloat(lyr_def.opacity) ?? 1,
fromComposition: lyr_def.fromComposition ?? true,
path: lyr_def.path,
visible: lyr_def.visibility,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export class VectorLayerDescriptor {
definition,
name,
title,
opacity: options.opacity || 1,
opacity: options.opacity ?? 1,
fromComposition: options.fromComposition || false,
removable: true,
path: options.path,
Expand Down

0 comments on commit 41b4030

Please sign in to comment.