Files
martinfencl.eu/kovarova/js/plan.js
T
martin.fencl 16804546e9
continuous-integration/drone/push Build is passing
Add .DS_Store file to locenice directory
2026-11-06 20:46:55 +01:00

78 lines
6.2 KiB
JavaScript

// Coordinates in metres, x right and y down in the supplied floor plans.
// Printed room areas are authoritative labels; digitised polygons are approximate.
const rect=(x,y,w,d)=>[[x,y],[x+w,y],[x+w,y+d],[x,y+d]];
const room=(id,name,area,polygon,level,height,floor,label,spawn,look)=>({id,name,short:id+' '+name,area,polygon,level,height,floor,label,spawn:spawn||label,look:look||[label[0],label[1]-1]});
export const rooms=[
room('S.01','Schodiště',3.56,[[5.07,1.02],[6.73,1.02],[6.73,2.98],[6.07,2.98],[6.07,4.12],[5.07,4.12]],-1.9,1.9,'tile',[5.6,1.6],[5.6,1.6],[6.8,1.5]),
room('S.02','Sklep',10.66,rect(6.73,.30,3.90,2.74),-2.2,2.06,'brick',[8.7,1.65],[7.7,1.7],[9.6,1.7]),
room('1.01','Zádveří',5.48,[[6.73,.30],[10.63,.30],[10.63,1.99],[7.5,1.99],[7.5,.90],[6.73,.90]],0,3.1,'tile',[8.95,1.14],[8.9,1.15],[7.9,1.15]),
room('1.02','Schodiště',5.58,[[5.07,.9],[6.73,.9],[6.73,1.99],[6.15,1.99],[6.15,4.27],[5.07,4.27]],0,5.78,'wood',[5.6,2.8],[5.6,4.12],[5.6,1.7]),
room('1.03','Chodba',9.39,[[6.5,2.14],[9.63,2.14],[9.63,3.46],[8.28,3.46],[8.28,5.45],[5.07,5.45],[5.07,4.27],[6.5,4.27]],0,3.1,'tile',[7.15,4.3],[6.9,4.5],[7.1,2.7]),
room('1.04','WC',1.18,rect(9.73,2.14,.9,1.32),0,2.6,'tile',[10.18,2.8],[10.17,2.58],[10.17,3.2]),
room('1.05','Koupelna',2.97,rect(8.46,3.75,1.51,2),0,2.6,'tile',[9.2,4.65],[8.9,5.12],[9.5,4.1]),
room('1.06','Pokoj',20.01,[[4.72,5.9],[9.97,5.9],[9.97,11.89],[7.37,11.89],[7.37,7.43],[4.72,7.43]],0,3.1,'wood',[8.65,8.4],[8.45,7],[8.7,10.3]),
room('1.07','Pokoj',11.09,rect(4.72,7.53,2.55,4.36),0,3.06,'wood',[5.98,9.4],[5.4,9.1],[6.1,10.4]),
room('1.08','Obývací pokoj',21.85,rect(.47,6.11,3.95,5.48),0,2.82,'wood',[2.4,8.6],[2.7,8.5],[1.4,10]),
room('1.09','Kuchyň',21.16,[[.47,1.02],[4.77,1.02],[4.77,4.26],[4.42,4.26],[4.42,5.94],[.47,5.94]],-.04,2.86,'tile',[2.6,3.3],[2.6,3.3],[1.3,1.5]),
room('2.01','Schodiště',4.98,rect(5.07,.9,1.20,4.54),3.4,2.38,'wood',[5.67,4.75],[5.67,5.05],[5.67,2.4]),
room('2.02','Chodba',4.79,rect(4.72,5.92,1.72,2.6),3.55,2.57,'tile',[5.6,7.3],[5.6,6.6],[5.6,8]),
room('2.03','Obývací pokoj + kuchyň',26.42,[[6.56,5.92],[9.97,5.92],[9.97,11.89],[4.72,11.89],[4.72,8.64],[6.56,8.64]],3.55,2.57,'wood',[8.3,9.1],[7.4,9.1],[8.7,10.5]),
room('2.04','Pokoj',17.20,rect(1.32,5.44,3.1,5.55),3.25,2.46,'wood',[2.95,8.4],[3.6,7.1],[2.5,9.8]),
room('2.05','Koupelna',11.65,rect(1.32,1.77,3.4,3.44),3.3,2.41,'tile',[3.1,3.4],[3.8,4.1],[2.7,2.6]),
room('2.06','Balkón',27.88,[[6.5,-.31],[11.34,-.31],[11.34,5.45],[6.5,5.45]],3.45,0,'deck',[8.6,2.5],[8.6,4],[8.6,1])
];
export const outline=[[0,.55],[6.43,.55],[6.43,0],[10.93,0],[10.93,3.63],[10.44,3.63],[10.44,12.36],[4.19,12.36],[4.19,12.06],[0,12.06]];
export const floors=[{id:'basement',title:'1PP · Suterén',area:14.22,base:-2.2,rooms:rooms.filter(r=>r.id.startsWith('S.')),outline:[[4.87,.72],[6.43,.72],[6.43,0],[10.93,0],[10.93,3.34],[6.27,3.34],[6.27,4.42],[4.87,4.42]]},
{id:'ground',title:'1NP · Přízemí',area:98.71,base:0,rooms:rooms.filter(r=>r.id.startsWith('1.')),outline},
{id:'upper',title:'2NP · Patro',area:65.04,base:3.55,rooms:rooms.filter(r=>r.id.startsWith('2.')),outline:[[.95,1.4],[4.72,1.4],[4.72,.55],[6.5,.55],[6.5,-.31],[11.34,-.31],[11.34,5.45],[10.44,5.45],[10.44,12.36],[4.19,12.36],[4.19,11.3],[.95,11.3]]}];
// Wall: axis (x = vertical in plan), fixed coordinate, start, end, thickness, bottom, top, openings.
// Opening: start, end, sill relative to datum, head, kind (door/window).
export const walls={
basement:[
['y',.15,6.43,10.93,.3,-2.2,-.14,[[7.95,8.45,-.64,-.14,'window']]],
['x',10.78,0,3.19,.3,-2.2,-.14,[]],['y',3.19,6.58,10.93,.3,-2.2,-.14,[]],
['x',6.58,.3,3.19,.3,-2.2,-.14,[[1.02,1.72,-2.2,-.25,'door']]],
['y',.87,4.87,6.58,.3,-1.9,0,[[5.34,5.84,-.53,-.11,'window']]],
['x',4.97,.9,4.27,.2,-1.9,0,[]],['x',6.17,1.9,4.27,.2,-1.9,0,[]],
['y',4.27,4.97,6.27,.2,-1.9,0,[]]],
ground:[
['y',.785,0,5.3,.47,0,3.43,[[2,3.2,.65,2.43,'window']]],
['y',.70,5.3,6.43,.3,0,3.43,[[5.34,5.84,1.7,2.12,'window']]],
['y',.15,6.43,10.93,.3,0,3.14,[[7.75,9.44,.92,2.74,'window']]],
['x',.235,.55,12.06,.47,0,3.43,[[3.6,4.8,.65,2.43,'window'],[7.5,8.7,.65,2.43,'window']]],
['y',11.825,0,4.19,.47,0,3.43,[[1.5,2.7,.65,2.43,'window']]],
['x',4.425,11.59,12.36,.47,0,3.55,[]],
['y',12.125,4.19,10.44,.47,0,3.55,[[5.8,7,.65,2.43,'window'],[7.63,8.83,.65,2.43,'window']]],
['x',10.205,3.63,12.36,.47,0,3.55,[[4.26,4.99,1.5,2.5,'window'],[8.46,9.66,.65,2.43,'window']]],
['y',3.545,9.63,10.93,.17,0,3.14,[]],
['x',10.78,0,3.63,.3,0,3.14,[[.52,1.79,0,2.25,'door'],[2.47,2.85,1.5,2.5,'window']]],
['x',6.58,0,.9,.3,0,3.43,[]],
['x',7.35,.3,1.99,.3,0,3.1,[]],
['y',2.065,6.15,10.63,.15,0,3.1,[[7.5,8.75,0,2.10,'door']]],
['x',9.68,2.14,3.46,.1,0,2.6,[[2.25,2.95,0,1.77,'door']]],
['y',3.6,8.28,9.97,.3,0,2.6,[]],
['x',8.37,3.6,5.75,.18,0,2.6,[[4.55,5.30,0,1.77,'door']]],
['y',5.825,8.28,10.44,.15,0,3.1,[]],
['y',5.675,4.42,8.28,.45,0,3.1,[[6.52,7.89,0,2.20,'door']]],
['x',4.92,1.02,5.45,.3,0,3.1,[[4.32,5.25,0,2.10,'door']]],
['x',6.325,1.99,4.27,.35,0,3.1,[]],
['y',4.34,5.07,6.15,.15,0,2.6,[[5.12,5.87,0,1.8,'door']]],
['y',6.025,.47,4.42,.17,0,2.82,[[1.87,3.03,0,2.20,'door']]],
['x',4.57,5.9,11.89,.30,0,3.06,[[8.26,9.63,0,2.07,'door']]],
['y',7.48,4.72,7.37,.1,0,3.06,[]],['x',7.32,7.48,11.89,.1,0,3.06,[]]],
upper:[
['x',1.22,1.67,11.09,.2,3.25,4.25,[]],['y',1.67,1.22,4.72,.2,3.3,4.15,[]],['y',11.09,1.22,4.42,.2,3.25,4.15,[]],
['y',5.325,1.32,4.72,.23,3.3,5.71,[[3.58,4.38,3.3,5.07,'door']]],
['x',4.57,5.44,12.36,.3,3.25,6.8,[[6.78,7.53,3.25,5.02,'door']]],
['x',4.895,.9,5.92,.35,3.3,5.78,[[5.30,5.92,3.3,5.40,'door']]],
['x',6.325,.55,5.92,.35,3.4,5.9,[[1.22,2.25,3.45,5.3,'door'],[4.12,5.12,3.45,5.5,'door']]],
['y',.725,4.72,6.5,.35,3.4,5.9,[]],
['y',5.57,5.07,6.27,.26,3.4,5.78,[[5.12,6.02,3.4,5.17,'door']]],
['y',5.685,6.5,10.44,.47,3.55,6.8,[[7.78,9.24,3.55,5.75,'door']]],
['x',10.205,5.45,12.36,.47,3.55,6.8,[[8.46,9.66,4.18,5.96,'window']]],
['y',12.125,4.19,10.44,.47,3.55,6.8,[[5.8,7,4.18,5.96,'window'],[7.64,8.84,4.18,5.96,'window']]],
['x',6.5,5.92,8.58,.12,3.55,6.12,[[6.77,7.57,3.55,5.57,'door']]],
['y',8.58,4.72,7.85,.12,3.55,6.12,[]]]
};
export function pointInPolygon(p,x,y){let ok=false;for(let i=0,j=p.length-1;i<p.length;j=i++){const a=p[i],b=p[j];if((a[1]>y)!==(b[1]>y)&&x<(b[0]-a[0])*(y-a[1])/(b[1]-a[1])+a[0])ok=!ok;}return ok;}