Add new functionality for dzialki, dzialki2, lines, mpzp, osuwiska, position, section, and test modules with API integration and canvas drawing capabilities
This commit is contained in:
46
js/functions/lines.js
Normal file
46
js/functions/lines.js
Normal file
@@ -0,0 +1,46 @@
|
||||
let LINES = [];
|
||||
|
||||
function getLines() {
|
||||
console.log("getLines");
|
||||
port.postMessage({ response: "getLines" });
|
||||
}
|
||||
function drawLines(data) {
|
||||
navigator.clipboard.writeText(data);
|
||||
for (let element of data) {
|
||||
if (element.SEARCH == "KIER. OBW. 4 SŁUP NR 11") {
|
||||
const canvas = document.getElementsByClassName("ol-unselectable")[0];
|
||||
const ctx = canvas.getContext("2d");
|
||||
console.log(element);
|
||||
if (element.SHAPE.length < 84) {
|
||||
let x1 = parseFloat(element.SHAPE.slice(14, 30));
|
||||
let y1 = parseFloat(element.SHAPE.slice(31, 47));
|
||||
let x2 = parseFloat(element.SHAPE.slice(49, 65));
|
||||
let y2 = parseFloat(element.SHAPE.slice(66, 82));
|
||||
// let coords = [
|
||||
// [x1, y1],
|
||||
// [x2, y2],
|
||||
// element.DESCRIPTION,
|
||||
// element.OBJ_SIZE,
|
||||
// element,
|
||||
// ];
|
||||
let translated = translate([
|
||||
[x1, y1],
|
||||
[x2, y2],
|
||||
]);
|
||||
console.log(translated);
|
||||
ctx.beginPath();
|
||||
ctx.shadowOffsetX = 2;
|
||||
ctx.shadowOffsetY = 2;
|
||||
ctx.shadowBlur = 4;
|
||||
ctx.shadowColor = "rgba(250, 0, 0, 1)";
|
||||
ctx.strokeStyle = "rgba(255, 0, 0, 1)";
|
||||
ctx.moveTo(translated[0][0], translated[0][1]);
|
||||
|
||||
ctx.lineTo(translated[1][0], translated[1][1]);
|
||||
ctx.stroke();
|
||||
ctx.shadowColor = "rgba(250, 0, 0, 0)";
|
||||
ctx.strokeStyle = "rgba(0, 0, 0, 1)";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user