Skip to content

Commit 2def5bb

Browse files
committed
Start with pois
1 parent f7bf03f commit 2def5bb

File tree

1 file changed

+101
-26
lines changed
  • tiles/src/main/java/com/protomaps/basemap/layers

1 file changed

+101
-26
lines changed

tiles/src/main/java/com/protomaps/basemap/layers/Pois.java

+101-26
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
package com.protomaps.basemap.layers;
22

33
import static com.onthegomap.planetiler.util.Parse.parseDoubleOrNull;
4+
import static com.protomaps.basemap.feature.Matcher.entry;
5+
import static com.protomaps.basemap.feature.Matcher.fromTag;
6+
import static com.protomaps.basemap.feature.Matcher.getString;
7+
import static com.protomaps.basemap.feature.Matcher.use;
8+
import static com.protomaps.basemap.feature.Matcher.with;
9+
import static com.protomaps.basemap.feature.Matcher.without;
410

511
import com.onthegomap.planetiler.FeatureCollector;
612
import com.onthegomap.planetiler.ForwardingProfile;
713
import com.onthegomap.planetiler.VectorTile;
14+
import com.onthegomap.planetiler.expression.MultiExpression;
815
import com.onthegomap.planetiler.geo.GeoUtils;
916
import com.onthegomap.planetiler.geo.GeometryException;
1017
import com.onthegomap.planetiler.reader.SourceFeature;
@@ -13,6 +20,7 @@
1320
import com.protomaps.basemap.feature.QrankDb;
1421
import com.protomaps.basemap.names.OsmNames;
1522
import java.util.List;
23+
import java.util.Map;
1624

