From 0920a06edfd941e7ca3ac6aaf81a79312de31f0d Mon Sep 17 00:00:00 2001 From: Nathaniel Kelso Date: Thu, 25 May 2023 16:17:52 -0700 Subject: [PATCH 01/28] add disputed boundaries handling --- .../java/com/protomaps/basemap/layers/Boundaries.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tiles/src/main/java/com/protomaps/basemap/layers/Boundaries.java b/tiles/src/main/java/com/protomaps/basemap/layers/Boundaries.java index a2851cf7..47bd5ddc 100644 --- a/tiles/src/main/java/com/protomaps/basemap/layers/Boundaries.java +++ b/tiles/src/main/java/com/protomaps/basemap/layers/Boundaries.java @@ -40,6 +40,17 @@ public void processFeature(SourceFeature sf, FeatureCollector features) { } else { line.setMinZoom(10); } + + // Disputed boundaries handling + if( sf.hasTag("boundary", "disputed") ) { + line.setAttr("disputed", 1) + .setAttr("claimed_by", sf.getString("claimed_by")) + .setAttr("recognized_by", sf.getString("recognized_by")) + .setAttr("disputed_by", sf.getString("disputed_by")) + // Normally we don't export names on boundaries... But has a hack + // for styling which disputed boundaries we include them here + .setAttr("disputed_name", sf.getString("name")); + } } } } From 3ea52117e3a1d2cd81f3b8923a000a9aa9beed7c Mon Sep 17 00:00:00 2001 From: Nathaniel Kelso Date: Thu, 25 May 2023 16:30:26 -0700 Subject: [PATCH 02/28] add exotic water tags and min pix size --- .../java/com/protomaps/basemap/layers/PhysicalLine.java | 8 ++++++++ .../main/java/com/protomaps/basemap/layers/Water.java | 9 +++++++++ 2 files changed, 17 insertions(+) diff --git a/tiles/src/main/java/com/protomaps/basemap/layers/PhysicalLine.java b/tiles/src/main/java/com/protomaps/basemap/layers/PhysicalLine.java index 8535ca28..45154633 100644 --- a/tiles/src/main/java/com/protomaps/basemap/layers/PhysicalLine.java +++ b/tiles/src/main/java/com/protomaps/basemap/layers/PhysicalLine.java @@ -23,8 +23,16 @@ public void processFeature(SourceFeature sf, FeatureCollector features) { .setId(FeatureId.create(sf)) .setAttr("waterway", sf.getString("waterway")) .setAttr("natural", sf.getString("natural")) + // Add less common attributes only at higher zooms + .setAttrWithMinzoom("bridge", sf.getString("bridge"), 12) + .setAttrWithMinzoom("tunnel", sf.getString("tunnel"), 12) + .setAttrWithMinzoom("layer", sf.getString("layer"), 12) .setZoomRange(12, 15); + if( sf.hasTag("intermittent", "yes" ) ) { + sf.setAttr("intermittent", 1); + } + String kind = "other"; if (sf.hasTag("waterway")) { kind = "waterway"; diff --git a/tiles/src/main/java/com/protomaps/basemap/layers/Water.java b/tiles/src/main/java/com/protomaps/basemap/layers/Water.java index 271e18d5..7cbdf4e3 100644 --- a/tiles/src/main/java/com/protomaps/basemap/layers/Water.java +++ b/tiles/src/main/java/com/protomaps/basemap/layers/Water.java @@ -43,9 +43,18 @@ public void processFeature(SourceFeature sf, FeatureCollector features) { .setAttr("leisure", sf.getString("leisure")) .setAttr("water", sf.getString("water")) .setAttr("waterway", sf.getString("waterway")) + // Add less common attributes only at higher zooms + .setAttrWithMinzoom("bridge", sf.getString("bridge"), 12) + .setAttrWithMinzoom("tunnel", sf.getString("tunnel"), 12) + .setAttrWithMinzoom("layer", sf.getString("layer"), 12) .setZoomRange(6, 15) + .setMinPixelSize(3.0) .setBufferPixels(8); + if( sf.hasTag("intermittent", "yes" ) ) { + sf.setAttr("intermittent", 1); + } + OsmNames.setOsmNames(feature, sf, 0); } } From 17f8dddeaa632c4d54fe358aead8e3d3d942290d Mon Sep 17 00:00:00 2001 From: Nathaniel Kelso Date: Thu, 25 May 2023 22:26:23 -0700 Subject: [PATCH 03/28] add provinces, add fallback populations by place type, add population_rank attr --- .../com/protomaps/basemap/layers/Places.java | 68 ++++++++++++++----- 1 file changed, 52 insertions(+), 16 deletions(-) diff --git a/tiles/src/main/java/com/protomaps/basemap/layers/Places.java b/tiles/src/main/java/com/protomaps/basemap/layers/Places.java index 5fce32df..9b7a819a 100644 --- a/tiles/src/main/java/com/protomaps/basemap/layers/Places.java +++ b/tiles/src/main/java/com/protomaps/basemap/layers/Places.java @@ -20,7 +20,8 @@ public String name() { @Override public void processFeature(SourceFeature sf, FeatureCollector features) { if (sf.isPoint() && - (sf.hasTag("place", "suburb", "town", "village", "neighbourhood", "city", "country", "state"))) { + (sf.hasTag("place", "suburb", "town", "village", "neighbourhood", "city", "country", "state", "province"))) { + Integer population = sf.getString("population") == null ? 0 : (int)Double.parseDouble(sf.getString("population")); var feat = features.point(this.name()) .setId(FeatureId.create(sf)) .setAttr("place", sf.getString("place")) @@ -38,31 +39,66 @@ public void processFeature(SourceFeature sf, FeatureCollector features) { } else if (sf.hasTag("place", "city")) { feat.setAttr("pmap:kind", "city") .setZoomRange(4, 15); - - if (sf.getString("population") != null) { - Integer population = Parse.parseIntOrNull(sf.getString("population")); - if (population != null) { - feat.setAttr("population", population); - feat.setSortKey((int) Math.log(population)); - // TODO: use label grid - } else { - feat.setSortKey(0); - } + if ( population.equals(0) ) { + population = 10000; } - - } else if (sf.hasTag("place", "suburb")) { - feat.setAttr("pmap:kind", "neighbourhood") - .setZoomRange(8, 15); } else if (sf.hasTag("place", "town")) { feat.setAttr("pmap:kind", "neighbourhood") .setZoomRange(8, 15); + if ( population.equals(0) ) { + population = 5000; + } } else if (sf.hasTag("place", "village")) { feat.setAttr("pmap:kind", "neighbourhood") - .setZoomRange(10, 15); + .setZoomRange(10, 15); + if ( population.equals(0) ) { + population = 2000; + } + } else if (sf.hasTag("place", "suburb")) { + feat.setAttr("pmap:kind", "neighbourhood") + .setZoomRange(8, 15); } else { feat.setAttr("pmap:kind", "neighbourhood") .setZoomRange(12, 15); } + + if (population != null) { + feat.setAttr("population", population); + feat.setSortKey((int) Math.log(population)); + // TODO: use label grid + } else { + feat.setSortKey(0); + } + + Integer population_rank = 0; + + int[] pop_breaks = { + 1000000000, + 100000000, + 50000000, + 20000000, + 10000000, + 5000000, + 1000000, + 500000, + 200000, + 100000, + 50000, + 20000, + 10000, + 5000, + 2000, + 1000, + 200, + 0}; + + for (int i = 0; i < pop_breaks.length; i++) { + if( population >= pop_breaks[i]) { + population_rank = pop_breaks.length - i; + } + } + + feat.setAttr("population_rank", population_rank); } } From e4c53c6993bcecd42b376f436b7f3c419f7a9133 Mon Sep 17 00:00:00 2001 From: Nathaniel Kelso Date: Thu, 25 May 2023 22:27:35 -0700 Subject: [PATCH 04/28] add leisure, add aerodrome, add pmap:kind coallese --- .../com/protomaps/basemap/layers/Pois.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tiles/src/main/java/com/protomaps/basemap/layers/Pois.java b/tiles/src/main/java/com/protomaps/basemap/layers/Pois.java index 234a0fbc..23ca1da8 100644 --- a/tiles/src/main/java/com/protomaps/basemap/layers/Pois.java +++ b/tiles/src/main/java/com/protomaps/basemap/layers/Pois.java @@ -20,6 +20,8 @@ public void processFeature(SourceFeature sf, FeatureCollector features) { if (sf.isPoint() && (sf.hasTag("amenity") || sf.hasTag("shop") || sf.hasTag("tourism") || + sf.hasTag("leisure") || + sf.hasTag("aeroway", "aerodrome") || sf.hasTag("railway", "station"))) { var feature = features.point(this.name()) .setId(FeatureId.create(sf)) @@ -29,10 +31,31 @@ public void processFeature(SourceFeature sf, FeatureCollector features) { .setAttr("cuisine", sf.getString("cuisine")) .setAttr("religion", sf.getString("religion")) .setAttr("tourism", sf.getString("tourism")) + .setAttr("iata", sf.getString("iata")) .setZoomRange(13, 15); OsmNames.setOsmNames(feature, sf, 0); } + + String kind = "other"; + if (sf.hasTag("aeroway", "aerodrome" )) { + kind = sf.getString("aeroway"); + } else if (sf.hasTag("amenity", "cafe", "college", "hospital", "library", "post_office", "school", "townhall")) { + kind = sf.getString("amenity"); + } else if (sf.hasTag("landuse", "cemetery" )) { + kind = sf.getString("landuse"); + } else if (sf.hasTag("leisure", "golf_course", "marina", "park", "stadium" )) { + kind = sf.getString("leisure"); + } else if (sf.hasTag("leisure" )) { + // This is dubious but existing behavior + kind = "park"; + } else if (sf.hasTag("shop", "grocery", "supermarket" )) { + kind = sf.getString("shop"); + } else if (sf.hasTag("tourism", "attraction", "camp_site", "hotel" )) { + kind = sf.getString("tourism"); + } + + feature.setAttr("pmap:kind", kind); } @Override From a44c44d92deff03300cb67f3e71457d08ad49d2a Mon Sep 17 00:00:00 2001 From: Nathaniel Kelso Date: Thu, 25 May 2023 22:29:37 -0700 Subject: [PATCH 05/28] add ref_length, split other into path and other, add pmap:link, add basic network support --- .../com/protomaps/basemap/layers/Roads.java | 51 +++++++++++++++++-- 1 file changed, 48 insertions(+), 3 deletions(-) diff --git a/tiles/src/main/java/com/protomaps/basemap/layers/Roads.java b/tiles/src/main/java/com/protomaps/basemap/layers/Roads.java index b60c07db..fad8ac52 100644 --- a/tiles/src/main/java/com/protomaps/basemap/layers/Roads.java +++ b/tiles/src/main/java/com/protomaps/basemap/layers/Roads.java @@ -23,6 +23,7 @@ public void processFeature(SourceFeature sourceFeature, FeatureCollector feature if (sourceFeature.canBeLine() && sourceFeature.hasTag("highway") && !(sourceFeature.hasTag("highway", "proposed", "abandoned", "razed", "demolished", "removed", "construction"))) { String highway = sourceFeature.getString("highway"); + Integer shield_text_length = (shield_text == null ? null : sourceFeature.getString("ref").length()); var feat = features.line("roads") .setId(FeatureId.create(sourceFeature)) .setMinPixelSize(0) @@ -36,24 +37,60 @@ public void processFeature(SourceFeature sourceFeature, FeatureCollector feature if (highway.equals("motorway") || highway.equals("motorway_link")) { feat.setAttr("pmap:kind", "highway").setZoomRange(6, 15); - OsmNames.setOsmNames(feat, sourceFeature, 10); + + if (highway.equals("motorway") ) { + feat.setAttrWithMinzoom("ref_length", shield_text_length, 7); + } else { + feat.setAttrWithMinzoom("ref_length", shield_text_length, 12); + } + + OsmNames.setOsmNames(feat, sourceFeature, 11); } else if (highway.equals("trunk") || highway.equals("trunk_link") || highway.equals("primary") || highway.equals("primary_link")) { feat.setAttr("pmap:kind", "major_road").setZoomRange(7, 15); + + if (highway.equals("trunk") ) { + feat.setAttrWithMinzoom("ref_length", shield_text_length, 8); + } else if (highway.equals("primary") ) { + feat.setAttrWithMinzoom("ref_length", shield_text_length, 10); + } else if (highway.equals("trunk_link") ) { + feat.setAttrWithMinzoom("ref_length", shield_text_length, 12); + } else { + feat.setAttrWithMinzoom("ref_length", shield_text_length, 13); + } + OsmNames.setOsmNames(feat, sourceFeature, 12); } else if (highway.equals("secondary") || highway.equals("secondary_link") || highway.equals("tertiary") || highway.equals("tertiary_link")) { - feat.setAttr("pmap:kind", "medium_road").setZoomRange(9, 15); + feat.setAttr("pmap:kind", "medium_road").setZoomRange(9, 15) + .setAttrWithMinzoom("ref_length", shield_text_length, 8); + + if (highway.equals("secondary") ) { + feat.setAttrWithMinzoom("ref_length", shield_text_length, 11); + } else if (highway.equals("tertiary") ) { + feat.setAttrWithMinzoom("ref_length", shield_text_length, 12); + } else { + feat.setAttrWithMinzoom("ref_length", shield_text_length, 13); + } + OsmNames.setOsmNames(feat, sourceFeature, 13); } else if (highway.equals("residential") || highway.equals("service") || highway.equals("unclassified") || - highway.equals("road")) { + highway.equals("road") || highway.equals("raceway")) { feat.setAttr("pmap:kind", "minor_road").setZoomRange(12, 15); OsmNames.setOsmNames(feat, sourceFeature, 14); + } else if (sourceFeature.hasTag("highway","pedestrian", "track", "path", "cycleway", "bridleway", "footway", "steps", "corridor")) { + feat.setAttr("pmap:kind", "path").setZoomRange(12, 15); + feat.setAttr("pmap:kind_detail", highway).setZoomRange(12, 15); + OsmNames.setOsmNames(feat, sourceFeature, 14); } else { feat.setAttr("pmap:kind", "other").setZoomRange(14, 15); OsmNames.setOsmNames(feat, sourceFeature, 14); } + if( sourceFeature.hasTag("highway", "motorway_link", "trunk_link", "primary_link", "secondary_link", "tertiary_link" )) { + feat.setAttr("pmap:link", 1).setZoomRange(12, 15); + } + if (sourceFeature.hasTag("bridge", "yes")) { feat.setAttrWithMinzoom("pmap:level", 1, 12); } else if (sourceFeature.hasTag("tunnel", "yes")) { @@ -61,6 +98,14 @@ public void processFeature(SourceFeature sourceFeature, FeatureCollector feature } else { feat.setAttrWithMinzoom("pmap:level", 0, 12); } + + if (sourceFeature.hasTag("network", "US:US")) { + feat.setAttrWithMinzoom("network", "US:US", 7); + } else if (sourceFeature.hasTag("network", "US:I")) { + feat.setAttrWithMinzoom("network", "US:I", 7); + } else if (sourceFeature.hasTag("network")) { + feat.setAttrWithMinzoom("network", "other", 7); + } } } From 0ed7b0cdceb9d3347bae2bcbf47689c6b79b5df1 Mon Sep 17 00:00:00 2001 From: Nathaniel Kelso Date: Thu, 25 May 2023 22:29:53 -0700 Subject: [PATCH 06/28] add pier lines --- tiles/src/main/java/com/protomaps/basemap/layers/Transit.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tiles/src/main/java/com/protomaps/basemap/layers/Transit.java b/tiles/src/main/java/com/protomaps/basemap/layers/Transit.java index d21ae9d7..4706a709 100644 --- a/tiles/src/main/java/com/protomaps/basemap/layers/Transit.java +++ b/tiles/src/main/java/com/protomaps/basemap/layers/Transit.java @@ -20,6 +20,7 @@ public void processFeature(SourceFeature sf, FeatureCollector features) { // todo: exclude railway stations, levels if (sf.canBeLine() && (sf.hasTag("railway") || sf.hasTag("aerialway", "cable_car") || + sf.hasTag("highway", "pier") || sf.hasTag("route", "ferry") || sf.hasTag("aeroway", "runway", "taxiway")) && (!sf.hasTag("railway", "abandoned", "razed", "demolished", "removed", "construction", "platform", "proposed"))) { @@ -35,6 +36,7 @@ public void processFeature(SourceFeature sf, FeatureCollector features) { .setAttr("railway", sf.getString("railway")) .setAttr("route", sf.getString("route")) .setAttr("aeroway", sf.getString("aeroway")) + .setAttr("highway", sf.getString("pier")) .setAttr("service", sf.getString("service")) .setAttr("aerialway", sf.getString("aerialway")) .setAttr("network", sf.getString("network")) @@ -50,6 +52,8 @@ public void processFeature(SourceFeature sf, FeatureCollector features) { kind = "railway"; } else if (sf.hasTag("ferry")) { kind = "ferry"; + } else if (sf.hasTag("highway", "pier")) { + kind = "pier"; } else if (sf.hasTag("aerialway")) { kind = "aerialway"; } From c643234b1651f4ee8f881c2ac8acab26cd4c0969 Mon Sep 17 00:00:00 2001 From: Nathaniel Kelso Date: Thu, 25 May 2023 22:51:04 -0700 Subject: [PATCH 07/28] bug fixes --- .../basemap/layers/PhysicalLine.java | 2 +- .../com/protomaps/basemap/layers/Pois.java | 38 +++++++++---------- .../com/protomaps/basemap/layers/Roads.java | 5 ++- .../com/protomaps/basemap/layers/Water.java | 2 +- 4 files changed, 24 insertions(+), 23 deletions(-) diff --git a/tiles/src/main/java/com/protomaps/basemap/layers/PhysicalLine.java b/tiles/src/main/java/com/protomaps/basemap/layers/PhysicalLine.java index 45154633..2c61d713 100644 --- a/tiles/src/main/java/com/protomaps/basemap/layers/PhysicalLine.java +++ b/tiles/src/main/java/com/protomaps/basemap/layers/PhysicalLine.java @@ -30,7 +30,7 @@ public void processFeature(SourceFeature sf, FeatureCollector features) { .setZoomRange(12, 15); if( sf.hasTag("intermittent", "yes" ) ) { - sf.setAttr("intermittent", 1); + feat.setAttr("intermittent", 1); } String kind = "other"; diff --git a/tiles/src/main/java/com/protomaps/basemap/layers/Pois.java b/tiles/src/main/java/com/protomaps/basemap/layers/Pois.java index 23ca1da8..10ccb471 100644 --- a/tiles/src/main/java/com/protomaps/basemap/layers/Pois.java +++ b/tiles/src/main/java/com/protomaps/basemap/layers/Pois.java @@ -35,27 +35,27 @@ public void processFeature(SourceFeature sf, FeatureCollector features) { .setZoomRange(13, 15); OsmNames.setOsmNames(feature, sf, 0); - } - String kind = "other"; - if (sf.hasTag("aeroway", "aerodrome" )) { - kind = sf.getString("aeroway"); - } else if (sf.hasTag("amenity", "cafe", "college", "hospital", "library", "post_office", "school", "townhall")) { - kind = sf.getString("amenity"); - } else if (sf.hasTag("landuse", "cemetery" )) { - kind = sf.getString("landuse"); - } else if (sf.hasTag("leisure", "golf_course", "marina", "park", "stadium" )) { - kind = sf.getString("leisure"); - } else if (sf.hasTag("leisure" )) { - // This is dubious but existing behavior - kind = "park"; - } else if (sf.hasTag("shop", "grocery", "supermarket" )) { - kind = sf.getString("shop"); - } else if (sf.hasTag("tourism", "attraction", "camp_site", "hotel" )) { - kind = sf.getString("tourism"); - } + String kind = "other"; + if (sf.hasTag("aeroway", "aerodrome" )) { + kind = sf.getString("aeroway"); + } else if (sf.hasTag("amenity", "cafe", "college", "hospital", "library", "post_office", "school", "townhall")) { + kind = sf.getString("amenity"); + } else if (sf.hasTag("landuse", "cemetery" )) { + kind = sf.getString("landuse"); + } else if (sf.hasTag("leisure", "golf_course", "marina", "park", "stadium" )) { + kind = sf.getString("leisure"); + } else if (sf.hasTag("leisure" )) { + // This is dubious but existing behavior + kind = "park"; + } else if (sf.hasTag("shop", "grocery", "supermarket" )) { + kind = sf.getString("shop"); + } else if (sf.hasTag("tourism", "attraction", "camp_site", "hotel" )) { + kind = sf.getString("tourism"); + } - feature.setAttr("pmap:kind", kind); + feature.setAttr("pmap:kind", kind); + } } @Override diff --git a/tiles/src/main/java/com/protomaps/basemap/layers/Roads.java b/tiles/src/main/java/com/protomaps/basemap/layers/Roads.java index fad8ac52..1100dc9f 100644 --- a/tiles/src/main/java/com/protomaps/basemap/layers/Roads.java +++ b/tiles/src/main/java/com/protomaps/basemap/layers/Roads.java @@ -23,7 +23,8 @@ public void processFeature(SourceFeature sourceFeature, FeatureCollector feature if (sourceFeature.canBeLine() && sourceFeature.hasTag("highway") && !(sourceFeature.hasTag("highway", "proposed", "abandoned", "razed", "demolished", "removed", "construction"))) { String highway = sourceFeature.getString("highway"); - Integer shield_text_length = (shield_text == null ? null : sourceFeature.getString("ref").length()); + String shield_text = sourceFeature.getString("ref"); + Integer shield_text_length = (shield_text == null ? null : shield_text.length()); var feat = features.line("roads") .setId(FeatureId.create(sourceFeature)) .setMinPixelSize(0) @@ -33,7 +34,7 @@ public void processFeature(SourceFeature sourceFeature, FeatureCollector feature .setAttrWithMinzoom("tunnel", sourceFeature.getString("tunnel"), 12) .setAttrWithMinzoom("layer", sourceFeature.getString("layer"), 12) .setAttrWithMinzoom("oneway", sourceFeature.getString("oneway"), 14) - .setAttr("ref", sourceFeature.getString("ref")); + .setAttr("ref", shield_text); if (highway.equals("motorway") || highway.equals("motorway_link")) { feat.setAttr("pmap:kind", "highway").setZoomRange(6, 15); diff --git a/tiles/src/main/java/com/protomaps/basemap/layers/Water.java b/tiles/src/main/java/com/protomaps/basemap/layers/Water.java index 7cbdf4e3..d8fbdb77 100644 --- a/tiles/src/main/java/com/protomaps/basemap/layers/Water.java +++ b/tiles/src/main/java/com/protomaps/basemap/layers/Water.java @@ -52,7 +52,7 @@ public void processFeature(SourceFeature sf, FeatureCollector features) { .setBufferPixels(8); if( sf.hasTag("intermittent", "yes" ) ) { - sf.setAttr("intermittent", 1); + feature.setAttr("intermittent", 1); } OsmNames.setOsmNames(feature, sf, 0); From 107730120b04e51ec95a04eeec7c0252ee891a11 Mon Sep 17 00:00:00 2001 From: Nathaniel Kelso Date: Fri, 26 May 2023 00:16:50 -0700 Subject: [PATCH 08/28] move water farther down, add pier lines, add poi labels --- base/src/base_layers.ts | 49 +++++++++++++++++++++++++++++++++-------- 1 file changed, 40 insertions(+), 9 deletions(-) diff --git a/base/src/base_layers.ts b/base/src/base_layers.ts index e218d647..b49603b2 100644 --- a/base/src/base_layers.ts +++ b/base/src/base_layers.ts @@ -128,6 +128,15 @@ export function nolabels_layers(source: string, c: Theme): any[] { "fill-color": c.aerodrome, }, }, + { + id: "water", + type: "fill", + source: source, + "source-layer": "water", + paint: { + "fill-color": c.water, + }, + }, { id: "transit_runway", type: "line", @@ -154,15 +163,6 @@ export function nolabels_layers(source: string, c: Theme): any[] { "fill-color": c.runway, }, }, - { - id: "water", - type: "fill", - source: source, - "source-layer": "water", - paint: { - "fill-color": c.water, - }, - }, { id: "roads_tunnels_other_casing", type: "line", @@ -534,6 +534,20 @@ export function nolabels_layers(source: string, c: Theme): any[] { visibility: casingVisibility, }, }, + { + id: "transit_pier", + type: "line", + source: source, + "source-layer": "transit", + filter: [ + "any", + ["==", "kind", "pier"], + ], + paint: { + "line-color": c.minor, + "line-width": 1, + }, + }, { id: "roads_minor", type: "line", @@ -1142,6 +1156,23 @@ export function labels_layers(source: string, c: Theme): any[] { "text-halo-width": 1.5, }, }, + { + id: "pois", + type: "symbol", + source: source, + minzoom: 17, + "source-layer": "pois", + layout: { + "text-font": ["NotoSans-Regular"], + "text-field": ["get", "name"], + "text-size": 12, + }, + paint: { + "text-color": c.subplace_label, + "text-halo-color": c.subplace_label_halo, + "text-halo-width": 1.5, + }, + }, { id: "places_subplace", type: "symbol", From 53c8ac79e8c0dc52e366310d99b4dc99e68c97d8 Mon Sep 17 00:00:00 2001 From: Nathaniel Kelso Date: Fri, 26 May 2023 00:17:49 -0700 Subject: [PATCH 09/28] add calcualted network, clean ref (first network only) --- .../com/protomaps/basemap/layers/Roads.java | 35 +++++++++++++------ 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/tiles/src/main/java/com/protomaps/basemap/layers/Roads.java b/tiles/src/main/java/com/protomaps/basemap/layers/Roads.java index 1100dc9f..510d4c6e 100644 --- a/tiles/src/main/java/com/protomaps/basemap/layers/Roads.java +++ b/tiles/src/main/java/com/protomaps/basemap/layers/Roads.java @@ -22,9 +22,24 @@ public String name() { public void processFeature(SourceFeature sourceFeature, FeatureCollector features) { if (sourceFeature.canBeLine() && sourceFeature.hasTag("highway") && !(sourceFeature.hasTag("highway", "proposed", "abandoned", "razed", "demolished", "removed", "construction"))) { + String highway = sourceFeature.getString("highway"); String shield_text = sourceFeature.getString("ref"); + String network_val = sourceFeature.getString("network"); + shield_text = (shield_text == null ? null : shield_text.split(";")[0]); + if( shield_text != null ) { + if( shield_text.contains("US ") ) { + shield_text = shield_text.replaceAll("US ", ""); + network_val = "US:US"; + } else if( shield_text.contains("I ") ) { + shield_text = shield_text.replaceAll("I ", ""); + network_val = "US:I"; + } else { + network_val = "other"; + } + } Integer shield_text_length = (shield_text == null ? null : shield_text.length()); + var feat = features.line("roads") .setId(FeatureId.create(sourceFeature)) .setMinPixelSize(0) @@ -41,8 +56,10 @@ public void processFeature(SourceFeature sourceFeature, FeatureCollector feature if (highway.equals("motorway") ) { feat.setAttrWithMinzoom("ref_length", shield_text_length, 7); + feat.setAttrWithMinzoom("network", network_val, 7); } else { feat.setAttrWithMinzoom("ref_length", shield_text_length, 12); + feat.setAttrWithMinzoom("network", network_val, 12); } OsmNames.setOsmNames(feat, sourceFeature, 11); @@ -52,26 +69,32 @@ public void processFeature(SourceFeature sourceFeature, FeatureCollector feature if (highway.equals("trunk") ) { feat.setAttrWithMinzoom("ref_length", shield_text_length, 8); + feat.setAttrWithMinzoom("network", network_val, 8); } else if (highway.equals("primary") ) { feat.setAttrWithMinzoom("ref_length", shield_text_length, 10); + feat.setAttrWithMinzoom("network", network_val, 10); } else if (highway.equals("trunk_link") ) { feat.setAttrWithMinzoom("ref_length", shield_text_length, 12); + feat.setAttrWithMinzoom("network", network_val, 12); } else { feat.setAttrWithMinzoom("ref_length", shield_text_length, 13); + feat.setAttrWithMinzoom("network", network_val, 13); } OsmNames.setOsmNames(feat, sourceFeature, 12); } else if (highway.equals("secondary") || highway.equals("secondary_link") || highway.equals("tertiary") || highway.equals("tertiary_link")) { - feat.setAttr("pmap:kind", "medium_road").setZoomRange(9, 15) - .setAttrWithMinzoom("ref_length", shield_text_length, 8); + feat.setAttr("pmap:kind", "medium_road").setZoomRange(9, 15); if (highway.equals("secondary") ) { feat.setAttrWithMinzoom("ref_length", shield_text_length, 11); + feat.setAttrWithMinzoom("network", network_val, 11); } else if (highway.equals("tertiary") ) { feat.setAttrWithMinzoom("ref_length", shield_text_length, 12); + feat.setAttrWithMinzoom("network", network_val, 12); } else { feat.setAttrWithMinzoom("ref_length", shield_text_length, 13); + feat.setAttrWithMinzoom("network", network_val, 13); } OsmNames.setOsmNames(feat, sourceFeature, 13); @@ -99,14 +122,6 @@ public void processFeature(SourceFeature sourceFeature, FeatureCollector feature } else { feat.setAttrWithMinzoom("pmap:level", 0, 12); } - - if (sourceFeature.hasTag("network", "US:US")) { - feat.setAttrWithMinzoom("network", "US:US", 7); - } else if (sourceFeature.hasTag("network", "US:I")) { - feat.setAttrWithMinzoom("network", "US:I", 7); - } else if (sourceFeature.hasTag("network")) { - feat.setAttrWithMinzoom("network", "other", 7); - } } } From 6825103974899380cab9888029200e121d75f197 Mon Sep 17 00:00:00 2001 From: Nathaniel Kelso Date: Fri, 26 May 2023 00:18:05 -0700 Subject: [PATCH 10/28] piers are man_made (not highway) --- .../src/main/java/com/protomaps/basemap/layers/Transit.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tiles/src/main/java/com/protomaps/basemap/layers/Transit.java b/tiles/src/main/java/com/protomaps/basemap/layers/Transit.java index 4706a709..64038ad7 100644 --- a/tiles/src/main/java/com/protomaps/basemap/layers/Transit.java +++ b/tiles/src/main/java/com/protomaps/basemap/layers/Transit.java @@ -20,7 +20,7 @@ public void processFeature(SourceFeature sf, FeatureCollector features) { // todo: exclude railway stations, levels if (sf.canBeLine() && (sf.hasTag("railway") || sf.hasTag("aerialway", "cable_car") || - sf.hasTag("highway", "pier") || + sf.hasTag("man_made", "pier") || sf.hasTag("route", "ferry") || sf.hasTag("aeroway", "runway", "taxiway")) && (!sf.hasTag("railway", "abandoned", "razed", "demolished", "removed", "construction", "platform", "proposed"))) { @@ -36,7 +36,7 @@ public void processFeature(SourceFeature sf, FeatureCollector features) { .setAttr("railway", sf.getString("railway")) .setAttr("route", sf.getString("route")) .setAttr("aeroway", sf.getString("aeroway")) - .setAttr("highway", sf.getString("pier")) + .setAttr("man_made", sf.getString("pier")) .setAttr("service", sf.getString("service")) .setAttr("aerialway", sf.getString("aerialway")) .setAttr("network", sf.getString("network")) @@ -52,7 +52,7 @@ public void processFeature(SourceFeature sf, FeatureCollector features) { kind = "railway"; } else if (sf.hasTag("ferry")) { kind = "ferry"; - } else if (sf.hasTag("highway", "pier")) { + } else if (sf.hasTag("man_made", "pier")) { kind = "pier"; } else if (sf.hasTag("aerialway")) { kind = "aerialway"; From 14d08249e5d7ed53188fe0f36177801db8f1fed7 Mon Sep 17 00:00:00 2001 From: Nathaniel Kelso Date: Fri, 26 May 2023 09:40:18 -0700 Subject: [PATCH 11/28] just under industrial --- base/src/base_layers.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/base/src/base_layers.ts b/base/src/base_layers.ts index b49603b2..546ed226 100644 --- a/base/src/base_layers.ts +++ b/base/src/base_layers.ts @@ -43,6 +43,15 @@ export function nolabels_layers(source: string, c: Theme): any[] { "fill-color": c.hospital, }, }, + { + id: "water", + type: "fill", + source: source, + "source-layer": "water", + paint: { + "fill-color": c.water, + }, + }, { id: "landuse_industrial", type: "fill", @@ -128,15 +137,6 @@ export function nolabels_layers(source: string, c: Theme): any[] { "fill-color": c.aerodrome, }, }, - { - id: "water", - type: "fill", - source: source, - "source-layer": "water", - paint: { - "fill-color": c.water, - }, - }, { id: "transit_runway", type: "line", From 3b55d6a7c3468d611091fd944ef8779b8ab4c94d Mon Sep 17 00:00:00 2001 From: Nathaniel Kelso Date: Fri, 26 May 2023 09:46:33 -0700 Subject: [PATCH 12/28] draw pier poly above water --- base/src/base_layers.ts | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/base/src/base_layers.ts b/base/src/base_layers.ts index 546ed226..1e6409d8 100644 --- a/base/src/base_layers.ts +++ b/base/src/base_layers.ts @@ -43,15 +43,6 @@ export function nolabels_layers(source: string, c: Theme): any[] { "fill-color": c.hospital, }, }, - { - id: "water", - type: "fill", - source: source, - "source-layer": "water", - paint: { - "fill-color": c.water, - }, - }, { id: "landuse_industrial", type: "fill", @@ -163,6 +154,28 @@ export function nolabels_layers(source: string, c: Theme): any[] { "fill-color": c.runway, }, }, + { + id: "water", + type: "fill", + source: source, + "source-layer": "water", + paint: { + "fill-color": c.water, + }, + }, + { + id: "landuse_pier", + type: "fill", + source: source, + "source-layer": "landuse", + filter: [ + "any", + ["==", "man_made", "pier"], + ], + paint: { + "fill-color": c.earth, + }, + }, { id: "roads_tunnels_other_casing", type: "line", From d8258ee82000c6ad87d46e1b93d756cbaf6dfc44 Mon Sep 17 00:00:00 2001 From: Nathaniel Kelso Date: Fri, 26 May 2023 11:54:54 -0700 Subject: [PATCH 13/28] fix pier bug, city sort on min_zoom and fix anchor bug --- base/src/base_layers.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/base/src/base_layers.ts b/base/src/base_layers.ts index 1e6409d8..20626fbe 100644 --- a/base/src/base_layers.ts +++ b/base/src/base_layers.ts @@ -554,7 +554,7 @@ export function nolabels_layers(source: string, c: Theme): any[] { "source-layer": "transit", filter: [ "any", - ["==", "kind", "pier"], + ["==", "pmap:kind", "pier"], ], paint: { "line-color": c.minor, @@ -1231,10 +1231,16 @@ export function labels_layers(source: string, c: Theme): any[] { "source-layer": "places", filter: ["==", "pmap:kind", "city"], layout: { + "symbol-sort-key": ["number", ["get", "pmap:min_zoom"]], "text-field": "{name}", "text-font": ["NotoSans-Bold"], "text-size": ["step", ["get", "pmap:rank"], 0, 1, 12, 2, 10], - "text-variable-anchor": ["bottom-left"], + "text-anchor": { + stops: [ + [7, "left"], + [8, "center"], + ], + }, "text-radial-offset": 0.2, }, paint: { From 43eb247358156e833ee345a55e67cbce66522e9f Mon Sep 17 00:00:00 2001 From: Nathaniel Kelso Date: Fri, 26 May 2023 11:55:23 -0700 Subject: [PATCH 14/28] register Natural Earth with Places layer --- tiles/src/main/java/com/protomaps/basemap/Basemap.java | 1 + 1 file changed, 1 insertion(+) diff --git a/tiles/src/main/java/com/protomaps/basemap/Basemap.java b/tiles/src/main/java/com/protomaps/basemap/Basemap.java index 1231538b..aae2236d 100644 --- a/tiles/src/main/java/com/protomaps/basemap/Basemap.java +++ b/tiles/src/main/java/com/protomaps/basemap/Basemap.java @@ -54,6 +54,7 @@ public Basemap(Boolean useTilezen) { var place = new Places(); registerHandler(place); registerSourceHandler("osm", place); + registerSourceHandler("ne", place::processNe); var poi = new Pois(); registerHandler(poi); From 53ce164c7899a4d5a605d894a0f2c04f9adc7d47 Mon Sep 17 00:00:00 2001 From: Nathaniel Kelso Date: Fri, 26 May 2023 11:56:05 -0700 Subject: [PATCH 15/28] refactor disputed (for bug) --- .../protomaps/basemap/layers/Boundaries.java | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/tiles/src/main/java/com/protomaps/basemap/layers/Boundaries.java b/tiles/src/main/java/com/protomaps/basemap/layers/Boundaries.java index 47bd5ddc..66e18ff5 100644 --- a/tiles/src/main/java/com/protomaps/basemap/layers/Boundaries.java +++ b/tiles/src/main/java/com/protomaps/basemap/layers/Boundaries.java @@ -30,6 +30,7 @@ public void processFeature(SourceFeature sf, FeatureCollector features) { List> recs = sf.relationInfo(AdminRecord.class); if (recs.size() > 0) { OptionalInt minAdminLevel = recs.stream().mapToInt(r -> r.relation().adminLevel).min(); + OptionalInt disputed = recs.stream().mapToInt(r -> r.relation().disputed).max(); var line = features.line(this.name()).setId(FeatureId.create(sf)).setMinPixelSize(0).setAttr("pmap:min_admin_level", minAdminLevel.getAsInt()); @@ -41,15 +42,8 @@ public void processFeature(SourceFeature sf, FeatureCollector features) { line.setMinZoom(10); } - // Disputed boundaries handling - if( sf.hasTag("boundary", "disputed") ) { - line.setAttr("disputed", 1) - .setAttr("claimed_by", sf.getString("claimed_by")) - .setAttr("recognized_by", sf.getString("recognized_by")) - .setAttr("disputed_by", sf.getString("disputed_by")) - // Normally we don't export names on boundaries... But has a hack - // for styling which disputed boundaries we include them here - .setAttr("disputed_name", sf.getString("name")); + if( disputed.getAsInt() == 1 ) { + line.setAttr("disputed", 1); } } } @@ -57,11 +51,13 @@ public void processFeature(SourceFeature sf, FeatureCollector features) { @Override public List preprocessOsmRelation(OsmElement.Relation relation) { - if (relation.hasTag("type", "boundary") && relation.hasTag("boundary", "administrative")) { + if (relation.hasTag("type", "boundary") && (relation.hasTag("boundary", "administrative") || relation.hasTag("boundary", "disputed"))) { Integer adminLevel = Parse.parseIntOrNull(relation.getString("admin_level")); + Integer disputed = relation.hasTag("boundary", "disputed") ? 1 : 0; + if (adminLevel == null || adminLevel > 8) return null; - return List.of(new AdminRecord(relation.id(), adminLevel)); + return List.of(new AdminRecord(relation.id(), adminLevel, disputed)); } return null; } @@ -75,5 +71,5 @@ public List postProcess(int zoom, List i ); } - private record AdminRecord(long id, int adminLevel) implements OsmRelationInfo {} + private record AdminRecord(long id, int adminLevel, int disputed) implements OsmRelationInfo {} } From 74d457842e6e6bef3f9e38665bd7ebc3398c7cf5 Mon Sep 17 00:00:00 2001 From: Nathaniel Kelso Date: Fri, 26 May 2023 11:56:41 -0700 Subject: [PATCH 16/28] add Natural Earth places at low zooms only --- .../com/protomaps/basemap/layers/Places.java | 60 ++++++++++++++++++- 1 file changed, 57 insertions(+), 3 deletions(-) diff --git a/tiles/src/main/java/com/protomaps/basemap/layers/Places.java b/tiles/src/main/java/com/protomaps/basemap/layers/Places.java index 9b7a819a..fae2ac22 100644 --- a/tiles/src/main/java/com/protomaps/basemap/layers/Places.java +++ b/tiles/src/main/java/com/protomaps/basemap/layers/Places.java @@ -7,6 +7,7 @@ import com.onthegomap.planetiler.util.Parse; import com.protomaps.basemap.feature.FeatureId; import com.protomaps.basemap.names.OsmNames; +import com.protomaps.basemap.names.NeNames; import java.util.ArrayList; import java.util.List; @@ -17,6 +18,59 @@ public String name() { return "places"; } + public void processNe(SourceFeature sf, FeatureCollector features) { + var sourceLayer = sf.getSourceLayer(); + var kind = ""; + var kind_detail = ""; + + var theme_min_zoom = 0; + var theme_max_zoom = 0; + if (sourceLayer.equals("ne_10m_populated_places")) { + theme_min_zoom = 1; + theme_max_zoom = 8; + } + + // Test for props because of Natural Earth funk + if( sf.isPoint() && sf.hasTag("featurecla") && sf.hasTag("min_zoom" ) ) { + switch (sf.getString("featurecla")) { + case "Admin-0 capital": + case "Admin-0 capital alt": + case "Admin-0 region capital": + kind = "city"; + break; + case "Admin-1 capital": + case "Admin-1 region capital": + kind = "city"; + break; + case "Populated place": + kind = "city"; + break; + case "Historic place": + kind = "locality"; + kind_detail = "hamlet"; + break; + case "Scientific station": + kind = "locality"; + kind_detail = "scientific_station"; + break; + } + } + + if( kind != "" ) { + var feat = features.point(this.name()) + .setAttr("name", sf.getString("name")) + .setAttr("pmap:min_zoom", sf.getLong("min_zoom")) + .setZoomRange(sf.getString("min_zoom") == null ? theme_min_zoom : (int)Double.parseDouble(sf.getString("min_zoom")), theme_max_zoom) + .setAttr("pmap:kind", kind) + .setAttr("pmap:kind_detail", kind_detail) + .setAttr("population", sf.getString("pop_max")) + .setAttr("population_rank", sf.getString("rank_max")) + .setAttr("wikidata_id", sf.getString("wikidata")) + .setBufferPixels(128); + + NeNames.setNeNames(feat, sf, 0); + } + } @Override public void processFeature(SourceFeature sf, FeatureCollector features) { if (sf.isPoint() && @@ -32,13 +86,13 @@ public void processFeature(SourceFeature sf, FeatureCollector features) { if (sf.hasTag("place", "country")) { feat.setAttr("pmap:kind", "country") - .setZoomRange(0, 15); + .setZoomRange(0, 9); } else if (sf.hasTag("place", "state", "province")) { feat.setAttr("pmap:kind", "state") - .setZoomRange(4, 15); + .setZoomRange(4, 11); } else if (sf.hasTag("place", "city")) { feat.setAttr("pmap:kind", "city") - .setZoomRange(4, 15); + .setZoomRange(8, 15); if ( population.equals(0) ) { population = 10000; } From 347f1214526fa749abad925e048e36bc92a24456 Mon Sep 17 00:00:00 2001 From: Nathaniel Kelso Date: Fri, 26 May 2023 11:57:22 -0700 Subject: [PATCH 17/28] allow polygon centroid POI labels --- .../com/protomaps/basemap/layers/Pois.java | 64 +++++++++++++------ 1 file changed, 44 insertions(+), 20 deletions(-) diff --git a/tiles/src/main/java/com/protomaps/basemap/layers/Pois.java b/tiles/src/main/java/com/protomaps/basemap/layers/Pois.java index 10ccb471..b7e909e5 100644 --- a/tiles/src/main/java/com/protomaps/basemap/layers/Pois.java +++ b/tiles/src/main/java/com/protomaps/basemap/layers/Pois.java @@ -17,25 +17,14 @@ public String name() { @Override public void processFeature(SourceFeature sf, FeatureCollector features) { - if (sf.isPoint() && (sf.hasTag("amenity") || - sf.hasTag("shop") || - sf.hasTag("tourism") || - sf.hasTag("leisure") || - sf.hasTag("aeroway", "aerodrome") || - sf.hasTag("railway", "station"))) { - var feature = features.point(this.name()) - .setId(FeatureId.create(sf)) - .setAttr("amenity", sf.getString("amenity")) - .setAttr("shop", sf.getString("shop")) - .setAttr("railway", sf.getString("railway")) - .setAttr("cuisine", sf.getString("cuisine")) - .setAttr("religion", sf.getString("religion")) - .setAttr("tourism", sf.getString("tourism")) - .setAttr("iata", sf.getString("iata")) - .setZoomRange(13, 15); - - OsmNames.setOsmNames(feature, sf, 0); - + if( !sf.canBeLine() && (sf.isPoint() || sf.canBePolygon()) + && (sf.hasTag("amenity") || + sf.hasTag("shop") || + sf.hasTag("tourism") || + sf.hasTag("leisure") || + sf.hasTag("aeroway", "aerodrome") || + sf.hasTag("railway", "station"))) + { String kind = "other"; if (sf.hasTag("aeroway", "aerodrome" )) { kind = sf.getString("aeroway"); @@ -54,7 +43,42 @@ public void processFeature(SourceFeature sf, FeatureCollector features) { kind = sf.getString("tourism"); } - feature.setAttr("pmap:kind", kind); + // try first for polygon -> point representations + if (sf.canBePolygon()) { + var poly_label_position = features.pointOnSurface(this.name()) + // all POIs should receive their IDs at all zooms + // (there is no merging of POIs like with lines and polygons in other layers) + .setId(FeatureId.create(sf)) + .setAttr("amenity", sf.getString("amenity")) + .setAttr("shop", sf.getString("shop")) + .setAttr("railway", sf.getString("railway")) + .setAttr("cuisine", sf.getString("cuisine")) + .setAttr("religion", sf.getString("religion")) + .setAttr("tourism", sf.getString("tourism")) + .setAttr("iata", sf.getString("iata")) + .setZoomRange(13, 15) + .setBufferPixels(128); + + OsmNames.setOsmNames(poly_label_position, sf, 0); + + poly_label_position.setAttr("pmap:kind", kind); + } else if (sf.isPoint()) { + var point_feature = features.point(this.name()) + .setId(FeatureId.create(sf)) + .setAttr("amenity", sf.getString("amenity")) + .setAttr("shop", sf.getString("shop")) + .setAttr("railway", sf.getString("railway")) + .setAttr("cuisine", sf.getString("cuisine")) + .setAttr("religion", sf.getString("religion")) + .setAttr("tourism", sf.getString("tourism")) + .setAttr("iata", sf.getString("iata")) + .setZoomRange(13, 15) + .setBufferPixels(128); + + OsmNames.setOsmNames(point_feature, sf, 0); + + point_feature.setAttr("pmap:kind", kind); + } } } From 00792336349eba301a4994e727f899edd1722a20 Mon Sep 17 00:00:00 2001 From: Nathaniel Kelso Date: Fri, 26 May 2023 11:58:07 -0700 Subject: [PATCH 18/28] strip whitespace from ref, and only set ref by zoom and kind --- .../com/protomaps/basemap/layers/Roads.java | 50 +++++++++++-------- 1 file changed, 29 insertions(+), 21 deletions(-) diff --git a/tiles/src/main/java/com/protomaps/basemap/layers/Roads.java b/tiles/src/main/java/com/protomaps/basemap/layers/Roads.java index 510d4c6e..788338ff 100644 --- a/tiles/src/main/java/com/protomaps/basemap/layers/Roads.java +++ b/tiles/src/main/java/com/protomaps/basemap/layers/Roads.java @@ -26,7 +26,7 @@ public void processFeature(SourceFeature sourceFeature, FeatureCollector feature String highway = sourceFeature.getString("highway"); String shield_text = sourceFeature.getString("ref"); String network_val = sourceFeature.getString("network"); - shield_text = (shield_text == null ? null : shield_text.split(";")[0]); + shield_text = (shield_text == null ? null : shield_text.split(";")[0].replaceAll("\\s", "")); if( shield_text != null ) { if( shield_text.contains("US ") ) { shield_text = shield_text.replaceAll("US ", ""); @@ -48,18 +48,19 @@ public void processFeature(SourceFeature sourceFeature, FeatureCollector feature .setAttrWithMinzoom("bridge", sourceFeature.getString("bridge"), 12) .setAttrWithMinzoom("tunnel", sourceFeature.getString("tunnel"), 12) .setAttrWithMinzoom("layer", sourceFeature.getString("layer"), 12) - .setAttrWithMinzoom("oneway", sourceFeature.getString("oneway"), 14) - .setAttr("ref", shield_text); + .setAttrWithMinzoom("oneway", sourceFeature.getString("oneway"), 14); if (highway.equals("motorway") || highway.equals("motorway_link")) { feat.setAttr("pmap:kind", "highway").setZoomRange(6, 15); if (highway.equals("motorway") ) { - feat.setAttrWithMinzoom("ref_length", shield_text_length, 7); - feat.setAttrWithMinzoom("network", network_val, 7); + feat.setAttrWithMinzoom("ref", shield_text, 7) + .setAttrWithMinzoom("ref_length", shield_text_length, 7) + .setAttrWithMinzoom("network", network_val, 7); } else { - feat.setAttrWithMinzoom("ref_length", shield_text_length, 12); - feat.setAttrWithMinzoom("network", network_val, 12); + feat.setAttrWithMinzoom("ref", shield_text, 12) + .setAttrWithMinzoom("ref_length", shield_text_length, 12) + .setAttrWithMinzoom("network", network_val, 12); } OsmNames.setOsmNames(feat, sourceFeature, 11); @@ -68,17 +69,21 @@ public void processFeature(SourceFeature sourceFeature, FeatureCollector feature feat.setAttr("pmap:kind", "major_road").setZoomRange(7, 15); if (highway.equals("trunk") ) { - feat.setAttrWithMinzoom("ref_length", shield_text_length, 8); - feat.setAttrWithMinzoom("network", network_val, 8); + feat.setAttrWithMinzoom("ref", shield_text, 8) + .setAttrWithMinzoom("ref_length", shield_text_length, 8) + .setAttrWithMinzoom("network", network_val, 8); } else if (highway.equals("primary") ) { - feat.setAttrWithMinzoom("ref_length", shield_text_length, 10); - feat.setAttrWithMinzoom("network", network_val, 10); + feat.setAttrWithMinzoom("ref", shield_text, 10) + .setAttrWithMinzoom("ref_length", shield_text_length, 10) + .setAttrWithMinzoom("network", network_val, 10); } else if (highway.equals("trunk_link") ) { - feat.setAttrWithMinzoom("ref_length", shield_text_length, 12); - feat.setAttrWithMinzoom("network", network_val, 12); + feat.setAttrWithMinzoom("ref", shield_text, 12) + .setAttrWithMinzoom("ref_length", shield_text_length, 12) + .setAttrWithMinzoom("network", network_val, 12); } else { - feat.setAttrWithMinzoom("ref_length", shield_text_length, 13); - feat.setAttrWithMinzoom("network", network_val, 13); + feat.setAttrWithMinzoom("ref", shield_text, 13) + .setAttrWithMinzoom("ref_length", shield_text_length, 13) + .setAttrWithMinzoom("network", network_val, 13); } OsmNames.setOsmNames(feat, sourceFeature, 12); @@ -87,14 +92,17 @@ public void processFeature(SourceFeature sourceFeature, FeatureCollector feature feat.setAttr("pmap:kind", "medium_road").setZoomRange(9, 15); if (highway.equals("secondary") ) { - feat.setAttrWithMinzoom("ref_length", shield_text_length, 11); - feat.setAttrWithMinzoom("network", network_val, 11); + feat.setAttrWithMinzoom("ref", shield_text, 11) + .setAttrWithMinzoom("ref_length", shield_text_length, 11) + .setAttrWithMinzoom("network", network_val, 11); } else if (highway.equals("tertiary") ) { - feat.setAttrWithMinzoom("ref_length", shield_text_length, 12); - feat.setAttrWithMinzoom("network", network_val, 12); + feat.setAttrWithMinzoom("ref", shield_text, 12) + .setAttrWithMinzoom("ref_length", shield_text_length, 12) + .setAttrWithMinzoom("network", network_val, 12); } else { - feat.setAttrWithMinzoom("ref_length", shield_text_length, 13); - feat.setAttrWithMinzoom("network", network_val, 13); + feat.setAttrWithMinzoom("ref", shield_text, 13) + .setAttrWithMinzoom("ref_length", shield_text_length, 13) + .setAttrWithMinzoom("network", network_val, 13); } OsmNames.setOsmNames(feat, sourceFeature, 13); From e675da6d00cf4693cf46a9879c54a7f7a7d1509d Mon Sep 17 00:00:00 2001 From: Nathaniel Kelso Date: Fri, 26 May 2023 11:58:29 -0700 Subject: [PATCH 19/28] add NeNames processing class --- .../com/protomaps/basemap/names/NeNames.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 tiles/src/main/java/com/protomaps/basemap/names/NeNames.java diff --git a/tiles/src/main/java/com/protomaps/basemap/names/NeNames.java b/tiles/src/main/java/com/protomaps/basemap/names/NeNames.java new file mode 100644 index 00000000..6c795794 --- /dev/null +++ b/tiles/src/main/java/com/protomaps/basemap/names/NeNames.java @@ -0,0 +1,21 @@ +package com.protomaps.basemap.names; + +import com.onthegomap.planetiler.FeatureCollector; +import com.onthegomap.planetiler.reader.SourceFeature; +import java.util.Map; + +public class NeNames { + public static FeatureCollector.Feature setNeNames(FeatureCollector.Feature feature, SourceFeature source, + int minzoom) { + for (Map.Entry tag : source.tags().entrySet()) { + var key = tag.getKey(); + if (key.equals("name") ) { + feature.setAttrWithMinzoom(key, source.getTag(key), minzoom); + } else if ( key.startsWith("name_")) { + feature.setAttrWithMinzoom(key.replace("_", ":"), source.getTag(key), minzoom); + } + } + + return feature; + } +} \ No newline at end of file From 1e2b1c52c59e2b0b4f1755b989045724b333d218 Mon Sep 17 00:00:00 2001 From: Nathaniel Kelso Date: Fri, 26 May 2023 12:21:31 -0700 Subject: [PATCH 20/28] even if an other road type, still export ref at higher zooms --- .../java/com/protomaps/basemap/layers/Roads.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tiles/src/main/java/com/protomaps/basemap/layers/Roads.java b/tiles/src/main/java/com/protomaps/basemap/layers/Roads.java index 788338ff..c0e7a757 100644 --- a/tiles/src/main/java/com/protomaps/basemap/layers/Roads.java +++ b/tiles/src/main/java/com/protomaps/basemap/layers/Roads.java @@ -104,18 +104,20 @@ public void processFeature(SourceFeature sourceFeature, FeatureCollector feature .setAttrWithMinzoom("ref_length", shield_text_length, 13) .setAttrWithMinzoom("network", network_val, 13); } - OsmNames.setOsmNames(feat, sourceFeature, 13); } else if (highway.equals("residential") || highway.equals("service") || highway.equals("unclassified") || highway.equals("road") || highway.equals("raceway")) { - feat.setAttr("pmap:kind", "minor_road").setZoomRange(12, 15); + feat.setAttrWithMinzoom("ref", shield_text, 12) + .setAttr("pmap:kind", "minor_road").setZoomRange(12, 15); OsmNames.setOsmNames(feat, sourceFeature, 14); } else if (sourceFeature.hasTag("highway","pedestrian", "track", "path", "cycleway", "bridleway", "footway", "steps", "corridor")) { - feat.setAttr("pmap:kind", "path").setZoomRange(12, 15); - feat.setAttr("pmap:kind_detail", highway).setZoomRange(12, 15); + feat.setAttrWithMinzoom("ref", shield_text, 12) + .setAttr("pmap:kind", "path").setZoomRange(12, 15) + .setAttr("pmap:kind_detail", highway).setZoomRange(12, 15); OsmNames.setOsmNames(feat, sourceFeature, 14); } else { - feat.setAttr("pmap:kind", "other").setZoomRange(14, 15); + feat.setAttrWithMinzoom("ref", shield_text, 12) + .setAttr("pmap:kind", "other").setZoomRange(14, 15); OsmNames.setOsmNames(feat, sourceFeature, 14); } From 71c827a3a47dc2b042fb73efb4ca9b198a9070c8 Mon Sep 17 00:00:00 2001 From: Nathaniel Kelso Date: Fri, 26 May 2023 12:24:25 -0700 Subject: [PATCH 21/28] even if an other road type, still export ref at higher zooms --- .../com/protomaps/basemap/layers/Roads.java | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/tiles/src/main/java/com/protomaps/basemap/layers/Roads.java b/tiles/src/main/java/com/protomaps/basemap/layers/Roads.java index c0e7a757..7f52d850 100644 --- a/tiles/src/main/java/com/protomaps/basemap/layers/Roads.java +++ b/tiles/src/main/java/com/protomaps/basemap/layers/Roads.java @@ -107,17 +107,23 @@ public void processFeature(SourceFeature sourceFeature, FeatureCollector feature OsmNames.setOsmNames(feat, sourceFeature, 13); } else if (highway.equals("residential") || highway.equals("service") || highway.equals("unclassified") || highway.equals("road") || highway.equals("raceway")) { - feat.setAttrWithMinzoom("ref", shield_text, 12) - .setAttr("pmap:kind", "minor_road").setZoomRange(12, 15); + feat.setAttr("pmap:kind", "minor_road").setZoomRange(12, 15) + .setAttrWithMinzoom("ref", shield_text, 12) + .setAttrWithMinzoom("ref_length", shield_text_length, 12) + .setAttrWithMinzoom("network", network_val, 12); OsmNames.setOsmNames(feat, sourceFeature, 14); } else if (sourceFeature.hasTag("highway","pedestrian", "track", "path", "cycleway", "bridleway", "footway", "steps", "corridor")) { - feat.setAttrWithMinzoom("ref", shield_text, 12) - .setAttr("pmap:kind", "path").setZoomRange(12, 15) - .setAttr("pmap:kind_detail", highway).setZoomRange(12, 15); + feat.setAttr("pmap:kind_detail", highway).setZoomRange(12, 15) + .setAttrWithMinzoom("ref", shield_text, 12) + .setAttrWithMinzoom("ref_length", shield_text_length, 12) + .setAttrWithMinzoom("network", network_val, 12) + .setAttr("pmap:kind", "path").setZoomRange(12, 15); OsmNames.setOsmNames(feat, sourceFeature, 14); } else { - feat.setAttrWithMinzoom("ref", shield_text, 12) - .setAttr("pmap:kind", "other").setZoomRange(14, 15); + feat.setAttr("pmap:kind", "other").setZoomRange(14, 15) + .setAttrWithMinzoom("ref", shield_text, 14) + .setAttrWithMinzoom("ref_length", shield_text_length, 14) + .setAttrWithMinzoom("network", network_val, 14); OsmNames.setOsmNames(feat, sourceFeature, 14); } From 4db8422a887e04508ef6dfe4d9e914c8b0499839 Mon Sep 17 00:00:00 2001 From: Nathaniel Kelso Date: Fri, 26 May 2023 12:51:21 -0700 Subject: [PATCH 22/28] strip after network calc --- tiles/src/main/java/com/protomaps/basemap/layers/Roads.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tiles/src/main/java/com/protomaps/basemap/layers/Roads.java b/tiles/src/main/java/com/protomaps/basemap/layers/Roads.java index 7f52d850..2dc0e626 100644 --- a/tiles/src/main/java/com/protomaps/basemap/layers/Roads.java +++ b/tiles/src/main/java/com/protomaps/basemap/layers/Roads.java @@ -26,7 +26,7 @@ public void processFeature(SourceFeature sourceFeature, FeatureCollector feature String highway = sourceFeature.getString("highway"); String shield_text = sourceFeature.getString("ref"); String network_val = sourceFeature.getString("network"); - shield_text = (shield_text == null ? null : shield_text.split(";")[0].replaceAll("\\s", "")); + shield_text = (shield_text == null ? null : shield_text.split(";")[0]); if( shield_text != null ) { if( shield_text.contains("US ") ) { shield_text = shield_text.replaceAll("US ", ""); @@ -38,6 +38,7 @@ public void processFeature(SourceFeature sourceFeature, FeatureCollector feature network_val = "other"; } } + shield_text = (shield_text == null ? null : shield_text..replaceAll("\\s", "")); Integer shield_text_length = (shield_text == null ? null : shield_text.length()); var feat = features.line("roads") From b22c1eae597512da20eb9aba4bc79745625667bd Mon Sep 17 00:00:00 2001 From: Nathaniel Kelso Date: Fri, 26 May 2023 14:29:01 -0700 Subject: [PATCH 23/28] typo --- tiles/src/main/java/com/protomaps/basemap/layers/Roads.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tiles/src/main/java/com/protomaps/basemap/layers/Roads.java b/tiles/src/main/java/com/protomaps/basemap/layers/Roads.java index 2dc0e626..0dffddd4 100644 --- a/tiles/src/main/java/com/protomaps/basemap/layers/Roads.java +++ b/tiles/src/main/java/com/protomaps/basemap/layers/Roads.java @@ -38,7 +38,7 @@ public void processFeature(SourceFeature sourceFeature, FeatureCollector feature network_val = "other"; } } - shield_text = (shield_text == null ? null : shield_text..replaceAll("\\s", "")); + shield_text = (shield_text == null ? null : shield_text.replaceAll("\\s", "")); Integer shield_text_length = (shield_text == null ? null : shield_text.length()); var feat = features.line("roads") From 8252e77dd8cd258238a856546fdddf21e472f28e Mon Sep 17 00:00:00 2001 From: Nathaniel Kelso Date: Fri, 26 May 2023 14:58:09 -0700 Subject: [PATCH 24/28] improve pier widths --- base/src/base_layers.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/base/src/base_layers.ts b/base/src/base_layers.ts index 20626fbe..fb6ccefa 100644 --- a/base/src/base_layers.ts +++ b/base/src/base_layers.ts @@ -558,7 +558,17 @@ export function nolabels_layers(source: string, c: Theme): any[] { ], paint: { "line-color": c.minor, - "line-width": 1, + "line-width": [ + "interpolate", + ["exponential", 1.6], + ["zoom"], + 12, + 0, + 12.5, + 0.5, + 20, + 16, + ], }, }, { From aeef7ac5dab9a570f1c8faeae0e713ee4d07db8a Mon Sep 17 00:00:00 2001 From: Brandon Liu Date: Mon, 29 May 2023 21:51:10 +0800 Subject: [PATCH 25/28] formatting --- .../protomaps/basemap/layers/Boundaries.java | 5 +- .../basemap/layers/PhysicalLine.java | 2 +- .../com/protomaps/basemap/layers/Places.java | 79 +++++++++--------- .../com/protomaps/basemap/layers/Pois.java | 72 ++++++++--------- .../com/protomaps/basemap/layers/Roads.java | 80 ++++++++++--------- .../com/protomaps/basemap/layers/Water.java | 2 +- .../com/protomaps/basemap/names/NeNames.java | 26 +++--- 7 files changed, 135 insertions(+), 131 deletions(-) diff --git a/tiles/src/main/java/com/protomaps/basemap/layers/Boundaries.java b/tiles/src/main/java/com/protomaps/basemap/layers/Boundaries.java index 66e18ff5..e52d3678 100644 --- a/tiles/src/main/java/com/protomaps/basemap/layers/Boundaries.java +++ b/tiles/src/main/java/com/protomaps/basemap/layers/Boundaries.java @@ -42,7 +42,7 @@ public void processFeature(SourceFeature sf, FeatureCollector features) { line.setMinZoom(10); } - if( disputed.getAsInt() == 1 ) { + if (disputed.getAsInt() == 1) { line.setAttr("disputed", 1); } } @@ -51,7 +51,8 @@ public void processFeature(SourceFeature sf, FeatureCollector features) { @Override public List preprocessOsmRelation(OsmElement.Relation relation) { - if (relation.hasTag("type", "boundary") && (relation.hasTag("boundary", "administrative") || relation.hasTag("boundary", "disputed"))) { + if (relation.hasTag("type", "boundary") && + (relation.hasTag("boundary", "administrative") || relation.hasTag("boundary", "disputed"))) { Integer adminLevel = Parse.parseIntOrNull(relation.getString("admin_level")); Integer disputed = relation.hasTag("boundary", "disputed") ? 1 : 0; diff --git a/tiles/src/main/java/com/protomaps/basemap/layers/PhysicalLine.java b/tiles/src/main/java/com/protomaps/basemap/layers/PhysicalLine.java index 2c61d713..81557200 100644 --- a/tiles/src/main/java/com/protomaps/basemap/layers/PhysicalLine.java +++ b/tiles/src/main/java/com/protomaps/basemap/layers/PhysicalLine.java @@ -29,7 +29,7 @@ public void processFeature(SourceFeature sf, FeatureCollector features) { .setAttrWithMinzoom("layer", sf.getString("layer"), 12) .setZoomRange(12, 15); - if( sf.hasTag("intermittent", "yes" ) ) { + if (sf.hasTag("intermittent", "yes")) { feat.setAttr("intermittent", 1); } diff --git a/tiles/src/main/java/com/protomaps/basemap/layers/Places.java b/tiles/src/main/java/com/protomaps/basemap/layers/Places.java index fae2ac22..0d7bbece 100644 --- a/tiles/src/main/java/com/protomaps/basemap/layers/Places.java +++ b/tiles/src/main/java/com/protomaps/basemap/layers/Places.java @@ -4,10 +4,9 @@ import com.onthegomap.planetiler.ForwardingProfile; import com.onthegomap.planetiler.VectorTile; import com.onthegomap.planetiler.reader.SourceFeature; -import com.onthegomap.planetiler.util.Parse; import com.protomaps.basemap.feature.FeatureId; -import com.protomaps.basemap.names.OsmNames; import com.protomaps.basemap.names.NeNames; +import com.protomaps.basemap.names.OsmNames; import java.util.ArrayList; import java.util.List; @@ -31,7 +30,7 @@ public void processNe(SourceFeature sf, FeatureCollector features) { } // Test for props because of Natural Earth funk - if( sf.isPoint() && sf.hasTag("featurecla") && sf.hasTag("min_zoom" ) ) { + if (sf.isPoint() && sf.hasTag("featurecla") && sf.hasTag("min_zoom")) { switch (sf.getString("featurecla")) { case "Admin-0 capital": case "Admin-0 capital alt": @@ -56,26 +55,30 @@ public void processNe(SourceFeature sf, FeatureCollector features) { } } - if( kind != "" ) { + if (kind != "") { var feat = features.point(this.name()) - .setAttr("name", sf.getString("name")) - .setAttr("pmap:min_zoom", sf.getLong("min_zoom")) - .setZoomRange(sf.getString("min_zoom") == null ? theme_min_zoom : (int)Double.parseDouble(sf.getString("min_zoom")), theme_max_zoom) - .setAttr("pmap:kind", kind) - .setAttr("pmap:kind_detail", kind_detail) - .setAttr("population", sf.getString("pop_max")) - .setAttr("population_rank", sf.getString("rank_max")) - .setAttr("wikidata_id", sf.getString("wikidata")) - .setBufferPixels(128); + .setAttr("name", sf.getString("name")) + .setAttr("pmap:min_zoom", sf.getLong("min_zoom")) + .setZoomRange( + sf.getString("min_zoom") == null ? theme_min_zoom : (int) Double.parseDouble(sf.getString("min_zoom")), + theme_max_zoom) + .setAttr("pmap:kind", kind) + .setAttr("pmap:kind_detail", kind_detail) + .setAttr("population", sf.getString("pop_max")) + .setAttr("population_rank", sf.getString("rank_max")) + .setAttr("wikidata_id", sf.getString("wikidata")) + .setBufferPixels(128); NeNames.setNeNames(feat, sf, 0); } } + @Override public void processFeature(SourceFeature sf, FeatureCollector features) { if (sf.isPoint() && (sf.hasTag("place", "suburb", "town", "village", "neighbourhood", "city", "country", "state", "province"))) { - Integer population = sf.getString("population") == null ? 0 : (int)Double.parseDouble(sf.getString("population")); + Integer population = + sf.getString("population") == null ? 0 : (int) Double.parseDouble(sf.getString("population")); var feat = features.point(this.name()) .setId(FeatureId.create(sf)) .setAttr("place", sf.getString("place")) @@ -93,24 +96,24 @@ public void processFeature(SourceFeature sf, FeatureCollector features) { } else if (sf.hasTag("place", "city")) { feat.setAttr("pmap:kind", "city") .setZoomRange(8, 15); - if ( population.equals(0) ) { + if (population.equals(0)) { population = 10000; } } else if (sf.hasTag("place", "town")) { feat.setAttr("pmap:kind", "neighbourhood") .setZoomRange(8, 15); - if ( population.equals(0) ) { + if (population.equals(0)) { population = 5000; } } else if (sf.hasTag("place", "village")) { feat.setAttr("pmap:kind", "neighbourhood") - .setZoomRange(10, 15); - if ( population.equals(0) ) { + .setZoomRange(10, 15); + if (population.equals(0)) { population = 2000; } } else if (sf.hasTag("place", "suburb")) { feat.setAttr("pmap:kind", "neighbourhood") - .setZoomRange(8, 15); + .setZoomRange(8, 15); } else { feat.setAttr("pmap:kind", "neighbourhood") .setZoomRange(12, 15); @@ -127,27 +130,27 @@ public void processFeature(SourceFeature sf, FeatureCollector features) { Integer population_rank = 0; int[] pop_breaks = { - 1000000000, - 100000000, - 50000000, - 20000000, - 10000000, - 5000000, - 1000000, - 500000, - 200000, - 100000, - 50000, - 20000, - 10000, - 5000, - 2000, - 1000, - 200, - 0}; + 1000000000, + 100000000, + 50000000, + 20000000, + 10000000, + 5000000, + 1000000, + 500000, + 200000, + 100000, + 50000, + 20000, + 10000, + 5000, + 2000, + 1000, + 200, + 0}; for (int i = 0; i < pop_breaks.length; i++) { - if( population >= pop_breaks[i]) { + if (population >= pop_breaks[i]) { population_rank = pop_breaks.length - i; } } diff --git a/tiles/src/main/java/com/protomaps/basemap/layers/Pois.java b/tiles/src/main/java/com/protomaps/basemap/layers/Pois.java index b7e909e5..245751e8 100644 --- a/tiles/src/main/java/com/protomaps/basemap/layers/Pois.java +++ b/tiles/src/main/java/com/protomaps/basemap/layers/Pois.java @@ -17,63 +17,61 @@ public String name() { @Override public void processFeature(SourceFeature sf, FeatureCollector features) { - if( !sf.canBeLine() && (sf.isPoint() || sf.canBePolygon()) - && (sf.hasTag("amenity") || - sf.hasTag("shop") || - sf.hasTag("tourism") || - sf.hasTag("leisure") || - sf.hasTag("aeroway", "aerodrome") || - sf.hasTag("railway", "station"))) - { + if (!sf.canBeLine() && (sf.isPoint() || sf.canBePolygon()) && (sf.hasTag("amenity") || + sf.hasTag("shop") || + sf.hasTag("tourism") || + sf.hasTag("leisure") || + sf.hasTag("aeroway", "aerodrome") || + sf.hasTag("railway", "station"))) { String kind = "other"; - if (sf.hasTag("aeroway", "aerodrome" )) { + if (sf.hasTag("aeroway", "aerodrome")) { kind = sf.getString("aeroway"); - } else if (sf.hasTag("amenity", "cafe", "college", "hospital", "library", "post_office", "school", "townhall")) { + } else if (sf.hasTag("amenity", "cafe", "college", "hospital", "library", "post_office", "school", "townhall")) { kind = sf.getString("amenity"); - } else if (sf.hasTag("landuse", "cemetery" )) { + } else if (sf.hasTag("landuse", "cemetery")) { kind = sf.getString("landuse"); - } else if (sf.hasTag("leisure", "golf_course", "marina", "park", "stadium" )) { + } else if (sf.hasTag("leisure", "golf_course", "marina", "park", "stadium")) { kind = sf.getString("leisure"); - } else if (sf.hasTag("leisure" )) { + } else if (sf.hasTag("leisure")) { // This is dubious but existing behavior kind = "park"; - } else if (sf.hasTag("shop", "grocery", "supermarket" )) { + } else if (sf.hasTag("shop", "grocery", "supermarket")) { kind = sf.getString("shop"); - } else if (sf.hasTag("tourism", "attraction", "camp_site", "hotel" )) { + } else if (sf.hasTag("tourism", "attraction", "camp_site", "hotel")) { kind = sf.getString("tourism"); } // try first for polygon -> point representations if (sf.canBePolygon()) { var poly_label_position = features.pointOnSurface(this.name()) - // all POIs should receive their IDs at all zooms - // (there is no merging of POIs like with lines and polygons in other layers) - .setId(FeatureId.create(sf)) - .setAttr("amenity", sf.getString("amenity")) - .setAttr("shop", sf.getString("shop")) - .setAttr("railway", sf.getString("railway")) - .setAttr("cuisine", sf.getString("cuisine")) - .setAttr("religion", sf.getString("religion")) - .setAttr("tourism", sf.getString("tourism")) - .setAttr("iata", sf.getString("iata")) - .setZoomRange(13, 15) - .setBufferPixels(128); + // all POIs should receive their IDs at all zooms + // (there is no merging of POIs like with lines and polygons in other layers) + .setId(FeatureId.create(sf)) + .setAttr("amenity", sf.getString("amenity")) + .setAttr("shop", sf.getString("shop")) + .setAttr("railway", sf.getString("railway")) + .setAttr("cuisine", sf.getString("cuisine")) + .setAttr("religion", sf.getString("religion")) + .setAttr("tourism", sf.getString("tourism")) + .setAttr("iata", sf.getString("iata")) + .setZoomRange(13, 15) + .setBufferPixels(128); OsmNames.setOsmNames(poly_label_position, sf, 0); poly_label_position.setAttr("pmap:kind", kind); } else if (sf.isPoint()) { var point_feature = features.point(this.name()) - .setId(FeatureId.create(sf)) - .setAttr("amenity", sf.getString("amenity")) - .setAttr("shop", sf.getString("shop")) - .setAttr("railway", sf.getString("railway")) - .setAttr("cuisine", sf.getString("cuisine")) - .setAttr("religion", sf.getString("religion")) - .setAttr("tourism", sf.getString("tourism")) - .setAttr("iata", sf.getString("iata")) - .setZoomRange(13, 15) - .setBufferPixels(128); + .setId(FeatureId.create(sf)) + .setAttr("amenity", sf.getString("amenity")) + .setAttr("shop", sf.getString("shop")) + .setAttr("railway", sf.getString("railway")) + .setAttr("cuisine", sf.getString("cuisine")) + .setAttr("religion", sf.getString("religion")) + .setAttr("tourism", sf.getString("tourism")) + .setAttr("iata", sf.getString("iata")) + .setZoomRange(13, 15) + .setBufferPixels(128); OsmNames.setOsmNames(point_feature, sf, 0); diff --git a/tiles/src/main/java/com/protomaps/basemap/layers/Roads.java b/tiles/src/main/java/com/protomaps/basemap/layers/Roads.java index 0dffddd4..b1af50ab 100644 --- a/tiles/src/main/java/com/protomaps/basemap/layers/Roads.java +++ b/tiles/src/main/java/com/protomaps/basemap/layers/Roads.java @@ -27,11 +27,11 @@ public void processFeature(SourceFeature sourceFeature, FeatureCollector feature String shield_text = sourceFeature.getString("ref"); String network_val = sourceFeature.getString("network"); shield_text = (shield_text == null ? null : shield_text.split(";")[0]); - if( shield_text != null ) { - if( shield_text.contains("US ") ) { + if (shield_text != null) { + if (shield_text.contains("US ")) { shield_text = shield_text.replaceAll("US ", ""); network_val = "US:US"; - } else if( shield_text.contains("I ") ) { + } else if (shield_text.contains("I ")) { shield_text = shield_text.replaceAll("I ", ""); network_val = "US:I"; } else { @@ -54,14 +54,14 @@ public void processFeature(SourceFeature sourceFeature, FeatureCollector feature if (highway.equals("motorway") || highway.equals("motorway_link")) { feat.setAttr("pmap:kind", "highway").setZoomRange(6, 15); - if (highway.equals("motorway") ) { + if (highway.equals("motorway")) { feat.setAttrWithMinzoom("ref", shield_text, 7) - .setAttrWithMinzoom("ref_length", shield_text_length, 7) - .setAttrWithMinzoom("network", network_val, 7); + .setAttrWithMinzoom("ref_length", shield_text_length, 7) + .setAttrWithMinzoom("network", network_val, 7); } else { feat.setAttrWithMinzoom("ref", shield_text, 12) - .setAttrWithMinzoom("ref_length", shield_text_length, 12) - .setAttrWithMinzoom("network", network_val, 12); + .setAttrWithMinzoom("ref_length", shield_text_length, 12) + .setAttrWithMinzoom("network", network_val, 12); } OsmNames.setOsmNames(feat, sourceFeature, 11); @@ -69,22 +69,22 @@ public void processFeature(SourceFeature sourceFeature, FeatureCollector feature highway.equals("primary_link")) { feat.setAttr("pmap:kind", "major_road").setZoomRange(7, 15); - if (highway.equals("trunk") ) { + if (highway.equals("trunk")) { feat.setAttrWithMinzoom("ref", shield_text, 8) - .setAttrWithMinzoom("ref_length", shield_text_length, 8) - .setAttrWithMinzoom("network", network_val, 8); - } else if (highway.equals("primary") ) { + .setAttrWithMinzoom("ref_length", shield_text_length, 8) + .setAttrWithMinzoom("network", network_val, 8); + } else if (highway.equals("primary")) { feat.setAttrWithMinzoom("ref", shield_text, 10) - .setAttrWithMinzoom("ref_length", shield_text_length, 10) - .setAttrWithMinzoom("network", network_val, 10); - } else if (highway.equals("trunk_link") ) { + .setAttrWithMinzoom("ref_length", shield_text_length, 10) + .setAttrWithMinzoom("network", network_val, 10); + } else if (highway.equals("trunk_link")) { feat.setAttrWithMinzoom("ref", shield_text, 12) - .setAttrWithMinzoom("ref_length", shield_text_length, 12) - .setAttrWithMinzoom("network", network_val, 12); + .setAttrWithMinzoom("ref_length", shield_text_length, 12) + .setAttrWithMinzoom("network", network_val, 12); } else { feat.setAttrWithMinzoom("ref", shield_text, 13) - .setAttrWithMinzoom("ref_length", shield_text_length, 13) - .setAttrWithMinzoom("network", network_val, 13); + .setAttrWithMinzoom("ref_length", shield_text_length, 13) + .setAttrWithMinzoom("network", network_val, 13); } OsmNames.setOsmNames(feat, sourceFeature, 12); @@ -92,43 +92,45 @@ public void processFeature(SourceFeature sourceFeature, FeatureCollector feature highway.equals("tertiary_link")) { feat.setAttr("pmap:kind", "medium_road").setZoomRange(9, 15); - if (highway.equals("secondary") ) { + if (highway.equals("secondary")) { feat.setAttrWithMinzoom("ref", shield_text, 11) - .setAttrWithMinzoom("ref_length", shield_text_length, 11) - .setAttrWithMinzoom("network", network_val, 11); - } else if (highway.equals("tertiary") ) { + .setAttrWithMinzoom("ref_length", shield_text_length, 11) + .setAttrWithMinzoom("network", network_val, 11); + } else if (highway.equals("tertiary")) { feat.setAttrWithMinzoom("ref", shield_text, 12) - .setAttrWithMinzoom("ref_length", shield_text_length, 12) - .setAttrWithMinzoom("network", network_val, 12); + .setAttrWithMinzoom("ref_length", shield_text_length, 12) + .setAttrWithMinzoom("network", network_val, 12); } else { feat.setAttrWithMinzoom("ref", shield_text, 13) - .setAttrWithMinzoom("ref_length", shield_text_length, 13) - .setAttrWithMinzoom("network", network_val, 13); + .setAttrWithMinzoom("ref_length", shield_text_length, 13) + .setAttrWithMinzoom("network", network_val, 13); } OsmNames.setOsmNames(feat, sourceFeature, 13); } else if (highway.equals("residential") || highway.equals("service") || highway.equals("unclassified") || highway.equals("road") || highway.equals("raceway")) { feat.setAttr("pmap:kind", "minor_road").setZoomRange(12, 15) - .setAttrWithMinzoom("ref", shield_text, 12) - .setAttrWithMinzoom("ref_length", shield_text_length, 12) - .setAttrWithMinzoom("network", network_val, 12); + .setAttrWithMinzoom("ref", shield_text, 12) + .setAttrWithMinzoom("ref_length", shield_text_length, 12) + .setAttrWithMinzoom("network", network_val, 12); OsmNames.setOsmNames(feat, sourceFeature, 14); - } else if (sourceFeature.hasTag("highway","pedestrian", "track", "path", "cycleway", "bridleway", "footway", "steps", "corridor")) { + } else if (sourceFeature.hasTag("highway", "pedestrian", "track", "path", "cycleway", "bridleway", "footway", + "steps", "corridor")) { feat.setAttr("pmap:kind_detail", highway).setZoomRange(12, 15) - .setAttrWithMinzoom("ref", shield_text, 12) - .setAttrWithMinzoom("ref_length", shield_text_length, 12) - .setAttrWithMinzoom("network", network_val, 12) - .setAttr("pmap:kind", "path").setZoomRange(12, 15); + .setAttrWithMinzoom("ref", shield_text, 12) + .setAttrWithMinzoom("ref_length", shield_text_length, 12) + .setAttrWithMinzoom("network", network_val, 12) + .setAttr("pmap:kind", "path").setZoomRange(12, 15); OsmNames.setOsmNames(feat, sourceFeature, 14); } else { feat.setAttr("pmap:kind", "other").setZoomRange(14, 15) - .setAttrWithMinzoom("ref", shield_text, 14) - .setAttrWithMinzoom("ref_length", shield_text_length, 14) - .setAttrWithMinzoom("network", network_val, 14); + .setAttrWithMinzoom("ref", shield_text, 14) + .setAttrWithMinzoom("ref_length", shield_text_length, 14) + .setAttrWithMinzoom("network", network_val, 14); OsmNames.setOsmNames(feat, sourceFeature, 14); } - if( sourceFeature.hasTag("highway", "motorway_link", "trunk_link", "primary_link", "secondary_link", "tertiary_link" )) { + if (sourceFeature.hasTag("highway", "motorway_link", "trunk_link", "primary_link", "secondary_link", + "tertiary_link")) { feat.setAttr("pmap:link", 1).setZoomRange(12, 15); } diff --git a/tiles/src/main/java/com/protomaps/basemap/layers/Water.java b/tiles/src/main/java/com/protomaps/basemap/layers/Water.java index d8fbdb77..2bc2ee62 100644 --- a/tiles/src/main/java/com/protomaps/basemap/layers/Water.java +++ b/tiles/src/main/java/com/protomaps/basemap/layers/Water.java @@ -51,7 +51,7 @@ public void processFeature(SourceFeature sf, FeatureCollector features) { .setMinPixelSize(3.0) .setBufferPixels(8); - if( sf.hasTag("intermittent", "yes" ) ) { + if (sf.hasTag("intermittent", "yes")) { feature.setAttr("intermittent", 1); } diff --git a/tiles/src/main/java/com/protomaps/basemap/names/NeNames.java b/tiles/src/main/java/com/protomaps/basemap/names/NeNames.java index 6c795794..6faa92fd 100644 --- a/tiles/src/main/java/com/protomaps/basemap/names/NeNames.java +++ b/tiles/src/main/java/com/protomaps/basemap/names/NeNames.java @@ -5,17 +5,17 @@ import java.util.Map; public class NeNames { - public static FeatureCollector.Feature setNeNames(FeatureCollector.Feature feature, SourceFeature source, - int minzoom) { - for (Map.Entry tag : source.tags().entrySet()) { - var key = tag.getKey(); - if (key.equals("name") ) { - feature.setAttrWithMinzoom(key, source.getTag(key), minzoom); - } else if ( key.startsWith("name_")) { - feature.setAttrWithMinzoom(key.replace("_", ":"), source.getTag(key), minzoom); - } - } - - return feature; + public static FeatureCollector.Feature setNeNames(FeatureCollector.Feature feature, SourceFeature source, + int minzoom) { + for (Map.Entry tag : source.tags().entrySet()) { + var key = tag.getKey(); + if (key.equals("name")) { + feature.setAttrWithMinzoom(key, source.getTag(key), minzoom); + } else if (key.startsWith("name_")) { + feature.setAttrWithMinzoom(key.replace("_", ":"), source.getTag(key), minzoom); + } } -} \ No newline at end of file + + return feature; + } +} From f1858ae304368e6d2aaa9941c5a2186a6abaf361 Mon Sep 17 00:00:00 2001 From: Nathaniel Kelso Date: Wed, 31 May 2023 10:03:53 -0700 Subject: [PATCH 26/28] add linting note, formatting --- README.md | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 4c2616bb..6b424918 100644 --- a/README.md +++ b/README.md @@ -12,25 +12,35 @@ You will need [Java 17+](https://github.com/onthegomap/planetiler/blob/main/CONT Generate and inspect a basemap PMTiles of any named area: 1. Clone this repository. -```sh + +```shell git clone git@github.com:protomaps/basemaps.git ``` 2. change to the `tiles` directory, download dependencies and compile the JAR: -```sh + +```shell +cd basemap/tiles mvn clean package ``` 3. Download and generate `monaco.pmtiles` in the current directory: -``` + +```shell java -jar target/*-with-deps.jar --download --force --area=monaco ``` 4. Switch to the `compare/` directory to run the map compare tool: -``` +```shell cd compare npm run serve ``` +5. Linting to apply code formatting + +```shell +mvn spotless:apply +``` + ## License [BSD 3-clause](/LICENSE.md). The organization of layers and features used by these map styles, as well as the "look and feel" of the resulting maps, are licensed [CC0](https://creativecommons.org/publicdomain/zero/1.0/). However, maps using the [Protomaps web map service](https://protomaps.com) or another OpenStreetMap-based service will be subject to the terms of the [Open Database License](https://www.openstreetmap.org/copyright). From 5b62ac04e9191fe6169821beeca4c7ec87218ef0 Mon Sep 17 00:00:00 2001 From: Nathaniel Kelso Date: Wed, 31 May 2023 10:53:53 -0700 Subject: [PATCH 27/28] int and break, per PR comments --- tiles/src/main/java/com/protomaps/basemap/layers/Places.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tiles/src/main/java/com/protomaps/basemap/layers/Places.java b/tiles/src/main/java/com/protomaps/basemap/layers/Places.java index 0d7bbece..b7b8c87d 100644 --- a/tiles/src/main/java/com/protomaps/basemap/layers/Places.java +++ b/tiles/src/main/java/com/protomaps/basemap/layers/Places.java @@ -127,7 +127,7 @@ public void processFeature(SourceFeature sf, FeatureCollector features) { feat.setSortKey(0); } - Integer population_rank = 0; + int population_rank = 0; int[] pop_breaks = { 1000000000, @@ -152,6 +152,7 @@ public void processFeature(SourceFeature sf, FeatureCollector features) { for (int i = 0; i < pop_breaks.length; i++) { if (population >= pop_breaks[i]) { population_rank = pop_breaks.length - i; + break; } } From 54013632e0f1745b828f67dac1f7e2c7cdb5bc72 Mon Sep 17 00:00:00 2001 From: Nathaniel Kelso Date: Wed, 31 May 2023 10:55:18 -0700 Subject: [PATCH 28/28] remove very small featues to declutter the map --- tiles/src/main/java/com/protomaps/basemap/layers/Landuse.java | 3 ++- tiles/src/main/java/com/protomaps/basemap/layers/Natural.java | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/tiles/src/main/java/com/protomaps/basemap/layers/Landuse.java b/tiles/src/main/java/com/protomaps/basemap/layers/Landuse.java index 8fdbfcdb..b4e8869a 100644 --- a/tiles/src/main/java/com/protomaps/basemap/layers/Landuse.java +++ b/tiles/src/main/java/com/protomaps/basemap/layers/Landuse.java @@ -38,7 +38,8 @@ public static void processFeature(SourceFeature sf, FeatureCollector features, S .setAttr("place", sf.getString("place")) .setAttr("railway", sf.getString("railway")) .setAttr("sport", sf.getString("sport")) - .setZoomRange(5, 15); + .setZoomRange(5, 15) + .setMinPixelSize(3.0); OsmNames.setOsmNames(poly, sf, 0); diff --git a/tiles/src/main/java/com/protomaps/basemap/layers/Natural.java b/tiles/src/main/java/com/protomaps/basemap/layers/Natural.java index c7a00a98..5a4d64fb 100644 --- a/tiles/src/main/java/com/protomaps/basemap/layers/Natural.java +++ b/tiles/src/main/java/com/protomaps/basemap/layers/Natural.java @@ -28,7 +28,8 @@ public void processFeature(SourceFeature sf, FeatureCollector features) { .setAttr("boundary", sf.getString("boundary")) .setAttr("landuse", sf.getString("landuse")) .setAttr("leisure", sf.getString("leisure")) - .setZoomRange(5, 15); + .setZoomRange(5, 15) + .setMinPixelSize(3.0); OsmNames.setOsmNames(feat, sf, 0); }