diff --git a/planetiler-core/src/main/java/com/onthegomap/planetiler/ForwardingProfile.java b/planetiler-core/src/main/java/com/onthegomap/planetiler/ForwardingProfile.java index 1a7aa64a..2ec843d4 100644 --- a/planetiler-core/src/main/java/com/onthegomap/planetiler/ForwardingProfile.java +++ b/planetiler-core/src/main/java/com/onthegomap/planetiler/ForwardingProfile.java @@ -28,7 +28,7 @@ import java.util.function.Consumer; *
  • {@link FeatureProcessor} to handle features from a particular source (added through * {@link #registerSourceHandler(String, FeatureProcessor)})
  • *
  • {@link FinishHandler} to be notified whenever we finish processing each source
  • - *
  • {@link LayerPostProcesser} to post-process features in a layer before rendering the output tile
  • + *
  • {@link LayerPostProcessor} to post-process features in a layer before rendering the output tile
  • *
  • {@link TilePostProcessor} to post-process features in a tile before rendering the output tile
  • * * See {@code OpenMapTilesProfile} for a full implementation using this framework. @@ -44,8 +44,8 @@ public abstract class ForwardingProfile implements Profile { private final List osmRelationPreprocessors = new ArrayList<>(); /** Handlers that get a callback when each source is finished reading. */ private final List finishHandlers = new ArrayList<>(); - /** Map from layer name to its handler if it implements {@link LayerPostProcesser}. */ - private final Map> layerPostProcessors = new HashMap<>(); + /** Map from layer name to its handler if it implements {@link LayerPostProcessor}. */ + private final Map> layerPostProcessors = new HashMap<>(); /** List of handlers that implement {@link TilePostProcessor}. */ private final List tilePostProcessors = new ArrayList<>(); /** List of handlers that implements {@link FeatureProcessor} along with a filter expression. */ @@ -147,7 +147,7 @@ public abstract class ForwardingProfile implements Profile { /** * Call {@code handler} for different events based on which interfaces {@code handler} implements: - * {@link OsmRelationPreprocessor}, {@link FinishHandler}, {@link TilePostProcessor} or {@link LayerPostProcesser}. + * {@link OsmRelationPreprocessor}, {@link FinishHandler}, {@link TilePostProcessor} or {@link LayerPostProcessor}. */ public void registerHandler(Handler handler) { if (!caresAboutLayer(handler)) { @@ -166,7 +166,7 @@ public abstract class ForwardingProfile implements Profile { if (handler instanceof FinishHandler finishHandler) { finishHandlers.add(finishHandler); } - if (handler instanceof LayerPostProcesser postProcessor) { + if (handler instanceof LayerPostProcessor postProcessor) { layerPostProcessors.computeIfAbsent(postProcessor.name(), name -> new ArrayList<>()) .add(postProcessor); } @@ -247,7 +247,7 @@ public abstract class ForwardingProfile implements Profile { public List postProcessLayerFeatures(String layer, int zoom, List items) throws GeometryException { // delegate feature post-processing to each layer, if it implements FeaturePostProcessor - List postProcessers = layerPostProcessors.get(layer); + List postProcessers = layerPostProcessors.get(layer); List result = makeMutable(items); if (postProcessers != null) { for (var handler : postProcessers) { @@ -350,7 +350,7 @@ public abstract class ForwardingProfile implements Profile { } /** Handlers should implement this interface to post-process vector tile features before emitting an output layer. */ - public interface LayerPostProcesser extends HandlerForLayer { + public interface LayerPostProcessor extends HandlerForLayer { /** * Apply any post-processing to features in this output layer of a tile before writing it to the output archive. @@ -361,9 +361,13 @@ public abstract class ForwardingProfile implements Profile { List postProcess(int zoom, List items) throws GeometryException; } - /** @deprecated use {@link LayerPostProcesser} or {@link TilePostProcessor} instead */ + /** @deprecated use {@link LayerPostProcessor} instead */ @Deprecated(forRemoval = true) - public interface FeaturePostProcessor extends LayerPostProcesser {} + public interface LayerPostProcesser extends LayerPostProcessor {} + + /** @deprecated use {@link LayerPostProcessor} or {@link TilePostProcessor} instead */ + @Deprecated(forRemoval = true) + public interface FeaturePostProcessor extends LayerPostProcessor {} /** * Handlers should implement this interface to post-process all features in a vector tile before writing to an diff --git a/planetiler-core/src/test/java/com/onthegomap/planetiler/ForwardingProfileTests.java b/planetiler-core/src/test/java/com/onthegomap/planetiler/ForwardingProfileTests.java index dc96b7f2..2d42ef00 100644 --- a/planetiler-core/src/test/java/com/onthegomap/planetiler/ForwardingProfileTests.java +++ b/planetiler-core/src/test/java/com/onthegomap/planetiler/ForwardingProfileTests.java @@ -157,7 +157,7 @@ class ForwardingProfileTests { } @Test - void testLayerPostProcesser() throws GeometryException { + void testLayerPostProcessor() throws GeometryException { VectorTile.Feature feature = new VectorTile.Feature( "layer", 1, @@ -167,7 +167,7 @@ class ForwardingProfileTests { assertEquals(List.of(feature), profile.postProcessLayerFeatures("layer", 0, List.of(feature))); // ignore null response - profile.registerHandler(new ForwardingProfile.LayerPostProcesser() { + profile.registerHandler(new ForwardingProfile.LayerPostProcessor() { @Override public List postProcess(int zoom, List items) { return null; @@ -181,7 +181,7 @@ class ForwardingProfileTests { assertEquals(List.of(feature), profile.postProcessLayerFeatures("a", 0, List.of(feature))); // allow mutations on initial input - profile.registerHandler(new ForwardingProfile.LayerPostProcesser() { + profile.registerHandler(new ForwardingProfile.LayerPostProcessor() { @Override public List postProcess(int zoom, List items) { items.set(0, items.getFirst()); @@ -196,7 +196,7 @@ class ForwardingProfileTests { assertEquals(List.of(feature), profile.postProcessLayerFeatures("a", 0, List.of(feature))); // empty list removes - profile.registerHandler(new ForwardingProfile.LayerPostProcesser() { + profile.registerHandler(new ForwardingProfile.LayerPostProcessor() { @Override public List postProcess(int zoom, List items) { return List.of(); @@ -212,7 +212,7 @@ class ForwardingProfileTests { assertEquals(List.of(feature), profile.postProcessLayerFeatures("b", 0, List.of(feature))); // allow mutations on subsequent input - profile.registerHandler(new ForwardingProfile.LayerPostProcesser() { + profile.registerHandler(new ForwardingProfile.LayerPostProcessor() { @Override public List postProcess(int zoom, List items) { items.add(null); @@ -229,7 +229,7 @@ class ForwardingProfileTests { assertEquals(List.of(), profile.postProcessLayerFeatures("a", 0, new ArrayList<>(List.of(feature)))); // 2 handlers for same layer run one after another - var skip1 = new ForwardingProfile.LayerPostProcesser() { + var skip1 = new ForwardingProfile.LayerPostProcessor() { @Override public List postProcess(int zoom, List items) { return items.stream().skip(1).toList(); @@ -242,7 +242,7 @@ class ForwardingProfileTests { }; profile.registerHandler(skip1); profile.registerHandler(skip1); - profile.registerHandler(new ForwardingProfile.LayerPostProcesser() { + profile.registerHandler(new ForwardingProfile.LayerPostProcessor() { @Override public List postProcess(int zoom, List items) { return null; // ensure that returning null after initial post-processors run keeps the postprocessed result