Add Heat Map Generation

This commit is contained in:
Sebastian Lenzlinger committed 2024-01-05 13:52:04 +01:00
1 parent 7c58cfc335
commit 40adf8a397
4 files changed
+400 -88

No files matched your search

+8
View File
@@ -0,0 +1,8 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
+13 -1
View File
@@ -48,7 +48,7 @@ class RemoteDB:
except Exception as e:
logger.exception(f"Connection failed: {e}")
def execute_query(self, query):
def execute_query(self, query: str):
session = self.Session()
try:
result = session.execute(sqlalchemy.text(query))
@@ -60,6 +60,18 @@ class RemoteDB:
finally:
session.close()
def execute_command(self, cmd: str):
session = self.Session()
try:
result = session.execute(sqlalchemy.text(cmd))
session.commit()
logger.debug(f"Command {cmd} committed.")
except Exception as e:
session.rollback()
raise
finally:
session.close()
def close(self):
if self.engine:
self.engine.dispose()
+28 -7
View File
@@ -5,6 +5,7 @@ import folium
from folium import plugins
import logging
from db_connector import RemoteDB
import shapely
from shapely import wkb
import json
@@ -60,6 +61,22 @@ color_dict = {
"T100": "gray"
}
def drop_heat_view():
drop_heat_view_sql = """
DROP VIEW IF EXISTS heat;
"""
remote_db = RemoteDB()
try:
result = remote_db.execute_query(drop_heat_view_sql)
logger.info("Heat View dropped.")
except Exception as e:
logger.exception(f"Exception while dropping heat view. Msg: {e} ")
finally:
remote_db.close()
logger.debug(f"RemoteDB object closed.")
def create_heat_view():
create_heat_view_sql = """
@@ -77,13 +94,11 @@ def create_heat_view():
"""
remote_db = RemoteDB()
remote_db.execute_query(create_heat_view_sql)
remote_db.execute_command(create_heat_view_sql)
remote_db.close()
logger.info("Heat View Created")\
def get_heat_view():
#create_heat_view()
get_heat_view_sql = """
SELECT latitude, longitude, year
FROM heat;
@@ -120,16 +135,18 @@ def create_heat_map_with_time():
index=index,
name="Accident Heatmap")
hm.add_to(interactive_map)
interactive_map.save("test.html")
# Add signald speeds data
sig_speeds_data = get_signaled_speed_sql()
sig_speed_df = gpd.GeoDataFrame(sig_speeds_data, columns=['tempo','wkb_geometry'])
sig_speed_df = pd.DataFrame(sig_speeds_data, columns=['tempo','wkb_geometry'])
sig_speed_df['geometry'] = sig_speed_df['wkb_geometry'].apply(lambda x: wkb.loads(x, hex=True))
logger.debug(f"{sig_speed_df.head()}")
sig_speed_gdf = gpd.GeoDataFrame(sig_speed_df, geometry="geometry")
for speedlimit in speedLimits:
signal_speed = sig_speed_df[sig_speed_df["tempo"].str.contains(speedlimit, case=False)]
geometry = signal_speed['geometry']
signal_speed = sig_speed_gdf[sig_speed_gdf["tempo"].str.contains(speedlimit, case=False)]
geometries = json.loads(json.dumps(shapely.geometry.mapping(signal_speed['geometry'].unary_union)))
folium.GeoJson(
data=geometry,
@@ -140,6 +157,8 @@ def create_heat_map_with_time():
).add_to(interactive_map)
folium.LayerControl(collapsed=True).add_to(interactive_map)
interactive_map.save("test.html")
def get_signaled_speed_sql():
sigspeed_sql = """
@@ -165,5 +184,7 @@ def save_map_as_html(map, name):
if __name__ == "__main__":
drop_heat_view()
create_heat_view()
create_heat_map_with_time()
save_map_as_html(interactive_map, "heat_map_with_time")
+351 -80
View File
@@ -2,93 +2,61 @@
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 9,
"id": "initial_id",
"metadata": {
"collapsed": true,
"ExecuteTime": {
"end_time": "2024-01-04T16:29:22.178229818Z",
"start_time": "2024-01-04T16:29:21.982584035Z"
"end_time": "2024-01-05T12:23:18.014124839Z",
"start_time": "2024-01-05T12:23:18.000018319Z"
}
},
"outputs": [],
"source": [
"from db_connector import RemoteDB"
"from db_connector import RemoteDB\n",
"import map "
]
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 10,
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"2024-01-04 17:29:22,165 - paramiko.transport - DEBUG - starting thread (client mode): 0xd85d5690\n",
"2024-01-04 17:29:22,166 - paramiko.transport - DEBUG - Local version/idstring: SSH-2.0-paramiko_3.4.0\n",
"2024-01-04 17:29:22,202 - paramiko.transport - DEBUG - Remote version/idstring: SSH-2.0-OpenSSH_8.9p1 Ubuntu-3ubuntu0.6\n",
"2024-01-04 17:29:22,202 - paramiko.transport - INFO - Connected (version 2.0, client OpenSSH_8.9p1)\n",
"2024-01-04 17:29:22,232 - paramiko.transport - DEBUG - === Key exchange possibilities ===\n",
"2024-01-04 17:29:22,233 - paramiko.transport - DEBUG - kex algos: curve25519-sha256, curve25519-sha256@libssh.org, ecdh-sha2-nistp256, ecdh-sha2-nistp384, ecdh-sha2-nistp521, sntrup761x25519-sha512@openssh.com, diffie-hellman-group-exchange-sha256, diffie-hellman-group16-sha512, diffie-hellman-group18-sha512, diffie-hellman-group14-sha256, kex-strict-s-v00@openssh.com\n",
"2024-01-04 17:29:22,233 - paramiko.transport - DEBUG - server key: rsa-sha2-512, rsa-sha2-256, ecdsa-sha2-nistp256, ssh-ed25519\n",
"2024-01-04 17:29:22,233 - paramiko.transport - DEBUG - client encrypt: chacha20-poly1305@openssh.com, aes128-ctr, aes192-ctr, aes256-ctr, aes128-gcm@openssh.com, aes256-gcm@openssh.com\n",
"2024-01-04 17:29:22,234 - paramiko.transport - DEBUG - server encrypt: chacha20-poly1305@openssh.com, aes128-ctr, aes192-ctr, aes256-ctr, aes128-gcm@openssh.com, aes256-gcm@openssh.com\n",
"2024-01-04 17:29:22,234 - paramiko.transport - DEBUG - client mac: umac-64-etm@openssh.com, umac-128-etm@openssh.com, hmac-sha2-256-etm@openssh.com, hmac-sha2-512-etm@openssh.com, hmac-sha1-etm@openssh.com, umac-64@openssh.com, umac-128@openssh.com, hmac-sha2-256, hmac-sha2-512, hmac-sha1\n",
"2024-01-04 17:29:22,234 - paramiko.transport - DEBUG - server mac: umac-64-etm@openssh.com, umac-128-etm@openssh.com, hmac-sha2-256-etm@openssh.com, hmac-sha2-512-etm@openssh.com, hmac-sha1-etm@openssh.com, umac-64@openssh.com, umac-128@openssh.com, hmac-sha2-256, hmac-sha2-512, hmac-sha1\n",
"2024-01-04 17:29:22,234 - paramiko.transport - DEBUG - client compress: none, zlib@openssh.com\n",
"2024-01-04 17:29:22,234 - paramiko.transport - DEBUG - server compress: none, zlib@openssh.com\n",
"2024-01-04 17:29:22,234 - paramiko.transport - DEBUG - client lang: <none>\n",
"2024-01-04 17:29:22,234 - paramiko.transport - DEBUG - server lang: <none>\n",
"2024-01-04 17:29:22,234 - paramiko.transport - DEBUG - kex follows: False\n",
"2024-01-04 17:29:22,235 - paramiko.transport - DEBUG - === Key exchange agreements ===\n",
"2024-01-04 17:29:22,235 - paramiko.transport - DEBUG - Strict kex mode: True\n",
"2024-01-04 17:29:22,235 - paramiko.transport - DEBUG - Kex: curve25519-sha256@libssh.org\n",
"2024-01-04 17:29:22,235 - paramiko.transport - DEBUG - HostKey: ssh-ed25519\n",
"2024-01-04 17:29:22,235 - paramiko.transport - DEBUG - Cipher: aes128-ctr\n",
"2024-01-04 17:29:22,235 - paramiko.transport - DEBUG - MAC: hmac-sha2-256\n",
"2024-01-04 17:29:22,235 - paramiko.transport - DEBUG - Compression: none\n",
"2024-01-04 17:29:22,236 - paramiko.transport - DEBUG - === End of kex handshake ===\n",
"2024-01-04 17:29:22,270 - paramiko.transport - DEBUG - Resetting outbound seqno after NEWKEYS due to strict mode\n",
"2024-01-04 17:29:22,271 - paramiko.transport - DEBUG - kex engine KexCurve25519 specified hash_algo <built-in function openssl_sha256>\n",
"2024-01-04 17:29:22,271 - paramiko.transport - DEBUG - Switch to new keys ...\n",
"2024-01-04 17:29:22,272 - paramiko.transport - DEBUG - Resetting inbound seqno after NEWKEYS due to strict mode\n",
"2024-01-04 17:29:22,272 - paramiko.transport - DEBUG - Attempting public-key auth...\n",
"2024-01-04 17:29:22,272 - paramiko.transport - DEBUG - Got EXT_INFO: {'server-sig-algs': b'ssh-ed25519,sk-ssh-ed25519@openssh.com,ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,sk-ecdsa-sha2-nistp256@openssh.com,webauthn-sk-ecdsa-sha2-nistp256@openssh.com', 'publickey-hostbound@openssh.com': b'0'}\n",
"2024-01-04 17:29:22,369 - paramiko.transport - DEBUG - userauth is OK\n",
"2024-01-04 17:29:22,409 - paramiko.transport - INFO - Authentication (publickey) failed.\n",
"2024-01-04 17:29:22,436 - paramiko.transport - DEBUG - starting thread (client mode): 0xb32a2d10\n",
"2024-01-04 17:29:22,437 - paramiko.transport - DEBUG - Local version/idstring: SSH-2.0-paramiko_3.4.0\n",
"2024-01-04 17:29:22,473 - paramiko.transport - DEBUG - Remote version/idstring: SSH-2.0-OpenSSH_8.9p1 Ubuntu-3ubuntu0.6\n",
"2024-01-04 17:29:22,474 - paramiko.transport - INFO - Connected (version 2.0, client OpenSSH_8.9p1)\n",
"2024-01-04 17:29:22,499 - paramiko.transport - DEBUG - === Key exchange possibilities ===\n",
"2024-01-04 17:29:22,500 - paramiko.transport - DEBUG - kex algos: curve25519-sha256, curve25519-sha256@libssh.org, ecdh-sha2-nistp256, ecdh-sha2-nistp384, ecdh-sha2-nistp521, sntrup761x25519-sha512@openssh.com, diffie-hellman-group-exchange-sha256, diffie-hellman-group16-sha512, diffie-hellman-group18-sha512, diffie-hellman-group14-sha256, kex-strict-s-v00@openssh.com\n",
"2024-01-04 17:29:22,500 - paramiko.transport - DEBUG - server key: rsa-sha2-512, rsa-sha2-256, ecdsa-sha2-nistp256, ssh-ed25519\n",
"2024-01-04 17:29:22,500 - paramiko.transport - DEBUG - client encrypt: chacha20-poly1305@openssh.com, aes128-ctr, aes192-ctr, aes256-ctr, aes128-gcm@openssh.com, aes256-gcm@openssh.com\n",
"2024-01-04 17:29:22,500 - paramiko.transport - DEBUG - server encrypt: chacha20-poly1305@openssh.com, aes128-ctr, aes192-ctr, aes256-ctr, aes128-gcm@openssh.com, aes256-gcm@openssh.com\n",
"2024-01-04 17:29:22,501 - paramiko.transport - DEBUG - client mac: umac-64-etm@openssh.com, umac-128-etm@openssh.com, hmac-sha2-256-etm@openssh.com, hmac-sha2-512-etm@openssh.com, hmac-sha1-etm@openssh.com, umac-64@openssh.com, umac-128@openssh.com, hmac-sha2-256, hmac-sha2-512, hmac-sha1\n",
"2024-01-04 17:29:22,501 - paramiko.transport - DEBUG - server mac: umac-64-etm@openssh.com, umac-128-etm@openssh.com, hmac-sha2-256-etm@openssh.com, hmac-sha2-512-etm@openssh.com, hmac-sha1-etm@openssh.com, umac-64@openssh.com, umac-128@openssh.com, hmac-sha2-256, hmac-sha2-512, hmac-sha1\n",
"2024-01-04 17:29:22,501 - paramiko.transport - DEBUG - client compress: none, zlib@openssh.com\n",
"2024-01-04 17:29:22,501 - paramiko.transport - DEBUG - server compress: none, zlib@openssh.com\n",
"2024-01-04 17:29:22,501 - paramiko.transport - DEBUG - client lang: <none>\n",
"2024-01-04 17:29:22,501 - paramiko.transport - DEBUG - server lang: <none>\n",
"2024-01-04 17:29:22,502 - paramiko.transport - DEBUG - kex follows: False\n",
"2024-01-04 17:29:22,502 - paramiko.transport - DEBUG - === Key exchange agreements ===\n",
"2024-01-04 17:29:22,502 - paramiko.transport - DEBUG - Strict kex mode: True\n",
"2024-01-04 17:29:22,502 - paramiko.transport - DEBUG - Kex: curve25519-sha256@libssh.org\n",
"2024-01-04 17:29:22,502 - paramiko.transport - DEBUG - HostKey: ssh-ed25519\n",
"2024-01-04 17:29:22,502 - paramiko.transport - DEBUG - Cipher: aes128-ctr\n",
"2024-01-04 17:29:22,502 - paramiko.transport - DEBUG - MAC: hmac-sha2-256\n",
"2024-01-04 17:29:22,502 - paramiko.transport - DEBUG - Compression: none\n",
"2024-01-04 17:29:22,503 - paramiko.transport - DEBUG - === End of kex handshake ===\n",
"2024-01-04 17:29:22,510 - paramiko.transport - DEBUG - EOF in transport thread\n",
"2024-01-04 17:29:22,585 - paramiko.transport - DEBUG - Resetting outbound seqno after NEWKEYS due to strict mode\n",
"2024-01-04 17:29:22,585 - paramiko.transport - DEBUG - kex engine KexCurve25519 specified hash_algo <built-in function openssl_sha256>\n",
"2024-01-04 17:29:22,586 - paramiko.transport - DEBUG - Switch to new keys ...\n",
"2024-01-04 17:29:22,586 - paramiko.transport - DEBUG - Resetting inbound seqno after NEWKEYS due to strict mode\n",
"2024-01-04 17:29:22,586 - paramiko.transport - DEBUG - Got EXT_INFO: {'server-sig-algs': b'ssh-ed25519,sk-ssh-ed25519@openssh.com,ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,sk-ecdsa-sha2-nistp256@openssh.com,webauthn-sk-ecdsa-sha2-nistp256@openssh.com', 'publickey-hostbound@openssh.com': b'0'}\n",
"2024-01-04 17:29:22,587 - paramiko.transport - DEBUG - Attempting public-key auth...\n",
"2024-01-04 17:29:22,677 - paramiko.transport - DEBUG - userauth is OK\n",
"2024-01-04 17:29:22,740 - paramiko.transport - INFO - Authentication (publickey) successful!\n"
"2024-01-05 13:23:18,086 - paramiko.transport - DEBUG - starting thread (client mode): 0xc3096d10\n",
"2024-01-05 13:23:18,087 - paramiko.transport - DEBUG - Local version/idstring: SSH-2.0-paramiko_3.4.0\n",
"2024-01-05 13:23:18,122 - paramiko.transport - DEBUG - Remote version/idstring: SSH-2.0-OpenSSH_8.9p1 Ubuntu-3ubuntu0.6\n",
"2024-01-05 13:23:18,123 - paramiko.transport - INFO - Connected (version 2.0, client OpenSSH_8.9p1)\n",
"2024-01-05 13:23:18,152 - paramiko.transport - DEBUG - === Key exchange possibilities ===\n",
"2024-01-05 13:23:18,153 - paramiko.transport - DEBUG - kex algos: curve25519-sha256, curve25519-sha256@libssh.org, ecdh-sha2-nistp256, ecdh-sha2-nistp384, ecdh-sha2-nistp521, sntrup761x25519-sha512@openssh.com, diffie-hellman-group-exchange-sha256, diffie-hellman-group16-sha512, diffie-hellman-group18-sha512, diffie-hellman-group14-sha256, kex-strict-s-v00@openssh.com\n",
"2024-01-05 13:23:18,154 - paramiko.transport - DEBUG - server key: rsa-sha2-512, rsa-sha2-256, ecdsa-sha2-nistp256, ssh-ed25519\n",
"2024-01-05 13:23:18,154 - paramiko.transport - DEBUG - client encrypt: chacha20-poly1305@openssh.com, aes128-ctr, aes192-ctr, aes256-ctr, aes128-gcm@openssh.com, aes256-gcm@openssh.com\n",
"2024-01-05 13:23:18,154 - paramiko.transport - DEBUG - server encrypt: chacha20-poly1305@openssh.com, aes128-ctr, aes192-ctr, aes256-ctr, aes128-gcm@openssh.com, aes256-gcm@openssh.com\n",
"2024-01-05 13:23:18,154 - paramiko.transport - DEBUG - client mac: umac-64-etm@openssh.com, umac-128-etm@openssh.com, hmac-sha2-256-etm@openssh.com, hmac-sha2-512-etm@openssh.com, hmac-sha1-etm@openssh.com, umac-64@openssh.com, umac-128@openssh.com, hmac-sha2-256, hmac-sha2-512, hmac-sha1\n",
"2024-01-05 13:23:18,155 - paramiko.transport - DEBUG - server mac: umac-64-etm@openssh.com, umac-128-etm@openssh.com, hmac-sha2-256-etm@openssh.com, hmac-sha2-512-etm@openssh.com, hmac-sha1-etm@openssh.com, umac-64@openssh.com, umac-128@openssh.com, hmac-sha2-256, hmac-sha2-512, hmac-sha1\n",
"2024-01-05 13:23:18,155 - paramiko.transport - DEBUG - client compress: none, zlib@openssh.com\n",
"2024-01-05 13:23:18,155 - paramiko.transport - DEBUG - server compress: none, zlib@openssh.com\n",
"2024-01-05 13:23:18,155 - paramiko.transport - DEBUG - client lang: <none>\n",
"2024-01-05 13:23:18,156 - paramiko.transport - DEBUG - server lang: <none>\n",
"2024-01-05 13:23:18,156 - paramiko.transport - DEBUG - kex follows: False\n",
"2024-01-05 13:23:18,156 - paramiko.transport - DEBUG - === Key exchange agreements ===\n",
"2024-01-05 13:23:18,156 - paramiko.transport - DEBUG - Strict kex mode: True\n",
"2024-01-05 13:23:18,156 - paramiko.transport - DEBUG - Kex: curve25519-sha256@libssh.org\n",
"2024-01-05 13:23:18,157 - paramiko.transport - DEBUG - HostKey: ssh-ed25519\n",
"2024-01-05 13:23:18,157 - paramiko.transport - DEBUG - Cipher: aes128-ctr\n",
"2024-01-05 13:23:18,157 - paramiko.transport - DEBUG - MAC: hmac-sha2-256\n",
"2024-01-05 13:23:18,157 - paramiko.transport - DEBUG - Compression: none\n",
"2024-01-05 13:23:18,157 - paramiko.transport - DEBUG - === End of kex handshake ===\n",
"2024-01-05 13:23:18,192 - paramiko.transport - DEBUG - Resetting outbound seqno after NEWKEYS due to strict mode\n",
"2024-01-05 13:23:18,192 - paramiko.transport - DEBUG - kex engine KexCurve25519 specified hash_algo <built-in function openssl_sha256>\n",
"2024-01-05 13:23:18,193 - paramiko.transport - DEBUG - Switch to new keys ...\n",
"2024-01-05 13:23:18,194 - paramiko.transport - DEBUG - Resetting inbound seqno after NEWKEYS due to strict mode\n",
"2024-01-05 13:23:18,194 - paramiko.transport - DEBUG - Attempting public-key auth...\n",
"2024-01-05 13:23:18,194 - paramiko.transport - DEBUG - Got EXT_INFO: {'server-sig-algs': b'ssh-ed25519,sk-ssh-ed25519@openssh.com,ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,sk-ecdsa-sha2-nistp256@openssh.com,webauthn-sk-ecdsa-sha2-nistp256@openssh.com', 'publickey-hostbound@openssh.com': b'0'}\n",
"2024-01-05 13:23:18,289 - paramiko.transport - DEBUG - userauth is OK\n",
"2024-01-05 13:23:18,342 - paramiko.transport - INFO - Authentication (publickey) successful!\n"
]
}
],
@@ -98,21 +66,38 @@
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-01-04T16:29:22.769191585Z",
"start_time": "2024-01-04T16:29:22.177669866Z"
"end_time": "2024-01-05T12:23:18.357341378Z",
"start_time": "2024-01-05T12:23:18.002685280Z"
}
},
"id": "62c8f38132d5cd27"
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 11,
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"2024-01-05 13:23:18,348 - paramiko.transport - DEBUG - [chan 0] Max packet in: 32768 bytes\n",
"2024-01-05 13:23:18,634 - paramiko.transport - DEBUG - Received global request \"hostkeys-00@openssh.com\"\n",
"2024-01-05 13:23:18,635 - paramiko.transport - DEBUG - Rejecting \"hostkeys-00@openssh.com\" global request from server.\n",
"2024-01-05 13:23:18,635 - paramiko.transport - DEBUG - Debug msg: b'/home/sebl/.ssh/authorized_keys:4: key options: agent-forwarding port-forwarding pty user-rc x11-forwarding'\n",
"2024-01-05 13:23:18,697 - paramiko.transport - DEBUG - [chan 0] Max packet out: 32768 bytes\n",
"2024-01-05 13:23:18,698 - paramiko.transport - DEBUG - Secsh channel 0 opened.\n",
"2024-01-05 13:23:19,550 - paramiko.transport - DEBUG - [chan 0] EOF sent (0)\n",
"2024-01-05 13:23:19,551 - paramiko.transport - DEBUG - [chan 1] Max packet in: 32768 bytes\n",
"2024-01-05 13:23:19,587 - paramiko.transport - DEBUG - [chan 0] EOF received (0)\n",
"2024-01-05 13:23:19,615 - paramiko.transport - DEBUG - [chan 1] Max packet out: 32768 bytes\n",
"2024-01-05 13:23:19,616 - paramiko.transport - DEBUG - Secsh channel 1 opened.\n"
]
},
{
"data": {
"text/plain": "[('T20', '0105000020E61000000100000001020000000700000048F8DEDFA00D21405260014C19AC474079B0C56E9F0D2140DBFB54151AAC4740E08618AF790D21406AC2F69331AC474074452921580D2140A20DC00644AC4740F14927124C0D214052D4997B48AC4740FC89CA86350D21405BB22AC24DAC47405B99F04BFD0C21402C7FBE2D58AC4740'),\n ('T0', '0105000020E6100000010000000102000000030000001E34BBEEAD10214092EBA694D7B44740813FFCFCF7102140D2A6EA1ED9B447400F98874CF9102140F1F3DF83D7B44740'),\n ('T30', '0105000020E6100000010000000102000000030000007C293C68760D2140B806B64AB0B0474079CDAB3AAB0D21408E90813CBBB04740ACAC6D8AC70D214001892650C4B04740'),\n ('T50', '0105000020E610000001000000010200000002000000D40AD3F71A1221408690F3FE3FAE4740FBB2B453731121407B1684F23EAE4740'),\n ('T50', '0105000020E61000000100000001020000000500000031B610E4A0242140B16CE690D4B0474094C151F2EA24214072FC5069C4B047409CFC169D2C252140C7A17E17B6B047408A0453CDAC2521405890662C9AB047409B3BFA5FAE252140643E20D099B04740'),\n ('T0', '0105000020E610000001000000010200000002000000A2B5A2CD71162140D9EBDD1FEFAF47403B8DB454DE162140B3791C06F3AF4740'),\n ('T20', '0105000020E6100000010000000102000000020000004B1E4FCB0F0421401C2444F982AE474024287E8CB9032140DC7F643A74AE4740'),\n ('T50', '0105000020E6100000010000000102000000020000005F45460724192140EDD79DEE3CAF4740BCB0355B79192140E146CA1649AF4740'),\n ('T30', '0105000020E6100000010000000102000000020000006DE525FF930F2140691D554D10B14740F6984869360F21408753E6E61BB14740'),\n ('T0', '0105000020E610000001000000010200000003000000C6A52A6D71152140A2CF471971AF474047E9D2BF24152140D978B0C56EAF47400B9A965819152140C70DBF9B6EAF4740'),\n ('T30', '0105000020E61000000100000001020000000300000063D520CCED1E2140E1CFF0660DB44740CFBF5DF6EB1E2140878A71FE26B44740A1D79FC4E71E2140CD3CB9A640B44740'),\n ('T50', '0105000020E610000001000000010200000002000000B4ACFBC74214214044A7E7DD58B447402158552FBF132140A9BD88B663B44740'),\n ('T50', '0105000020E610000001000000010200000003000000E04BE141B30B2140815F234910B24740703FE081010C2140ACC8E88024B2474026547078410C2140207A522635B24740'),\n ('T30', '0105000020E6100000010000000102000000020000008E5BCCCF0D1D2140494DBB9866B047403D0AD7A3701D2140FFD0CC936BB04740'),\n ('T30', '0105000020E6100000010000000102000000030000006C770FD07D192140F04DD36707AE47403602F1BA7E192140F04DD36707AE4740DD7A4D0F0A1A2140520FD1E80EAE4740'),\n ('T30', '0105000020E61000000100000001020000000200000095826E2F690C21401442075DC2AF4740E8C072840C0C2140A04FE449D2AF4740'),\n ('T0', '0105000020E610000001000000010200000002000000F969DC9BDF00214003931B45D6B24740D482177D050121403468E89FE0B24740'),\n ('T50', '0105000020E61000000100000001020000000300000055BDFC4E93192140E144F46BEBB34740E998F38C7D1921404CC79C67ECB347409015FC36C4182140C4B0C398F4B34740'),\n ('T30', '0105000020E61000000100000001020000000200000052802898310D2140450F7C0C56B04740D11F9A79720D214017618A7269B04740'),\n ('T0', '0105000020E61000000100000001020000000300000000E2AE5E450E2140E5D2F88557B247404A7B832F4C0E2140FCC6D79E59B24740063065E0800E2140CAC342AD69B24740'),\n ('T20', '0105000020E610000001000000010200000002000000FAB48AFED0242140003B376DC6B34740ED9FA701832421409B92ACC3D1B34740'),\n ('T0', '0105000020E6100000010000000102000000020000003B8DB454DE062140B741EDB776B04740892650C422062140122F4FE78AB04740'),\n ('T30', '0105000020E610000001000000010200000004000000904AB1A3710821409F2287889BAF4740580053060E082140F8A75489B2AF474037AAD381AC072140103E9468C9AF47402BF697DD930721404CDE0033DFAF4740'),\n ('T30', '0105000020E610000001000000010200000002000000B4AA251DE5102140185E49F25CAF474085ED27637C102140C36169E047AF4740'),\n ('T0', '0105000020E6100000010000000102000000020000004ED53DB2B9122140EF8CB62A89B24740F209D9791B1321402C616D8C9DB24740'),\n ('T0', '0105000020E610000001000000010200000002000000F24064912616214049BDA772DAB1474023D74D29AF1521401686C8E9EBB14740'),\n ('T0', '0105000020E610000001000000010200000003000000C34A051555F720408F1B7E37DDB047400805A568E5F6204020CF2EDFFAB047405A0EF450DBF62040A8363811FDB04740'),\n ('T0', '0105000020E6100000010000000102000000030000007FDAA84E071A21406281AFE8D6B547408884EFFD0D1A214060E5D022DBB54740520FD1E80E1A214077D9AF3BDDB54740'),\n ('T0', '0105000020E610000001000000010200000002000000F35A09DD251121405BCEA5B8AAB44740EAB0C22D1F112140DA740470B3B44740'),\n ('T50', '0105000020E6100000010000000102000000030000006B11514CDE10214009F9A067B3AE47405C8DEC4ACB102140CEFA9463B2AE4740C68503215910214019ABCDFFABAE4740'),\n ('T0', '0105000020E610000001000000010200000003000000DD7BB8E4B80B214089247A19C5B24740A12C7C7DAD0B2140CE001764CBB247404C1938A0A50B2140C573B680D0B24740'),\n ('T0', '0105000020E61000000100000001020000000400000005DCF3FC691321403BE12538F5AF47409F2287889B132140C3B645990DB04740605AD427B9132140B7F1272A1BB047409E7939ECBE1321401492CCEA1DB04740'),\n ('T50', '0105000020E61000000100000001020000000300000071CB4752D2132140A67C08AA46B14740450F7C0C56142140C37E4FAC53B147403ACFD8976C1421404BE658DE55B14740'),\n ('T30', '0105000020E6100000010000000102000000020000009BA9108FC41B2140D9D0CDFE40AF4740B6476FB88F1C2140245E9ECE15AF4740'),\n ('T0', 'Line truncated
},
"execution_count": 4,
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
@@ -130,21 +115,21 @@
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-01-04T16:29:44.362107002Z",
"start_time": "2024-01-04T16:29:43.573101962Z"
"end_time": "2024-01-05T12:23:20.524885942Z",
"start_time": "2024-01-05T12:23:18.348591925Z"
}
},
"id": "29b60614b47dbc87"
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 12,
"outputs": [
{
"data": {
"text/plain": "('T20', '0105000020E61000000100000001020000000700000048F8DEDFA00D21405260014C19AC474079B0C56E9F0D2140DBFB54151AAC4740E08618AF790D21406AC2F69331AC474074452921580D2140A20DC00644AC4740F14927124C0D214052D4997B48AC4740FC89CA86350D21405BB22AC24DAC47405B99F04BFD0C21402C7FBE2D58AC4740')"
},
"execution_count": 5,
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
@@ -155,11 +140,297 @@
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-01-04T16:30:07.107723230Z",
"start_time": "2024-01-04T16:30:07.104921329Z"
"end_time": "2024-01-05T12:23:20.525754482Z",
"start_time": "2024-01-05T12:23:20.520394152Z"
}
},
"id": "cddcbd64b8c52d93"
},
{
"cell_type": "code",
"execution_count": 13,
"outputs": [],
"source": [
"def get_signaled_speed_sql():\n",
" sigspeed_sql = \"\"\"\n",
" SELECT \n",
" temporegime_technical as tempo, \n",
" wkb_geometry\n",
" FROM signaled_speeds;\n",
" \"\"\"\n",
" remote_db = RemoteDB()\n",
" try:\n",
" result = remote_db.execute_query(sigspeed_sql)\n",
" #logger.info(f\"Succesfully retrieved result\")\n",
" return result\n",
" except Exception as e:\n",
" print(f\"Exception occred{e}\")\n",
" #logger.exception(f\"Failed getting result with exception {e}\")\n",
" finally:\n",
" remote_db.close()"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-01-05T12:23:20.596801366Z",
"start_time": "2024-01-05T12:23:20.523639796Z"
}
},
"id": "27a7b3f6851e64c4"
},
{
"cell_type": "code",
"execution_count": 14,
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"2024-01-05 13:23:20,599 - paramiko.transport - DEBUG - starting thread (client mode): 0xaa5d7e10\n",
"2024-01-05 13:23:20,599 - paramiko.transport - DEBUG - Local version/idstring: SSH-2.0-paramiko_3.4.0\n",
"2024-01-05 13:23:20,630 - paramiko.transport - DEBUG - Remote version/idstring: SSH-2.0-OpenSSH_8.9p1 Ubuntu-3ubuntu0.6\n",
"2024-01-05 13:23:20,630 - paramiko.transport - INFO - Connected (version 2.0, client OpenSSH_8.9p1)\n",
"2024-01-05 13:23:20,658 - paramiko.transport - DEBUG - === Key exchange possibilities ===\n",
"2024-01-05 13:23:20,658 - paramiko.transport - DEBUG - kex algos: curve25519-sha256, curve25519-sha256@libssh.org, ecdh-sha2-nistp256, ecdh-sha2-nistp384, ecdh-sha2-nistp521, sntrup761x25519-sha512@openssh.com, diffie-hellman-group-exchange-sha256, diffie-hellman-group16-sha512, diffie-hellman-group18-sha512, diffie-hellman-group14-sha256, kex-strict-s-v00@openssh.com\n",
"2024-01-05 13:23:20,659 - paramiko.transport - DEBUG - server key: rsa-sha2-512, rsa-sha2-256, ecdsa-sha2-nistp256, ssh-ed25519\n",
"2024-01-05 13:23:20,659 - paramiko.transport - DEBUG - client encrypt: chacha20-poly1305@openssh.com, aes128-ctr, aes192-ctr, aes256-ctr, aes128-gcm@openssh.com, aes256-gcm@openssh.com\n",
"2024-01-05 13:23:20,659 - paramiko.transport - DEBUG - server encrypt: chacha20-poly1305@openssh.com, aes128-ctr, aes192-ctr, aes256-ctr, aes128-gcm@openssh.com, aes256-gcm@openssh.com\n",
"2024-01-05 13:23:20,659 - paramiko.transport - DEBUG - client mac: umac-64-etm@openssh.com, umac-128-etm@openssh.com, hmac-sha2-256-etm@openssh.com, hmac-sha2-512-etm@openssh.com, hmac-sha1-etm@openssh.com, umac-64@openssh.com, umac-128@openssh.com, hmac-sha2-256, hmac-sha2-512, hmac-sha1\n",
"2024-01-05 13:23:20,659 - paramiko.transport - DEBUG - server mac: umac-64-etm@openssh.com, umac-128-etm@openssh.com, hmac-sha2-256-etm@openssh.com, hmac-sha2-512-etm@openssh.com, hmac-sha1-etm@openssh.com, umac-64@openssh.com, umac-128@openssh.com, hmac-sha2-256, hmac-sha2-512, hmac-sha1\n",
"2024-01-05 13:23:20,659 - paramiko.transport - DEBUG - client compress: none, zlib@openssh.com\n",
"2024-01-05 13:23:20,660 - paramiko.transport - DEBUG - server compress: none, zlib@openssh.com\n",
"2024-01-05 13:23:20,660 - paramiko.transport - DEBUG - client lang: <none>\n",
"2024-01-05 13:23:20,660 - paramiko.transport - DEBUG - server lang: <none>\n",
"2024-01-05 13:23:20,660 - paramiko.transport - DEBUG - kex follows: False\n",
"2024-01-05 13:23:20,660 - paramiko.transport - DEBUG - === Key exchange agreements ===\n",
"2024-01-05 13:23:20,660 - paramiko.transport - DEBUG - Strict kex mode: True\n",
"2024-01-05 13:23:20,660 - paramiko.transport - DEBUG - Kex: curve25519-sha256@libssh.org\n",
"2024-01-05 13:23:20,660 - paramiko.transport - DEBUG - HostKey: ssh-ed25519\n",
"2024-01-05 13:23:20,661 - paramiko.transport - DEBUG - Cipher: aes128-ctr\n",
"2024-01-05 13:23:20,661 - paramiko.transport - DEBUG - MAC: hmac-sha2-256\n",
"2024-01-05 13:23:20,661 - paramiko.transport - DEBUG - Compression: none\n",
"2024-01-05 13:23:20,661 - paramiko.transport - DEBUG - === End of kex handshake ===\n",
"2024-01-05 13:23:20,699 - paramiko.transport - DEBUG - Resetting outbound seqno after NEWKEYS due to strict mode\n",
"2024-01-05 13:23:20,700 - paramiko.transport - DEBUG - kex engine KexCurve25519 specified hash_algo <built-in function openssl_sha256>\n",
"2024-01-05 13:23:20,701 - paramiko.transport - DEBUG - Switch to new keys ...\n",
"2024-01-05 13:23:20,701 - paramiko.transport - DEBUG - Resetting inbound seqno after NEWKEYS due to strict mode\n",
"2024-01-05 13:23:20,701 - paramiko.transport - DEBUG - Got EXT_INFO: {'server-sig-algs': b'ssh-ed25519,sk-ssh-ed25519@openssh.com,ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,sk-ecdsa-sha2-nistp256@openssh.com,webauthn-sk-ecdsa-sha2-nistp256@openssh.com', 'publickey-hostbound@openssh.com': b'0'}\n",
"2024-01-05 13:23:20,701 - paramiko.transport - DEBUG - Attempting public-key auth...\n",
"2024-01-05 13:23:20,798 - paramiko.transport - DEBUG - userauth is OK\n",
"2024-01-05 13:23:20,849 - paramiko.transport - INFO - Authentication (publickey) successful!\n",
"2024-01-05 13:23:20,851 - paramiko.transport - DEBUG - [chan 0] Max packet in: 32768 bytes\n",
"2024-01-05 13:23:20,939 - paramiko.transport - DEBUG - Received global request \"hostkeys-00@openssh.com\"\n",
"2024-01-05 13:23:20,939 - paramiko.transport - DEBUG - Rejecting \"hostkeys-00@openssh.com\" global request from server.\n",
"2024-01-05 13:23:20,940 - paramiko.transport - DEBUG - Debug msg: b'/home/sebl/.ssh/authorized_keys:4: key options: agent-forwarding port-forwarding pty user-rc x11-forwarding'\n",
"2024-01-05 13:23:21,004 - paramiko.transport - DEBUG - [chan 0] Max packet out: 32768 bytes\n",
"2024-01-05 13:23:21,004 - paramiko.transport - DEBUG - Secsh channel 0 opened.\n",
"2024-01-05 13:23:21,737 - paramiko.transport - DEBUG - [chan 0] EOF sent (0)\n",
"2024-01-05 13:23:21,738 - paramiko.transport - DEBUG - [chan 1] Max packet in: 32768 bytes\n",
"2024-01-05 13:23:21,774 - paramiko.transport - DEBUG - [chan 0] EOF received (0)\n",
"2024-01-05 13:23:21,797 - paramiko.transport - DEBUG - [chan 1] Max packet out: 32768 bytes\n",
"2024-01-05 13:23:21,797 - paramiko.transport - DEBUG - Secsh channel 1 opened.\n",
"2024-01-05 13:23:22,642 - paramiko.transport - DEBUG - [chan 1] EOF sent (1)\n",
"2024-01-05 13:23:22,642 - paramiko.transport - DEBUG - Dropping user packet because connection is dead.\n",
"2024-01-05 13:23:22,643 - paramiko.transport - DEBUG - Dropping user packet because connection is dead.\n"
]
}
],
"source": [
"res = get_signaled_speed_sql()"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-01-05T12:23:22.646286681Z",
"start_time": "2024-01-05T12:23:20.554383997Z"
}
},
"id": "35187c733fff25ca"
},
{
"cell_type": "code",
"execution_count": 14,
"outputs": [],
"source": [],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-01-05T12:23:22.661701192Z",
"start_time": "2024-01-05T12:23:22.646931596Z"
}
},
"id": "a7ad24ab0b54a527"
},
{
"cell_type": "code",
"execution_count": 15,
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"2024-01-05 13:23:22,652 - paramiko.transport - DEBUG - Sending global request \"keepalive@lag.net\"\n"
]
},
{
"data": {
"text/plain": "[('T20', '0105000020E61000000100000001020000000700000048F8DEDFA00D21405260014C19AC474079B0C56E9F0D2140DBFB54151AAC4740E08618AF790D21406AC2F69331AC474074452921580D2140A20DC00644AC4740F14927124C0D214052D4997B48AC4740FC89CA86350D21405BB22AC24DAC47405B99F04BFD0C21402C7FBE2D58AC4740'),\n ('T0', '0105000020E6100000010000000102000000030000001E34BBEEAD10214092EBA694D7B44740813FFCFCF7102140D2A6EA1ED9B447400F98874CF9102140F1F3DF83D7B44740'),\n ('T30', '0105000020E6100000010000000102000000030000007C293C68760D2140B806B64AB0B0474079CDAB3AAB0D21408E90813CBBB04740ACAC6D8AC70D214001892650C4B04740'),\n ('T50', '0105000020E610000001000000010200000002000000D40AD3F71A1221408690F3FE3FAE4740FBB2B453731121407B1684F23EAE4740'),\n ('T50', '0105000020E61000000100000001020000000500000031B610E4A0242140B16CE690D4B0474094C151F2EA24214072FC5069C4B047409CFC169D2C252140C7A17E17B6B047408A0453CDAC2521405890662C9AB047409B3BFA5FAE252140643E20D099B04740'),\n ('T0', '0105000020E610000001000000010200000002000000A2B5A2CD71162140D9EBDD1FEFAF47403B8DB454DE162140B3791C06F3AF4740'),\n ('T20', '0105000020E6100000010000000102000000020000004B1E4FCB0F0421401C2444F982AE474024287E8CB9032140DC7F643A74AE4740'),\n ('T50', '0105000020E6100000010000000102000000020000005F45460724192140EDD79DEE3CAF4740BCB0355B79192140E146CA1649AF4740'),\n ('T30', '0105000020E6100000010000000102000000020000006DE525FF930F2140691D554D10B14740F6984869360F21408753E6E61BB14740'),\n ('T0', '0105000020E610000001000000010200000003000000C6A52A6D71152140A2CF471971AF474047E9D2BF24152140D978B0C56EAF47400B9A965819152140C70DBF9B6EAF4740'),\n ('T30', '0105000020E61000000100000001020000000300000063D520CCED1E2140E1CFF0660DB44740CFBF5DF6EB1E2140878A71FE26B44740A1D79FC4E71E2140CD3CB9A640B44740'),\n ('T50', '0105000020E610000001000000010200000002000000B4ACFBC74214214044A7E7DD58B447402158552FBF132140A9BD88B663B44740'),\n ('T50', '0105000020E610000001000000010200000003000000E04BE141B30B2140815F234910B24740703FE081010C2140ACC8E88024B2474026547078410C2140207A522635B24740'),\n ('T30', '0105000020E6100000010000000102000000020000008E5BCCCF0D1D2140494DBB9866B047403D0AD7A3701D2140FFD0CC936BB04740'),\n ('T30', '0105000020E6100000010000000102000000030000006C770FD07D192140F04DD36707AE47403602F1BA7E192140F04DD36707AE4740DD7A4D0F0A1A2140520FD1E80EAE4740'),\n ('T30', '0105000020E61000000100000001020000000200000095826E2F690C21401442075DC2AF4740E8C072840C0C2140A04FE449D2AF4740'),\n ('T0', '0105000020E610000001000000010200000002000000F969DC9BDF00214003931B45D6B24740D482177D050121403468E89FE0B24740'),\n ('T50', '0105000020E61000000100000001020000000300000055BDFC4E93192140E144F46BEBB34740E998F38C7D1921404CC79C67ECB347409015FC36C4182140C4B0C398F4B34740'),\n ('T30', '0105000020E61000000100000001020000000200000052802898310D2140450F7C0C56B04740D11F9A79720D214017618A7269B04740'),\n ('T0', '0105000020E61000000100000001020000000300000000E2AE5E450E2140E5D2F88557B247404A7B832F4C0E2140FCC6D79E59B24740063065E0800E2140CAC342AD69B24740'),\n ('T20', '0105000020E610000001000000010200000002000000FAB48AFED0242140003B376DC6B34740ED9FA701832421409B92ACC3D1B34740'),\n ('T0', '0105000020E6100000010000000102000000020000003B8DB454DE062140B741EDB776B04740892650C422062140122F4FE78AB04740'),\n ('T30', '0105000020E610000001000000010200000004000000904AB1A3710821409F2287889BAF4740580053060E082140F8A75489B2AF474037AAD381AC072140103E9468C9AF47402BF697DD930721404CDE0033DFAF4740'),\n ('T30', '0105000020E610000001000000010200000002000000B4AA251DE5102140185E49F25CAF474085ED27637C102140C36169E047AF4740'),\n ('T0', '0105000020E6100000010000000102000000020000004ED53DB2B9122140EF8CB62A89B24740F209D9791B1321402C616D8C9DB24740'),\n ('T0', '0105000020E610000001000000010200000002000000F24064912616214049BDA772DAB1474023D74D29AF1521401686C8E9EBB14740'),\n ('T0', '0105000020E610000001000000010200000003000000C34A051555F720408F1B7E37DDB047400805A568E5F6204020CF2EDFFAB047405A0EF450DBF62040A8363811FDB04740'),\n ('T0', '0105000020E6100000010000000102000000030000007FDAA84E071A21406281AFE8D6B547408884EFFD0D1A214060E5D022DBB54740520FD1E80E1A214077D9AF3BDDB54740'),\n ('T0', '0105000020E610000001000000010200000002000000F35A09DD251121405BCEA5B8AAB44740EAB0C22D1F112140DA740470B3B44740'),\n ('T50', '0105000020E6100000010000000102000000030000006B11514CDE10214009F9A067B3AE47405C8DEC4ACB102140CEFA9463B2AE4740C68503215910214019ABCDFFABAE4740'),\n ('T0', '0105000020E610000001000000010200000003000000DD7BB8E4B80B214089247A19C5B24740A12C7C7DAD0B2140CE001764CBB247404C1938A0A50B2140C573B680D0B24740'),\n ('T0', '0105000020E61000000100000001020000000400000005DCF3FC691321403BE12538F5AF47409F2287889B132140C3B645990DB04740605AD427B9132140B7F1272A1BB047409E7939ECBE1321401492CCEA1DB04740'),\n ('T50', '0105000020E61000000100000001020000000300000071CB4752D2132140A67C08AA46B14740450F7C0C56142140C37E4FAC53B147403ACFD8976C1421404BE658DE55B14740'),\n ('T30', '0105000020E6100000010000000102000000020000009BA9108FC41B2140D9D0CDFE40AF4740B6476FB88F1C2140245E9ECE15AF4740'),\n ('T0', 'Line truncated
},
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"res"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-01-05T12:23:22.666988635Z",
"start_time": "2024-01-05T12:23:22.653362014Z"
}
},
"id": "1d746210c4056933"
},
{
"cell_type": "code",
"execution_count": 20,
"outputs": [],
"source": [
"from shapely import wkb\n",
"import shapely\n",
"import folium\n",
"import json\n",
"\n",
"# Your Folium map\n",
"map = folium.Map(location=[47.368650, 8.539183], zoom_start=13, tiles=\"cartodb positron\")\n",
"\n",
"# Example WKB geometry\n",
"wkb_geometry = '0105000020E6100000010000000102000000030000001C261AA4E0112140605793A7ACB047400EA2B5A2CD11214058E1968FA4B047406F47382D78112140983446EBA8B04740'\n",
"\n",
"# Convert WKB to Shapely Geometry\n",
"shapely_geometry = wkb.loads(wkb_geometry, hex=True)\n",
"\n",
"# Convert Shapely Geometry to GeoJSON\n",
"geojson_geometry = json.loads(json.dumps(shapely.geometry.mapping(shapely_geometry)))\n",
"\n",
"# Add to Folium Map\n",
"folium.GeoJson(geojson_geometry).add_to(map)\n",
"\n",
"# Save or show map\n",
"map.save(\"map.html\") # or use map.show() in a Jupyter environment\n"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-01-05T12:27:13.987931682Z",
"start_time": "2024-01-05T12:27:13.985968916Z"
}
},
"id": "2951c82f59b6d90c"
},
{
"cell_type": "code",
"execution_count": 28,
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"2024-01-05 13:43:28,309 - paramiko.transport - DEBUG - starting thread (client mode): 0x8b0a0e10\n",
"2024-01-05 13:43:28,310 - paramiko.transport - DEBUG - Local version/idstring: SSH-2.0-paramiko_3.4.0\n",
"2024-01-05 13:43:28,343 - paramiko.transport - DEBUG - Remote version/idstring: SSH-2.0-OpenSSH_8.9p1 Ubuntu-3ubuntu0.6\n",
"2024-01-05 13:43:28,344 - paramiko.transport - INFO - Connected (version 2.0, client OpenSSH_8.9p1)\n",
"2024-01-05 13:43:28,368 - paramiko.transport - DEBUG - === Key exchange possibilities ===\n",
"2024-01-05 13:43:28,368 - paramiko.transport - DEBUG - kex algos: curve25519-sha256, curve25519-sha256@libssh.org, ecdh-sha2-nistp256, ecdh-sha2-nistp384, ecdh-sha2-nistp521, sntrup761x25519-sha512@openssh.com, diffie-hellman-group-exchange-sha256, diffie-hellman-group16-sha512, diffie-hellman-group18-sha512, diffie-hellman-group14-sha256, kex-strict-s-v00@openssh.com\n",
"2024-01-05 13:43:28,369 - paramiko.transport - DEBUG - server key: rsa-sha2-512, rsa-sha2-256, ecdsa-sha2-nistp256, ssh-ed25519\n",
"2024-01-05 13:43:28,370 - paramiko.transport - DEBUG - client encrypt: chacha20-poly1305@openssh.com, aes128-ctr, aes192-ctr, aes256-ctr, aes128-gcm@openssh.com, aes256-gcm@openssh.com\n",
"2024-01-05 13:43:28,370 - paramiko.transport - DEBUG - server encrypt: chacha20-poly1305@openssh.com, aes128-ctr, aes192-ctr, aes256-ctr, aes128-gcm@openssh.com, aes256-gcm@openssh.com\n",
"2024-01-05 13:43:28,370 - paramiko.transport - DEBUG - client mac: umac-64-etm@openssh.com, umac-128-etm@openssh.com, hmac-sha2-256-etm@openssh.com, hmac-sha2-512-etm@openssh.com, hmac-sha1-etm@openssh.com, umac-64@openssh.com, umac-128@openssh.com, hmac-sha2-256, hmac-sha2-512, hmac-sha1\n",
"2024-01-05 13:43:28,371 - paramiko.transport - DEBUG - server mac: umac-64-etm@openssh.com, umac-128-etm@openssh.com, hmac-sha2-256-etm@openssh.com, hmac-sha2-512-etm@openssh.com, hmac-sha1-etm@openssh.com, umac-64@openssh.com, umac-128@openssh.com, hmac-sha2-256, hmac-sha2-512, hmac-sha1\n",
"2024-01-05 13:43:28,371 - paramiko.transport - DEBUG - client compress: none, zlib@openssh.com\n",
"2024-01-05 13:43:28,371 - paramiko.transport - DEBUG - server compress: none, zlib@openssh.com\n",
"2024-01-05 13:43:28,371 - paramiko.transport - DEBUG - client lang: <none>\n",
"2024-01-05 13:43:28,372 - paramiko.transport - DEBUG - server lang: <none>\n",
"2024-01-05 13:43:28,372 - paramiko.transport - DEBUG - kex follows: False\n",
"2024-01-05 13:43:28,372 - paramiko.transport - DEBUG - === Key exchange agreements ===\n",
"2024-01-05 13:43:28,373 - paramiko.transport - DEBUG - Strict kex mode: True\n",
"2024-01-05 13:43:28,373 - paramiko.transport - DEBUG - Kex: curve25519-sha256@libssh.org\n",
"2024-01-05 13:43:28,373 - paramiko.transport - DEBUG - HostKey: ssh-ed25519\n",
"2024-01-05 13:43:28,374 - paramiko.transport - DEBUG - Cipher: aes128-ctr\n",
"2024-01-05 13:43:28,374 - paramiko.transport - DEBUG - MAC: hmac-sha2-256\n",
"2024-01-05 13:43:28,374 - paramiko.transport - DEBUG - Compression: none\n",
"2024-01-05 13:43:28,374 - paramiko.transport - DEBUG - === End of kex handshake ===\n",
"2024-01-05 13:43:28,453 - paramiko.transport - DEBUG - Resetting outbound seqno after NEWKEYS due to strict mode\n",
"2024-01-05 13:43:28,453 - paramiko.transport - DEBUG - kex engine KexCurve25519 specified hash_algo <built-in function openssl_sha256>\n",
"2024-01-05 13:43:28,455 - paramiko.transport - DEBUG - Switch to new keys ...\n",
"2024-01-05 13:43:28,455 - paramiko.transport - DEBUG - Resetting inbound seqno after NEWKEYS due to strict mode\n",
"2024-01-05 13:43:28,456 - paramiko.transport - DEBUG - Attempting public-key auth...\n",
"2024-01-05 13:43:28,456 - paramiko.transport - DEBUG - Got EXT_INFO: {'server-sig-algs': b'ssh-ed25519,sk-ssh-ed25519@openssh.com,ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,sk-ecdsa-sha2-nistp256@openssh.com,webauthn-sk-ecdsa-sha2-nistp256@openssh.com', 'publickey-hostbound@openssh.com': b'0'}\n",
"2024-01-05 13:43:28,545 - paramiko.transport - DEBUG - userauth is OK\n",
"2024-01-05 13:43:28,596 - paramiko.transport - INFO - Authentication (publickey) successful!\n",
"2024-01-05 13:43:28,600 - paramiko.transport - DEBUG - [chan 0] Max packet in: 32768 bytes\n",
"2024-01-05 13:43:28,685 - paramiko.transport - DEBUG - Received global request \"hostkeys-00@openssh.com\"\n",
"2024-01-05 13:43:28,686 - paramiko.transport - DEBUG - Rejecting \"hostkeys-00@openssh.com\" global request from server.\n",
"2024-01-05 13:43:28,686 - paramiko.transport - DEBUG - Debug msg: b'/home/sebl/.ssh/authorized_keys:4: key options: agent-forwarding port-forwarding pty user-rc x11-forwarding'\n",
"2024-01-05 13:43:28,748 - paramiko.transport - DEBUG - [chan 0] Max packet out: 32768 bytes\n",
"2024-01-05 13:43:28,749 - paramiko.transport - DEBUG - Secsh channel 0 opened.\n",
"2024-01-05 13:43:29,313 - paramiko.transport - DEBUG - [chan 0] EOF sent (0)\n",
"2024-01-05 13:43:29,314 - paramiko.transport - DEBUG - [chan 1] Max packet in: 32768 bytes\n",
"2024-01-05 13:43:29,345 - paramiko.transport - DEBUG - [chan 0] EOF received (0)\n",
"2024-01-05 13:43:29,368 - paramiko.transport - DEBUG - [chan 1] Max packet out: 32768 bytes\n",
"2024-01-05 13:43:29,369 - paramiko.transport - DEBUG - Secsh channel 1 opened.\n",
"2024-01-05 13:43:29,631 - paramiko.transport - DEBUG - Sending global request \"keepalive@lag.net\"\n",
"2024-01-05 13:43:30,332 - paramiko.transport - DEBUG - [chan 1] EOF sent (1)\n",
"2024-01-05 13:43:30,375 - paramiko.transport - DEBUG - [chan 1] EOF received (1)\n",
"2024-01-05 13:43:30,445 - paramiko.transport - DEBUG - EOF in transport thread\n"
]
}
],
"source": [
"import pandas as pd\n",
"import geopandas as gpd\n",
"map = folium.Map(location=[47.368650, 8.539183], zoom_start=13, tiles=\"cartodb positron\")\n",
"sig_speeds_data = get_signaled_speed_sql()\n",
"sig_speed_df = pd.DataFrame(sig_speeds_data, columns=['tempo','wkb_geometry'])\n",
"sig_speed_df[\"geometry\"] = sig_speed_df[\"wkb_geometry\"].apply(lambda x: wkb.loads(x, hex=True))\n",
"speedLimits = [\"T0\",\"T10\",\"T20\",\"T30\",\"T50\",\"T60\",\"T80\",\"T100\"]\n",
"color_dict = {\n",
" \"T0\": \"red\",\n",
" \"T10\": \"blue\",\n",
" \"T20\": \"orange\",\n",
" \"T30\": \"green\",\n",
" \"T50\": \"yellow\",\n",
" \"T60\": \"purple\",\n",
" \"T80\": \"pink\",\n",
" \"T100\": \"gray\"\n",
"}\n",
"sig_speed_gdf = gpd.GeoDataFrame(sig_speed_df, geometry=\"geometry\")\n",
"for speedlimit in speedLimits:\n",
" signal_speed = sig_speed_gdf[sig_speed_gdf[\"tempo\"].str.contains(speedlimit, case=False)]\n",
" geometries = json.loads(json.dumps(shapely.geometry.mapping(signal_speed['geometry'].unary_union)))\n",
"\n",
"\n",
" folium.GeoJson(\n",
" data=geometries,\n",
" name=f'Signaled Speed {speedlimit}',\n",
" color=color_dict[speedlimit],\n",
" show=False,\n",
" line_cap=\"butt\",\n",
" ).add_to(map)\n",
"\n",
"folium.LayerControl(collapsed=True).add_to(map)\n",
"map.save(\"map.html\") "
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-01-05T12:43:31.133678293Z",
"start_time": "2024-01-05T12:43:28.276015267Z"
}
},
"id": "f159f38ba318313d"
}
],
"metadata": {