diff --git a/index.html b/index.html
index b89e682a..ab9a073a 100644
--- a/index.html
+++ b/index.html
@@ -4456,13 +4456,20 @@
type="range"
min="1"
max="13"
- value="8"
- data-cells="50000"
+ value="4"
+ data-cells="10000"
oninput="document.getElementById('submapPointsOutput').value=cellsDensityConstants[+this.value]/1000 + 'K'; event.stopPropagation()"
/>
-
+
+ |
+
+
+ | Shift |
+
+ X:
+ Y:
|
@@ -4483,10 +4490,13 @@
- | Shift |
+ Mirror |
- X:
- Y:
+
+
+
+
+
|
diff --git a/main.js b/main.js
index 7f6b451d..93b14fea 100644
--- a/main.js
+++ b/main.js
@@ -1413,6 +1413,7 @@ function reMarkFeatures() {
cells.harbor[i] = water.length;
};
+ if (!cells.i.length) return; // no cells -> there is nothing to do
for (let i = 1, queue = [0]; queue[0] !== -1; i++) {
const start = queue[0]; // first cell
cells.f[start] = i; // assign feature number
diff --git a/modules/ui/submap.js b/modules/ui/submap.js
index 1b5382cd..15906e52 100644
--- a/modules/ui/submap.js
+++ b/modules/ui/submap.js
@@ -25,6 +25,12 @@ window.UISubmap = (function () {
function openRemapOptions() {
resetZoom(0);
+ document.getElementById("submapRotationAngle").value = 0;
+ document.getElementById("submapRotationAngleOutput").value = "0°";
+ document.getElementById("submapShiftX").value = 0;
+ document.getElementById("submapShiftY").value = 0;
+ document.getElementById("submapMirrorH").checked = false;
+ document.getElementById("submapMirrorV").checked = false;
$("#remapOptionsDialog").dialog({
title: "Resampler options",
resizable: false,
@@ -50,26 +56,32 @@ window.UISubmap = (function () {
const angle = Number(document.getElementById("submapRotationAngle").value) / 180 * Math.PI;
const shiftX = Number(document.getElementById("submapShiftX").value);
const shiftY = Number(document.getElementById("submapShiftY").value);
+ const mirrorH = document.getElementById("submapMirrorH").checked;
+ const mirrorV = document.getElementById("submapMirrorV").checked;
+ if (!cellsDensityConstants[cellNumId]) {
+ console.error("Unknown cell number!");
+ return;
+ }
+
const [cx, cy] = [graphWidth / 2, graphHeight / 2];
const rot = alfa => (x, y) => [
(x - cx) * Math.cos(alfa) - (y - cy) * Math.sin(alfa) + cx,
(y - cy) * Math.cos(alfa) + (x - cx) * Math.sin(alfa) + cy
];
const shift = (dx, dy) => (x, y) => [x + dx, y + dy];
+ const flipH = (x, y) => [-x + 2 * cx, y];
+ const flipV = (x, y) => [x, -y + 2 * cy];
const app = (f, g) => (x, y) => f(...g(x, y));
- if (!cellsDensityConstants[cellNumId]) {
- console.error("Unknown cell number!");
- return;
- }
+ const id = (x, y) => [x, y];
+ let projection = id, inverse = id;
- let projection, inverse;
- if (angle || shiftX || shiftY) {
- projection = app(shift(shiftX, shiftY), rot(angle));
- inverse = app(rot(-angle), shift(-shiftX, -shiftY));
- } else {
- projection = (x, y) => [x, y];
- inverse = (x, y) => [x, y];
+ if (angle) [projection, inverse] = [rot(angle), rot(-angle)];
+ if (shiftX || shiftY) {
+ projection = app(shift(shiftX, shiftY), projection);
+ inverse = app(inverse, shift(-shiftX, -shiftY));
}
+ if (mirrorH) [projection, inverse] = [app(flipH, projection), app(inverse, flipH)];
+ if (mirrorV) [projection, inverse] = [app(flipV, projection), app(inverse, flipV)];
changeCellsDensity(cellNumId);
WARN && console.warn("Resampling current map");