JanuaryDesk commited on
Commit
410319c
1 Parent(s): 9268c51

add sub map support

Browse files
Files changed (2) hide show
  1. app.py +13 -3
  2. lib/JTSParser.dll +0 -0
app.py CHANGED
@@ -71,7 +71,10 @@ road_names_map = {
71
  with gr.Blocks(analytics_enabled=False) as demo:
72
  with gr.Row():
73
  with gr.Column(scale=1):
74
- file_input = gr.File(default_path, label="Map File (NB/CWB/PZC)", file_types=[".map"])
 
 
 
75
  code_dropdown = gr.Dropdown(choices=["NB", "CWB", "PZC"], value="NB", label="Series")
76
  labels_checkbox = gr.Checkbox(True, label="Labels")
77
  labels_size_threshold_number = gr.Number(0, label="Label Size Threshold", info="1 => Tactical, 2 => Normal, 3 => Important")
@@ -85,7 +88,6 @@ with gr.Blocks(analytics_enabled=False) as demo:
85
  with gr.Row():
86
  road_offset_number = gr.Number(0.3, label="Road Offset")
87
  elevation_scale_number = gr.Number(0.1, label="Elevation Scale")
88
- plot_button = gr.Button("Plot")
89
  with gr.Column(scale=2):
90
  output_plot = gr.Plot()
91
 
@@ -95,6 +97,14 @@ with gr.Blocks(analytics_enabled=False) as demo:
95
 
96
  code = data[code_dropdown]
97
  map_file = JTS.JTSParser.FromCode(code).ParseMap(map_str, False)
 
 
 
 
 
 
 
 
98
  network = JTS.HexNetwork.FromMapFile(map_file)
99
 
100
  height_mat = np.empty([map_file.Height, map_file.Width])
@@ -191,7 +201,7 @@ with gr.Blocks(analytics_enabled=False) as demo:
191
 
192
  return {output_plot: fig}
193
 
194
- plot_button.click(plot, {file_input, code_dropdown,
195
  labels_checkbox, labels_size_threshold_number,
196
  path_checkbox, road_checkbox, pike_checkbox, railway_checkbox,
197
  elevation_scale_number, road_offset_number}, {output_plot})
 
71
  with gr.Blocks(analytics_enabled=False) as demo:
72
  with gr.Row():
73
  with gr.Column(scale=1):
74
+ plot_button = gr.Button("Plot")
75
+ with gr.Row():
76
+ file_input = gr.File(default_path, label="Map File (NB/CWB/PZC)", file_types=[".map"])
77
+ sub_file_input = gr.File(label="Sub Map File (optional)", file_types=[".map"])
78
  code_dropdown = gr.Dropdown(choices=["NB", "CWB", "PZC"], value="NB", label="Series")
79
  labels_checkbox = gr.Checkbox(True, label="Labels")
80
  labels_size_threshold_number = gr.Number(0, label="Label Size Threshold", info="1 => Tactical, 2 => Normal, 3 => Important")
 
88
  with gr.Row():
89
  road_offset_number = gr.Number(0.3, label="Road Offset")
90
  elevation_scale_number = gr.Number(0.1, label="Elevation Scale")
 
91
  with gr.Column(scale=2):
92
  output_plot = gr.Plot()
93
 
 
97
 
98
  code = data[code_dropdown]
99
  map_file = JTS.JTSParser.FromCode(code).ParseMap(map_str, False)
100
+
101
+ if data[sub_file_input]:
102
+ with open(data[sub_file_input].name) as f:
103
+ sub_map_str = f.read()
104
+ sub_map_file = JTS.SubMapFile()
105
+ sub_map_file.Extract(sub_map_str)
106
+ sub_map_file.ApplyTo(map_file)
107
+
108
  network = JTS.HexNetwork.FromMapFile(map_file)
109
 
110
  height_mat = np.empty([map_file.Height, map_file.Width])
 
201
 
202
  return {output_plot: fig}
203
 
204
+ plot_button.click(plot, {file_input, sub_file_input, code_dropdown,
205
  labels_checkbox, labels_size_threshold_number,
206
  path_checkbox, road_checkbox, pike_checkbox, railway_checkbox,
207
  elevation_scale_number, road_offset_number}, {output_plot})
lib/JTSParser.dll CHANGED
Binary files a/lib/JTSParser.dll and b/lib/JTSParser.dll differ