Compare commits
18 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4097aff759 | |||
| 8f845c95bb | |||
| e2bf4ee3b1 | |||
| 5b37680d73 | |||
| 661d0e9104 | |||
| 434f712cbf | |||
| ebfb49c4a1 | |||
| 8759fc9e09 | |||
| 4e43085ef2 | |||
| 079e8e5dda | |||
| f5e52de572 | |||
| 66d7bd69fb | |||
| 6b7112ccef | |||
| 6bf99294db | |||
| 8bbd50265e | |||
| dd2f3f3bb0 | |||
| a20daffc4b | |||
| 6a8b5df87c |
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
access_log
|
access_log
|
||||||
error_log
|
error_log*
|
||||||
|
|
||||||
# Byte-compiled / optimized / DLL files
|
# Byte-compiled / optimized / DLL files
|
||||||
__pycache__/
|
__pycache__/
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ Then you can add it to the base map (e.g. using Leaflet and OpenStreetMap basema
|
|||||||
loadSpeckleData();
|
loadSpeckleData();
|
||||||
|
|
||||||
async function loadSpeckleData() => {
|
async function loadSpeckleData() => {
|
||||||
var speckle_model_url = 'https://geo.speckle.systems/?speckleUrl=https://app.speckle.systems/projects/344f803f81/models/5582ab673e&datatype=polygons';
|
var speckle_model_url = 'https://geo.speckle.systems/speckle/?speckleUrl=https://app.speckle.systems/projects/344f803f81/models/5582ab673e&datatype=polygons';
|
||||||
const speckle_data = await fetch(speckle_model_url, {
|
const speckle_data = await fetch(speckle_model_url, {
|
||||||
headers: {'Accept': 'application/geo+json'}
|
headers: {'Accept': 'application/geo+json'}
|
||||||
}).then(response => response.json());
|
}).then(response => response.json());
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ LOGGER = logging.getLogger(__name__)
|
|||||||
#: Return headers for requests (e.g:X-Powered-By)
|
#: Return headers for requests (e.g:X-Powered-By)
|
||||||
HEADERS = {
|
HEADERS = {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
'X-Powered-By': f'pygeoapi {__version__}'
|
# 'X-Powered-By': f'pygeoapi {__version__}'
|
||||||
}
|
}
|
||||||
|
|
||||||
CHARSET = ['utf-8']
|
CHARSET = ['utf-8']
|
||||||
|
|||||||
@@ -574,61 +574,6 @@ def get_collection_items(
|
|||||||
if isinstance(url_saved_as_data, str):
|
if isinstance(url_saved_as_data, str):
|
||||||
url_props = url_saved_as_data.lower().split("&")
|
url_props = url_saved_as_data.lower().split("&")
|
||||||
|
|
||||||
content['missing_url'] = content['missing_url_href'] = ""
|
|
||||||
content['requested_data_type'] = "polygons (default)"
|
|
||||||
content['preserve_attributes'] = "false (default)"
|
|
||||||
content['speckle_url'] = content['speckle_project_url'] = content['crs_authid'] = content['lat'] = content['lon'] = content['north_degrees'] = content['limit'] = "-"
|
|
||||||
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'] = "false (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]}"
|
|
||||||
|
|
||||||
if content['speckle_url'] == "-":
|
|
||||||
content['missing_url'] = "true"
|
|
||||||
|
|
||||||
if crsauthid:
|
|
||||||
content['lat'] += " (not applied)"
|
|
||||||
content['lon'] += " (not applied)"
|
|
||||||
content['north_degrees'] += " (not applied)"
|
|
||||||
|
|
||||||
if content['limit'] == "-":
|
|
||||||
content['limit'] = f"{api.config['server']['limit']} (default)"
|
|
||||||
|
|
||||||
# Set response language to requested provider locale
|
# Set response language to requested provider locale
|
||||||
# (if it supports language) and/or otherwise the requested pygeoapi
|
# (if it supports language) and/or otherwise the requested pygeoapi
|
||||||
# locale (or fallback default locale)
|
# locale (or fallback default locale)
|
||||||
|
|||||||
+28
-16
@@ -168,6 +168,21 @@ def execute_from_flask(api_function, request: Request, *args,
|
|||||||
return get_response((headers, status, content))
|
return get_response((headers, status, content))
|
||||||
|
|
||||||
|
|
||||||
|
def generate():
|
||||||
|
collection_id = "speckle"
|
||||||
|
|
||||||
|
yield loading_screen().data
|
||||||
|
|
||||||
|
try:
|
||||||
|
browser_response = execute_from_flask(itemtypes_api.get_collection_items,
|
||||||
|
request, collection_id,
|
||||||
|
skip_valid_check=True)
|
||||||
|
yield browser_response.data
|
||||||
|
|
||||||
|
except Exception as ex:
|
||||||
|
yield error_screen(ex).data
|
||||||
|
|
||||||
|
|
||||||
@BLUEPRINT.route('/')
|
@BLUEPRINT.route('/')
|
||||||
def landing_page():
|
def landing_page():
|
||||||
"""
|
"""
|
||||||
@@ -176,8 +191,6 @@ def landing_page():
|
|||||||
:returns: HTTP response
|
:returns: HTTP response
|
||||||
"""
|
"""
|
||||||
|
|
||||||
collection_id = "speckle"
|
|
||||||
|
|
||||||
agent = request.headers.get('User-Agent')
|
agent = request.headers.get('User-Agent')
|
||||||
# Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36
|
# Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36
|
||||||
# Mozilla/5.0 QGIS/32815/Windows 10 Version 2009
|
# Mozilla/5.0 QGIS/32815/Windows 10 Version 2009
|
||||||
@@ -187,7 +200,11 @@ def landing_page():
|
|||||||
browser_list = ["Chrome", "Safari", "Firefox", "Edg/", "Trident/"]
|
browser_list = ["Chrome", "Safari", "Firefox", "Edg/", "Trident/"]
|
||||||
print(agent)
|
print(agent)
|
||||||
|
|
||||||
if "YaBrowser/" in agent:
|
request.url += f"&userAgent={agent}"
|
||||||
|
CONFIG = get_config(request=request)
|
||||||
|
api_ = API(CONFIG, OPENAPI)
|
||||||
|
|
||||||
|
if agent is not None and ("YaBrowser/" in agent or "yandex" in agent.lower()):
|
||||||
raise ValueError("Your browser is not supported.")
|
raise ValueError("Your browser is not supported.")
|
||||||
for br in browser_list:
|
for br in browser_list:
|
||||||
if br in agent:
|
if br in agent:
|
||||||
@@ -196,18 +213,6 @@ def landing_page():
|
|||||||
|
|
||||||
# if requested from the browser, return this, otherwise ignore IF statement
|
# if requested from the browser, return this, otherwise ignore IF statement
|
||||||
if request.method == 'GET' and browser_agent: # list items
|
if request.method == 'GET' and browser_agent: # list items
|
||||||
|
|
||||||
def generate():
|
|
||||||
yield loading_screen().data
|
|
||||||
try:
|
|
||||||
browser_response = execute_from_flask(itemtypes_api.get_collection_items,
|
|
||||||
request, collection_id,
|
|
||||||
skip_valid_check=True)
|
|
||||||
yield browser_response.data
|
|
||||||
|
|
||||||
except Exception as ex:
|
|
||||||
yield error_screen(ex).data
|
|
||||||
|
|
||||||
return Response(stream_with_context(generate()))
|
return Response(stream_with_context(generate()))
|
||||||
|
|
||||||
return get_response(api_.landing_page(request))
|
return get_response(api_.landing_page(request))
|
||||||
@@ -294,10 +299,17 @@ def collections(collection_id=None):
|
|||||||
:returns: HTTP response
|
:returns: HTTP response
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# raise NotImplementedError()
|
|
||||||
return get_response(api_.describe_collections(request, collection_id))
|
return get_response(api_.describe_collections(request, collection_id))
|
||||||
|
|
||||||
|
|
||||||
|
@BLUEPRINT.route('/speckle')
|
||||||
|
def speckle_collection():
|
||||||
|
|
||||||
|
collection_id="speckle"
|
||||||
|
|
||||||
|
return collection_items(collection_id=collection_id)
|
||||||
|
|
||||||
|
|
||||||
@BLUEPRINT.route('/collections/<path:collection_id>/schema')
|
@BLUEPRINT.route('/collections/<path:collection_id>/schema')
|
||||||
def collection_schema(collection_id):
|
def collection_schema(collection_id):
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -119,21 +119,29 @@ class SpeckleProvider(BaseProvider):
|
|||||||
self.speckle_url = self.url.lower().split("speckleurl=")[-1].split("&")[0].split("@")[0].split("?")[0]
|
self.speckle_url = self.url.lower().split("speckleurl=")[-1].split("&")[0].split("@")[0].split("?")[0]
|
||||||
|
|
||||||
self.speckle_data = None
|
self.speckle_data = None
|
||||||
|
self.project_name = ""
|
||||||
self.model_name = ""
|
self.model_name = ""
|
||||||
|
|
||||||
self.crs = None
|
self.crs = None
|
||||||
self.crs_dict = None
|
self.crs_dict = None
|
||||||
|
|
||||||
self.requested_data_type: str = "polygons (default)" # points, lines, polygons, projectcomments
|
self.commit_gis = False
|
||||||
self.preserve_attributes: str = "false (default)"
|
self.url_params = {"url_data_type":"", "url_preserve_attributes":"", "url_crs_authid":"", "url_lat":"","url_lon":"","url_north_degrees":"","url_limit":""}
|
||||||
|
self.times = {}
|
||||||
|
|
||||||
|
self.requested_data_type: str = "polygons (default)" # points, lines, polygons, projectcomments
|
||||||
|
self.preserve_attributes: str = "true (default)"
|
||||||
self.lat: float = 48.76755913928929 #51.52486388756923
|
self.lat: float = 48.76755913928929 #51.52486388756923
|
||||||
self.lon: float = 11.408741923664028 #0.1621445437168942
|
self.lon: float = 11.408741923664028 #0.1621445437168942
|
||||||
self.north_degrees: float = 0
|
self.north_degrees: float = 0
|
||||||
self.extent = [-180,-90,180,90]
|
self.crs_authid = ""
|
||||||
self.limit = 10000
|
self.limit = 10000
|
||||||
|
self.user_agent = ""
|
||||||
|
|
||||||
|
self.missing_url = ""
|
||||||
self.limit_message = ""
|
self.limit_message = ""
|
||||||
|
|
||||||
|
self.extent = [-180,-90,180,90]
|
||||||
self.material_color_proxies = {}
|
self.material_color_proxies = {}
|
||||||
|
|
||||||
|
|
||||||
@@ -173,7 +181,7 @@ class SpeckleProvider(BaseProvider):
|
|||||||
if self.data == "":
|
if self.data == "":
|
||||||
return
|
return
|
||||||
|
|
||||||
get_set_url_parameters(self)
|
get_set_url_parameters(self) # possible ValueError
|
||||||
|
|
||||||
# check if it's a new request (self.data was updated and doesn't match self.url)
|
# check if it's a new request (self.data was updated and doesn't match self.url)
|
||||||
new_request = False
|
new_request = False
|
||||||
@@ -266,6 +274,18 @@ class SpeckleProvider(BaseProvider):
|
|||||||
if data is None:
|
if data is None:
|
||||||
return {"features":[], "comments":[], "extent": [-180,-90,180,90]}
|
return {"features":[], "comments":[], "extent": [-180,-90,180,90]}
|
||||||
|
|
||||||
|
# add URL parameters
|
||||||
|
data['speckle_url'] = self.speckle_url
|
||||||
|
data['requested_data_type'] = self.requested_data_type
|
||||||
|
data['preserve_attributes'] = self.preserve_attributes
|
||||||
|
data['crs_authid'] = self.crs_authid
|
||||||
|
data['lat'] = self.lat
|
||||||
|
data['lon'] = self.lon
|
||||||
|
data['north_degrees'] = self.north_degrees
|
||||||
|
data['limit'] = self.limit
|
||||||
|
data['missing_url'] = self.missing_url
|
||||||
|
|
||||||
|
|
||||||
data["numberMatched"] = len(data["features"])
|
data["numberMatched"] = len(data["features"])
|
||||||
|
|
||||||
if resulttype == "hits":
|
if resulttype == "hits":
|
||||||
@@ -324,7 +344,8 @@ class SpeckleProvider(BaseProvider):
|
|||||||
def load_speckle_data(self: str) -> Dict:
|
def load_speckle_data(self: str) -> Dict:
|
||||||
"""Receive and process Speckle data, return geojson."""
|
"""Receive and process Speckle data, return geojson."""
|
||||||
|
|
||||||
from pygeoapi.provider.speckle_utils.server_utils import get_stream_branch, get_client, get_comments
|
from datetime import datetime, timezone
|
||||||
|
from pygeoapi.provider.speckle_utils.server_utils import get_stream_branch, get_client, get_comments, set_actions
|
||||||
|
|
||||||
from specklepy.objects.base import Base
|
from specklepy.objects.base import Base
|
||||||
from specklepy.logging.exceptions import SpeckleException
|
from specklepy.logging.exceptions import SpeckleException
|
||||||
@@ -354,6 +375,7 @@ class SpeckleProvider(BaseProvider):
|
|||||||
comments = {}
|
comments = {}
|
||||||
|
|
||||||
# set the Model name
|
# set the Model name
|
||||||
|
self.project_name = stream['name']
|
||||||
self.model_name = branch['name']
|
self.model_name = branch['name']
|
||||||
|
|
||||||
commit = branch["commits"]["items"][0]
|
commit = branch["commits"]["items"][0]
|
||||||
@@ -364,6 +386,7 @@ class SpeckleProvider(BaseProvider):
|
|||||||
raise SpeckleException("Transport not found")
|
raise SpeckleException("Transport not found")
|
||||||
|
|
||||||
# receive commit
|
# receive commit
|
||||||
|
set_actions(self, client)
|
||||||
try:
|
try:
|
||||||
commit_obj = operations.receive(objId, transport, None)
|
commit_obj = operations.receive(objId, transport, None)
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
@@ -377,10 +400,9 @@ class SpeckleProvider(BaseProvider):
|
|||||||
message="Received commit in pygeoapi",
|
message="Received commit in pygeoapi",
|
||||||
)
|
)
|
||||||
|
|
||||||
print(f"Rendering model '{branch['name']}' of the project '{stream['name']}'")
|
print(f"____{datetime.now().astimezone(timezone.utc)} _Rendering model '{branch['name']}' of the project '{stream['name']}'")
|
||||||
speckle_data = self.traverse_data(commit_obj, comments)
|
speckle_data = self.traverse_data(commit_obj, comments)
|
||||||
|
|
||||||
|
|
||||||
speckle_data["features"].extend(speckle_data["comments"])
|
speckle_data["features"].extend(speckle_data["comments"])
|
||||||
speckle_data["comments"] = []
|
speckle_data["comments"] = []
|
||||||
|
|
||||||
@@ -459,7 +481,10 @@ class SpeckleProvider(BaseProvider):
|
|||||||
sorted_list[i]["properties"]["FID"] = i+1
|
sorted_list[i]["properties"]["FID"] = i+1
|
||||||
data['features'] = sorted_list
|
data['features'] = sorted_list
|
||||||
time2 = datetime.now()
|
time2 = datetime.now()
|
||||||
print(f"Sorting time: {(time2-time1).total_seconds()}")
|
|
||||||
|
time_operation = (time2-time1).total_seconds()
|
||||||
|
self.times["time_sort"] = time_operation
|
||||||
|
# print(f"Sorting time: {time_operation}")
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,10 @@ def reproject_bulk(self, all_coords: List[List[List[float]]], all_coord_counts:
|
|||||||
time1 = datetime.now()
|
time1 = datetime.now()
|
||||||
flat_coords = reproject_2d_coords_list(self, all_coords)
|
flat_coords = reproject_2d_coords_list(self, all_coords)
|
||||||
time2 = datetime.now()
|
time2 = datetime.now()
|
||||||
print(f"Reproject time: {(time2-time1).total_seconds()}")
|
|
||||||
|
time_operation = (time2-time1).total_seconds()
|
||||||
|
self.times["time_reproject"] = time_operation
|
||||||
|
# print(f"Reproject time: {time_operation}")
|
||||||
|
|
||||||
# define type of features
|
# define type of features
|
||||||
feat_coord_group_is_multi = [True if None in x else False for x in all_coord_counts]
|
feat_coord_group_is_multi = [True if None in x else False for x in all_coord_counts]
|
||||||
@@ -61,7 +64,10 @@ def reproject_bulk(self, all_coords: List[List[List[float]]], all_coord_counts:
|
|||||||
geometry["coordinates"].extend(polygon_parts)
|
geometry["coordinates"].extend(polygon_parts)
|
||||||
|
|
||||||
time3 = datetime.now()
|
time3 = datetime.now()
|
||||||
print(f"Construct back geometry time: {(time3-time2).total_seconds()}")
|
|
||||||
|
time_operation = (time3-time2).total_seconds()
|
||||||
|
self.times["time_reconstruct_geometry"] = time_operation
|
||||||
|
# print(f"Construct back geometry time: {time_operation}")
|
||||||
|
|
||||||
def reproject_2d_coords_list(self, coords_in: List[List[float]]) -> List[List[float]]:
|
def reproject_2d_coords_list(self, coords_in: List[List[float]]) -> List[List[float]]:
|
||||||
"""Return coordinates in a CRS of SpeckleProvider."""
|
"""Return coordinates in a CRS of SpeckleProvider."""
|
||||||
|
|||||||
@@ -73,6 +73,7 @@ def get_set_crs_settings(self: "SpeckleProvider", commit_obj: "Base", context_li
|
|||||||
offset_y = crs["offset_y"]
|
offset_y = crs["offset_y"]
|
||||||
self.north_degrees = crs["rotation"]
|
self.north_degrees = crs["rotation"]
|
||||||
create_crs_from_wkt(self, crs["wkt"])
|
create_crs_from_wkt(self, crs["wkt"])
|
||||||
|
self.commit_gis = True
|
||||||
|
|
||||||
if self.crs.to_authority() is not None:
|
if self.crs.to_authority() is not None:
|
||||||
data["model_crs"] = f"{self.crs.to_authority()}, {self.crs.name} "
|
data["model_crs"] = f"{self.crs.to_authority()}, {self.crs.name} "
|
||||||
|
|||||||
@@ -165,12 +165,14 @@ def get_single_display_object(displayValForColor: List) -> "Base":
|
|||||||
except IndexError:
|
except IndexError:
|
||||||
break
|
break
|
||||||
elif item is not None:
|
elif item is not None:
|
||||||
displayValForColor = item
|
return item
|
||||||
|
|
||||||
mesh = Mesh.create(faces= faces, vertices=verts, colors=colors)
|
mesh = Mesh.create(faces= faces, vertices=verts, colors=colors)
|
||||||
for prop in displayValForColor[0].get_member_names():
|
|
||||||
if prop not in ["colors", "vertices", "faces"]:
|
if isinstance(displayValForColor, List) and len(displayValForColor)>0:
|
||||||
mesh[prop] = getattr(displayValForColor[0], prop)
|
for prop in displayValForColor[0].get_member_names():
|
||||||
|
if prop not in ["colors", "vertices", "faces"]:
|
||||||
|
mesh[prop] = getattr(displayValForColor[0], prop)
|
||||||
|
|
||||||
displayValForColor = mesh
|
displayValForColor = mesh
|
||||||
return displayValForColor
|
return displayValForColor
|
||||||
@@ -258,10 +260,35 @@ def set_default_color(context_list: List["TraversalContext"]) -> None:
|
|||||||
DEFAULT_COLOR = (255 << 24) + (10 << 16) + (132 << 8) + 255
|
DEFAULT_COLOR = (255 << 24) + (10 << 16) + (132 << 8) + 255
|
||||||
break
|
break
|
||||||
|
|
||||||
def assign_color(self: "SpeckleProvider", obj_display, props) -> None:
|
def getAllParents(tc: "TraversalContext"):
|
||||||
|
|
||||||
|
all_tc = [tc]
|
||||||
|
while True:
|
||||||
|
try:
|
||||||
|
parent = tc.parent
|
||||||
|
if parent:
|
||||||
|
all_tc.append(parent)
|
||||||
|
tc = parent
|
||||||
|
else:
|
||||||
|
break
|
||||||
|
except:
|
||||||
|
break
|
||||||
|
|
||||||
|
return all_tc
|
||||||
|
|
||||||
|
def assign_color(self: "SpeckleProvider", obj_display_tc: "TraversalContext", props: Dict) -> None:
|
||||||
"""Get and assign color to feature displayProperties."""
|
"""Get and assign color to feature displayProperties."""
|
||||||
|
|
||||||
from specklepy.objects.geometry import Base, Mesh, Brep
|
from specklepy.objects.geometry import Mesh, Brep
|
||||||
|
|
||||||
|
for tc in getAllParents(obj_display_tc):
|
||||||
|
|
||||||
|
try:
|
||||||
|
color = self.material_color_proxies[tc.current.applicationId]
|
||||||
|
props['color'] = color
|
||||||
|
return
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
try:
|
try:
|
||||||
color = self.material_color_proxies[obj_display.applicationId]
|
color = self.material_color_proxies[obj_display.applicationId]
|
||||||
@@ -274,6 +301,8 @@ def assign_color(self: "SpeckleProvider", obj_display, props) -> None:
|
|||||||
color = DEFAULT_COLOR
|
color = DEFAULT_COLOR
|
||||||
opacity = None
|
opacity = None
|
||||||
|
|
||||||
|
obj_display = obj_display_tc.current
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# prioritize renderMaterials for Meshes & Brep
|
# prioritize renderMaterials for Meshes & Brep
|
||||||
if isinstance(obj_display, Mesh) or isinstance(obj_display, Brep):
|
if isinstance(obj_display, Mesh) or isinstance(obj_display, Brep):
|
||||||
@@ -336,12 +365,12 @@ def get_r_g_b(rgb: int) -> Tuple[int, int, int]:
|
|||||||
a = 255
|
a = 255
|
||||||
return a, r, g, b
|
return a, r, g, b
|
||||||
|
|
||||||
def assign_display_properties(self: "SpeckleProvider", feature: Dict, f_base: "Base", obj_display: "Base") -> None:
|
def assign_display_properties(self: "SpeckleProvider", feature: Dict, f_base: "Base", obj_display_tc: "TraversalContext") -> None:
|
||||||
"""Assign displayProperties to the feature."""
|
"""Assign displayProperties to the feature."""
|
||||||
|
|
||||||
from specklepy.objects.geometry import Mesh, Brep
|
from specklepy.objects.geometry import Mesh, Brep
|
||||||
|
|
||||||
assign_color(self, obj_display, feature["displayProperties"])
|
assign_color(self, obj_display_tc, feature["displayProperties"])
|
||||||
feature["properties"]["color"] = feature["displayProperties"]["color"]
|
feature["properties"]["color"] = feature["displayProperties"]["color"]
|
||||||
|
|
||||||
# other properties for rendering
|
# other properties for rendering
|
||||||
|
|||||||
@@ -10,7 +10,10 @@ def initialize_features(self: "SpeckleProvider", all_coords, all_coord_counts, d
|
|||||||
from pygeoapi.provider.speckle_utils.converter_utils import assign_geometry
|
from pygeoapi.provider.speckle_utils.converter_utils import assign_geometry
|
||||||
from pygeoapi.provider.speckle_utils.display_utils import find_display_obj, assign_display_properties, find_list_of_display_obj
|
from pygeoapi.provider.speckle_utils.display_utils import find_display_obj, assign_display_properties, find_list_of_display_obj
|
||||||
|
|
||||||
print(f"Creating features..")
|
from specklepy.objects.graph_traversal.traversal import TraversalContext
|
||||||
|
from specklepy.objects.other import Collection
|
||||||
|
|
||||||
|
# print(f"Creating features..")
|
||||||
time1 = datetime.now()
|
time1 = datetime.now()
|
||||||
|
|
||||||
all_props = []
|
all_props = []
|
||||||
@@ -19,6 +22,9 @@ def initialize_features(self: "SpeckleProvider", all_coords, all_coord_counts, d
|
|||||||
if self.requested_data_type != "projectcomments":
|
if self.requested_data_type != "projectcomments":
|
||||||
for item in context_list:
|
for item in context_list:
|
||||||
|
|
||||||
|
if item.current.speckle_type.endswith("Collection") or item.current.speckle_type.endswith("Layer") or item.current.speckle_type.endswith("Proxy"):
|
||||||
|
continue
|
||||||
|
|
||||||
if feature_count >= self.limit:
|
if feature_count >= self.limit:
|
||||||
self.limit_message = f" (feature count limited to {self.limit})"
|
self.limit_message = f" (feature count limited to {self.limit})"
|
||||||
break
|
break
|
||||||
@@ -28,9 +34,13 @@ def initialize_features(self: "SpeckleProvider", all_coords, all_coord_counts, d
|
|||||||
f_fid = feature_count + 1
|
f_fid = feature_count + 1
|
||||||
|
|
||||||
# initialize feature
|
# initialize feature
|
||||||
|
speckle_type = item.current.speckle_type
|
||||||
|
if ":" in speckle_type:
|
||||||
|
speckle_type = speckle_type.split(":")[-1]
|
||||||
|
|
||||||
feature: Dict = {
|
feature: Dict = {
|
||||||
"type": "Feature",
|
"type": "Feature",
|
||||||
# "bbox": [-180.0, -90.0, 180.0, 90.0],
|
#"bbox": [-180.0, -90.0, 180.0, 90.0], should not be in degrees
|
||||||
"geometry": {},
|
"geometry": {},
|
||||||
"displayProperties":{
|
"displayProperties":{
|
||||||
"object_type": "geometry",
|
"object_type": "geometry",
|
||||||
@@ -38,7 +48,7 @@ def initialize_features(self: "SpeckleProvider", all_coords, all_coord_counts, d
|
|||||||
"properties": {
|
"properties": {
|
||||||
"id": f_id,
|
"id": f_id,
|
||||||
"FID": f_fid,
|
"FID": f_fid,
|
||||||
"speckle_type": item.current.speckle_type.split(":")[-1],
|
"speckle_type": speckle_type,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,8 +77,11 @@ def initialize_features(self: "SpeckleProvider", all_coords, all_coord_counts, d
|
|||||||
if prop not in all_props:
|
if prop not in all_props:
|
||||||
all_props.append(prop)
|
all_props.append(prop)
|
||||||
|
|
||||||
assign_display_properties(self, feature, f_base, obj_get_color)
|
obj_get_color_tc = TraversalContext(obj_get_color, "", item)
|
||||||
|
|
||||||
|
assign_display_properties(self, feature, f_base, obj_get_color_tc)
|
||||||
feature["max_height"] = max([c[2] for c in coords])
|
feature["max_height"] = max([c[2] for c in coords])
|
||||||
|
feature["bbox"] = get_feature_bbox(coords)
|
||||||
data["features"].append(feature)
|
data["features"].append(feature)
|
||||||
feature_count += 1
|
feature_count += 1
|
||||||
|
|
||||||
@@ -81,7 +94,7 @@ def initialize_features(self: "SpeckleProvider", all_coords, all_coord_counts, d
|
|||||||
f_fid = feature_count + 1
|
f_fid = feature_count + 1
|
||||||
feature_new: Dict = {
|
feature_new: Dict = {
|
||||||
"type": "Feature",
|
"type": "Feature",
|
||||||
# "bbox": [-180.0, -90.0, 180.0, 90.0],
|
#"bbox": [-180.0, -90.0, 180.0, 90.0], should not be in degrees
|
||||||
"geometry": {},
|
"geometry": {},
|
||||||
"displayProperties":{
|
"displayProperties":{
|
||||||
"object_type": "geometry",
|
"object_type": "geometry",
|
||||||
@@ -107,11 +120,14 @@ def initialize_features(self: "SpeckleProvider", all_coords, all_coord_counts, d
|
|||||||
all_coords.extend(coords)
|
all_coords.extend(coords)
|
||||||
all_coord_counts.append(coord_counts)
|
all_coord_counts.append(coord_counts)
|
||||||
|
|
||||||
assign_display_properties(self, feature_new, f_base, obj_get_color)
|
obj_get_color_tc = TraversalContext(obj_get_color, "", item)
|
||||||
|
|
||||||
|
assign_display_properties(self, feature_new, f_base, obj_get_color_tc)
|
||||||
feature_new["max_height"] = max([c[2] for c in coords])
|
feature_new["max_height"] = max([c[2] for c in coords])
|
||||||
|
feature_new["bbox"] = get_feature_bbox(coords)
|
||||||
data["features"].append(feature_new)
|
data["features"].append(feature_new)
|
||||||
feature_count +=1
|
feature_count +=1
|
||||||
|
|
||||||
assign_missing_props(data["features"], all_props)
|
assign_missing_props(data["features"], all_props)
|
||||||
else:
|
else:
|
||||||
####################### create comment features
|
####################### create comment features
|
||||||
@@ -156,7 +172,20 @@ def initialize_features(self: "SpeckleProvider", all_coords, all_coord_counts, d
|
|||||||
raise ValueError("No supported features found")
|
raise ValueError("No supported features found")
|
||||||
|
|
||||||
time2 = datetime.now()
|
time2 = datetime.now()
|
||||||
print(f"Creating features time: {(time2-time1).total_seconds()}")
|
|
||||||
|
time_operation = (time2-time1).total_seconds()
|
||||||
|
self.times["time_creating_features"] = time_operation
|
||||||
|
# print(f"Creating features time: {time_operation}")
|
||||||
|
|
||||||
|
def get_feature_bbox(coords) -> List[float]:
|
||||||
|
"""Get min max coordinates of the feature."""
|
||||||
|
|
||||||
|
x0 = min([c[0] for c in coords])
|
||||||
|
x1 = max([c[0] for c in coords])
|
||||||
|
y0 = min([c[1] for c in coords])
|
||||||
|
y1 = max([c[1] for c in coords])
|
||||||
|
|
||||||
|
return [x0, y0, x1, y1]
|
||||||
|
|
||||||
def assign_comment_data(comments, properties):
|
def assign_comment_data(comments, properties):
|
||||||
"""Create html text to display for the thread."""
|
"""Create html text to display for the thread."""
|
||||||
|
|||||||
@@ -168,8 +168,23 @@ class ServerTransport(AbstractTransport):
|
|||||||
# iter through returned objects saving them as we go
|
# iter through returned objects saving them as we go
|
||||||
target_transport.begin_write()
|
target_transport.begin_write()
|
||||||
all_lines = [line for _,line in enumerate(lines)]
|
all_lines = [line for _,line in enumerate(lines)]
|
||||||
|
|
||||||
|
# fix wrongly split lines
|
||||||
for i, line in enumerate(all_lines):
|
for i, line in enumerate(all_lines):
|
||||||
if line:
|
if line and i!= 0 and (len(line)<=10 or'"id": "' not in line[:10]):
|
||||||
|
# find the last line with ID
|
||||||
|
matching_index = -1
|
||||||
|
for k, id_line in enumerate(all_lines):
|
||||||
|
if k<i and '"id": "' in id_line:
|
||||||
|
matching_index = k
|
||||||
|
if k==i:
|
||||||
|
break
|
||||||
|
if matching_index != -1:
|
||||||
|
all_lines[matching_index] += "},{" + line
|
||||||
|
all_lines[i] = ""
|
||||||
|
|
||||||
|
for i, line in enumerate(all_lines):
|
||||||
|
if line and len(line)>10 and '"id": "' in line[:10]:
|
||||||
hash = line.split('"id": "')[1].split('"')[0]
|
hash = line.split('"id": "')[1].split('"')[0]
|
||||||
obj = "{" + line + "}"
|
obj = "{" + line + "}"
|
||||||
if i==0:
|
if i==0:
|
||||||
|
|||||||
@@ -216,4 +216,15 @@ def get_attachment(project_id: str, attachment_id: str, attachment_name: str) ->
|
|||||||
raise Exception(
|
raise Exception(
|
||||||
f"Request not successful: Response code {r.status_code}"
|
f"Request not successful: Response code {r.status_code}"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def set_actions(self: "SpeckleProvider", client: "SpeckleClient"):
|
||||||
|
from specklepy.logging.metrics import track
|
||||||
|
try:
|
||||||
|
full_dict = {**self.url_params, **self.times}
|
||||||
|
full_dict["GIS commit"] = self.commit_gis
|
||||||
|
full_dict["model"] = f"{self.project_name}, {self.model_name}"
|
||||||
|
full_dict["time_TOTAL"] = sum([x[1] for x in self.times.items()])
|
||||||
|
full_dict["model_url"] = self.speckle_url
|
||||||
|
track("GEO receive", client.account, full_dict)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
@@ -1,65 +1,104 @@
|
|||||||
|
|
||||||
|
|
||||||
from typing import Dict
|
import inspect
|
||||||
|
|
||||||
|
|
||||||
def get_set_url_parameters(self: "SpeckleProvider"):
|
def get_set_url_parameters(self: "SpeckleProvider"):
|
||||||
|
"""Parse and save URL parameters."""
|
||||||
|
|
||||||
from pygeoapi.provider.speckle_utils.crs_utils import create_crs_from_authid
|
from pygeoapi.provider.speckle_utils.crs_utils import create_crs_from_authid
|
||||||
|
|
||||||
if (
|
crsauthid = False
|
||||||
isinstance(self.data, str)
|
|
||||||
and "speckleurl=" in self.data.lower()
|
if (isinstance(self.data, str)):
|
||||||
and "projects" in self.data
|
|
||||||
and "models" in self.data
|
|
||||||
):
|
|
||||||
crs_authid = ""
|
|
||||||
for item in self.data.lower().split("&"):
|
for item in self.data.lower().split("&"):
|
||||||
|
|
||||||
# if CRS authid is found, rest will be ignored
|
# if CRS authid is found, rest will be ignored
|
||||||
if "datatype=" in item:
|
if "speckleurl=" in item:
|
||||||
try:
|
try:
|
||||||
self.requested_data_type = item.split("datatype=")[1]
|
speckle_url = item.split("speckleurl=")[1]
|
||||||
if self.requested_data_type not in ["points", "lines", "polygons", "projectcomments"]:
|
if "/projects/" not in speckle_url or "/models/" not in speckle_url:
|
||||||
self.requested_data_type = "polygons (default)"
|
raise ValueError(f"Provide valid Speckle Model URL: {item}")
|
||||||
|
|
||||||
|
if speckle_url[-1] == "/":
|
||||||
|
speckle_url = speckle_url[:-1]
|
||||||
|
self.speckle_project_url = speckle_url.split("/models")[0]
|
||||||
except:
|
except:
|
||||||
pass
|
raise ValueError(f"Provide valid Speckle Model URL: {item}")
|
||||||
|
|
||||||
|
elif "datatype=" in item:
|
||||||
|
try:
|
||||||
|
requested_data_type = item.split("datatype=")[1]
|
||||||
|
if requested_data_type in ["points", "lines", "polygons", "projectcomments"]:
|
||||||
|
self.requested_data_type = requested_data_type
|
||||||
|
self.url_params["url_data_type"] = requested_data_type
|
||||||
|
except:
|
||||||
|
raise ValueError(f"Provide valid dataType parameter (points/lines/polygons/projectcomments): {item}")
|
||||||
|
|
||||||
elif "preserveattributes=" in item:
|
elif "preserveattributes=" in item:
|
||||||
try:
|
try:
|
||||||
self.preserve_attributes = item.split("preserveattributes=")[1]
|
preserve_attributes = item.split("preserveattributes=")[1]
|
||||||
if self.preserve_attributes not in ["true", "false"]:
|
if preserve_attributes in ["true", "false"]:
|
||||||
self.preserve_attributes = "false (default)"
|
self.preserve_attributes = preserve_attributes
|
||||||
|
self.url_params["url_preserve_attributes"] = preserve_attributes
|
||||||
except:
|
except:
|
||||||
pass
|
ValueError(f"Provide valid preserverAttributes parameter (true/false): {item}")
|
||||||
|
|
||||||
elif "limit=" in item:
|
|
||||||
try:
|
|
||||||
self.limit = int(item.split("limit=")[1])
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
|
|
||||||
elif "crsauthid=" in item:
|
elif "crsauthid=" in item:
|
||||||
crs_authid = item.split("crsauthid=")[1]
|
crs_authid = item.split("crsauthid=")[1]
|
||||||
|
if isinstance(crs_authid, str) and len(crs_authid)>3:
|
||||||
|
crsauthid = True
|
||||||
|
self.crs_authid = crs_authid
|
||||||
|
self.url_params["url_crs_authid"] = crs_authid
|
||||||
|
|
||||||
elif "lat=" in item:
|
elif "lat=" in item:
|
||||||
try:
|
try:
|
||||||
self.lat = float(item.split("lat=")[1])
|
lat = float(item.split("lat=")[1])
|
||||||
|
self.lat = lat
|
||||||
|
self.url_params["url_lat"] = lat
|
||||||
except:
|
except:
|
||||||
pass
|
raise ValueError(f"Invalid Lat input, must be numeric: {item}")
|
||||||
# raise ValueError(f"Invalid Lat input, must be numeric: {item.split('lat=')[1]}")
|
|
||||||
elif "lon=" in item:
|
elif "lon=" in item:
|
||||||
try:
|
try:
|
||||||
self.lon = float(item.split("lon=")[1])
|
lon = float(item.split("lon=")[1])
|
||||||
|
self.lon = lon
|
||||||
|
self.url_params["url_lon"] = lon
|
||||||
except:
|
except:
|
||||||
pass
|
raise ValueError(f"Invalid Lon input, must be numeric: {item}")
|
||||||
# raise ValueError(f"Invalid Lon input, must be numeric: {item.split('lon=')[1]}")
|
|
||||||
elif "northdegrees=" in item:
|
elif "northdegrees=" in item:
|
||||||
try:
|
try:
|
||||||
self.north_degrees = float(item.split("northdegrees=")[1])
|
north_degrees = float(item.split("northdegrees=")[1])
|
||||||
|
self.north_degrees = north_degrees
|
||||||
|
self.url_params["url_north_degrees"] = north_degrees
|
||||||
except:
|
except:
|
||||||
pass
|
raise ValueError(f"Invalid northDegrees input, must be numeric: {item}")
|
||||||
# raise ValueError(f"Invalid NorthDegrees input, must be numeric: {item.split('northdegrees=')[1]}")
|
elif "limit=" in item:
|
||||||
|
try:
|
||||||
|
limit = int(item.split("limit=")[1])
|
||||||
|
if limit>0:
|
||||||
|
self.limit = limit
|
||||||
|
self.url_params["url_limit"] = limit
|
||||||
|
except:
|
||||||
|
ValueError(f"Invalid limit input, must be a positive integer: {item}")
|
||||||
|
|
||||||
|
elif "useragent=" in item:
|
||||||
|
try:
|
||||||
|
agent = item.split("useragent=")[1]
|
||||||
|
self.user_agent = agent
|
||||||
|
self.url_params["user_agent"] = agent
|
||||||
|
except:
|
||||||
|
ValueError(f"Invalid limit input, must be a positive integer: {item}")
|
||||||
|
|
||||||
|
|
||||||
|
if self.speckle_url == "-":
|
||||||
|
self.missing_url = "true"
|
||||||
|
|
||||||
|
# if CRS authid is found, rest will be ignored
|
||||||
|
if crsauthid:
|
||||||
|
self.lat = str(self.lat) + " (not applied)"
|
||||||
|
self.lon = str(self.lon) + " (not applied)"
|
||||||
|
self.north_degrees = str(self.north_degrees) + " (not applied)"
|
||||||
|
|
||||||
# if CRS parameter present, create and assign CRS:
|
# if CRS parameter present, create and assign CRS:
|
||||||
if len(crs_authid)>3:
|
if len(self.crs_authid)>3:
|
||||||
create_crs_from_authid(self)
|
create_crs_from_authid(self)
|
||||||
|
|||||||
@@ -71,7 +71,7 @@
|
|||||||
<meta name="language" content="{{ config['server']['language'] }}">
|
<meta name="language" content="{{ config['server']['language'] }}">
|
||||||
<meta name="description" content="{{ config['metadata']['identification']['title'] }}">
|
<meta name="description" content="{{ config['metadata']['identification']['title'] }}">
|
||||||
<meta name="keywords" content="{{ config['metadata']['identification']['keywords']|join(',') }}">
|
<meta name="keywords" content="{{ config['metadata']['identification']['keywords']|join(',') }}">
|
||||||
<link rel="shortcut icon" href="{{ config['server']['url'] }}/static/img/speckle_geo.png" type="image/x-icon">
|
<link rel="shortcut icon" href="https://github.com/specklesystems/pygeoapi/blob/dev/pygeoapi/static/img/speckle_geo.png" type="image/x-icon">
|
||||||
<link rel="stylesheet" href="https://unpkg.com/bootstrap@5.1.3/dist/css/bootstrap.min.css">
|
<link rel="stylesheet" href="https://unpkg.com/bootstrap@5.1.3/dist/css/bootstrap.min.css">
|
||||||
<link rel="stylesheet" href="{{ config['server']['url'] }}/static/css/default.css">
|
<link rel="stylesheet" href="{{ config['server']['url'] }}/static/css/default.css">
|
||||||
<!--[if lt IE 9]>
|
<!--[if lt IE 9]>
|
||||||
@@ -109,11 +109,9 @@
|
|||||||
title="{{ config['metadata']['identification']['title'] }}" style="height:30px;vertical-align: middle;" />
|
title="{{ config['metadata']['identification']['title'] }}" style="height:30px;vertical-align: middle;" />
|
||||||
<b style="text-align:left;padding-left: 10px;">Speckle</b>
|
<b style="text-align:left;padding-left: 10px;">Speckle</b>
|
||||||
</a>
|
</a>
|
||||||
<p style="text-align:left;padding-left: 10px;" class="d-flex align-items-center mb-3 mb-md-0 me-md-auto text-dark text-decoration-none">
|
<a href="https://geo.speckle.systems/" target="_blank" style="text-align:left;padding-left: 10px;" class="d-flex align-items-center mb-3 mb-md-0 me-md-auto text-dark text-decoration-none">
|
||||||
<a href="https://geo.speckle.systems/" target="_blank" style="text-align:left;padding-left: 10px;" class="d-flex align-items-center mb-3 mb-md-0 me-md-auto text-dark text-decoration-none">
|
|
||||||
> Geolocating your data
|
> Geolocating your data
|
||||||
</a>
|
</a>
|
||||||
</p>
|
|
||||||
{% if (data["model"] and data["model"]!="") %}
|
{% if (data["model"] and data["model"]!="") %}
|
||||||
<a href="{{data['speckle_project_url']}}" target="_blank" style="text-align:left;padding-left: 10px;" class="d-flex align-items-center mb-3 mb-md-0 me-md-auto text-dark text-decoration-none">
|
<a href="{{data['speckle_project_url']}}" target="_blank" style="text-align:left;padding-left: 10px;" class="d-flex align-items-center mb-3 mb-md-0 me-md-auto text-dark text-decoration-none">
|
||||||
> {{data["project"]}} >
|
> {{data["project"]}} >
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
{% if not data['missing_url'] %}
|
{% if data['speckle_url'] %}
|
||||||
|
|
||||||
|
|
||||||
<div id="map2d" style="height: 80vh;"></div>
|
<div id="map2d" style="height: 80vh;"></div>
|
||||||
@@ -53,7 +53,7 @@
|
|||||||
</p>
|
</p>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
{% if data['missing_url'] %}
|
{% if not data['speckle_url'] %}
|
||||||
<tr>
|
<tr>
|
||||||
<p>
|
<p>
|
||||||
<div style="height: fit-content;">
|
<div style="height: fit-content;">
|
||||||
@@ -335,7 +335,10 @@
|
|||||||
{% block extrafoot %}
|
{% block extrafoot %}
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
document.getElementById("loading_screen").remove();
|
try {
|
||||||
|
document.getElementById("loading_screen").remove();
|
||||||
|
}
|
||||||
|
catch(err) {}
|
||||||
|
|
||||||
// attach even to modeSwitch btn
|
// attach even to modeSwitch btn
|
||||||
document.getElementById("modeSwitch").onclick = switchMode;
|
document.getElementById("modeSwitch").onclick = switchMode;
|
||||||
@@ -357,67 +360,97 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function split_polygons(geojson_data){
|
||||||
|
features = []
|
||||||
|
geojson_data.forEach((element, index) => {
|
||||||
|
if (element.geometry.type == "MultiPolygon"){
|
||||||
|
// mesh faces are stored as parts, so most buildings might have hundreds of parts with just 1 loop or 3-4pts
|
||||||
|
all_parts = element.geometry.coordinates;
|
||||||
|
|
||||||
|
// loops are usually simple (3-4 vertices), and usually only loop
|
||||||
|
for (polyPart of all_parts){
|
||||||
|
new_coordinates = [polyPart];
|
||||||
|
new_element = {"id": element.properties.id, "type":"Feature",
|
||||||
|
"geometry": {"type": "MultiPolygon", "coordinates": new_coordinates},
|
||||||
|
"properties": element.properties,
|
||||||
|
"displayProperties": element.displayProperties };
|
||||||
|
|
||||||
|
features.push(new_element)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
features.push(element)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return features
|
||||||
|
}
|
||||||
|
|
||||||
var data = {{ data | to_json | safe }};
|
var data = {{ data | to_json | safe }};
|
||||||
var geojson_data = {{ data['features'] | to_json | safe }};
|
var geojson_data_original = {{ data['features'] | to_json | safe }};
|
||||||
|
|
||||||
// Leaflet 2d map
|
// Leaflet 2d map
|
||||||
function initialize2d() {
|
function initialize2d() {
|
||||||
var map = L.map('map2d').setView([45, 0], 2);
|
var map = L.map('map2d', {zoomControl: false}).setView([45, 0], 2);
|
||||||
map.addLayer(new L.TileLayer(
|
L.control.zoom({
|
||||||
'{{ config['server']['map']['url'] }}', {
|
position: 'topright'
|
||||||
maxZoom: 22,
|
}).addTo(map);
|
||||||
attribution: '{{ config['server']['map']['attribution'] | safe }} © Data: <a href="https://speckle.systems/">Speckle Systems</a>'
|
map.addLayer(new L.TileLayer(
|
||||||
}
|
'{{ config['server']['map']['url'] }}', {
|
||||||
));
|
maxZoom: 22,
|
||||||
|
attribution: '{{ config['server']['map']['attribution'] | safe }} © Data: <a href="https://speckle.systems/">Speckle Systems</a>'
|
||||||
|
}
|
||||||
|
));
|
||||||
|
|
||||||
var items = new L.GeoJSON(geojson_data, {
|
geojson_data = split_polygons(geojson_data_original);
|
||||||
filter: (feature) => {
|
|
||||||
return feature.displayProperties["object_type"] == "geometry"
|
|
||||||
},
|
|
||||||
pointToLayer: (feature, latlng) => {
|
|
||||||
return new L.circleMarker(latlng)
|
|
||||||
},
|
|
||||||
onEachFeature: function (feature, layer) {
|
|
||||||
var url = '{{ data['speckle_project_url'] }}/models/' + feature.id.split("_")[0]
|
|
||||||
var html = '<span><td><p>' + feature['properties']['speckle_type'] + '</p></td><a href="' + url + '" target="_blank">' + feature['properties']['id'].split("_")[0] + '</a></span>';
|
|
||||||
layer.bindPopup(html);
|
|
||||||
|
|
||||||
var myFillColor = feature.displayProperties['color'];
|
var items = new L.GeoJSON(geojson_data, {
|
||||||
var mylineWeight = feature.displayProperties['lineWidth'];
|
filter: (feature) => {
|
||||||
var myRadius = feature.displayProperties['radius'];
|
return feature.displayProperties["object_type"] == "geometry"
|
||||||
|
},
|
||||||
|
pointToLayer: (feature, latlng) => {
|
||||||
|
return new L.circleMarker(latlng)
|
||||||
|
},
|
||||||
|
onEachFeature: function (feature, layer) {
|
||||||
|
var url = '{{ data['speckle_project_url'] }}/models/' + feature.id.split("_")[0]
|
||||||
|
var html = '<span><td><p>' + feature['properties']['speckle_type'] + '</p></td><a href="' + url + '" target="_blank">' + feature['properties']['id'].split("_")[0] + '</a></span>';
|
||||||
|
layer.bindPopup(html);
|
||||||
|
|
||||||
layer.setStyle({
|
var myFillColor = feature.displayProperties['color'];
|
||||||
fillColor: myFillColor,
|
var mylineWeight = feature.displayProperties['lineWidth'];
|
||||||
color: myFillColor,
|
var myRadius = feature.displayProperties['radius'];
|
||||||
fillOpacity: 0.8,
|
|
||||||
weight: mylineWeight,
|
|
||||||
radius: myRadius
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}); //.addTo(map);
|
|
||||||
|
|
||||||
var comments = new L.GeoJSON(geojson_data, {
|
|
||||||
filter: (feature) => {
|
|
||||||
return feature.displayProperties["object_type"] == "comment"
|
|
||||||
},
|
|
||||||
pointToLayer: (feature, latlng) => {
|
|
||||||
return new L.marker(latlng)
|
|
||||||
},
|
|
||||||
onEachFeature: function (feature, layer) {
|
|
||||||
var url = '{{ data['speckle_project_url'] }}/models/' + feature.properties.resource_id + '#threadId=' + feature.id;
|
|
||||||
var html = '<span><td><a href="' + url + '" target="_blank">Go to thread</a></td> <td><p>' + feature['properties']['text_html'] + '</p></td> </span>';
|
|
||||||
layer.bindPopup(html);
|
|
||||||
}
|
|
||||||
}); //.addTo(map);
|
|
||||||
|
|
||||||
var group = L.featureGroup([items, comments])
|
layer.setStyle({
|
||||||
.addTo(map);
|
fillColor: myFillColor,
|
||||||
|
color: myFillColor,
|
||||||
|
fillOpacity: 0.8,
|
||||||
|
weight: mylineWeight,
|
||||||
|
radius: myRadius
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}); //.addTo(map);
|
||||||
|
|
||||||
|
var comments = new L.GeoJSON(geojson_data, {
|
||||||
|
filter: (feature) => {
|
||||||
|
return feature.displayProperties["object_type"] == "comment"
|
||||||
|
},
|
||||||
|
pointToLayer: (feature, latlng) => {
|
||||||
|
return new L.marker(latlng)
|
||||||
|
},
|
||||||
|
onEachFeature: function (feature, layer) {
|
||||||
|
var url = '{{ data['speckle_project_url'] }}/models/' + feature.properties.resource_id + '#threadId=' + feature.id;
|
||||||
|
var html = '<span><td><a href="' + url + '" target="_blank">Go to thread</a></td> <td><p>' + feature['properties']['text_html'] + '</p></td> </span>';
|
||||||
|
layer.bindPopup(html);
|
||||||
|
}
|
||||||
|
}); //.addTo(map);
|
||||||
|
|
||||||
//map.addLayer(lines);
|
var group = L.featureGroup([items, comments])
|
||||||
|
.addTo(map);
|
||||||
|
|
||||||
map.fitBounds(group.getBounds());
|
//map.addLayer(lines);
|
||||||
// map.setZoom(19); // in order for the tiles to load
|
|
||||||
|
map.fitBounds(group.getBounds());
|
||||||
|
// map.setZoom(19); // in order for the tiles to load
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -504,11 +537,20 @@
|
|||||||
coords = feature.geometry.coordinates;
|
coords = feature.geometry.coordinates;
|
||||||
|
|
||||||
if (feature.geometry.type.includes("Polygon")) {
|
if (feature.geometry.type.includes("Polygon")) {
|
||||||
polygons = []
|
|
||||||
|
|
||||||
// check orientation of each PolygonPart, if vertical - shift points slightly
|
polygon_all_parts = []
|
||||||
|
// iterate through Polygon Parts
|
||||||
for (let p = 0; p < coords.length; p++) {
|
for (let p = 0; p < coords.length; p++) {
|
||||||
|
|
||||||
|
// check orientation of each PolygonPart, if vertical - shift points slightly
|
||||||
|
polygon_part = [];
|
||||||
|
inner = false;
|
||||||
|
|
||||||
for (let c = 0; c < coords[p].length; c++) {
|
for (let c = 0; c < coords[p].length; c++) {
|
||||||
|
polygon_part_loop = [];
|
||||||
|
if (c>0){
|
||||||
|
inner = true;
|
||||||
|
}
|
||||||
|
|
||||||
sum_orientation = 0;
|
sum_orientation = 0;
|
||||||
polygon_pts = coords[p][c]; // usually 3 for Mesh faces
|
polygon_pts = coords[p][c]; // usually 3 for Mesh faces
|
||||||
@@ -521,7 +563,9 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
createdPolygon = false;
|
createdPolygon = false;
|
||||||
if (-0.01 < sum_orientation && sum_orientation <0.01){
|
|
||||||
|
if (-0.000000001 < sum_orientation && sum_orientation <0.000000001){
|
||||||
|
|
||||||
coords[p][c][0][0] += 0.0000001;
|
coords[p][c][0][0] += 0.0000001;
|
||||||
coords[p][c][0][1] += 0.0000001;
|
coords[p][c][0][1] += 0.0000001;
|
||||||
|
|
||||||
@@ -530,46 +574,60 @@
|
|||||||
|
|
||||||
coords[p][c][2][0] += 0.0000001;
|
coords[p][c][2][0] += 0.0000001;
|
||||||
coords[p][c][2][1] += 0.0000001;
|
coords[p][c][2][1] += 0.0000001;
|
||||||
|
|
||||||
if(polygon_pts.length==3) {
|
if(polygon_pts.length==3) {
|
||||||
createdPolygon = true;
|
createdPolygon = true;
|
||||||
|
|
||||||
multipolygon_coords = [coords[p][c]];
|
multipolygon_coords = coords[p][c];
|
||||||
polygons.push({"id": speckle_features.length, "type":"Feature",
|
polygon_part_loop = multipolygon_coords;
|
||||||
"geometry": {"type": "MultiPolygon", "coordinates":[multipolygon_coords]},
|
|
||||||
"properties": speckle_data.features[i].properties,
|
polygon_part = [polygon_part_loop];
|
||||||
"displayProperties": speckle_data.features[i].displayProperties });
|
polygon_all_parts.push(polygon_part);
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (polygon_pts.length==4) {
|
else if (polygon_pts.length==4) {
|
||||||
createdPolygon = true;
|
createdPolygon = true;
|
||||||
|
|
||||||
multipolygon_coords = [coords[p][c].slice(0,3)];
|
multipolygon_coords = coords[p][c].slice(0,3);
|
||||||
polygons.push({"id": speckle_features.length, "type":"Feature",
|
polygon_part_loop = multipolygon_coords;
|
||||||
"geometry": {"type": "MultiPolygon", "coordinates":[multipolygon_coords]},
|
|
||||||
"properties": speckle_data.features[i].properties,
|
|
||||||
"displayProperties": speckle_data.features[i].displayProperties });
|
|
||||||
|
|
||||||
multipolygon_coords = [[coords[p][c][2], coords[p][c][3], coords[p][c][0]]];
|
polygon_part = [polygon_part_loop];
|
||||||
polygons.push({"id": speckle_features.length, "type":"Feature",
|
polygon_all_parts.push(polygon_part);
|
||||||
"geometry": {"type": "MultiPolygon", "coordinates":[multipolygon_coords]},
|
|
||||||
"properties": speckle_data.features[i].properties ,
|
/////////
|
||||||
"displayProperties": speckle_data.features[i].displayProperties });
|
multipolygon_coords = [coords[p][c][2], coords[p][c][3], coords[p][c][0]];
|
||||||
|
polygon_part_loop = multipolygon_coords;
|
||||||
|
|
||||||
|
polygon_part = [polygon_part_loop];
|
||||||
|
polygon_all_parts.push(polygon_part);
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
if (createdPolygon == false){
|
if (createdPolygon == false){ // if non-vertical, or vertical with more than 4 vertices
|
||||||
multipolygon_coords = [coords[p][c]];
|
|
||||||
polygons.push({"id": speckle_features.length, "type":"Feature",
|
multipolygon_coords = coords[p][c];
|
||||||
"geometry": {"type": "MultiPolygon", "coordinates":[multipolygon_coords]},
|
polygon_part_loop = multipolygon_coords;
|
||||||
"properties": speckle_data.features[i].properties,
|
|
||||||
"displayProperties": speckle_data.features[i].displayProperties });
|
if (inner == false){
|
||||||
|
polygon_part = [polygon_part_loop];
|
||||||
|
polygon_all_parts.push(polygon_part);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
polygon_all_parts[polygon_all_parts.length-1].push(polygon_part_loop);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
polygons.forEach((element, index, array) => {
|
|
||||||
element.displayProperties.lineWidth = 0.05
|
new_polygon = {"id": speckle_features.length, "type":"Feature",
|
||||||
speckle_features.push(element);
|
"geometry": {"type": "MultiPolygon", "coordinates":polygon_all_parts},
|
||||||
});
|
"properties": speckle_data.features[i].properties,
|
||||||
|
"displayProperties": speckle_data.features[i].displayProperties };
|
||||||
|
|
||||||
|
new_polygon.displayProperties.lineWidth = 0.05
|
||||||
|
speckle_features.push(new_polygon);
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (speckle_data.features[i].displayProperties.object_type == "comment")
|
else if (speckle_data.features[i].displayProperties.object_type == "comment")
|
||||||
|
|||||||
@@ -9,7 +9,10 @@
|
|||||||
</body>
|
</body>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
document.getElementById("loading_screen").remove();
|
try {
|
||||||
|
document.getElementById("loading_screen").remove();
|
||||||
|
}
|
||||||
|
catch(err) {}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -5,4 +5,10 @@
|
|||||||
<h2>{% trans %}Exception{% endtrans %}</h2>
|
<h2>{% trans %}Exception{% endtrans %}</h2>
|
||||||
<p>{{ data['description'] }}</p>
|
<p>{{ data['description'] }}</p>
|
||||||
</section>
|
</section>
|
||||||
|
<script>
|
||||||
|
try {
|
||||||
|
document.getElementById("loading_screen").remove();
|
||||||
|
}
|
||||||
|
catch(err) {}
|
||||||
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
@@ -86,7 +86,7 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
// construnt data URL
|
// construnt data URL
|
||||||
var link = "https://geo.speckle.systems/?speckleUrl=";
|
var link = "https://geo.speckle.systems/speckle/?speckleUrl=";
|
||||||
if (document.getElementById("speckle_model").value!=""){
|
if (document.getElementById("speckle_model").value!=""){
|
||||||
link += document.getElementById("speckle_model").value.replace(" ", "")
|
link += document.getElementById("speckle_model").value.replace(" ", "")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,7 @@
|
|||||||
));
|
));
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
const speckle_data = await fetch('https://geo.speckle.systems/?speckleUrl=https://app.speckle.systems/projects/344f803f81/models/5582ab673e&datatype=projectcomments', {
|
const speckle_data = await fetch('https://geo.speckle.systems/speckle/?speckleUrl=https://app.speckle.systems/projects/344f803f81/models/5582ab673e&datatype=projectcomments', {
|
||||||
headers: {
|
headers: {
|
||||||
'Accept': 'application/geo+json'
|
'Accept': 'application/geo+json'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,7 @@
|
|||||||
));
|
));
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
const speckle_data = await fetch('https://geo.speckle.systems/?speckleUrl=https://app.speckle.systems/projects/344f803f81/models/5582ab673e&datatype=polygons', {
|
const speckle_data = await fetch('https://geo.speckle.systems/speckle/?speckleUrl=https://app.speckle.systems/projects/344f803f81/models/5582ab673e&datatype=polygons', {
|
||||||
headers: {
|
headers: {
|
||||||
'Accept': 'application/geo+json'
|
'Accept': 'application/geo+json'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,7 @@
|
|||||||
|
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
const speckle_data2 = await fetch('https://geo.speckle.systems/?speckleUrl=https://app.speckle.systems/projects/344f803f81/models/37d93c5d32&preserveAttributes=true', {
|
const speckle_data2 = await fetch('https://geo.speckle.systems/speckle/?speckleUrl=https://app.speckle.systems/projects/344f803f81/models/37d93c5d32&preserveAttributes=true', {
|
||||||
//const speckle_data = await fetch('http://localhost:5000/?speckleUrl=https://app.speckle.systems/projects/64753f52b7/models/338b386787&limit=1000000&lat=-0.031405&lon=109.335828&preserveAttributes=true', {
|
//const speckle_data = await fetch('http://localhost:5000/?speckleUrl=https://app.speckle.systems/projects/64753f52b7/models/338b386787&limit=1000000&lat=-0.031405&lon=109.335828&preserveAttributes=true', {
|
||||||
headers: {
|
headers: {
|
||||||
'Accept': 'application/geo+json'
|
'Accept': 'application/geo+json'
|
||||||
@@ -155,7 +155,7 @@
|
|||||||
|
|
||||||
//map.fitBounds(speckle_layer.getBounds())
|
//map.fitBounds(speckle_layer.getBounds())
|
||||||
|
|
||||||
const speckle_data = await fetch('https://geo.speckle.systems/?speckleUrl=https://app.speckle.systems/projects/344f803f81/models/5582ab673e&datatype=projectcomments', {
|
const speckle_data = await fetch('https://geo.speckle.systems/speckle/?speckleUrl=https://app.speckle.systems/projects/344f803f81/models/5582ab673e&datatype=projectcomments', {
|
||||||
//const speckle_data = await fetch('http://localhost:5000/?speckleUrl=https://app.speckle.systems/projects/64753f52b7/models/338b386787&limit=1000000&lat=-0.031405&lon=109.335828&preserveAttributes=true', {
|
//const speckle_data = await fetch('http://localhost:5000/?speckleUrl=https://app.speckle.systems/projects/64753f52b7/models/338b386787&limit=1000000&lat=-0.031405&lon=109.335828&preserveAttributes=true', {
|
||||||
headers: {
|
headers: {
|
||||||
'Accept': 'application/geo+json'
|
'Accept': 'application/geo+json'
|
||||||
|
|||||||
@@ -30,12 +30,12 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
//const speckle_data = await fetch('https://geo.speckle.systems/?speckleUrl=https://app.speckle.systems/projects/344f803f81/models/5582ab673e&datatype=projectcomments', {
|
//const speckle_data = await fetch('https://geo.speckle.systems/speckle/?speckleUrl=https://app.speckle.systems/projects/344f803f81/models/5582ab673e&datatype=projectcomments', {
|
||||||
//var speckle_url = 'http://localhost:5000/?speckleUrl=https://app.speckle.systems/projects/5feae56049/models/9c43d7569c&limit=1000000&datatype=polygons&preserveattributes=false';
|
//var speckle_url = 'http://localhost:5000/speckle/?speckleUrl=https://app.speckle.systems/projects/5feae56049/models/9c43d7569c&limit=1000000&datatype=polygons&preserveattributes=false';
|
||||||
// https://app.speckle.systems/projects/5feae56049/models/01c4183677
|
// https://app.speckle.systems/projects/5feae56049/models/01c4183677
|
||||||
var speckle_url = 'http://localhost:5000/?speckleUrl=https://app.speckle.systems/projects/5feae56049/models/01c4183677&limit=1000000&datatype=polygons&preserveattributes=true';
|
var speckle_url = 'https://geo.speckle.systems/speckle/?speckleUrl=https://app.speckle.systems/projects/5feae56049/models/01c4183677&limit=1000000&datatype=polygons&preserveattributes=true';
|
||||||
|
|
||||||
//var speckle_url = 'https://geo.speckle.systems/?speckleUrl=https://app.speckle.systems/projects/5feae56049/models/9c43d7569c&northDegrees=-30&preserveAttributes=true';
|
//var speckle_url = 'https://geo.speckle.systems/speckle/?speckleUrl=https://app.speckle.systems/projects/5feae56049/models/9c43d7569c&northDegrees=-30&preserveAttributes=true';
|
||||||
const speckle_data = await fetch(speckle_url, {
|
const speckle_data = await fetch(speckle_url, {
|
||||||
headers: {
|
headers: {
|
||||||
'Accept': 'application/geo+json'
|
'Accept': 'application/geo+json'
|
||||||
|
|||||||
@@ -65,7 +65,7 @@
|
|||||||
|
|
||||||
//////// add Speckle layer
|
//////// add Speckle layer
|
||||||
(async () => {
|
(async () => {
|
||||||
const geojson = await fetch('https://geo.speckle.systems/?speckleUrl=https://app.speckle.systems/projects/344f803f81/models/5582ab673e&datatype=polygons', {
|
const geojson = await fetch('https://geo.speckle.systems/speckle/?speckleUrl=https://app.speckle.systems/projects/344f803f81/models/5582ab673e&datatype=polygons', {
|
||||||
headers: {
|
headers: {
|
||||||
'Accept': 'application/geo+json'
|
'Accept': 'application/geo+json'
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user