diff --git a/src/org/openstreetmap/josm/data/imagery/Shape.java b/src/org/openstreetmap/josm/data/imagery/Shape.java
index 9e7fa16076..c55d371d61 100644
--- a/src/org/openstreetmap/josm/data/imagery/Shape.java
+++ b/src/org/openstreetmap/josm/data/imagery/Shape.java
@@ -1,6 +1,8 @@
 // License: GPL. For details, see LICENSE file.
 package org.openstreetmap.josm.data.imagery;
 
+import static org.openstreetmap.josm.tools.I18n.tr;
+
 import java.awt.Polygon;
 import java.text.MessageFormat;
 import java.util.AbstractList;
@@ -13,8 +15,6 @@ import org.openstreetmap.gui.jmapviewer.Coordinate;
 import org.openstreetmap.josm.data.coor.LatLon;
 import org.openstreetmap.josm.tools.CheckParameterUtil;
 
-import static org.openstreetmap.josm.tools.I18n.tr;
-
 /**
  * Data class to store the outline for background imagery coverage.
  *
@@ -85,6 +85,12 @@ public class Shape {
         };
     }
 
+    /**
+     * Check if the coordinates are inside this shape.
+     * @see Polygon#contains(int, int)
+     * @param latlon The latlon to look for
+     * @return {@code true} if the LatLon is inside the shape.
+     */
     public boolean contains(LatLon latlon) {
         return coords.contains(
                 latlon.getX() * LatLon.MAX_SERVER_INV_PRECISION,
@@ -114,8 +120,8 @@ public class Shape {
         }
 
         coords.addPoint(
-                (int) (lon * LatLon.MAX_SERVER_INV_PRECISION),
-                (int) (lat * LatLon.MAX_SERVER_INV_PRECISION));
+                (int) Math.round((lon * LatLon.MAX_SERVER_INV_PRECISION)),
+                (int) Math.round((lat * LatLon.MAX_SERVER_INV_PRECISION)));
     }
 
     @Override
diff --git a/test/unit/org/openstreetmap/josm/data/imagery/ShapeTest.java b/test/unit/org/openstreetmap/josm/data/imagery/ShapeTest.java
index 4887ff3085..6ac3e4901b 100644
--- a/test/unit/org/openstreetmap/josm/data/imagery/ShapeTest.java
+++ b/test/unit/org/openstreetmap/josm/data/imagery/ShapeTest.java
@@ -1,11 +1,14 @@
 // License: GPL. For details, see LICENSE file.
 package org.openstreetmap.josm.data.imagery;
 
+import static org.junit.jupiter.api.Assertions.assertAll;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 
 import java.util.Arrays;
 
 import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ValueSource;
 
 /**
  * Unit tests for class {@link Shape}.
@@ -28,4 +31,25 @@ class ShapeTest {
         assertEquals("47.1//11.1//47.2//11.2//47.3//11.3", shape.encodeAsString("//"));
         assertEquals("47.1,11.1,47.2,11.2,47.3,11.3;47.1,11.1,47.2,11.2,47.3,11.3", Shape.encodeAsString(Arrays.asList(shape, shape)));
     }
+
+    /**
+     * Check double edge cases
+     * @param coordinate the coordinate to check
+     */
+    @ParameterizedTest
+    @ValueSource(doubles = {
+            // The double representation of 0.2575799 * 1e7 is 2575798.9999999995. Directly casting to int will round down.
+            0.2575799,
+            // Check that 2575798.0000000005 is rounded down
+            0.2575798
+    })
+    void testDoubleEdgeCases(final double coordinate) {
+        final Shape shape = new Shape();
+        shape.addPoint(Double.toString(1), Double.toString(coordinate));
+        shape.addPoint(Double.toString(coordinate), Double.toString(1));
+        shape.addPoint(Double.toString(coordinate), Double.toString(coordinate));
+        assertAll("Coordinates are not properly rounded on entry",
+                () -> assertEquals(coordinate, shape.getPoints().get(0).getLon()),
+                () -> assertEquals(coordinate, shape.getPoints().get(1).getLat()));
+    }
 }
