Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Overture.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.onthegomap.planetiler.util.Glob;

import overturelayers.Building;
import overturelayers.LandCover;
import overturelayers.Transportation;
import overturelayers.Water;

Expand All @@ -25,6 +26,7 @@ public class Overture extends ForwardingProfile {
Overture(PlanetilerConfig config) {
super(config);
registerHandler(new Water(config));
registerHandler(new LandCover(config));
registerHandler(new Transportation(config));
registerHandler(new Building());
}
Expand Down
40 changes: 40 additions & 0 deletions overturelayers/LandCover.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package overturelayers;

import java.util.List;

import com.onthegomap.planetiler.FeatureCollector;
import com.onthegomap.planetiler.FeatureMerge;
import com.onthegomap.planetiler.ForwardingProfile.LayerPostProcesser;
import com.onthegomap.planetiler.VectorTile.Feature;
import com.onthegomap.planetiler.geo.GeometryException;
import com.onthegomap.planetiler.config.PlanetilerConfig;
import com.onthegomap.planetiler.reader.SourceFeature;

public class LandCover extends BaseLayer implements LayerPostProcesser {

private PlanetilerConfig config;

public LandCover(PlanetilerConfig config) {
super("land_cover", List.of("land_cover"));
this.config = config;
}

@Override
public void processFeature(SourceFeature sourceFeature, FeatureCollector features) {
var cartography = sourceFeature.getStruct("cartography");
var minZoom = cartography.get("min_zoom").asInt();
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was taken from the existing OvertureLandcover example.

var maxZoom = cartography.get("max_zoom").asInt();

features.polygon("land_cover")
.setMinZoom(minZoom)
.setMaxZoom(maxZoom)
.inheritAttrsFromSource("subtype");
}

@Override
public List<Feature> postProcess(int zoom, List<Feature> items) throws GeometryException {
double minSize = zoom < 13 ? 8 : config.minFeatureSize(zoom);
items = FeatureMerge.mergeOverlappingPolygons(items, minSize);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was not in the existing OvertureLandcover example, but I thought it seemed like a good idea. What do you think?

return items;
}
}