pyvalhalla-git 3.5.1.post132__cp39-cp39-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- _valhalla.cp39-win_amd64.pyd +0 -0
- pyvalhalla_git-3.5.1.post132.data/platlib/.load-order-pyvalhalla_git-3.5.1.post132 +20 -0
- pyvalhalla_git-3.5.1.post132.data/platlib/Lerc-d4ff05a506ddcfc551c350aa718ab4da.dll +0 -0
- pyvalhalla_git-3.5.1.post132.data/platlib/abseil_dll-bdd8a5a1f5a4da3f67279509940f7994.dll +0 -0
- pyvalhalla_git-3.5.1.post132.data/platlib/gdal-e68c9d36ee94002182307d221cc91ce3.dll +0 -0
- pyvalhalla_git-3.5.1.post132.data/platlib/geos-b8640de6faf146d9855a807e72427e47.dll +0 -0
- pyvalhalla_git-3.5.1.post132.data/platlib/geos_c-7d79920a3a18ad2c1ff594fcef060f0a.dll +0 -0
- pyvalhalla_git-3.5.1.post132.data/platlib/geotiff-020296779aedd28fd03f34200e6e3c61.dll +0 -0
- pyvalhalla_git-3.5.1.post132.data/platlib/jpeg62-52d863f4f0f8139faf1608976c1d91f6.dll +0 -0
- pyvalhalla_git-3.5.1.post132.data/platlib/json-c-0d6db73c6075abe84a7bdd2a2d393471.dll +0 -0
- pyvalhalla_git-3.5.1.post132.data/platlib/libcurl-bfd466d47923540033e77b192031a728.dll +0 -0
- pyvalhalla_git-3.5.1.post132.data/platlib/libexpat-6da76b3644b9424613b6d75323fcdc82.dll +0 -0
- pyvalhalla_git-3.5.1.post132.data/platlib/liblzma-9b97b163f3fff34e786ef56c4f919383.dll +0 -0
- pyvalhalla_git-3.5.1.post132.data/platlib/libpng16-45e0d625267ecee5996170051645e533.dll +0 -0
- pyvalhalla_git-3.5.1.post132.data/platlib/libprotobuf-lite-2bea258fef20ab8f71dcb2fec86675a8.dll +0 -0
- pyvalhalla_git-3.5.1.post132.data/platlib/lz4-cb6b9d0ac653fc68b286ff6ba7ef9bf5.dll +0 -0
- pyvalhalla_git-3.5.1.post132.data/platlib/msvcp140-73e7ea186a7d9ab676a764ffa64cf7e6.dll +0 -0
- pyvalhalla_git-3.5.1.post132.data/platlib/proj_9-3a2a70c01b92ddd4e14ab2bc22e06ab7.dll +0 -0
- pyvalhalla_git-3.5.1.post132.data/platlib/qhull_r-46ecfc2e889bb30a2c3af738edb6eeb9.dll +0 -0
- pyvalhalla_git-3.5.1.post132.data/platlib/sqlite3-219685aef036100e03dd97e60c61281d.dll +0 -0
- pyvalhalla_git-3.5.1.post132.data/platlib/tiff-f8c8a1908722e0556fad08f0b5c1bb6f.dll +0 -0
- pyvalhalla_git-3.5.1.post132.data/platlib/zlib1-8425906e295d322425fe840dc45228db.dll +0 -0
- pyvalhalla_git-3.5.1.post132.dist-info/DELVEWHEEL +2 -0
- pyvalhalla_git-3.5.1.post132.dist-info/METADATA +137 -0
- pyvalhalla_git-3.5.1.post132.dist-info/RECORD +39 -0
- pyvalhalla_git-3.5.1.post132.dist-info/WHEEL +5 -0
- pyvalhalla_git-3.5.1.post132.dist-info/licenses/AUTHORS +5 -0
- pyvalhalla_git-3.5.1.post132.dist-info/licenses/COPYING +22 -0
- pyvalhalla_git-3.5.1.post132.dist-info/licenses/LICENSE.md +1 -0
- pyvalhalla_git-3.5.1.post132.dist-info/top_level.txt +2 -0
- valhalla/__init__.py +41 -0
- valhalla/__main__.py +72 -0
- valhalla/__version__.py +21 -0
- valhalla/_scripts.py +46 -0
- valhalla/_valhalla.cc +81 -0
- valhalla/actor.py +118 -0
- valhalla/config.py +45 -0
- valhalla/utils.py +62 -0
- valhalla/valhalla_build_config.py +760 -0
@@ -0,0 +1,760 @@
|
|
1
|
+
#!/usr/bin/env python3
|
2
|
+
from argparse import ArgumentParser, ArgumentDefaultsHelpFormatter
|
3
|
+
import json
|
4
|
+
from typing import List, Union
|
5
|
+
|
6
|
+
|
7
|
+
def strtobool(value):
|
8
|
+
lower = str(value).lower()
|
9
|
+
if lower in {'y', 'yes', 't', 'true', 'on', '1'}:
|
10
|
+
return True
|
11
|
+
elif lower in {'n', 'no', 'f', 'false', 'off', '0'}:
|
12
|
+
return False
|
13
|
+
else:
|
14
|
+
raise ValueError('"{}" is not a valid bool value'.format(value))
|
15
|
+
|
16
|
+
|
17
|
+
class Optional:
|
18
|
+
def __init__(self, t=None):
|
19
|
+
self.type = t
|
20
|
+
|
21
|
+
|
22
|
+
# global default configuration
|
23
|
+
config = {
|
24
|
+
'mjolnir': {
|
25
|
+
'max_cache_size': 1000000000,
|
26
|
+
'id_table_size': 1300000000,
|
27
|
+
'use_lru_mem_cache': False,
|
28
|
+
'lru_mem_cache_hard_control': False,
|
29
|
+
'use_simple_mem_cache': False,
|
30
|
+
'user_agent': Optional(str),
|
31
|
+
'tile_url': Optional(str),
|
32
|
+
'tile_url_gz': Optional(bool),
|
33
|
+
'concurrency': Optional(int),
|
34
|
+
'tile_dir': '/data/valhalla',
|
35
|
+
'tile_extract': '/data/valhalla/tiles.tar',
|
36
|
+
'traffic_extract': '/data/valhalla/traffic.tar',
|
37
|
+
'incident_dir': Optional(str),
|
38
|
+
'incident_log': Optional(str),
|
39
|
+
'shortcut_caching': Optional(bool),
|
40
|
+
'graph_lua_name': Optional(str),
|
41
|
+
'admin': '/data/valhalla/admin.sqlite',
|
42
|
+
'landmarks': '/data/valhalla/landmarks.sqlite',
|
43
|
+
'timezone': '/data/valhalla/tz_world.sqlite',
|
44
|
+
'transit_dir': '/data/valhalla/transit',
|
45
|
+
'transit_feeds_dir': '/data/valhalla/transit_feeds',
|
46
|
+
'transit_bounding_box': Optional(str),
|
47
|
+
'transit_pbf_limit': 20000,
|
48
|
+
'hierarchy': True,
|
49
|
+
'shortcuts': True,
|
50
|
+
'include_platforms': False,
|
51
|
+
'include_driveways': True,
|
52
|
+
'include_construction': False,
|
53
|
+
'include_bicycle': True,
|
54
|
+
'include_pedestrian': True,
|
55
|
+
'include_driving': True,
|
56
|
+
'import_bike_share_stations': False,
|
57
|
+
'global_synchronized_cache': False,
|
58
|
+
'max_concurrent_reader_users': 1,
|
59
|
+
'reclassify_links': True,
|
60
|
+
'default_speeds_config': Optional(str),
|
61
|
+
'data_processing': {
|
62
|
+
'infer_internal_intersections': True,
|
63
|
+
'infer_turn_channels': True,
|
64
|
+
'apply_country_overrides': True,
|
65
|
+
'grid_divisions_within_tile': 32,
|
66
|
+
'use_admin_db': True,
|
67
|
+
'use_direction_on_ways': False,
|
68
|
+
'allow_alt_name': False,
|
69
|
+
'use_urban_tag': False,
|
70
|
+
'use_rest_area': False,
|
71
|
+
'scan_tar': False,
|
72
|
+
},
|
73
|
+
'logging': {'type': 'std_out', 'color': True, 'file_name': 'path_to_some_file.log'},
|
74
|
+
},
|
75
|
+
'additional_data': {'elevation': '/data/valhalla/elevation/', 'elevation_url': Optional(str)},
|
76
|
+
'loki': {
|
77
|
+
'actions': [
|
78
|
+
'locate',
|
79
|
+
'route',
|
80
|
+
'height',
|
81
|
+
'sources_to_targets',
|
82
|
+
'optimized_route',
|
83
|
+
'isochrone',
|
84
|
+
'trace_route',
|
85
|
+
'trace_attributes',
|
86
|
+
'transit_available',
|
87
|
+
'expansion',
|
88
|
+
'centroid',
|
89
|
+
'status',
|
90
|
+
],
|
91
|
+
'use_connectivity': True,
|
92
|
+
'service_defaults': {
|
93
|
+
'radius': 0,
|
94
|
+
'minimum_reachability': 50,
|
95
|
+
'search_cutoff': 35000,
|
96
|
+
'node_snap_tolerance': 5,
|
97
|
+
'street_side_tolerance': 5,
|
98
|
+
'street_side_max_distance': 1000,
|
99
|
+
'heading_tolerance': 60,
|
100
|
+
},
|
101
|
+
'logging': {
|
102
|
+
'type': 'std_out',
|
103
|
+
'color': True,
|
104
|
+
'file_name': 'path_to_some_file.log',
|
105
|
+
'long_request': 100.0,
|
106
|
+
},
|
107
|
+
'service': {'proxy': 'ipc:///tmp/loki'},
|
108
|
+
},
|
109
|
+
'thor': {
|
110
|
+
'logging': {
|
111
|
+
'type': 'std_out',
|
112
|
+
'color': True,
|
113
|
+
'file_name': 'path_to_some_file.log',
|
114
|
+
'long_request': 110.0,
|
115
|
+
},
|
116
|
+
'source_to_target_algorithm': 'select_optimal',
|
117
|
+
'service': {'proxy': 'ipc:///tmp/thor'},
|
118
|
+
'max_reserved_labels_count_astar': 2000000,
|
119
|
+
'max_reserved_labels_count_bidir_astar': 1000000,
|
120
|
+
'max_reserved_labels_count_dijkstras': 4000000,
|
121
|
+
'max_reserved_labels_count_bidir_dijkstras': 2000000,
|
122
|
+
'clear_reserved_memory': False,
|
123
|
+
'extended_search': False,
|
124
|
+
'costmatrix': {
|
125
|
+
'check_reverse_connection': False,
|
126
|
+
'allow_second_pass': False,
|
127
|
+
'max_reserved_locations': 25,
|
128
|
+
'max_iterations': 2800,
|
129
|
+
'hierarchy_limits': {
|
130
|
+
'max_up_transitions': {
|
131
|
+
'1': 400,
|
132
|
+
'2': 100,
|
133
|
+
},
|
134
|
+
},
|
135
|
+
},
|
136
|
+
'bidirectional_astar': {
|
137
|
+
'hierarchy_limits': {
|
138
|
+
'max_up_transitions': {
|
139
|
+
'1': 400,
|
140
|
+
'2': 100,
|
141
|
+
},
|
142
|
+
'expand_within_distance': {'0': 1e8, '1': 20000, '2': 5000},
|
143
|
+
}
|
144
|
+
},
|
145
|
+
'unidirectional_astar': {
|
146
|
+
'hierarchy_limits': {
|
147
|
+
'max_up_transitions': {
|
148
|
+
'1': 400,
|
149
|
+
'2': 100,
|
150
|
+
},
|
151
|
+
'expand_within_distance': {'0': 1e8, '1': 100000, '2': 5000},
|
152
|
+
}
|
153
|
+
},
|
154
|
+
},
|
155
|
+
'odin': {
|
156
|
+
'logging': {'type': 'std_out', 'color': True, 'file_name': 'path_to_some_file.log'},
|
157
|
+
'service': {'proxy': 'ipc:///tmp/odin'},
|
158
|
+
'markup_formatter': {
|
159
|
+
'markup_enabled': False,
|
160
|
+
'phoneme_format': '<TEXTUAL_STRING> (<span class=<QUOTES>phoneme<QUOTES>>/<VERBAL_STRING>/</span>)',
|
161
|
+
},
|
162
|
+
},
|
163
|
+
'meili': {
|
164
|
+
'mode': 'auto',
|
165
|
+
'customizable': [
|
166
|
+
'mode',
|
167
|
+
'search_radius',
|
168
|
+
'turn_penalty_factor',
|
169
|
+
'gps_accuracy',
|
170
|
+
'interpolation_distance',
|
171
|
+
'sigma_z',
|
172
|
+
'beta',
|
173
|
+
'max_route_distance_factor',
|
174
|
+
'max_route_time_factor',
|
175
|
+
],
|
176
|
+
'verbose': False,
|
177
|
+
'default': {
|
178
|
+
'sigma_z': 4.07,
|
179
|
+
'gps_accuracy': 5.0,
|
180
|
+
'beta': 3,
|
181
|
+
'max_route_distance_factor': 5,
|
182
|
+
'max_route_time_factor': 5,
|
183
|
+
'max_search_radius': 100,
|
184
|
+
'breakage_distance': 2000,
|
185
|
+
'interpolation_distance': 10,
|
186
|
+
'search_radius': 50,
|
187
|
+
'geometry': False,
|
188
|
+
'route': True,
|
189
|
+
'turn_penalty_factor': 0,
|
190
|
+
},
|
191
|
+
'auto': {'turn_penalty_factor': 200, 'search_radius': 50},
|
192
|
+
'pedestrian': {'turn_penalty_factor': 100, 'search_radius': 50},
|
193
|
+
'bicycle': {'turn_penalty_factor': 140},
|
194
|
+
'multimodal': {'turn_penalty_factor': 70},
|
195
|
+
'logging': {'type': 'std_out', 'color': True, 'file_name': 'path_to_some_file.log'},
|
196
|
+
'service': {'proxy': 'ipc:///tmp/meili'},
|
197
|
+
'grid': {'size': 500, 'cache_size': 100240},
|
198
|
+
},
|
199
|
+
'httpd': {
|
200
|
+
'service': {
|
201
|
+
'listen': 'tcp://*:8002',
|
202
|
+
'loopback': 'ipc:///tmp/loopback',
|
203
|
+
'interrupt': 'ipc:///tmp/interrupt',
|
204
|
+
'drain_seconds': 28,
|
205
|
+
'shutdown_seconds': 1,
|
206
|
+
'timeout_seconds': -1,
|
207
|
+
}
|
208
|
+
},
|
209
|
+
'service_limits': {
|
210
|
+
'auto': {
|
211
|
+
'max_distance': 5000000.0,
|
212
|
+
'max_locations': 20,
|
213
|
+
'max_matrix_distance': 400000.0,
|
214
|
+
'max_matrix_location_pairs': 2500,
|
215
|
+
},
|
216
|
+
'bus': {
|
217
|
+
'max_distance': 5000000.0,
|
218
|
+
'max_locations': 50,
|
219
|
+
'max_matrix_distance': 400000.0,
|
220
|
+
'max_matrix_location_pairs': 2500,
|
221
|
+
},
|
222
|
+
'taxi': {
|
223
|
+
'max_distance': 5000000.0,
|
224
|
+
'max_locations': 20,
|
225
|
+
'max_matrix_distance': 400000.0,
|
226
|
+
'max_matrix_location_pairs': 2500,
|
227
|
+
},
|
228
|
+
'pedestrian': {
|
229
|
+
'max_distance': 250000.0,
|
230
|
+
'max_locations': 50,
|
231
|
+
'max_matrix_distance': 200000.0,
|
232
|
+
'max_matrix_location_pairs': 2500,
|
233
|
+
'min_transit_walking_distance': 1,
|
234
|
+
'max_transit_walking_distance': 10000,
|
235
|
+
},
|
236
|
+
'motor_scooter': {
|
237
|
+
'max_distance': 500000.0,
|
238
|
+
'max_locations': 50,
|
239
|
+
'max_matrix_distance': 200000.0,
|
240
|
+
'max_matrix_location_pairs': 2500,
|
241
|
+
},
|
242
|
+
'motorcycle': {
|
243
|
+
'max_distance': 500000.0,
|
244
|
+
'max_locations': 50,
|
245
|
+
'max_matrix_distance': 200000.0,
|
246
|
+
'max_matrix_location_pairs': 2500,
|
247
|
+
},
|
248
|
+
'bicycle': {
|
249
|
+
'max_distance': 500000.0,
|
250
|
+
'max_locations': 50,
|
251
|
+
'max_matrix_distance': 200000.0,
|
252
|
+
'max_matrix_location_pairs': 2500,
|
253
|
+
},
|
254
|
+
'multimodal': {
|
255
|
+
'max_distance': 500000.0,
|
256
|
+
'max_locations': 50,
|
257
|
+
'max_matrix_distance': 0.0,
|
258
|
+
'max_matrix_location_pairs': 0,
|
259
|
+
},
|
260
|
+
'status': {'allow_verbose': False},
|
261
|
+
'transit': {
|
262
|
+
'max_distance': 500000.0,
|
263
|
+
'max_locations': 50,
|
264
|
+
'max_matrix_distance': 200000.0,
|
265
|
+
'max_matrix_location_pairs': 2500,
|
266
|
+
},
|
267
|
+
'truck': {
|
268
|
+
'max_distance': 5000000.0,
|
269
|
+
'max_locations': 20,
|
270
|
+
'max_matrix_distance': 400000.0,
|
271
|
+
'max_matrix_location_pairs': 2500,
|
272
|
+
},
|
273
|
+
'skadi': {'max_shape': 750000, 'min_resample': 10.0},
|
274
|
+
'isochrone': {
|
275
|
+
'max_contours': 4,
|
276
|
+
'max_time_contour': 120,
|
277
|
+
'max_distance': 25000.0,
|
278
|
+
'max_locations': 1,
|
279
|
+
'max_distance_contour': 200,
|
280
|
+
},
|
281
|
+
'trace': {
|
282
|
+
'max_distance': 200000.0,
|
283
|
+
'max_gps_accuracy': 100.0,
|
284
|
+
'max_search_radius': 100.0,
|
285
|
+
'max_shape': 16000,
|
286
|
+
'max_alternates': 3,
|
287
|
+
'max_alternates_shape': 100,
|
288
|
+
},
|
289
|
+
'bikeshare': {
|
290
|
+
'max_distance': 500000.0,
|
291
|
+
'max_locations': 50,
|
292
|
+
'max_matrix_distance': 200000.0,
|
293
|
+
'max_matrix_location_pairs': 2500,
|
294
|
+
},
|
295
|
+
'centroid': {'max_distance': 200000.0, 'max_locations': 5},
|
296
|
+
'max_exclude_locations': 50,
|
297
|
+
'max_reachability': 100,
|
298
|
+
'max_radius': 200,
|
299
|
+
'max_timedep_distance': 500000,
|
300
|
+
'max_timedep_distance_matrix': 0,
|
301
|
+
'max_alternates': 2,
|
302
|
+
'max_exclude_polygons_length': 10000,
|
303
|
+
'max_distance_disable_hierarchy_culling': 0,
|
304
|
+
'hierarchy_limits': {
|
305
|
+
'allow_modification': False,
|
306
|
+
'costmatrix': {
|
307
|
+
'max_allowed_up_transitions': {
|
308
|
+
'1': 400,
|
309
|
+
'2': 100,
|
310
|
+
},
|
311
|
+
},
|
312
|
+
'unidirectional_astar': {
|
313
|
+
'max_allowed_up_transitions': {
|
314
|
+
'1': 400,
|
315
|
+
'2': 100,
|
316
|
+
},
|
317
|
+
'max_expand_within_distance': {'0': 1e8, '1': 100000, '2': 5000},
|
318
|
+
},
|
319
|
+
'bidirectional_astar': {
|
320
|
+
'max_allowed_up_transitions': {
|
321
|
+
'1': 400,
|
322
|
+
'2': 100,
|
323
|
+
},
|
324
|
+
'max_expand_within_distance': {'0': 1e8, '1': 20000, '2': 5000},
|
325
|
+
},
|
326
|
+
},
|
327
|
+
'allow_hard_exclusions': False,
|
328
|
+
},
|
329
|
+
'statsd': {
|
330
|
+
'host': Optional(str),
|
331
|
+
'port': 8125,
|
332
|
+
'prefix': 'valhalla',
|
333
|
+
'batch_size': Optional(int),
|
334
|
+
'tags': Optional(list),
|
335
|
+
},
|
336
|
+
}
|
337
|
+
|
338
|
+
help_text = {
|
339
|
+
'mjolnir': {
|
340
|
+
'max_cache_size': 'Number of bytes per thread used to store tile data in memory',
|
341
|
+
'id_table_size': 'Value controls the initial size of the Id table',
|
342
|
+
'use_lru_mem_cache': 'Use memory cache with LRU eviction policy',
|
343
|
+
'lru_mem_cache_hard_control': 'Use hard memory limit control for LRU memory cache (i.e. on every put) - never allow overcommit',
|
344
|
+
'use_simple_mem_cache': 'Use memory cache within a simple hash map the clears all tiles when overcommitted',
|
345
|
+
'user_agent': 'User-Agent http header to request single tiles',
|
346
|
+
'tile_url': 'Http location to read tiles from if they are not found in the tile_dir, e.g.: http://your_valhalla_tile_server_host:8000/some/Optional/path/{tilePath}?some=Optional&query=params. Valhalla will look for the {tilePath} portion of the url and fill this out with a given tile path when it make a request for that tile',
|
347
|
+
'tile_url_gz': 'Whether or not to request for compressed tiles',
|
348
|
+
'concurrency': 'How many threads to use in the concurrent parts of tile building',
|
349
|
+
'tile_dir': 'Location to read/write tiles to/from',
|
350
|
+
'tile_extract': 'Location to read tiles from tar',
|
351
|
+
'traffic_extract': 'Location to read traffic from tar',
|
352
|
+
'incident_dir': 'Location to read incident tiles from',
|
353
|
+
'incident_log': 'Location to read change events of incident tiles',
|
354
|
+
'shortcut_caching': 'Precaches the superseded edges of all shortcuts in the graph. Defaults to false',
|
355
|
+
'graph_lua_name': 'Location of the lua file to use for graph customization during tile building instead of default one',
|
356
|
+
'admin': 'Location of sqlite file holding admin polygons created with valhalla_build_admins',
|
357
|
+
'landmarks': 'Location of sqlite file holding landmark POI created with valhalla_build_landmarks',
|
358
|
+
'timezone': 'Location of sqlite file holding timezone information created with valhalla_build_timezones',
|
359
|
+
'transit_dir': 'Location of intermediate transit tiles created with valhalla_build_transit',
|
360
|
+
'transit_feeds_dir': 'Location of all GTFS transit feeds, needs to contain one subdirectory per feed',
|
361
|
+
'transit_bounding_box': 'Add comma separated bounding box values to only download transit data inside the given bounding box',
|
362
|
+
'transit_pbf_limit': 'Limit individual PBF files to this many trips (needed for PBF\'s stupid size limit)',
|
363
|
+
'hierarchy': 'bool indicating whether road hierarchy is to be built - default to True',
|
364
|
+
'shortcuts': 'bool indicating whether shortcuts are to be built - default to True',
|
365
|
+
'include_platforms': 'bool indicating whether to include highway=platform - default to False',
|
366
|
+
'include_driveways': 'bool indicating whether private driveways are included - default to True',
|
367
|
+
'include_construction': 'bool indicating where roads under construction are included - default to False',
|
368
|
+
'include_bicycle': 'bool indicating whether cycling only ways are included - default to True',
|
369
|
+
'include_pedestrian': 'bool indicating whether pedestrian only ways are included - default to True',
|
370
|
+
'include_driving': 'bool indicating whether driving only ways are included - default to True',
|
371
|
+
'import_bike_share_stations': 'bool indicating whether importing bike share stations(BSS). Set to True when using multimodal - default to False',
|
372
|
+
'global_synchronized_cache': 'bool indicating whether global_synchronized_cache is used - default to False',
|
373
|
+
'max_concurrent_reader_users': 'number of threads in the threadpool which can be used to fetch tiles over the network via curl',
|
374
|
+
'reclassify_links': 'bool indicating whether or not to reclassify links - reclassifies ramps based on the lowest class connecting road',
|
375
|
+
'default_speeds_config': 'a path indicating the json config file which graph enhancer will use to set the speeds of edges in the graph based on their geographic location (state/country), density (urban/rural), road class, road use (form of way)',
|
376
|
+
'data_processing': {
|
377
|
+
'infer_internal_intersections': 'bool indicating whether or not to infer internal intersections during the graph enhancer phase or use the internal_intersection key from the pbf',
|
378
|
+
'infer_turn_channels': 'bool indicating whether or not to infer turn channels during the graph enhancer phase or use the turn_channel key from the pbf',
|
379
|
+
'apply_country_overrides': 'bool indicating whether or not to apply country overrides during the graph enhancer phase',
|
380
|
+
'grid_divisions_within_tile': 'number of grid subdivisions within a tile. Used for spatial sorting of nodes within a tile. Set to 0 to disable spatial sorting of nodes',
|
381
|
+
'use_admin_db': 'bool indicating whether or not to use the administrative database during the graph enhancer phase or use the admin keys from the pbf that are set on the node',
|
382
|
+
'use_direction_on_ways': 'bool indicating whether or not to process the direction key on the ways or utilize the guidance relation tags during the parsing phase',
|
383
|
+
'allow_alt_name': 'bool indicating whether or not to process the alt_name key on the ways during the parsing phase',
|
384
|
+
'use_urban_tag': 'bool indicating whether or not to use the urban area tag on the ways or to utilize the getDensity function within the graph enhancer phase',
|
385
|
+
'use_rest_area': 'bool indicating whether or not to use the rest/service area tag on the ways',
|
386
|
+
'scan_tar': 'bool indicating whether or not to pre-scan the tar ball(s) when loading an extract with an index file, to warm up the OS page cache.',
|
387
|
+
},
|
388
|
+
'logging': {
|
389
|
+
'type': 'Type of logger either std_out or file',
|
390
|
+
'color': 'User colored log level in std_out logger',
|
391
|
+
'file_name': 'Output log file for the file logger',
|
392
|
+
},
|
393
|
+
},
|
394
|
+
'additional_data': {
|
395
|
+
'elevation': 'Location of elevation tiles',
|
396
|
+
'elevation_url': 'Http location to read elevations from. this address is used if elevation tiles were not found in the elevation directory. Ex.: http://<your_valhalla_tile_server_host>:<your_valhalla_tile_server_port>/some/Optional/path/{tilePath}?some=Optional&query=params. Valhalla will look for the {tilePath} portion of the url and fill this out with an elevation path when it makes a request for that particular elevation',
|
397
|
+
},
|
398
|
+
'loki': {
|
399
|
+
'actions': 'Comma separated list of allowable actions for the service, one or more of: locate, route, height, optimized_route, isochrone, trace_route, trace_attributes, transit_available, expansion, centroid, status',
|
400
|
+
'use_connectivity': 'a boolean value to know whether or not to construct the connectivity maps',
|
401
|
+
'service_defaults': {
|
402
|
+
'radius': 'Default radius to apply to incoming locations should one not be supplied',
|
403
|
+
'minimum_reachability': 'Default minimum reachability to apply to incoming locations should one not be supplied',
|
404
|
+
'search_cutoff': 'The cutoff at which we will assume the input is too far away from civilisation to be worth correlating to the nearest graph elements',
|
405
|
+
'node_snap_tolerance': 'During edge correlation this is the tolerance used to determine whether or not to snap to the intersection rather than along the street, if the snap location is within this distance from the intersection the intersection is used instead',
|
406
|
+
'street_side_tolerance': 'If your input coordinate is less than this tolerance away from the edge centerline then we set your side of street to none otherwise your side of street will be left or right depending on direction of travel',
|
407
|
+
'street_side_max_distance': 'The max distance in meters that the input coordinates or display ll can be from the edge centerline for them to be used for determining the side of street. Beyond this distance the side of street is set to none',
|
408
|
+
'heading_tolerance': 'When a heading is supplied, this is the tolerance around that heading with which we determine whether an edges heading is similar enough to match the supplied heading',
|
409
|
+
},
|
410
|
+
'logging': {
|
411
|
+
'type': 'Type of logger either std_out or file',
|
412
|
+
'color': 'User colored log level in std_out logger',
|
413
|
+
'file_name': 'Output log file for the file logger',
|
414
|
+
'long_request': 'Value used in processing to determine whether it took too long',
|
415
|
+
},
|
416
|
+
'service': {'proxy': 'IPC linux domain socket file location'},
|
417
|
+
},
|
418
|
+
'thor': {
|
419
|
+
'logging': {
|
420
|
+
'type': 'Type of logger either std_out or file',
|
421
|
+
'color': 'User colored log level in std_out logger',
|
422
|
+
'file_name': 'Output log file for the file logger',
|
423
|
+
'long_request': 'Value used in processing to determine whether it took too long',
|
424
|
+
},
|
425
|
+
'source_to_target_algorithm': 'Which matrix algorithm should be used, one of "timedistancematrix" or "costmatrix". If blank, the optimal will be selected.',
|
426
|
+
'service': {'proxy': 'IPC linux domain socket file location'},
|
427
|
+
'max_reserved_labels_count_astar': 'Maximum capacity allowed to keep reserved for unidirectional A*.',
|
428
|
+
'max_reserved_labels_count_bidir_astar': 'Maximum capacity allowed to keep reserved for bidirectional A*.',
|
429
|
+
'max_reserved_labels_count_dijkstras': 'Maximum capacity allowed to keep reserved for unidirectional Dijkstras.',
|
430
|
+
'max_reserved_labels_count_bidir_dijkstras': 'Maximum capacity allowed to keep reserved for bidirectional Dijkstras.',
|
431
|
+
'max_reserved_locations_costmatrix': 'Maximum amount of locations allowed to to keep reserved between requests for CostMatrix',
|
432
|
+
'clear_reserved_memory': 'If True clean reserved memory in path algorithms',
|
433
|
+
'extended_search': 'If True and 1 side of the bidirectional search is exhausted, causes the other side to continue if the starting location of that side began on a not_thru or closed edge',
|
434
|
+
'costmatrix': {
|
435
|
+
'check_reverse_connection': 'Whether to check for expansion connections on the reverse tree, which has an adverse effect on performance',
|
436
|
+
'allow_second_pass': 'Whether to allow a second pass for unfound CostMatrix connections, where we turn off destination-only, relax hierarchies and expand into "semi-islands"',
|
437
|
+
'max_reserved_locations': 'Maximum amount of locations allowed to to keep reserved between requests for CostMatrix',
|
438
|
+
'max_iterations': 'Upper bound on the number of iterations per expansion once a path has been found. Must be a positive integer',
|
439
|
+
'hierarchy_limits': {
|
440
|
+
'max_up_transitions': {
|
441
|
+
'1': 'The default maximum up transitions for level 1 in CostMatrix',
|
442
|
+
'2': 'The default maximum up transitions for level 2 in CostMatrix',
|
443
|
+
}
|
444
|
+
},
|
445
|
+
},
|
446
|
+
'bidirectional_astar': {
|
447
|
+
'hierarchy_limits': {
|
448
|
+
'max_up_transitions': {
|
449
|
+
'1': 'The default maximum up transitions for level 1 in CostMatrix',
|
450
|
+
'2': 'The default maximum up transitions for level 2 in CostMatrix',
|
451
|
+
},
|
452
|
+
'expand_within_distance': {
|
453
|
+
'0': 'The default distance within which expansion is allowed from the origin/destination on level 0 in bidirectional astar',
|
454
|
+
'1': 'The default distance within which expansion is allowed from the origin/destination on level 1 in bidirectional astar',
|
455
|
+
'2': 'The default distance within which expansion is allowed from the origin/destination on level 2 in bidirectional astar',
|
456
|
+
},
|
457
|
+
}
|
458
|
+
},
|
459
|
+
'unidirectional_astar': {
|
460
|
+
'hierarchy_limits': {
|
461
|
+
'max_up_transitions': {
|
462
|
+
'1': 'The default maximum up transitions for level 1 in CostMatrix',
|
463
|
+
'2': 'The default maximum up transitions for level 2 in CostMatrix',
|
464
|
+
},
|
465
|
+
'expand_within_distance': {
|
466
|
+
'0': 'The default distance within which expansion is allowed from the origin/destination on level 0 in bidirectional astar',
|
467
|
+
'1': 'The default distance within which expansion is allowed from the origin/destination on level 1 in bidirectional astar',
|
468
|
+
'2': 'The default distance within which expansion is allowed from the origin/destination on level 2 in bidirectional astar',
|
469
|
+
},
|
470
|
+
}
|
471
|
+
},
|
472
|
+
},
|
473
|
+
'odin': {
|
474
|
+
'logging': {
|
475
|
+
'type': 'Type of logger either std_out or file',
|
476
|
+
'color': 'User colored log level in std_out logger',
|
477
|
+
'file_name': 'Output log file for the file logger',
|
478
|
+
},
|
479
|
+
'service': {'proxy': 'IPC linux domain socket file location'},
|
480
|
+
'markup_formatter': {
|
481
|
+
'markup_enabled': 'Boolean flag to use markup formatting',
|
482
|
+
'phoneme_format': 'The phoneme format string that will be used by street names and signs',
|
483
|
+
},
|
484
|
+
},
|
485
|
+
'meili': {
|
486
|
+
'mode': 'Specify the default transport mode',
|
487
|
+
'customizable': 'Specify which parameters are allowed to be customized by URL query parameters',
|
488
|
+
'verbose': 'Control verbose output for debugging',
|
489
|
+
'default': {
|
490
|
+
'sigma_z': 'A non-negative value to specify the GPS accuracy (the variance of the normal distribution) of an incoming GPS sequence. It is also used to weight emission costs of measurements',
|
491
|
+
'gps_accuracy': 'TODO: ',
|
492
|
+
'beta': 'A non-negative emprical value to weight the transition cost of two successive candidates',
|
493
|
+
'max_route_distance_factor': 'A non-negative value used to limit the routing search range which is the distance to next measurement multiplied by this factor',
|
494
|
+
'max_route_time_factor': 'A non-negative value used to limit the routing search range which is the time to the next measurement multiplied by this factor',
|
495
|
+
'breakage_distance': 'A non-negative value. If two successive measurements are far than this distance, then connectivity in between will not be considered',
|
496
|
+
'max_search_radius': 'A non-negative value specifying the maximum radius in meters about a given point to search for candidate edges for routing',
|
497
|
+
'interpolation_distance': 'If two successive measurements are closer than this distance, then the later one will be interpolated into the matched route',
|
498
|
+
'search_radius': 'A non-negative value to specify the search radius (in meters) within which to search road candidates for each measurement',
|
499
|
+
'geometry': 'TODO: ',
|
500
|
+
'route': 'TODO: ',
|
501
|
+
'turn_penalty_factor': 'A non-negative value to penalize turns from one road segment to next',
|
502
|
+
},
|
503
|
+
'auto': {
|
504
|
+
'turn_penalty_factor': 'A non-negative value to penalize turns from one road segment to next',
|
505
|
+
'search_radius': 'A non-negative value to specify the search radius (in meters) within which to search road candidates for each measurement',
|
506
|
+
},
|
507
|
+
'pedestrian': {
|
508
|
+
'turn_penalty_factor': 'A non-negative value to penalize turns from one road segment to next',
|
509
|
+
'search_radius': 'A non-negative value to specify the search radius (in meters) within which to search road candidates for each measurement',
|
510
|
+
},
|
511
|
+
'bicycle': {
|
512
|
+
'turn_penalty_factor': 'A non-negative value to penalize turns from one road segment to next'
|
513
|
+
},
|
514
|
+
'multimodal': {
|
515
|
+
'turn_penalty_factor': 'A non-negative value to penalize turns from one road segment to next'
|
516
|
+
},
|
517
|
+
'logging': {
|
518
|
+
'type': 'Type of logger either std_out or file',
|
519
|
+
'color': 'User colored log level in std_out logger',
|
520
|
+
'file_name': 'Output log file for the file logger',
|
521
|
+
},
|
522
|
+
'service': {'proxy': 'IPC linux domain socket file location'},
|
523
|
+
'grid': {
|
524
|
+
'size': 'TODO: Resolution of the grid used in finding match candidates',
|
525
|
+
'cache_size': 'TODO: number of grids to keep in cache',
|
526
|
+
},
|
527
|
+
},
|
528
|
+
'httpd': {
|
529
|
+
'service': {
|
530
|
+
'listen': 'The protocol, host location and port your service will bind to',
|
531
|
+
'loopback': 'IPC linux domain socket file location used to communicate results back to the client',
|
532
|
+
'interrupt': 'IPC linux domain socket file location used to cancel work in progress',
|
533
|
+
'drain_seconds': 'How long to wait for currently running threads to finish before signaling them to shutdown',
|
534
|
+
'shutdown_seconds': 'How long to wait for currently running threads to quit before exiting the process',
|
535
|
+
'timeout_seconds': 'How long to wait for a single request to finish before timing it out (defaults to infinite)',
|
536
|
+
}
|
537
|
+
},
|
538
|
+
'service_limits': {
|
539
|
+
'auto': {
|
540
|
+
'max_distance': 'Maximum b-line distance between all locations in meters',
|
541
|
+
'max_locations': 'Maximum number of input locations',
|
542
|
+
'max_matrix_distance': 'Maximum b-line distance between 2 most distant locations in meters for a matrix',
|
543
|
+
'max_matrix_location_pairs': 'Maximum number of routes computed with the matrix, e.g. 2500 = 50:50 or 1:2500',
|
544
|
+
},
|
545
|
+
'bus': {
|
546
|
+
'max_distance': 'Maximum b-line distance between all locations in meters',
|
547
|
+
'max_locations': 'Maximum number of input locations',
|
548
|
+
'max_matrix_distance': 'Maximum b-line distance between 2 most distant locations in meters for a matrix',
|
549
|
+
'max_matrix_location_pairs': 'Maximum number of routes computed with the matrix, e.g. 2500 = 50:50 or 1:2500',
|
550
|
+
},
|
551
|
+
'taxi': {
|
552
|
+
'max_distance': 'Maximum b-line distance between all locations in meters',
|
553
|
+
'max_locations': 'Maximum number of input locations',
|
554
|
+
'max_matrix_distance': 'Maximum b-line distance between 2 most distant locations in meters for a matrix',
|
555
|
+
'max_matrix_location_pairs': 'Maximum number of routes computed with the matrix, e.g. 2500 = 50:50 or 1:2500',
|
556
|
+
},
|
557
|
+
'pedestrian': {
|
558
|
+
'max_distance': 'Maximum b-line distance between all locations in meters',
|
559
|
+
'max_locations': 'Maximum number of input locations',
|
560
|
+
'max_matrix_distance': 'Maximum b-line distance between 2 most distant locations in meters for a matrix',
|
561
|
+
'max_matrix_location_pairs': 'Maximum number of routes computed with the matrix, e.g. 2500 = 50:50 or 1:2500',
|
562
|
+
'min_transit_walking_distance': 'Minimum distance you must walk to the egress of to a station',
|
563
|
+
'max_transit_walking_distance': 'Maximum distance allowed for walking when using transit',
|
564
|
+
},
|
565
|
+
'motor_scooter': {
|
566
|
+
'max_distance': 'Maximum b-line distance between all locations in meters',
|
567
|
+
'max_locations': 'Maximum number of input locations',
|
568
|
+
'max_matrix_distance': 'Maximum b-line distance between 2 most distant locations in meters for a matrix',
|
569
|
+
'max_matrix_location_pairs': 'Maximum number of routes computed with the matrix, e.g. 2500 = 50:50 or 1:2500',
|
570
|
+
},
|
571
|
+
'motorcycle': {
|
572
|
+
'max_distance': 'Maximum b-line distance between all locations in meters',
|
573
|
+
'max_locations': 'Maximum number of input locations',
|
574
|
+
'max_matrix_distance': 'Maximum b-line distance between 2 most distant locations in meters for a matrix',
|
575
|
+
'max_matrix_location_pairs': 'Maximum number of routes computed with the matrix, e.g. 2500 = 50:50 or 1:2500',
|
576
|
+
},
|
577
|
+
'bicycle': {
|
578
|
+
'max_distance': 'Maximum b-line distance between all locations in meters',
|
579
|
+
'max_locations': 'Maximum number of input locations',
|
580
|
+
'max_matrix_distance': 'Maximum b-line distance between 2 most distant locations in meters for a matrix',
|
581
|
+
'max_matrix_location_pairs': 'Maximum number of routes computed with the matrix, e.g. 2500 = 50:50 or 1:2500',
|
582
|
+
},
|
583
|
+
'multimodal': {
|
584
|
+
'max_distance': 'Maximum b-line distance between all locations in meters',
|
585
|
+
'max_locations': 'Maximum number of input locations',
|
586
|
+
'max_matrix_distance': 'Maximum b-line distance between 2 most distant locations in meters for a matrix',
|
587
|
+
'max_matrix_location_pairs': 'Maximum number of routes computed with the matrix, e.g. 2500 = 50:50 or 1:2500',
|
588
|
+
},
|
589
|
+
'status': {
|
590
|
+
'allow_verbose': 'Allow verbose output for the /status endpoint, which can be computationally expensive'
|
591
|
+
},
|
592
|
+
'transit': {
|
593
|
+
'max_distance': 'Maximum b-line distance between all locations in meters',
|
594
|
+
'max_locations': 'Maximum number of input locations',
|
595
|
+
'max_matrix_distance': 'Maximum b-line distance between 2 most distant locations in meters for a matrix',
|
596
|
+
'max_matrix_location_pairs': 'Maximum number of routes computed with the matrix, e.g. 2500 = 50:50 or 1:2500',
|
597
|
+
},
|
598
|
+
'truck': {
|
599
|
+
'max_distance': 'Maximum b-line distance between all locations in meters',
|
600
|
+
'max_locations': 'Maximum number of input locations',
|
601
|
+
'max_matrix_distance': 'Maximum b-line distance between 2 most distant locations in meters for a matrix',
|
602
|
+
'max_matrix_location_pairs': 'Maximum number of routes computed with the matrix, e.g. 2500 = 50:50 or 1:2500',
|
603
|
+
},
|
604
|
+
'skadi': {
|
605
|
+
'max_shape': 'Maximum number of input shapes',
|
606
|
+
'min_resample': 'Smalled resampling distance to allow in meters',
|
607
|
+
},
|
608
|
+
'isochrone': {
|
609
|
+
'max_contours': 'Maximum number of input contours to allow',
|
610
|
+
'max_time_contour': 'Maximum time value for any one contour in minutes',
|
611
|
+
'max_distance': 'Maximum b-line distance between all locations in meters',
|
612
|
+
'max_locations': 'Maximum number of input locations',
|
613
|
+
'max_distance_contour': 'Maximum distance value for any one contour in kilometers',
|
614
|
+
},
|
615
|
+
'trace': {
|
616
|
+
'max_distance': 'Maximum input shape distance in meters',
|
617
|
+
'max_gps_accuracy': 'Maximum input gps accuracy in meters',
|
618
|
+
'max_search_radius': 'Maximum upper bounds of the search radius in meters',
|
619
|
+
'max_shape': 'Maximum number of input shape points',
|
620
|
+
'max_alternates': 'Maximum number of alternate map matching',
|
621
|
+
'max_alternates_shape': 'Maximum number of input shape points when requesting multiple paths',
|
622
|
+
},
|
623
|
+
'bikeshare': {
|
624
|
+
'max_distance': 'Maximum b-line distance between all locations in meters',
|
625
|
+
'max_locations': 'Maximum number of input locations',
|
626
|
+
'max_matrix_distance': 'Maximum b-line distance between 2 most distant locations in meters for a matrix',
|
627
|
+
'max_matrix_location_pairs': 'Maximum number of routes computed with the matrix, e.g. 2500 = 50:50 or 1:2500',
|
628
|
+
},
|
629
|
+
'centroid': {
|
630
|
+
'max_distance': 'Maximum b-line distance between any pair of locations in meters',
|
631
|
+
'max_locations': 'Maximum number of input locations, 127 is a hard limit and cannot be increased in config',
|
632
|
+
},
|
633
|
+
'max_exclude_locations': 'Maximum number of avoid locations to allow in a request',
|
634
|
+
'max_reachability': 'Maximum reachability (number of nodes reachable) allowed on any one location',
|
635
|
+
'max_radius': 'Maximum radius in meters allowed on any one location',
|
636
|
+
'max_timedep_distance': 'Maximum b-line distance between locations to allow a time-dependent route',
|
637
|
+
'max_timedep_distance_matrix': 'Maximum b-line distance between 2 most distant locations in meters to allow a time-dependent matrix',
|
638
|
+
'max_alternates': 'Maximum number of alternate routes to allow in a request',
|
639
|
+
'max_exclude_polygons_length': 'Maximum total perimeter of all exclude_polygons in meters',
|
640
|
+
'max_distance_disable_hierarchy_culling': 'Maximum search distance allowed with hierarchy culling disabled',
|
641
|
+
'hierarchy_limits': {
|
642
|
+
'allow_modification': 'Whether hierarchy limits can be modified via the request',
|
643
|
+
'costmatrix': {
|
644
|
+
'max_allowed_up_transitions': {
|
645
|
+
'1': 'The maximum up transitions for level 1. Values set via request parameters that exceed this value are clamped. Ignored if "allow_modifications" is set to false.',
|
646
|
+
'2': 'The maximum up transitions for level 2. Values set via request parameters that exceed this value are clamped. Ignored if "allow_modifications" is set to false.',
|
647
|
+
},
|
648
|
+
'max_expand_within_distance': {
|
649
|
+
'0': 'The maximum distance in meters from which the origin/destination will be expanded on level 0. Values set via request parameters that exceed this value are clamped. Ignored if "allow_modifications" is set to false.',
|
650
|
+
'1': 'The maximum distance in meters from which the origin/destination will be expanded on level 1. Values set via request parameters that exceed this value are clamped. Ignored if "allow_modifications" is set to false.',
|
651
|
+
'2': 'The maximum distance in meters from which the origin/destination will be expanded on level 2. Values set via request parameters that exceed this value are clamped. Ignored if "allow_modifications" is set to false.',
|
652
|
+
},
|
653
|
+
},
|
654
|
+
'bidirectional_astar': {
|
655
|
+
'max_allowed_up_transitions': {
|
656
|
+
'1': 'The maximum up transitions for level 1. Values set via request parameters that exceed this value are clamped. Ignored if "allow_modifications" is set to false.',
|
657
|
+
'2': 'The maximum up transitions for level 2. Values set via request parameters that exceed this value are clamped. Ignored if "allow_modifications" is set to false.',
|
658
|
+
},
|
659
|
+
'max_expand_within_distance': {
|
660
|
+
'0': 'The maximum distance in meters from which the origin/destination will be expanded on level 0. Values set via request parameters that exceed this value are clamped. Ignored if "allow_modifications" is set to false.',
|
661
|
+
'1': 'The maximum distance in meters from which the origin/destination will be expanded on level 1. Values set via request parameters that exceed this value are clamped. Ignored if "allow_modifications" is set to false.',
|
662
|
+
'2': 'The maximum distance in meters from which the origin/destination will be expanded on level 2. Values set via request parameters that exceed this value are clamped. Ignored if "allow_modifications" is set to false.',
|
663
|
+
},
|
664
|
+
},
|
665
|
+
'unidirectional_astar': {
|
666
|
+
'max_allowed_up_transitions': {
|
667
|
+
'1': 'The maximum up transitions for level 1. Values set via request parameters that exceed this value are clamped. Ignored if "allow_modifications" is set to false.',
|
668
|
+
'2': 'The maximum up transitions for level 2. Values set via request parameters that exceed this value are clamped. Ignored if "allow_modifications" is set to false.',
|
669
|
+
},
|
670
|
+
'max_expand_within_distance': {
|
671
|
+
'0': 'The maximum distance in meters from which the origin/destination will be expanded on level 0. Values set via request parameters that exceed this value are clamped. Ignored if "allow_modifications" is set to false.',
|
672
|
+
'1': 'The maximum distance in meters from which the origin/destination will be expanded on level 1. Values set via request parameters that exceed this value are clamped. Ignored if "allow_modifications" is set to false.',
|
673
|
+
'2': 'The maximum distance in meters from which the origin/destination will be expanded on level 2. Values set via request parameters that exceed this value are clamped. Ignored if "allow_modifications" is set to false.',
|
674
|
+
},
|
675
|
+
},
|
676
|
+
},
|
677
|
+
'allow_hard_exclusions': 'Whether hard exclusions, such as exclude_bridges, exclude_tunnels, exclude_tolls, exclude_highways or exclude_ferries are allowed on this server',
|
678
|
+
},
|
679
|
+
'statsd': {
|
680
|
+
'host': 'The statsd host address',
|
681
|
+
'port': 'The statsd port',
|
682
|
+
'prefix': 'The statsd prefix to use for each metric',
|
683
|
+
'batch_size': 'Approximate maximum size in bytes of each batch of stats to send to statsd',
|
684
|
+
'tags': 'List of tags to include with each metric',
|
685
|
+
},
|
686
|
+
}
|
687
|
+
|
688
|
+
|
689
|
+
def add_leaf_args(
|
690
|
+
path: str,
|
691
|
+
tree: Union[dict, bool, str, list, Optional],
|
692
|
+
leaves_: List[str],
|
693
|
+
parser_: ArgumentParser,
|
694
|
+
help: dict,
|
695
|
+
):
|
696
|
+
"""
|
697
|
+
returns a list of leaves of the tree, `\0` separated, stops at non dicts
|
698
|
+
while doing so it also adds arguments to the parser
|
699
|
+
"""
|
700
|
+
# if we are at a dict go deeper
|
701
|
+
if isinstance(tree, dict):
|
702
|
+
for k in tree:
|
703
|
+
v = tree[k]
|
704
|
+
add_leaf_args('\0'.join([path, k]) if len(path) else k, v, leaves_, parser_, help)
|
705
|
+
# we've reached a leaf
|
706
|
+
else:
|
707
|
+
keys = path.split('\0')
|
708
|
+
h = help
|
709
|
+
for k in keys:
|
710
|
+
h = h[k]
|
711
|
+
|
712
|
+
# its either required and is the right type or optional and has a type to use
|
713
|
+
# lists are supported as comma separated and bools support a bunch of conventions
|
714
|
+
# the rest of the primitives (strings and numbers) parse automatically
|
715
|
+
if isinstance(tree, Optional):
|
716
|
+
t = tree.type
|
717
|
+
elif isinstance(tree, list):
|
718
|
+
t = lambda arg: arg.split(',')
|
719
|
+
elif isinstance(tree, bool):
|
720
|
+
t = lambda arg: bool(strtobool(arg))
|
721
|
+
else:
|
722
|
+
t = type(tree)
|
723
|
+
|
724
|
+
arg = '--' + path.replace('_', '-').replace('\0', '-')
|
725
|
+
if t == list:
|
726
|
+
parser_.add_argument(arg, nargs="+", help=h, default=tree)
|
727
|
+
else:
|
728
|
+
parser_.add_argument(arg, type=t, help=h, default=tree)
|
729
|
+
leaves_.append(path)
|
730
|
+
|
731
|
+
|
732
|
+
def override_config(args_: dict, leaves_: list, config_: dict):
|
733
|
+
"""override the defaults given what was passed"""
|
734
|
+
for leaf in leaves_:
|
735
|
+
keys = leaf.split('\0')
|
736
|
+
v = config_
|
737
|
+
for k in keys[:-1]:
|
738
|
+
v = v[k]
|
739
|
+
v[keys[-1]] = args_.get(leaf.replace('\0', '_'))
|
740
|
+
if isinstance(v[keys[-1]], type(Optional())):
|
741
|
+
del v[keys[-1]]
|
742
|
+
|
743
|
+
|
744
|
+
# set up available program options
|
745
|
+
leaves = []
|
746
|
+
parser = ArgumentParser(
|
747
|
+
description='Generate valhalla configuration', formatter_class=ArgumentDefaultsHelpFormatter
|
748
|
+
)
|
749
|
+
add_leaf_args('', config, leaves, parser, help_text)
|
750
|
+
|
751
|
+
# entry point to program
|
752
|
+
if __name__ == '__main__':
|
753
|
+
# TODO: add argument to set base path and use in all other path based values
|
754
|
+
args = parser.parse_args()
|
755
|
+
|
756
|
+
# encapsulate to test easier
|
757
|
+
override_config(args.__dict__, leaves, config)
|
758
|
+
|
759
|
+
# show the config
|
760
|
+
print(json.dumps(config, sort_keys=True, indent=2, separators=(',', ': ')))
|