@@ -213,6 +213,81 @@ public Roads(CountryCoder countryCoder) {
213
213
)
214
214
)).index ();
215
215
216
+ private static final MultiExpression .Index <Map <String , Object >> indexNonHighways = MultiExpression .of (List .of (
217
+ rule (
218
+ with ("railway" ),
219
+ use ("kind" , "rail" ),
220
+ use ("kindDetail" , fromTag ("railway" )),
221
+ use ("minZoom" , 11 )
222
+ ),
223
+ rule (
224
+ with ("railway" , "service" ),
225
+ use ("minZoom" , 13 )
226
+ ),
227
+ rule (
228
+ with ("railway" , "service" ),
229
+ with ("service" ),
230
+ use ("minZoom" , 14 )
231
+ ),
232
+ rule (
233
+ with ("""
234
+ railway
235
+ funicular
236
+ light_rail
237
+ miniature
238
+ monorail
239
+ narrow_gauge
240
+ preserved
241
+ subway
242
+ tram
243
+ """ ),
244
+ use ("minZoom" , 14 )
245
+ ),
246
+ rule (
247
+ with ("railway" , "disused" ),
248
+ use ("minZoom" , 15 )
249
+ ),
250
+ rule (
251
+ with ("railway" ),
252
+ with ("""
253
+ service
254
+ yard
255
+ siding
256
+ crossover
257
+ """ ),
258
+ use ("minZoom" , 13 )
259
+ ),
260
+ rule (
261
+ with ("aerialway" , "cable_car" ),
262
+ use ("kind" , "aerialway" ),
263
+ use ("kindDetail" , "cable_car" ),
264
+ use ("minZoom" , 11 )
265
+ ),
266
+ rule (
267
+ with ("man_made" , "pier" ),
268
+ use ("kind" , "path" ),
269
+ use ("kindDetail" , "pier" ),
270
+ use ("minZoom" , 13 )
271
+ ),
272
+ rule (
273
+ with ("route" , "ferry" ),
274
+ use ("kind" , "ferry" ),
275
+ use ("minZoom" , 11 )
276
+ ),
277
+ rule (
278
+ with ("aeroway" , "taxiway" ),
279
+ use ("kind" , "aeroway" ),
280
+ use ("kindDetail" , "taxiway" ),
281
+ use ("minZoom" , 10 )
282
+ ),
283
+ rule (
284
+ with ("aeroway" , "runway" ),
285
+ use ("kind" , "aeroway" ),
286
+ use ("kindDetail" , "runway" ),
287
+ use ("minZoom" , 9 )
288
+ )
289
+ )).index ();
290
+
216
291
@ Override
217
292
public String name () {
218
293
return LAYER_NAME ;
@@ -241,6 +316,14 @@ public List<OsmRelationInfo> preprocessOsmRelation(OsmElement.Relation relation)
241
316
242
317
private void processOsmHighways (SourceFeature sf , FeatureCollector features ) {
243
318
319
+ if (!sf .hasTag ("highway" )) {
320
+ return ;
321
+ }
322
+
323
+ if (sf .hasTag ("highway" , "proposed" , "abandoned" , "razed" , "demolished" , "removed" , "construction" , "elevator" )) {
324
+ return ;
325
+ }
326
+
244
327
String highway = sf .getString ("highway" );
245
328
246
329
Shield shield = locale .getShield (sf );
@@ -321,53 +404,24 @@ private void processOsmHighways(SourceFeature sf, FeatureCollector features) {
321
404
322
405
private void processOsmNonHighways (SourceFeature sf , FeatureCollector features ) {
323
406
324
- int minZoom = 11 ;
407
+ if (sf .hasTag ("building" )) {
408
+ // see https://github.com/protomaps/basemaps/issues/249
409
+ return ;
410
+ }
325
411
326
- if (sf .hasTag ("aeroway" , "runway" )) {
327
- minZoom = 9 ;
328
- } else if (sf .hasTag ("aeroway" , "taxiway" )) {
329
- minZoom = 10 ;
330
- } else if (sf .hasTag ("service" , "yard" , "siding" , "crossover" )) {
331
- minZoom = 13 ;
332
- } else if (sf .hasTag ("man_made" , "pier" )) {
333
- minZoom = 13 ;
412
+ if (sf .hasTag ("railway" , "abandoned" , "razed" , "demolished" , "removed" , "construction" , "platform" , "proposed" )) {
413
+ return ;
334
414
}
335
415
336
- String kind = "other" ;
337
- String kindDetail = "" ;
338
- if (sf .hasTag ("aeroway" )) {
339
- kind = "aeroway" ;
340
- kindDetail = sf .getString ("aeroway" );
341
- } else if (sf .hasTag ("railway" , "disused" , "funicular" , "light_rail" , "miniature" , "monorail" , "narrow_gauge" ,
342
- "preserved" , "subway" , "tram" )) {
343
- kind = "rail" ;
344
- kindDetail = sf .getString ("railway" );
345
- minZoom = 14 ;
346
-
347
- if (sf .hasTag ("railway" , "disused" )) {
348
- minZoom = 15 ;
349
- }
350
- } else if (sf .hasTag ("railway" )) {
351
- kind = "rail" ;
352
- kindDetail = sf .getString ("railway" );
416
+ var matches = indexNonHighways .getMatches (sf );
417
+ if (matches .isEmpty ()) {
418
+ return ;
419
+ }
353
420
354
- if (kindDetail .equals ("service" )) {
355
- minZoom = 13 ;
421
+ int minZoom = getInteger (sf , matches , "minZoom" , 11 );
422
+ String kind = getString (sf , matches , "kind" , "other" );
423
+ String kindDetail = getString (sf , matches , "kindDetail" , "" );
356
424
357
- // eg a rail yard
358
- if (sf .hasTag ("service" )) {
359
- minZoom = 14 ;
360
- }
361
- }
362
- } else if (sf .hasTag ("route" , "ferry" )) {
363
- kind = "ferry" ;
364
- } else if (sf .hasTag ("man_made" , "pier" )) {
365
- kind = "path" ;
366
- kindDetail = "pier" ;
367
- } else if (sf .hasTag ("aerialway" )) {
368
- kind = "aerialway" ;
369
- kindDetail = sf .getString ("aerialway" );
370
- }
371
425
372
426
var feature = features .line (this .name ())
373
427
.setId (FeatureId .create (sf ))
@@ -407,20 +461,13 @@ private void processOsmNonHighways(SourceFeature sf, FeatureCollector features)
407
461
}
408
462
409
463
public void processOsm (SourceFeature sf , FeatureCollector features ) {
410
- if (sf .canBeLine () && sf .hasTag ("highway" ) &&
411
- !(sf .hasTag ("highway" , "proposed" , "abandoned" , "razed" , "demolished" , "removed" , "construction" , "elevator" ))) {
412
- processOsmHighways (sf , features );
464
+ if (!sf .canBeLine ()) {
465
+ return ;
413
466
}
414
467
415
- if (sf .canBeLine () && (sf .hasTag ("railway" ) ||
416
- sf .hasTag ("aerialway" , "cable_car" ) ||
417
- sf .hasTag ("man_made" , "pier" ) ||
418
- sf .hasTag ("route" , "ferry" ) ||
419
- sf .hasTag ("aeroway" , "runway" , "taxiway" )) &&
420
- (!sf .hasTag ("building" ) /* see https://github.com/protomaps/basemaps/issues/249 */ ) &&
421
- (!sf .hasTag ("railway" , "abandoned" , "razed" , "demolished" , "removed" , "construction" , "platform" , "proposed" ))) {
422
- processOsmNonHighways (sf , features );
423
- }
468
+ processOsmHighways (sf , features );
469
+ processOsmNonHighways (sf , features );
470
+
424
471
}
425
472
426
473
@ Override
0 commit comments