Skip to content

Landuse geometry simplification #500

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
Tiles 4.11.10
------
- Landuse geometry simplification [#500]

Tiles 4.11.9
------
- Remove extra large buffer at z15 POIs to reduce tile size [#493]
Expand Down
Binary file modified render-tests/tests/landuse/grassland/expected.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion tiles/src/main/java/com/protomaps/basemap/Basemap.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public String description() {

@Override
public String version() {
return "4.11.9";
return "4.11.10";
}

@Override
Expand Down
36 changes: 13 additions & 23 deletions tiles/src/main/java/com/protomaps/basemap/layers/Landuse.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
import com.onthegomap.planetiler.VectorTile;
import com.onthegomap.planetiler.expression.MultiExpression;
import com.onthegomap.planetiler.geo.GeometryException;
import com.onthegomap.planetiler.geo.VWSimplifier;
import com.onthegomap.planetiler.reader.SourceFeature;
import com.protomaps.basemap.feature.FeatureId;
import com.protomaps.basemap.postprocess.Area;
import com.onthegomap.planetiler.stats.Stats;
import java.util.List;
import java.util.Map;

Expand Down Expand Up @@ -248,14 +248,11 @@ public void processOsm(SourceFeature sf, FeatureCollector features) {
String kind = getString(sf, matches, "kind", "other");

features.polygon(this.name())
.setId(FeatureId.create(sf))
// Core Tilezen schema properties
.setId(1)
.setAttr("kind", kind)
.setAttr("sort_rank", 189)
// NOTE: (nvkelso 20230622) Consider zoom 5 instead...
// But to match Protomaps v2 we do earlier
.setZoomRange(2, 15)
.setMinPixelSize(2.0);
.setPixelTolerance(0.0)
.setMinPixelSize(1.0);

}
}
Expand All @@ -269,20 +266,13 @@ public String name() {

@Override
public List<VectorTile.Feature> postProcess(int zoom, List<VectorTile.Feature> items) throws GeometryException {
if (zoom == 15)
return items;
int minArea = 400 / (4096 * 4096) * (256 * 256);
if (zoom == 6)
minArea = 600 / (4096 * 4096) * (256 * 256);
else if (zoom <= 5)
minArea = 800 / (4096 * 4096) * (256 * 256);
items = Area.filterArea(items, minArea);

// We only care about park boundaries inside groups of adjacent parks at higher zooms when they are labeled
// so at lower zooms we merge them to reduce file size
if (zoom <= 6) {
return FeatureMerge.mergeNearbyPolygons(items, 3.125, 3.125, 0.5, 0.5);
}
return items;
double resolution = 0.0625;
double tolerance = switch (zoom) {
case 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 -> 5 * resolution;
case 11 -> 10 * resolution;
default -> 15 * resolution;
};
var simplifier = new VWSimplifier().setTolerance(tolerance);
return FeatureMerge.mergeNearbyPolygons(items, 3.125, 3.125, 0.5, 0.5, Stats.inMemory(), simplifier);
}
}
Loading