feat: burgs - export icons

This commit is contained in:
Azgaar 2024-09-30 20:49:25 +02:00
parent 63898d8fd8
commit 4a8ce1af0e
2 changed files with 16 additions and 6 deletions

View file

@ -168,8 +168,9 @@ async function exportToPngTiles() {
} }
// parse map svg to object url // parse map svg to object url
async function getMapURL(type, options) { async function getMapURL(
const { type,
{
debug = false, debug = false,
noLabels = false, noLabels = false,
noWater = false, noWater = false,
@ -177,8 +178,8 @@ async function getMapURL(type, options) {
noIce = false, noIce = false,
noVignette = false, noVignette = false,
fullMap = false fullMap = false
} = options || {}; } = {}
) {
const cloneEl = byId("map").cloneNode(true); // clone svg const cloneEl = byId("map").cloneNode(true); // clone svg
cloneEl.id = "fantasyMap"; cloneEl.id = "fantasyMap";
document.body.appendChild(cloneEl); document.body.appendChild(cloneEl);
@ -307,6 +308,15 @@ async function getMapURL(type, options) {
if (rose) cloneDefs.appendChild(rose.cloneNode(true)); 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 // add port icon
if (cloneEl.getElementById("anchors")) { if (cloneEl.getElementById("anchors")) {
const anchor = svgDefs.getElementById("icon-anchor"); const anchor = svgDefs.getElementById("icon-anchor");

View file

@ -537,7 +537,7 @@ window.Routes = (function () {
return roadConnections.length > 2; return roadConnections.length > 2;
} }
const connectivityRates = { const connectivityRateMap = {
roads: 0.2, roads: 0.2,
trails: 0.1, trails: 0.1,
searoutes: 0.2, searoutes: 0.2,
@ -550,7 +550,7 @@ window.Routes = (function () {
const connectivity = Object.values(connections).reduce((acc, routeId) => { const connectivity = Object.values(connections).reduce((acc, routeId) => {
const route = pack.routes.find(route => route.i === 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; return acc + rate;
}, 0.8); }, 0.8);