@@ -189,12 +189,55 @@ public class Water implements ForwardingProfile.LayerPostProcessor {
189
189
),
190
190
rule (
191
191
with ("place" , "sea" ),
192
+ with ("_can_be_polygon" ),
193
+ use ("kind" , "sea" ),
194
+ use ("keepPolygon" , false )
195
+ ),
196
+ rule (
197
+ with ("place" , "sea" ),
198
+ with ("_can_be_polygon" ),
199
+ with ("""
200
+ name:en
201
+ Caspian Sea
202
+ Red Sea
203
+ Persian Gulf
204
+ Sea of Oman
205
+ Gulf of Aden
206
+ Gulf of Thailand
207
+ Sea of Japan
208
+ """ ),
209
+ use ("minZoom" , 5 )
210
+ ),
211
+ rule (
212
+ with ("place" , "sea" ),
213
+ with ("_can_be_polygon" ),
214
+ with ("""
215
+ name:en
216
+ Arabian Sea
217
+ Bay of Bengal
218
+ Black Sea
219
+ """ ),
220
+ use ("minZoom" , 3 )
221
+ ),
222
+ rule (
223
+ with ("place" , "sea" ),
224
+ with ("_can_be_polygon" ),
225
+ with ("""
226
+ name:en
227
+ Black Sea
228
+ Caspian Sea
229
+ """ ),
230
+ use ("nameOverride" , fromTag ("name:en" ))
231
+ ),
232
+ rule (
233
+ with ("place" , "sea" ),
234
+ with ("_is_point" ),
192
235
use ("kind" , "sea" ),
193
- use ("keepPolygon" , false ),
194
236
use ("minZoom" , 6 )
195
237
),
196
238
rule (
197
239
with ("place" , "sea" ),
240
+ with ("_is_point" ),
198
241
with ("""
199
242
name:en
200
243
North Atlantic Ocean
@@ -216,18 +259,16 @@ public class Water implements ForwardingProfile.LayerPostProcessor {
216
259
Gulf of Alaska
217
260
Gulf of Guinea
218
261
""" ),
262
+ use ("kind" , "sea" ),
219
263
use ("minZoom" , 3 )
220
264
),
221
265
rule (
222
266
with ("place" , "ocean" ),
223
267
use ("kind" , "ocean" ),
224
- use ("keepPolygon" , false ),
225
268
use ("minZoom" , 0 )
226
269
)
227
270
)).index ();
228
271
229
-
230
-
231
272
@ Override
232
273
public String name () {
233
274
return LAYER_NAME ;
@@ -272,21 +313,16 @@ public void processNe(SourceFeature sf, FeatureCollector features) {
272
313
.setMinPixelSize (1.0 )
273
314
.setBufferPixels (8 );
274
315
}
275
-
276
- if (sf .getSourceLayer ().equals ("ne_10m_lakes" ) && sf .hasTag ("min_label" ) && sf .hasTag ("name" )) {
277
- int minZoom = (int ) Math .round (Double .parseDouble (sf .getString ("min_label" )));
278
- var waterLabelPosition = features .pointOnSurface (LAYER_NAME )
279
- .setAttr ("kind" , kind )
280
- .setAttr ("min_zoom" , minZoom + 1 )
281
- .setZoomRange (minZoom + 1 , 5 )
282
- .setSortKey (minZoom )
283
- .setBufferPixels (128 );
284
-
285
- NeNames .setNeNames (waterLabelPosition , sf , 0 );
286
- }
287
316
}
288
317
289
318
public void processOsm (SourceFeature sf , FeatureCollector features ) {
319
+ if (!sf .tags ().isEmpty () && sf .isPoint ()) {
320
+ sf .setTag ("_is_point" , "yes" );
321
+ }
322
+
323
+ if (!sf .tags ().isEmpty () && sf .canBePolygon ()) {
324
+ sf .setTag ("_can_be_polygon" , "yes" );
325
+ }
290
326
291
327
var matches = osmIndex .getMatches (sf );
292
328
if (matches .isEmpty ()) {
@@ -298,6 +334,11 @@ public void processOsm(SourceFeature sf, FeatureCollector features) {
298
334
return ;
299
335
}
300
336
337
+ String nameOverride = getString (sf , matches , "nameOverride" , null );
338
+ if (nameOverride != null ) {
339
+ sf .setTag ("name" , nameOverride );
340
+ }
341
+
301
342
String kindDetail = getString (sf , matches , "kindDetail" , null );
302
343
boolean keepPolygon = getBoolean (sf , matches , "keepPolygon" , true );
303
344
@@ -333,19 +374,6 @@ public void processOsm(SourceFeature sf, FeatureCollector features) {
333
374
.setPixelTolerance (0 )
334
375
.setMinZoom (minZoom );
335
376
336
- // Set "brunnel" (bridge / tunnel) property where "level" = 1 is a bridge, 0 is ground level, and -1 is a tunnel
337
- // Because of MapLibre performance and draw order limitations, generally the boolean is sufficient
338
- // See also: "layer" for more complicated ±6 layering for more sophisticated graphics libraries
339
- if (sf .hasTag ("bridge" ) && !sf .hasTag ("bridge" , "no" )) {
340
- feat .setAttrWithMinzoom ("level" , 1 , extraAttrMinzoom );
341
- } else if (sf .hasTag ("tunnel" ) && !sf .hasTag ("tunnel" , "no" )) {
342
- feat .setAttrWithMinzoom ("level" , -1 , extraAttrMinzoom );
343
- } else if (sf .hasTag ("layer" , "-6" , "-5" , "-4" , "-3" , "-2" , "-1" )) {
344
- feat .setAttrWithMinzoom ("level" , -1 , extraAttrMinzoom );
345
- } else {
346
- feat .setAttrWithMinzoom ("level" , 0 , extraAttrMinzoom );
347
- }
348
-
349
377
OsmNames .setOsmNames (feat , sf , 0 );
350
378
}
351
379
@@ -356,7 +384,7 @@ public void processOsm(SourceFeature sf, FeatureCollector features) {
356
384
var feat = features .point (LAYER_NAME )
357
385
.setId (FeatureId .create (sf ))
358
386
.setAttr ("kind" , kind )
359
- .setAttr ("min_zoom" , minZoom )
387
+ .setAttr ("min_zoom" , minZoom + 1 )
360
388
.setSortKey (minZoom )
361
389
.setMinZoom (minZoom );
362
390
@@ -374,39 +402,22 @@ public void processOsm(SourceFeature sf, FeatureCollector features) {
374
402
e .log ("Exception in way area calculation" );
375
403
}
376
404
377
- // We don't want to show too many water labels at early zooms else it crowds the map
378
- // TODO: (nvkelso 20230621) These numbers are super wonky, they should instead be sq meters in web mercator prj
379
- // Zoom 5 and earlier from Natural Earth instead (see above)
380
- if (wayArea > 25000 ) { //500000000
381
- nameMinZoom = 6 ;
382
- } else if (wayArea > 8000 ) { //500000000
383
- nameMinZoom = 7 ;
384
- } else if (wayArea > 3000 ) { //200000000
385
- nameMinZoom = 8 ;
386
- } else if (wayArea > 500 ) { //40000000
387
- nameMinZoom = 9 ;
388
- } else if (wayArea > 200 ) { //8000000
389
- nameMinZoom = 10 ;
390
- } else if (wayArea > 30 ) { //1000000
391
- nameMinZoom = 11 ;
392
- } else if (wayArea > 25 ) { //500000
393
- nameMinZoom = 12 ;
394
- } else if (wayArea > 0.5 ) { //50000
395
- nameMinZoom = 13 ;
396
- } else if (wayArea > 0.05 ) { //10000
397
- nameMinZoom = 14 ;
405
+ for (int i = 6 ; i < 15 ; ++i ) {
406
+ if (wayArea > Math .pow (4 , 15 - i )) {
407
+ nameMinZoom = i ;
408
+ break ;
409
+ }
398
410
}
399
411
412
+ nameMinZoom = getInteger (sf , matches , "minZoom" , nameMinZoom );
413
+
400
414
var waterLabelPosition = features .pointOnSurface (LAYER_NAME )
401
415
.setAttr ("kind" , kind )
402
416
.setAttr ("kind_detail" , kindDetail )
403
417
// While other layers don't need min_zoom, physical point labels do for more
404
418
// predictable client-side label collisions
405
419
// 512 px zooms versus 256 px logical zooms
406
420
.setAttr ("min_zoom" , nameMinZoom + 1 )
407
- .setAttrWithMinzoom ("bridge" , sf .getString ("bridge" ), extraAttrMinzoom )
408
- .setAttrWithMinzoom ("tunnel" , sf .getString ("tunnel" ), extraAttrMinzoom )
409
- .setAttrWithMinzoom ("layer" , Parse .parseIntOrNull (sf .getString ("layer" )), extraAttrMinzoom )
410
421
.setMinZoom (nameMinZoom )
411
422
.setAttr ("sort_rank" , 200 )
412
423
.setSortKey (nameMinZoom )
0 commit comments