Skip to content

Commit

Permalink
distinguished hedge and city_wall barriers (fixes #290)
Browse files Browse the repository at this point in the history
  • Loading branch information
zdila committed Dec 8, 2023
1 parent 90a2f8b commit d1ddd1f
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 9 deletions.
18 changes: 16 additions & 2 deletions style/Barrierways.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,27 @@
import { LineSymbolizer, Style } from "jsxnik/mapnikConfig";
import { hsl } from "./colors";
import { colors, hsl } from "./colors";
import { RuleEx } from "./RuleEx";
import { SqlLayer } from "./SqlLayer";

export function Barrierways() {
return (
<>
<Style name="barrierways">
<RuleEx minZoom={16}>
<RuleEx minZoom={16} type="city_wall">
<LineSymbolizer stroke={colors.building} strokeWidth={2} />
</RuleEx>

<RuleEx minZoom={16} type="hedge">
<LineSymbolizer
stroke={colors.pitch}
strokeWidth="@zoom - 14"
strokeDasharray="'0.01,' + (@zoom - 14)"
strokeLinejoin="round"
strokeLinecap="round"
/>
</RuleEx>

<RuleEx minZoom={16} fallback>
<LineSymbolizer stroke={hsl(0, 100, 50)} strokeWidth={1} strokeDasharray="2,1" />
</RuleEx>
</Style>
Expand Down
10 changes: 5 additions & 5 deletions style/Buildings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ export function Buildings() {
return (
<>
<Style name="buildings">
<RuleEx minZoom={13} filter="[type] <> 'ruins'">
<PolygonSymbolizer fill={colors.building} />
</RuleEx>

<RuleEx minZoom={14} filter="[type] = 'ruins'">
<RuleEx minZoom={14} type="ruins">
<PolygonSymbolizer fill={colors.building} fillOpacity={0.5} />
<LineSymbolizer stroke={colors.building} strokeDasharray="4 4" strokeWidth={2} offset={-1} />
</RuleEx>

<RuleEx minZoom={13} fallback>
<PolygonSymbolizer fill={colors.building} />
</RuleEx>
</Style>

<SqlLayer
Expand Down
6 changes: 4 additions & 2 deletions style/RuleEx.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Filter, MaxScaleDenominator, MinScaleDenominator, Rule } from "jsxnik/mapnikConfig";
import { ElseFilter, Filter, MaxScaleDenominator, MinScaleDenominator, Rule } from "jsxnik/mapnikConfig";
import { types, zoomDenoms } from "./utils";

type Props = {
Expand All @@ -7,15 +7,17 @@ type Props = {
type?: string | string[];
filter?: string;
children: JSX.Element;
fallback?: boolean;
};

export function RuleEx({ minZoom, maxZoom, type, filter, children }: Props) {
export function RuleEx({ minZoom, maxZoom, type, filter, children, fallback }: Props) {
return (
<Rule>
{minZoom !== undefined && <MaxScaleDenominator>{zoomDenoms[minZoom]}</MaxScaleDenominator>}
{maxZoom !== undefined && <MinScaleDenominator>{zoomDenoms[maxZoom + 1]}</MinScaleDenominator>}
{type != undefined && <Filter>{types(...(Array.isArray(type) ? type : [type]))}</Filter>}
{filter != undefined && <Filter>{filter}</Filter>}
{fallback && <ElseFilter />}
{children}
</Rule>
);
Expand Down

0 comments on commit d1ddd1f

Please sign in to comment.