From 4a8ce1af0e55276344cc54522277140cf750381e Mon Sep 17 00:00:00 2001 From: Azgaar Date: Mon, 30 Sep 2024 20:49:25 +0200 Subject: [PATCH] feat: burgs - export icons --- modules/io/export.js | 18 ++++++++++++++---- modules/routes-generator.js | 4 ++-- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/modules/io/export.js b/modules/io/export.js index 92d31e50..075ac801 100644 --- a/modules/io/export.js +++ b/modules/io/export.js @@ -168,8 +168,9 @@ async function exportToPngTiles() { } // parse map svg to object url -async function getMapURL(type, options) { - const { +async function getMapURL( + type, + { debug = false, noLabels = false, noWater = false, @@ -177,8 +178,8 @@ async function getMapURL(type, options) { noIce = false, noVignette = false, fullMap = false - } = options || {}; - + } = {} +) { const cloneEl = byId("map").cloneNode(true); // clone svg cloneEl.id = "fantasyMap"; document.body.appendChild(cloneEl); @@ -307,6 +308,15 @@ async function getMapURL(type, options) { if (rose) cloneDefs.appendChild(rose.cloneNode(true)); } + // add burs icons + if (cloneEl.getElementById("burgIcons")) { + const groups = cloneEl.getElementById("burgIcons").querySelectorAll("g"); + for (const group of Array.from(groups)) { + const icon = svgDefs.querySelector(group.dataset.icon); + if (icon) cloneDefs.appendChild(icon.cloneNode(true)); + } + } + // add port icon if (cloneEl.getElementById("anchors")) { const anchor = svgDefs.getElementById("icon-anchor"); diff --git a/modules/routes-generator.js b/modules/routes-generator.js index bd119d06..5ff4abe2 100644 --- a/modules/routes-generator.js +++ b/modules/routes-generator.js @@ -537,7 +537,7 @@ window.Routes = (function () { return roadConnections.length > 2; } - const connectivityRates = { + const connectivityRateMap = { roads: 0.2, trails: 0.1, searoutes: 0.2, @@ -550,7 +550,7 @@ window.Routes = (function () { const connectivity = Object.values(connections).reduce((acc, routeId) => { const route = pack.routes.find(route => route.i === routeId); - const rate = connectivityRates[route.group] || connectivityRates.default; + const rate = connectivityRateMap[route.group] || connectivityRateMap.default; return acc + rate; }, 0.8);