Skip to content

Commit

Permalink
fix isEmpty
Browse files Browse the repository at this point in the history
  • Loading branch information
msbarry committed Sep 22, 2023
1 parent 080045b commit 119211c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public static TileWeights readFromFile(Path path) {
}

public boolean isEmpty() {
return byZoom.entrySet().stream().anyMatch(e -> e.getValue() > 0);
return byZoom.values().stream().noneMatch(e -> e > 0);
}

@JsonPropertyOrder({"z", "x", "y", "loads"})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.onthegomap.planetiler.util;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

import com.onthegomap.planetiler.geo.TileCoord;
import java.io.IOException;
Expand All @@ -20,12 +22,14 @@ void test() {
assertEquals(0, weights.getWeight(TileCoord.ofXYZ(0, 0, 1)));
assertEquals(0, weights.getWeight(TileCoord.ofXYZ(1, 0, 1)));
assertEquals(0, weights.getZoomWeight(1));
assertTrue(weights.isEmpty());

weights.put(TileCoord.ofXYZ(0, 0, 0), 1);
weights.put(TileCoord.ofXYZ(0, 0, 0), 2);
weights.put(TileCoord.ofXYZ(0, 0, 1), 3);
weights.put(TileCoord.ofXYZ(1, 0, 1), 4);

assertFalse(weights.isEmpty());
assertEquals(3, weights.getWeight(TileCoord.ofXYZ(0, 0, 0)));
assertEquals(3, weights.getZoomWeight(0));
assertEquals(3, weights.getWeight(TileCoord.ofXYZ(0, 0, 1)));
Expand Down

0 comments on commit 119211c

Please sign in to comment.