feat(index): language, colors

This commit is contained in:
HangerThem 2026-11-07 10:21:47 +01:00
parent 41698e338c
commit 3d75509a6e

View file

@ -6,8 +6,8 @@
<title>Building-use map – Czechia (RÚIAN)</title>
<!--
Single-file app, no dependencies. Open it locally or host it as a static file.
Data: live queries to the public ČÚZK ArcGIS services (RÚIAN buildings, ZABAGED roads/water/green).
© ČÚZK. A Chrastava sample is embedded so the app works without a network connection.
Data: live queries to the public ČÚZK ArcGIS services (RÚIAN buildings, ZABAGED roads/water/green), © ČÚZK.
A small built-in example area is used as a fallback when the live service cannot be reached.
-->
<style>
:root{--bg:#f5f2ea;--ink:#1d1d1f;--mut:#666;--line:#d8d4c8;--acc:#1f5fbf}
@ -16,8 +16,10 @@
body{font:14px/1.4 system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;color:var(--ink);background:#fff}
#app{display:grid;grid-template-columns:340px 1fr;height:100%}
aside{overflow:auto;border-right:1px solid var(--line);padding:14px 14px 24px;background:#fbfaf6}
.head{display:flex;gap:8px;align-items:flex-start;justify-content:space-between}
h1{font-size:17px;margin:0 0 2px}
h1 small{display:block;font-weight:400;color:var(--mut);font-size:12px;margin-top:2px}
#lang{width:auto;padding:4px 6px;font-size:12px;flex:none}
h2{font-size:12px;text-transform:uppercase;letter-spacing:.06em;color:var(--mut);margin:18px 0 6px}
label{display:block;font-size:12px;color:var(--mut);margin:10px 0 3px}
input[type=text],select{width:100%;padding:7px 8px;border:1px solid #c9c5b8;border-radius:6px;font:inherit;background:#fff}
@ -30,12 +32,11 @@
#status{margin-top:10px;font-size:12px;min-height:16px;color:var(--mut);white-space:pre-wrap}
#status.err{color:#b3261e}
#status.ok{color:#1b6e2a}
.leg{display:flex;align-items:center;gap:8px;padding:3px 0;cursor:pointer;user-select:none}
.leg{display:flex;align-items:center;gap:8px;padding:3px 0;cursor:pointer;user-select:none;color:var(--ink);font-size:14px;margin:0}
.leg input{margin:0}
.sw{width:18px;height:12px;border:1px solid #555;border-radius:2px;flex:none}
.leg .n{margin-left:auto;color:var(--mut);font-variant-numeric:tabular-nums}
.leg.off{opacity:.4}
.leg.zero{display:none}
.chk{display:flex;gap:8px;align-items:center;margin:6px 0;color:var(--ink);font-size:13px}
.chk input{margin:0}
.exp{display:grid;grid-template-columns:1fr 1fr;gap:8px}
@ -67,51 +68,51 @@
<body>
<div id="app">
<aside>
<h1>Building-use map <small>Czechia · RÚIAN buildings over ZABAGED roads &amp; rivers (ČÚZK)</small></h1>
<div class="head">
<h1><span data-i18n="title">Building-use map</span> <small data-i18n="subtitle"></small></h1>
<select id="lang" aria-label="Language"><option value="cs">CS</option><option value="en">EN</option></select>
</div>
<label for="loc">Location – Mapy.com link, “lat, lon”, or “lon, lat”</label>
<label for="loc" data-i18n="locLabel"></label>
<input id="loc" type="text" value="https://mapy.com/en/turisticka?l=0&x=14.9686780&y=50.8171633&z=16.762" spellcheck="false">
<label for="radius">Radius <output id="rv">300 m</output></label>
<label for="radius"><span data-i18n="radius"></span> <output id="rv">300 m</output></label>
<input id="radius" type="range" min="100" max="700" step="50" value="300">
<div class="row">
<button id="load">Load area</button>
<button id="sample" class="ghost">Chrastava sample</button>
</div>
<div class="row"><button id="load" data-i18n="load"></button></div>
<div id="status"></div>
<h2>Layers <span id="total" style="text-transform:none;letter-spacing:0"></span></h2>
<h2><span data-i18n="layers"></span> <span id="total" style="text-transform:none;letter-spacing:0"></span></h2>
<div id="legend"></div>
<h2>Display</h2>
<label class="chk"><input type="checkbox" id="optBase" checked> Roads, rivers, green areas</label>
<label class="chk"><input type="checkbox" id="optNums" checked> House numbers when zoomed in</label>
<label for="mixrule">Mixed-use rule</label>
<select id="mixrule">
<option value="1">Non-residential use with ≥ 1 flat</option>
<option value="2">Non-residential use with ≥ 2 flats</option>
<option value="0">Off</option>
<h2 data-i18n="display"></h2>
<label for="colormode" data-i18n="colorMode"></label>
<select id="colormode">
<option value="simple" data-i18n="modeSimple"></option>
<option value="detailed" data-i18n="modeDetailed"></option>
</select>
<label for="mixrule" data-i18n="mixLabel"></label>
<select id="mixrule">
<option value="1" data-i18n="mix1"></option>
<option value="2" data-i18n="mix2"></option>
<option value="0" data-i18n="mix0"></option>
</select>
<label class="chk"><input type="checkbox" id="optBase" checked> <span data-i18n="optBase"></span></label>
<label class="chk"><input type="checkbox" id="optNums" checked> <span data-i18n="optNums"></span></label>
<h2>Export</h2>
<h2 data-i18n="export"></h2>
<div class="exp">
<button id="expPng" class="ghost">PNG</button>
<button id="expSvg" class="ghost">SVG</button>
<button id="expCsv" class="ghost">CSV table</button>
<button id="expPrint" class="ghost">Print / PDF</button>
<button id="expCsv" class="ghost" data-i18n="csv"></button>
<button id="expPrint" class="ghost" data-i18n="print"></button>
</div>
<p class="note">
Colours come from the registered use (způsob využití) in RÚIAN. RÚIAN has no “mixed” class, so orange marks
buildings whose registered use is non-residential (shop, civic, technical…) but which also have flats. Apartment
blocks with shops on the ground floor are still registered as apartment buildings and stay red.<br><br>
Data © ČÚZK (RÚIAN, ZABAGED). Drag to pan, scroll or pinch to zoom, click a building for details.
</p>
<p class="note" id="note"></p>
</aside>
<main id="stage">
<canvas id="cv"></canvas>
<div class="zoom"><button id="zin" title="Zoom in">+</button><button id="zout" title="Zoom out">−</button><button id="zfit" title="Fit" style="font-size:13px">⤢</button></div>
<div class="zoom"><button id="zin">+</button><button id="zout">−</button><button id="zfit" style="font-size:13px">⤢</button></div>
<div id="tip"></div>
<div id="info"></div>
</main>
@ -121,49 +122,155 @@
(() => {
'use strict';
/* ---------- geometry helpers ---------- */
/* ================= i18n ================= */
const L = {
en: {
title: 'Building-use map',
subtitle: 'Czechia · RÚIAN buildings over ZABAGED roads & rivers (ČÚZK)',
locLabel: 'Location – Mapy.com link, “lat, lon”, or “lon, lat”',
radius: 'Radius', load: 'Load area', layers: 'Layers', display: 'Display',
colorMode: 'Colour scheme', modeSimple: 'Simple – grouped categories', modeDetailed: 'Detailed – one colour per use code',
mixLabel: 'Mixed-use rule', mix1: 'Non-residential use with ≥ 1 flat', mix2: 'Non-residential use with ≥ 2 flats', mix0: 'Off',
optBase: 'Roads, rivers, green areas', optNums: 'House numbers when zoomed in',
export: 'Export', csv: 'CSV table', print: 'Print / PDF',
note: 'Colours come from the registered use (způsob využití) in RÚIAN. RÚIAN has no “mixed” class, so orange marks buildings whose registered use is non-residential (shop, civic, technical…) but which also have flats. Apartment blocks with shops on the ground floor are still registered as apartment buildings and stay red.<br><br>Data © ČÚZK (RÚIAN, ZABAGED). Drag to pan, scroll or pinch to zoom, click a building for details.',
nBuildings: n => `· ${n} buildings`,
st_loading: 'Loading buildings and basemap from ČÚZK…',
st_progress: (n, m) => `Loading from ČÚZK… ${n}/${m} requests done`,
st_loaded: (loc, n) => `${loc}: ${n} buildings.`,
st_baseFail: n => `${n} basemap layer(s) failed:`,
st_none: 'No buildings found here (outside Czechia, or an empty area).',
st_badLoc: 'Could not read a location. Paste a Mapy.com link or "50.8171, 14.9687".',
st_err: e => `Could not load data from ČÚZK: ${e}\nThe service may be down, you may be offline, or this page is running somewhere that blocks requests to other sites (some embedded viewers do). Opening the file directly in a browser or hosting it yourself works.`,
st_fallback: e => `Showing the built-in example area (Chrastava centre) because live data could not be loaded: ${e}`,
st_init: 'Loading live data…',
hn: n => `č.p. ${n}`, nohn: 'No house number',
i_cat: 'Category', i_use: 'RÚIAN use', i_flats: 'Flats', i_floors: 'Floors', i_area: 'Built-up area', i_done: 'Completed', i_pos: 'Position',
b_water: 'River / water', b_green: 'Green area / garden', b_road: 'Main road', b_street: 'Street',
zoomIn: 'Zoom in', zoomOut: 'Zoom out', fit: 'Fit', close: 'Close',
'cat.res': 'Residential – family house', 'cat.unit': 'Unit housing – apartment building',
'cat.rec': 'Recreational / garden house (chata)', 'cat.mix': 'Mixed – non-residential use + flats',
'cat.civic': 'Public / civic (admin, school, health…)', 'cat.assem': 'Assembly (church, hall, club)',
'cat.shop': 'Commercial – shop', 'cat.hotel': 'Accommodation', 'cat.office': 'Administration / office',
'cat.ind': 'Industrial / production / storage', 'cat.agri': 'Agricultural', 'cat.tech': 'Technical / transport',
'cat.garage': 'Garage', 'cat.other': 'Other / outbuilding / shed',
use: { 1:'Industrial building', 2:'Farmstead', 3:'Dwelling (generic)', 4:'Forestry building', 5:'Civic amenity building',
6:'Apartment building', 7:'Family house', 8:'Family recreation building (chata)', 9:'Assembly building',
10:'Shop', 11:'Accommodation building', 12:'Production & storage', 13:'Agricultural building',
14:'Administration building', 15:'Civic facilities building', 16:'Technical facilities building',
17:'Transport building', 18:'Garage', 19:'Other building', 20:'Multi-purpose building', 21:'Greenhouse',
w:'Water structures (dams, weirs…)', 0:'No registered use' },
},
cs: {
title: 'Mapa využití budov',
subtitle: 'Česko · budovy z RÚIAN nad silnicemi a vodními toky ZABAGED (ČÚZK)',
locLabel: 'Poloha – odkaz z Mapy.com, „šířka, délka“ nebo „délka, šířka“',
radius: 'Poloměr', load: 'Načíst oblast', layers: 'Vrstvy', display: 'Zobrazení',
colorMode: 'Barevné schéma', modeSimple: 'Jednoduché – sloučené kategorie', modeDetailed: 'Podrobné – každý druh využití zvlášť',
mixLabel: 'Pravidlo pro smíšené využití', mix1: 'Nebytové využití s ≥ 1 bytem', mix2: 'Nebytové využití s ≥ 2 byty', mix0: 'Vypnuto',
optBase: 'Silnice, řeky, zeleň', optNums: 'Čísla popisná při přiblížení',
export: 'Export', csv: 'Tabulka CSV', print: 'Tisk / PDF',
note: 'Barvy vycházejí ze způsobu využití zapsaného v RÚIAN. RÚIAN nemá třídu „smíšený“, proto oranžová označuje budovy, jejichž zapsané využití je nebytové (obchod, občanská vybavenost, technické…), ale které mají i byty. Bytové domy s obchodem v přízemí jsou v registru vedeny jako bytové domy, a zůstávají proto červené.<br><br>Data © ČÚZK (RÚIAN, ZABAGED). Tažením posouváte mapu, kolečkem nebo štípnutím přibližujete, kliknutím na budovu zobrazíte podrobnosti.',
nBuildings: n => `· ${n} budov`,
st_loading: 'Načítám budovy a podklad z ČÚZK…',
st_progress: (n, m) => `Načítání z ČÚZK… hotovo ${n}/${m} dotazů`,
st_loaded: (loc, n) => `${loc}: ${n} budov.`,
st_baseFail: n => `Nepodařilo se načíst vrstev podkladu: ${n}`,
st_none: 'Na tomto místě nejsou žádné budovy (mimo Česko, nebo prázdná oblast).',
st_badLoc: 'Polohu se nepodařilo přečíst. Vložte odkaz z Mapy.com nebo „50.8171, 14.9687“.',
st_err: e => `Data z ČÚZK se nepodařilo načíst: ${e}\nSlužba může být nedostupná, můžete být offline, nebo stránka běží v prostředí, které blokuje požadavky na jiné weby (některé vestavěné prohlížeče). Otevření souboru přímo v prohlížeči nebo vlastní hosting funguje.`,
st_fallback: e => `Zobrazen vestavěný příklad (centrum Chrastavy), protože se živá data nepodařilo načíst: ${e}`,
st_init: 'Načítám živá data…',
hn: n => `č.p. ${n}`, nohn: 'Bez čísla popisného',
i_cat: 'Kategorie', i_use: 'Využití v RÚIAN', i_flats: 'Byty', i_floors: 'Podlaží', i_area: 'Zastavěná plocha', i_done: 'Dokončeno', i_pos: 'Poloha',
b_water: 'Řeka / voda', b_green: 'Zeleň / zahrady', b_road: 'Silnice', b_street: 'Ulice',
zoomIn: 'Přiblížit', zoomOut: 'Oddálit', fit: 'Celá oblast', close: 'Zavřít',
'cat.res': 'Bydlení – rodinný dům', 'cat.unit': 'Bytové domy',
'cat.rec': 'Rekreace / zahrádkářské chaty', 'cat.mix': 'Smíšené – nebytové využití + byty',
'cat.civic': 'Veřejné / občanská vybavenost (úřady, školy, zdravotnictví…)', 'cat.assem': 'Shromažďování (kostel, sál, klub)',
'cat.shop': 'Obchod', 'cat.hotel': 'Ubytování', 'cat.office': 'Administrativa / kanceláře',
'cat.ind': 'Průmysl / výroba / sklady', 'cat.agri': 'Zemědělství', 'cat.tech': 'Technické / doprava',
'cat.garage': 'Garáž', 'cat.other': 'Ostatní / hospodářské budovy / kůlny',
use: { 1:'Průmyslový objekt', 2:'Zemědělská usedlost', 3:'Objekt k bydlení', 4:'Objekt lesního hospodářství',
5:'Objekt občanské vybavenosti', 6:'Bytový dům', 7:'Rodinný dům', 8:'Stavba pro rodinnou rekreaci',
9:'Stavba pro shromažďování většího počtu osob', 10:'Stavba pro obchod', 11:'Stavba ubytovacího zařízení',
12:'Stavba pro výrobu a skladování', 13:'Zemědělská stavba', 14:'Stavba pro administrativu',
15:'Stavba občanského vybavení', 16:'Stavba technického vybavení', 17:'Stavba pro dopravu', 18:'Garáž',
19:'Jiná stavba', 20:'Víceúčelová stavba', 21:'Skleník',
w:'Vodní stavby (přehrady, jezy…)', 0:'Bez zapsaného využití' },
},
};
function detectLang() {
let saved = null;
try { saved = localStorage.getItem('bum-lang'); } catch (e) {}
if (saved === 'cs' || saved === 'en') return saved;
const prefs = (navigator.languages && navigator.languages.length ? navigator.languages : [navigator.language || 'en']);
return String(prefs[0] || 'en').toLowerCase().startsWith('cs') ? 'cs' : 'en';
}
let lang = detectLang();
const t = (k, ...a) => { const v = (L[lang][k] !== undefined ? L[lang][k] : L.en[k]); return typeof v === 'function' ? v(...a) : (v === undefined ? k : v); };
const useName = u => (L[lang].use[u] || L.en.use[u] || '');
/* ================= geometry helpers ================= */
const R = 6378137, D2R = Math.PI / 180;
const ll2m = (lon, lat) => [R * lon * D2R, R * Math.log(Math.tan(Math.PI / 4 + lat * D2R / 2))];
const m2ll = (x, y) => [x / R / D2R, (2 * Math.atan(Math.exp(y / R)) - Math.PI / 2) / D2R];
/* ---------- categories ---------- */
// key, label, colour, show house numbers
const CATS = [
['res', 'Residential – family house', '#000000', 0],
['unit', 'Unit housing – apartment building', '#d62728', 1],
['rec', 'Recreational / garden house (chata)', '#2ca02c', 1],
['mix', 'Mixed – non-residential use + flats', '#ff8c00', 1],
['civic', 'Public / civic (admin, school, health…)', '#1f5fbf', 1],
['assem', 'Assembly (church, hall, club)', '#4fb3e8', 1],
['shop', 'Commercial – shop', '#e377c2', 1],
['hotel', 'Accommodation', '#e8c000', 1],
['office','Administration / office', '#17808a', 1],
['ind', 'Industrial / production / storage', '#7b3294', 1],
['agri', 'Agricultural', '#8c564b', 0],
['tech', 'Technical / transport', '#4d4d4d', 0],
['garage','Garage', '#d9b77e', 0],
['other', 'Other / outbuilding / shed', '#bdbdbd', 0],
/* ================= categories ================= */
// Simple scheme: key, colour, show house number
const SIMPLE = [
['res', '#000000', 0], ['unit', '#d62728', 1], ['rec', '#2ca02c', 1], ['mix', '#ff8c00', 1],
['civic', '#1f5fbf', 1], ['assem', '#4fb3e8', 1], ['shop', '#e377c2', 1], ['hotel', '#e8c000', 1],
['office', '#17808a', 1], ['ind', '#7b3294', 1], ['agri', '#8c564b', 0], ['tech', '#4d4d4d', 0],
['garage', '#d9b77e', 0], ['other', '#bdbdbd', 0],
];
const CAT = Object.fromEntries(CATS.map(c => [c[0], { label: c[1], color: c[2], nums: !!c[3] }]));
const SIMPLE_COLOR = Object.fromEntries(SIMPLE.map(c => [c[0], c[1]]));
const SIMPLE_NUMS = Object.fromEntries(SIMPLE.map(c => [c[0], !!c[2]]));
const SIMPLE_ORDER = ['other', 'garage', 'agri', 'tech', 'ind', 'office', 'hotel', 'shop', 'assem', 'civic', 'res', 'unit', 'rec', 'mix'];
const USE_CAT = {1:'ind',2:'agri',4:'agri',5:'civic',6:'unit',7:'res',8:'rec',9:'assem',10:'shop',11:'hotel',12:'ind',
13:'agri',14:'office',15:'civic',16:'tech',17:'tech',18:'garage',19:'other',20:'other',21:'other'};
const USE_NAME = {1:'průmyslový objekt',2:'zemědělská usedlost',3:'objekt k bydlení',4:'objekt lesního hospodářství',
5:'objekt občanské vybavenosti',6:'bytový dům',7:'rodinný dům',8:'stavba pro rodinnou rekreaci',
9:'stavba pro shromažďování většího počtu osob',10:'stavba pro obchod',11:'stavba ubytovacího zařízení',
12:'stavba pro výrobu a skladování',13:'zemědělská stavba',14:'stavba pro administrativu',
15:'stavba občanského vybavení',16:'stavba technického vybavení',17:'stavba pro dopravu',18:'garáž',
19:'jiná stavba',20:'víceúčelová stavba',21:'skleník'};
function classify(use, flats) {
// Detailed scheme: one entry per RÚIAN use code
const DETAIL_COLOR = {
u1:'#7b3294', u2:'#8c564b', u3:'#ff9896', u4:'#556b2f', u5:'#1f5fbf', u6:'#d62728', u7:'#000000', u8:'#2ca02c',
u9:'#4fb3e8', u10:'#e377c2', u11:'#e8c000', u12:'#b39ddb', u13:'#bc8f6f', u14:'#17808a', u15:'#3949ab',
u16:'#4d4d4d', u17:'#7f7f3f', u18:'#d9b77e', u19:'#bdbdbd', u20:'#26c6da', u21:'#a5d6a7', uw:'#607d8b',
u0:'#e3e3e3', mix:'#ff8c00',
};
const DETAIL_ORDER = ['u0', 'uw', 'u19', 'u18', 'u21', 'u20', 'u13', 'u2', 'u4', 'u16', 'u17', 'u12', 'u1', 'u14', 'u10',
'u11', 'u9', 'u15', 'u5', 'u7', 'u6', 'u3', 'u8', 'mix'];
const DETAIL_LIST = ['u7', 'u6', 'u3', 'u8', 'mix', 'u5', 'u15', 'u9', 'u10', 'u11', 'u14', 'u1', 'u12', 'u2', 'u13', 'u4',
'u16', 'u17', 'u18', 'u20', 'u21', 'u19', 'uw', 'u0'];
function simpleKey(use, flats) {
const f = flats || 0;
if (use === 3) return f >= 4 ? 'unit' : 'res'; // generic "objekt k bydlení"
if (use === 3) return f >= 4 ? 'unit' : 'res'; // generic dwelling
const base = USE_CAT[use] || 'other';
if (base === 'res' || base === 'unit' || base === 'rec') return base;
if (S.mixMin > 0 && f >= S.mixMin && base !== 'garage' && base !== 'agri') return 'mix';
return base;
}
function detailKey(use, sk) {
if (sk === 'mix') return 'mix';
if (use >= 1 && use <= 21) return 'u' + use;
if (use >= 22 && use <= 29) return 'uw';
return 'u0';
}
const catColor = key => (S.mode === 'simple' ? SIMPLE_COLOR[key] : DETAIL_COLOR[key]) || '#bdbdbd';
function catLabel(key) {
if (S.mode === 'simple') return t('cat.' + key);
if (key === 'mix') return t('cat.mix');
if (key === 'uw') return useName('w');
if (key === 'u0') return useName(0);
return key.slice(1) + ' · ' + useName(+key.slice(1));
}
const catList = () => (S.mode === 'simple' ? SIMPLE.map(c => c[0]) : DETAIL_LIST);
const catOrder = () => (S.mode === 'simple' ? SIMPLE_ORDER : DETAIL_ORDER);
function isDark(hex) {
const n = parseInt(hex.slice(1), 16), r = n >> 16, g = (n >> 8) & 255, b = n & 255;
return (0.299 * r + 0.587 * g + 0.114 * b) < 140;
}
/* ---------- basemap styles (draw order) ---------- */
/* ================= basemap styles ================= */
const BASE = [
{ k: 'garden', t: 'poly', fill: '#e6efd6' },
{ k: 'green', t: 'poly', fill: '#cfe4bd' },
@ -182,20 +289,27 @@ const BASE = [
const ZAB_LAYERS = { road: 79, street: 84, track: 83, path: 82, rail: 75, stream: 93, water: 132,
green: 134, garden: 135, cemetery: 116, parking: 123 };
/* ---------- state ---------- */
/* ================= state ================= */
const S = {
buildings: [], base: {}, K: 0.63, center: [14.9687, 50.8172],
view: { cx: 0, cy: 0, s: 1 }, hidden: new Set(), mixMin: 1, showBase: true, showNums: true,
sel: null, loaded: false,
view: { cx: 0, cy: 0, s: 1 }, hidden: new Set(), mixMin: 1, mode: 'simple', showBase: true, showNums: true,
sel: null, loaded: false, status: null,
};
const $ = id => document.getElementById(id);
const cv = $('cv'), ctx0 = cv.getContext('2d');
let W = 0, H = 0, DPR = 1;
/* ---------- parsing the location ---------- */
function classifyAll() {
for (const b of S.buildings) {
b.sc = simpleKey(b.use, b.flats);
b.cat = S.mode === 'simple' ? b.sc : detailKey(b.use, b.sc);
}
}
/* ================= location parsing ================= */
function parseLoc(text) {
text = (text || '').trim();
let m = text.match(/[?&]x=(-?\d+(?:\.\d+)?)/), n = text.match(/[?&]y=(-?\d+(?:\.\d+)?)/);
const m = text.match(/[?&]x=(-?\d+(?:\.\d+)?)/), n = text.match(/[?&]y=(-?\d+(?:\.\d+)?)/);
if (m && n) return { lon: +m[1], lat: +n[1] };
const nums = (text.match(/-?\d+(?:\.\d+)?/g) || []).map(Number);
if (nums.length >= 2) {
@ -206,7 +320,7 @@ function parseLoc(text) {
return null;
}
/* ---------- fetching from ČÚZK ---------- */
/* ================= fetching from ČÚZK ================= */
const RUIAN = 'https://ags.cuzk.cz/arcgis/rest/services/RUIAN/MapServer/3/query';
const ZAB = 'https://ags.cuzk.cz/arcgis/rest/services/ZABAGED_POLOHOPIS/MapServer/';
@ -242,7 +356,6 @@ async function queryAll(url, fields, env) {
}
const lowerKeys = o => Object.fromEntries(Object.entries(o || {}).map(([k, v]) => [k.toLowerCase(), v]));
const ringsOf = f => (f.geometry && (f.geometry.rings || f.geometry.paths)) || [];
const sleep = ms => new Promise(r => setTimeout(r, ms));
async function pool(tasks, n) { // run async tasks, at most n at a time
const out = new Array(tasks.length); let i = 0;
@ -279,8 +392,7 @@ async function fetchArea(lon, lat, radius, onProgress) {
return mkBuilding(a.cisladomovni, a.zpusobvyuzitikod, a.pocetbytu, a.pocetpodlazi, a.zastavenaplocha,
a.dokonceni, ringsOf(f));
}).filter(b => b.rings.length);
const have = Object.values(base).reduce((n, a) => n + a.length, 0);
return { buildings, base, baseFail: fails.length, fails, baseShapes: have };
return { buildings, base, fails };
}
function mkBuilding(cp, use, flats, floors, area, done, rings) {
@ -292,10 +404,10 @@ function mkBuilding(cp, use, flats, floors, area, done, rings) {
const year = (done != null && isFinite(done)) ? new Date(done).getUTCFullYear() : null;
return { cp: (cp || '').toString().trim(), use: use == null ? 0 : +use, flats: flats == null ? null : +flats,
floors: floors == null ? null : +floors, area: area == null ? null : +area, year, rings,
bb: [x0, y0, x1, y1], cat: 'other' };
bb: [x0, y0, x1, y1], cat: 'other', sc: 'other' };
}
/* ---------- embedded sample (Chrastava centre) ---------- */
/* ================= built-in example (offline fallback) ================= */
const SAMPLE_B = String.raw`1665796,6588401
341;15;15;4;471,357 3,1 0,0 2,-3 1,-3 2,-3 1,0 4,-8 -25,-15 -11,17 6,4 4,2 4,3 9,5
340;15;14;4;424,385 6,3 8,5 9,5 2,2 1,0 5,-9 0,-1 5,-8 -3,-1 -9,-6 -14,-8 -5,10 -5,8
@ -1118,28 +1230,19 @@ function loadSample() {
});
const base = {}; let cur = null;
for (const l of SAMPLE_BASE.split('\n')) {
const t = l.trim(); if (!t) continue;
if (t[0] === '#') { cur = t.slice(1); base[cur] = []; continue; }
base[cur].push(decodeRing(t, ox, oy));
const t2 = l.trim(); if (!t2) continue;
if (t2[0] === '#') { cur = t2.slice(1); base[cur] = []; continue; }
base[cur].push(decodeRing(t2, ox, oy));
}
return { buildings, base, baseFail: 0, lon: 14.968678, lat: 50.8171633 };
return { buildings, base, fails: [] };
}
/* ---------- applying data ---------- */
function applyData(d, lon, lat, label) {
/* ================= applying data ================= */
function applyData(d, lon, lat) {
S.buildings = d.buildings; S.base = d.base; S.center = [lon, lat];
S.K = Math.cos(lat * D2R); S.sel = null; $('info').style.display = 'none';
reclassify(); fitView(); S.loaded = true; buildLegend(); draw();
const n = S.buildings.length;
setStatus(`${label}: ${n} buildings.` + (d.baseFail ? `\n${d.baseFail} basemap layer(s) failed:\n` + (d.fails || []).join('\n') : '') +
(d.fails && !d.baseFail && d.baseShapes === 0 ? '\nThe service returned no roads/rivers for this area.' : ''), d.baseFail ? 'err' : 'ok');
classifyAll(); fitView(); S.loaded = true; S.hidden.clear(); buildLegend(); draw();
}
function reclassify() {
for (const b of S.buildings) b.cat = classify(b.use, b.flats);
updateCounts();
}
/* ---------- view ---------- */
function fitView() {
if (!S.buildings.length) return;
let x0 = 1e18, y0 = 1e18, x1 = -1e18, y1 = -1e18;
@ -1149,10 +1252,9 @@ function fitView() {
}
const pxPerMeter = v => v.s / S.K; // screen px per true metre
/* ---------- drawing ---------- */
/* ================= drawing ================= */
function niceScale(v) {
const steps = [5, 10, 20, 50, 100, 200, 500, 1000];
for (const m of steps) { const px = m * pxPerMeter(v); if (px >= 70) return { m, px }; }
for (const m of [5, 10, 20, 50, 100, 200, 500, 1000]) { const px = m * pxPerMeter(v); if (px >= 70) return { m, px }; }
return { m: 1000, px: 1000 * pxPerMeter(v) };
}
@ -1184,38 +1286,32 @@ function drawScene(ctx, W, H, v, r, opts) {
}
}
}
// buildings, per category
const order = ['other', 'garage', 'agri', 'tech', 'ind', 'office', 'hotel', 'shop', 'assem', 'civic', 'res', 'unit', 'rec', 'mix'];
for (const key of order) {
for (const key of catOrder()) {
if (S.hidden.has(key)) continue;
const rings = [];
for (const b of S.buildings) if (b.cat === key) for (const rg of b.rings) rings.push(rg);
if (!rings.length) continue;
path(rings, true);
ctx.fillStyle = CAT[key].color; ctx.fill('evenodd');
ctx.strokeStyle = key === 'res' ? 'rgba(255,255,255,.55)' : 'rgba(0,0,0,.55)'; ctx.lineWidth = .5; ctx.stroke();
ctx.fillStyle = catColor(key); ctx.fill('evenodd');
ctx.strokeStyle = (key === 'res' || key === 'u7') ? 'rgba(255,255,255,.55)' : 'rgba(0,0,0,.55)'; ctx.lineWidth = .5; ctx.stroke();
}
// house numbers
if (S.showNums && ppm >= 1.5) {
const all = ppm >= 3.2;
ctx.textAlign = 'center'; ctx.textBaseline = 'middle';
ctx.font = `${Math.min(12, Math.max(8, ppm * 2.2))}px system-ui,sans-serif`;
for (const b of S.buildings) {
if (!b.cp || S.hidden.has(b.cat) || !(all || CAT[b.cat].nums)) continue;
if (!b.cp || S.hidden.has(b.cat) || !(all || SIMPLE_NUMS[b.sc])) continue;
const cx = sx((b.bb[0] + b.bb[2]) / 2), cy = sy((b.bb[1] + b.bb[3]) / 2);
if (cx < -20 || cy < -20 || cx > W + 20 || cy > H + 20) continue;
const dark = ['res', 'unit', 'rec', 'civic', 'ind', 'tech', 'office'].includes(b.cat);
const txt = b.cp.split(',')[0];
const dark = isDark(catColor(b.cat)), txt = b.cp.split(',')[0];
if (!dark) { ctx.lineWidth = 2.5; ctx.strokeStyle = 'rgba(255,255,255,.8)'; ctx.strokeText(txt, cx, cy); }
ctx.fillStyle = dark ? '#fff' : '#111'; ctx.fillText(txt, cx, cy);
}
}
// selection
if (opts.sel && S.sel) {
path(S.sel.rings, true); ctx.strokeStyle = '#ffcc00'; ctx.lineWidth = 3; ctx.stroke();
ctx.strokeStyle = '#000'; ctx.lineWidth = 1; ctx.stroke();
}
// scale bar + north arrow
const sc = niceScale(v), bx = 16, by = H - 18;
ctx.fillStyle = 'rgba(245,242,234,.85)'; ctx.fillRect(bx - 6, by - 20, sc.px + 12, 30);
ctx.strokeStyle = '#000'; ctx.lineWidth = 2; ctx.beginPath(); ctx.moveTo(bx, by); ctx.lineTo(bx + sc.px, by); ctx.stroke();
@ -1226,18 +1322,23 @@ function drawScene(ctx, W, H, v, r, opts) {
ctx.restore();
}
function counts() { const c = {}; for (const b of S.buildings) c[b.cat] = (c[b.cat] || 0) + 1; return c; }
function legendEntries() {
const cnt = counts(); const e = [];
for (const c of CATS) if (cnt[c[0]]) e.push({ color: c[2], label: `${c[1]} (${cnt[c[0]]})` });
if (S.showBase) e.push({ color: '#a8cfe8', label: 'River / water' }, { color: '#cfe4bd', label: 'Green area / garden' },
{ color: '#ffe08a', label: 'Main road' }, { color: '#ffffff', label: 'Street', border: '#9a9a9a' });
const cnt = counts(), e = [];
for (const k of catList()) if (cnt[k]) e.push({ color: catColor(k), label: `${catLabel(k)} (${cnt[k]})` });
if (S.showBase) e.push({ color: '#a8cfe8', label: t('b_water') }, { color: '#cfe4bd', label: t('b_green') },
{ color: '#ffe08a', label: t('b_road') }, { color: '#ffffff', label: t('b_street'), border: '#9a9a9a' });
return e;
}
function drawLegend(ctx, y0, W, r) {
function legendLayout(W) {
const e = legendEntries(), colW = Math.max(240, Math.floor(W / Math.max(1, Math.floor(W / 300))));
const cols = Math.max(1, Math.floor(W / colW)), rows = Math.ceil(e.length / cols);
return { e, colW, rows, h: rows * 20 + 16 };
}
function drawLegend(ctx, y0, W, r) {
const { e, colW, rows, h } = legendLayout(W);
ctx.save(); ctx.setTransform(r, 0, 0, r, 0, 0);
ctx.fillStyle = '#fff'; ctx.fillRect(0, y0, W, rows * 20 + 16);
ctx.fillStyle = '#fff'; ctx.fillRect(0, y0, W, h);
ctx.font = '12px system-ui,sans-serif'; ctx.textAlign = 'left'; ctx.textBaseline = 'middle';
e.forEach((it, i) => {
const c = Math.floor(i / rows), rr = i % rows, x = 14 + c * colW, y = y0 + 14 + rr * 20;
@ -1246,24 +1347,20 @@ function drawLegend(ctx, y0, W, r) {
ctx.fillStyle = '#111'; ctx.fillText(it.label, x + 26, y);
});
ctx.restore();
return rows * 20 + 16;
}
function legendHeight(W) {
const e = legendEntries(), colW = Math.max(240, Math.floor(W / Math.max(1, Math.floor(W / 300))));
const cols = Math.max(1, Math.floor(W / colW)); return Math.ceil(e.length / cols) * 20 + 16;
}
function draw() { if (W) drawScene(ctx0, W, H, S.view, DPR, { sel: true }); }
/* ---------- legend (sidebar) ---------- */
function counts() { const c = {}; for (const b of S.buildings) c[b.cat] = (c[b.cat] || 0) + 1; return c; }
/* ================= sidebar legend ================= */
function buildLegend() {
const box = $('legend'); box.innerHTML = '';
for (const c of CATS) {
const row = document.createElement('label'); row.className = 'leg'; row.dataset.key = c[0];
row.innerHTML = `<input type="checkbox" checked><span class="sw" style="background:${c[2]}"></span><span>${c[1]}</span><span class="n">0</span>`;
row.querySelector('input').addEventListener('change', e => {
if (e.target.checked) S.hidden.delete(c[0]); else S.hidden.add(c[0]);
for (const key of catList()) {
const row = document.createElement('label'); row.className = 'leg'; row.dataset.key = key;
row.innerHTML = '<input type="checkbox"><span class="sw"></span><span class="lbl"></span><span class="n">0</span>';
const inp = row.querySelector('input'); inp.checked = !S.hidden.has(key); row.classList.toggle('off', S.hidden.has(key));
row.querySelector('.sw').style.background = catColor(key);
row.querySelector('.lbl').textContent = catLabel(key);
inp.addEventListener('change', e => {
if (e.target.checked) S.hidden.delete(key); else S.hidden.add(key);
row.classList.toggle('off', !e.target.checked); draw();
});
box.appendChild(row);
@ -1273,12 +1370,12 @@ function buildLegend() {
function updateCounts() {
const cnt = counts();
document.querySelectorAll('#legend .leg').forEach(r => {
const n = cnt[r.dataset.key] || 0; r.querySelector('.n').textContent = n; r.classList.toggle('zero', !n);
const n = cnt[r.dataset.key] || 0; r.querySelector('.n').textContent = n; r.style.display = n ? '' : 'none';
});
$('total').textContent = S.buildings.length ? `· ${S.buildings.length} buildings` : '';
$('total').textContent = S.buildings.length ? t('nBuildings', S.buildings.length) : '';
}
/* ---------- hit testing & interaction ---------- */
/* ================= hit testing & interaction ================= */
function inRing(x, y, ring) {
let inside = false;
for (let i = 0, j = ring.length - 1; i < ring.length; j = i++) {
@ -1288,29 +1385,28 @@ function inRing(x, y, ring) {
return inside;
}
function pick(px, py) {
const v = S.view, x = (px - W / 2) / v.s + v.cx, y = (H / 2 - py) / v.s + v.cy;
const pad = 2 / v.s;
const v = S.view, x = (px - W / 2) / v.s + v.cx, y = (H / 2 - py) / v.s + v.cy, pad = 2 / v.s;
for (let i = S.buildings.length - 1; i >= 0; i--) {
const b = S.buildings[i];
if (S.hidden.has(b.cat) || x < b.bb[0] - pad || x > b.bb[2] + pad || y < b.bb[1] - pad || y > b.bb[3] + pad) continue;
let hit = false; for (const r of b.rings) if (inRing(x, y, r)) { hit = !hit; }
let hit = false; for (const r of b.rings) if (inRing(x, y, r)) hit = !hit;
if (hit) return b;
}
return null;
}
const desc = b => `${b.cp ? 'č.p. ' + b.cp : 'no house number'} – ${CAT[b.cat].label}`;
const desc = b => `${b.cp ? t('hn', b.cp) : t('nohn')} – ${catLabel(b.cat)}`;
function showInfo(b) {
const el = $('info');
if (!b) { el.style.display = 'none'; return; }
const ll = m2ll((b.bb[0] + b.bb[2]) / 2, (b.bb[1] + b.bb[3]) / 2);
el.innerHTML = `<span class="x" title="Close">✕</span><b>${b.cp ? 'č.p. ' + b.cp : 'No house number'}</b>
<dl><dt>Category</dt><dd>${CAT[b.cat].label}</dd>
<dt>RÚIAN use</dt><dd>${USE_NAME[b.use] || '—'} (${b.use || '?'})</dd>
<dt>Flats</dt><dd>${b.flats == null ? '—' : b.flats}</dd>
<dt>Floors</dt><dd>${b.floors == null ? '—' : b.floors}</dd>
<dt>Built-up area</dt><dd>${b.area == null ? '—' : b.area + ' m²'}</dd>
<dt>Completed</dt><dd>${b.year == null ? '—' : b.year}</dd>
<dt>Position</dt><dd>${ll[1].toFixed(6)}, ${ll[0].toFixed(6)}</dd></dl>`;
const ll = m2ll((b.bb[0] + b.bb[2]) / 2, (b.bb[1] + b.bb[3]) / 2), dash = '—';
el.innerHTML = `<span class="x" title="${t('close')}">✕</span><b>${b.cp ? t('hn', b.cp) : t('nohn')}</b>
<dl><dt>${t('i_cat')}</dt><dd>${catLabel(b.cat)}</dd>
<dt>${t('i_use')}</dt><dd>${useName(b.use) || dash} (${b.use || '?'})</dd>
<dt>${t('i_flats')}</dt><dd>${b.flats == null ? dash : b.flats}</dd>
<dt>${t('i_floors')}</dt><dd>${b.floors == null ? dash : b.floors}</dd>
<dt>${t('i_area')}</dt><dd>${b.area == null ? dash : b.area + ' m²'}</dd>
<dt>${t('i_done')}</dt><dd>${b.year == null ? dash : b.year}</dd>
<dt>${t('i_pos')}</dt><dd>${ll[1].toFixed(6)}, ${ll[0].toFixed(6)}</dd></dl>`;
el.style.display = 'block';
el.querySelector('.x').onclick = () => { S.sel = null; el.style.display = 'none'; draw(); };
}
@ -1362,38 +1458,59 @@ function resize() {
}
new ResizeObserver(resize).observe($('stage'));
/* ---------- controls ---------- */
function setStatus(t, cls) { const s = $('status'); s.textContent = t; s.className = cls || ''; }
/* ================= language ================= */
// status is stored as a function so it can be re-rendered when the language changes
function setStatus(fn, cls) { S.status = { fn, cls }; renderStatus(); }
function renderStatus() { const s = $('status'); if (!S.status) { s.textContent = ''; s.className = ''; return; } s.textContent = S.status.fn(); s.className = S.status.cls || ''; }
function applyLang() {
document.documentElement.lang = lang;
document.querySelectorAll('[data-i18n]').forEach(el => { el.textContent = t(el.dataset.i18n); });
$('note').innerHTML = t('note');
$('zin').title = t('zoomIn'); $('zout').title = t('zoomOut'); $('zfit').title = t('fit');
$('lang').value = lang;
document.title = t('title') + ' – RÚIAN';
buildLegend(); renderStatus(); if (S.sel) showInfo(S.sel); draw();
}
$('lang').onchange = e => { lang = e.target.value; try { localStorage.setItem('bum-lang', lang); } catch (x) {} applyLang(); };
/* ================= controls ================= */
$('radius').oninput = e => { $('rv').textContent = e.target.value + ' m'; };
$('optBase').onchange = e => { S.showBase = e.target.checked; draw(); };
$('optNums').onchange = e => { S.showNums = e.target.checked; draw(); };
$('mixrule').onchange = e => { S.mixMin = +e.target.value; reclassify(); draw(); };
$('sample').onclick = () => {
const d = loadSample(); $('loc').value = 'https://mapy.com/en/turisticka?x=14.968678&y=50.8171633&z=16.8';
applyData(d, d.lon, d.lat, 'Chrastava sample');
};
$('load').onclick = async () => {
const p = parseLoc($('loc').value);
if (!p) { setStatus('Could not read a location. Paste a Mapy.com link or "50.8171, 14.9687".', 'err'); return; }
const btn = $('load'); btn.disabled = true; setStatus('Loading buildings and basemap from ČÚZK…');
$('mixrule').onchange = e => { S.mixMin = +e.target.value; classifyAll(); updateCounts(); buildLegend(); draw(); };
$('colormode').onchange = e => { S.mode = e.target.value; S.hidden.clear(); classifyAll(); buildLegend(); draw(); };
async function liveLoad(p, quietFallback) {
const btn = $('load'); btn.disabled = true; setStatus(() => t('st_loading'));
try {
const d = await fetchArea(p.lon, p.lat, +$('radius').value, (n, m) => setStatus(`Loading from ČÚZK… ${n}/${m} requests done`));
if (!d.buildings.length) { setStatus('No buildings found here (outside Czechia, or an empty area).', 'err'); return; }
applyData(d, p.lon, p.lat, `${p.lat.toFixed(5)}, ${p.lon.toFixed(5)}`);
const d = await fetchArea(p.lon, p.lat, +$('radius').value, (n, m) => setStatus(() => t('st_progress', n, m)));
if (!d.buildings.length) { setStatus(() => t('st_none'), 'err'); return false; }
applyData(d, p.lon, p.lat);
const loc = `${p.lat.toFixed(5)}, ${p.lon.toFixed(5)}`, n = d.buildings.length, fails = d.fails;
setStatus(() => t('st_loaded', loc, n) + (fails.length ? '\n' + t('st_baseFail', fails.length) + '\n' + fails.join('\n') : ''),
fails.length ? 'err' : 'ok');
return true;
} catch (e) {
setStatus('Could not load data from ČÚZK: ' + (e && e.message ? e.message : e) +
'\nThe service may be down, you may be offline, or this page is running somewhere that blocks requests to other sites (some embedded viewers do). Opening the file directly in a browser or hosting it yourself works. The Chrastava sample still works offline.', 'err');
const msg = e && e.message ? e.message : String(e);
setStatus(() => quietFallback ? t('st_fallback', msg) : t('st_err', msg), 'err');
return false;
} finally { btn.disabled = false; }
}
$('load').onclick = () => {
const p = parseLoc($('loc').value);
if (!p) { setStatus(() => t('st_badLoc'), 'err'); return; }
liveLoad(p, false);
};
$('loc').addEventListener('keydown', e => { if (e.key === 'Enter') $('load').click(); });
/* ---------- export ---------- */
/* ================= export ================= */
function download(blob, name) {
const a = document.createElement('a'); a.href = URL.createObjectURL(blob); a.download = name;
document.body.appendChild(a); a.click(); a.remove(); setTimeout(() => URL.revokeObjectURL(a.href), 4000);
}
$('expPng').onclick = () => {
if (!S.loaded) return; const r = 2, lh = legendHeight(W);
if (!S.loaded) return; const r = 2, lh = legendLayout(W).h;
const oc = document.createElement('canvas'); oc.width = W * r; oc.height = (H + lh) * r;
const c = oc.getContext('2d'); drawScene(c, W, H, S.view, r, {}); drawLegend(c, H, W, r);
oc.toBlob(b => download(b, 'building-use-map.png'), 'image/png');
@ -1402,7 +1519,7 @@ $('expSvg').onclick = () => {
if (!S.loaded) return;
const v = S.view, sx = x => ((x - v.cx) * v.s + W / 2).toFixed(1), sy = y => (H / 2 - (y - v.cy) * v.s).toFixed(1), ppm = pxPerMeter(v);
const d = (rings, close) => rings.map(r => 'M' + r.map(p => sx(p[0]) + ' ' + sy(p[1])).join('L') + (close ? 'Z' : '')).join('');
const lh = legendHeight(W); let o = '';
const { e, colW, rows, h: lh } = legendLayout(W); let o = '';
o += `<svg xmlns="http://www.w3.org/2000/svg" width="${W}" height="${H + lh}" viewBox="0 0 ${W} ${H + lh}"><defs><clipPath id="c"><rect width="${W}" height="${H}"/></clipPath></defs>`;
o += `<rect width="${W}" height="${H}" fill="#f5f2ea"/><g clip-path="url(#c)" stroke-linejoin="round" stroke-linecap="round">`;
if (S.showBase) for (const st of BASE) {
@ -1410,13 +1527,12 @@ $('expSvg').onclick = () => {
if (st.t === 'poly') o += `<path d="${d(rings, true)}" fill="${st.fill}" fill-rule="evenodd"${st.stroke ? ` stroke="${st.stroke}" stroke-width="1"` : ''}/>`;
else o += `<path d="${d(rings, false)}" fill="none" stroke="${st.c}" stroke-width="${Math.max(st.min, st.m * ppm).toFixed(1)}"${st.dash ? ` stroke-dasharray="${st.dash.map(x => x * Math.max(1, ppm / 2)).join(' ')}"` : ''}/>`;
}
for (const c of CATS) {
if (S.hidden.has(c[0])) continue;
const rings = []; for (const b of S.buildings) if (b.cat === c[0]) for (const r of b.rings) rings.push(r);
if (rings.length) o += `<path d="${d(rings, true)}" fill="${c[2]}" fill-rule="evenodd" stroke="${c[0] === 'res' ? '#ffffff88' : '#00000088'}" stroke-width=".5"/>`;
for (const key of catOrder()) {
if (S.hidden.has(key)) continue;
const rings = []; for (const b of S.buildings) if (b.cat === key) for (const r of b.rings) rings.push(r);
if (rings.length) o += `<path d="${d(rings, true)}" fill="${catColor(key)}" fill-rule="evenodd" stroke="${(key === 'res' || key === 'u7') ? '#ffffff88' : '#00000088'}" stroke-width=".5"/>`;
}
o += '</g>';
const e = legendEntries(), colW = Math.max(240, Math.floor(W / Math.max(1, Math.floor(W / 300)))), cols = Math.max(1, Math.floor(W / colW)), rows = Math.ceil(e.length / cols);
o += `<rect y="${H}" width="${W}" height="${lh}" fill="#fff"/><g font-family="system-ui,sans-serif" font-size="12">`;
e.forEach((it, i) => {
const c = Math.floor(i / rows), rr = i % rows, x = 14 + c * colW, y = H + 14 + rr * 20;
@ -1431,16 +1547,21 @@ $('expCsv').onclick = () => {
let o = 'house_no,ruian_use_code,ruian_use,category,flats,floors,built_up_area_m2,completed,lat,lon\n';
for (const b of S.buildings) {
const ll = m2ll((b.bb[0] + b.bb[2]) / 2, (b.bb[1] + b.bb[3]) / 2);
o += [q(b.cp), b.use, q(USE_NAME[b.use] || ''), q(CAT[b.cat].label), b.flats ?? '', b.floors ?? '', b.area ?? '', b.year ?? '', ll[1].toFixed(6), ll[0].toFixed(6)].join(',') + '\n';
o += [q(b.cp), b.use, q(useName(b.use)), q(catLabel(b.cat)), b.flats ?? '', b.floors ?? '', b.area ?? '', b.year ?? '', ll[1].toFixed(6), ll[0].toFixed(6)].join(',') + '\n';
}
download(new Blob(['' + o], { type: 'text/csv;charset=utf-8' }), 'buildings.csv');
};
$('expPrint').onclick = () => window.print();
/* ---------- start ---------- */
buildLegend();
/* ================= start ================= */
applyLang();
resize();
$('sample').click();
{ // show the built-in example immediately, then replace it with live data for the default location
const d = loadSample(); applyData(d, 14.968678, 50.8171633);
setStatus(() => t('st_init'));
const p = parseLoc($('loc').value);
if (p) liveLoad(p, true);
}
})();
</script>
</body>