diff --git a/libraries/classes/Gis/GisVisualization.php b/libraries/classes/Gis/GisVisualization.php
index b9abe2708b..af53773baa 100644
--- a/libraries/classes/Gis/GisVisualization.php
+++ b/libraries/classes/Gis/GisVisualization.php
@@ -606,17 +606,13 @@ class GisVisualization
$scale = $ratio != 0 ? 1 / $ratio : 1;
- if ($x_ratio < $y_ratio) {
- // center horizontally
- $x = ($min_max['maxX'] + $min_max['minX'] - $plot_width / $scale) / 2;
- // fit vertically
- $y = $min_max['minY'] - ($border / $scale);
- } else {
- // fit horizontally
- $x = $min_max['minX'] - ($border / $scale);
- // center vertically
- $y = ($min_max['maxY'] + $min_max['minY'] - $plot_height / $scale) / 2;
- }
+ // Center plot
+ $x = $ratio == 0 || $x_ratio < $y_ratio
+ ? ($min_max['maxX'] + $min_max['minX'] - $this->settings['width'] / $scale) / 2
+ : $min_max['minX'] - ($border / $scale);
+ $y = $ratio == 0 || $x_ratio >= $y_ratio
+ ? ($min_max['maxY'] + $min_max['minY'] - $this->settings['height'] / $scale) / 2
+ : $min_max['minY'] - ($border / $scale);
return [
'scale' => $scale,
diff --git a/psalm-baseline.xml b/psalm-baseline.xml
index ae47a9bebc..40ddebd805 100644
--- a/psalm-baseline.xml
+++ b/psalm-baseline.xml
@@ -7546,7 +7546,7 @@
$row[$this->settings['spatialColumn']]
$row[$this->settings['spatialColumn']]
-
+
$label
$pdf
$plot_height
@@ -7557,10 +7557,8 @@
$row
$scale
$x
- $x
$x_ratio
$y
- $y
$y_ratio
@@ -7569,11 +7567,9 @@
$border / $scale
$border / $scale
- $min_max['maxX'] + $min_max['minX'] - $plot_width / $scale
- $min_max['maxY'] + $min_max['minY'] - $plot_height / $scale
+ $min_max['maxX'] + $min_max['minX'] - $this->settings['width'] / $scale
+ $min_max['maxY'] + $min_max['minY'] - $this->settings['height'] / $scale
$plot_height
- $plot_height
- $plot_width
$plot_width
$ratio
$scale
@@ -7581,6 +7577,8 @@
$this->prepareDataSet($this->data, $scale_data, 'ol', '')
$this->prepareDataSet($this->data, $scale_data, 'svg', '')
$this->settings['height']
+ $this->settings['height']
+ $this->settings['width']
$this->settings['width']
diff --git a/test/classes/Gis/GisVisualizationTest.php b/test/classes/Gis/GisVisualizationTest.php
index 6e234458c5..617d8397b2 100644
--- a/test/classes/Gis/GisVisualizationTest.php
+++ b/test/classes/Gis/GisVisualizationTest.php
@@ -42,8 +42,8 @@ class GisVisualizationTest extends AbstractTestCase
$this->assertSame(
[
'scale' => 1,
- 'x' => -15.0,
- 'y' => -210.0,
+ 'x' => -300.0,
+ 'y' => -225.0,
'minX' => 0.0,
'maxX' => 0.0,
'minY' => 0.0,
@@ -69,7 +69,7 @@ class GisVisualizationTest extends AbstractTestCase
$this->assertSame(
[
'scale' => 2.1,
- 'x' => -38.21428571428572,
+ 'x' => -45.35714285714286,
'y' => 42.85714285714286,
'minX' => 17.0,
'maxX' => 178.0,