Skip to content

Commit

Permalink
Addresses review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
mholthausen committed May 7, 2021
1 parent 91d3164 commit 8526ce8
Showing 1 changed file with 12 additions and 19 deletions.
31 changes: 12 additions & 19 deletions src/MapfileStyleParser.ts
Expand Up @@ -421,7 +421,7 @@ export class MapfileStyleParser implements StyleParser {
getIconSymbolizerFromMapfileStyle(mapfileStyle: MapfileStyle): IconSymbolizer {
const iconSymbolizer: IconSymbolizer = {
kind: 'Icon',
image: mapfileStyle.symbol.image || mapfileStyle.symbol,
image: mapfileStyle.symbol.image,
} as IconSymbolizer;

if (mapfileStyle.size) {
Expand Down Expand Up @@ -812,12 +812,10 @@ export class MapfileStyleParser implements StyleParser {
mapfileLabel.text = mapfileLabel.text ? mapfileLabel.text : mapfileLayerLabelItem;

// Set Icons in front of the associated label
const labelIcons = this.getIconsFromMapfileLabel(mapfileLabel);
if (labelIcons) {
labelIcons.forEach(labelIcon => {
symbolizers.push(labelIcon);
});
}
const labelIcons = this.getIconsFromMapfileLabel(mapfileLabel);
labelIcons?.forEach(labelIcon => {
symbolizers.push(labelIcon);
});

const symbolizer = Object.assign(
this.getTextSymbolizerFromMapfileStyle(mapfileLabel),
Expand All @@ -836,24 +834,19 @@ export class MapfileStyleParser implements StyleParser {
/**
* Collect icon data if defined within the label tag
*
* @param mapfileLabel
* @returns
* @param {MapfileLabel} mapfileLabel Mapfile label data
* @return {IconSymbolizer[]} The IconSymbolizer
*/
getIconsFromMapfileLabel(
mapfileLabel: MapfileLabel
): IconSymbolizer[] | void {
getIconsFromMapfileLabel(mapfileLabel: MapfileLabel): IconSymbolizer[] {
const labelStyles: IconSymbolizer[] = [];
mapfileLabel?.styles?.forEach((style: MapfileStyle) => {
if (style.symbol) {
labelStyles.push(this.getIconSymbolizerFromMapfileStyle(style));
labelStyles.push(this.getIconSymbolizerFromMapfileStyle(
{symbol: {image: style.symbol}} as unknown as MapfileStyle
));
}
});

if (labelStyles.length) {
return labelStyles;
} else {
return undefined;
}
return labelStyles;
}

/**
Expand Down

0 comments on commit 8526ce8

Please sign in to comment.