building-use-map/index.html

1568 lines
86 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<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 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}
*{box-sizing:border-box}
html,body{height:100%;margin:0}
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}
input[type=range]{width:100%}
.row{display:flex;gap:8px;margin-top:10px}
button{font:inherit;padding:7px 10px;border-radius:6px;border:1px solid var(--acc);background:var(--acc);color:#fff;cursor:pointer}
button.ghost{background:#fff;color:var(--acc)}
button:disabled{opacity:.5;cursor:default}
.row button{flex:1}
#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;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}
.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}
.note{font-size:11.5px;color:var(--mut);margin-top:14px}
main{position:relative;min-width:0;min-height:0;background:var(--bg)}
canvas{position:absolute;inset:0;width:100%;height:100%;touch-action:none;cursor:grab}
canvas.drag{cursor:grabbing}
#tip{position:absolute;pointer-events:none;background:rgba(20,20,20,.9);color:#fff;padding:5px 8px;border-radius:5px;font-size:12px;display:none;max-width:260px;z-index:3}
#info{position:absolute;left:12px;bottom:12px;background:#fff;border:1px solid var(--line);border-radius:8px;padding:10px 12px;font-size:13px;max-width:300px;display:none;box-shadow:0 2px 10px rgba(0,0,0,.12);z-index:3}
#info b{font-size:14px}
#info dl{margin:6px 0 0;display:grid;grid-template-columns:auto 1fr;gap:2px 10px}
#info dt{color:var(--mut)}
#info dd{margin:0}
#info .x{position:absolute;top:4px;right:8px;cursor:pointer;color:var(--mut)}
.zoom{position:absolute;right:12px;top:12px;display:flex;flex-direction:column;gap:6px;z-index:3}
.zoom button{width:34px;height:34px;padding:0;background:#fff;color:var(--ink);border:1px solid #bbb;font-size:18px}
@media (max-width:820px){
#app{grid-template-columns:1fr;grid-template-rows:auto 1fr}
aside{max-height:46vh;border-right:0;border-bottom:1px solid var(--line)}
main{min-height:54vh}
}
@media print{
aside,.zoom,#tip,#info{display:none!important}
#app{display:block}
main{height:100vh}
}
</style>
</head>
<body>
<div id="app">
<aside>
<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" 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"><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" data-i18n="load"></button></div>
<div id="status"></div>
<h2><span data-i18n="layers"></span> <span id="total" style="text-transform:none;letter-spacing:0"></span></h2>
<div id="legend"></div>
<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 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" data-i18n="csv"></button>
<button id="expPrint" class="ghost" data-i18n="print"></button>
</div>
<p class="note" id="note"></p>
</aside>
<main id="stage">
<canvas id="cv"></canvas>
<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>
</div>
<script>
(() => {
'use strict';
/* ================= 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 m2ll = (x, y) => [x / R / D2R, (2 * Math.atan(Math.exp(y / R)) - Math.PI / 2) / D2R];
/* ================= 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 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'};
// 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 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 ================= */
const BASE = [
{ k: 'garden', t: 'poly', fill: '#e6efd6' },
{ k: 'green', t: 'poly', fill: '#cfe4bd' },
{ k: 'cemetery', t: 'poly', fill: '#c9d9bd', stroke: '#9bb08a' },
{ k: 'parking', t: 'poly', fill: '#e2e2e2', stroke: '#c4c4c4' },
{ k: 'water', t: 'poly', fill: '#a8cfe8', stroke: '#7fb2d6' },
{ k: 'stream', t: 'line', c: '#7fb2d6', m: 2, min: 1.2 },
{ k: 'path', t: 'line', c: '#b58b5a', m: 1, min: .8, dash: [2, 3] },
{ k: 'track', t: 'line', c: '#c9a16b', m: 2, min: 1, dash: [6, 4] },
{ k: 'rail', t: 'line', c: '#666666', m: 3, min: 1.2, dash: [8, 4] },
{ k: 'street', t: 'line', c: '#9a9a9a', m: 7, min: 2.4 },
{ k: 'street', t: 'line', c: '#ffffff', m: 5, min: 1.8 },
{ k: 'road', t: 'line', c: '#b8862f', m: 11, min: 3.6 },
{ k: 'road', t: 'line', c: '#ffe08a', m: 8.5, min: 2.8 },
];
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 ================= */
const S = {
buildings: [], base: {}, K: 0.63, center: [14.9687, 50.8172],
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;
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();
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) {
const [a, b] = nums;
if (a >= 48 && a <= 52 && b >= 12 && b <= 19) return { lat: a, lon: b };
if (b >= 48 && b <= 52 && a >= 12 && a <= 19) return { lat: b, lon: a };
}
return null;
}
/* ================= 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/';
async function query(url, fields, env, offset) {
const p = { geometry: env, geometryType: 'esriGeometryEnvelope', inSR: '4326', outSR: '3857',
spatialRel: 'esriSpatialRelIntersects', where: '1=1', outFields: fields, returnGeometry: 'true',
geometryPrecision: '1', maxAllowableOffset: '0.3', f: 'json' };
if (offset) { p.resultOffset = String(offset); p.resultRecordCount = '1000'; }
// No AbortSignal / fetch options: some embedded viewers proxy fetch through postMessage and cannot clone them.
const url2 = url + '?' + new URLSearchParams(p);
let timer;
const timeout = new Promise((_, rej) => { timer = setTimeout(() => rej(new Error('timed out after 45 s')), 45000); });
try {
const res = await Promise.race([fetch(url2), timeout]);
if (!res.ok) throw new Error('HTTP ' + res.status);
const j = await Promise.race([res.json(), timeout]);
if (j.error) throw new Error(j.error.message || 'service error');
return j;
} finally { clearTimeout(timer); }
}
async function queryAll(url, fields, env) {
let out = [], off = 0;
for (let page = 0; page < 12; page++) {
let j;
try { j = await query(url, fields, env, off); }
catch (e) { if (off > 0) break; throw e; }
const f = j.features || [];
out = out.concat(f);
if (!j.exceededTransferLimit || !f.length) break;
off += f.length;
}
return out;
}
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;
await Promise.all(Array.from({ length: Math.min(n, tasks.length) }, async () => {
while (i < tasks.length) { const k = i++; try { out[k] = { ok: true, v: await tasks[k]() }; } catch (e) { out[k] = { ok: false, e }; } }
}));
return out;
}
async function baseLayer(id, env) { // retry, then try an explicit field instead of an empty field list
let last;
for (const fields of ['', 'objectid', '']) {
try { return await queryAll(ZAB + id + '/query', fields, env); } catch (e) { last = e; await sleep(500); }
}
throw last;
}
async function fetchArea(lon, lat, radius, onProgress) {
const dLat = radius * 1.1 / 111320, dLon = radius * 1.1 / (111320 * Math.cos(lat * D2R));
const env = [lon - dLon, lat - dLat, lon + dLon, lat + dLat].map(v => v.toFixed(6)).join(',');
const fields = 'cisladomovni,zpusobvyuzitikod,pocetbytu,pocetpodlazi,zastavenaplocha,dokonceni';
const keys = Object.keys(ZAB_LAYERS);
const tasks = [() => queryAll(RUIAN, fields, env), ...keys.map(k => () => baseLayer(ZAB_LAYERS[k], env))];
let done = 0;
const res = await pool(tasks.map(fn => async () => { try { return await fn(); } finally { if (onProgress) onProgress(++done, tasks.length); } }), 4);
if (!res[0].ok) throw res[0].e;
const base = {}, fails = [];
keys.forEach((k, i) => {
const r = res[i + 1];
if (r.ok) base[k] = r.v.map(ringsOf).flat();
else { base[k] = []; fails.push(k + ': ' + (r.e && r.e.message ? r.e.message : r.e)); }
});
const buildings = res[0].v.map(f => {
const a = lowerKeys(f.attributes);
return mkBuilding(a.cisladomovni, a.zpusobvyuzitikod, a.pocetbytu, a.pocetpodlazi, a.zastavenaplocha,
a.dokonceni, ringsOf(f));
}).filter(b => b.rings.length);
return { buildings, base, fails };
}
function mkBuilding(cp, use, flats, floors, area, done, rings) {
let x0 = 1e18, y0 = 1e18, x1 = -1e18, y1 = -1e18;
for (const r of rings) for (const p of r) {
if (p[0] < x0) x0 = p[0]; if (p[0] > x1) x1 = p[0];
if (p[1] < y0) y0 = p[1]; if (p[1] > y1) y1 = p[1];
}
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', sc: 'other' };
}
/* ================= 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
339;15;12;4;433,422 -9,-5 -4,-3 -3,-2 -7,-4 -10,18 19,12 4,2 1,0 1,1 5,-8 1,-1 5,-9 -3,-1
61;6;4;4;907,904 -5,-2 1,-2 -5,-3 -1,2 -7,-5 -9,14 17,10 9,-14
165;7;1;2;255,769 8,3 7,-17 -3,-6 -5,3 -7,17
;16;0;1;457,317 -2,-2 -3,4 3,2 2,-4
149;6;7;4;413,668 8,5 -7,11 -1,-1 -4,7 8,3 3,-5 7,-12 9,5 7,-14 -22,-13 -8,14
138;6;7;3;564,763 11,-29 -13,-7 -13,29 -4,9 -3,13 3,0 4,-10 11,4 4,-9
572;7;1;1;1038,67 -4,12 -1,2 20,6 1,1 5,-13 0,-1 -21,-7
48;6;9;5;803,1208 3,-17 5,-34 -19,-3 -8,60 13,2 5,0 1,-8
55;7;2;2;827,1272 16,2 2,-12 -17,-2 -1,12
83;7;2;2;916,1094 -1,12 6,0 1,0 23,-5 -2,-11 -23,4 -4,0
63;1;0;1;908,1237 35,16 10,-23 24,11 21,-44 -61,-28 -18,-9 -4,9 -19,40 13,6 -5,9 8,4 -4,9
1;5;1;3;591,595 18,9 19,-36 -6,-3 -12,-7 0,0 -7,13 -1,2 -3,7 -1,1 -7,14
2;6;2;2;641,541 6,-12 -12,-7 -3,5 -4,7 13,7
3;6;2;1;647,529 8,-15 -8,-5 -2,4 -6,-4 -6,12 2,1 12,7
4;7;1;2;657,511 8,-15 -14,-7 -3,5 -1,2 -2,-1 -4,-2 -3,7 4,3 15,8
5;7;1;2;179,884 10,4 2,-4 4,2 5,-14 -15,-6 -6,18
6;6;3;3;663,466 -4,7 14,8 12,-22 -2,-1 -12,-8 -3,6 -4,8 -1,2
9;7;1;2;733,364 9,8 18,-17 -13,-12 -10,11 4,4 -8,6
10;7;2;2;630,412 5,3 4,-5 4,-7 -11,-8 -8,12 6,5
11;6;4;3;669,374 14,17 20,-17 -10,-11 -3,2 -5,-5 -2,2 -14,12
12;7;1;2;730,297 12,3 7,-22 -11,-4 -2,6 -2,5 -4,12
13;7;1;2;788,243 6,-7 9,-16 -9,-6 -15,22 9,7
15;7;1;2;852,129 9,9 14,-16 -9,-8 -4,5 -7,7 -3,3
20;7;2;2;958,45 -13,-4 -7,20 13,5 7,-21
21;7;2;2;939,94 2,-4 -12,-5 -6,12 12,5 4,-8
22;7;1;2;891,145 14,13 8,-9 -4,-3 3,-4 -11,-10 -10,13
23;3;0;;751,691 3,1 12,4 5,-13 -16,-5 -2,7 -2,6
25;7;2;1;887,272 19,-7 -4,-11 -13,5 -6,2 4,11
26;7;2;1;909,251 5,12 21,-8 -4,-12 -22,8
27;7;1;3;923,210 4,1 1,0 5,-19 -3,-1 -11,-3 -4,15 7,2 3,0 -2,5
28;7;1;2;942,210 4,-15 -13,-3 -5,19 4,1 1,-4 2,0 7,2
30;7;1;2;869,295 4,12 -3,1 -2,-4 -12,4 3,8 17,-5 12,-4 -1,-4 6,-2 1,0 -5,-13 -20,7
31;7;1;2;1011,207 -13,-2 0,-2 0,0 -3,22 0,0 4,1 0,-5 2,0 8,1 2,-15
33;6;5;3;742,421 2,-1 7,-7 -1,-1 7,-8 -13,-12 -10,10 -4,7 12,12
34;7;2;2;991,225 4,0 3,-22 0,0 -1,2 -13,-2 -2,15 7,1 2,0 0,6
35;1;0;2;719,478 4,-7 13,7 7,-13 -34,-18 -11,20 21,11
36;7;1;2;698,501 10,-18 -5,-3 1,-2 -9,-5 -11,19 14,9
38;6;3;2;684,525 9,-15 -14,-8 -9,15 14,8
39;7;2;3;684,525 -14,-8 -11,19 14,8 11,-19
40;5;0;3;618,608 22,10 5,-9 3,-5 8,-14 -21,-12 -17,30
42;7;2;2;665,628 20,9 5,-12 7,-8 -7,-6 -1,2 -6,-2 -2,5 -9,-4 -7,16
43;7;2;2;685,637 18,7 7,-15 -11,-5 -2,5 -7,-4 -5,12
44;3;4;3;723,679 4,1 7,3 1,-3 3,-9 2,-4 -25,-9 -6,16 14,5
45;6;6;3;648,632 -24,-8 -9,21 25,10 0,0 30,12 3,-7 0,-1 -26,-10 1,-2 -3,-2 1,-2 -2,0 4,-11
46;7;1;2;633,667 2,1 3,-9 2,-4 0,0 -25,-10 -6,13 24,9
47;7;2;3;628,680 3,-8 2,-5 -24,-9 -4,12 23,10
48;6;5;2;621,696 2,-5 5,-11 -23,-10 -6,16 15,7 7,3
49;3;3;3;607,711 5,-13 2,-5 -15,-7 -8,18 16,7
50;6;5;3;584,723 19,9 4,-13 3,-7 -3,-1 -16,-7 -7,19
51;7;3;3;622,741 16,8 6,-13 -6,-3 -5,-2 -5,-3 -1,3 -5,10
53;7;2;1;666,762 21,10 4,-8 -3,-3 3,-5 -8,-4 -2,5 -10,-5 -5,10
55;6;9;3;729,770 1,-2 -5,-2 7,-17 -7,-3 -3,4 -14,30 21,10 7,-16 -7,-4
56;6;3;2;765,806 6,-14 -7,-3 1,-3 -6,-2 -1,2 -9,-4 -6,14 22,10
57;6;9;3;786,819 26,16 7,-11 25,-27 -8,-8 -26,28 -1,1 -1,0 2,-3 -8,-5 -2,3 -8,-5 -6,11
62;7;3;3;898,918 12,8 11,-17 -7,-4 -6,-3 -1,2 -9,14
63;7;2;3;935,927 -4,-2 2,-3 -10,-6 -8,13 8,5 5,4 7,-11
73;6;4;3;825,919 1,-12 -7,-11 -19,11 10,16 5,-2 1,2 9,-4
78;6;5;3;673,801 1,-2 3,2 -1,7 9,3 6,-18 -5,-3 2,-6 -24,-10 0,1 -8,19 17,7
80;6;3;2;575,766 15,6 1,-3 3,1 2,-6 8,3 8,-16 -8,-4 -18,-8 -11,27
85;15;0;1;554,819 18,8 7,-14 3,1 2,-6 2,1 3,-7 -25,-10 -10,27
87;19;1;2;614,843 1,0 -1,3 17,6 1,-2 12,-32 -15,-6 -11,29 -3,-1 -1,3
89;7;1;2;680,862 -10,-6 -3,7 -5,-2 -5,10 15,8 8,-17
90;7;1;2;707,890 2,-10 -9,-2 -8,-2 -2,9 17,5
92;7;1;2;757,902 6,2 2,-10 -20,-5 -2,10 14,3
93;7;2;1;786,905 -1,-9 -6,1 -13,1 1,9 19,-2
94;7;1;2;789,957 12,18 13,-9 -8,-12 -3,-4 -5,4 -1,-2 -8,5
95;8;0;;711,939 8,-12 -17,-10 -7,11 16,11
96;6;2;1;698,912 -3,-3 -16,-13 -9,12 19,16 9,-12
98;7;2;2;628,923 10,5 2,-4 3,2 5,-9 -15,-8 -5,9 3,1 -3,4
99;7;1;2;611,909 2,1 13,6 5,-8 -15,-8 -5,9
101;7;1;1;586,894 4,-8 -14,-7 -4,8 5,2 9,5
102;7;2;2;653,895 -13,-13 -10,10 13,14 10,-11
104;7;2;2;600,872 4,-9 4,2 4,-8 -15,-9 -10,17 3,2 10,5
106;7;2;2;561,854 11,5 6,-13 2,-5 -15,-6 -6,13 4,1 -2,5
107;19;1;2;565,951 -8,-4 -29,-15 2,-3 -4,-3 -2,3 -26,-13 -11,-6 -7,15 78,41 7,-15
108;7;3;2;515,978 17,9 10,-19 -18,-8 -4,9 -5,9
109;7;1;1;642,1035 21,7 3,-9 -2,-1 -20,-6 -2,9
110;7;1;1;678,1023 10,4 8,-19 -9,-4 -2,4 -6,12 -1,3
111;6;4;3;728,1038 19,8 6,-13 -6,-3 5,-11 -14,-7 -2,6 -8,20
112;7;2;2;800,1072 5,-29 -5,-5 -9,20 -3,8 12,6
116;7;3;3;878,1069 22,9 2,-6 4,-11 -8,-3 -8,-3 -6,-2 -6,16
118;7;1;1;845,1084 2,-4 9,4 3,-7 -16,-7 -1,1 -5,13 8,0
119;7;1;1;837,1084 5,-13 -7,-3 -8,-4 -6,14 16,6
121;6;6;4;759,1085 -2,4 -1,2 19,7 1,-3 6,-16 -39,-15 -5,13 13,5 8,3
124;3;0;3;621,1070 4,1 -2,7 0,1 12,4 9,-27 -28,-9 -6,19 11,4
125;6;9;5;449,968 30,14 8,-17 -31,-14 -7,17
126;6;4;3;422,956 7,5 16,-26 -14,-10 -10,15 -5,8 -2,4 8,4
132;7;1;2;265,839 4,1 -1,6 13,3 1,-7 4,1 2,-11 -21,-3 -2,10
133;7;1;1;221,844 17,8 8,-20 -10,-5 -2,5 -7,-3 -6,15
135;7;1;1;64,759 3,2 -3,4 10,8 9,-13 -1,-1 4,-4 -4,-4 5,-7 -8,-6 -15,21
139;3;3;3;542,753 7,3 13,-29 -15,-7 -13,29 8,4
140;3;3;3;534,749 13,-29 -13,-6 -14,29 14,6
141;7;3;3;519,736 -2,5 3,2 14,-29 -13,-7 -12,23 10,6
142;6;4;3;496,724 13,6 12,-23 -14,-7 -11,24
143;7;1;3;496,724 11,-24 -14,-7 -10,25 13,6
144;6;3;3;464,715 11,5 6,2 2,-4 10,-25 -15,-7 -14,29
145;6;5;3;454,780 6,-21 -14,-4 -6,20 14,5
146;6;4;3;427,775 12,-25 -17,-7 -11,25 16,7
147;7;2;2;437,728 10,4 10,-22 -9,-4 -8,-3 -10,22 7,3
148;7;4;3;436,681 11,6 -1,3 17,8 8,-17 -28,-14 -7,14
150;6;2;2;391,660 -2,3 8,4 2,-3 13,8 1,-4 8,-14 -24,-14 -9,18 3,2
151;7;1;2;377,654 7,4 -2,3 4,2 2,-5 9,-18 -9,-5 -11,19
152;6;3;3;384,633 -17,-10 -10,17 6,4 11,6 10,-17
153;7;2;2;346,633 11,7 10,-17 -11,-7 -2,3 -8,14
155;6;2;3;313,610 -1,2 6,3 1,-2 5,2 -8,25 7,2 7,-19 8,-15 1,-3 -24,-13 -7,15 5,3
156;6;6;3;278,591 14,6 5,-15 -24,-8 -3,14 5,2 0,2 2,1 1,-2
157;7;2;2;251,571 -2,14 21,3 3,-14 -22,-3
158;7;1;2;245,589 0,-19 -18,1 0,18 18,0
159;7;3;3;195,584 3,16 12,-2 -1,-15 9,0 -1,-12 -22,0 0,13
160;6;1;2;206,634 13,-4 -4,-21 -14,2 5,23
162;6;2;2;212,664 5,22 17,-4 -4,-18 -6,1 0,-1 -1,-3 -11,3
163;7;2;2;225,720 11,-3 -3,-11 -3,-10 -11,2 6,22
164;7;1;1;231,729 5,21 21,-5 -2,-7 -2,0 -4,-14 -18,5
166;7;1;2;275,759 -1,16 22,0 0,-11 -9,0 0,-5 -12,0
168;6;5;2;153,749 7,7 2,-2 7,7 10,-10 -17,-15 -11,10 2,3
169;7;1;2;149,734 -5,4 5,6 12,-10 -11,-12 -7,6 6,6
171;7;1;1;117,701 8,10 11,-8 -9,-11 -10,9
175;7;2;2;155,710 11,-8 -6,-10 -12,9 7,9
176;7;2;2;143,689 5,6 11,-9 -13,-17 -17,13 9,11 5,-4
179;7;1;1;100,622 6,-5 -12,-15 -6,5 10,13 2,2
180;7;2;2;110,607 14,17 9,-7 -3,-4 4,-3 -7,-8 -3,3 -4,-5 -10,7
182;7;1;2;150,657 9,-7 -15,-18 -9,7 15,18
183;7;1;1;215,725 -11,-15 -8,6 12,15 7,-6
184;7;1;2;195,687 2,9 3,12 12,-3 -5,-21 -12,3
185;7;1;2;167,578 7,28 1,0 14,-4 -5,-23 -17,-1
200;7;2;2;52,531 20,7 6,-16 -20,-8 -6,17
201;7;1;2;79,516 7,-17 -10,-4 -2,4 -4,13 9,4
202;6;4;2;80,486 10,6 10,-20 -10,-6 -2,5 -2,4 -17,-9 -8,14 17,9 2,-3
203;5;1;2;123,420 -16,-7 -5,12 -3,6 -17,-6 -4,12 32,13 13,-30
206;7;2;2;114,356 8,-5 -10,-13 -7,6 6,7 3,5
208;7;3;2;76,316 12,11 6,-7 1,-2 1,-1 -4,-4 -5,-4 0,-2 -5,0 1,2 -7,7
209;7;2;2;156,402 8,24 11,-4 -5,-15 -3,-9 -11,4
210;6;3;3;189,447 -1,-8 -3,1 -2,-8 -15,4 4,15 17,-4
212;7;3;3;187,513 5,20 14,-4 9,-2 1,-2 -4,-16 -1,-3 -1,-6 -4,-2 -5,1 -2,3 1,2 -4,1 -2,2 -3,1 0,1 -3,1 0,2 -1,1
214;6;5;3;230,530 -3,24 26,3 2,-18 1,-5 -13,-2 -13,-2
215;6;5;4;253,557 22,2 6,-15 -16,-3 -10,-2 -2,18
216;7;1;2;314,562 1,-3 5,-18 -8,-3 -6,17 -4,-2 5,-15 -6,-2 -2,6 -3,9 -5,15 16,8 7,-12
217;7;2;2;307,574 21,11 6,-13 -7,-3 -10,-6 -3,-1 -7,12
218;7;2;2;328,585 16,9 8,-14 -12,-6 -5,-3 -1,1 -6,13
219;7;2;2;379,601 -3,-2 -13,-8 -2,-1 -6,9 19,11 5,-9
220;7;3;3;373,611 12,8 2,-4 11,-19 1,-5 -2,-1 -5,11 -2,-1 -2,3 -8,-4 -1,2 -5,9 -1,1
222;7;2;2;431,625 -16,-9 -6,12 -2,3 16,9 8,-15
223;7;1;2;452,635 -15,-7 4,-7 -5,-3 -1,0 -4,7 -8,15 20,11 9,-16
224;6;2;3;468,638 19,11 6,-13 -19,-11 -6,13
225;6;3;3;493,636 8,-15 -18,-11 0,-1 -9,16 19,11
226;3;1;3;483,610 18,11 7,-13 -17,-12 -16,-10 -2,3 -2,3 17,11 -5,7
227;7;2;3;494,579 -2,-1 0,-2 -2,-1 0,1 -7,-4 -20,-12 -11,-7 -4,-2 0,0 -7,10 -1,2 5,3 10,7 6,3 4,3 1,0 8,6 1,1 16,10 17,12 10,-20 -20,-11 -2,-2 -2,4
228;15;0;1;453,545 34,22 4,-7 7,5 -4,7 5,3 -1,2 20,11 12,-24 -68,-43 -9,16 3,2 -3,6 0,-1 0,1 -1,0 1,0
230;3;0;1;428,517 4,-9 -17,-8 -4,9 4,3 13,5
231;7;2;2;359,467 9,-13 -17,-12 -9,13 12,8 5,4
234;7;1;1;163,282 -6,10 10,7 4,-6 2,-3 -10,-8
236;5;0;1;386,374 0,0 -19,-13 -23,35 -2,-1 -7,10 24,16 3,-3 24,-44
241;6;11;5;477,422 17,-28 -16,-9 -16,28 15,9
242;6;13;5;448,435 16,9 13,-22 -15,-9 -14,22
243;6;12;5;457,477 22,14 10,-15 -22,-14 -10,15
244;6;11;5;479,491 28,17 10,-15 -1,0 -27,-17 -10,15
245, 246;6;18;5;546,497 0,1 15,10 33,-50 -16,-9 -14,21 -18,27
247, 248, 249;6;18;4;575,434 9,-13 -22,-14 -42,-27 -9,12 64,42
250;6;5;4;569,548 -3,5 3,1 -3,5 -4,-3 -1,3 -9,-5 -9,17 19,9 6,-13 2,-2 1,1 5,-10 9,-17 -2,-1 2,-4 -6,-4 0,0 -3,5 2,1 -7,14 -2,-2
251;6;3;3;588,575 -8,-5 -1,2 -11,-5 -6,13 18,9 8,-14
254;7;1;2;907,782 2,2 10,-12 -12,-9 -15,18 10,7 5,-6
255;7;1;3;977,539 -3,-2 -9,-10 -1,1 1,0 -13,13 0,0 -5,5 14,14 5,-5 0,0 13,-13 0,1 1,-1 -1,-1 -2,-2
258;7;1;2;863,799 5,6 4,5 7,-6 -4,-4 5,-3 -6,-7 -11,9
259;7;1;2;805,196 -7,13 10,6 12,-22 -26,-13 -4,8 15,8
260;7;1;1;868,100 6,5 -5,7 9,7 13,-18 -9,-7 -5,7 -6,-5 -3,4
261;7;1;;825,992 4,-4 7,-6 -6,-6 -1,1 -9,10 5,5
264;16;0;1;834,294 5,-7 -7,-6 -2,2 -7,7 -7,8 3,3 15,-7
267;7;2;2;882,889 1,-2 1,-2 -8,-6 -6,9 -5,-4 -6,9 16,11 7,-15
269;7;3;2;720,336 15,-20 -14,-10 -4,6 -11,-8 -11,14 9,6 -2,3 4,4 3,-3 11,8
271;7;1;2;126,667 -3,2 7,9 14,-11 -7,-9 -11,9
272;7;2;2;186,740 5,6 2,-2 1,1 8,-7 -14,-15 -8,7 -5,5 7,8 4,-3
273;7;1;1;107,296 6,-9 -5,-3 2,-4 -8,-5 -5,-3 -8,12 18,12
274;7;1;2;14,673 11,-3 -1,-4 7,-2 -3,-10 -16,5 -2,1 4,13
275;7;2;2;281,368 1,-1 6,-9 10,-13 -1,0 -11,-8 -1,1 -5,7 -5,-4 -11,15 17,12 0,0
283;7;2;2;255,1025 11,4 9,-21 -12,-4 -3,7 -5,14
286;7;1;1;278,1001 8,-21 -12,-5 -3,8 -1,1 -6,-2 -5,11 19,8
287;7;3;3;814,348 3,-2 2,3 5,-4 -2,-4 8,-6 -11,-14 -17,12 12,15
289;6;6;3;299,947 9,-23 -13,-5 -9,22 0,1 11,4 2,1
290;7;1;1;114,676 7,9 9,-7 -7,-9 -9,7
295;7;2;2;240,1053 15,5 8,-22 -10,-4 -3,7 -4,-1 -6,15
303;7;1;2;112,298 21,8 5,-12 -7,-3 3,-6 -10,-4 -2,6 -5,-1 -5,12
305;7;2;2;651,1011 23,9 6,-16 -5,-2 -1,2 -6,-3 -1,3 -11,-5 -5,12
308;7;2;1;216,1109 16,6 8,-20 -11,-5 -3,9 -5,-2 -5,12
309;7;2;2;601,483 13,9 7,-10 5,-7 -13,-9 -12,17
310;6;5;3;586,980 23,11 6,-12 -3,-2 -5,-2 3,-6 -7,-3 0,0 -5,-3 -3,6 -3,-1 -6,12
318;7;1;2;33,634 -3,-11 -22,5 2,11 23,-5
324;7;1;1;588,188 12,7 10,-18 2,-4 -11,-6 -13,21
325;7;3;2;89,284 8,-12 -14,-10 -7,-6 -7,9 1,5 19,14
326;6;5;3;831,369 -8,-8 -12,15 -11,-10 1,-2 -2,-2 7,-7 -12,-13 -20,20 36,31 21,-24
328;7;3;3;218,583 0,7 9,-1 0,-18 -10,0 1,12
329;7;1;2;179,628 15,-3 -2,-7 -3,-16 -14,4 2,13 2,9
331;7;2;2;453,1147 9,-21 -21,-9 -9,21 21,9
332;7;2;3;404,1201 6,2 13,6 9,-21 -19,-8 -9,21
334;6;3;3;761,301 12,5 11,2 4,-21 -11,-3 -3,0 -4,4 -9,13
335;7;1;2;548,276 7,-11 3,-7 -9,-5 -1,-1 -11,19 11,6 0,-1
336;7;1;3;772,337 10,-18 -13,-8 -4,8 -6,10 13,8
337;7;1;1;1047,209 0,12 16,-1 0,-12 -16,1
342;7;1;2;275,559 16,7 5,-15 -15,-7 -6,15
347;6;4;3;477,669 10,-20 -19,-11 -3,6 3,2 -8,14 17,9
351;7;2;1;536,235 9,6 12,-18 -10,-6 -5,8 -7,-5 -5,7 8,5 -2,3
352;6;4;4;544,995 11,-17 -13,-10 -10,19 12,8
354;7;1;2;443,651 6,3 3,-6 1,0 1,1 8,-14 -2,-1 -6,-3 -2,4 -9,16
355;7;1;2;565,365 14,9 7,-11 -4,-3 2,-4 -5,-3 -2,3 -4,-2 -8,11
360;7;3;2;949,125 14,3 1,-4 4,-19 -14,-3 -5,23
362;7;3;3;328,444 9,-12 -8,-5 -19,25 9,6 9,-14
365;6;3;3;356,226 16,8 5,-8 3,1 3,-5 -3,-1 8,-14 -16,-10 -16,29
367;5;1;3;169,360 3,-2 -3,-9 -4,2 -6,-14 -17,6 14,34 17,-6 -4,-11
368;7;1;1;77,236 12,5 8,-24 -12,-4 -8,23
374;7;1;2;532,302 3,-5 4,2 7,-10 -4,-3 2,-3 -10,-6 -12,19 10,6
375;7;2;3;516,334 -2,3 4,2 2,-3 6,4 4,-7 -3,-1 4,-7 -15,-10 -8,14 8,5
379;7;2;2;496,276 5,3 -3,6 11,7 12,-19 -12,-7 -4,7 -6,-3 -3,6
382;7;2;2;597,138 19,12 8,-12 -8,-5 -6,-4 -5,-3 -8,12
384;7;2;2;437,83 8,4 -2,3 8,4 7,-14 -6,-4 1,-1 -9,-5 -7,13
385;7;2;2;657,176 19,11 4,-8 -4,-2 2,-5 -15,-9 -6,13
386;7;2;1;554,112 -1,1 4,3 1,-2 7,5 6,-10 -13,-9 -5,-2 -6,9 7,5
387;7;1;2;442,46 6,4 1,-2 8,4 7,-12 -16,-10 -7,13 2,1 -1,2
388;7;2;1;424,108 17,9 7,-14 -17,-9 -7,14
389;7;1;1;515,88 20,13 8,-13 -5,-3 2,-3 -9,-6 -2,3 -5,-2 -1,-1 -8,12
390;7;3;2;513,249 5,3 -2,3 2,1 7,4 8,-13 -14,-9 -1,3 -5,8
391;7;1;2;663,267 6,3 -2,2 2,1 6,3 6,-11 -12,-7 -1,-1 -5,10
392;15;0;;845,358 31,6 0,0 0,-2 1,-8 -8,-2 -13,-2 -5,-1 -6,3 -1,6 1,0
394;7;1;2;577,234 -12,-8 -10,15 12,8 6,-8 3,-5 1,-2
399;7;1;2;470,113 8,5 3,2 5,-8 5,-7 1,-2 -12,-8 -12,17 2,1
400;7;2;2;589,39 5,-8 -6,-4 -6,-4 -6,8 7,4 6,4
401;7;1;2;564,22 7,5 5,4 6,-8 -4,-2 -8,-7 -6,8
402;7;2;2;637,147 -5,8 -2,4 14,9 4,-7 3,2 2,-4 -3,-1 1,-3 2,-3 -7,-5 -2,3 -7,-3
404;7;1;1;209,929 1,-3 -3,-1 -1,3 -4,-1 -1,3 0,0 -2,5 4,1 -6,20 12,4 8,-28 -8,-3
407;5;0;1;360,488 6,4 -2,3 9,6 -3,3 -2,-1 -6,10 1,1 -2,3 11,8 11,-15 5,-7 11,-14 -26,-18 -13,17
408;3;0;1;316,392 12,-17 -11,-8 -2,2 -4,-2 -10,14 15,11
409;7;1;2;300,321 -2,3 7,6 9,-11 3,2 3,-4 -3,-2 0,0 -13,-11 -1,2 -2,0 -3,3 2,1 -5,7 5,4
411;7;2;2;337,277 -2,3 8,6 2,-3 1,1 4,-6 -1,-1 3,-4 5,-7 -8,-6 -8,-5 -12,16 8,6
427;7;1;2;513,60 7,4 7,-13 4,-7 -8,-4 -10,20
429;6;3;3;586,223 3,-4 2,1 4,-7 -3,-1 4,-6 -14,-8 -10,17 14,8
430;14;0;2;320,759 18,0 1,-19 -8,0 0,3 -12,0 1,16
431;7;1;2;958,142 -2,0 1,-4 -5,-1 -1,4 -14,-4 -4,17 31,6 15,3 3,-14 -25,-5 1,-2
433;7;2;2;727,181 4,2 -3,5 13,8 9,-15 -6,-3 1,-2 -10,-6 -3,6 -2,-1 -3,6
442;5;0;3;514,144 3,-5 23,15 -4,6 15,9 -5,8 13,7 17,-27 -8,-5 -12,-8 -42,-26 -11,19 11,7
453;16;1;3;510,181 1,-2 24,15 -1,2 12,8 10,-15 -8,-6 -1,2 -34,-21 -2,3 -7,-5 -7,11 13,8
458;7;3;2;693,187 -7,11 13,8 0,-1 4,3 5,-10 -6,-3 2,-3 -11,-5
472;7;2;2;653,381 6,-7 2,-3 4,-5 -9,-8 -12,14 9,9
473;7;3;3;702,591 -12,20 7,6 13,-21 -8,-5
474;7;1;2;815,803 5,-11 -9,-4 -5,-3 -10,-5 -4,11 23,12
475;7;2;3;679,829 6,-18 -9,-3 -8,-3 -6,19 17,5
476;7;2;2;594,778 14,6 8,4 2,-6 10,-24 0,0 -6,-3 -10,21 -5,-2 0,0 -2,4 -9,-4 -1,0 -1,4
477;7;1;2;524,960 -13,-7 -4,9 13,7 4,-9
479;6;4;2;485,792 14,-34 -2,-1 4,-8 -7,-3 -2,-1 -19,46 11,4 1,-3
480;3;0;;467,761 3,-8 8,-23 3,-8 -6,-2 -3,11 -2,0 -4,9 -4,-1 -6,18 4,1 7,3
481;16;0;;365,705 22,11 5,-9 -12,-7 -6,-2 -5,-2 -4,9
482;7;1;2;176,310 6,-10 -11,-7 -4,6 -8,9 7,7 6,-8 4,3
486;7;1;1;152,944 13,3 5,-17 -17,-4 -3,14 3,0 -1,4
487;7;2;1;766,247 7,-13 4,-5 2,2 3,-5 -4,-3 -4,-3 -3,5 -19,-13 -8,14 9,13 13,8
488;5;0;3;627,215 13,8 -3,5 6,3 3,-5 10,6 12,-21 -10,-5 1,-2 -7,-4 -1,3 -13,-8 -11,20
503;5;0;;458,294 8,-12 3,2 9,-14 -15,-10 -2,4 -6,-4 -15,22 1,1 0,0 0,3 3,1 2,-1 0,0 12,8
513;7;1;2;752,86 1,-2 2,1 11,-17 -10,-6 -13,21 8,5 1,-2
515;7;2;2;388,305 14,11 11,-13 -13,-10 -7,9 -2,-1 -3,4
520;7;1;2;34,694 14,-4 -4,-12 -14,5 4,11
521;7;1;2;779,47 8,-12 -9,-6 -4,5 -4,-2 -4,7 4,2 -2,3 5,3 1,-3 5,3
523;7;1;2;129,881 3,-15 -6,-1 -7,-2 -3,15 4,1 9,2
524;7;1;2;103,876 9,1 4,1 3,-15 -13,-2 -3,15
531;7;1;2;810,175 7,-11 -11,-7 -3,4 -4,-3 -4,7 1,1 -1,2 5,3 1,-2 9,6
534;7;2;2;670,37 2,1 3,2 4,-6 4,-7 -14,-9 -9,14 10,5
541;7;1;2;755,138 14,8 8,-13 -14,-9 -7,11 -1,3
544;7;1;2;588,114 -5,-4 -8,10 -3,3 7,5 9,-14
545;7;2;2;695,144 14,8 1,-2 6,-10 3,-3 -3,-2 2,-1 -11,-8 -4,6 -3,4 -5,8
546;7;2;1;647,12 -5,-5 1,-1 -5,-6 -10,10 11,11 8,-9
547;7;2;1;985,54 -2,7 -2,8 12,4 5,-15 -13,-4
549;7;3;2;636,355 3,-5 -2,-1 1,-1 -4,-3 3,-5 -9,-6 -5,-3 -7,12 20,12
558;16;0;2;824,278 6,5 2,-2 7,6 -5,7 21,-10 29,-10 -8,-24 -5,-13 -27,4 -35,31 -1,11 10,2 6,-7
565;7;2;2;83,783 -7,9 1,1 9,7 3,-4 1,-1 5,3 8,-10 1,-1 -5,-3 3,-4 -10,-8 -9,11
566;7;2;2;787,106 -1,-1 4,-6 -11,-7 -7,12 11,7 4,-5
576;7;1;2;806,72 1,-2 1,1 3,-5 -2,0 4,-6 -10,-6 -7,11 10,7
578;7;1;2;994,279 -3,-10 -13,3 3,11 13,-4
579;16;1;1;409,928 9,-12 -21,-16 -14,18 0,-1 -7,14 -1,1 11,6 6,-12 -1,0 4,-7 14,9
653;12;0;1;708,858 13,-27 9,-20 -9,-5 -22,48 9,4
654;7;1;2;740,852 6,3 5,2 6,-12 -11,-5 -6,12
655;7;1;2;755,859 6,3 6,-12 -10,-5 -6,12 4,2
656;5;0;1;265,417 36,22 13,-21 -41,-26 -14,21 6,4
661;5;0;1;970,468 10,18 79,-43 -10,-18 -3,2 -12,6 -47,26 -12,6 -5,3
6;19;0;;669,296 0,-9 -8,0 0,8 8,1
7;8;0;;904,647 4,4 4,-5 -5,-3 -3,4
34;19;0;;74,366 1,28 1,6 0,8 13,-1 3,0 -1,-40 4,0 -1,-10 -17,1 0,4 -2,0 0,4 -1,0
287;8;0;;817,1057 -9,-3 -5,17 15,4 3,-13 -5,-1 1,-4
290;18;0;;277,486 2,-3 -10,-5 -1,1 -2,4 10,5 1,-2
291;18;0;;274,468 10,5 2,-4 0,-1 -10,-5 -1,1 -1,4
292;5;0;;303,240 14,-24 4,3 15,-26 -50,-30 -15,26 4,2 -14,23 42,26
296;18;0;;271,508 2,-7 -11,-2 -2,7 11,2
297;18;0;;273,501 1,-8 -11,-2 0,2 -1,6 11,2
205;7;1;2;887,659 11,6 -1,2 9,5 3,-5 -1,-1 -2,-1 3,-5 -17,-9 -5,8
207;7;1;1;106,361 8,-5 -3,-5 -6,-7 -7,7 8,10
483;7;1;1;109,939 13,3 1,-4 4,1 3,-13 -16,-5 -5,18
484;7;1;1;95,992 13,4 1,-4 4,1 3,-14 -16,-4 -5,17
567;7;2;2;123,818 7,-16 -14,-6 -7,16 14,6
240;6;22;4;544,533 17,-25 -15,-10 0,-1 -1,0 -6,9 -6,-3 -16,-11 -1,1 1,0 -10,15 16,11 5,3 16,11
262;7;2;3;891,577 8,13 9,-6 5,7 8,-6 -5,-7 1,0 -9,-13 -11,7 1,1 -7,4
41;7;2;2;675,598 4,-7 16,-26 0,-1 -20,-9 -8,13 6,3 -8,15 0,0 -4,5 14,7
265;7;1;2;917,400 5,-5 2,2 6,-6 -2,-2 3,-3 -10,-10 -5,5 -1,-2 -3,0 -2,2 0,3 2,1 -5,5 10,10
266;7;1;2;893,449 10,-10 -8,-8 0,-3 -1,-2 -3,0 -2,2 0,2 -7,7 -1,-1 0,0 12,13
77;7;1;2;253,894 18,0 0,-18 -17,0 -1,18
343;15;0;1;421,407 -5,-4 -5,-3 -4,-4 8,-12 -16,-11 -11,15 -9,13 -1,2 -3,3 2,2 -2,3 0,0 -1,0 -3,5 -1,1 -6,9 39,28 7,-10 3,2 1,0 2,-4 3,-4 0,0 -19,-12 10,-18 7,4 4,-5
257;7;1;1;938,586 -10,14 10,8 10,-15 -10,-7
134;7;1;3;138,823 14,6 6,-14 -14,-7 -2,5 -2,5 -2,5
253;7;1;2;883,475 -12,-3 -4,-1 -4,17 1,0 15,3 4,-16
91;7;1;2;790,873 -2,2 3,3 2,-2 7,8 9,-9 -14,-16 -9,9 4,5
574;7;1;;737,111 -20,-13 -7,11 19,13 4,-8 2,1 2,-4
306;7;0;3;655,471 5,-10 -1,-1 -15,-8 -1,2 -14,-10 -6,8 25,15 7,4
237;18;0;1;703,374 1,-8 -8,-7 -3,4 10,11
100;7;1;2;857,620 12,9 1,-1 6,-8 0,-1 -12,-9 -7,10
315;7;1;2;938,300 -8,-22 0,0 -2,0 -13,5 8,22 15,-5
239;15;0;;956,694 28,13 13,-27 -18,-8 -10,-5 -13,27
800;6;7;4;387,245 7,5 11,7 8,-13 1,1 3,-5 -1,-1 8,-12 -3,-2 -14,-10 -7,11 -2,-1 -5,8 1,1 -7,11
216;7;1;2;10,830 0,0 10,3 4,-18 -7,-2 -2,6 -13,-2 -2,10 10,3
217;7;1;2;24,778 -1,6 -13,-3 -2,11 9,2 0,1 3,1 8,2 0,-1 4,-17 -8,-2
572;7;1;2;88,843 2,-19 -11,-1 -1,19 10,1
;18;;;30,805 1,-7 -3,-1 0,1 -8,-2 -1,7 11,2
;19;;;836,1089 6,3 3,-8 -8,0 -1,5
;18;;;811,1252 7,2 2,-14 -7,-1 -2,13
;18;0;1;772,713 -22,-8 0,2 -1,1 -3,-1 -2,4 -2,-1 -3,7 2,1 4,1 9,3 0,-2 15,6 4,-12 -1,-1
;19;0;;1021,293 -1,-4 -7,1 1,5 7,-2
;18;;;302,1069 -5,-2 -4,9 6,2 3,-9
;18;;;426,412 9,6 3,-4 -10,-5 -2,3
;19;;;697,700 33,14 3,-7 -33,-15 -3,8
;19;;;686,790 5,3 2,-5 0,-1 -5,-3 -2,6
;18;;;845,320 9,-3 -4,-10 -9,3 3,9 1,1
;18;;;181,828 -4,-2 -4,9 5,2 3,-9
;18;;;290,1115 4,-10 -4,-1 -4,10 4,1
;18;;;168,848 7,3 3,-5 -8,-3 -2,5
;18;;;692,342 11,8 3,-5 -11,-7 -3,4
;18;;;692,342 -4,5 11,8 0,0 4,-5 -11,-8
;18;;;603,359 8,6 4,-6 -8,-6 -4,6
;19;;;406,1213 13,5 2,-5 2,-4 -13,-6 -2,4 -2,6
;19;;;319,653 9,2 8,-7 -13,-5 -4,10
;19;;;520,64 7,4 7,-14 -7,-3 -7,13
;19;;;932,940 14,8 15,-19 -15,-10 -1,2 -13,19
;18;;;147,852 2,-5 -11,-4 -2,5 11,4
;18;;;299,1119 4,-10 -4,-2 -4,10 4,2
;18;;;330,1042 4,-10 -5,-2 -4,10 5,2
;18;;;307,1071 3,-9 -5,-2 -3,9 5,2
;18;;;260,1131 4,2 3,-9 -4,-2 -3,9
;18;;;281,1112 5,-10 -5,-2 -4,10 4,2
;19;0;1;723,304 2,-6 -15,-5 -2,7 15,4
;19;;;170,1101 4,2 1,-2 9,3 1,-4 8,-20 -11,-3 -3,8 0,0 -14,-5 -5,15 10,4 0,2
;19;;;411,840 19,6 8,-29 -20,-6 -7,26 0,3
;18;;;644,82 1,0 -2,-2 -5,-7 -9,7 7,8 8,-6
;18;;;302,1069 3,-9 -5,-2 -3,9 5,2
;18;;;303,1109 4,-8 -5,-2 -3,8 4,2
;18;;;294,1105 4,-8 -4,-2 -4,9 4,1
;18;;;272,1136 4,1 3,-9 -4,-1 -3,9
;18;;;442,406 2,-4 -9,-5 -2,4 9,5
;18;;;424,417 9,5 2,-4 -9,-6 -2,5
;18;;;469,361 2,-4 0,0 -9,-5 -2,4 9,5
;18;;;924,681 -9,-5 -3,5 9,5 3,-5
;18;;;450,371 0,1 -2,3 9,6 3,-5 -10,-5
;18;;;455,363 -2,4 9,6 2,-4 -9,-6
;18;;;466,365 3,-4 -9,-5 -3,4 9,5
;18;;;268,1134 4,2 3,-9 -4,-2 -3,9
;18;;;140,837 -2,6 11,4 1,-5 -10,-5
;18;;;299,1107 3,-8 -4,-2 -4,8 5,2
;18;;;315,1036 3,-10 -5,-1 -4,9 6,2
;16;;;287,271 -8,-6 -6,8 8,5 6,-7
;18;;;191,831 -5,-2 -4,10 5,2 4,-10
;18;;;290,1104 4,-9 -5,-2 -3,9 4,2
;18;;;448,706 9,4 3,-6 -9,-4 -3,6
;19;;;684,146 1,0 4,3 3,-4 6,-10 -2,-1 -2,-2 0,-1 0,-1 -10,16
;18;;;325,1040 4,-10 -5,-2 -4,10 5,2
;18;;;311,1045 4,-9 -6,-2 -3,9 5,2
;18;;;316,1047 6,2 3,-9 -5,-2 -4,9
;18;;;316,1064 -6,-2 -3,9 5,2 4,-9
;18;;;304,1080 5,2 3,-9 -5,-2 -3,9
;18;;;314,1084 3,-9 -5,-2 -3,9 5,2
;18;;;281,1112 5,2 4,-10 -4,-2 -5,10
;19;;;641,267 -8,-2 -2,5 8,2 2,-5
;19;;;968,371 8,-4 -2,-5 -8,4 2,5
;18;;;166,853 -2,6 7,3 2,-6 -7,-3
;18;;;168,848 -2,5 7,3 2,-5 -7,-3
;18;;;703,510 12,7 3,-6 -12,-6 -3,5
;19;0;1;237,1035 -4,-1 -8,-4 -3,6 -13,-5 -4,12 16,6 9,4 1,-2 6,-15 0,-1
;18;;;264,489 10,4 2,-5 -10,-5 -2,6
;18;;;279,483 2,-5 -10,-5 -2,5 10,5
;18;;;274,468 -3,5 10,5 3,-5 -10,-5
;19;;;1034,299 -1,-3 -7,1 1,3 7,-1
;18;;;180,846 -1,3 -1,4 5,2 2,-7 -5,-2
;19;;;183,380 17,-4 0,5 0,10 13,0 0,-18 -3,-11 -29,7 2,11
;18;;;120,954 -15,-4 -1,5 14,4 2,-5
;19;;;876,250 5,-2 -4,-12 -6,1 5,13
;19;;;245,589 0,10 4,1 -2,-11 1,-18 -3,-1 0,19
;19;;;566,304 6,-11 -5,-2 -5,11 4,2
;18;;;307,1071 -5,-2 -3,9 5,2 3,-9
;18;;;737,92 9,6 3,-5 -8,-5 -4,4
;19;;;503,1061 53,14 2,-7 5,1 5,-4 2,-6 -4,-5 -5,-1 2,-8 -53,-13 -3,10 -3,-1 -2,10 3,1 -2,9
;19;;;961,929 5,-6 -16,-10 -4,6 15,10
;18;;;280,1139 3,-9 -4,-2 -3,9 4,2
;18;;;324,1028 -6,-2 -3,10 5,2 4,-10
;19;;;159,1126 9,-21 -11,-4 -8,22 10,3
;1;;;398,835 13,2 0,-7 5,-21 -8,-1 -4,0 -2,14 -3,-1 -1,14
;18;;;186,829 -5,-1 -3,9 4,2 4,-10
;18;;;621,482 8,6 3,-5 2,-4 -7,-5 -1,1 -5,7
;18;;;696,359 8,7 2,-6 -7,-5 0,0 -3,4
;18;;;317,1075 4,-9 -5,-2 -4,9 5,2
;18;;;192,843 5,2 4,-10 -5,-2 -4,10
;18;;;332,715 6,1 1,-12 -6,0 -1,11
;18;;;178,846 2,-5 -7,-3 -3,5 8,3
;18;;;187,841 5,2 4,-10 -5,-2 -4,10
;19;;;301,585 -2,21 4,0 7,-16 -9,-5
;18;;;440,410 2,-4 -9,-5 -2,4 9,5
;18;;;431,405 -1,2 -2,2 10,5 0,-1 2,-3 -9,-5
;18;;;453,367 -3,4 10,5 2,-3 -9,-6
;18;;;780,517 13,6 8,-18 -3,-1 12,-25 -8,-5 -22,43
;19;;;208,1074 2,-6 -8,-3 -2,6 8,3
;18;;;464,369 2,-4 -9,-5 -2,3 9,6
;18;;;290,1115 5,2 4,-10 -5,-2 -4,10
;18;;;614,62 7,8 8,-8 -8,-8 -7,8
;18;;;492,253 0,0 -6,9 9,5 6,-9 -9,-5
;5;;;110,509 16,-18 -5,-4 -16,18 5,4
;18;;;538,352 3,2 5,-8 -3,-2 -5,8
;16;;;213,214 13,-21 -18,-10 -3,4 7,4 -2,4 -6,-3 -3,6 5,3 -4,6 11,7
;18;;;322,1049 5,2 3,-9 -5,-2 -3,9
;18;;;289,1143 4,-9 -6,-2 -3,9 5,2
;18;;;320,1038 -5,-2 -4,9 5,2 4,-9
;18;;;549,314 9,4 2,-6 -8,-4 -3,6
;18;;;280,1139 4,2 3,-9 -4,-2 -3,9
;18;;;444,402 3,-3 0,-1 -9,-5 -3,4 9,5
;18;;;710,1030 1,-4 -5,-3 -4,10 6,2 2,-5
;18;;;80,338 5,4 6,-7 -5,-4 -6,7
;18;;;887,460 7,5 6,-9 -8,-5 -5,9
;18;;;286,1102 3,-9 -5,-2 -3,9 5,2
;18;;;280,521 4,0 2,-9 -5,-1 -1,10
;18;;;922,127 -2,6 8,3 2,-6 -8,-3
;18;;;669,668 13,5 0,-1 3,-7 -12,-5 -3,7 -1,1
;18;;;268,1134 3,-9 -4,-1 -3,9 4,1
;18;0;1;930,321 4,10 13,-5 -4,-10 -13,5
;11;4;1;676,651 2,-7 -22,-9 -3,8 23,8
;19;0;1;423,997 9,1 2,-13 -9,-1 -2,13
;19;0;1;308,356 9,-13 -9,-5 -8,12 8,6
;18;0;1;868,590 5,2 0,0 15,8 5,-9 -16,-8 -1,1 -4,-2 -4,8
;18;0;1;162,966 2,-11 -14,-4 -3,11 15,4
;19;0;1;449,245 10,-17 3,-4 -9,-6 -13,21 9,6
;18;0;1;90,890 3,7 7,-3 -4,-9 -6,2 -1,1 1,2
;19;0;1;983,162 15,3 3,-15 -15,-3 -3,15
;18;0;1;729,492 3,-6 -8,-5 -3,7 8,4
;19;0;1;59,433 4,2 7,3 6,-15 -6,-2 -5,-3 -3,9 -3,6
;18;0;1;731,37 8,5 4,-6 -8,-5 -4,6
;18;0;1;967,234 10,1 0,-5 1,-7 -10,-1 -1,7 0,5
;19;0;1;429,911 16,11 5,-9 -15,-10 -6,8
;19;0;1;281,617 -2,-13 -5,1 2,13 5,-1
;18;0;1;282,367 8,6 7,-9 -9,-6 -6,9
;18;0;1;828,161 4,-10 -13,-9 -6,9 15,10
;19;0;1;86,1028 23,5 10,3 3,-13 2,-8 -9,-2 -2,8 -1,2 0,0 -23,-6 -3,11
;18;0;1;102,961 15,4 1,-5 -14,-4 -2,5
;18;0;1;680,293 8,2 2,-6 -9,-2 -1,6
;18;0;1;706,300 2,-7 -8,-3 -2,8 8,2
;18;0;1;692,296 6,2 2,-8 -6,-1 -2,7
;18;0;1;688,295 4,1 2,-7 -4,-1 0,1 -2,6
;16;0;1;375,905 6,3 4,-7 -6,-3 -4,7
;19;0;1;385,962 7,5 11,-16 -8,-4 -10,15
;19;;;811,81 -4,5 8,6 9,-12 -9,-6 -4,7
724;7;1;1;153,1019 0,0 -3,14 -3,0 -1,7 2,1 -4,13 12,3 9,-35 0,0 -12,-3
84;7;1;2;835,146 9,8 8,-9 -9,-8 -8,9
105;7;1;2;898,514 9,11 5,-4 1,0 4,-3 -2,-2 4,-3 1,1 6,-5 -9,-11 -19,16
198;7;1;2;919,1027 14,6 0,-1 5,3 6,-11 -6,-3 1,-1 -5,-2 -4,-2 -5,-2 -6,13
57;7;1;1;727,1245 -2,14 22,4 0,3 11,1 4,-29 -15,-2 -2,11 -18,-2
772;7;1;2;217,1142 8,-19 -11,-4 -8,19 11,4
47;3;6;4;829,1097 -20,-10 -5,10 -2,-1 -2,4 -10,-5 -3,4 -3,6 -2,4 39,6 8,-18
60;7;1;2;828,849 -8,8 10,11 9,10 8,-7 -1,-1 10,-9 -5,-6 -5,5 -5,-5 0,1 -4,-3 -3,3 -6,-7
56;7;1;2;785,1266 12,2 0,-2 2,-10 0,0 -12,-2 -2,12
53;7;1;2;774,1265 11,1 2,-12 -12,-1 0,0 -1,10 0,2`;
const SAMPLE_BASE = String.raw`#road
568,722 42,-109 106,-196 16,-22 46,-51 7,-10 8,-22 6,-40 9,-39 11,-24 16,-27 67,-76 14,-25 24,-59 11,-46 15,-117 40,-184 99,-157 152,-230 32,-57 47,-105 6,-29 0,-29 -27,-95 -5,-37 5,-28 9,-14 15,-9 66,-21 27,-12 25,-18 19,-18 24,-40 113,-237 19,-32 28,-41 79,-91 27,-35 30,-56 14,-38
93,-20 -25,-18 -16,-7 -30,-5 -21,4 -31,16 -31,23 -62,65
93,-20 10,20 6,23 -1,24 -4,16 -49,136 -26,62
125,-266 -41,71 -20,45 -6,26 0,20 4,17 31,67
377,856 -1,20 -4,12 -35,66 -11,13 -30,21 -17,27 -69,179 -9,37 -24,125 -12,15 -22,15 -63,25 -21,12 -13,16 -66,99 -19,37 -20,92 -58,340 -20,94 -10,20 -10,16 -32,40 -62,66
125,-266 -65,73 -79,98 -48,67 -56,86
-231,175 96,27 164,59
377,856 68,-4 23,4 11,3 26,15 83,68 33,19 63,23 114,32 35,5 30,-3 23,-8 33,-18 26,-7 18,0 19,6 18,14 14,20 40,92 23,46 131,176 13,16 17,15 135,81 111,73 39,16 135,39 34,12 19,10 20,14 10,13 36,75 6,8 16,13 264,114 17,9 18,17 59,91 9,31 -2,28 -3,12 -73,151 -63,124 -10,15 -16,16 -11,7 -16,6 -34,3 -72,-17 -25,0 -19,7 -14,10 -9,10 -7,13 -31,99 -3,19 1,24 6,17 9,16 27,35 15,16 23,15 52,13 87,17 60,3 46,-2 20,-4 40,-17 148,-77 32,-9 30,-3 28,4 15,6 45,25 79,50 36,17 39,11 28,1 26,-4 198,-91 33,-6 83,-5 26,2 15,4 127,55 43,16 97,16 19,6 57,26 33,22 284,286 38,29 97,59 37,19 33,10 17,2 38,3 133,-2 27,3 33,13 22,17 15,17 7,13 6,20 1,24 -11,89 -1,24 5,35 10,21 155,194 187,245 21,14 28,7 40,0 356,-44 29,-1 21,2 19,5 25,10 28,17 16,14 29,29 212,235 19,17 20,11 218,71 27,5 16,0 71,-11 188,-34 42,2 234,61 100,30 19,9 156,88 55,28 18,6 14,1 21,-3 168,-65
-245,182 -4,84 1,27 6,33 14,31 15,22 20,20 34,26 119,80 26,22 24,25 21,29 16,29 43,118 8,16 14,20 15,14 14,9 25,11 63,15 76,13 29,11 30,17 13,2
#street
143,386 -17,-41 -14,-25
658,631 95,37
803,849 28,33
97,590 -3,4
952,1431 10,-65
673,143 -12,-37 -2,-18
896,470 27,-51 0,-8
568,722 -90,-45
66,549 11,0
245,355 15,-16 77,-106
303,446 -12,23
-14,527 14,14
-14,527 -15,2
867,1108 53,9 102,45 14,-1 32,-15
595,651 15,-38
713,-46 -6,-10 -21,-13 -7,-10 -4,-11
579,389 42,-68
535,579 2,-26
734,-30 -21,-16
896,470 121,62 4,8
303,446 -37,19 -23,21 -34,58
537,553 -10,-1 -10,-6 -108,-66
831,882 104,70 7,12 3,21
112,320 -9,-10 -24,-20 -15,-11 -35,-18
94,594 142,182
789,976 -12,0 -67,-34
325,415 -22,31
831,882 -34,23 -16,8
721,408 42,-47
610,613 111,-205
1014,1025 133,9
618,1037 49,25 48,30 48,36
682,1044 37,1
236,776 -10,-28 -33,-148 -4,-29 10,-12
579,389 23,16
864,1254 -3,15 -8,23
599,460 4,4
236,776 -7,37
291,993 -12,22 -69,179 -9,37 -22,120 -9,15
17,562 49,-13
553,829 -16,-8
326,967 36,48
436,56 165,99
236,776 -36,-6 -13,-12
177,802 52,11
736,239 -8,-22 -23,-31
460,937 9,-10
478,677 14,-3
891,120 18,-24 7,-15 24,-59 11,-46 15,-117 10,-44
891,120 15,1 13,-2 10,-5 25,-19 35,-9 9,-7 37,-103 5,-34
525,599 10,-20
118,563 8,-11
77,549 49,3
610,613 -75,-34
177,802 -13,31 -6,35 -9,25 -26,104
1014,1025 33,77
960,303 9,12 28,24 34,42 27,28
957,255 -107,41 -24,11 -14,4 -19,1
77,549 2,-14
710,942 -51,-23
478,677 9,-10 38,-68
441,1089 -14,-13
126,552 73,7
468,-63 34,-87
763,361 37,31
1144,222 -106,7 -70,22
499,1144 -18,-15 -40,-40
618,1270 22,-4 22,1 59,8 65,4 67,13
723,564 -8,4 -25,29 -12,6 -10,9 -10,19
685,1439 -16,-71 -16,-36 -35,-62
583,729 189,91 31,29
793,312 6,-40
469,927 103,54 147,64
325,415 58,42 26,23
853,1292 109,74
697,386 24,22
472,378 -35,59
603,464 -58,81 -8,8
209,544 -10,15
497,333 16,-32 88,-146
337,233 44,-76 55,-101
618,1270 -30,-52 -16,-20 -73,-54
431,44 5,12
935,673 8,-20 22,-40 56,-73
29,261 24,-57
445,442 -8,-5
864,1254 1,-7 -1,-14 -24,-44 -8,-29 1,-23 4,-13 6,-9 9,-6
705,186 102,-162 -62,-48 -11,-6
346,603 -69,-35 -63,-5 -15,-4
635,427 -32,37
427,1076 12,-90 10,-31 11,-18
734,-30 -75,118
460,310 37,23
438,782 -1,-5 3,-18 38,-82
427,1076 -13,-12
781,913 -34,-6 -46,-13 -41,-14
199,559 -6,-5 -6,-9 -23,-92 -21,-67
229,813 76,13 29,11 30,17 13,2
945,985 18,0 19,6 18,14 14,20
783,1013 -99,-29 -63,-23 -33,-19 -83,-68 -15,-10
79,535 10,-33 54,-116
896,470 -19,46
409,480 -63,123
236,776 18,4 88,-5 40,1 56,6
852,1109 15,-1
478,677 -36,-18 -96,-56
659,919 -100,-55 -5,-5 -5,-13 4,-17
-138,439 98,66 26,22
1120,468 -22,4 -24,12 -53,56
504,976 -13,30 -10,38 18,100
853,1292 -9,39 3,5 48,51 57,44
349,869 -29,40 -8,16 -13,37 -8,31
836,1056 -24,-15 -14,-16
376,876 -4,12 -35,66 -11,13
682,1044 -21,1 -68,-21
245,355 80,60
819,1020 -36,-7
659,88 -16,-32 -31,-39
957,255 3,9 0,39
660,880 -30,-20 -44,-21 -33,-10
437,437 -28,43
601,63 33,30 21,32 18,18
499,1144 -17,32 -13,36 -62,301 -22,128
763,1128 17,11 23,8 12,9 8,29 39,59 2,10
504,976 30,21 59,27
497,333 82,56
337,233 123,77
968,251 -11,4
-11,825 12,-64 -5,-5 -66,-14
497,333 4,13
525,599 3,3
490,864 -44,-43 -5,-7 4,-25 -7,-7
774,263 -57,86 -9,25 -11,12
112,320 33,-1 33,7 33,11 34,18
66,549 2,9 26,36
29,261 -164,-59
568,722 27,-71
697,386 -62,41
0,541 17,21
896,470 -55,-43 -41,-35
659,919 1,-39
960,303 -11,68 -6,13 -20,27
635,427 -9,2
598,410 4,-5
595,651 -4,-2
17,562 30,48 43,118 14,26 16,18 21,15 36,15
326,967 -22,14 -13,12
774,263 25,9
962,1366 128,6
610,613 48,18
935,673 -27,-64
819,1020 -1,12 18,24
438,782 67,29 32,10
490,864 -22,-8 -23,-4 -68,4
362,1015 -3,10
546,-77 -1,16
593,1024 25,13
377,856 -1,20
968,251 -19,-25 -8,-5 -29,-6
414,1064 -8,4
736,239 38,24
460,310 -1,8 -34,48
735,-34 -1,4
65,214 -8,20 -9,11 -19,16
602,405 33,22
472,378 8,3
763,361 22,-27 8,-22
583,729 -27,70 -19,22
537,821 -47,43
799,272 11,-45 25,-45 56,-62
497,333 -25,45
460,937 44,39
469,927 6,-14 3,-18 12,-31
568,722 15,7
601,155 135,84
789,976 -8,-63
460,937 -13,-5 -71,-56
-64,564 42,-8 9,-4 13,-11
719,1045 99,42 19,10 15,12
419,1138 22,-49
705,186 -32,-43
362,1015 52,49
867,1108 -1,-23 -3,-9 -27,-20
945,985 -26,7 -33,18 -23,8 -22,3 -22,-1
803,849 35,-39 54,-44 17,-17 6,-13 20,-63
675,-90 -22,6 -40,6 -11,-7 -56,8
789,976 2,7 -8,30
#track
364,1092 -4,13 -9,12 -75,77 -16,25 -11,38 -2,77 -18,34
528,602 12,13
406,1068 -42,24
118,563 -13,14 -8,13
540,615 8,22
591,649 -27,-15
236,-68 -66,-78 -22,-11 -60,-20 -140,-79 -34,-24
507,397 70,47
361,1055 3,37
564,634 -9,0 -7,3
577,444 21,-34
577,444 -38,55
1222,146 -18,-15 -16,-9 -22,-8 -47,-13 -15,-8
372,-70 -101,-5 -21,2 -14,5
461,452 -16,-10
468,-63 -25,-4 -71,-3
564,634 7,-14 1,-9 -2,-4 -16,-7 -9,5 -5,10
539,499 -78,-47
485,-58 -17,-5
612,17 -27,-25 -19,-13 -38,-17 -25,-16
480,381 27,16
236,-68 -21,20 -26,36 -46,94 -25,63 -5,8 -35,39 -13,22
548,637 -17,17 -39,20
359,1025 2,30
503,-54 -18,-4
#path
461,452 58,-4
626,429 -43,11 -6,4
507,397 12,51
577,444 -58,4
501,346 6,51
577,444 22,16
519,448 20,51
512,-52 14,-7 5,-6 6,-26 14,-8 13,-19
372,-70 24,-122
539,-55 -12,5 -15,-2
512,-52 -9,-2
431,44 30,-73 1,-9 -13,-3 8,-9 12,-7 16,-1
723,564 24,6 -4,18 60,12 13,-2 19,-7 12,-12 12,-20 18,-43
735,-34 22,-64 12,-12 5,-21
545,-61 -6,6
#stream
717,360 -30,41
357,881 9,-35
293,1012 18,-52
208,14 -34,33 -26,52 -10,37 -17,23
871,234 -31,6 -31,19 -32,16
777,275 -42,57 -18,28
428,792 -79,-4 -38,2 -58,9
687,401 -39,23 -18,15 -21,24 -60,82
121,159 -45,61 -6,20
549,545 -13,11 -11,3 -117,-72 -188,-134 -119,-42 -30,-24 -20,-7
-13,1781 12,-51 9,-57 4,-66 4,-11 10,-18 29,-29 26,-38 8,-18 17,-57 7,-13 7,-4 30,-2 10,-3 19,-13 8,-11 4,-10 11,-85 12,-24 11,-81 21,-58 47,-120
253,799 -57,-10 -45,-14 -35,-28 -10,-13 -6,-15 -29,-100 -14,-36
366,846 -1,-7 -12,-12 -15,-6 -85,-22
57,583 -24,-47 -30,-48 -24,-31 -124,-93 -33,-16
51,280 -22,-8 -34,-7 -23,4 -24,10 -16,17
634,-545 -16,13 -30,99 -40,69 -9,4 -23,2 -108,52 -12,1 -24,-3 -10,4 -12,6 -9,13 -43,9 -9,5 -25,23 -6,5 -16,5 -8,9 -30,5 -19,8 -22,15 -5,6 -6,29 -37,104 -3,14 1,16 18,47 -1,28 -5,32 -13,50 1,14 8,11 0,9
1038,1116 -4,-8 -20,-17 -170,-80 -113,-34 -70,-19 -68,-35 -18,-15 -54,-62 -25,-24 -26,-16 -18,-8 -24,-6
311,960 22,-45 24,-34
70,240 -19,40
1290,224 -31,15 -26,9 -9,0 -20,-4 -28,2 -31,-14 -19,-1 -77,4 -73,21 -10,1 -16,-12 -12,-14 -22,-8 -45,11
#water
87,1115 -2,15 3,4 6,2 3,-2 3,-14 -13,-5
294,806 -51,3 77,14 28,10 18,13 9,2 -11,-19 -24,-11 -46,-12
8675,4271 -1,12 6,28 14,33 -6,6 -18,9 -58,7 -38,0 -12,-2 -42,-15 -31,-5 -18,-1 -18,6 -34,17 -17,-1 -56,-23 -49,-17 -18,-9 -25,-20 -39,-40 -32,-27 -32,-24 -9,-4 -14,0 -50,4 -35,-10 -6,-4 -10,-11 -14,-36 14,-39 1,-13 -10,-18 -23,-34 -9,-6 -49,-16 -22,-32 -16,-7 -21,-4 -10,2 -61,23 -14,-4 -44,-24 -10,-3 -20,3 -44,22 -12,4 -30,-13 -14,-10 -82,-14 -36,-6 -86,3 -32,-12 -68,-42 -15,0 -70,13 -36,34 -10,4 -63,5 -50,-5 -26,0 -22,5 -47,21 -46,29 -75,57 -15,29 -16,68 -8,24 -16,34 -24,27 -12,9 -64,25 -47,34 -28,15 -65,25 -10,2 -20,1 -14,-6 -22,-30 -18,-52 -17,-65 -27,-58 -62,-70 -20,-27 -40,-83 -14,-23 -11,-9 -14,-6 -20,-3 -88,4 -114,1 -63,-15 -53,-21 -39,-4 -14,3 -21,13 -17,19 -31,57 -26,79 -3,18 -40,64 -61,25 -50,4 -63,-10 -34,-14 -15,-17 -11,-29 -30,-24 -45,-9 -17,-7 -75,-7 -17,-7 -32,-35 -21,-71 -9,-24 -26,-43 -18,-52 -10,-12 -16,-12 -103,-44 -66,-35 -36,-15 -20,-3 -22,1 -59,2 -28,4 -20,15 -17,20 -19,28 -21,10 -75,11 -37,3 -66,-4 -49,10 -9,-1 -15,-9 -7,-10 -20,-54 -17,-75 -12,-26 -36,-40 -36,-45 -144,-121 -65,-65 -4,-9 -5,-22 -2,-25 3,-33 15,-73 5,-59 4,-13 9,-16 5,-16 1,-11 -4,-33 -11,-19 -5,-4 -14,-3 -49,-5 -144,11 -82,-5 -56,0 -39,-3 -42,-11 -17,-9 -81,-61 -15,-15 -35,-44 -56,-52 -13,-16 -28,-41 -46,-55 -26,-26 -47,-94 -11,-20 -5,-4 -14,-5 -71,-11 -15,1 -18,5 -74,33 -8,2 -21,-7 -17,-10 -64,-32 -16,-6 -104,-48 -46,-8 -4,-5 -57,-7 -36,-2 -18,2 -18,6 -17,21 -94,81 -39,26 -29,11 -42,-5 -33,-12 -172,-108 -22,-6 -26,-5 -28,2 -39,14 -37,27 -9,8 -13,21 -11,10 -15,11 -56,26 -25,9 -25,5 -81,-1 -30,-5 -82,-18 -25,-8 -13,-8 -19,-16 -24,-29 -7,-12 -3,-19 1,-19 14,-51 11,-36 13,-26 21,-15 22,-3 64,29 82,0 11,-2 18,-12 27,-37 26,-69 25,-47 16,-34 17,-42 9,-32 8,-19 14,-25 41,-51 12,-24 -2,-12 -9,-11 -38,-35 -54,-89 -38,-51 -26,-30 -14,-11 -44,-45 -14,-10 -29,-11 1,-7 -26,-5 -74,-26 -39,-8 -27,-4 -7,8 -76,35 -46,14 -68,6 -24,-4 -17,-6 -9,-7 -55,-102 -28,-30 -23,-16 -41,-16 -49,-25 -8,-2 -72,-30 -21,-13 -28,-25 -38,-50 -2,0 -9,-10 -23,-29 -53,-54 -16,-23 -7,-13 -11,-32 -26,-91 -19,-20 -16,-13 -67,-37 -55,-26 -84,-30 -148,-41 -79,-48 -42,-60 -14,-15 -20,-14 -51,-22 -32,-7 -53,-5 -90,6 -38,0 -64,-15 -29,-15 -13,-13 -8,-16 -45,-128 -23,-51 -69,-91 -83,-66 -67,-44 -67,-26 -93,-27 -79,-15 -34,-3 -25,0 -64,8 -70,19 -97,38 -32,3 -11,-1 -10,-3 -24,-15 -108,-77 0,-4 -130,-66 -23,-9 -105,-8 -106,-2 -64,4 -78,14 -24,6 -111,36 -24,13 -95,61 -101,47 -99,60 -19,8 -39,3 -18,-1 -8,-3 -5,-4 -35,17 55,5 65,-5 115,-67 87,-40 22,-11 34,-23 103,-54 48,-15 85,-22 73,-12 36,-1 118,5 53,-1 41,8 52,30 95,47 116,76 17,8 17,5 30,2 34,-7 95,-34 53,-14 83,-5 60,8 151,38 33,13 54,30 32,21 64,53 25,24 16,19 10,22 42,73 35,104 17,38 17,25 20,16 22,12 23,8 59,12 51,-3 6,-7 43,-1 49,2 48,6 29,12 24,15 79,85 16,12 64,33 133,40 40,8 107,50 68,38 17,16 20,32 5,16 -1,15 2,11 31,71 10,16 18,18 52,49 48,61 23,34 13,14 39,22 42,19 27,8 84,35 21,11 17,14 15,19 42,86 16,23 20,15 33,8 84,-6 32,-11 97,-47 13,-2 24,3 127,47 22,11 68,70 23,28 27,62 29,44 7,-4 57,70 1,9 -11,8 -10,15 -32,68 -16,54 -16,43 -15,32 -16,26 -38,90 -13,18 -18,16 -14,8 -21,5 -26,0 -32,-5 -27,-10 -29,-16 -17,-3 -10,1 -19,8 -21,19 -34,106 -4,34 5,20 12,23 11,15 34,28 13,8 21,8 86,21 46,5 54,3 27,-3 21,-4 24,-8 52,-26 29,-17 11,-13 8,-5 13,-3 7,-4 6,-14 24,-18 20,-11 33,-5 30,5 15,5 91,53 55,37 37,17 43,12 26,3 19,-4 16,-8 29,-22 73,-57 16,-19 17,-13 9,-15 6,-4 8,-3 41,-3 52,10 37,5 10,-2 12,2 68,32 33,11 70,34 16,4 33,21 16,3 21,-3 33,-14 24,-17 15,-7 11,-1 27,5 29,13 6,7 31,16 38,67 9,24 22,19 55,64 43,57 53,48 36,44 27,26 59,44 17,15 43,16 41,6 51,-2 110,8 138,-13 46,7 16,7 7,11 2,16 -1,13 -17,58 -25,164 1,22 6,27 6,12 14,17 40,41 157,131 35,45 36,39 10,22 22,85 17,45 9,14 7,6 13,7 10,2 32,0 10,-2 6,3 159,-18 53,-19 23,-35 30,-24 22,-3 59,-2 28,0 10,2 34,14 66,35 82,31 32,18 11,16 15,48 26,44 9,22 9,59 51,56 30,8 65,2 60,15 14,8 8,8 17,33 17,18 19,13 53,16 33,4 59,-7 15,-8 29,-10 6,-5 38,-51 11,-25 14,-51 47,-96 16,-17 16,-11 11,-2 39,3 61,25 62,11 47,-2 58,2 88,-3 16,2 11,4 7,7 12,20 41,83 19,26 63,71 23,48 19,72 19,55 15,23 13,10 18,8 21,0 103,-38 -2,-5 55,-28 34,-12 24,-11 30,-26 19,-24 18,-35 9,-25 14,-66 12,-24 74,-56 45,-28 45,-20 19,-5 24,0 50,6 56,-4 24,-8 32,-28 12,-7 67,-10 50,32 44,17 113,3 95,13 47,25 9,1 10,-3 43,-23 24,0 26,17 21,8 13,2 8,-1 47,-18 16,-1 17,2 16,7 17,31 52,17 26,34 8,14 -12,46 -1,8 6,19 14,23 22,15 28,7 18,2 38,-3 18,3 44,33 65,61 29,21 55,24 30,9 31,13 11,2 12,-2 50,-22 16,-2 38,8 38,16 96,-1 43,-22 3,-7 -2,-8 -16,-38 -3,-18 2,-14 15,-31 28,-16 37,2 37,-16 5,0 36,10 13,1 15,-1 32,-8 5,-3 7,-10 11,-35 40,-42 26,-49 82,-13 9,1 18,31 12,4 15,-4 45,-35 58,-52 28,-35 11,-18 0,-15 -4,-23 3,-29 11,-21 15,-7 17,-19 10,-56 30,-1 44,-25 62,-14 28,-22 46,-42 105,-83 18,-22 -2,-10 -23,24 -25,19 -70,51 -82,75 -61,14 -43,24 -33,2 -5,6 -9,55 -12,15 -17,7 -7,10 -12,25 -1,9 6,50 -9,15 -27,33 -57,51 -45,35 -13,1 -14,-28 -8,-5 -13,-2 -49,6 -39,10 -11,17 -14,31 -42,42 -15,45 -47,10 -19,-2 -30,-12 -7,1 -37,18 -27,-2 -11,3 -33,19 -18,33 -1,6
#green
727,908 -16,31 36,20 14,1 12,-3 7,-15 -2,-17 -3,-4 -4,-3 -44,-10
751,1125 -38,-30 -47,-31 -49,-25 -1,8 -27,-8 0,-10 -57,-29 -27,-17 -11,23 -11,36 19,99 73,54 47,66 63,4 33,5 33,-145
492,674 43,23 15,1 11,-2 8,-5 9,-13 9,-18 13,-40 -52,-27 -9,0 -8,4 -7,12 6,4 -21,40 -6,-4 -11,25
236,-68 -17,16 19,4 14,-11 63,28 34,13 37,7 29,-33 34,3 8,-9 12,-7 16,-1 18,4 25,16 38,17 19,13 27,25 27,-50 25,-1 14,7 15,-19 6,-3 8,5 3,-5 -12,-11 -15,-8 -8,-14 -130,21 -3,-11 0,-17 62,-12 10,18 19,-2 7,-9 27,-6 20,-22 5,-10 2,-12 0,-75 8,-1 -1,-23 -25,13 -1,12 -40,-1 -6,5 0,25 3,4 -17,8 -25,2 -13,10 1,21 -24,26 -36,0 0,9 17,7 0,6 -12,32 -17,1 -11,-5 -10,-24 -13,30 -4,-1 -5,-2 3,-7 -7,-3 17,-39 5,1 12,-28 -7,-7 2,-3 -8,-5 -5,1 -5,8 -7,-1 4,-22 -1,-7 -6,-7 -17,-5 -2,7 -16,-3 1,-6 -8,-1 -3,8 6,1 -8,45 -26,-5 10,-53 10,2 2,-16 43,7 0,6 10,5 22,17 10,9 -1,6 6,-1 4,-2 6,-11 12,-36 -4,-11 -40,-37 -11,-8 9,-10 43,40 5,1 8,-5 5,-24 -54,-44 2,-3 -36,9 -59,49 -16,3 -22,-4 -91,78 -27,-16 -25,8 -9,17 -11,44 48,55
323,1307 34,-139 24,-66 30,-28 -73,-69 5,24 -50,121 -50,-21 -28,67 -11,39 -22,120 -3,20 0,42 26,-17 24,-32 42,19 33,-34 19,-46
432,998 -9,-1 -7,21 -35,-17 -36,-27 8,17 10,15 59,56 6,-18 4,-46
626,429 -125,-83 -59,100 4,4 -19,32 107,64 3,-1 5,-3 65,-94 19,-19
474,1035 -35,-5 -3,42 2,5 55,53 -19,-95
920,706 -50,-20 9,-41 -34,-26 -34,17 4,19 27,-7 6,50 11,4 -21,57 -2,6 1,5 -8,12 15,15 37,-27 25,-23 10,-18 4,-23
-153,592 7,-1 68,-34 12,-4 42,-5 4,-7 0,-4 -9,-8 -41,-30 -90,-59 -2,70 3,79 6,3
881,365 -37,-7 -7,13 -23,28 26,24 41,-58
893,-223 -30,-16 -7,-2 -7,4 -5,9 -3,13 3,4 4,2 -12,132 -15,-4 -8,3 -1,-5 8,-8 14,-134 6,-15 16,-18 15,7 38,-95 22,9 -5,10 -3,-1 -6,7 -24,61 -6,16 1,2 2,3 75,41 5,-1 4,-23 -1,-21 13,-61 -24,-36 -33,-21 -9,-2 -19,-2 -19,6 -161,92 -13,20 4,108 -7,19 -24,33 -1,5 6,9 8,3 15,13 4,6 22,17 15,-46 97,53 14,-136 32,-60
537,1227 16,-4 10,-17 -65,-52 -13,23 -13,39 65,11
99,594 29,1 25,-18 31,2 -4,-9 -104,-10 23,34
#garden
1090,1368 0,-45 -73,-19 -80,-36 -34,-25 -17,-17 -12,15 -8,28 0,26 93,64 131,9
877,233 10,39 66,-25 -15,-16 -22,-8 -39,10
-226,339 9,17 21,29 14,9 14,3 43,28 -2,3 50,36 66,52 34,38 2,-1 -25,-46 -2,-8 -16,-19 -25,-24 -80,-64 -70,-40 -33,-13
197,776 -2,-7 -10,-9 20,-19 -36,-42 -93,-119 -7,2 45,124 15,35 13,13 24,13 31,9
856,1010 12,-3 46,-27 8,-7 3,-8 -4,-9 -9,-6 3,-5 -76,-47 -10,-4 -10,2 -29,18 -1,43 16,24 -6,9 57,20
175,463 19,-7 11,1 26,10 14,11 23,-20 -33,-20 16,-29 -4,-3 12,-25 -47,-31 -30,-13 -26,-8 -12,0 -13,6 37,101 7,27
1121,1027 9,-30 -16,-3 -25,-22 -3,-30 -75,57 13,21 40,7 57,0
78,1033 118,38 -12,33 46,17 78,-197 12,-21 0,-31 -17,-3 3,-33 -97,-18 -12,27 -10,-4 -2,7 -5,-2 -11,26 -6,-2 -12,35 -24,102 -11,-3 28,-102 -1,-8 26,-86 -33,-13 -21,-15 -21,-25 -18,-41 -28,-78 -25,-51 -14,-13 -40,-2 -25,2 11,97 -8,2 -12,-95 -23,8 -51,27 4,42 35,-3 1,17 13,-2 0,6 28,-2 3,28 -75,10 -2,15 139,32 -18,82 43,10 35,15 -7,156 3,11 15,5
474,1035 24,-58 -11,-12 -31,-14 -7,17 -10,62 35,5
968,700 -32,-17 -15,54 -8,14 -39,39 -35,28 -13,14 -12,16 16,20 21,20 89,57 10,-2 16,-20 -16,-10 43,-67 -14,-4 -36,-67 -2,-15 3,-28 24,-32
503,970 40,25 53,28 67,19 14,-1 4,-6 -108,-46 -31,-21 -56,-28 -3,6 20,24
751,1125 -33,145 117,12 11,-3 9,-8 1,-26 -10,-19 -78,-12 1,-12 9,1 9,-57 -17,-8 -19,-13
-19,834 10,-43 2,-3 3,-23 -5,-6 -56,-11 -3,3 -17,67 66,16
584,947 -17,24 135,62 79,33 2,-2 13,-30 -6,-7 -28,-8 1,-5 -120,-37 -22,-10 -37,-20
893,-223 -32,60 -14,136 -97,-53 -15,46 68,49 3,-5 11,5 -4,11 -99,153 0,6 39,54 29,17 13,-17 25,-46 21,-29 57,-67 -32,-35 14,-38 42,17 14,-38 17,-108 3,-51 6,-27 -69,-40
711,939 16,-31 -60,-20 -1,9 4,11 41,31
431,44 15,6 273,169 3,-1 1,-4 -71,-86 -15,-25 -7,-4 2,-3 -33,-30 9,-10 6,6 19,-16 -23,-27 2,-2 -27,-25 -19,-13 -22,40 -42,-16 -21,-3 -21,4 -14,10 -13,22 -2,8
880,517 -8,21 1,8 12,8 -28,40 -10,6 -4,15 6,8 30,22 -9,41 50,20 0,-7 -3,-5 7,-13 2,-9 -19,-53 -12,-2 16,-17 13,18 -4,11 13,28 25,-44 49,-65 -8,-13 -67,-37 -4,1 -31,-22 -17,40
1416,-160 -10,29 -18,39 -67,-27 -68,154 -2,21 -24,67 -5,23 -18,-15 -16,-9 -22,-8 -47,-13 -15,-8 -10,-11 -4,-10 0,-9 35,-95 12,-43 -19,2 -70,-13 -17,-12 0,-4 74,-181 -44,-21 -39,-23 -9,18 -10,41 -27,127 -22,143 2,2 -27,80 -6,13 -3,-2 -10,18 10,2 8,-4 21,-18 38,-11 8,-5 34,-104 7,-31 8,1 -5,28 8,3 2,6 -5,6 -8,-3 -26,83 3,16 8,3 -2,8 -19,-2 -31,3 -16,6 -24,20 34,8 -1,6 -3,-1 -2,5 -17,-8 -10,0 -17,-5 -10,-1 -8,6 -20,20 10,15 10,5 -14,25 2,5 -2,8 10,9 22,-5 51,13 1,16 4,1 78,-21 135,-8 11,-12 19,-28 36,-17 53,-132 7,2 -9,28 -39,95 2,1 34,-16 9,-11 22,-44 17,-46 8,2 -21,55 19,10 57,-122 5,-4 48,-11 -47,-35 7,-8 5,-1 10,9 2,10 2,2 24,15 4,0 14,-15 15,-24 15,-39 -95,-37
22,1214 -3,48 -14,111 -27,25 -16,69 -44,-18 -6,83 -6,-2 -6,48 4,2 -14,78 42,3 7,-37 14,-58 10,-19 43,-63 -4,-2 3,-5 4,2 42,-60 13,-10 58,-24 32,-17 10,-9 9,-23 13,-65 2,-27 3,-10 -32,-9 -137,-11
844,797 -15,-15 8,-12 -1,-5 2,-6 21,-57 -105,-38 -2,7 -58,-21 -9,15 -38,-16 1,-2 -4,-4 4,-11 -24,-8 -40,99 103,49 93,40 7,5 -1,2 26,16 7,-11 25,-27
498,103 -57,-33 -70,127 17,10 12,-2 9,-12 5,3 3,-6 45,34 -36,56 67,46 67,-109 -39,-17 -6,12 -66,-39 49,-70
477,669 40,-81 -21,-13 -2,4 -2,-3 -72,-43 14,-29 -19,-11 -4,0 -56,106 19,11 -1,1 104,58
518,-118 1,-8 -15,-7 -19,41 10,24 11,5 17,-1 12,-32 0,-6 -17,-7 0,-9
442,1288 8,-47 5,2 8,-39 19,-64 -41,-39 -18,39 -11,36 -19,43 -11,58 60,11
1340,472 -57,-18 -39,-1 60,-102 18,-44 -47,-44 -5,-27 -12,-23 -99,15 -6,8 -15,-5 -12,0 -77,4 -73,21 -10,1 12,51 33,15 -11,13 35,40 -1,3 44,24 -19,18 25,28 -15,24 45,-8 54,-92 11,0 -49,79 11,10 45,-7 3,11 -2,5 37,27 -8,14 75,47 49,-87
420,363 32,-50 -106,-69 -8,4 -77,105 98,68 31,-54 13,-12 17,8
558,776 17,-42 -97,-48 -32,69 -6,20 14,5 -1,4 70,26 10,0 2,-10 5,2 18,-26
352,580 26,-52 -17,-11 -23,-4 2,-9 24,-34 -5,-3 9,-13 -39,-27 -34,43 -19,-7 -19,14 -9,46 -4,0 -1,9 -13,-2 -3,24 48,5 69,35 8,-14
597,848 -32,-13 -8,18 1,6 54,29 3,-4 10,5 4,-7 5,5 6,-5 2,-5 -4,-6 -41,-23
620,450 -33,43 23,16 -5,11 36,21 44,-82 -14,-9 -3,6 -3,-2 -5,7 -5,10 -35,-21
949,1424 9,-56 -99,-68 -6,15 -4,16 2,6 52,52 46,35
959,1424 134,6 -3,-50 -28,2 0,-6 -94,-7 -5,6 -5,36 1,13
53,546 19,-8 14,-39 24,-49 -33,-13 -7,1 -17,-5 -28,43 -6,26 34,44
681,217 -35,57 -52,-16 40,-70 -33,-21 -86,141 -13,24 76,49 40,-61 5,3 -38,63 50,36 23,-14 44,-34 4,-14 -7,-5 7,-10 -25,-18 0,-8 -5,0 1,-34 43,11 1,-3 4,2 -4,11 14,10 14,-38 -5,-22 -63,-39
797,1082 -15,-3 -65,-27 -18,-4 -47,0 45,27 58,44 16,9 7,1 12,-12 42,2 1,-19 -36,-18
788,565 -29,-7 16,-31 -48,-29 5,-12 -34,-19 -43,76 20,12 -8,13 6,3 -15,26 11,7 10,-13 7,4 18,-33 7,2 2,-5 10,5 -7,11 12,6 -25,39 8,4 -8,20 7,3 9,-23 45,14 19,-46 5,-27
860,1028 -8,1 -5,27 31,16 -5,11 0,18 42,5 0,4 27,9 71,35 16,3 11,-2 -15,-29 -8,-11 -17,-16 -68,-38 -72,-33
121,159 -45,61 -6,20 0,30 37,26 26,10 46,12 13,-27 8,-32 -11,-72 -68,-28
184,579 -31,-2 -25,18 -29,-1 77,97 19,21 1,4 16,21 5,-3 -5,-29 -28,-126
881,365 -41,58 54,42 28,-47 -6,-4 25,-35 4,-9 1,-10 -7,-7 6,-4 4,-17 -8,-21 -17,8 -43,46
678,75 -8,21 9,41 26,38 92,-148 -62,-49 -57,97
693,788 -20,60 -7,-1 2,-9 -20,-5 -9,27 32,18 19,7 73,18 4,4 19,-2 27,-18 3,-9 -30,-36 -38,-26 -23,49 -26,-11 23,-51 -29,-15
463,698 8,-17 -115,-65 -2,3 -16,-11 1,-3 -42,-23 -24,-8 -28,-4 -50,1 0,13 36,165 8,13 9,9 10,4 54,-1 3,-30 5,-10 6,-35 20,5 1,67 45,2 1,-4 9,1 9,-2 16,7 36,-77
654,949 13,-22 -102,-54 -6,6 16,22 79,48
717,360 18,19 25,-24 22,-36 7,-36 -12,-8 -42,57 -18,28
707,-44 -8,-5 -6,3 -15,19 -14,-7 -25,1 -26,49 19,20 27,37 9,-2 30,-50 -3,-5 -29,-18 4,-6 31,20 25,-40 -19,-16
1041,1112 1,-7 -33,-74 -11,-14 -27,-16 -33,-1 -15,4 -30,14 -7,2 55,26 67,37 16,13 17,16
815,479 59,35 18,-41 -16,-10 1,-3 -49,-22 -32,-20 -5,6 -42,-36 -15,14 -8,14 89,63
#cemetery
1033,564 172,113 86,-118 -115,-71 -30,-21 -57,11 -56,86
#parking
403,892 5,-8 8,-3 52,4 -2,-18 -50,-5 -2,8 -20,12 9,10
23,80 -21,55 6,2 -9,22 -5,-2 -6,13 -37,-14 -17,46 -1,7 4,5 61,26 21,-5 8,-10 43,-126 -47,-19
1126,625 -93,-61 -13,-16 -15,22 16,0 9,5 -1,10 63,41 28,9 6,-10`;
function decodeRing(s, ox, oy) {
let px = 0, py = 0; const pts = [];
for (const tok of s.split(' ')) {
const [dx, dy] = tok.split(','); px += +dx; py += +dy; pts.push([ox + px, oy + py]);
}
return pts;
}
function loadSample() {
const lines = SAMPLE_B.trim().split('\n');
const [ox, oy] = lines[0].split(',').map(Number);
const buildings = lines.slice(1).map(l => {
const [cp, use, flats, floors, geom] = l.split(';');
return mkBuilding(cp, +use, flats === '' ? null : +flats, floors === '' ? null : +floors, null, null,
geom.split('|').map(r => decodeRing(r, ox, oy)));
});
const base = {}; let cur = null;
for (const l of SAMPLE_BASE.split('\n')) {
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, fails: [] };
}
/* ================= 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';
classifyAll(); fitView(); S.loaded = true; S.hidden.clear(); buildLegend(); draw();
}
function fitView() {
if (!S.buildings.length) return;
let x0 = 1e18, y0 = 1e18, x1 = -1e18, y1 = -1e18;
for (const b of S.buildings) { x0 = Math.min(x0, b.bb[0]); y0 = Math.min(y0, b.bb[1]); x1 = Math.max(x1, b.bb[2]); y1 = Math.max(y1, b.bb[3]); }
const w = Math.max(x1 - x0, 50), h = Math.max(y1 - y0, 50);
S.view = { cx: (x0 + x1) / 2, cy: (y0 + y1) / 2, s: Math.min(W / w, H / h) * 0.94 };
}
const pxPerMeter = v => v.s / S.K; // screen px per true metre
/* ================= drawing ================= */
function niceScale(v) {
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) };
}
function drawScene(ctx, W, H, v, r, opts) {
opts = opts || {};
ctx.save();
ctx.setTransform(r, 0, 0, r, 0, 0);
ctx.beginPath(); ctx.rect(0, 0, W, H); ctx.clip();
ctx.fillStyle = '#f5f2ea'; ctx.fillRect(0, 0, W, H);
const sx = x => (x - v.cx) * v.s + W / 2, sy = y => H / 2 - (y - v.cy) * v.s;
const ppm = pxPerMeter(v);
const path = (rings, close) => {
ctx.beginPath();
for (const ring of rings) {
for (let i = 0; i < ring.length; i++) { const p = ring[i]; if (i) ctx.lineTo(sx(p[0]), sy(p[1])); else ctx.moveTo(sx(p[0]), sy(p[1])); }
if (close) ctx.closePath();
}
};
ctx.lineJoin = 'round'; ctx.lineCap = 'round';
if (S.showBase) {
for (const st of BASE) {
const rings = S.base[st.k]; if (!rings || !rings.length) continue;
if (st.t === 'poly') {
path(rings, true); ctx.fillStyle = st.fill; ctx.fill('evenodd');
if (st.stroke) { ctx.strokeStyle = st.stroke; ctx.lineWidth = 1; ctx.stroke(); }
} else {
path(rings, false); ctx.strokeStyle = st.c; ctx.lineWidth = Math.max(st.min, st.m * ppm);
ctx.setLineDash(st.dash ? st.dash.map(d => d * Math.max(1, ppm / 2)) : []); ctx.stroke(); ctx.setLineDash([]);
}
}
}
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 = 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();
}
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 || 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 = 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);
}
}
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();
}
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();
ctx.fillStyle = '#000'; ctx.font = '11px system-ui,sans-serif'; ctx.textAlign = 'center'; ctx.textBaseline = 'bottom';
ctx.fillText(sc.m >= 1000 ? sc.m / 1000 + ' km' : sc.m + ' m', bx + sc.px / 2, by - 4);
ctx.beginPath(); ctx.moveTo(24, 44); ctx.lineTo(24, 16); ctx.moveTo(24, 16); ctx.lineTo(20, 24); ctx.moveTo(24, 16); ctx.lineTo(28, 24);
ctx.lineWidth = 1.5; ctx.stroke(); ctx.textBaseline = 'top'; ctx.fillText('N', 24, 46);
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(), 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 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, 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;
ctx.fillStyle = it.color; ctx.fillRect(x, y - 6, 18, 12);
ctx.strokeStyle = it.border || '#555'; ctx.lineWidth = 1; ctx.strokeRect(x + .5, y - 5.5, 17, 11);
ctx.fillStyle = '#111'; ctx.fillText(it.label, x + 26, y);
});
ctx.restore();
}
function draw() { if (W) drawScene(ctx0, W, H, S.view, DPR, { sel: true }); }
/* ================= sidebar legend ================= */
function buildLegend() {
const box = $('legend'); box.innerHTML = '';
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);
}
updateCounts();
}
function updateCounts() {
const cnt = counts();
document.querySelectorAll('#legend .leg').forEach(r => {
const n = cnt[r.dataset.key] || 0; r.querySelector('.n').textContent = n; r.style.display = n ? '' : 'none';
});
$('total').textContent = S.buildings.length ? t('nBuildings', S.buildings.length) : '';
}
/* ================= hit testing & interaction ================= */
function inRing(x, y, ring) {
let inside = false;
for (let i = 0, j = ring.length - 1; i < ring.length; j = i++) {
const a = ring[i], b = ring[j];
if ((a[1] > y) !== (b[1] > y) && x < (b[0] - a[0]) * (y - a[1]) / (b[1] - a[1]) + a[0]) inside = !inside;
}
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, 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;
if (hit) return b;
}
return null;
}
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), 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(); };
}
const ptrs = new Map(); let dragMoved = 0, lastPinch = 0;
cv.addEventListener('pointerdown', e => {
cv.setPointerCapture(e.pointerId); ptrs.set(e.pointerId, [e.offsetX, e.offsetY]); dragMoved = 0; cv.classList.add('drag');
if (ptrs.size === 2) { const [a, b] = [...ptrs.values()]; lastPinch = Math.hypot(a[0] - b[0], a[1] - b[1]); }
});
cv.addEventListener('pointermove', e => {
const prev = ptrs.get(e.pointerId);
if (prev) {
ptrs.set(e.pointerId, [e.offsetX, e.offsetY]);
if (ptrs.size === 1) {
const dx = e.offsetX - prev[0], dy = e.offsetY - prev[1]; dragMoved += Math.abs(dx) + Math.abs(dy);
S.view.cx -= dx / S.view.s; S.view.cy += dy / S.view.s; draw(); $('tip').style.display = 'none';
} else if (ptrs.size === 2) {
const [a, b] = [...ptrs.values()], d = Math.hypot(a[0] - b[0], a[1] - b[1]);
if (lastPinch) zoomAt((a[0] + b[0]) / 2, (a[1] + b[1]) / 2, d / lastPinch); lastPinch = d; dragMoved = 99;
}
return;
}
const b = pick(e.offsetX, e.offsetY), tip = $('tip');
if (b) { tip.textContent = desc(b); tip.style.left = (e.offsetX + 14) + 'px'; tip.style.top = (e.offsetY + 14) + 'px'; tip.style.display = 'block'; }
else tip.style.display = 'none';
});
const endPtr = e => {
const had = ptrs.delete(e.pointerId); cv.classList.remove('drag'); lastPinch = 0;
if (had && dragMoved < 5 && e.type === 'pointerup') { S.sel = pick(e.offsetX, e.offsetY); showInfo(S.sel); draw(); }
};
cv.addEventListener('pointerup', endPtr); cv.addEventListener('pointercancel', endPtr);
cv.addEventListener('pointerleave', () => { $('tip').style.display = 'none'; });
cv.addEventListener('wheel', e => { e.preventDefault(); zoomAt(e.offsetX, e.offsetY, Math.exp(-e.deltaY * 0.0015)); }, { passive: false });
function zoomAt(px, py, f) {
const v = S.view, ns = Math.min(Math.max(v.s * f, 0.02), 40);
const x = (px - W / 2) / v.s + v.cx, y = (H / 2 - py) / v.s + v.cy;
v.s = ns; v.cx = x - (px - W / 2) / ns; v.cy = y + (py - H / 2) / ns; draw();
}
$('zin').onclick = () => zoomAt(W / 2, H / 2, 1.5);
$('zout').onclick = () => zoomAt(W / 2, H / 2, 1 / 1.5);
$('zfit').onclick = () => { fitView(); draw(); };
function resize() {
const r = $('stage').getBoundingClientRect(); DPR = Math.min(window.devicePixelRatio || 1, 3);
const oldW = W; W = Math.max(1, Math.floor(r.width)); H = Math.max(1, Math.floor(r.height));
cv.width = W * DPR; cv.height = H * DPR;
if (S.loaded && !oldW) fitView();
draw();
}
new ResizeObserver(resize).observe($('stage'));
/* ================= 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; 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(() => 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) {
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 ================= */
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 = 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');
};
$('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 { 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) {
const rings = S.base[st.k]; if (!rings || !rings.length) continue;
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 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>';
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;
o += `<rect x="${x}" y="${y - 6}" width="18" height="12" fill="${it.color}" stroke="${it.border || '#555'}"/><text x="${x + 26}" y="${y + 4}">${it.label.replace(/&/g, '&amp;').replace(/</g, '&lt;')}</text>`;
});
o += '</g></svg>';
download(new Blob([o], { type: 'image/svg+xml' }), 'building-use-map.svg');
};
$('expCsv').onclick = () => {
if (!S.loaded) return;
const q = s => '"' + String(s).replace(/"/g, '""') + '"';
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(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 ================= */
applyLang();
resize();
{ // 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>
</html>