Skip to content

Commit

Permalink
fix: add graphic fill padding on fill symbolizer
Browse files Browse the repository at this point in the history
  • Loading branch information
ger-benjamin committed Dec 3, 2024
1 parent 9f981a7 commit 53d120f
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 12 deletions.
57 changes: 57 additions & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .idea/codeStyles/codeStyleConfig.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"lint:typecheck:test": "npm run lint && npm run typecheck && npm run test"
},
"dependencies": {
"geostyler-style": "^9.0.1"
"geostyler-style": "^9.2.0"
},
"devDependencies": {
"@babel/cli": "^7.25.7",
Expand All @@ -53,7 +53,7 @@
"coveralls": "^3.1.1",
"eslint": "^8.40.0",
"eslint-config-prettier": "^9.1.0",
"prettier": "^3.3.3",
"prettier": "^3.4.0",
"typescript": "^5.4.5",
"vitest": "^2.0.0"
},
Expand Down
6 changes: 2 additions & 4 deletions src/processSymbolLayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,16 +307,14 @@ const processSymbolHatchFill = (layer: SymbolLayer): Symbolizer => {
// To keep the "original size" given by the separation value, we play with a negative margin.
let negativeMargin = ((neededSize - separation) / 2) * -1;
if (wellKnowName === getStraightHatchMarker()[0]) {
// @ts-ignore FIXME see issue #64
fillSymbolizer.graphicFillMargin = [
fillSymbolizer.graphicFillPadding = [
negativeMargin,
0,
negativeMargin,
0,
];
} else {
// @ts-ignore FIXME see issue #64
fillSymbolizer.graphicFillMargin = [
fillSymbolizer.graphicFillPadding = [
0,
negativeMargin,
0,
Expand Down
13 changes: 9 additions & 4 deletions src/processSymbolReference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
import { Options } from "./types.ts";
import { processSymbolLayer } from "./processSymbolLayer.ts";
import {
Expression,
FillSymbolizer,
LineSymbolizer,
MarkSymbolizer,
Expand Down Expand Up @@ -137,16 +138,15 @@ const formatPolygonSymbolizer = (
): FillSymbolizer | LineSymbolizer | null => {
const markerPlacementType = markerPlacement.type;
if (markerPlacementType === "CIMMarkerPlacementInsidePolygon") {
const margin = processMarkerPlacementInsidePolygon(
const padding = processMarkerPlacementInsidePolygon(
symbolizer,
markerPlacement,
);
return {
kind: "Fill",
opacity: 1.0,
graphicFill: symbolizer,
// @ts-ignore FIXME see issue #64
graphicFillMargin: margin,
graphicFillPadding: padding,
};
}
if (markerPlacementType === "CIMMarkerPlacementAlongLineSameSize") {
Expand Down Expand Up @@ -238,7 +238,12 @@ const processOrientedMarkerAtEndOfLine = (
const processMarkerPlacementInsidePolygon = (
symbolizer: MarkSymbolizer,
markerPlacement: CIMMarkerPlacement,
): number[] => {
): [
Expression<number>,
Expression<number>,
Expression<number>,
Expression<number>,
] => {
const resizeFactor = symbolizer?.wellKnownName?.startsWith("wkt://POLYGON")
? 1
: POLYGON_FILL_RESIZE_FACTOR;
Expand Down

0 comments on commit 53d120f

Please sign in to comment.