forked from Ortho4XP/Ortho4XP
/
config.py
1501 lines (1462 loc) · 53.5 KB
/
config.py
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
import os
import tkinter as tk
import tkinter.ttk as ttk
from math import ceil
from tkinter import RIDGE, E, N, S, W, filedialog
from . import airport_data, dem, filenames, imagery
from . import osm as osm
from . import overlay
from . import tile as tile
from . import ui as ui
from .common import CoverZLConfig, DecalConfig, ScreenRes
cfg_vars = {
# App
"verbosity": {
"module": "ui",
"type": int,
"default": 1,
"values": (0, 1, 2, 3),
"hint": (
"Verbosity determines the amount of information about the whole"
" process which is printed on screen. Critical errors, if any,"
" are reported in all states as well as in the Log. Values above 1"
" are probably only useful for for debug purposes."
),
},
"cleaning_level": {
"module": "ui",
"type": int,
"default": 1,
"values": (0, 1, 2, 3),
"hint": (
"Determines which temporary files are removed. Level 3 erases"
" everything except the config and what is needed for X-Plane;"
" Level 2 erases everything except what is needed to redo the"
" current step only; Level 1 allows you to redo any prior step;"
" Level 0 keeps every single file."
),
},
"overpass_server_choice": {
"module": "osm",
"type": str,
"default": "random",
"values": ["random"] + sorted(osm.overpass_servers.keys()),
"hint": (
"The (country) of the Overpass OSM server used to grab vector"
" data. It can be modified on the fly (as all _Application_"
" variables) in case of problem with a particular server."
),
},
"skip_downloads": {
"module": "tile",
"type": bool,
"default": False,
"hint": (
"Will only build the DSF and TER files but not the textures"
" (neither download nor convert). This could be useful in cases"
" where imagery cannot be shared."
),
},
"skip_converts": {
"module": "tile",
"type": bool,
"default": False,
"hint": (
"Imagery will be downloaded but not converted from jpg to dds."
" Some user prefer to postprocess imagery with third party"
" softwares prior to the dds conversion. In that case Step 3 needs"
" to be run a second time after the retouch work."
),
},
"max_convert_slots": {
"module": "tile",
"type": int,
"default": 4,
"values": (1, 2, 3, 4, 5, 6, 7, 8),
"hint": (
"Number of parallel threads for dds conversion. Should be mainly"
" dictated by the number of cores in your CPU."
),
},
"check_tms_response": {
"module": "imagery",
"type": bool,
"default": True,
"hint": (
"When set, internal server errors (HTTP [500] and the likes)"
" yields new requests, if not a white texture is used in place."
),
},
"http_timeout": {
"module": "imagery",
"type": float,
"default": 10,
"hint": "Delay before we decide that a http request is timed out.",
},
"max_connect_retries": {
"module": "imagery",
"type": int,
"default": 5,
"hint": (
"How much times do we try again after a failed connection for"
" imagery request. Only used if check_tms_response is set to True."
),
},
"max_baddata_retries": {
"module": "imagery",
"type": int,
"default": 5,
"hint": (
"How much times do we try again after an internal server error for"
" an imagery request. Only used if check_tms_response is set to"
" True."
),
},
"ovl_exclude_pol": {
"module": "overlay",
"type": list,
"default": [0],
"hint": (
"Indices of polygon types which one would like to left aside in"
" the extraction of overlays. The list of these indices in front"
' of their name can be obtained by running the "extract overlay"'
" process with verbosity = 2 (skip facades that can be numerous)"
" or 3. Index 0 corresponds to beaches in Global and HD sceneries."
" Strings can be used in places of indices, in that case any"
" polygon_def that contains that string is excluded, and the"
" string can begin with a ! to invert the matching. As an exmaple,"
' ["!.for"] would exclude everything but forests.'
),
},
"ovl_exclude_net": {
"module": "overlay",
"type": list,
"default": [],
"hint": (
"Indices of road types which one would like to left aside in the"
" extraction of overlays. The list of these indices is can be in"
" the roads.net file within X-Plane Resources, but some sceneries"
" use their own corresponding net definition file. Powerlines have"
" index 22001 in XP11 roads.net default file."
),
},
"xplane_install_dir": {
"type": str,
"default": "<X-Plane Top Level directory>",
"hint": (
"Your X-Plane top-level directory. Used to find and parse the"
' X-Plane apt.dat files. Also used for "1-click" linking of tiles'
" from Ortho4XP to the X-Plane Custom Scenery folder. Supersedes"
' the old "custom_scenery_dir" config option'
),
},
"custom_overlay_src": {
"module": "overlay",
"type": str,
"default": "",
"hint": (
"The directory containing the sceneries with the overlays you"
" would like to extract. You need to select the level of directory"
" just _ABOVE_ Earth nav data."
),
},
# Vector
"apt_smoothing_pix": {
"type": int,
"default": 8,
"hint": (
"How much gaussian blur is applied to the elevation raster for the"
" look up of altitude over airports. Unit is the evelation raster"
" pixel size."
),
},
"road_level": {
"type": int,
"default": 1,
"values": (0, 1, 2, 3, 4, 5),
"hint": (
"Allows to level the mesh along roads and railways. Zero means"
' nothing such is included; "1" looks for banking ways among'
' motorways, primary and secondary roads and railway tracks; "2"'
' adds tertiary roads; "3" brings residential and unclassified'
' roads; "4" takes service roads, and 5 finishes with tracks.'
" Purge the small_roads.osm cached data if you change your mind in"
" between the levels 2-5."
),
},
"road_banking_limit": {
"type": float,
"default": 0.5,
"hint": (
"How much sloped does a roads need to be to be in order to be"
" included in the mesh levelling process. The value is in meters,"
" measuring the height difference between a point in the center of"
" a road node and its closest point on the side of the road."
),
},
"lane_width": {
"type": float,
"default": 5,
"hint": (
"With (in meters) to be used for buffering that part of the road"
" network that requires levelling."
),
},
"max_levelled_segs": {
"type": int,
"default": 100000,
"hint": (
"This limits the total number of roads segments included for mesh"
" levelling, in order to keep triangle count under control in case"
" of abundant OSM data."
),
},
"water_simplification": {
"type": float,
"default": 0,
"hint": (
"In case the OSM data for water areas would become too large, this"
" parameter (in meter) can be used for node simplification."
),
},
"min_area": {
"type": float,
"default": 0.001,
"hint": (
"Minimum area (in km^2) a water patch needs to be in order to be"
" included in the mesh as such. Contiguous water patches are"
" merged before area computation."
),
},
"max_area": {
"type": float,
"default": 200,
"hint": (
"Any water patch larger than this quantity (in km^2) will be"
" masked like the sea."
),
},
"clean_bad_geometries": {
"type": bool,
"default": True,
"hint": (
"When set, all OSM geometries are checked for self-intersection"
" and merged between themselves in case of overlapping, allowing"
" (hopefully!) to go around most OSM errors. This is"
" computationally expensive, especially in places where OSM"
" road/water data is detailed, and this is the reason for this"
" switch, but if you are not in a hurry it is probably wise"
" leaving it always activated."
),
},
"mesh_zl": {
"type": int,
"default": 19,
"values": (16, 17, 18, 19, 20),
"hint": (
"The mesh will be preprocessed to accept later any combination of"
" imageries up to and including a zoomlevel equal to mesh_zl."
" Lower value could save a few tens of thousands triangles, but"
" put a limitation on the maximum allowed imagery zoomlevel."
),
},
# Mesh
"curvature_tol": {
"type": float,
"default": 2,
"hint": (
"This parameter is intrinsically linked the mesh final density."
" Mesh refinement is mostly based on curvature computations on the"
" elevation data (the exact decision rule can be found in _"
" triunsuitable() _ in Utils/Triangle4XP.c). A higher curvature"
" tolerance yields fewer triangles."
),
},
"apt_curv_tol": {
"type": float,
"default": 0.5,
"hint": (
"If smaller, it supersedes curvature_tol over airports"
" neighbourhoods."
),
},
"apt_curv_ext": {
"type": float,
"default": 0.5,
"hint": (
"Extent (in km) around the airports where apt_curv_tol applies."
),
},
"coast_curv_tol": {
"type": float,
"default": 1,
"hint": "If smaller, it supersedes curvature_tol along the coastline.",
},
"coast_curv_ext": {
"type": float,
"default": 0.5,
"hint": (
"Extent (in km) around the coastline where coast_curv_tol applies."
),
},
"limit_tris": {
"type": int,
"default": 0,
"hint": (
"If non zero, upper bound on the number of final triangles in the"
" mesh."
),
},
"hmin": {
"type": float,
"default": 0,
"hint": (
"The mesh algorithm will not try to subdivide triangles whose"
" shortest edge is already smaller than hmin (in meters). If hmin"
" is smaller than half of the levation data step size, it will"
" default to it anyhow (its default zero value thus means : as"
" good as the DEM can do)."
),
},
"min_angle": {
"type": float,
"default": 10,
"hint": (
"The mesh algorithm will try to not have mesh triangles with"
" second smallest angle less than the value (in deg) of min_angle"
" (prior to v1.3 it was the smallest, not second smallest) The"
" goal behind this is to avoid potential artifacts when a triangle"
" vertex is very close the the middle of its facing edge."
),
},
"sea_smoothing_mode": {
"type": str,
"default": "zero",
"values": ["zero", "mean", "none"],
"hint": (
"Zero means that all nodes of sea triangles are set to zero"
" elevation. With mean, some kind of smoothing occurs (triangles"
" are levelled one at a time to their mean elevation), None (a"
" value mostly appropriate for DEM resolution of 10m and less),"
" positive altitudes of sea nodes are kept intact, only negative"
" ones are brought back to zero, this avoids to create unrealistic"
" vertical cliffs if the coastline vector data was lower res."
),
},
"water_smoothing": {
"type": int,
"default": 10,
"hint": (
"Number of smoothing passes over all inland water triangles"
" (sequentially set to their mean elevation)."
),
},
"iterate": {
"type": int,
"default": 0,
"hint": (
"Allows to refine a mesh using higher resolution elevation data of"
" local scope only (requires Gdal), typically LIDAR data. Having"
" an iterate number is handy to go backward one step when some"
" choice of parameters needs to be revised. REQUIRES"
" cleaning_level=0."
),
},
# Masks
"mask_zl": {
"type": int,
"default": 14,
"values": (14, 15, 16),
"hint": (
"The zoomlevel at which the (sea) water masks are built. Masks are"
" used for alpha channel, and this channel usually requires less"
" resolution than the RGB ones, the reason for this (VRAM saving)"
" parameter. If the coastline and elevation data are very"
" detailed, it might be interesting to lift this parameter up so"
" that the masks can reproduce this complexity."
),
},
"masks_width": {
"type": list,
"default": 100,
"hint": (
"Maximum extent of the masks perpendicularly to the coastline"
" (rough definition). NOTE: The value is now in meters, it used to"
" be in ZL14 pixel size in earlier verions, the scale is roughly"
" one to ten between both."
),
},
"masking_mode": {
"type": str,
"default": "sand",
"values": ["sand", "rocks", "3steps"],
"hint": (
"A selection of three tentative masking algorithms (still looking"
" for the Holy Grail...). The first two (sand and rocks) requires"
" masks_width to be a single value; the third one (3steps)"
' requires a list of the form [a,b,c] for masks width: "a" is the'
" length in meters of a first transition from plain imagery at the"
' shoreline towards ratio_water transparency, "b" is the second'
" extent zone where transparency level is kept constant equal to"
' ratio_water, and "c" is the last extent where the masks'
" eventually fade to nothing. The transition with rocks is more"
" abrupt than with sand."
),
},
"use_masks_for_inland": {
"type": bool,
"default": False,
"hint": (
"Will use masks for the inland water (lakes, rivers, etc) too,"
" instead of the default constant transparency level determined by"
" ratio_water. This is VRAM expensive and presumably not really"
" worth the price."
),
},
"imprint_masks_to_dds": {
"type": bool,
"default": False,
"hint": (
"Will apply masking directly to dds textures (at the Build"
" Imagery/DSF step) rather than using external png files. This"
" doubles the file size of masked textures (dxt5 vs dxt1) but"
" reduce the overall VRAM footprint (a matter of choice!)"
),
},
"masks_use_DEM_too": {
"type": bool,
"default": False,
"hint": (
"If you have acces to high resolutions DEMs (really shines with 5m"
" or lower), you can use the elevation in addition to the vector"
" data in order to draw masks with higher precision. If the DEM is"
" not high res, this option will yield unpleasant pixellisation."
),
},
"masks_custom_extent": {
"type": str,
"default": "",
"hint": (
"Yet another tentative to draw masks with maximizing the use of"
' the good imagery part. Requires to draw (JOSM) the "good'
' imagery" threshold first, but it could be one order of magnitude'
" faster to do compared to hand tweaking the masks and the"
" imageries one by one."
),
},
# DSF/Imagery
"default_website": {"type": str, "default": "", "hint": ""},
"default_zl": {"type": int, "default": 16, "hint": ""},
"zone_list": {"type": list, "default": [], "hint": ""},
"cover_airports_with_highres": {
"type": str,
"default": "False",
"values": ("False", "True", "ICAO", "Progressive", "Existing"),
"hint": (
"When set to True, textures above airports will be upgraded to a"
" higher zoomlevel, the imagery being the same as the one they"
" would otherwise receive.\nIn ICAO mode, this will be limited to"
" airports with an ICAO code (for tiles with so many"
" airports).\nIn Progressive mode, custom ZL zones will"
" automatically be computed along all the runway axes, from"
' "cover_zl" (highest resolution near the airport, see below) up'
' to "base_zl" (lowest). See also cover_screen_res, cover_fov, and'
' cover_fpa.\nIn "Existing" mode, (try to) derive custom zl zones'
" from the textures directory of an existing tile."
),
"short_name": "high_zl_airports",
},
"cover_extent": {
"type": float,
"default": 1,
"hint": (
'Only used in True or ICAO mode (see "high_zl_airports")\nThe'
" extent (in km) past the airport boundary taken into account for"
" higher ZL.\nNote that for VRAM efficiency higher ZL textures are"
" fully used on their whole extent as soon as part of them are"
" needed."
),
},
"cover_zl": {
"type": CoverZLConfig,
"default": 18,
"hint": (
"Only used in True, ICAO or Progressive mode (see"
' "high_zl_airports")\nIn True or ICAO mode, this is the zoomlevel'
" with which to cover the airports zone.\nNote that if the"
" cover_zl is lower than the zoomlevel which would otherwise be"
" applied on a specific zone, the latter is used.\nIn Progressive"
" mode, this is the highest desired ZL, near the airport (lowest"
" is set to the base_zl).\nIt can be either an int, or dict of the"
' form {"non-icao": 17, "icao": 18, "KBSP": 19, "L52": 16} ("icao"'
' and "non-icao" are required)'
),
},
"cover_screen_res": {
"type": ScreenRes,
"default": "HD_1080p",
"values": [str(res) for res in ScreenRes],
"hint": (
'Only used in Progressive mode (see "high_zl_airports")\nThe'
" screen resolution you are expecting to use the most in the"
" simulator."
),
},
"cover_fov": {
"type": float,
"default": 60.0,
"hint": (
'Only used in Progressive mode (see "high_zl_airports")\nThe Field'
" of View you are are expecting to use in the simulator."
),
},
"cover_fpa": {
"type": float,
"default": 10,
"hint": (
'Only used in Progressive mode (see "high_zl_airports")\nThe'
" higher you are, the less texture resolution you need."
" Progressive mode uses this Flight Path Angle (from the runway"
" outward) to progressively decrease the Zoom Level of the"
" textures.\nThe total tile size can very drastically increase as"
" you lower this value. The default of 10 degrees was found"
" visually acceptable, with a decent tile size."
),
},
"cover_greediness": {
"type": int,
"default": 1,
"hint": (
'Only used in Progressive mode (see "high_zl_airports")\nOptimize'
' texture usage, by "eating up" any ZLn-1 texture being'
' "greediness_threshold"-percent covered by ZLn textures\nWill'
" look up to 'greediness' lower zoom levels"
),
},
"cover_greediness_threshold": {
"type": float,
"default": 0.70,
"hint": (
'Only used in Progressive mode (see "high_zl_airports")\nOptimize'
' texture usage, by "eating up" any ZLn-1 texture being'
' "greediness_threshold"-percent covered by ZLn textures\nWill'
" look up to 'greediness' lower zoom levels"
),
},
"sea_texture_blur": {
"type": float,
"default": 0,
"hint": (
'For layers of type "mask" in combined providers imageries,'
" determines the extent (in meters) of the blur radius applied."
" This allows to smoothen some sea imageries where the wave or"
" reflection pattern was too much present."
),
},
"add_low_res_sea_ovl": {
"type": bool,
"default": False,
"hint": (
"Will add an extra texture layer over the sea (with constant alpha"
" channel given by ratio_water as for inland water), based on a"
" low resolution imagery with global coverage. Masks with their"
" full resolution imagery are still being used when present, the"
" final render is a composite of both. The default imagery with"
" code SEA can be changed as any other imagery defined in the"
" Providers directory, it needs to have a max_zl defined and is"
" used at its max_zl."
),
},
"experimental_water": {
"type": int,
"default": 0,
"values": (0, 1, 2, 3),
"hint": (
"If non zero, replaces X-Plane water by a custom normal map over"
" low res ortho-imagery (requires XP11 but turns water rendering"
" more XP10 alike). The value 0 corresponds to legacy X-Plane"
" water, 1 replaces it for inland water only, 2 over sea water"
" only, and 3 over both. Values 2 and 3 should always be used in"
' combination with "imprint_masks_to_dds".\n\nThis experimental'
" feature has two strong downsides: 1) the waves are static rather"
" dynamical (would require a plugin to update the normal_map as"
" X-Plane does) and 2) the wave height is no longer weather"
" dependent. On the other hand, waves might have less repetitive"
" patterns and some blinking in water reflections might be"
" improved too; users are welcome to improve the provided"
" water_normal_map.dds (Gimp can be used to edit the mipmaps"
" individually)."
),
},
"ratio_water": {
"type": float,
"default": 0.25,
"hint": (
"Inland water rendering is made of two layers : one bottom layer"
' of "X-Plane water" and one overlay layer of orthophoto with'
" constant level of transparency applied. The parameter"
" ratio_water (values between 0 and 1) determines how much"
" transparency is applied to the orthophoto. At zero, the"
" orthophoto is fully opaque and X-Plane water cannot be seen ; at"
" 1 the orthophoto is fully transparent and only the X-Plane water"
" is seen."
),
},
"normal_map_strength": {
"type": float,
"default": 1,
"hint": (
"Orthophotos by essence already contain the part of the shading"
" burned in (here by shading we mean the amount of reflected light"
" in the camera direction as a function of the terrain slope, not"
" the shadows). This option allows to tweak the normal coordinates"
' of the mesh in the DSF to avoid "overshading", but it has side'
" effects on the way X-Plane computes scenery shadows. Used to be"
" 0.3 by default in earlier versions, the default is now 1 which"
" means exact normals.}, "
),
},
"terrain_casts_shadows": {
"type": bool,
"default": True,
"hint": (
"If unset, the terrain itself will not cast (but still receive!)"
" shadows. This option is only meaningful if scenery shadows are"
" opted for in the X-Plane graphics settings."
),
"short_name": "terrain_casts_shadow",
},
"overlay_lod": {
"type": float,
"default": 25000,
"hint": (
"Distance until which overlay imageries (that is orthophotos over"
" water) are drawn. Lower distances have a positive impact on"
" frame rate and VRAM usage, and IFR flyers will probably need a"
" higher value than VFR ones."
),
},
"use_decal_on_terrain": {
"type": DecalConfig,
"default": True,
"hint": "\n".join(
[
"Terrain files for all but water triangles will or will not"
" contain a decal directive according to this value.",
"The effect is noticeable at very low altitude and helps to"
" overcome the orthophoto blur at such levels.",
"Can be slightly distracting at higher altitude.",
"Can be either :",
"- a boolean : if True, apply default decals according to"
" the ZL",
"- an int : if the ZL is at or above this value, a default"
" decal is applied",
'- a dict of {"zl": "<dcl_file_from_XP11/Resources/default'
' scenery/1000 decals>"} :',
" => both zl and the decal file must be enclosed in"
" double-quotes",
" => the corresponding decal is applied to each specified zl,"
" or no decal if omitted",
]
),
},
# Other
"custom_dem": {
"type": str,
"default": "",
"hint": (
"Path to an elevation data file to be used instead of the default"
" Viewfinderpanoramas.org ones (J. de Ferranti). The raster must"
" be in geopgraphical coordinates (EPSG:4326) but the extent need"
" not match the tile boundary (requires Gdal). Regions of the tile"
" that are not covered by the raster are mapped to zero altitude"
" (can be useful for high resolution data over islands in"
" particular). "
),
},
"fill_nodata": {
"type": bool,
"default": True,
"hint": (
"When set, the no_data values in the raster will be filled by a"
" nearest neighbour algorithm. If unset, they are turned into zero"
" (can be useful for rasters with no_data over the whole oceanic"
" part or partial LIDAR data)."
),
},
}
list_app_vars = [
"verbosity",
"cleaning_level",
"overpass_server_choice",
"skip_downloads",
"skip_converts",
"max_convert_slots",
"check_tms_response",
"http_timeout",
"max_connect_retries",
"max_baddata_retries",
"ovl_exclude_pol",
"ovl_exclude_net",
"xplane_install_dir",
"custom_overlay_src",
]
gui_app_vars_short = list_app_vars[:-2]
gui_app_vars_long = list_app_vars[-2:]
list_vector_vars = [
"apt_smoothing_pix",
"road_level",
"road_banking_limit",
"lane_width",
"max_levelled_segs",
"water_simplification",
"min_area",
"max_area",
"clean_bad_geometries",
"mesh_zl",
]
list_mesh_vars = [
"curvature_tol",
"apt_curv_tol",
"apt_curv_ext",
"coast_curv_tol",
"coast_curv_ext",
"limit_tris",
"hmin",
"min_angle",
"sea_smoothing_mode",
"water_smoothing",
"iterate",
]
list_mask_vars = [
"mask_zl",
"masks_width",
"masking_mode",
"use_masks_for_inland",
"imprint_masks_to_dds",
"masks_use_DEM_too",
"masks_custom_extent",
]
list_dsf_vars = [
"cover_airports_with_highres",
"cover_extent",
"cover_zl",
"cover_screen_res",
"cover_fov",
"cover_fpa",
"cover_greediness",
"cover_greediness_threshold",
"ratio_water",
"overlay_lod",
"sea_texture_blur",
"add_low_res_sea_ovl",
"experimental_water",
"normal_map_strength",
"terrain_casts_shadows",
"use_decal_on_terrain",
]
list_other_vars = ["custom_dem", "fill_nodata"]
list_tile_vars = (
list_vector_vars
+ list_mesh_vars
+ list_mask_vars
+ list_dsf_vars
+ list_other_vars
+ ["default_website", "default_zl", "zone_list"]
)
list_global_cfg = (
list_app_vars
+ list_vector_vars
+ list_mesh_vars
+ list_mask_vars
+ list_dsf_vars
)
############################################################################################
# Initialization to default values
for var in cfg_vars:
target = (
cfg_vars[var]["module"] + "." + var
if "module" in cfg_vars[var]
else var
)
exec(target + "=cfg_vars['" + var + "']['default']")
############################################################################################
# Update from Global Ortho4XP.cfg
try:
with open(os.path.join(filenames.Ortho4XP_dir, "Ortho4XP.cfg"), "r") as f:
for line in f.readlines():
line = line.strip()
if not line:
continue
if line[0] == "#":
continue
try:
(var, value) = line.split("=")
# compatibility with config files from version <= 1.20
if value and value[0] in ('"', "'"):
value = value[1:]
if value and value[-1] in ('"', "'"):
value = value[:-1]
target = (
cfg_vars[var]["module"] + "." + var
if "module" in cfg_vars[var]
else var
)
if cfg_vars[var]["type"] in (bool, list):
cmd = target + "=" + value
else:
cmd = target + "=cfg_vars['" + var + "']['type'](value)"
exec(cmd)
except:
ui.lvprint(
1, "Global config file contains an invalide line:", line
)
except OSError:
print("No global config file found. Reverting to default values.")
############################################################################################
class Tile:
def __init__(self, lat, lon, custom_build_dir):
self.lat = lat
self.lon = lon
self.custom_build_dir = custom_build_dir
self.grouped = bool((custom_build_dir and custom_build_dir[-1] != "/"))
self.build_dir = filenames.build_dir(lat, lon, custom_build_dir)
self.dem = None
for var in list_tile_vars:
exec("self." + var + "=" + var)
def make_dirs(self):
if os.path.isdir(self.build_dir):
if not os.access(self.build_dir, os.W_OK):
ui.vprint(
0,
"OS error: Tile directory",
self.build_dir,
" is write protected.",
)
raise OSError
else:
try:
os.makedirs(self.build_dir)
except OSError as e:
ui.vprint(
0,
"OS error: Cannot create tile directory",
self.build_dir,
" check file permissions.",
)
raise e
def read_from_config(self, config_file=None):
if not config_file:
config_file = os.path.join(
self.build_dir,
"Ortho4XP_"
+ filenames.short_latlon(self.lat, self.lon)
+ ".cfg",
)
if not os.path.isfile(config_file):
config_file = os.path.join(self.build_dir, "Ortho4XP.cfg")
if not os.path.isfile(config_file):
ui.lvprint(
0,
"CFG error: No config file found for tile",
filenames.short_latlon(self.lat, self.lon),
)
return 0
try:
f = open(config_file, "r")
for line in f.readlines():
line = line.strip()
if not line:
continue
if line[0] == "#":
continue
try:
(var, value) = line.split("=")
# compatibility with config files from version <= 1.20
if value and value[0] in ('"', "'"):
value = value[1:]
if value and value[-1] in ('"', "'"):
value = value[:-1]
if cfg_vars[var]["type"] in (bool, list):
cmd = "self." + var + "=" + value
elif cfg_vars[var]["type"] is ScreenRes:
cmd = (
"self."
+ var
+ "=ScreenRes.from_config_value(value)"
)
else:
cmd = (
"self."
+ var
+ "=cfg_vars['"
+ var
+ "']['type'](value)"
)
exec(cmd)
except Exception as e:
# compatibility with zone_list config files from version <= 1.20
if "zone_list.append" in line:
try:
exec("self." + line)
except:
pass
else:
ui.vprint(2, e)
pass
f.close()
return 1
except:
ui.lvprint(
0,
"CFG error: Could not read config file for tile",
filenames.short_latlon(self.lat, self.lon),
)
return 0
def write_to_config(self, config_file=None):
if not config_file:
config_file = os.path.join(
self.build_dir,
"Ortho4XP_"
+ filenames.short_latlon(self.lat, self.lon)
+ ".cfg",
)
config_file_bak = config_file + ".bak"
try:
os.replace(config_file, config_file_bak)
except:
pass
try:
f = open(config_file, "w")
for var in list_tile_vars:
f.write(var + "=" + str(eval("self." + var)) + "\n")
f.close()
return 1
except Exception as e:
ui.vprint(2, e)
ui.lvprint(
0,
"CFG error: Could not write config file for tile",
filenames.short_latlon(self.lat, self.lon),
)
return 0
############################################################################################
############################################################################################
class Ortho4XP_Config(tk.Toplevel):
def __init__(self, parent):
tk.Toplevel.__init__(self)
self.option_add("*Font", "TkFixedFont")
self.title("Ortho4XP Config")
self.columnconfigure(0, weight=1)
self.rowconfigure(0, weight=1)
if self.winfo_screenheight() >= 1024:
self.pady = 5
else:
self.pady = 1
# Ortho4XP main window reference
self.parent = parent
# Frames
self.main_frame = tk.Frame(
self, border=4, relief=RIDGE, bg="light green"
)
self.frame_cfg = tk.Frame(
self.main_frame, border=0, padx=5, pady=self.pady, bg="light green"
)
self.frame_dem = tk.Frame(
self.frame_cfg, border=0, padx=0, pady=self.pady, bg="light green"
)
self.frame_lastbtn = tk.Frame(
self.main_frame, border=0, padx=5, pady=self.pady, bg="light green"
)
# Frames properties
for j in range(8):
self.frame_cfg.columnconfigure(j, weight=1)
self.frame_cfg.rowconfigure(0, weight=1)
for j in range(6):
self.frame_lastbtn.columnconfigure(j, weight=1)
self.frame_lastbtn.rowconfigure(0, weight=1)
# Frames placement
self.main_frame.grid(row=0, column=0, sticky=N + S + W + E)
self.frame_cfg.grid(row=0, column=0, pady=10, sticky=N + S + E + W)
self.frame_lastbtn.grid(row=1, column=0, pady=10, sticky=N + S + E + W)