Skip to content

Commit cfb6e7e

Browse files
authored
Merge pull request #124 from geostyler/123-dont-show-outline-when-null
fix(123): remove stroke when 0
2 parents 74b8d63 + c8537e1 commit cfb6e7e

File tree

1 file changed

+32
-19
lines changed

1 file changed

+32
-19
lines changed

src/processSymbolLayer.ts

Lines changed: 32 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -135,28 +135,41 @@ const formatLineSymbolizer = (
135135
symbolizer: PointSymbolizer,
136136
layer: SymbolLayer,
137137
): LineSymbolizer => {
138-
const markerPlacement = layer.markerPlacement;
139-
if (layer.markerPlacement.type === "CIMMarkerPlacementAlongLineSameSize") {
140-
const size = ptToPxProp(layer, "size", 10);
141-
const template = processMarkerPlacementAlongLine(markerPlacement, size);
142-
return {
143-
kind: "Line",
144-
opacity: 1.0,
145-
width: size,
146-
perpendicularOffset: ptToPxProp(symbolizer, "perpendicularOffset", 0.0),
147-
graphicStroke: symbolizer,
148-
dasharray: template,
149-
};
150-
}
151-
return {
138+
const lineSymbolizer: LineSymbolizer = {
152139
kind: "Line",
153140
opacity: 1.0,
154-
perpendicularOffset: 0.0,
155141
graphicStroke: symbolizer,
156-
// @ts-ignore FIXME see issue #65
157-
graphicStrokeInterval: ptToPxProp(symbolizer, "size", 0) * 2,
158-
graphicStrokeOffset: 0.0,
159142
};
143+
const markerPlacement = layer.markerPlacement;
144+
if (layer.markerPlacement.type === "CIMMarkerPlacementAlongLineSameSize") {
145+
const size = ptToPxProp(layer, "size", 10);
146+
const template = processMarkerPlacementAlongLine(markerPlacement, size);
147+
if (symbolizer.kind === "Mark") {
148+
if (
149+
!symbolizer.wellKnownName.startsWith("wkt://") &&
150+
symbolizer.strokeWidth === 0
151+
) {
152+
// If the marker has a known shape with strokeWidth of 0, we don't want to render it because Geoserver still draws a line.
153+
delete symbolizer.strokeWidth;
154+
delete symbolizer.strokeColor;
155+
delete symbolizer.strokeOpacity;
156+
}
157+
}
158+
lineSymbolizer.width = size;
159+
lineSymbolizer.perpendicularOffset = ptToPxProp(
160+
symbolizer,
161+
"perpendicularOffset",
162+
0.0,
163+
);
164+
lineSymbolizer.dasharray = template;
165+
return lineSymbolizer;
166+
}
167+
lineSymbolizer.perpendicularOffset = 0;
168+
// @ts-ignore FIXME see issue #65
169+
lineSymbolizer.graphicStrokeInterval = ptToPxProp(symbolizer, "size", 0) * 2;
170+
// @ts-ignore FIXME see issue #65
171+
lineSymbolizer.graphicStrokeOffset = 0.0;
172+
return lineSymbolizer;
160173
};
161174

162175
const processMarkerPlacementAlongLine = (
@@ -622,7 +635,7 @@ const processSymbolHatchFill = (layer: SymbolLayer): Symbolizer[] => {
622635

623636
// Geoserver acts weird with tilted lines. Empirically, that's the best result so far:
624637
// Takes the double of the raw separation value. Line and dash lines are treated equally and are looking good.
625-
// For the straight hatch markers, it looks that dividing the value by 2 gives best results.
638+
// For the straight hatch markers, it looks that dividing the value by 2 gives best results.
626639
let rawSeparation = layer.separation || 0;
627640
let separation = getStraightHatchMarker().includes(wellKnowName)
628641
? ptToPx(rawSeparation) / 2

0 commit comments

Comments
 (0)