Ignore min_size when tile_post_process exists

pull/1277/head
zstadler 2025-06-29 18:10:44 +03:00
rodzic a90d45d5e1
commit a0025a898a
2 zmienionych plików z 35 dodań i 2 usunięć

Wyświetl plik

@ -21,6 +21,8 @@ import java.util.Objects;
import java.util.Set;
import java.util.function.BiConsumer;
import java.util.function.Function;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* A map feature, configured from a YML configuration file.
@ -29,6 +31,8 @@ import java.util.function.Function;
* and {@link #processFeature(Contexts.FeaturePostMatch, FeatureCollector)} processes matching elements.
*/
public class ConfiguredFeature {
private static final Logger LOGGER = LoggerFactory.getLogger(ConfiguredFeature.class);
private static final double LOG4 = Math.log(4);
private final Expression geometryTest;
private final Function<FeatureCollector, Feature> geometryFactory;
@ -91,8 +95,14 @@ public class ConfiguredFeature {
}
processors.add(makeFeatureProcessor(feature.minZoom(), Integer.class, Feature::setMinZoom));
processors.add(makeFeatureProcessor(feature.maxZoom(), Integer.class, Feature::setMaxZoom));
processors.add(makeFeatureProcessor(feature.minSize(), Double.class, Feature::setMinPixelSize));
if (layer.postProcess() != null) {
if (layer.postProcess() == null) {
processors.add(makeFeatureProcessor(feature.minSize(), Double.class, Feature::setMinPixelSize));
} else {
processors.add(makeFeatureProcessor(0, Double.class, Feature::setMinPixelSize));
if (feature.minSize() != null ) {
LOGGER.info("Ignored min_size settings in layer {} in favour of its tile_post_process settings",
layer.id());
}
var merge = layer.postProcess().mergeLineStrings();
if (merge != null) {
var minLength = merge.minLength();

Wyświetl plik

@ -226,6 +226,29 @@ class ConfiguredFeatureTest {
assertEquals(List.of(feature), profile.postProcessLayerFeatures("testLayer", 0, List.of(feature)));
}
@Test
void testMergeLineStringMinLengthSetsBufferPixels() {
testLinestring("""
sources:
osm:
type: osm
url: geofabrik:rhode-island
local_path: data/rhode-island.osm.pbf
layers:
- id: testLayer
features:
- source: osm
geometry: line
tile_post_process:
merge_line_strings:
min_length: 10
tolerance: 5
buffer: 4
""", Map.of(), f -> {
assertEquals(10, f.getBufferPixelsAtZoom(14));
}, 1);
}
@Test
void testFeaturePostProcessorMergePolygons() throws GeometryException {
var config = """