Skip to content

Commit

Permalink
remove pmap: prefixes (breaking change) [#282]
Browse files Browse the repository at this point in the history
  • Loading branch information
bdon committed Sep 20, 2024
1 parent dec9f03 commit 91483f1
Show file tree
Hide file tree
Showing 27 changed files with 118 additions and 118 deletions.
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
6 changes: 3 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 @@ -16,16 +16,16 @@ 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");
}
}

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
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,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
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,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
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ public void processOsm(SourceFeature sf, FeatureCollector features) {
var feat = features.line(this.name())
.setId(FeatureId.create(sf))
// Core Tilezen schema properties
.setAttr("pmap:kind", kind)
.setAttr("kind", kind)
// Used for client-side label collisions
.setAttr("pmap:min_zoom", minZoom + 1)
.setAttr("min_zoom", minZoom + 1)
// Add less common core Tilezen attributes only at higher zooms (will continue to v4)
//.setAttrWithMinzoom("bridge", sf.getString("bridge"), 12)
//.setAttrWithMinzoom("tunnel", sf.getString("tunnel"), 12)
Expand All @@ -51,13 +51,13 @@ public void processOsm(SourceFeature sf, FeatureCollector features) {
// Because of MapLibre performance and draw order limitations, generally the boolean is sufficient
// See also: "layer" for more complicated ±6 layering for more sophisticated graphics libraries
if (sf.hasTag("bridge") && !sf.hasTag("bridge", "no")) {
feat.setAttr("pmap:level", 1);
feat.setAttr("level", 1);
} else if (sf.hasTag("tunnel") && !sf.hasTag("tunnel", "no")) {
feat.setAttr("pmap:level", -1);
feat.setAttr("level", -1);
} else if (sf.hasTag("layer", "-6", "-5", "-4", "-3", "-2", "-1")) {
feat.setAttr("pmap:level", -1);
feat.setAttr("level", -1);
} else {
feat.setAttr("pmap:level", 0);
feat.setAttr("level", 0);
}

// Server sort features so client label collisions are pre-sorted
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ public void processNe(SourceFeature sf, FeatureCollector features) {

if (!kind.isEmpty() && sf.hasTag("min_label") && sf.hasTag("name") && sf.getTag("name") != null) {
var waterLabelPosition = features.pointOnSurface(this.name())
.setAttr("pmap:kind", kind)
.setAttr("pmap:min_zoom", minZoom + 1)
.setAttr("kind", kind)
.setAttr("min_zoom", minZoom + 1)
.setZoomRange(sf.getString("min_label") == null ? themeMinZoom :
(int) Double.parseDouble(sf.getString("min_label")) + 1, themeMaxZoom)
.setBufferPixels(128);
Expand Down Expand Up @@ -88,9 +88,9 @@ public void processOsm(SourceFeature sf, FeatureCollector features) {

var feat = features.point(this.name())
.setId(FeatureId.create(sf))
.setAttr("pmap:kind", kind)
.setAttr("kind", kind)
// Used for client-side label collisions
.setAttr("pmap:min_zoom", minZoom + 1)
.setAttr("min_zoom", minZoom + 1)
.setAttr("place", sf.getString("place"))
.setAttr("natural", sf.getString("natural"))
.setAttr("ele", sf.getString("ele"))
Expand Down Expand Up @@ -181,12 +181,12 @@ public void processOsm(SourceFeature sf, FeatureCollector features) {

var waterLabelPosition = features.pointOnSurface(this.name())
// Core Tilezen schema properties
.setAttr("pmap:kind", kind)
.setAttr("pmap:kind_detail", kindDetail)
.setAttr("kind", kind)
.setAttr("kind_detail", kindDetail)
// While other layers don't need min_zoom, physical point labels do for more
// predictable client-side label collisions
// 512 px zooms versus 256 px logical zooms
.setAttr("pmap:min_zoom", nameMinZoom + 1)
.setAttr("min_zoom", nameMinZoom + 1)
// Add less common core Tilezen attributes only at higher zooms (will continue to v4)
.setAttrWithMinzoom("bridge", sf.getString("bridge"), 12)
.setAttrWithMinzoom("tunnel", sf.getString("tunnel"), 12)
Expand All @@ -196,7 +196,7 @@ public void processOsm(SourceFeature sf, FeatureCollector features) {

// Add less common core Tilezen attributes only at higher zooms (will continue to v4)
if (!kindDetail.isEmpty()) {
waterLabelPosition.setAttr("pmap:kind_detail", kindDetail);
waterLabelPosition.setAttr("kind_detail", kindDetail);
}
if (sf.hasTag("water", "reservoir") || reservoir) {
waterLabelPosition.setAttr("reservoir", true);
Expand Down
8 changes: 4 additions & 4 deletions tiles/src/main/java/com/protomaps/basemap/layers/Places.java
Original file line number Diff line number Diff line change
Expand Up @@ -268,13 +268,13 @@ public void processOsm(SourceFeature sf, FeatureCollector features) {
var feat = features.point(this.name())
.setId(FeatureId.create(sf))
// Core Tilezen schema properties
.setAttr("pmap:kind", kind)
.setAttr("pmap:kind_detail", place)
.setAttr("pmap:min_zoom", minZoom + 1)
.setAttr("kind", kind)
.setAttr("kind_detail", place)
.setAttr("min_zoom", minZoom + 1)
// Core OSM tags for different kinds of places
.setAttr("capital", sf.getString("capital"))
.setAttr("population", population)
.setAttr("pmap:population_rank", populationRank)
.setAttr("population_rank", populationRank)
// Generally we use NE and low zooms, and OSM at high zooms
// With exceptions for country and region labels
.setZoomRange((int) minZoom, (int) maxZoom);
Expand Down
20 changes: 10 additions & 10 deletions tiles/src/main/java/com/protomaps/basemap/layers/Pois.java
Original file line number Diff line number Diff line change
Expand Up @@ -441,13 +441,13 @@ public void processOsm(SourceFeature sf, FeatureCollector features) {
// (there is no merging of POIs like with lines and polygons in other layers)
.setId(FeatureId.create(sf))
// Core Tilezen schema properties
.setAttr("pmap:kind", kind)
.setAttr("kind", kind)
// While other layers don't need min_zoom, POIs do for more predictable client-side label collisions
// 512 px zooms versus 256 px logical zooms
.setAttr("pmap:min_zoom", minZoom + 1)
.setAttr("min_zoom", minZoom + 1)
//
// DEBUG
//.setAttr("pmap:area_debug", wayArea)
//.setAttr("area_debug", wayArea)
//
// Core OSM tags for different kinds of places
// Special airport only tag (to indicate if it's an airport with regular commercial flights)
Expand All @@ -459,7 +459,7 @@ public void processOsm(SourceFeature sf, FeatureCollector features) {

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

OsmNames.setOsmNames(polyLabelPosition, sf, 0);
Expand All @@ -482,10 +482,10 @@ public void processOsm(SourceFeature sf, FeatureCollector features) {
// (there is no merging of POIs like with lines and polygons in other layers)
.setId(FeatureId.create(sf))
// Core Tilezen schema properties
.setAttr("pmap:kind", kind)
.setAttr("kind", kind)
// While other layers don't need min_zoom, POIs do for more predictable client-side label collisions
// 512 px zooms versus 256 px logical zooms
.setAttr("pmap:min_zoom", minZoom + 1)
.setAttr("min_zoom", minZoom + 1)
// Core OSM tags for different kinds of places
// Special airport only tag (to indicate if it's an airport with regular commercial flights)
.setAttr("iata", sf.getString("iata"))
Expand All @@ -494,7 +494,7 @@ public void processOsm(SourceFeature sf, FeatureCollector features) {

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

OsmNames.setOsmNames(pointFeature, sf, 0);
Expand All @@ -510,7 +510,7 @@ public void processOsm(SourceFeature sf, FeatureCollector features) {
sf.hasTag("historic", "landmark", "wayside_cross") ||
sf.hasTag("leisure", "dog_park", "firepit", "fishing", "pitch", "playground", "slipway", "swimming_area") ||
sf.hasTag("tourism", "alpine_hut", "information", "picnic_site", "viewpoint", "wilderness_hut"))) {
pointFeature.setAttr("pmap:min_zoom", 17);
pointFeature.setAttr("min_zoom", 17);
}

if (sf.hasTag("amenity", "clinic", "dentist", "doctors", "social_facility", "baby_hatch", "childcare",
Expand All @@ -527,7 +527,7 @@ public void processOsm(SourceFeature sf, FeatureCollector features) {
"travel_agency") ||
sf.hasTag("tourism", "artwork", "hanami", "trail_riding_station", "bed_and_breakfast", "chalet",
"guest_house", "hostel")) {
pointFeature.setAttr("pmap:min_zoom", 17);
pointFeature.setAttr("min_zoom", 17);
}

// Server sort features so client label collisions are pre-sorted
Expand All @@ -548,7 +548,7 @@ public void processOsm(SourceFeature sf, FeatureCollector features) {
@Override
public List<VectorTile.Feature> postProcess(int zoom, List<VectorTile.Feature> items) throws GeometryException {

// TODO: (nvkelso 20230623) Consider adding a "pmap:rank" here for POIs, like for Places
// TODO: (nvkelso 20230623) Consider adding a "rank" here for POIs, like for Places

return items;
}
Expand Down
20 changes: 10 additions & 10 deletions tiles/src/main/java/com/protomaps/basemap/layers/Roads.java
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,9 @@ public void processOsm(SourceFeature sf, FeatureCollector features) {
var feat = features.line("roads")
.setId(FeatureId.create(sf))
// Core Tilezen schema properties
.setAttr("pmap:kind", kind)
.setAttr("kind", kind)
// To power better client label collisions
.setAttr("pmap:min_zoom", minZoom + 1)
.setAttr("min_zoom", minZoom + 1)
.setAttrWithMinzoom("ref", shield.text(), minZoomShieldText)
.setAttrWithMinzoom("shield_text_length", shieldTextLength, minZoomShieldText)
.setAttrWithMinzoom("network", shield.network(), minZoomShieldText)
Expand All @@ -152,9 +152,9 @@ public void processOsm(SourceFeature sf, FeatureCollector features) {

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

// Core OSM tags for different kinds of places
Expand All @@ -164,18 +164,18 @@ public void processOsm(SourceFeature sf, FeatureCollector features) {

if (sf.hasTag("highway", "motorway_link", "trunk_link", "primary_link", "secondary_link",
"tertiary_link")) {
feat.setAttr("pmap:link", 1);
feat.setAttr("link", 1);
}

// Set "brunnel" (bridge / tunnel) property where "level" = 1 is a bridge, 0 is ground level, and -1 is a tunnel
// Because of MapLibre performance and draw order limitations, generally the boolean is sufficent
// See also: "layer" for more complicated ±6 layering for more sophisticated graphics libraries
if (sf.hasTag("bridge") && !sf.hasTag("bridge", "no")) {
feat.setAttrWithMinzoom("pmap:level", 1, 12);
feat.setAttrWithMinzoom("level", 1, 12);
} else if (sf.hasTag("tunnel") && !sf.hasTag("tunnel", "no")) {
feat.setAttrWithMinzoom("pmap:level", -1, 12);
feat.setAttrWithMinzoom("level", -1, 12);
} else {
feat.setAttrWithMinzoom("pmap:level", 0, 12);
feat.setAttrWithMinzoom("level", 0, 12);
}

// Server sort features so client label collisions are pre-sorted
Expand All @@ -198,8 +198,8 @@ public List<VectorTile.Feature> postProcess(int zoom, List<VectorTile.Feature> i

for (var item : items) {
item.attrs().remove("highway");
if (!item.attrs().containsKey("pmap:level")) {
item.attrs().put("pmap:level", 0);
if (!item.attrs().containsKey("level")) {
item.attrs().put("level", 0);
}
}

Expand Down
12 changes: 6 additions & 6 deletions tiles/src/main/java/com/protomaps/basemap/layers/Transit.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ public void processOsm(SourceFeature sf, FeatureCollector features) {
var feature = features.line(this.name())
.setId(FeatureId.create(sf))
// Core Tilezen schema properties
.setAttr("pmap:kind", kind)
.setAttr("kind", kind)
// Used for client-side label collisions
.setAttr("pmap:min_zoom", minZoom + 1)
.setAttr("min_zoom", minZoom + 1)
// Core OSM tags for different kinds of places
.setAttr("layer", Parse.parseIntOrNull(sf.getString("layer")))
.setAttr("network", sf.getString("network"))
Expand All @@ -90,18 +90,18 @@ public void processOsm(SourceFeature sf, FeatureCollector features) {

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

// Set "brunnel" (bridge / tunnel) property where "level" = 1 is a bridge, 0 is ground level, and -1 is a tunnel
// Because of MapLibre performance and draw order limitations, generally the boolean is sufficent
// See also: "layer" for more complicated ±6 layering for more sophisticated graphics libraries
if (sf.hasTag("bridge") && !sf.hasTag("bridge", "no")) {
feature.setAttr("pmap:level", 1);
feature.setAttr("level", 1);
} else if (sf.hasTag("tunnel") && !sf.hasTag("tunnel", "no")) {
feature.setAttr("pmap:level", -1);
feature.setAttr("level", -1);
} else {
feature.setAttr("pmap:level", 0);
feature.setAttr("level", 0);
}

// Too many small pier lines otherwise
Expand Down
Loading

0 comments on commit 91483f1

Please sign in to comment.