diff --git a/index.html b/index.html
index ecc43d23..c55262b1 100644
--- a/index.html
+++ b/index.html
@@ -138,7 +138,7 @@
}
-
+
@@ -8117,7 +8117,7 @@
-
+
@@ -8127,7 +8127,7 @@
-
+
@@ -8169,8 +8169,8 @@
-
-
+
+
diff --git a/modules/resample.js b/modules/resample.js
index 81ffcc1f..21349b9e 100644
--- a/modules/resample.js
+++ b/modules/resample.js
@@ -254,9 +254,11 @@ window.Resample = (function () {
});
if (points.length < 2) return null;
- const firstCell = points[0][2];
+ const bbox = [0, 0, graphWidth, graphHeight];
+ const clipped = lineclip(points, bbox)[0].map(([x, y]) => [rn(x, 2), rn(y, 2), findCell(x, y)]);
+ const firstCell = clipped[0][2];
const feature = pack.cells.f[firstCell];
- return {...route, feature, points};
+ return {...route, feature, points: clipped};
})
.filter(Boolean);
diff --git a/modules/ui/options.js b/modules/ui/options.js
index bd8d8b0f..537a6a4e 100644
--- a/modules/ui/options.js
+++ b/modules/ui/options.js
@@ -210,16 +210,16 @@ function fitMapToScreen() {
svgHeight = Math.min(+mapHeightInput.value, window.innerHeight);
svg.attr("width", svgWidth).attr("height", svgHeight);
- const zoomExtent = [
- [0, 0],
- [graphWidth, graphHeight]
- ];
-
const zoomMin = rn(Math.max(svgWidth / graphWidth, svgHeight / graphHeight), 3);
zoomExtentMin.value = zoomMin;
const zoomMax = +zoomExtentMax.value;
- zoom.translateExtent(zoomExtent).scaleExtent([zoomMin, zoomMax]).scaleTo(svg, zoomMin);
+ zoom
+ .translateExtent([
+ [0, 0],
+ [graphWidth, graphHeight]
+ ])
+ .scaleExtent([zoomMin, zoomMax]);
fitScaleBar(scaleBar, svgWidth, svgHeight);
if (window.fitLegendBox) fitLegendBox();
diff --git a/modules/ui/submap-tool.js b/modules/ui/submap-tool.js
index 6586b1e7..1c992b7a 100644
--- a/modules/ui/submap-tool.js
+++ b/modules/ui/submap-tool.js
@@ -49,6 +49,8 @@ function openSubmapTool() {
const projection = (x, y) => [(x - x0) * scale, (y - y0) * scale];
const inverse = (x, y) => [x / scale + x0, y / scale + y0];
+ applyGraphSize();
+ fitMapToScreen();
resetZoom(0);
undraw();
Resample.process({projection, inverse, scale});
diff --git a/modules/ui/transform-tool.js b/modules/ui/transform-tool.js
index 81ac984f..86d5c504 100644
--- a/modules/ui/transform-tool.js
+++ b/modules/ui/transform-tool.js
@@ -132,9 +132,12 @@ async function openTransformTool() {
const [projection, inverse] = getProjection();
+ applyGraphSize();
+ fitMapToScreen();
resetZoom(0);
undraw();
Resample.process({projection, inverse, scale: 1});
+
drawLayers();
INFO && console.groupEnd("transformMap");