1725
public class Pois implements ForwardingProfile.LayerPostProcessor {
1826

@@ -33,15 +41,82 @@ public String name() {
3341
Math.pow(GeoUtils.metersToPixelAtEquator(0, Math.sqrt(70_000)) / 256d, 2);
3442
private static final double LOG2 = Math.log(2);
3543

44+
private static final MultiExpression.Index<Map<String, Object>> index = MultiExpression.of(List.of(
45+
entry(
46+
with("aeroway", "aerodrome"),
47+
use("kind", "aerodrome"),
48+
use("kindDetail", ""),
49+
use("minZoom", 13)
50+
),
51+
entry(
52+
with("aeroway", "aerodrome"),
53+
with("iata"),
54+
use("minZoom", 11)
55+
),
56+
entry(
57+
with("aeroway", "aerodrome"),
58+
with("aerodrome"),
59+
use("kindDetail", fromTag("aerodrome"))
60+
),
61+
entry(
62+
with("amenity"),
63+
use("kind", "other"),
64+
use("kindDetail", ""),
65+
use("minZoom", 15)
66+
),
67+
entry(
68+
with("amenity", "hospital"),
69+
use("kind", "hospital"),
70+
use("minZoom", 12)
71+
),
72+
entry(
73+
with("amenity", "library", "post_office", "townhall"),
74+
use("kind", fromTag("amenity")),
75+
use("minZoom", 13)
76+
),
77+
entry(
78+
with("amenity", "university", "college"),
79+
use("kind", fromTag("amenity")),
80+
use("minZoom", 14)
81+
),
82+
entry(
83+
with("amenity", "school", "cafe"),
84+
use("kind", fromTag("amenity"))
85+
),
86+
entry(
87+
with("landuse", "cemetery", "recreation_ground", "winter_sports", "quarry", "park", "forest", "military",
88+
"village_green", "allotments"),
89+
use("kind", "other"),
90+
use("kindDetail", ""),
91+
use("minZoom", 15)
92+
),
93+
entry(
94+
with("landuse", "cemetery"),
95+
use("kind", "cemetery"),
96+
use("minZoom", 14)
97+
),
98+
entry(
99+
with("landuse", "military"),
100+
use("kind", "military")
101+
),
102+
entry(
103+
with("landuse", "military"),
104+
with("military", "naval_base", "airfield")
105+
use("kind", fromTag("military"))
106+
)
107+
108+
)).index();
109+
36110
public void processOsm(SourceFeature sf, FeatureCollector features) {
37-
if ((sf.isPoint() || sf.canBePolygon()) && (sf.hasTag("aeroway", "aerodrome") ||
38-
sf.hasTag("amenity") ||
111+
if ((sf.isPoint() || sf.canBePolygon()) && (
112+
// sf.hasTag("aeroway", "aerodrome") ||
113+
// sf.hasTag("amenity") ||
39114
sf.hasTag("attraction") ||
40115
sf.hasTag("boundary", "national_park", "protected_area") ||
41116
sf.hasTag("craft") ||
42117
sf.hasTag("historic") ||
43-
sf.hasTag("landuse", "cemetery", "recreation_ground", "winter_sports", "quarry", "park", "forest", "military",
44-
"village_green", "allotments") ||
118+
// sf.hasTag("landuse", "cemetery", "recreation_ground", "winter_sports", "quarry", "park", "forest", "military",
119+
// "village_green", "allotments") ||
45120
sf.hasTag("leisure") ||
46121
sf.hasTag("natural", "beach", "peak") ||
47122
sf.hasTag("railway", "station") ||
@@ -59,34 +134,34 @@ public void processOsm(SourceFeature sf, FeatureCollector features) {
59134
}
60135

61136
if (sf.hasTag("aeroway", "aerodrome")) {
62-
kind = sf.getString("aeroway");
63-
minZoom = 13;
137+
// kind = sf.getString("aeroway");
138+
// minZoom = 13;
64139

65-
// Emphasize large international airports earlier
66-
if (kind.equals("aerodrome") && sf.hasTag("iata")) {
67-
minZoom -= 2;
68-
}
140+
// // Emphasize large international airports earlier
141+
// if (kind.equals("aerodrome") && sf.hasTag("iata")) {
142+
// minZoom -= 2;
143+
// }
69144

70-
if (sf.hasTag("aerodrome")) {
71-
kindDetail = sf.getString("aerodrome");
72-
}
145+
// if (sf.hasTag("aerodrome")) {
146+
// kindDetail = sf.getString("aerodrome");
147+
// }
73148
} else if (sf.hasTag("amenity", "university", "college")) {
74-
kind = sf.getString("amenity");
75-
// One would think University should be earlier, but there are lots of dinky node only places
76-
// So if the university has a large area, it'll naturally improve it's zoom in the next section...
77-
minZoom = 14;
149+
// kind = sf.getString("amenity");
150+
// // One would think University should be earlier, but there are lots of dinky node only places
151+
// // So if the university has a large area, it'll naturally improve it's zoom in the next section...
152+
// minZoom = 14;
78153
} else if (sf.hasTag("amenity", "hospital")) {
79-
kind = sf.getString("amenity");
80-
minZoom = 12;
154+
// kind = sf.getString("amenity");
155+
// minZoom = 12;
81156
} else if (sf.hasTag("amenity", "library", "post_office", "townhall")) {
82-
kind = sf.getString("amenity");
83-
minZoom = 13;
157+
// kind = sf.getString("amenity");
158+
// minZoom = 13;
84159
} else if (sf.hasTag("amenity", "school")) {
85-
kind = sf.getString("amenity");
86-
minZoom = 15;
87-
} else if (sf.hasTag("amenity", "cafe")) {
88-
kind = sf.getString("amenity");
89-
minZoom = 15;
160+
// // kind = sf.getString("amenity");
161+
// // minZoom = 15;
162+
// } else if (sf.hasTag("amenity", "cafe")) {
163+
// kind = sf.getString("amenity");
164+
// minZoom = 15;
90165
} else if (sf.hasTag("landuse", "cemetery")) {
91166
kind = sf.getString("landuse");
92167
minZoom = 14;

0 commit comments

Comments
 (0)