Skip to content

Commit

Permalink
refactor(styler): Opacity fix ins not necessary anymore
Browse files Browse the repository at this point in the history
  • Loading branch information
FilipLeitner committed Feb 12, 2024
1 parent cbe93c5 commit 062c75c
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 28 deletions.
Expand Up @@ -36,7 +36,7 @@ export class HsRuleComponent extends HsStylerPartBaseComponent {
if (kind === Kinds.fill) {
Object.assign(symbolizer, {
outlineColor: '#ffffff',
opacity: 1,
fillOpacity: 1,
outlineOpacity: 0.5,
outlineWidth: 2,
});
Expand Down
19 changes: 0 additions & 19 deletions projects/hslayers/src/components/styles/styler.service.ts
Expand Up @@ -374,7 +374,6 @@ export class HsStylerService {
this.styleObject = blankStyleObj;
}
this.fixSymbolizerBugs(this.styleObject);
this.geostylerWorkaround();
/**
* Save (update OL style) layer style
* unsavedChange - synced layman layer with changes
Expand Down Expand Up @@ -406,24 +405,6 @@ export class HsStylerService {
}
}

/**
* Tweak geostyler object attributes to mitigate
* some discrepancies between opacity and fillOpacity usage
*/
geostylerWorkaround(): void {
if (this.styleObject.rules) {
for (const rule of this.styleObject.rules) {
if (rule.symbolizers) {
for (const symbol of rule.symbolizers.filter(
(symb) => symb.kind == 'Fill',
) as FillSymbolizer[]) {
symbol.opacity = symbol.fillOpacity;
}
}
}
}
}

/**
* Convert SLD to OL style object
*/
Expand Down
@@ -1,14 +1,14 @@
<form class="form">

<hs-symbolizer-color-picker [symbolizer]="symbolizer" attribute="color" opacityAttribute="opacity"
[class.disabled]="symbolizer.graphicFill !== undefined" (changes)="opacityFix(); emitChange()"
<hs-symbolizer-color-picker [symbolizer]="symbolizer" attribute="color" opacityAttribute="fillOpacity"
[class.disabled]="symbolizer.graphicFill !== undefined" (changes)="emitChange()"
[label]="'STYLER.fillColor' | translateHs">
<span class="badge bg-warning mt-2" *ngIf="symbolizer.graphicFill !== undefined"
[title]="'STYLER.warningFillNotVisualizedDueToGraphic' | translateHs ">!</span>
</hs-symbolizer-color-picker>

<hs-symbolizer-slider [symbolizer]="symbolizer" attribute="opacity" (changes)="opacityFix(); emitChange()" step="0.05"
min="0" max="1" [label]="'STYLER.opacity' | translateHs "></hs-symbolizer-slider>
<hs-symbolizer-slider [symbolizer]="symbolizer" attribute="fillOpacity" (changes)="emitChange()" step="0.05" min="0"
max="1" [label]="'STYLER.opacity' | translateHs "></hs-symbolizer-slider>

<hs-symbolizer-color-picker [symbolizer]="symbolizer" attribute="outlineColor" opacityAttribute="outlineOpacity"
(changes)="emitChange()" [label]="'STYLER.outlineColor' | translateHs ">
Expand Down
Expand Up @@ -44,8 +44,4 @@ export class HsFillSymbolizerComponent extends HsStylerPartBaseComponent {
this.menuRef.close();
this.emitChange();
}

opacityFix(): void {
this.symbolizer.fillOpacity = this.symbolizer.opacity;
}
}

0 comments on commit 062c75c

Please sign in to comment.