Add geoButton, getGmina, messages, and translate handler files with initial implementations

This commit is contained in:
2025-06-05 11:33:17 +02:00
parent e3bcf9dd7c
commit 1c97e0610f
5 changed files with 332 additions and 0 deletions

33
js/handlers/translate.js Normal file
View File

@@ -0,0 +1,33 @@
function translate(data) {
let newData = [];
const canvas = document.getElementsByClassName("ol-unselectable")[0];
const bound = canvas.getBoundingClientRect();
// szerokość 90%
// wysokość 109%
// SZEROKOŚĆ 137
// WYSOKOŚĆ 132
const XMIN = MapData.X_MIN;
const YMIN = MapData.Y_MIN;
const XMAX = MapData.X_MAX;
const YMAX = MapData.Y_MAX;
const xratio = ((XMAX - XMIN) * 1) / bound.width;
const yratio = ((YMAX - YMIN) * 1) / bound.height;
console.log(bound.width/bound.height)
console.log((XMAX-XMIN)/(YMAX-YMIN))
// return ((val - src[0]) / (src[1]-src[0])) * (dst[1]-dst[0]) + dst[0]
for (let point of data) {
let tempx = ((point[0] - XMIN) / (XMAX-XMIN)) * (bound.width)
let tempy = ((YMAX - point[1]) / (YMAX-YMIN)) * (bound.height) ;
// let tempx = (point[0] - XMIN) / xratio;
// let tempy = (YMAX - point[1]) / yratio;
newData.push([tempx, tempy]);
}
return newData;
}