-
Notifications
You must be signed in to change notification settings - Fork 3
/
style.lua
11142 lines (10253 loc) · 536 KB
/
style.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
-- ----------------------------------------------------------------------------
-- style.lua
--
-- Copyright (C) 2018-2024 Andy Townsend
--
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <https://www.gnu.org/licenses/>.
-- ----------------------------------------------------------------------------
-- Code common to several projects is in "shared_lua.lua".
-- That file is in this repository, but needs to be available on the standard
-- lua path when this script is invoked. The "update_render.sh" script does
-- this by:
-- cp /home/${local_filesystem_user}/src/SomeoneElse-style/shared_lua.lua -
-- /usr/local/share/lua/5.3/
-- ----------------------------------------------------------------------------
require "shared_lua"
polygon_keys = { 'boundary', 'building', 'landcover', 'landuse', 'amenity', 'harbour', 'historic', 'leisure',
'man_made', 'military', 'natural', 'office', 'place', 'power',
'public_transport', 'seamark:type', 'shop', 'sport', 'tourism', 'waterway',
'wetland', 'water', 'aeroway' }
generic_keys = {'access','addr:housename','addr:housenumber','addr:interpolation','admin_level','advertising','aerialway','aeroway','amenity','area','area:highway','barrier',
'bicycle','brand','bridge','bridleway','booth','boundary','building', 'canoe', 'capital','construction','covered','culvert','cutting','denomination','departures_board','designation','disused','disused:highway','disused:man_made','disused:military','disused:shop','ele',
'embankment','emergency','entrance','foot','flood_prone','generation:source','geological','golf','government',
'harbour','hazard_prone','hazard_type','highway','historic','horse','hours','information','intermittent',
'junction','landcover','landuse','layer','leisure','lcn_ref','lock','locked',
'man_made','marker','military','motor_car','name','natural','ncn_milepost','office','oneway','operator','opening_hours:covid19','outlet','passenger_information_display','pipeline','pitch','place','playground','poi','population','power','power_source','public_transport',
'railway','railway:historic','ref','religion','rescue_equipment','route',
'school','seamark:type','seamark:rescue_station:category','service','shop','sport','surface',
'toll','tourism','tower:type', 'tracktype','training','tunnel','water','waterway',
'wetland', 'whitewater', 'width','wood','type', 'zoo' }
function add_z_order(keyvalues)
z_order = 0
if (keyvalues["layer"] ~= nil and tonumber(keyvalues["layer"])) then
z_order = 10*keyvalues["layer"]
end
zordering_tags = {{ 'railway', nil, 5, 1}, { 'boundary', 'administrative', 0, 1},
{ 'bridge', 'yes', 10, 0 }, { 'bridge', 'true', 10, 0 }, { 'bridge', 1, 10, 0 },
{ 'tunnel', 'yes', -10, 0}, { 'tunnel', 'true', -10, 0}, { 'tunnel', 1, -10, 0},
{ 'highway', 'road', 2, 0 },
{ 'highway', 'unclassified', 3, 0 }, { 'highway', 'unclassified_sidewalk', 3, 0 }, { 'highway', 'unclassified_verge', 3, 0 }, { 'highway', 'unclassified_ford', 3, 0 },
{ 'highway', 'living_street', 3, 0 }, { 'highway', 'living_street_sidewalk', 3, 0 }, { 'highway', 'living_street_verge', 3, 0 }, { 'highway', 'living_street_ford', 3, 0 },
{ 'highway', 'residential', 3, 0 },
{ 'highway', 'tertiary_link', 4, 0}, { 'highway', 'tertiary', 4, 0}, { 'highway', 'tertiary_sidewalk', 4, 0}, { 'highway', 'tertiary_verge', 4, 0},
{ 'highway', 'secondary_link', 6, 1}, { 'highway', 'secondary', 6, 1}, { 'highway', 'secondary_sidewalk', 6, 1}, { 'highway', 'secondary_verge', 6, 1},
{ 'highway', 'primary_link', 7, 1}, { 'highway', 'primary', 7, 1},{ 'highway', 'primary_sidewalk', 7, 1},{ 'highway', 'primary_verge', 7, 1},
{ 'highway', 'trunk_link', 8, 1}, { 'highway', 'trunk', 8, 1},
{ 'highway', 'motorway_link', 9, 1}, { 'highway', 'motorway', 9, 1},
{ 'highway', 'ldpnwn', 91, 1}, { 'highway', 'ldpncn', 91, 1}, { 'highway', 'ldpmtb', 91, 1}, { 'highway', 'ldpnhn', 91, 1},
}
for i,k in ipairs(zordering_tags) do
if ((k[2] and keyvalues[k[1]] == k[2]) or (k[2] == nil and keyvalues[k[1]] ~= nil)) then
if (k[4] == 1) then
roads = 1
end
z_order = z_order + k[3]
end
end
keyvalues["z_order"] = z_order
return keyvalues, roads
end
function filter_tags_generic(keyvalues, nokeys)
-- ----------------------------------------------------------------------------
-- local table for parameter passing
-- ----------------------------------------------------------------------------
local t = {}
filter = 0
tagcount = 0
if nokeys == 0 then
filter = 1
return filter, keyvalues
end
delete_tags = { 'FIXME', 'note', 'source' }
for i,k in ipairs(delete_tags) do
keyvalues[k] = nil
end
for k,v in pairs(keyvalues) do
for i, k2 in ipairs(generic_keys) do if k2 == k then tagcount = tagcount + 1; end end
end
if tagcount == 0 then
filter = 1
end
-- ----------------------------------------------------------------------------
-- Invalid layer values - change them to something plausible.
-- ----------------------------------------------------------------------------
keyvalues["layer"] = fix_invalid_layer_values( keyvalues["layer"], keyvalues["bridge"], keyvalues["embankment"] )
-- ----------------------------------------------------------------------------
-- Treat "was:" as "disused:"
-- ----------------------------------------------------------------------------
if (( keyvalues["was:amenity"] ~= nil ) and
( keyvalues["disused:amenity"] == nil )) then
keyvalues["disused:amenity"] = keyvalues["was:amenity"]
end
if (( keyvalues["was:waterway"] ~= nil ) and
( keyvalues["disused:waterway"] == nil )) then
keyvalues["disused:waterway"] = keyvalues["was:waterway"]
end
if (( keyvalues["was:railway"] ~= nil ) and
( keyvalues["disused:railway"] == nil )) then
keyvalues["disused:railway"] = keyvalues["was:railway"]
end
if (( keyvalues["was:aeroway"] ~= nil ) and
( keyvalues["disused:aeroway"] == nil )) then
keyvalues["disused:aeroway"] = keyvalues["was:aeroway"]
end
if (( keyvalues["was:landuse"] ~= nil ) and
( keyvalues["disused:landuse"] == nil )) then
keyvalues["disused:landuse"] = keyvalues["was:landuse"]
end
if (( keyvalues["was:shop"] ~= nil ) and
( keyvalues["disused:shop"] == nil )) then
keyvalues["disused:shop"] = keyvalues["was:shop"]
end
-- ----------------------------------------------------------------------------
-- Treat "closed:" as "disused:" in some cases too.
-- ----------------------------------------------------------------------------
if (( keyvalues["closed:amenity"] ~= nil ) and
( keyvalues["disused:amenity"] == nil )) then
keyvalues["disused:amenity"] = keyvalues["closed:amenity"]
end
if (( keyvalues["closed:shop"] ~= nil ) and
( keyvalues["disused:shop"] == nil )) then
keyvalues["disused:shop"] = keyvalues["closed:shop"]
end
-- ----------------------------------------------------------------------------
-- Treat "status=abandoned" as "disused=yes"
-- ----------------------------------------------------------------------------
if ( keyvalues["status"] == "abandoned" ) then
keyvalues["disused"] = "yes"
end
-- ----------------------------------------------------------------------------
-- Designation processing
--
-- The "standard" stylesheet contains rules for different sorts of tracks
-- (tracktype), but doesn't contain rules for English/Welsh rights of way
-- designations.
--
-- The changes here do the following:
-- 1) Render any non-designated footway, bridleway, cycleway or track as "path"
-- (grey dashes in the "standard" style)
-- 2) Render anything designated as "public_footpath" as a "footway" (dotted
-- salmon)
-- 3) Render anything designated as "public_bridleway" as a "bridleway" (dotted
-- green).
-- 4) Render anything designated as "restricted_byway" as something a bit like
-- a bridleway, but with different dashes. Likewise "public_right_of_way".
-- 5) Render anything designated as "byway_open_to_all_traffic" as something
-- like a track (dashed brown)
-- 6) Render anything designated as "unclassified_county_road" or a
-- misspelling also like a track, but longer dashed brown.
--
-- These changes do mean that the the resulting database isn't any use for
-- anything other than rendering, but they do allow designations to be
-- displayed without any stylesheet changes.
-- ----------------------------------------------------------------------------
keyvalues["tracktype"] = nil
-- ----------------------------------------------------------------------------
-- Before processing footways, turn certain corridors into footways
--
-- Note that https://wiki.openstreetmap.org/wiki/Key:indoor defines
-- indoor=corridor as a closed way. highway=corridor is not documented there
-- but is used for corridors. We'll only process layer or level 0 (or nil)
-- ----------------------------------------------------------------------------
keyvalues["highway"] = fix_corridors( keyvalues["highway"], keyvalues["layer"], keyvalues["level"] )
-- ----------------------------------------------------------------------------
-- If there are different names on each side of the street, we create one name
-- containing both.
-- If "name" does not exist but "name:en" does, use that.
-- ----------------------------------------------------------------------------
keyvalues["name"] = set_name_left_right_en( keyvalues["name"], keyvalues["name:left"], keyvalues["name:right"], keyvalues["name:en"] )
-- ----------------------------------------------------------------------------
-- Move refs to consider as "official" to official_ref
-- ----------------------------------------------------------------------------
keyvalues["official_ref"] = set_official_ref( keyvalues["official_ref"], keyvalues["highway_authority_ref"], keyvalues["highway_ref"], keyvalues["admin_ref"], keyvalues["admin:ref"], keyvalues["loc_ref"], keyvalues["ref"] )
-- ----------------------------------------------------------------------------
-- Consolidate some rare highway types into ones we can display.
-- ----------------------------------------------------------------------------
keyvalues["highway"] = process_golf_tracks( keyvalues["highway"], keyvalues["golf"] )
-- ----------------------------------------------------------------------------
-- "Sabristas" sometimes add dubious names to motorway junctions. Don't show
-- them if they're not signed.
-- ----------------------------------------------------------------------------
keyvalues["name"] = suppress_unsigned_motorway_junctions( keyvalues["name"], keyvalues["highway"], keyvalues["name:signed"], keyvalues["name:absent"], keyvalues["unsigned"] )
-- ----------------------------------------------------------------------------
-- Move unsigned road refs to the name, in brackets.
-- ----------------------------------------------------------------------------
t = { keyvalues["name"], keyvalues["highway"], keyvalues["name:signed"], keyvalues["name:absent"], keyvalues["official_ref"], keyvalues["ref"], keyvalues["ref:signed"], keyvalues["unsigned"] }
suppress_unsigned_road_refs( t )
keyvalues["name"] = t[1]
keyvalues["highway"] = t[2]
keyvalues["name:signed"] = t[3]
keyvalues["name:absent"] = t[4]
keyvalues["official_ref"] = t[5]
keyvalues["ref"] = t[6]
keyvalues["ref:signed"] = t[7]
keyvalues["unsigned"] = t[8]
-- ----------------------------------------------------------------------------
-- Show natural=bracken as scrub
-- ----------------------------------------------------------------------------
if ( keyvalues["natural"] == "bracken" ) then
keyvalues["natural"] = "scrub"
end
-- ----------------------------------------------------------------------------
-- Show natural=col as natural=saddle
-- ----------------------------------------------------------------------------
if ( keyvalues["natural"] == "col" ) then
keyvalues["natural"] = "saddle"
end
-- ----------------------------------------------------------------------------
-- Render old names on farmland etc.
-- ----------------------------------------------------------------------------
if ((( keyvalues["landuse"] == "farmland" ) or
( keyvalues["natural"] == "grassland" ) or
( keyvalues["natural"] == "scrub" )) and
( keyvalues["name"] == nil ) and
( keyvalues["old_name"] ~= nil )) then
keyvalues["name"] = "(" .. keyvalues["old_name"] .. ")"
keyvalues["old_name"] = nil
end
-- ----------------------------------------------------------------------------
-- If "visibility" is set but "trail_visibility" is not, use "visibility".
-- ----------------------------------------------------------------------------
if (( keyvalues["visibility"] ~= nil ) and
( keyvalues["trail_visibility"] == nil )) then
keyvalues["trail_visibility"] = keyvalues["visibility"]
end
-- ----------------------------------------------------------------------------
-- Rationalise the various trail_visibility values into 3 sets
-- (no value) Implied good trail visibility.
--
-- intermediate Less trail visibility. Shown with wider gaps in dotted line
-- bad Even less trail visibility. Shown with wider gaps or not shown
-- (depending on designation).
--
-- "trail_visibility=unknown" is treated as "good" since it's been mapped
-- from aerial imagery. It's not explicitly referenced below.
--
-- "trail_visibility=low" is treated as "intermediate" based on looking at
-- the use in OSM.
--
-- Also treat "overgrown=yes" as "intermediate". A discussion on talk-gb was
-- largely inconclusive, but "overgrown" is the "most renderable" way to deal
-- with things like this. A later suggestion "foot:physical=no" is also
-- included.
--
-- "informal=yes" was less common in the UK (but is becoming more so).
-- ----------------------------------------------------------------------------
if (( keyvalues["trail_visibility"] == "no" ) or
( keyvalues["trail_visibility"] == "none" ) or
( keyvalues["trail_visibility"] == "nil" ) or
( keyvalues["trail_visibility"] == "horrible" ) or
( keyvalues["trail_visibility"] == "very_bad" ) or
( keyvalues["trail_visibility"] == "bad" ) or
( keyvalues["trail_visibility"] == "poor" ) or
( keyvalues["foot:physical"] == "no" )) then
keyvalues["trail_visibility"] = "bad"
end
if (( keyvalues["trail_visibility"] == "intermediate" ) or
( keyvalues["trail_visibility"] == "intermittent" ) or
( keyvalues["trail_visibility"] == "indistinct" ) or
( keyvalues["trail_visibility"] == "medium" ) or
( keyvalues["trail_visibility"] == "low" ) or
( keyvalues["overgrown"] == "yes" ) or
( keyvalues["obstacle"] == "vegetation" ) or
(( keyvalues["trail_visibility"] == nil ) and
( keyvalues["informal"] == "yes" ))) then
keyvalues["trail_visibility"] = "intermediate"
end
-- ----------------------------------------------------------------------------
-- If we have an est_width but no width, use the est_width
-- ----------------------------------------------------------------------------
if (( keyvalues["width"] == nil ) and
( keyvalues["est_width"] ~= nil )) then
keyvalues["width"] = keyvalues["est_width"]
end
-- ----------------------------------------------------------------------------
-- highway=scramble is used very occasionally
--
-- If sac_scale is unset, set it to "demanding_alpine_hiking" here so that
-- e.g. "badpathnarrow" is set lower down.
-- If it is already set, use the already-set value.
--
-- Somewhat related, if "scramble=yes" is set and "trail_visibility" isn't,
-- set "trail_visibility==intermediate" so that e.g. "badpathnarrow" is set.
-- ----------------------------------------------------------------------------
if ( keyvalues["highway"] == "scramble" ) then
keyvalues["highway"] = "path"
if ( keyvalues["sac_scale"] == nil ) then
keyvalues["sac_scale"] = "demanding_alpine_hiking"
end
end
if (( keyvalues["highway"] ~= nil ) and
( keyvalues["scramble"] == "yes" ) and
( keyvalues["sac_scale"] == nil ) and
( keyvalues["trail_visibility"] == nil )) then
keyvalues["trail_visibility"] = "intermediate"
end
-- ----------------------------------------------------------------------------
-- Suppress non-designated very low-visibility paths
-- Various low-visibility trail_visibility values have been set to "bad" above
-- to suppress from normal display.
-- The "bridge" check (on trail_visibility, not sac_scale) is because if
-- there's really a bridge there, surely you can see it?
-- ----------------------------------------------------------------------------
if (( keyvalues["highway"] ~= nil ) and
( keyvalues["designation"] == nil ) and
( keyvalues["trail_visibility"] == "bad" )) then
if ((( tonumber(keyvalues["width"]) or 0 ) >= 2 ) or
( keyvalues["width"] == "2 m" ) or
( keyvalues["width"] == "2.5 m" ) or
( keyvalues["width"] == "3 m" ) or
( keyvalues["width"] == "4 m" )) then
if ( keyvalues["bridge"] == nil ) then
keyvalues["highway"] = "badpathwide"
else
keyvalues["highway"] = "intpathwide"
end
else
if ( keyvalues["bridge"] == nil ) then
keyvalues["highway"] = "badpathnarrow"
else
keyvalues["highway"] = "intpathnarrow"
end
end
end
-- ----------------------------------------------------------------------------
-- Various low-visibility trail_visibility values have been set to "bad" above.
-- ----------------------------------------------------------------------------
if (( keyvalues["highway"] ~= nil ) and
( keyvalues["ladder"] == "yes" )) then
keyvalues["highway"] = "steps"
keyvalues["ladder"] = nil
end
-- ----------------------------------------------------------------------------
-- Where a wide width is specified on a normally narrow path, render as wider
--
-- Note that "steps" and "footwaysteps" are unchanged by the
-- pathwide / path choice below:
-- ----------------------------------------------------------------------------
if (( keyvalues["highway"] == "footway" ) or
( keyvalues["highway"] == "bridleway" ) or
( keyvalues["highway"] == "cycleway" ) or
( keyvalues["highway"] == "path" )) then
if ((( tonumber(keyvalues["width"]) or 0 ) >= 2 ) or
( keyvalues["width"] == "2 m" ) or
( keyvalues["width"] == "2.5 m" ) or
( keyvalues["width"] == "3 m" ) or
( keyvalues["width"] == "4 m" )) then
if (( keyvalues["trail_visibility"] == "bad" ) or
( keyvalues["trail_visibility"] == "intermediate" )) then
keyvalues["highway"] = "intpathwide"
else
keyvalues["highway"] = "pathwide"
end
else
if (( keyvalues["trail_visibility"] == "bad" ) or
( keyvalues["trail_visibility"] == "intermediate" )) then
keyvalues["highway"] = "intpathnarrow"
else
keyvalues["highway"] = "pathnarrow"
end
end
end
-- ----------------------------------------------------------------------------
-- Where a narrow width is specified on a normally wide track, render as
-- narrower
-- ----------------------------------------------------------------------------
if ( keyvalues["highway"] == "track" ) then
if ( keyvalues["width"] == nil ) then
keyvalues["width"] = "2"
end
if ((( tonumber(keyvalues["width"]) or 0 ) >= 2 ) or
( keyvalues["width"] == "2 m" ) or
( keyvalues["width"] == "2.5 m" ) or
( keyvalues["width"] == "2.5m" ) or
( keyvalues["width"] == "3 m" ) or
( keyvalues["width"] == "3 metres" ) or
( keyvalues["width"] == "3.5 m" ) or
( keyvalues["width"] == "4 m" ) or
( keyvalues["width"] == "5m" )) then
if (( keyvalues["trail_visibility"] == "bad" ) or
( keyvalues["trail_visibility"] == "intermediate" )) then
keyvalues["highway"] = "intpathwide"
else
keyvalues["highway"] = "pathwide"
end
else
if (( keyvalues["trail_visibility"] == "bad" ) or
( keyvalues["trail_visibility"] == "intermediate" )) then
keyvalues["highway"] = "intpathnarrow"
else
keyvalues["highway"] = "pathnarrow"
end
end
end
-- ----------------------------------------------------------------------------
-- Suppress some "demanding" paths. UK examples with sac_scale:
-- alpine_hiking:
-- http://www.openstreetmap.org/way/168426583 Crib Goch, Snowdon
-- demanding_mountain_hiking:
-- http://www.openstreetmap.org/way/114871124 Near Tryfan
-- difficult_alpine_hiking:
-- http://www.openstreetmap.org/way/334306672 Jack's Rake, Pavey Ark
-- ----------------------------------------------------------------------------
if (( keyvalues["designation"] == nil ) and
(( keyvalues["sac_scale"] == "demanding_alpine_hiking" ) or
( keyvalues["sac_scale"] == "difficult_alpine_hiking" ))) then
if ((( tonumber(keyvalues["width"]) or 0 ) >= 2 ) or
( keyvalues["width"] == "2 m" ) or
( keyvalues["width"] == "2.5 m" ) or
( keyvalues["width"] == "3 m" ) or
( keyvalues["width"] == "4 m" )) then
keyvalues["highway"] = "badpathwide"
else
keyvalues["highway"] = "badpathnarrow"
end
end
-- ----------------------------------------------------------------------------
-- The OSM Carto derivative that I'm using still tries to second-guess paths
-- as footway or cycleway. We don't want to do this - set "designated" to
-- "yes"
--
-- First - lose "access=designated", which is meaningless.
-- ----------------------------------------------------------------------------
if ( keyvalues["access"] == "designated" ) then
keyvalues["access"] = nil
end
if ( keyvalues["foot"] == "designated" ) then
keyvalues["foot"] = "yes"
end
if ( keyvalues["bicycle"] == "designated" ) then
keyvalues["bicycle"] = "yes"
end
if ( keyvalues["horse"] == "designated" ) then
keyvalues["horse"] = "yes"
end
-- ----------------------------------------------------------------------------
-- Handle dodgy access tags. Note that this doesn't affect my "designation"
-- processing, but may be used by the main style, as "foot", "bicycle" and
-- "horse" are all in as columns.
-- ----------------------------------------------------------------------------
if (keyvalues["access:foot"] == "yes") then
keyvalues["access:foot"] = nil
keyvalues["foot"] = "yes"
end
if (keyvalues["access:bicycle"] == "yes") then
keyvalues["access:bicycle"] = nil
keyvalues["bicycle"] = "yes"
end
if (keyvalues["access:horse"] == "yes") then
keyvalues["access:horse"] = nil
keyvalues["horse"] = "yes"
end
-- ----------------------------------------------------------------------------
-- On footpaths, if foot=no set access=no
--
-- Tracks etc. that aren't narrow won't be "pathnarrow" at this stage, and we
-- shouldn't set "access" based on "foot"
--
-- Things that are narrow but have a designation will either not be private to
-- foot traffic or should be picked up by the TRO etc. handling below.
-- ----------------------------------------------------------------------------
if (( keyvalues["highway"] == "pathnarrow" ) and
(( keyvalues["foot"] == "private" ) or
( keyvalues["foot"] == "no" )) and
(( keyvalues["bicycle"] == nil ) or
( keyvalues["bicycle"] == "private" ) or
( keyvalues["bicycle"] == "no" )) and
(( keyvalues["horse"] == nil ) or
( keyvalues["horse"] == "private" ) or
( keyvalues["horse"] == "no" ))) then
keyvalues["access"] = "no"
end
-- ----------------------------------------------------------------------------
-- When handling TROs etc. we test for "no", not private, hence this change:
-- ----------------------------------------------------------------------------
if ( keyvalues["access"] == "private" ) then
keyvalues["access"] = "no"
end
if ( keyvalues["foot"] == "private" ) then
keyvalues["foot"] = "no"
end
if ( keyvalues["bicycle"] == "private" ) then
keyvalues["bicycle"] = "no"
end
if ( keyvalues["horse"] == "private" ) then
keyvalues["horse"] = "no"
end
-- ----------------------------------------------------------------------------
-- Here we apply the track grade rendering to road designations:
-- unpaved roads unpaved
-- narrow unclassigned_county_road ucrnarrow
-- wide unclassigned_county_road ucrwide
-- narrow BOAT boatnarrow
-- wide BOAT boatwide
-- narrow restricted byway rbynarrow
-- wide restricted byway rbywide
--
-- prow_ref is appended in brackets if present.
-- ----------------------------------------------------------------------------
if (( keyvalues["highway"] == "unclassified" ) and
(( keyvalues["surface"] == "unpaved" ) or
( keyvalues["surface"] == "gravel" ))) then
keyvalues["highway"] = "unpaved"
end
if ((( keyvalues["highway"] == "residential" ) or
( keyvalues["highway"] == "service" )) and
(( keyvalues["surface"] == "unpaved" ) or
( keyvalues["surface"] == "gravel" ))) then
keyvalues["highway"] = "track"
end
if (( keyvalues["designation"] == "unclassified_county_road" ) or
( keyvalues["designation"] == "unclassified_country_road" ) or
( keyvalues["designation"] == "unclassified_highway" ) or
( keyvalues["designation"] == "unclassified_road" ) or
( keyvalues["designation"] == "unmade_road" ) or
( keyvalues["designation"] == "public_highway" ) or
( keyvalues["designation"] == "unclassified_highway;public_footpath" ) or
( keyvalues["designation"] == "unmade_road" ) or
( keyvalues["designation"] == "adopted" ) or
( keyvalues["designation"] == "unclassified_highway;public_bridleway" ) or
( keyvalues["designation"] == "adopted highway" ) or
( keyvalues["designation"] == "adopted_highway" ) or
( keyvalues["designation"] == "unclassified_highway;byway_open_to_all_traffic" ) or
( keyvalues["designation"] == "adopted_highway;public_footpath" ) or
( keyvalues["designation"] == "tertiary_highway" ) or
( keyvalues["designation"] == "public_road" ) or
( keyvalues["designation"] == "quiet_lane;unclassified_highway" ) or
( keyvalues["designation"] == "unclassified_highway;quiet_lane" )) then
if (( keyvalues["highway"] == "steps" ) or
( keyvalues["highway"] == "intpathnarrow" ) or
( keyvalues["highway"] == "pathnarrow" )) then
keyvalues["highway"] = "ucrnarrow"
else
if (( keyvalues["highway"] == "service" ) or
( keyvalues["highway"] == "road" ) or
( keyvalues["highway"] == "track" ) or
( keyvalues["highway"] == "intpathwide" ) or
( keyvalues["highway"] == "pathwide" )) then
keyvalues["highway"] = "ucrwide"
end
end
if ( keyvalues["prow_ref"] ~= nil ) then
if ( keyvalues["name"] == nil ) then
keyvalues["name"] = "(" .. keyvalues["prow_ref"] .. ")"
keyvalues["prow_ref"] = nil
else
keyvalues["name"] = keyvalues["name"] .. " (" .. keyvalues["prow_ref"] .. ")"
keyvalues["prow_ref"] = nil
end
end
end
if (( keyvalues["designation"] == "byway_open_to_all_traffic" ) or
( keyvalues["designation"] == "public_byway" ) or
( keyvalues["designation"] == "byway" ) or
( keyvalues["designation"] == "carriageway" )) then
if (( keyvalues["highway"] == "steps" ) or
( keyvalues["highway"] == "intpathnarrow" ) or
( keyvalues["highway"] == "pathnarrow" )) then
keyvalues["highway"] = "boatnarrow"
keyvalues["designation"] = "byway_open_to_all_traffic"
else
if (( keyvalues["highway"] == "service" ) or
( keyvalues["highway"] == "road" ) or
( keyvalues["highway"] == "track" ) or
( keyvalues["highway"] == "intpathwide" ) or
( keyvalues["highway"] == "pathwide" )) then
keyvalues["highway"] = "boatwide"
keyvalues["designation"] = "byway_open_to_all_traffic"
end
end
if ( keyvalues["prow_ref"] ~= nil ) then
if ( keyvalues["name"] == nil ) then
keyvalues["name"] = "(" .. keyvalues["prow_ref"] .. ")"
keyvalues["prow_ref"] = nil
else
keyvalues["name"] = keyvalues["name"] .. " (" .. keyvalues["prow_ref"] .. ")"
keyvalues["prow_ref"] = nil
end
end
end
-- ----------------------------------------------------------------------------
-- Note that a designated restricted_byway up some steps would be rendered
-- as a restricted_byway. I've never seen one though.
-- There is special processing for "public footpath" and "public_bridleway"
-- steps (see below) and non-designated steps are rendered as is by the
-- stylesheet.
-- ----------------------------------------------------------------------------
if (( keyvalues["designation"] == "restricted_byway" ) or
( keyvalues["designation"] == "public_right_of_way" ) or
( keyvalues["designation"] == "unclassified_highway;restricted_byway" ) or
( keyvalues["designation"] == "unknown_byway" ) or
( keyvalues["designation"] == "public_way" ) or
( keyvalues["designation"] == "tertiary_highway;restricted_byway" ) or
( keyvalues["designation"] == "orpa" ) or
( keyvalues["designation"] == "restricted_byway;quiet_lane" )) then
if (( keyvalues["highway"] == "steps" ) or
( keyvalues["highway"] == "intpathnarrow" ) or
( keyvalues["highway"] == "pathnarrow" )) then
keyvalues["highway"] = "rbynarrow"
keyvalues["designation"] = "restricted_byway"
else
if (( keyvalues["highway"] == "service" ) or
( keyvalues["highway"] == "road" ) or
( keyvalues["highway"] == "track" ) or
( keyvalues["highway"] == "intpathwide" ) or
( keyvalues["highway"] == "pathwide" )) then
keyvalues["highway"] = "rbywide"
keyvalues["designation"] = "restricted_byway"
end
end
if ( keyvalues["prow_ref"] ~= nil ) then
if ( keyvalues["name"] == nil ) then
keyvalues["name"] = "(" .. keyvalues["prow_ref"] .. ")"
keyvalues["prow_ref"] = nil
else
keyvalues["name"] = keyvalues["name"] .. " (" .. keyvalues["prow_ref"] .. ")"
keyvalues["prow_ref"] = nil
end
end
end
-- ----------------------------------------------------------------------------
-- When a value is changed we get called again. That's why there's a check
-- for "bridlewaysteps" below "before the only place that it can be set".
-- ----------------------------------------------------------------------------
if (( keyvalues["designation"] == "public_bridleway" ) or
( keyvalues["designation"] == "bridleway" ) or
( keyvalues["designation"] == "tertiary_highway;public_bridleway" ) or
( keyvalues["designation"] == "public_bridleway;public_cycleway" ) or
( keyvalues["designation"] == "public_cycleway;public_bridleway" ) or
( keyvalues["designation"] == "public_bridleway;public_footpath" )) then
if (( keyvalues["highway"] == "intpathnarrow" ) or
( keyvalues["highway"] == "pathnarrow" )) then
if (( keyvalues["trail_visibility"] == "bad" ) or
( keyvalues["trail_visibility"] == "intermediate" )) then
keyvalues["highway"] = "intbridlewaynarrow"
else
keyvalues["highway"] = "bridlewaynarrow"
end
else
if (( keyvalues["highway"] == "steps" ) or
( keyvalues["highway"] == "bridlewaysteps" )) then
keyvalues["highway"] = "bridlewaysteps"
else
if (( keyvalues["highway"] == "service" ) or
( keyvalues["highway"] == "road" ) or
( keyvalues["highway"] == "track" ) or
( keyvalues["highway"] == "intpathwide" ) or
( keyvalues["highway"] == "pathwide" )) then
if (( keyvalues["trail_visibility"] == "bad" ) or
( keyvalues["trail_visibility"] == "intermediate" )) then
keyvalues["highway"] = "intbridlewaywide"
else
keyvalues["highway"] = "bridlewaywide"
end
end
end
end
if ( keyvalues["prow_ref"] ~= nil ) then
if ( keyvalues["name"] == nil ) then
keyvalues["name"] = "(" .. keyvalues["prow_ref"] .. ")"
keyvalues["prow_ref"] = nil
else
keyvalues["name"] = keyvalues["name"] .. " (" .. keyvalues["prow_ref"] .. ")"
keyvalues["prow_ref"] = nil
end
end
end
-- ----------------------------------------------------------------------------
-- When a value is changed we get called again. That's why there's a check
-- for "footwaysteps" below "before the only place that it can be set".
--
-- Rights of way for people on foot are designated as:
-- England and Wales: public_footpath
-- Scotland: core_path (ish - more general acess rights exist)
-- Northern Ireland: public_footpath or PROW (actually "footpath" in law)
-- ----------------------------------------------------------------------------
if (( keyvalues["designation"] == "public_footpath" ) or
( keyvalues["designation"] == "core_path" ) or
( keyvalues["designation"] == "footpath" ) or
( keyvalues["designation"] == "public_footway" ) or
( keyvalues["designation"] == "public_footpath;permissive_bridleway" ) or
( keyvalues["designation"] == "public_footpath;public_cycleway" ) or
( keyvalues["designation"] == "PROW" ) or
( keyvalues["designation"] == "access_land" )) then
if (( keyvalues["highway"] == "intpathnarrow" ) or
( keyvalues["highway"] == "pathnarrow" )) then
if (( keyvalues["trail_visibility"] == "bad" ) or
( keyvalues["trail_visibility"] == "intermediate" )) then
keyvalues["highway"] = "intfootwaynarrow"
else
keyvalues["highway"] = "footwaynarrow"
end
else
if (( keyvalues["highway"] == "steps" ) or
( keyvalues["highway"] == "footwaysteps" )) then
keyvalues["highway"] = "footwaysteps"
else
if (( keyvalues["highway"] == "service" ) or
( keyvalues["highway"] == "road" ) or
( keyvalues["highway"] == "track" ) or
( keyvalues["highway"] == "intpathwide" ) or
( keyvalues["highway"] == "pathwide" )) then
if (( keyvalues["trail_visibility"] == "bad" ) or
( keyvalues["trail_visibility"] == "intermediate" )) then
keyvalues["highway"] = "intfootwaywide"
else
keyvalues["highway"] = "footwaywide"
end
end
end
end
if ( keyvalues["prow_ref"] ~= nil ) then
if ( keyvalues["name"] == nil ) then
keyvalues["name"] = "(" .. keyvalues["prow_ref"] .. ")"
keyvalues["prow_ref"] = nil
else
keyvalues["name"] = keyvalues["name"] .. " (" .. keyvalues["prow_ref"] .. ")"
keyvalues["prow_ref"] = nil
end
end
end
-- ----------------------------------------------------------------------------
-- If something is still "track" by this point change it to pathwide.
-- ----------------------------------------------------------------------------
if ( keyvalues["highway"] == "track" ) then
if (( keyvalues["trail_visibility"] == "bad" ) or
( keyvalues["trail_visibility"] == "intermediate" )) then
keyvalues["highway"] = "intpathwide"
else
keyvalues["highway"] = "pathwide"
end
end
-- ----------------------------------------------------------------------------
-- Treat access=permit as access=no (which is what we have set "private" to
-- above).
-- ----------------------------------------------------------------------------
if (( keyvalues["access"] == "permit" ) or
( keyvalues["access"] == "agricultural" ) or
( keyvalues["access"] == "forestry" ) or
( keyvalues["access"] == "delivery" ) or
( keyvalues["access"] == "military" )) then
keyvalues["access"] = "no"
end
if ( keyvalues["access"] == "customers" ) then
keyvalues["access"] = "destination"
end
-- ----------------------------------------------------------------------------
-- Don't make driveways with a designation disappear.
-- ----------------------------------------------------------------------------
if (( keyvalues["service"] == "driveway" ) and
(( keyvalues["designation"] == "public_footpath" ) or
( keyvalues["designation"] == "public_bridleway" ) or
( keyvalues["designation"] == "restricted_byway" ) or
( keyvalues["designation"] == "byway_open_to_all_traffic" ) or
( keyvalues["designation"] == "unclassified_county_road" ) or
( keyvalues["designation"] == "unclassified_country_road" ) or
( keyvalues["designation"] == "unclassified_highway" ))) then
keyvalues["service"] = nil
end
-- ----------------------------------------------------------------------------
-- If motor_vehicle=no is set on a BOAT, it's probably a TRO, so display as
-- an RBY instead
-- ----------------------------------------------------------------------------
if (( keyvalues["highway"] == "boatwide" ) and
( keyvalues["motor_vehicle"] == "no" )) then
keyvalues["highway"] = "rbywide"
end
if (( keyvalues["highway"] == "boatnarrow" ) and
( keyvalues["motor_vehicle"] == "no" )) then
keyvalues["highway"] = "rbynarrow"
end
-- ----------------------------------------------------------------------------
-- Try and detect genuinely closed public footpaths, bridleways (not just those
-- closed to motor traffic etc.). Examples with "access=no/private" are
-- picked up below; we need to make sure that those that do not get an
-- access=private tag first.
-- ----------------------------------------------------------------------------
if (( keyvalues["access"] == nil ) and
(( keyvalues["designation"] == "public_footpath" ) or
( keyvalues["designation"] == "public_bridleway" ) or
( keyvalues["designation"] == "restricted_byway" ) or
( keyvalues["designation"] == "byway_open_to_all_traffic" ) or
( keyvalues["designation"] == "unclassified_county_road" ) or
( keyvalues["designation"] == "unclassified_country_road" ) or
( keyvalues["designation"] == "unclassified_highway" )) and
( keyvalues["foot"] == "no" )) then
keyvalues["access"] = "no"
end
-- ----------------------------------------------------------------------------
-- The extra information "and"ed with "public_footpath" below checks that
-- "It's access=private and designation=public_footpath, and ordinarily we'd
-- just remove the access=private tag as you ought to be able to walk there,
-- unless there isn't foot=yes/designated to say you can, or there is an
-- explicit foot=no".
-- ----------------------------------------------------------------------------
if ((( keyvalues["access"] == "no" ) or
( keyvalues["access"] == "destination" )) and
(((( keyvalues["designation"] == "public_footpath" ) or
( keyvalues["designation"] == "public_bridleway" ) or
( keyvalues["designation"] == "restricted_byway" ) or
( keyvalues["designation"] == "byway_open_to_all_traffic" ) or
( keyvalues["designation"] == "unclassified_county_road" ) or
( keyvalues["designation"] == "unclassified_country_road" ) or
( keyvalues["designation"] == "unclassified_highway" )) and
( keyvalues["foot"] ~= nil ) and
( keyvalues["foot"] ~= "no" )) or
((( keyvalues["highway"] == "pathnarrow" ) or
( keyvalues["highway"] == "pathwide" ) or
( keyvalues["highway"] == "intpathnarrow" ) or
( keyvalues["highway"] == "intpathwide" ) or
( keyvalues["highway"] == "service" )) and
(( keyvalues["foot"] == "permissive" ) or
( keyvalues["foot"] == "yes" ))))) then
keyvalues["access"] = nil
end
-- ----------------------------------------------------------------------------
-- Render national parks and AONBs as such no matter how they are tagged.
--
-- Any with "boundary=national_park" set already will be included and won't
-- be affected by this. Most national parks and AONBs in UK have
-- "protect_class=5", but also have one of the "designation" values below.
-- Many smaller nature reserves have other values for designation and are
-- ignored here.
--
-- Previously this section also had "protect_class=2" because IE ones had that
-- and not "boundary"="national_park", but that situation seems to have changed.
-- ----------------------------------------------------------------------------
if (( keyvalues["boundary"] == "protected_area" ) and
(( keyvalues["designation"] == "national_park" ) or
( keyvalues["designation"] == "area_of_outstanding_natural_beauty" ) or
( keyvalues["designation"] == "national_scenic_area" ))) then
keyvalues["boundary"] = "national_park"
keyvalues["protect_class"] = nil
end
-- ----------------------------------------------------------------------------
-- Access land is shown with a high-zoom yellow border (to contrast with the
-- high-zoom green border of nature reserves) and with a low-opacity
-- yellow fill at all zoom levels (to contrast with the low-opacity green fill
-- at low zoom levels of nature reserves.
-- ----------------------------------------------------------------------------
if (( keyvalues["designation"] == "access_land" ) and
(( keyvalues["boundary"] == nil ) or
( keyvalues["boundary"] == "protected_area" )) and
( keyvalues["highway"] == nil )) then
keyvalues["boundary"] = "access_land"
end
-- ----------------------------------------------------------------------------
-- Render certain protect classes and designations of protected areas as
-- nature_reserve:
-- protect_class==1 "... strictly set aside to protect ... " (all sorts)
-- protect_class==4 "Habitat/Species Management Area"
--
-- There are a few instances of "leisure" being set to something else already
-- ("common", "park", "golf_course", "dog_park"). We leave that if so.
--
-- This selection does not currently include:
-- protect_class==98 "intercontinental treaties..." (e.g. world heritage)
-- ----------------------------------------------------------------------------
if ((( keyvalues["boundary"] == "protected_area" ) and
(( keyvalues["protect_class"] == "1" ) or
( keyvalues["protect_class"] == "2" ) or
( keyvalues["protect_class"] == "4" ) or
( keyvalues["designation"] == "national_nature_reserve" ) or
( keyvalues["designation"] == "local_nature_reserve" ) or
( keyvalues["designation"] == "Nature Reserve" ) or
( keyvalues["designation"] == "Marine Conservation Zone" ))) and
( keyvalues["leisure"] == nil )) then
keyvalues["leisure"] = "nature_reserve"
end
-- ----------------------------------------------------------------------------
-- Show grass schoolyards as green
-- ----------------------------------------------------------------------------
if (( keyvalues["leisure"] == "schoolyard" ) and
( keyvalues["surface"] == "grass" )) then
keyvalues["landuse"] = "grass"
keyvalues["leisure"] = nil
keyvalues["surface"] = nil
end
-- ----------------------------------------------------------------------------
-- "Nature reserve" doesn't say anything about what's inside; but one UK OSMer
-- changed "landuse" to "surface" (changeset 98859964). This undoes that.
-- ----------------------------------------------------------------------------
if (( keyvalues["leisure"] == "nature_reserve" ) and
( keyvalues["surface"] == "grass" )) then
keyvalues["landuse"] = "grass"
keyvalues["surface"] = nil
end
-- ----------------------------------------------------------------------------
-- Treat landcover=grass as landuse=grass
-- Also landuse=college_court, flowerbed
-- ----------------------------------------------------------------------------
if (( keyvalues["landcover"] == "grass" ) or
( keyvalues["landuse"] == "college_court" ) or
( keyvalues["landuse"] == "flowerbed" )) then
keyvalues["landcover"] = nil
keyvalues["landuse"] = "grass"
end
-- ----------------------------------------------------------------------------
-- Treat natural=grass as landuse=grass
-- if there is no other more appropriate tag
-- ----------------------------------------------------------------------------
if (( keyvalues["natural"] == "grass" ) and
(( keyvalues["landuse"] == nil ) and
( keyvalues["leisure"] == nil ) and
( keyvalues["aeroway"] == nil ))) then
keyvalues["landuse"] = "grass"
end