]> jfr.im git - z_archive/floorplanning.git/commitdiff
init main
authorJohn Runyon <redacted>
Mon, 25 May 2020 14:09:37 +0000 (09:09 -0500)
committerJohn Runyon <redacted>
Mon, 25 May 2020 14:09:37 +0000 (09:09 -0500)
.gitignore [new file with mode: 0644]
495.html [new file with mode: 0644]
495.php [new file with mode: 0644]
495.svg [new file with mode: 0644]
README.txt [new file with mode: 0644]
index.php [new file with mode: 0644]

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..4f4773f
--- /dev/null
@@ -0,0 +1 @@
+config.php
diff --git a/495.html b/495.html
new file mode 100644 (file)
index 0000000..c1b448f
--- /dev/null
+++ b/495.html
@@ -0,0 +1,2 @@
+<!DOCTYPE html>
+<img src="495.svg" width="700">
diff --git a/495.php b/495.php
new file mode 100644 (file)
index 0000000..f9ab4c8
--- /dev/null
+++ b/495.php
@@ -0,0 +1,4 @@
+<!DOCTYPE html>
+<?php
+readfile('495.svg');
+?>
diff --git a/495.svg b/495.svg
new file mode 100644 (file)
index 0000000..93c11bf
--- /dev/null
+++ b/495.svg
@@ -0,0 +1,215 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1525 405">
+       <defs>
+               <!-- down, right -->
+               <g id="door">
+                       <line x1="0" y1="0" x2="0" y2="20" />
+                       <line x1="0" y1="0" x2="20" y2="0" />
+                       <path d="M 20 0 A 20 20 0 0 1 0 20" stroke-dasharray="1" />
+               </g>
+               <!-- down, left -->
+               <g id="door2"><use href="#door" transform="rotate(90)" /></g>
+               <!-- left, up -->
+               <g id="door3"><use href="#door" transform="rotate(180)" /></g>
+               <!-- down, left -->
+               <g id="door4"><use href="#door" transform="rotate(270)" /></g>
+               <g id="dot">
+                       <circle r="5" fill="rgba(136,136,136,.5)" />
+                       <circle r="1" fill="black" />
+               </g>
+       </defs>
+       <g id="settings" fill="none" stroke="black">
+               <path id="southwest" d="
+                       M 25 10
+                       l 100 0
+                       l 0 37
+                       l -50 0
+                       m 0 -37
+                       l 0 70
+                       l -50 0
+                       m 50 0
+                       l 0 16
+                       m 0 23
+                       l 0 19
+                       l 32 0
+                       m -32 0
+                       l 0 16
+                       l -50 0
+               " />
+               <path id="south_and_southeast" d="
+                       M 25 10
+                       l 0 390
+                       l 50 0
+                       l 0 -140
+                       l -50 0
+               " />
+               <path id="guest_and_storage" d="
+                       M 75 400
+                       l 67 0
+                       l 0 -36
+                       l -67 0
+                       m 47 0
+                       l 0 -50
+                       m 37 0
+                       l 0 50
+                       l -37 0
+               " />
+               <path id="kitchen_wall_through_offices" d="
+                       M 108 314
+                       l 150 0
+               " />
+               <path id="main_offices" d="
+                       M 108 314
+                       l 0 -60
+                       l 84 0
+                       m -84 0
+                       l 0 -60
+                       l 84 0
+                       m -84 0
+                       l 0 -60
+                       l 84 0
+                       l 0 180
+                       m 33 0
+                       l 0 86
+               " />
+               <path id="labs" d="
+                       M 291 400
+                       l 0 -170
+                       l 50 0
+                       l 0 134
+                       m 0 -134
+                       l 50 0
+                       l 0 134
+                       m -80 -134
+                       l 0 30
+                       l -20 0
+                       m 0 -60
+                       l 970 0
+                       l 0 164
+                       l -970 0
+               " />
+               <path id="lab_separations" d="
+                       M 391 200
+                       l 0 30
+                       m 348 -30
+                       l 0 164
+                       m 174 -164
+                       l 0 164
+                       m 174 -164
+                       l 0 164
+               " />
+               <path id="southwest_offices" d="
+                       M 125 0
+                       l 145 0
+                       l 0 75
+                       l -72.5 0
+                       l 0 -75
+                       m 0 75
+                       l -72.5 0
+                       l 0 -75
+               " />
+               <path id="west_wall_from_offices" d="
+                       M 270 50
+                       L 1261 50
+                       L 1261 0
+                       L 1361 0
+                       L 1361 25
+                       L 1500 25
+               " />
+               <path id="raceway" d="
+                       M 325 364
+                       L 325 400
+                       L 1227 400
+                       L 1227 364
+               " />
+               <path id="east_wall_north" d="
+                       M 1261 364
+                       L 1261 400
+                       L 1500 400
+               " />
+               <path id="east_wall_web_kitchen" d="
+                       M 25 400
+                       L 291 400
+               " />
+               <path id="north_restrooms" d="
+                       M 1261 328
+                       L 1361 328
+                       L 1361 400
+                       M 1311 400
+                       L 1311 328
+               " />
+               <path id="north_showers" d="
+                       M 1361 350
+                       L 1400 350
+                       L 1400 400
+
+                       M 1361 375
+                       L 1400 375
+               " />
+               <path id="north_partition" d="
+                       M 1261 300
+                       L 1400 300
+               " />
+               <path id="garage_and_entry" d="
+                       M 1435 25
+                       L 1435 150
+                       L 1500 150
+                       M 1435 150
+                       L 1435 400
+               " />
+               <path id="north_wall" d="
+                       M 1500 25
+                       L 1500 400
+               " />
+               <g id="front_doors">
+                       <use href="#door2" x="25" y="180" />
+                       <use href="#door3" x="25" y="220" />
+               </g>
+               <g id="conference_room">
+                       <use href="#door2" x="75" y="265" />
+                       <use href="#door2" x="75" y="335" />
+               </g>
+               <use id="guest_bathroom" href="#door2" x="108" y="364" />
+               <use id="lobby" href="#door2" x="100" y="138" />
+               <use id="accounting" href="#door3" x="75" y="73" />
+               <use id="net" href="#door2" x="120" y="47" />
+               <g id="lab1">
+                       <use href="#door" x="535" y="200" />
+                       <use href="#door2" x="575" y="200" />
+               </g>
+               <use id="lab2" href="#door" x="816" y="200" />
+               <g id="lab3">
+                       <use href="#door" x="930" y="200" />
+                       <use href="#door2" x="970" y="200" />
+               </g>
+               <g id="lab4">
+                       <use href="#door4" x="1154" y="200" />
+                       <use href="#door3" x="1194" y="200" />
+               </g>
+               <g id="west_doors"><!-- from south (shipping) to north -->
+                       <use href="#door4" x="610" y="50" />
+                       <use href="#door4" x="930" y="50" />
+                       <use href="#door3" x="970" y="50" />
+                       <use href="#door4" x="1154" y="50" />
+               </g>
+               <use id="chuck" href="#door4" x="130" y="75" />
+               <use id="dan" href="#door4" x="202.5" y="75" />
+               <use id="dave" href="#door3" x="192" y="190" />
+               <use id="jeff" href="#door3" x="192" y="250" />
+               <use id="sue" href="#door3" x="192" y="310" />
+               <use id="web" href="#door2" x="220" y="314" />
+               <use id="front_bathroom_w" href="#door" x="315" y="230" />
+               <use id="front_bathroom_m" href="#door" x="345" y="230" />
+               <use id="north" href="#door" x="1500" y="30" />
+               <g id="north_to_sales">
+                       <use href="#door2" x="1435" y="100" />
+                       <use href="#door3" x="1435" y="140" />
+               </g>
+               <g id="north_to_garage">
+                       <use href="#door4" x="1440" y="150" />
+                       <use href="#door3" x="1480" y="150" />
+               </g>
+       </g>
+
+       <text x="500" y="9" style="font: 10px sans-serif">Not to scale.</text>
+</svg>
diff --git a/README.txt b/README.txt
new file mode 100644 (file)
index 0000000..a8706fa
--- /dev/null
@@ -0,0 +1 @@
+Floor-plan software
diff --git a/index.php b/index.php
new file mode 100644 (file)
index 0000000..cef3615
--- /dev/null
+++ b/index.php
@@ -0,0 +1,82 @@
+<!DOCTYPE html>
+<svg id="map" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1525 405" width="1525">
+<style>
+       .block {
+               fill: rgba(0,255,255,0.8);
+       }
+</style>
+<?php
+require 'config.php';
+$sth = $dbh->prepare('SELECT id, x, y, width, height, occupant FROM rects');
+$sth->execute();
+$sth->bind_result($id, $x, $y, $w, $h, $occupant);
+while ($sth->fetch()) {
+       echo '<rect x="' . $x . '" y="' . $y . '" width="' . $w . '" height="' . $h . '" class="block" />' . PHP_EOL;
+}
+$sth->close();
+
+$sth = $dbh->prepare('SELECT id, pointset, occupant FROM polys');
+$sth->execute();
+$sth->bind_result($id, $pointset, $occupant);
+while ($sth->fetch()) {
+       echo '<polygon points="' . $pointset . '" class="block" />' . PHP_EOL;
+}
+?>
+       <image href="https://private.simplynuc.com/john-test/plan/495.svg" width="1525" />
+</svg>
+<script>
+var max_variance = 5;
+
+var svgNS = "http://www.w3.org/2000/svg";
+
+var ele = document.getElementById('map');
+var startpos = null;
+var poslist = [];
+var in_progress = null;
+ele.addEventListener('mousedown', function (ev) {
+       in_progress = document.createElementNS(svgNS, 'circle');
+       in_progress.setAttributeNS(null,'r',5);
+       in_progress.setAttributeNS(null,'cx',ev.offsetX);
+       in_progress.setAttributeNS(null,'cy',ev.offsetY);
+       ele.appendChild(in_progress);
+       startpos = [ev.offsetX, ev.offsetY];
+});
+ele.addEventListener('mouseup', function (ev) {
+       if (startpos) {
+               if (!poslist.length && (Math.abs(startpos[0]-ev.offsetX) > max_variance || Math.abs(startpos[1]-ev.offsetY) > max_variance)) {
+                       // rectangle mode
+                       console.log(startpos, [ev.offsetX, ev.offsetY]);
+                       in_progress.parentNode.removeChild(in_progress);
+               } else {
+                       // polygon mode
+                       poslist.push(in_progress);
+               }
+               startpos = null;
+       }
+});
+ele.addEventListener('mousemove', function (ev) {
+       if (startpos && !poslist.length) {
+               if (Math.abs(startpos[0]-ev.offsetX) > max_variance || Math.abs(startpos[1]-ev.offsetY) > max_variance) {
+                       if (in_progress.tagName == 'circle') {
+                               in_progress.parentNode.removeChild(in_progress);
+                               in_progress = null;
+                       }
+                       if (!in_progress) {
+                               in_progress = document.createElementNS(svgNS, 'rect');
+                       }
+                       in_progress.setAttributeNS(null,'fill','rgba(0,0,255,0.5)');
+                       in_progress.setAttributeNS(null,'x',startpos[0]);
+                       in_progress.setAttributeNS(null,'y',startpos[1]);
+                       in_progress.setAttributeNS(null,'width',ev.offsetX-startpos[0]);
+                       in_progress.setAttributeNS(null,'height',ev.offsetY-startpos[1]);
+                       ele.appendChild(in_progress);
+                       // display in-progress rectangle
+               }
+       }
+});
+
+function clear_poslist() {
+       poslist.forEach(function (v) { v.parentNode.removeChild(v); });
+       poslist = [];
+}
+</script>