[fix] handle mapping source_type to url_tile on executing samexporter_predict()
Browse files- .gitignore +3 -0
- src/app.py +1 -1
- src/io/lambda_helpers.py +11 -1
- src/utilities/constants.py +1 -0
.gitignore
CHANGED
@@ -273,3 +273,6 @@ fabric.properties
|
|
273 |
# Sonarlint plugin
|
274 |
.idea/sonarlint
|
275 |
/.idea/modules.xml
|
|
|
|
|
|
|
|
273 |
# Sonarlint plugin
|
274 |
.idea/sonarlint
|
275 |
/.idea/modules.xml
|
276 |
+
|
277 |
+
# node_modules
|
278 |
+
node_modules
|
src/app.py
CHANGED
@@ -39,7 +39,7 @@ def lambda_handler(event: Dict, context: LambdaContext) -> str:
|
|
39 |
|
40 |
try:
|
41 |
body_response = samexporter_predict(
|
42 |
-
body_request["bbox"], body_request["prompt"], body_request["zoom"], url_tile=body_request["
|
43 |
)
|
44 |
app_logger.info(f"output body_response length:{len(body_response)}.")
|
45 |
app_logger.debug(f"output body_response:{body_response}.")
|
|
|
39 |
|
40 |
try:
|
41 |
body_response = samexporter_predict(
|
42 |
+
body_request["bbox"], body_request["prompt"], body_request["zoom"], url_tile=body_request["url_tile"]
|
43 |
)
|
44 |
app_logger.info(f"output body_response length:{len(body_response)}.")
|
45 |
app_logger.debug(f"output body_response:{body_response}.")
|
src/io/lambda_helpers.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
"""lambda helper functions"""
|
2 |
from typing import Dict
|
3 |
from aws_lambda_powertools.event_handler import content_types
|
|
|
4 |
|
5 |
from src import app_logger
|
6 |
from src.io.coordinates_pixel_conversion import get_latlng_to_pixel_coordinates
|
@@ -72,7 +73,7 @@ def get_parsed_bbox_points(request_input: RawRequestInput) -> Dict:
|
|
72 |
"bbox": [ne_latlng, sw_latlng],
|
73 |
"prompt": new_prompt_list,
|
74 |
"zoom": new_zoom,
|
75 |
-
"
|
76 |
}
|
77 |
|
78 |
|
@@ -149,3 +150,12 @@ def get_parsed_request_body(event: Dict or str) -> RawRequestInput:
|
|
149 |
app_logger.warning(f"set log level to {getLevelName(app_logger.log_level)}.")
|
150 |
|
151 |
return parsed_body
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
"""lambda helper functions"""
|
2 |
from typing import Dict
|
3 |
from aws_lambda_powertools.event_handler import content_types
|
4 |
+
from xyzservices import providers
|
5 |
|
6 |
from src import app_logger
|
7 |
from src.io.coordinates_pixel_conversion import get_latlng_to_pixel_coordinates
|
|
|
73 |
"bbox": [ne_latlng, sw_latlng],
|
74 |
"prompt": new_prompt_list,
|
75 |
"zoom": new_zoom,
|
76 |
+
"url_tile": get_url_tile(request_input.source_type)
|
77 |
}
|
78 |
|
79 |
|
|
|
150 |
app_logger.warning(f"set log level to {getLevelName(app_logger.log_level)}.")
|
151 |
|
152 |
return parsed_body
|
153 |
+
|
154 |
+
|
155 |
+
def get_url_tile(source_type: str):
|
156 |
+
from src.utilities.constants import DEFAULT_TMS_NAME, DEFAULT_TMS
|
157 |
+
|
158 |
+
if source_type.lower() == DEFAULT_TMS_NAME:
|
159 |
+
return DEFAULT_TMS
|
160 |
+
providers_type = providers.query_name(source_type)
|
161 |
+
return providers_type.url
|
src/utilities/constants.py
CHANGED
@@ -13,6 +13,7 @@ MODEL_ENCODER_NAME = "mobile_sam.encoder.onnx"
|
|
13 |
MODEL_DECODER_NAME = "sam_vit_h_4b8939.decoder.onnx"
|
14 |
TILE_SIZE = 256
|
15 |
EARTH_EQUATORIAL_RADIUS = 6378137.0
|
|
|
16 |
DEFAULT_TMS = 'https://tile.openstreetmap.org/{z}/{x}/{y}.png'
|
17 |
WKT_3857 = 'PROJCS["WGS 84 / Pseudo-Mercator",GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,'
|
18 |
WKT_3857 += 'AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],'
|
|
|
13 |
MODEL_DECODER_NAME = "sam_vit_h_4b8939.decoder.onnx"
|
14 |
TILE_SIZE = 256
|
15 |
EARTH_EQUATORIAL_RADIUS = 6378137.0
|
16 |
+
DEFAULT_TMS_NAME = "openstreetmap"
|
17 |
DEFAULT_TMS = 'https://tile.openstreetmap.org/{z}/{x}/{y}.png'
|
18 |
WKT_3857 = 'PROJCS["WGS 84 / Pseudo-Mercator",GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,'
|
19 |
WKT_3857 += 'AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],'
|