kopia lustrzana https://github.com/onthegomap/planetiler
cleanup
rodzic
27f993cdd8
commit
e86d0c9fcf
|
@ -110,7 +110,7 @@ public class Wikidata {
|
||||||
}
|
}
|
||||||
JsonNode label = row.get("label");
|
JsonNode label = row.get("label");
|
||||||
map.put(
|
map.put(
|
||||||
"name:" + label.get("xml:lang").asText(),
|
label.get("xml:lang").asText(),
|
||||||
label.get("value").asText()
|
label.get("value").asText()
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package com.onthegomap.flatmap.collections;
|
package com.onthegomap.flatmap.collections;
|
||||||
|
|
||||||
import com.google.common.collect.Range;
|
import com.google.common.collect.Range;
|
||||||
import com.google.common.collect.RangeSet;
|
|
||||||
import com.google.common.collect.TreeRangeSet;
|
import com.google.common.collect.TreeRangeSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.PrimitiveIterator;
|
import java.util.PrimitiveIterator;
|
||||||
|
@ -44,15 +43,6 @@ public class IntRange implements Iterable<Integer> {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int nextInRange(int lo, int hi) {
|
|
||||||
RangeSet<Integer> subset = rangeSet.subRangeSet(Range.closed(lo, hi));
|
|
||||||
if (subset.isEmpty()) {
|
|
||||||
return hi;
|
|
||||||
} else {
|
|
||||||
return subset.span().lowerEndpoint();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class Iter implements PrimitiveIterator.OfInt {
|
private static class Iter implements PrimitiveIterator.OfInt {
|
||||||
|
|
||||||
private final Iterator<Range<Integer>> rangeIter;
|
private final Iterator<Range<Integer>> rangeIter;
|
||||||
|
|
|
@ -112,8 +112,8 @@ public class WikidataTest {
|
||||||
}),
|
}),
|
||||||
dynamicTest("can load serialized data", () -> {
|
dynamicTest("can load serialized data", () -> {
|
||||||
var translations = Wikidata.load(new BufferedReader(new StringReader(writer.toString())));
|
var translations = Wikidata.load(new BufferedReader(new StringReader(writer.toString())));
|
||||||
assertEquals(Map.of("name:en", "en name", "name:es", "es name"), translations.get(1));
|
assertEquals(Map.of("en", "en name", "es", "es name"), translations.get(1));
|
||||||
assertEquals(Map.of("name:es", "es name2"), translations.get(2));
|
assertEquals(Map.of("es", "es name2"), translations.get(2));
|
||||||
}),
|
}),
|
||||||
dynamicTest("do not re-request on subsequent loads", () -> {
|
dynamicTest("do not re-request on subsequent loads", () -> {
|
||||||
StringWriter writer2 = new StringWriter();
|
StringWriter writer2 = new StringWriter();
|
||||||
|
|
|
@ -137,24 +137,4 @@ public class IntRangeTest {
|
||||||
range.intersect(range2);
|
range.intersect(range2);
|
||||||
assertEquals(List.of(3, 5), getInts(range));
|
assertEquals(List.of(3, 5), getInts(range));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testNextEmpty() {
|
|
||||||
IntRange range = new IntRange();
|
|
||||||
assertEquals(1, range.nextInRange(0, 1));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testNextInRange() {
|
|
||||||
IntRange range = new IntRange();
|
|
||||||
range.add(0, 2);
|
|
||||||
assertEquals(0, range.nextInRange(0, 1));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testNextBelowInRange() {
|
|
||||||
IntRange range = new IntRange();
|
|
||||||
range.add(2, 4);
|
|
||||||
assertEquals(2, range.nextInRange(1, 3));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue