Merge overlapping water polygons (#235)

pull/238/head
Michael Barry 2022-05-28 05:40:17 -04:00 zatwierdzone przez GitHub
rodzic 4ecc96e9d9
commit f7fd3e90a7
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
1 zmienionych plików z 14 dodań i 1 usunięć

Wyświetl plik

@ -36,15 +36,20 @@ See https://github.com/openmaptiles/openmaptiles/blob/master/LICENSE.md for deta
package com.onthegomap.planetiler.basemap.layers;
import com.onthegomap.planetiler.FeatureCollector;
import com.onthegomap.planetiler.FeatureMerge;
import com.onthegomap.planetiler.ForwardingProfile;
import com.onthegomap.planetiler.VectorTile;
import com.onthegomap.planetiler.basemap.BasemapProfile;
import com.onthegomap.planetiler.basemap.generated.OpenMapTilesSchema;
import com.onthegomap.planetiler.basemap.generated.Tables;
import com.onthegomap.planetiler.basemap.util.Utils;
import com.onthegomap.planetiler.config.PlanetilerConfig;
import com.onthegomap.planetiler.expression.MultiExpression;
import com.onthegomap.planetiler.geo.GeometryException;
import com.onthegomap.planetiler.reader.SourceFeature;
import com.onthegomap.planetiler.stats.Stats;
import com.onthegomap.planetiler.util.Translations;
import java.util.List;
/**
* Defines the logic for generating map elements for oceans and lakes in the {@code water} layer from source features.
@ -56,7 +61,8 @@ public class Water implements
OpenMapTilesSchema.Water,
Tables.OsmWaterPolygon.Handler,
BasemapProfile.NaturalEarthProcessor,
BasemapProfile.OsmWaterPolygonProcessor {
BasemapProfile.OsmWaterPolygonProcessor,
ForwardingProfile.FeaturePostProcessor {
/*
* At low zoom levels, use natural earth for oceans and major lakes, and at high zoom levels
@ -66,9 +72,11 @@ public class Water implements
*/
private final MultiExpression.Index<String> classMapping;
private final PlanetilerConfig config;
public Water(Translations translations, PlanetilerConfig config, Stats stats) {
this.classMapping = FieldMappings.Class.index();
this.config = config;
}
@Override
@ -116,4 +124,9 @@ public class Water implements
.setAttr(Fields.CLASS, clazz);
}
}
@Override
public List<VectorTile.Feature> postProcess(int zoom, List<VectorTile.Feature> items) throws GeometryException {
return items.size() > 1 ? FeatureMerge.mergeOverlappingPolygons(items, config.minFeatureSize(zoom)) : items;
}
}