diff --git a/jpx/src/main/java/io/jenetics/jpx/Bounds.java b/jpx/src/main/java/io/jenetics/jpx/Bounds.java index 807488a5..1a3a487d 100644 --- a/jpx/src/main/java/io/jenetics/jpx/Bounds.java +++ b/jpx/src/main/java/io/jenetics/jpx/Bounds.java @@ -163,8 +163,8 @@ public String toString() { final double[] a = new double[4]; a[0] = Double.MAX_VALUE; a[1] = Double.MAX_VALUE; - a[2] = Double.MIN_VALUE; - a[3] = Double.MIN_VALUE; + a[2] = -Double.MAX_VALUE; + a[3] = -Double.MAX_VALUE; return a; }, (a, b) -> { diff --git a/jpx/src/test/java/io/jenetics/jpx/BoundsTest.java b/jpx/src/test/java/io/jenetics/jpx/BoundsTest.java index 6e5ec481..4506a700 100644 --- a/jpx/src/test/java/io/jenetics/jpx/BoundsTest.java +++ b/jpx/src/test/java/io/jenetics/jpx/BoundsTest.java @@ -85,6 +85,28 @@ public void toBounds() { ); } + // https://github.com/jenetics/jpx/issues/110 + @Test + public void toBoundsNegativeValues() { + final Stream points = Stream.of( + WayPoint.of(-50, -100), + WayPoint.of(-51, -101), + WayPoint.of(-52, -102), + WayPoint.of(-53, -103), + WayPoint.of(-54, -104), + WayPoint.of(-55, -105) + ); + + final Bounds bounds = points.collect(Bounds.toBounds()); + Assert.assertEquals( + bounds, + Bounds.of( + Latitude.ofDegrees(-55), Longitude.ofDegrees(-105), + Latitude.ofDegrees(-50), Longitude.ofDegrees(-100) + ) + ); + } + @Test public void toBoundsForOnePoints() { final Stream points = Stream.of(