[refactor] set some methods as private
Browse files- src/io/lambda_helpers.py +6 -6
src/io/lambda_helpers.py
CHANGED
@@ -62,7 +62,7 @@ def get_parsed_bbox_points(request_input: RawRequestInput) -> Dict:
|
|
62 |
ne_latlng = [float(ne.lat), float(ne.lng)]
|
63 |
sw_latlng = [float(sw.lat), float(sw.lng)]
|
64 |
new_zoom = int(request_input.zoom)
|
65 |
-
new_prompt_list =
|
66 |
|
67 |
app_logger.debug(f"bbox => {bbox}.")
|
68 |
app_logger.debug(f'request_input-prompt updated => {new_prompt_list}.')
|
@@ -75,16 +75,16 @@ def get_parsed_bbox_points(request_input: RawRequestInput) -> Dict:
|
|
75 |
}
|
76 |
|
77 |
|
78 |
-
def
|
79 |
new_prompt_list = []
|
80 |
for prompt in prompt_list:
|
81 |
app_logger.debug(f"current prompt: {type(prompt)}, value:{prompt}.")
|
82 |
new_prompt = {"type": prompt.type.value}
|
83 |
if prompt.type == "point":
|
84 |
-
new_prompt_data =
|
85 |
new_prompt["label"] = prompt.label.value
|
86 |
elif prompt.type == "rectangle":
|
87 |
-
new_prompt_data =
|
88 |
else:
|
89 |
msg = "Valid prompt type: 'point' or 'rectangle', not '{}'. Check RawRequestInput parsing/validation."
|
90 |
raise TypeError(msg.format(prompt.type))
|
@@ -94,13 +94,13 @@ def get_parsed_prompt_list(bbox_ne, bbox_sw, zoom, prompt_list):
|
|
94 |
return new_prompt_list
|
95 |
|
96 |
|
97 |
-
def
|
98 |
current_point = get_latlng_to_pixel_coordinates(bbox_ne, bbox_sw, prompt.data, zoom, prompt.type)
|
99 |
app_logger.debug(f"current prompt: {type(current_point)}, value:{current_point}, label: {prompt.label}.")
|
100 |
return [current_point['x'], current_point['y']]
|
101 |
|
102 |
|
103 |
-
def
|
104 |
current_point_ne = get_latlng_to_pixel_coordinates(bbox_ne, bbox_sw, prompt.data.ne, zoom, prompt.type)
|
105 |
app_logger.debug(
|
106 |
f"rectangle:: current_point_ne prompt: {type(current_point_ne)}, value:{current_point_ne}.")
|
|
|
62 |
ne_latlng = [float(ne.lat), float(ne.lng)]
|
63 |
sw_latlng = [float(sw.lat), float(sw.lng)]
|
64 |
new_zoom = int(request_input.zoom)
|
65 |
+
new_prompt_list = _get_parsed_prompt_list(ne, sw, new_zoom, request_input.prompt)
|
66 |
|
67 |
app_logger.debug(f"bbox => {bbox}.")
|
68 |
app_logger.debug(f'request_input-prompt updated => {new_prompt_list}.')
|
|
|
75 |
}
|
76 |
|
77 |
|
78 |
+
def _get_parsed_prompt_list(bbox_ne, bbox_sw, zoom, prompt_list):
|
79 |
new_prompt_list = []
|
80 |
for prompt in prompt_list:
|
81 |
app_logger.debug(f"current prompt: {type(prompt)}, value:{prompt}.")
|
82 |
new_prompt = {"type": prompt.type.value}
|
83 |
if prompt.type == "point":
|
84 |
+
new_prompt_data = _get_new_prompt_data_point(bbox_ne, bbox_sw, prompt, zoom)
|
85 |
new_prompt["label"] = prompt.label.value
|
86 |
elif prompt.type == "rectangle":
|
87 |
+
new_prompt_data = _get_new_prompt_data_rectangle(bbox_ne, bbox_sw, prompt, zoom)
|
88 |
else:
|
89 |
msg = "Valid prompt type: 'point' or 'rectangle', not '{}'. Check RawRequestInput parsing/validation."
|
90 |
raise TypeError(msg.format(prompt.type))
|
|
|
94 |
return new_prompt_list
|
95 |
|
96 |
|
97 |
+
def _get_new_prompt_data_point(bbox_ne, bbox_sw, prompt, zoom):
|
98 |
current_point = get_latlng_to_pixel_coordinates(bbox_ne, bbox_sw, prompt.data, zoom, prompt.type)
|
99 |
app_logger.debug(f"current prompt: {type(current_point)}, value:{current_point}, label: {prompt.label}.")
|
100 |
return [current_point['x'], current_point['y']]
|
101 |
|
102 |
|
103 |
+
def _get_new_prompt_data_rectangle(bbox_ne, bbox_sw, prompt, zoom):
|
104 |
current_point_ne = get_latlng_to_pixel_coordinates(bbox_ne, bbox_sw, prompt.data.ne, zoom, prompt.type)
|
105 |
app_logger.debug(
|
106 |
f"rectangle:: current_point_ne prompt: {type(current_point_ne)}, value:{current_point_ne}.")
|