Map textures after field test: forest texture dropped (too busy), scrub / dwarf pine gets its own tint + bushes from zoom 11 instead of the grass texture; strict reserves and natural monuments a step darker than landscape protected areas; fix military outline losing its source
This commit is contained in:
1 parent
25f5c42a1b
commit
357d28bf72
3 files changed
+36
-20
No files matched your search
+33
-18
@@ -97,12 +97,17 @@ const NATIONAL_PARK = ["any", ...["nation", "národn", "narodn", "nemzeti", "naz
|
||||
// National parks keep the flat Park Tiles sage; other protected areas
|
||||
// (nature reserves, landscape areas, Natura 2000, …) get a translucent
|
||||
// gray-green with a dashed edge, so the map tells "national park rules"
|
||||
// from "some protection" at a glance. Military areas red-hatched. Forest
|
||||
// and meadow get a tree/grass texture over their flat fill from zoom 12/13.
|
||||
// from "some protection" at a glance; strict reserves and monuments (where
|
||||
// you mostly can't leave the marked trail) a step darker than landscape
|
||||
// areas / Natura 2000. Military areas red-hatched. Meadows get a grass
|
||||
// texture from zoom 13, scrub / dwarf pine its own bushes from 11 (no forest texture: OSM rarely says what kind, and
|
||||
// trees everywhere were too busy).
|
||||
// The pattern images are drawn at runtime (patternImage below, on
|
||||
// MapLibre's styleimagemissing), so there's no sprite sheet to extend and
|
||||
// they work offline alike.
|
||||
const PROTECTED_FILL = "rgba(140, 165, 120, 0.18)";
|
||||
// ponytail: same substring trick as NATIONAL_PARK, a word per language.
|
||||
const STRICT_RESERVE = ["any", ...["rezerv", "reserv", "wilderness", "wildnis", "pamiatk", "památk", "monument", "denkmal"].map((word) => ["in", word, ["coalesce", ["get", "class"], ""]])];
|
||||
const protectedFill = (strict, other, nationalPark) => ["case", NATIONAL_PARK, nationalPark, STRICT_RESERVE, strict, other];
|
||||
const PROTECTED_LINE = "#7d9468";
|
||||
|
||||
function protectedAreasAndTextures(style) {
|
||||
@@ -112,7 +117,7 @@ function protectedAreasAndTextures(style) {
|
||||
const band = find("park_tintband");
|
||||
if (!park || !outline) return style;
|
||||
const sage = park.paint["fill-color"];
|
||||
park.paint["fill-color"] = ["case", ["!", NATIONAL_PARK], PROTECTED_FILL, sage];
|
||||
park.paint["fill-color"] = protectedFill("rgba(130, 160, 110, 0.32)", "rgba(140, 165, 120, 0.14)", sage);
|
||||
park.paint["fill-outline-color"] = ["case", ["!", NATIONAL_PARK], "rgba(0, 0, 0, 0)", sage];
|
||||
const protectedOutline = {
|
||||
...outline,
|
||||
@@ -124,8 +129,8 @@ function protectedAreasAndTextures(style) {
|
||||
if (band) band.filter = ["all", band.filter, NATIONAL_PARK];
|
||||
|
||||
const textures = [
|
||||
{ id: "landcover_wood_pattern", source: "landcover", class: "wood", pattern: "forest", minzoom: 12 },
|
||||
{ id: "landcover_grass_pattern", source: "landcover", class: "grass", pattern: "grass", minzoom: 13 },
|
||||
{ id: "landcover_grass_pattern", source: "landcover", class: "grass", pattern: "grass", minzoom: 13, not: "scrub" },
|
||||
{ id: "landcover_scrub_pattern", source: "landcover", class: "grass", pattern: "scrub", minzoom: 11, only: "scrub" },
|
||||
{ id: "landuse_military", source: "landuse", class: "military", pattern: "military", minzoom: 8 },
|
||||
].map((t) => ({
|
||||
id: t.id,
|
||||
@@ -133,11 +138,13 @@ function protectedAreasAndTextures(style) {
|
||||
source: park.source,
|
||||
"source-layer": t.source,
|
||||
minzoom: t.minzoom,
|
||||
filter: ["==", ["get", "class"], t.class],
|
||||
filter: ["all", ["==", ["get", "class"], t.class],
|
||||
...(t.not ? [["!=", ["get", "subclass"], t.not]] : []),
|
||||
...(t.only ? [["==", ["get", "subclass"], t.only]] : [])],
|
||||
paint: { "fill-pattern": `maptool-pattern-${t.pattern}` },
|
||||
}));
|
||||
const military = {
|
||||
...textures[2],
|
||||
...textures.find((t) => t.id === "landuse_military"),
|
||||
id: "landuse_military_outline",
|
||||
type: "line",
|
||||
paint: { "line-color": "#c0392b", "line-width": 1.2, "line-opacity": 0.7 },
|
||||
@@ -149,8 +156,10 @@ function protectedAreasAndTextures(style) {
|
||||
}
|
||||
|
||||
const PATTERNS = {
|
||||
forest: { day: "rgba(110, 130, 90, 0.45)", night: "rgba(120, 150, 110, 0.35)" },
|
||||
grass: { day: "rgba(130, 140, 95, 0.45)", night: "rgba(120, 140, 105, 0.3)" },
|
||||
// Scrub, incl. dwarf pine (kosodrevina) above the tree line: its own
|
||||
// tint (bg) plus bushes, so it reads apart from both meadow and forest.
|
||||
scrub: { day: "rgba(95, 125, 80, 0.55)", night: "rgba(110, 140, 100, 0.4)", bg: "rgba(150, 170, 120, 0.3)", bgNight: "rgba(60, 80, 55, 0.35)" },
|
||||
military: { day: "rgba(192, 57, 43, 0.4)", night: "rgba(192, 57, 43, 0.35)" },
|
||||
};
|
||||
|
||||
@@ -166,13 +175,19 @@ export function patternImage(id) {
|
||||
ctx.strokeStyle = ctx.fillStyle = match[2] ? colors.night : colors.day;
|
||||
ctx.lineWidth = 2;
|
||||
ctx.lineCap = "round";
|
||||
if (match[1] === "forest") {
|
||||
// Two little trees, staggered, so the texture doesn't read as a grid.
|
||||
for (const [x, y] of [[12, 14], [36, 38]]) {
|
||||
ctx.beginPath();
|
||||
ctx.arc(x, y - 3, 6, 0, 2 * Math.PI);
|
||||
ctx.fill();
|
||||
ctx.fillRect(x - 1, y + 2, 2, 5);
|
||||
if (colors.bg) {
|
||||
ctx.fillStyle = match[2] ? colors.bgNight : colors.bg;
|
||||
ctx.fillRect(0, 0, size, size);
|
||||
ctx.fillStyle = match[2] ? colors.night : colors.day;
|
||||
}
|
||||
if (match[1] === "scrub") {
|
||||
// Low bushes: three overlapping dots each, staggered.
|
||||
for (const [x, y] of [[12, 16], [36, 40], [34, 14], [10, 38]]) {
|
||||
for (const dx of [-3, 0, 3]) {
|
||||
ctx.beginPath();
|
||||
ctx.arc(x + dx, y - (dx ? 0 : 2), 3, 0, 2 * Math.PI);
|
||||
ctx.fill();
|
||||
}
|
||||
}
|
||||
} else if (match[1] === "grass") {
|
||||
for (const [x, y] of [[10, 16], [34, 40], [30, 12]]) {
|
||||
@@ -247,13 +262,13 @@ const NIGHT_PATCH = {
|
||||
waterway_river: { "line-color": "#1a3040" },
|
||||
waterway_other: { "line-color": "#1a3040" },
|
||||
park: {
|
||||
"fill-color": ["case", ["!", NATIONAL_PARK], "rgba(120, 150, 110, 0.12)", "#1f2b22"],
|
||||
"fill-color": protectedFill("rgba(120, 150, 110, 0.2)", "rgba(120, 150, 110, 0.09)", "#1f2b22"),
|
||||
"fill-outline-color": ["case", ["!", NATIONAL_PARK], "rgba(0, 0, 0, 0)", "#1f2b22"],
|
||||
},
|
||||
park_outline: { "line-color": "#4f6b3a" },
|
||||
park_outline_protected: { "line-color": "#46593a" },
|
||||
landcover_wood_pattern: { "fill-pattern": "maptool-pattern-forest-night" },
|
||||
landcover_grass_pattern: { "fill-pattern": "maptool-pattern-grass-night" },
|
||||
landcover_scrub_pattern: { "fill-pattern": "maptool-pattern-scrub-night" },
|
||||
landuse_military: { "fill-pattern": "maptool-pattern-military-night" },
|
||||
landuse_military_outline: { "line-color": "#8a3a30" },
|
||||
park_tintband: { "line-color": "#2b3a26" },
|
||||
|
||||
Reference in new issue
Block a user