Files
maps-saas/apps/web/scripts/build_tactical_style.ts
T

266 lines
7.3 KiB
TypeScript

import * as fs from 'fs';
import * as path from 'path';
const stylePath = path.join(__dirname, '../public/style.json');
const tacticalStylePath = path.join(__dirname, '../public/tactical-style.json');
const baseStyle = JSON.parse(fs.readFileSync(stylePath, 'utf8'));
// Clone the base style
const tacticalStyle = {
...baseStyle,
name: "Intaleq Sovereign Tactical Military Style (منظومة الدفاع التكتيكية)",
metadata: {
...baseStyle.metadata,
version: "3.0.0-tactical",
description: "Sovereign Military Tactical Style with Rock Escarpments, Cliffs, Retaining Walls, Berms, Wadis, Quarries, and Man-Made Obstacles"
}
};
// Define Tactical Obstacle & Terrain Layers
const tacticalLayers = [
// ── 1. NATRUAL ROCK & TERRAIN POLYGONS (المقاطع والكتل الصخرية والمقالع) ──
{
id: "tactical-bare-rock-poly",
type: "fill",
source: "local-osm-polygons",
filter: ["in", "natural", "bare_rock", "rock", "scree", "shingle", "bedrock"],
paint: {
"fill-color": "#78716c",
"fill-opacity": 0.4
}
},
{
id: "tactical-bare-rock-outline",
type: "line",
source: "local-osm-polygons",
filter: ["in", "natural", "bare_rock", "rock", "scree", "shingle", "bedrock"],
paint: {
"line-color": "#57534e",
"line-width": 1.5,
"line-dasharray": [3, 2]
}
},
{
id: "tactical-quarry-poly",
type: "fill",
source: "local-osm-polygons",
filter: ["any", ["==", "landuse", "quarry"], ["==", "man_made", "quarry"], ["==", "landuse", "surface_mining"]],
paint: {
"fill-color": "#d97706",
"fill-opacity": 0.25
}
},
{
id: "tactical-quarry-outline",
type: "line",
source: "local-osm-polygons",
filter: ["any", ["==", "landuse", "quarry"], ["==", "man_made", "quarry"], ["==", "landuse", "surface_mining"]],
paint: {
"line-color": "#b45309",
"line-width": 2.0,
"line-dasharray": [4, 2]
}
},
{
id: "tactical-wetland-poly",
type: "fill",
source: "local-osm-polygons",
filter: ["any", ["==", "natural", "wetland"], ["==", "wetland", "marsh"], ["==", "natural", "marsh"]],
paint: {
"fill-color": "#0d9488",
"fill-opacity": 0.35
}
},
// ── 2. HYDROLOGICAL DEFILS & WADIS (مجاري الأودية والسيول الجافة) ──
{
id: "tactical-wadis-lines",
type: "line",
source: "local-osm-lines",
filter: ["in", "waterway", "wadi", "dry_stream", "drain", "ditch"],
paint: {
"line-color": "#0891b2",
"line-width": 2.2,
"line-dasharray": [3, 2],
"line-opacity": 0.95
}
},
// ── 3. CLIFFS & ESCARPMENTS (الجروف الصخرية الشاهقة والنتوءات الحادة) ──
{
id: "tactical-cliffs-casing",
type: "line",
source: "local-osm-lines",
filter: ["==", "natural", "cliff"],
paint: {
"line-color": "#451a03",
"line-width": 4.5,
"line-opacity": 0.9
}
},
{
id: "tactical-cliffs-inner",
type: "line",
source: "local-osm-lines",
filter: ["==", "natural", "cliff"],
paint: {
"line-color": "#dc2626",
"line-width": 2.2,
"line-dasharray": [2, 2]
}
},
{
id: "tactical-ridges-lines",
type: "line",
source: "local-osm-lines",
filter: ["in", "natural", "ridge", "arete"],
paint: {
"line-color": "#92400e",
"line-width": 2.5,
"line-dasharray": [4, 2]
}
},
// ── 4. MAN-MADE BARRIERS (الجدران الاستنادية، السواتر الترابية، الحواجز والأسوار) ──
{
id: "tactical-retaining-walls",
type: "line",
source: "local-osm-lines",
filter: ["==", "barrier", "retaining_wall"],
paint: {
"line-color": "#e11d48",
"line-width": 3.0,
"line-opacity": 1.0
}
},
{
id: "tactical-berms-embankments",
type: "line",
source: "local-osm-lines",
filter: ["any", ["==", "barrier", "berm"], ["==", "man_made", "embankment"]],
paint: {
"line-color": "#f59e0b",
"line-width": 2.8,
"line-dasharray": [3, 1]
}
},
{
id: "tactical-trenches-ditches",
type: "line",
source: "local-osm-lines",
filter: ["==", "barrier", "ditch"],
paint: {
"line-color": "#881337",
"line-width": 2.5,
"line-dasharray": [2, 2]
}
},
{
id: "tactical-fences-walls",
type: "line",
source: "local-osm-lines",
filter: ["in", "barrier", "wall", "jersey_barrier", "fence", "wire_fence"],
paint: {
"line-color": "#991b1b",
"line-width": 1.8,
"line-dasharray": [3, 2]
}
},
// ── 5. TACTICAL POINTS (فتحات المغاور والكهوف، الشلالات، والمكاشف الصخرية) ──
{
id: "tactical-cave-entrances",
type: "circle",
source: "local-osm-points",
filter: ["==", "natural", "cave_entrance"],
paint: {
"circle-radius": 5.5,
"circle-color": "#1e293b",
"circle-stroke-color": "#f59e0b",
"circle-stroke-width": 2
}
},
{
id: "tactical-waterfalls",
type: "circle",
source: "local-osm-points",
filter: ["==", "waterway", "waterfall"],
paint: {
"circle-radius": 5,
"circle-color": "#06b6d4",
"circle-stroke-color": "#ffffff",
"circle-stroke-width": 2
}
},
{
id: "tactical-outcrops",
type: "circle",
source: "local-osm-points",
filter: ["==", "geological", "outcrop"],
paint: {
"circle-radius": 4.5,
"circle-color": "#c2410c",
"circle-stroke-color": "#ffffff",
"circle-stroke-width": 1.5
}
},
// ── 6. TACTICAL LABELS (تسميات الموانع والمعالم التكتيكية الحاكمة) ──
{
id: "tactical-obstacle-text-lines",
type: "symbol",
source: "local-osm-lines",
filter: ["any",
["==", "natural", "cliff"],
["==", "barrier", "retaining_wall"],
["==", "waterway", "wadi"],
["in", "natural", "ridge", "arete"]
],
minzoom: 12,
layout: {
"symbol-placement": "line",
"text-field": "{name}",
"text-size": 11,
"text-font": ["Noto Sans Arabic Bold", "Open Sans Bold"],
"text-letter-spacing": 0.05
},
paint: {
"text-color": "#7f1d1d",
"text-halo-color": "#ffffff",
"text-halo-width": 2.0
}
},
{
id: "tactical-obstacle-text-poly",
type: "symbol",
source: "local-osm-polygons",
filter: ["any",
["==", "landuse", "quarry"],
["in", "natural", "bare_rock", "rock", "scree", "wetland"]
],
minzoom: 12,
layout: {
"text-field": "{name}",
"text-size": 11,
"text-font": ["Noto Sans Arabic Bold", "Open Sans Bold"]
},
paint: {
"text-color": "#78350f",
"text-halo-color": "#ffffff",
"text-halo-width": 2.0
}
}
];
// Insert the tactical layers before road labels and text symbols for optimal z-ordering
const textIndex = tacticalStyle.layers.findIndex((l: any) => l.id.includes('label') || l.type === 'symbol');
if (textIndex > -1) {
tacticalStyle.layers.splice(textIndex, 0, ...tacticalLayers);
} else {
tacticalStyle.layers.push(...tacticalLayers);
}
fs.writeFileSync(tacticalStylePath, JSON.stringify(tacticalStyle, null, 2), 'utf8');
console.log(`✅ Successfully generated tactical-style.json with ${tacticalLayers.length} tactical obstacle layers!`);