mirror of
https://github.com/cfpwastaken/planetiler-openmaptiles.git
synced 2026-02-04 04:21:08 +00:00
Merge overlapping water polygons (#235)
This commit is contained in:
@@ -36,15 +36,20 @@ See https://github.com/openmaptiles/openmaptiles/blob/master/LICENSE.md for deta
|
|||||||
package com.onthegomap.planetiler.openmaptiles.layers;
|
package com.onthegomap.planetiler.openmaptiles.layers;
|
||||||
|
|
||||||
import com.onthegomap.planetiler.FeatureCollector;
|
import com.onthegomap.planetiler.FeatureCollector;
|
||||||
|
import com.onthegomap.planetiler.FeatureMerge;
|
||||||
|
import com.onthegomap.planetiler.ForwardingProfile;
|
||||||
|
import com.onthegomap.planetiler.VectorTile;
|
||||||
import com.onthegomap.planetiler.openmaptiles.OpenMapTilesProfile;
|
import com.onthegomap.planetiler.openmaptiles.OpenMapTilesProfile;
|
||||||
import com.onthegomap.planetiler.openmaptiles.generated.OpenMapTilesSchema;
|
import com.onthegomap.planetiler.openmaptiles.generated.OpenMapTilesSchema;
|
||||||
import com.onthegomap.planetiler.openmaptiles.generated.Tables;
|
import com.onthegomap.planetiler.openmaptiles.generated.Tables;
|
||||||
import com.onthegomap.planetiler.openmaptiles.util.Utils;
|
import com.onthegomap.planetiler.openmaptiles.util.Utils;
|
||||||
import com.onthegomap.planetiler.config.PlanetilerConfig;
|
import com.onthegomap.planetiler.config.PlanetilerConfig;
|
||||||
import com.onthegomap.planetiler.expression.MultiExpression;
|
import com.onthegomap.planetiler.expression.MultiExpression;
|
||||||
|
import com.onthegomap.planetiler.geo.GeometryException;
|
||||||
import com.onthegomap.planetiler.reader.SourceFeature;
|
import com.onthegomap.planetiler.reader.SourceFeature;
|
||||||
import com.onthegomap.planetiler.stats.Stats;
|
import com.onthegomap.planetiler.stats.Stats;
|
||||||
import com.onthegomap.planetiler.util.Translations;
|
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.
|
* 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,
|
OpenMapTilesSchema.Water,
|
||||||
Tables.OsmWaterPolygon.Handler,
|
Tables.OsmWaterPolygon.Handler,
|
||||||
OpenMapTilesProfile.NaturalEarthProcessor,
|
OpenMapTilesProfile.NaturalEarthProcessor,
|
||||||
OpenMapTilesProfile.OsmWaterPolygonProcessor {
|
OpenMapTilesProfile.OsmWaterPolygonProcessor,
|
||||||
|
ForwardingProfile.FeaturePostProcessor {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* At low zoom levels, use natural earth for oceans and major lakes, and at high zoom levels
|
* 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 MultiExpression.Index<String> classMapping;
|
||||||
|
private final PlanetilerConfig config;
|
||||||
|
|
||||||
public Water(Translations translations, PlanetilerConfig config, Stats stats) {
|
public Water(Translations translations, PlanetilerConfig config, Stats stats) {
|
||||||
this.classMapping = FieldMappings.Class.index();
|
this.classMapping = FieldMappings.Class.index();
|
||||||
|
this.config = config;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -116,4 +124,9 @@ public class Water implements
|
|||||||
.setAttr(Fields.CLASS, clazz);
|
.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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user