You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@baremaps.apache.org by bc...@apache.org on 2024/06/12 23:02:11 UTC
(incubator-baremaps) branch sonar updated (0c11054d -> 284baf0c)
This is an automated email from the ASF dual-hosted git repository.
bchapuis pushed a change to branch sonar
in repository https://gitbox.apache.org/repos/asf/incubator-baremaps.git
from 0c11054d Merge cases
new f6ad6ae2 Merge if statements
new 284baf0c Use record instead of class
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../maplibre/expression/ExpressionsTest.java | 14 ++--
.../function/RelationMultiPolygonBuilder.java | 10 +--
.../apache/baremaps/openstreetmap/model/Bound.java | 91 +---------------------
3 files changed, 12 insertions(+), 103 deletions(-)
(incubator-baremaps) 01/02: Merge if statements
Posted by bc...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
bchapuis pushed a commit to branch sonar
in repository https://gitbox.apache.org/repos/asf/incubator-baremaps.git
commit f6ad6ae275f01121c15f71c0f3aea37ec7c6fda7
Author: Bertil Chapuis <bc...@gmail.com>
AuthorDate: Thu Jun 13 00:58:36 2024 +0200
Merge if statements
---
.../baremaps/maplibre/expression/ExpressionsTest.java | 14 +++++++-------
.../function/RelationMultiPolygonBuilder.java | 10 ++++------
2 files changed, 11 insertions(+), 13 deletions(-)
diff --git a/baremaps-maplibre/src/test/java/org/apache/baremaps/maplibre/expression/ExpressionsTest.java b/baremaps-maplibre/src/test/java/org/apache/baremaps/maplibre/expression/ExpressionsTest.java
index 06d05288..54d56bcb 100644
--- a/baremaps-maplibre/src/test/java/org/apache/baremaps/maplibre/expression/ExpressionsTest.java
+++ b/baremaps-maplibre/src/test/java/org/apache/baremaps/maplibre/expression/ExpressionsTest.java
@@ -29,13 +29,13 @@ import org.junit.jupiter.api.Test;
class ExpressionsTest {
@Test
- void literal() {
+ void literal() {
assertEquals(1, new Literal(1).evaluate(null));
assertEquals("value", new Literal("value").evaluate(null));
}
@Test
- void at() {
+ void at() {
var literal = new Literal(List.of(0, 1, 2));
assertEquals(0, new At(0, literal).evaluate(null));
assertEquals(1, new At(1, literal).evaluate(null));
@@ -45,21 +45,21 @@ class ExpressionsTest {
}
@Test
- void get() {
+ void get() {
assertEquals("value",
new Get("key").evaluate(new Feature(0L, Map.of("key", "value"), null)));
assertEquals(null, new Get("key").evaluate(new Feature(0L, Map.of(), null)));
}
@Test
- void has() {
+ void has() {
assertEquals(true,
new Has("key").evaluate(new Feature(0L, Map.of("key", "value"), null)));
assertEquals(false, new Has("key").evaluate(new Feature(0L, Map.of(), null)));
}
@Test
- void inList() {
+ void inList() {
var literal = new Literal(List.of(0, 1, 2));
assertEquals(true, new In(0, literal).evaluate(null));
assertEquals(true, new In(1, literal).evaluate(null));
@@ -76,7 +76,7 @@ class ExpressionsTest {
}
@Test
- void indexOfList() {
+ void indexOfList() {
var literal = new Literal(List.of(0, 1, 2));
assertEquals(0, new IndexOf(0, literal).evaluate(null));
assertEquals(1, new IndexOf(1, literal).evaluate(null));
@@ -85,7 +85,7 @@ class ExpressionsTest {
}
@Test
- void indexOfString() {
+ void indexOfString() {
var literal = new Literal("foobar");
assertEquals(0, new IndexOf("foo", literal).evaluate(null));
assertEquals(3, new IndexOf("bar", literal).evaluate(null));
diff --git a/baremaps-openstreetmap/src/main/java/org/apache/baremaps/openstreetmap/function/RelationMultiPolygonBuilder.java b/baremaps-openstreetmap/src/main/java/org/apache/baremaps/openstreetmap/function/RelationMultiPolygonBuilder.java
index 73a674f5..cdda73cf 100644
--- a/baremaps-openstreetmap/src/main/java/org/apache/baremaps/openstreetmap/function/RelationMultiPolygonBuilder.java
+++ b/baremaps-openstreetmap/src/main/java/org/apache/baremaps/openstreetmap/function/RelationMultiPolygonBuilder.java
@@ -192,12 +192,10 @@ public class RelationMultiPolygonBuilder implements Consumer<Entity> {
// Merge the lines to build the polygons
for (Object geometry : lineMerger.getMergedLineStrings()) {
- if (geometry instanceof LineString lineString) {
- if (lineString.isClosed()) {
- var polygon =
- GeometryUtils.GEOMETRY_FACTORY_WGS84.createPolygon(lineString.getCoordinates());
- repairPolygon(polygon, polygons);
- }
+ if (geometry instanceof LineString lineString && lineString.isClosed()) {
+ var polygon =
+ GeometryUtils.GEOMETRY_FACTORY_WGS84.createPolygon(lineString.getCoordinates());
+ repairPolygon(polygon, polygons);
}
}
(incubator-baremaps) 02/02: Use record instead of class
Posted by bc...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
bchapuis pushed a commit to branch sonar
in repository https://gitbox.apache.org/repos/asf/incubator-baremaps.git
commit 284baf0cb7c18d6348d13ae06f72b1c789a56fe5
Author: Bertil Chapuis <bc...@gmail.com>
AuthorDate: Thu Jun 13 01:01:07 2024 +0200
Use record instead of class
---
.../apache/baremaps/openstreetmap/model/Bound.java | 91 +---------------------
1 file changed, 1 insertion(+), 90 deletions(-)
diff --git a/baremaps-openstreetmap/src/main/java/org/apache/baremaps/openstreetmap/model/Bound.java b/baremaps-openstreetmap/src/main/java/org/apache/baremaps/openstreetmap/model/Bound.java
index b30d5a4b..fc798f52 100644
--- a/baremaps-openstreetmap/src/main/java/org/apache/baremaps/openstreetmap/model/Bound.java
+++ b/baremaps-openstreetmap/src/main/java/org/apache/baremaps/openstreetmap/model/Bound.java
@@ -18,96 +18,7 @@
package org.apache.baremaps.openstreetmap.model;
-
-import java.util.Objects;
-import java.util.StringJoiner;
-
/** Represents the bounds of an OpenStreetMap dataset. */
-public final class Bound implements Entity {
-
- private final double maxLat;
-
- private final double maxLon;
-
- private final double minLat;
-
- private final double minLon;
-
- /**
- * Consturcts a {@code Bound} with the specified limits.
- *
- * @param maxLat the max latitude
- * @param maxLon the max longitude
- * @param minLat the min latitude
- * @param minLon the max longitude
- */
- public Bound(double maxLat, double maxLon, double minLat, double minLon) {
- this.maxLat = maxLat;
- this.maxLon = maxLon;
- this.minLat = minLat;
- this.minLon = minLon;
- }
-
- /**
- * Returns the max latitude.
- *
- * @return the max latitude
- */
- public double getMaxLat() {
- return maxLat;
- }
-
- /**
- * Returns the max longitude.
- *
- * @return the max longitude
- */
- public double getMaxLon() {
- return maxLon;
- }
-
- /**
- * Returns the min latitude.
- *
- * @return the min latitude
- */
- public double getMinLat() {
- return minLat;
- }
-
- /**
- * Returns the min longitude.
- *
- * @return the min longitude
- */
- public double getMinLon() {
- return minLon;
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (!(o instanceof Bound)) {
- return false;
- }
- Bound bound = (Bound) o;
- return Double.compare(bound.maxLat, maxLat) == 0 && Double.compare(bound.maxLon, maxLon) == 0
- && Double.compare(bound.minLat, minLat) == 0 && Double.compare(bound.minLon, minLon) == 0;
- }
-
- /** {@inheritDoc} */
- @Override
- public int hashCode() {
- return Objects.hash(maxLat, maxLon, minLat, minLon);
- }
+public record Bound(double maxLat, double maxLon, double minLat, double minLon) implements Entity {
- /** {@inheritDoc} */
- @Override
- public String toString() {
- return new StringJoiner(", ", Bound.class.getSimpleName() + "[", "]").add("maxLat=" + maxLat)
- .add("maxLon=" + maxLon).add("minLat=" + minLat).add("minLon=" + minLon).toString();
- }
}