ensure speckleURL argument

This commit is contained in:
KatKatKateryna
2024-09-04 16:04:45 +01:00
parent 6d425d4212
commit 4e867c86d8
+44 -37
View File
@@ -581,43 +581,50 @@ def get_collection_items(
crsauthid = False
for item in url_props:
# if CRS authid is found, rest will be ignored
if "speckleurl=" in item:
content['speckle_url'] = item.split("speckleurl=")[1]
if content['speckle_url'][-1] == "/":
content['speckle_url'] = content['speckle_url'][:-1]
content['speckle_project_url'] = content['speckle_url'].split("/models")[0]
elif "datatype=" in item:
content['requested_data_type'] = item.split("datatype=")[1]
if content['requested_data_type'] not in ["points", "lines", "polygons", "projectcomments"]:
content['requested_data_type'] = "polygons (default)"
elif "preserveattributes=" in item:
content['preserve_attributes'] = item.split("preserveattributes=")[1]
if content['preserve_attributes'] not in ["true", "false"]:
content['preserve_attributes'] = "true (default)"
elif "crsauthid=" in item:
content['crs_authid'] = item.split("crsauthid=")[1]
crsauthid = True
elif "lat=" in item:
try:
content['lat'] = float(item.split("lat=")[1])
except:
content['lat'] = f"Invalid input, must be numeric: {item.split('lat=')[1]}"
elif "lon=" in item:
try:
content['lon'] = float(item.split("lon=")[1])
except:
content['lon'] = f"Invalid input, must be numeric: {item.split('lon=')[1]}"
elif "northdegrees=" in item:
try:
content['north_degrees'] = float(item.split("northdegrees=")[1])
except:
content['north_degrees'] = f"Invalid input, must be numeric: {item.split('northdegrees=')[1]}"
elif "limit=" in item:
try:
content['limit'] = float(item.split("limit=")[1])
except:
content['limit'] = f"Invalid input, must be integer: {item.split('limit=')[1]}"
try:
if "speckleurl=" in item:
try:
content['speckle_url'] = item.split("speckleurl=")[1]
if content['speckle_url'][-1] == "/":
content['speckle_url'] = content['speckle_url'][:-1]
content['speckle_project_url'] = content['speckle_url'].split("/models")[0]
except IndexError:
raise KeyError("Provide valid Speckle Model URL")
elif "datatype=" in item:
content['requested_data_type'] = item.split("datatype=")[1]
if content['requested_data_type'] not in ["points", "lines", "polygons", "projectcomments"]:
content['requested_data_type'] = "polygons (default)"
elif "preserveattributes=" in item:
content['preserve_attributes'] = item.split("preserveattributes=")[1]
if content['preserve_attributes'] not in ["true", "false"]:
content['preserve_attributes'] = "true (default)"
elif "crsauthid=" in item:
content['crs_authid'] = item.split("crsauthid=")[1]
crsauthid = True
elif "lat=" in item:
try:
content['lat'] = float(item.split("lat=")[1])
except:
content['lat'] = f"Invalid input, must be numeric: {item.split('lat=')[1]}"
elif "lon=" in item:
try:
content['lon'] = float(item.split("lon=")[1])
except:
content['lon'] = f"Invalid input, must be numeric: {item.split('lon=')[1]}"
elif "northdegrees=" in item:
try:
content['north_degrees'] = float(item.split("northdegrees=")[1])
except:
content['north_degrees'] = f"Invalid input, must be numeric: {item.split('northdegrees=')[1]}"
elif "limit=" in item:
try:
content['limit'] = float(item.split("limit=")[1])
except:
content['limit'] = f"Invalid input, must be integer: {item.split('limit=')[1]}"
except IndexError:
pass
if content['speckle_url'] == "-":
content['missing_url'] = "true"