Skip to content

Commit

Permalink
tiles 4.0.0-alpha.4 [#282] (#296)
Browse files Browse the repository at this point in the history
* breaking change: remove pmap: prefixes from tiles.
* breaking change: remove physical_point, natural and physical_line layers.
* move features into landuse, water, pois and earth.
  • Loading branch information
bdon authored Sep 20, 2024
1 parent dec9f03 commit 55d0df2
Show file tree
Hide file tree
Showing 29 changed files with 401 additions and 550 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
Tiles v4.0.0-alpha.3
------
- remove all `pmap:` prefixes (breaking change) [#282]
- remove `physical_point`, `natural` and `physical_line` layers.
- move into `landuse`, `water`, `pois` and `earth` layers to align with Tilezen.
- Some layers are now mixed geometry types.

Styles v4.0.0-alpha.0
------
- Add lang and script parameters to TypeScript style generation [#275]
Expand Down
22 changes: 4 additions & 18 deletions tiles/src/main/java/com/protomaps/basemap/Basemap.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
import com.protomaps.basemap.layers.Earth;
import com.protomaps.basemap.layers.Landcover;
import com.protomaps.basemap.layers.Landuse;
import com.protomaps.basemap.layers.Natural;
import com.protomaps.basemap.layers.PhysicalLine;
import com.protomaps.basemap.layers.PhysicalPoint;
import com.protomaps.basemap.layers.Places;
import com.protomaps.basemap.layers.Pois;
import com.protomaps.basemap.layers.Roads;
Expand Down Expand Up @@ -47,19 +44,6 @@ public Basemap(NaturalEarthDb naturalEarthDb, QrankDb qrankDb) {
registerHandler(landcover);
registerSourceHandler("landcover", landcover::processLandcover);

var natural = new Natural();
registerHandler(natural);
registerSourceHandler("osm", natural::processOsm);

var physicalLine = new PhysicalLine();
registerHandler(physicalLine);
registerSourceHandler("osm", physicalLine::processOsm);

var physicalPoint = new PhysicalPoint();
registerHandler(physicalPoint);
registerSourceHandler("osm", physicalPoint::processOsm);
registerSourceHandler("ne", physicalPoint::processNe);

var place = new Places(naturalEarthDb);
registerHandler(place);
registerSourceHandler("osm", place::processOsm);
Expand All @@ -84,6 +68,8 @@ public Basemap(NaturalEarthDb naturalEarthDb, QrankDb qrankDb) {

var earth = new Earth();
registerHandler(earth);

registerSourceHandler("osm", earth::processOsm);
registerSourceHandler("osm_land", earth::processPreparedOsm);
registerSourceHandler("ne", earth::processNe);
}
Expand All @@ -100,7 +86,7 @@ public String description() {

@Override
public String version() {
return "4.0.0-alpha.3";
return "4.0.0-alpha.4";
}

@Override
Expand All @@ -111,7 +97,7 @@ public boolean isOverlay() {
@Override
public String attribution() {
return """
<a href="https://www.openstreetmap.org/copyright" target="_blank">&copy; OpenStreetMap contributors</a>
<a href="https://www.openstreetmap.org/copyright" target="_blank">&copy; OpenStreetMap</a>
""".trim();
}

Expand Down
20 changes: 10 additions & 10 deletions tiles/src/main/java/com/protomaps/basemap/layers/Boundaries.java
Original file line number Diff line number Diff line change
Expand Up @@ -143,15 +143,15 @@ public void processNe(SourceFeature sf, FeatureCollector features) {

var line = features.line(this.name())
// Core Tilezen schema properties
.setAttr("pmap:kind", kind)
.setAttr("kind", kind)
// Don't label lines to reduce file size (and they aren't shown in styles anyhow)
//.setAttr("name", sf.getString("name"))
// Preview v4 schema (disabled)
//.setAttr("pmap:min_zoom", sf.getLong("min_zoom"))
.setAttr("pmap:min_admin_level", adminLevel)
//.setAttr("min_zoom", sf.getLong("min_zoom"))
.setAttr("min_admin_level", adminLevel)
// Reduce file size at low zooms
//.setAttr("pmap:ne_id", sf.getString("ne_id"))
.setAttr("pmap:brk_a3", sf.getString("brk_a3"))
//.setAttr("ne_id", sf.getString("ne_id"))
.setAttr("brk_a3", sf.getString("brk_a3"))
.setZoomRange(
sf.getString("min_zoom") == null ? themeMinZoom : (int) minZoom,
themeMaxZoom)
Expand All @@ -161,7 +161,7 @@ public void processNe(SourceFeature sf, FeatureCollector features) {

// Core Tilezen schema properties
if (!kindDetail.isEmpty()) {
line.setAttr("pmap:kind_detail", kindDetail);
line.setAttr("kind_detail", kindDetail);
}

if (disputed) {
Expand Down Expand Up @@ -238,16 +238,16 @@ public void processOsm(SourceFeature sf, FeatureCollector features) {
var line = features.line(this.name())
.setId(FeatureId.create(sf))
// Core Tilezen schema properties
.setAttr("pmap:kind", kind)
.setAttr("pmap:min_admin_level", minAdminLevel.getAsInt())
.setAttr("kind", kind)
.setAttr("min_admin_level", minAdminLevel.getAsInt())
.setMinPixelSize(0)
// Preview v4 schema (disabled)
//.setAttr("pmap:min_zoom", min_zoom)
//.setAttr("min_zoom", min_zoom)
.setMinZoom(themeMinZoom);

// Core Tilezen schema properties
if (!kindDetail.isEmpty()) {
line.setAttr("pmap:kind_detail", kindDetail);
line.setAttr("kind_detail", kindDetail);
}

// Core Tilezen schema properties
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public void processOsm(SourceFeature sf, FeatureCollector features) {
var feature = features.polygon(this.name())
.setId(FeatureId.create(sf))
// Core Tilezen schema properties
.setAttr("pmap:kind", kind)
.setAttr("kind", kind)
// Core OSM tags for different kinds of places
.setAttrWithMinzoom("layer", Parse.parseIntOrNull(sf.getString("layer")), 13)
// NOTE: Height is quantized by zoom in a post-process step
Expand All @@ -85,7 +85,7 @@ public void processOsm(SourceFeature sf, FeatureCollector features) {

if (kind.equals("building_part")) {
// We don't need to set WithMinzoom because that's implicate with the ZoomRange
feature.setAttr("pmap:kind_detail", sf.getString("building:part"));
feature.setAttr("kind_detail", sf.getString("building:part"));
feature.setAttr(MIN_HEIGHT_KEY, height.min_height());
}

Expand Down
21 changes: 18 additions & 3 deletions tiles/src/main/java/com/protomaps/basemap/layers/Earth.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import com.onthegomap.planetiler.VectorTile;
import com.onthegomap.planetiler.geo.GeometryException;
import com.onthegomap.planetiler.reader.SourceFeature;
import com.protomaps.basemap.feature.FeatureId;
import com.protomaps.basemap.names.OsmNames;
import java.util.List;

public class Earth implements ForwardingProfile.FeaturePostProcessor {
Expand All @@ -16,16 +18,29 @@ public String name() {

public void processPreparedOsm(SourceFeature ignoredSf, FeatureCollector features) {
features.polygon(this.name())
.setAttr("pmap:kind", "earth")
.setAttr("kind", "earth")
.setZoomRange(6, 15).setBufferPixels(8);
}

public void processNe(SourceFeature sf, FeatureCollector features) {
var sourceLayer = sf.getSourceLayer();
if (sourceLayer.equals("ne_50m_land")) {
features.polygon(this.name()).setZoomRange(0, 4).setBufferPixels(8).setAttr("pmap:kind", "earth");
features.polygon(this.name()).setZoomRange(0, 4).setBufferPixels(8).setAttr("kind", "earth");
} else if (sourceLayer.equals("ne_10m_land")) {
features.polygon(this.name()).setZoomRange(5, 5).setBufferPixels(8).setAttr("pmap:kind", "earth");
features.polygon(this.name()).setZoomRange(5, 5).setBufferPixels(8).setAttr("kind", "earth");
}
}

public void processOsm(SourceFeature sf, FeatureCollector features) {
if (sf.canBeLine() && !sf.canBePolygon() && sf.hasTag("natural", "cliff")) {
int minZoom = 12;
var feat = features.line(this.name())
.setId(FeatureId.create(sf))
.setAttr("min_zoom", minZoom + 1)
.setAttr("kind", "cliff")
.setZoomRange(minZoom, 15);

OsmNames.setOsmNames(feat, sf, 0);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public void processLandcover(SourceFeature sf, FeatureCollector features) {

features.polygon(this.name())
.setId(FeatureId.create(sf))
.setAttr("pmap:kind", kind)
.setAttr("kind", kind)
.setZoomRange(0, 7)
.setSortKey(sortKey)
.setMinPixelSize(0.0);
Expand Down
7 changes: 4 additions & 3 deletions tiles/src/main/java/com/protomaps/basemap/layers/Landuse.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ public void processOsm(SourceFeature sf, FeatureCollector features) {
sf.hasTag("amenity", "hospital", "school", "kindergarten", "university", "college") ||
sf.hasTag("boundary", "national_park", "protected_area") ||
sf.hasTag("landuse", "recreation_ground", "industrial", "brownfield", "railway", "cemetery", "commercial",
"grass", "orchard", "farmland", "farmyard", "residential", "military", "village_green", "allotments") ||
"grass", "orchard", "farmland", "farmyard", "residential", "military", "village_green", "allotments", "forest",
"meadow", "grass") ||
sf.hasTag("leisure", "park", "garden", "golf_course", "dog_park", "playground", "pitch", "nature_reserve") ||
sf.hasTag("man_made", "pier", "bridge") ||
sf.hasTag("natural", "beach") ||
sf.hasTag("natural", "beach", "wood", "glacier", "grass", "scrub", "sand", "wetland", "bare_rock") ||
// TODO: (nvkelso 20230622) This use of the place tag here is dubious, though paired with "residential"
sf.hasTag("place", "neighbourhood") ||
sf.hasTag("railway", "platform") ||
Expand Down Expand Up @@ -152,7 +153,7 @@ public void processOsm(SourceFeature sf, FeatureCollector features) {
features.polygon(this.name())
.setId(FeatureId.create(sf))
// Core Tilezen schema properties
.setAttr("pmap:kind", kind)
.setAttr("kind", kind)
// NOTE: (nvkelso 20230622) Consider zoom 5 instead...
// But to match Protomaps v2 we do earlier
.setZoomRange(2, 15)
Expand Down
55 changes: 0 additions & 55 deletions tiles/src/main/java/com/protomaps/basemap/layers/Natural.java

This file was deleted.

74 changes: 0 additions & 74 deletions tiles/src/main/java/com/protomaps/basemap/layers/PhysicalLine.java

This file was deleted.

Loading

0 comments on commit 55d0df2

Please sign in to comment.