diff --git a/pom.xml b/pom.xml
index 3eaae282..ad4e4087 100644
--- a/pom.xml
+++ b/pom.xml
@@ -130,12 +130,6 @@
3.9.0
test
-
- junit
- junit
- RELEASE
- test
-
diff --git a/src/main/java/com/onthegomap/flatmap/FeatureRenderer.java b/src/main/java/com/onthegomap/flatmap/FeatureRenderer.java
index eed64bb1..53f9ee07 100644
--- a/src/main/java/com/onthegomap/flatmap/FeatureRenderer.java
+++ b/src/main/java/com/onthegomap/flatmap/FeatureRenderer.java
@@ -1,6 +1,6 @@
package com.onthegomap.flatmap;
-import com.onthegomap.flatmap.collections.MergeSort;
+import com.onthegomap.flatmap.collections.FeatureSort;
import java.util.function.Consumer;
import org.locationtech.jts.geom.Geometry;
import org.locationtech.jts.geom.GeometryCollection;
@@ -22,11 +22,11 @@ public class FeatureRenderer {
this.config = config;
}
- public void renderFeature(RenderableFeature feature, Consumer consumer) {
+ public void renderFeature(RenderableFeature feature, Consumer consumer) {
renderGeometry(feature.getGeometry(), feature, consumer);
}
- public void renderGeometry(Geometry geom, RenderableFeature feature, Consumer consumer) {
+ public void renderGeometry(Geometry geom, RenderableFeature feature, Consumer consumer) {
// TODO what about converting between area and line?
if (geom instanceof Point point) {
addPointFeature(feature, point, consumer);
@@ -44,15 +44,15 @@ public class FeatureRenderer {
}
}
- private void addPointFeature(RenderableFeature feature, Point point, Consumer consumer) {
+ private void addPointFeature(RenderableFeature feature, Point point, Consumer consumer) {
// TODO render features into tile
}
- private void addPointFeature(RenderableFeature feature, MultiPoint points, Consumer consumer) {
+ private void addPointFeature(RenderableFeature feature, MultiPoint points, Consumer consumer) {
// TODO render features into tile
}
- private void addLinearFeature(RenderableFeature feature, Geometry geom, Consumer consumer) {
+ private void addLinearFeature(RenderableFeature feature, Geometry geom, Consumer consumer) {
// TODO render lines / areas into tile
}
}
diff --git a/src/main/java/com/onthegomap/flatmap/LayerFeature.java b/src/main/java/com/onthegomap/flatmap/LayerFeature.java
deleted file mode 100644
index a99c8f34..00000000
--- a/src/main/java/com/onthegomap/flatmap/LayerFeature.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package com.onthegomap.flatmap;
-
-import com.onthegomap.flatmap.VectorTileEncoder.VectorTileFeature;
-import com.onthegomap.flatmap.collections.MergeSortFeatureMap.FeatureMapKey;
-import com.onthegomap.flatmap.collections.MergeSortFeatureMap.FeatureMapValue;
-import java.util.Map;
-
-public record LayerFeature(
- boolean hasGroup,
- long group,
- int zorder,
- Map attrs,
- byte geomType,
- int[] commands,
- long id
-) implements VectorTileFeature {
-
- public static LayerFeature of(FeatureMapKey key, FeatureMapValue value) {
- return new LayerFeature(
- key.hasGroup(),
- value.group(),
- key.zOrder(),
- value.attrs(),
- value.geomType(),
- value.commands(),
- value.featureId()
- );
- }
-
-}
diff --git a/src/main/java/com/onthegomap/flatmap/MbtilesWriter.java b/src/main/java/com/onthegomap/flatmap/MbtilesWriter.java
index adfd5aef..d42d383e 100644
--- a/src/main/java/com/onthegomap/flatmap/MbtilesWriter.java
+++ b/src/main/java/com/onthegomap/flatmap/MbtilesWriter.java
@@ -1,7 +1,6 @@
package com.onthegomap.flatmap;
-import com.onthegomap.flatmap.collections.MergeSortFeatureMap;
-import com.onthegomap.flatmap.collections.MergeSortFeatureMap.TileFeatures;
+import com.onthegomap.flatmap.collections.FeatureGroup;
import com.onthegomap.flatmap.geo.TileCoord;
import com.onthegomap.flatmap.monitoring.ProgressLoggers;
import com.onthegomap.flatmap.monitoring.Stats;
@@ -33,7 +32,7 @@ public class MbtilesWriter {
}
- public static void writeOutput(long featureCount, MergeSortFeatureMap features, File output, FlatMapConfig config) {
+ public static void writeOutput(long featureCount, FeatureGroup features, File output, FlatMapConfig config) {
Stats stats = config.stats();
output.delete();
MbtilesWriter writer = new MbtilesWriter(config.stats());
@@ -56,8 +55,8 @@ public class MbtilesWriter {
topology.awaitAndLog(loggers, config.logInterval());
}
- public void tileEncoder(Supplier prev, Consumer next) throws Exception {
- MergeSortFeatureMap.TileFeatures tileFeatures, last = null;
+ public void tileEncoder(Supplier prev, Consumer next) throws Exception {
+ FeatureGroup.TileFeatures tileFeatures, last = null;
byte[] lastBytes = null, lastEncoded = null;
while ((tileFeatures = prev.get()) != null) {
featuresProcessed.addAndGet(tileFeatures.getNumFeatures());
diff --git a/src/main/java/com/onthegomap/flatmap/OpenMapTilesMain.java b/src/main/java/com/onthegomap/flatmap/OpenMapTilesMain.java
index 81b39445..6f1b4cf8 100644
--- a/src/main/java/com/onthegomap/flatmap/OpenMapTilesMain.java
+++ b/src/main/java/com/onthegomap/flatmap/OpenMapTilesMain.java
@@ -1,8 +1,8 @@
package com.onthegomap.flatmap;
+import com.onthegomap.flatmap.collections.FeatureGroup;
+import com.onthegomap.flatmap.collections.FeatureSort;
import com.onthegomap.flatmap.collections.LongLongMap;
-import com.onthegomap.flatmap.collections.MergeSort;
-import com.onthegomap.flatmap.collections.MergeSortFeatureMap;
import com.onthegomap.flatmap.profiles.OpenMapTilesProfile;
import com.onthegomap.flatmap.reader.NaturalEarthReader;
import com.onthegomap.flatmap.reader.OpenStreetMapReader;
@@ -66,8 +66,8 @@ public class OpenMapTilesMain {
FileUtils.forceMkdir(tmpDir.toFile());
File nodeDb = tmpDir.resolve("node.db").toFile();
LongLongMap nodeLocations = new LongLongMap.MapdbSortedTable(nodeDb);
- MergeSort featureDb = MergeSort.newExternalMergeSort(tmpDir.resolve("feature.db"), threads, stats);
- MergeSortFeatureMap featureMap = new MergeSortFeatureMap(featureDb, profile);
+ FeatureSort featureDb = FeatureSort.newExternalMergeSort(tmpDir.resolve("feature.db"), threads, stats);
+ FeatureGroup featureMap = new FeatureGroup(featureDb, profile);
FlatMapConfig config = new FlatMapConfig(profile, envelope, threads, stats, logInterval);
FeatureRenderer renderer = new FeatureRenderer(config);
diff --git a/src/main/java/com/onthegomap/flatmap/OsmInputFile.java b/src/main/java/com/onthegomap/flatmap/OsmInputFile.java
index efe1679e..ffc60a8c 100644
--- a/src/main/java/com/onthegomap/flatmap/OsmInputFile.java
+++ b/src/main/java/com/onthegomap/flatmap/OsmInputFile.java
@@ -5,7 +5,7 @@ import com.graphhopper.reader.ReaderElement;
import com.graphhopper.reader.osm.pbf.PbfDecoder;
import com.graphhopper.reader.osm.pbf.PbfStreamSplitter;
import com.graphhopper.reader.osm.pbf.Sink;
-import com.onthegomap.flatmap.worker.Topology.SourceStep;
+import com.onthegomap.flatmap.worker.Topology;
import java.io.BufferedInputStream;
import java.io.DataInputStream;
import java.io.File;
@@ -80,7 +80,7 @@ public class OsmInputFile {
}
}
- public SourceStep read(int threads) {
+ public Topology.SourceStep read(int threads) {
return next -> readTo(next, threads);
}
diff --git a/src/main/java/com/onthegomap/flatmap/Profile.java b/src/main/java/com/onthegomap/flatmap/Profile.java
index b4034395..120d5eea 100644
--- a/src/main/java/com/onthegomap/flatmap/Profile.java
+++ b/src/main/java/com/onthegomap/flatmap/Profile.java
@@ -1,24 +1,24 @@
package com.onthegomap.flatmap;
import com.graphhopper.reader.ReaderRelation;
-import com.onthegomap.flatmap.VectorTileEncoder.VectorTileFeature;
-import com.onthegomap.flatmap.reader.OpenStreetMapReader.RelationInfo;
+import com.onthegomap.flatmap.reader.OpenStreetMapReader;
import java.util.List;
public interface Profile {
- List preprocessOsmRelation(ReaderRelation relation);
+ List preprocessOsmRelation(ReaderRelation relation);
void processFeature(SourceFeature sourceFeature, RenderableFeatures features);
void release();
- List postProcessLayerFeatures(String layer, int zoom, List items);
+ List postProcessLayerFeatures(String layer, int zoom,
+ List items);
class NullProfile implements Profile {
@Override
- public List preprocessOsmRelation(ReaderRelation relation) {
+ public List preprocessOsmRelation(ReaderRelation relation) {
return null;
}
@@ -33,8 +33,9 @@ public interface Profile {
}
@Override
- public List postProcessLayerFeatures(String layer, int zoom,
- List items) {
+ public List postProcessLayerFeatures(String layer,
+ int zoom,
+ List items) {
return items;
}
}
diff --git a/src/main/java/com/onthegomap/flatmap/RenderedFeature.java b/src/main/java/com/onthegomap/flatmap/RenderedFeature.java
new file mode 100644
index 00000000..2e8f0e45
--- /dev/null
+++ b/src/main/java/com/onthegomap/flatmap/RenderedFeature.java
@@ -0,0 +1,20 @@
+package com.onthegomap.flatmap;
+
+import com.onthegomap.flatmap.geo.TileCoord;
+import java.util.Optional;
+
+public record RenderedFeature(
+ TileCoord tile,
+ VectorTileEncoder.Feature vectorTileFeature,
+ int zOrder,
+ Optional group
+) {
+
+ public RenderedFeature {
+ assert vectorTileFeature != null;
+ }
+
+ public static record Group(long group, int limit) {
+
+ }
+}
diff --git a/src/main/java/com/onthegomap/flatmap/Translations.java b/src/main/java/com/onthegomap/flatmap/Translations.java
index f09618fe..a87ae271 100644
--- a/src/main/java/com/onthegomap/flatmap/Translations.java
+++ b/src/main/java/com/onthegomap/flatmap/Translations.java
@@ -1,7 +1,6 @@
package com.onthegomap.flatmap;
import com.graphhopper.reader.ReaderElement;
-import com.onthegomap.flatmap.Wikidata.WikidataTranslations;
import java.util.List;
import java.util.Map;
@@ -16,7 +15,7 @@ public class Translations {
return null;
}
- public void addTranslationProvider(WikidataTranslations load) {
+ public void addTranslationProvider(Wikidata.WikidataTranslations load) {
// TODO
}
diff --git a/src/main/java/com/onthegomap/flatmap/VectorTileEncoder.java b/src/main/java/com/onthegomap/flatmap/VectorTileEncoder.java
index 7ae48496..f22add6f 100644
--- a/src/main/java/com/onthegomap/flatmap/VectorTileEncoder.java
+++ b/src/main/java/com/onthegomap/flatmap/VectorTileEncoder.java
@@ -24,6 +24,7 @@ import com.google.common.primitives.Ints;
import com.google.protobuf.InvalidProtocolBufferException;
import com.onthegomap.flatmap.geo.GeoUtils;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
@@ -66,13 +67,13 @@ public class VectorTileEncoder {
private static final double SCALE = ((double) EXTENT) / SIZE;
private final Map layers = new LinkedHashMap<>();
- public static int[] getCommands(Geometry input) {
+ private static int[] getCommands(Geometry input) {
var encoder = new CommandEncoder();
encoder.accept(input);
return encoder.result.toArray();
}
- public static VectorTile.Tile.GeomType toGeomType(Geometry geometry) {
+ private static VectorTile.Tile.GeomType toGeomType(Geometry geometry) {
if (geometry instanceof Point || geometry instanceof MultiPoint) {
return VectorTile.Tile.GeomType.POINT;
} else if (geometry instanceof LineString || geometry instanceof MultiLineString) {
@@ -97,7 +98,7 @@ public class VectorTileEncoder {
return ((n >> 1) ^ (-(n & 1)));
}
- public static Geometry decodeCommands(byte geomTypeByte, int[] commands) {
+ private static Geometry decodeCommands(byte geomTypeByte, int[] commands) {
VectorTile.Tile.GeomType geomType = Objects.requireNonNull(VectorTile.Tile.GeomType.forNumber(geomTypeByte));
GeometryFactory gf = GeoUtils.gf;
int x = 0;
@@ -226,13 +227,13 @@ public class VectorTileEncoder {
return geometry;
}
- public static List decode(byte[] encoded) {
+ public static List decode(byte[] encoded) {
try {
VectorTile.Tile tile = VectorTile.Tile.parseFrom(encoded);
- List features = new ArrayList<>();
+ List features = new ArrayList<>();
for (VectorTile.Tile.Layer layer : tile.getLayersList()) {
String layerName = layer.getName();
- int extent = layer.getExtent();
+ assert layer.getExtent() == 4096;
List keys = layer.getKeysList();
List