신호생성 repo (24. 1. 5 ~).
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

1370 lines
48 KiB

{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"import pandas as pd\n",
"import numpy as np\n",
"import sys\n",
"sys.path.append('../../Scripts')\n",
"from preprocess_daily import DailyPreprocessor\n",
"from generate_signals import SignalGenerator"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"비보호좌회전, 신호우회전, 유턴\n",
"\n",
"줄임말 목록\n",
"- `i` : 교차로번호, `inter_no`\n",
"- `f` : 진입, from, `inc_edge_id`\n",
"- `t` : 진출, to, `out_edge_id`\n",
"- `vec` : 방향벡터, unit vector (`np.array([0.6, 0.8])`)\n",
"- `dire` : 방위, direction (동, 서, 남, 북, 북동, 북서, 남동, 남서)\n",
"- `rvec` : 정방향 방향벡터, unit vector to the right direction (`np.array([0,1])`)\n",
"\n",
"필요한 객체들 목록\n",
"\n",
"- `inter2dire2rvec` : `inter_no` $\\mapsto$ `dire2rvec`\n",
" - `dire2rvec` : `dire` $\\mapsto$ `rvec`\n",
"- `inter2incs` : `inter_no` $\\mapsto$ `inc_edge_ids`\n",
"- `inter2outs` : `inter_no` $\\mapsto$ `out_edge_ids`\n",
"- `inter2inc2dire` : `inter_no` $\\mapsto$ `int2dire`\n",
" - `inc2dire` : `out_edge_id` $\\mapsto$ `dire`\n",
"- `inter2out2dire` : `inter_no` $\\mapsto$ `out2dire`\n",
" - `out2dire` : `inc_edge_id` $\\mapsto$ `dire`\n",
"- `inter2inc2vec` : `inter_no` $\\mapsto$ `int2vec`\n",
" - `inc2vec` : `out_edge_id` $\\mapsto$ `vec`\n",
"- `inter2out2vec` : `inter_no` $\\mapsto$ `out2vec`\n",
" - `out2vec` : `inc_edge_id` $\\mapsto$ `vec`\n",
"\n",
"좌회전 판단\n",
"\n",
"Given `inter_no`, `inc_edge_id` and `out_edge_id`, we have `inc_vec = inter2inc2vec[inter_no][inc_edge_id]` and `out_vec = inter2out2vec[inter_no][out_edge_id]`.\n",
"Rotate `inc_vec` by 90, 180 and 270 degrees clockwise, to define \n",
"`out_vec_left`, `out_vec_straight` and `out_vec_right`.\n",
"Define `out_vecs={'right':out_vec_left, 'straight':out_vec_straight, 'right':out_vec_right}`.\n",
"Select the key that maximize the similarity of the corresponding value of the key and `inc_vec`."
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"1. 데이터를 로드합니다.\n",
"1-1. 네트워크가 로드되었습니다.\n",
"1-2. 테이블들이 로드되었습니다.\n",
"1-3. 네트워크의 모든 clean state requirement들을 체크했습니다.\n",
"1-4. 테이블들의 무결성 검사를 완료했습니다.\n",
"1-5. 주요 객체 (리스트, 딕셔너리)들을 저장했습니다.\n"
]
},
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>parent_id</th>\n",
" <th>child_id</th>\n",
" <th>direction</th>\n",
" <th>condition</th>\n",
" <th>inc_edge_id</th>\n",
" <th>out_edge_id</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>i0</td>\n",
" <td>u00</td>\n",
" <td>북</td>\n",
" <td>좌회전시</td>\n",
" <td>571500487_02</td>\n",
" <td>571500487_01.32</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>i2</td>\n",
" <td>u20</td>\n",
" <td>북</td>\n",
" <td>보행신호시</td>\n",
" <td>571542810_01.51</td>\n",
" <td>571542810_02</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>i3</td>\n",
" <td>u30</td>\n",
" <td>북</td>\n",
" <td>보행신호시</td>\n",
" <td>571556452_01</td>\n",
" <td>571556452_02</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>i3</td>\n",
" <td>u31</td>\n",
" <td>동</td>\n",
" <td>보행신호시</td>\n",
" <td>571500475_02</td>\n",
" <td>571500475_01.26</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>i3</td>\n",
" <td>u32</td>\n",
" <td>서</td>\n",
" <td>보행신호시</td>\n",
" <td>571540303_02</td>\n",
" <td>-571540303_02</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>i6</td>\n",
" <td>u60</td>\n",
" <td>서</td>\n",
" <td>좌회전시</td>\n",
" <td>571500535_02</td>\n",
" <td>-571500535_02</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" parent_id child_id direction condition inc_edge_id out_edge_id\n",
"0 i0 u00 북 좌회전시 571500487_02 571500487_01.32\n",
"1 i2 u20 북 보행신호시 571542810_01.51 571542810_02\n",
"2 i3 u30 북 보행신호시 571556452_01 571556452_02\n",
"3 i3 u31 동 보행신호시 571500475_02 571500475_01.26\n",
"4 i3 u32 서 보행신호시 571540303_02 -571540303_02\n",
"5 i6 u60 서 좌회전시 571500535_02 -571500535_02"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>parent_id</th>\n",
" <th>child_id</th>\n",
" <th>head_edge_id</th>\n",
" <th>from_edge_id</th>\n",
" <th>to_edge_id</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>i0</td>\n",
" <td>u00</td>\n",
" <td>-571500487_01</td>\n",
" <td>571500487_02</td>\n",
" <td>571500487_01.32</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>i2</td>\n",
" <td>u20</td>\n",
" <td>571542811_02</td>\n",
" <td>571542810_01.51</td>\n",
" <td>571542810_02</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>i3</td>\n",
" <td>u30</td>\n",
" <td>571556450_02</td>\n",
" <td>571556452_01</td>\n",
" <td>571556452_02</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>i3</td>\n",
" <td>u31</td>\n",
" <td>-571500475_01</td>\n",
" <td>571500475_02</td>\n",
" <td>571500475_01.26</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>i3</td>\n",
" <td>u32</td>\n",
" <td>571540303_02.21</td>\n",
" <td>571540303_02</td>\n",
" <td>-571540303_02</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>i6</td>\n",
" <td>u60</td>\n",
" <td>571500535_02.18</td>\n",
" <td>571500535_02</td>\n",
" <td>-571500535_02</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" parent_id child_id head_edge_id from_edge_id to_edge_id\n",
"0 i0 u00 -571500487_01 571500487_02 571500487_01.32\n",
"1 i2 u20 571542811_02 571542810_01.51 571542810_02\n",
"2 i3 u30 571556450_02 571556452_01 571556452_02\n",
"3 i3 u31 -571500475_01 571500475_02 571500475_01.26\n",
"4 i3 u32 571540303_02.21 571540303_02 -571540303_02\n",
"5 i6 u60 571500535_02.18 571500535_02 -571500535_02"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>parent_id</th>\n",
" <th>child_id</th>\n",
" <th>head_edge_id</th>\n",
" <th>from_edge_id</th>\n",
" <th>to_edge_id</th>\n",
" <th>condition</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>i0</td>\n",
" <td>u00</td>\n",
" <td>-571500487_01</td>\n",
" <td>571500487_02</td>\n",
" <td>571500487_01.32</td>\n",
" <td>좌회전시</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>i2</td>\n",
" <td>u20</td>\n",
" <td>571542811_02</td>\n",
" <td>571542810_01.51</td>\n",
" <td>571542810_02</td>\n",
" <td>보행신호시</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>i3</td>\n",
" <td>u30</td>\n",
" <td>571556450_02</td>\n",
" <td>571556452_01</td>\n",
" <td>571556452_02</td>\n",
" <td>보행신호시</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>i3</td>\n",
" <td>u31</td>\n",
" <td>-571500475_01</td>\n",
" <td>571500475_02</td>\n",
" <td>571500475_01.26</td>\n",
" <td>보행신호시</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>i3</td>\n",
" <td>u32</td>\n",
" <td>571540303_02.21</td>\n",
" <td>571540303_02</td>\n",
" <td>-571540303_02</td>\n",
" <td>보행신호시</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>i6</td>\n",
" <td>u60</td>\n",
" <td>571500535_02.18</td>\n",
" <td>571500535_02</td>\n",
" <td>-571500535_02</td>\n",
" <td>좌회전시</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" parent_id child_id head_edge_id from_edge_id to_edge_id \\\n",
"0 i0 u00 -571500487_01 571500487_02 571500487_01.32 \n",
"1 i2 u20 571542811_02 571542810_01.51 571542810_02 \n",
"2 i3 u30 571556450_02 571556452_01 571556452_02 \n",
"3 i3 u31 -571500475_01 571500475_02 571500475_01.26 \n",
"4 i3 u32 571540303_02.21 571540303_02 -571540303_02 \n",
"5 i6 u60 571500535_02.18 571500535_02 -571500535_02 \n",
"\n",
" condition \n",
"0 좌회전시 \n",
"1 보행신호시 \n",
"2 보행신호시 \n",
"3 보행신호시 \n",
"4 보행신호시 \n",
"5 좌회전시 "
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"self = DailyPreprocessor()\n",
"self.load_data()\n",
"self.make_match1()\n",
"self.make_match2()\n",
"self.make_match3()\n",
"self.make_match4()\n",
"self.make_match5()\n",
"display(self.uturn)\n",
"display(self.u_turn)\n",
"self.u_turn = pd.merge(self.u_turn, self.u_condition, on='child_id')\n",
"self.u_turn"
]
},
{
"cell_type": "code",
"execution_count": 85,
"metadata": {},
"outputs": [],
"source": [
"# n2inc_edge2angle : node_id to inc_edge2angle\n",
"n2inc_edge2angle = dict()\n",
"# n2out_edge2angle : node_id to out_edge2angle\n",
"n2out_edge2angle = dict()\n",
"# n2inc_angle2edge : node_id to inc_angle2edge\n",
"n2inc_angle2edge = dict()\n",
"# n2out_angle2edge : node_id to out_angle2edge\n",
"n2out_angle2edge = dict()\n",
"for node_id in self.parent_ids:\n",
" m5 = self.match5[self.match5.node_id==node_id]\n",
" m5 = m5.dropna(subset=['inc_edge_id', 'out_edge_id'])\n",
" # inc_edge2angle : inc_edge_id to inc_angle\n",
" inc_edge2angle = dict(zip(m5.inc_edge_id, m5.inc_angle.astype(int)))\n",
" n2inc_edge2angle[node_id] = inc_edge2angle\n",
" # out_edge2angle : out_edge_id to out_angle\n",
" out_edge2angle = dict(zip(m5.out_edge_id, m5.out_angle.astype(int)))\n",
" n2out_edge2angle[node_id] = out_edge2angle\n",
" # inc_angle2edge : inc_angle to inc_edge_id\n",
" inc_angle2edge = dict(zip(m5.inc_angle.astype(int), m5.inc_edge_id))\n",
" n2inc_angle2edge[node_id] = inc_angle2edge\n",
" # out_angle2edge : out_angle to out_edge_id\n",
" out_angle2edge = dict(zip(m5.out_angle.astype(int), m5.out_edge_id))\n",
" n2out_angle2edge[node_id] = out_angle2edge"
]
},
{
"cell_type": "code",
"execution_count": 173,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"parent_id i2\n",
"child_id u20\n",
"head_edge_id 571542811_02\n",
"from_edge_id 571542810_01.51\n",
"to_edge_id 571542810_02\n",
"condition 보행신호시\n",
"Name: 1, dtype: object"
]
},
"execution_count": 173,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"i = 1\n",
"row = self.u_turn.iloc[i]\n",
"\n",
"parent_id = row.parent_id\n",
"child_id = row.child_id\n",
"condition = row.condition\n",
"inc_edge_id = row.from_edge_id\n",
"out_edge_id = row.to_edge_id\n",
"head_edge_id = row.head_edge_id\n",
"row"
]
},
{
"cell_type": "code",
"execution_count": 174,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"i2 u20 보행신호시\n"
]
},
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>inter_no</th>\n",
" <th>phase_no</th>\n",
" <th>ring_type</th>\n",
" <th>move_no</th>\n",
" <th>inc_dire</th>\n",
" <th>out_dire</th>\n",
" <th>inc_angle</th>\n",
" <th>out_angle</th>\n",
" <th>inc_edge_id</th>\n",
" <th>out_edge_id</th>\n",
" <th>node_id</th>\n",
" <th>turn_type</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>177</td>\n",
" <td>1</td>\n",
" <td>A</td>\n",
" <td>8</td>\n",
" <td>남</td>\n",
" <td>북</td>\n",
" <td>179</td>\n",
" <td>000</td>\n",
" <td>-571542809_01</td>\n",
" <td>571542811_01</td>\n",
" <td>u20</td>\n",
" <td>left</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>177</td>\n",
" <td>1</td>\n",
" <td>B</td>\n",
" <td>4</td>\n",
" <td>북</td>\n",
" <td>남</td>\n",
" <td>000</td>\n",
" <td>180</td>\n",
" <td>571542811_02</td>\n",
" <td>571542809_01</td>\n",
" <td>u20</td>\n",
" <td>straight</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>177</td>\n",
" <td>2</td>\n",
" <td>A</td>\n",
" <td>7</td>\n",
" <td>북</td>\n",
" <td>동</td>\n",
" <td>000</td>\n",
" <td>090</td>\n",
" <td>571542811_02</td>\n",
" <td>571542107_01</td>\n",
" <td>u20</td>\n",
" <td>left</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>177</td>\n",
" <td>2</td>\n",
" <td>B</td>\n",
" <td>3</td>\n",
" <td>남</td>\n",
" <td>서</td>\n",
" <td>179</td>\n",
" <td>270</td>\n",
" <td>-571542809_01</td>\n",
" <td>571542809_01</td>\n",
" <td>u20</td>\n",
" <td>left</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>177</td>\n",
" <td>4</td>\n",
" <td>A</td>\n",
" <td>5</td>\n",
" <td>서</td>\n",
" <td>북</td>\n",
" <td>268</td>\n",
" <td>000</td>\n",
" <td>-571542809_01</td>\n",
" <td>571542811_01</td>\n",
" <td>u20</td>\n",
" <td>left</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>177</td>\n",
" <td>4</td>\n",
" <td>B</td>\n",
" <td>1</td>\n",
" <td>동</td>\n",
" <td>남</td>\n",
" <td>090</td>\n",
" <td>180</td>\n",
" <td>571542107_02</td>\n",
" <td>571542809_01</td>\n",
" <td>u20</td>\n",
" <td>left</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" inter_no phase_no ring_type move_no inc_dire out_dire inc_angle \\\n",
"0 177 1 A 8 남 북 179 \n",
"1 177 1 B 4 북 남 000 \n",
"2 177 2 A 7 북 동 000 \n",
"3 177 2 B 3 남 서 179 \n",
"4 177 4 A 5 서 북 268 \n",
"5 177 4 B 1 동 남 090 \n",
"\n",
" out_angle inc_edge_id out_edge_id node_id turn_type \n",
"0 000 -571542809_01 571542811_01 u20 left \n",
"1 180 571542811_02 571542809_01 u20 straight \n",
"2 090 571542811_02 571542107_01 u20 left \n",
"3 270 -571542809_01 571542809_01 u20 left \n",
"4 000 -571542809_01 571542811_01 u20 left \n",
"5 180 571542107_02 571542809_01 u20 left "
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# match5에서 부모노드id에 해당하는 행들을 가져옴 (cmatch)\n",
"cmatch = self.match5.copy()[self.match5.node_id==parent_id] # match dataframe for a child node\n",
"cmatch = cmatch.dropna(subset=['inc_angle', 'out_angle'])\n",
"cmatch = cmatch.sort_values(by=['phase_no', 'ring_type']).reset_index(drop=True)\n",
"cmatch['node_id'] = child_id\n",
"print(parent_id, child_id, condition)\n",
"display(cmatch)"
]
},
{
"cell_type": "code",
"execution_count": 184,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>node_id</th>\n",
" <th>inc_edge_id</th>\n",
" <th>out_edge_id</th>\n",
" <th>turn_type</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>13</th>\n",
" <td>i2</td>\n",
" <td>-571542809_01</td>\n",
" <td>571542811_01</td>\n",
" <td>straight</td>\n",
" </tr>\n",
" <tr>\n",
" <th>14</th>\n",
" <td>i2</td>\n",
" <td>571542811_02</td>\n",
" <td>571542809_01</td>\n",
" <td>straight</td>\n",
" </tr>\n",
" <tr>\n",
" <th>15</th>\n",
" <td>i2</td>\n",
" <td>571542811_02</td>\n",
" <td>571542107_01</td>\n",
" <td>left</td>\n",
" </tr>\n",
" <tr>\n",
" <th>16</th>\n",
" <td>i2</td>\n",
" <td>-571542809_01</td>\n",
" <td>571542809_01</td>\n",
" <td>left</td>\n",
" </tr>\n",
" <tr>\n",
" <th>17</th>\n",
" <td>i2</td>\n",
" <td>-571542809_01</td>\n",
" <td>571542811_01</td>\n",
" <td>left</td>\n",
" </tr>\n",
" <tr>\n",
" <th>18</th>\n",
" <td>i2</td>\n",
" <td>571542107_02</td>\n",
" <td>571542809_01</td>\n",
" <td>left</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" node_id inc_edge_id out_edge_id turn_type\n",
"13 i2 -571542809_01 571542811_01 straight\n",
"14 i2 571542811_02 571542809_01 straight\n",
"15 i2 571542811_02 571542107_01 left\n",
"16 i2 -571542809_01 571542809_01 left\n",
"17 i2 -571542809_01 571542811_01 left\n",
"18 i2 571542107_02 571542809_01 left"
]
},
"execution_count": 184,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"self.turn_type[self.turn_type.node_id=='i2']"
]
},
{
"cell_type": "code",
"execution_count": 181,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"i0\n",
"{('-571542797_02', '571500487_01'): 'straight', ('-571500487_01', '571542797_02'): 'straight', ('-571500487_01', '571545870_01'): 'left', ('-571542797_02', '571510153_01'): 'left', ('571545870_02', '571510153_01'): 'straight', ('571545870_02', '571542797_02'): 'left', ('571510153_02', '571500487_01'): 'left', ('571510153_02', '571545870_01'): 'straight'}\n",
"i1\n",
"{('-571542810_01', '-571542797_02.99'): 'straight', ('571542797_02.99', '571542810_01'): 'straight', ('-571542810_01', '571543469_01'): 'left', ('571543469_02', '-571542797_02.99'): 'left'}\n",
"i2\n",
"{('-571542809_01', '571542811_01'): 'left', ('571542811_02', '571542809_01'): 'straight', ('571542811_02', '571542107_01'): 'left', ('-571542809_01', '571542809_01'): 'left', ('571542107_02', '571542809_01'): 'left'}\n",
"i3\n",
"{('571540304_02', '571556450_01'): 'straight', ('571556450_02', '571540304_01'): 'straight', ('571556450_02', '571500475_01'): 'left', ('571540304_02', '571540303_01'): 'left', ('571540303_02.21', '571556450_01'): 'left', ('571540303_02.21', '571500475_01'): 'straight', ('-571500475_01', '571540303_01'): 'straight', ('-571500475_01', '571540304_01'): 'left'}\n",
"i6\n",
"{('-571542115_01', '571500535_01'): 'straight', ('571500535_02.18', '571511538_01'): 'left', ('571500535_02.18', '571542115_01'): 'straight', ('571511538_02.121', '571542115_01'): 'left', ('571511538_02.121', '571500585_01'): 'straight', ('571500585_02', '571511538_01'): 'straight', ('571500585_02', '571500535_01'): 'left'}\n",
"i7\n",
"{('-571511538_02', '571542073_02'): 'straight', ('571542073_01', '571511538_02'): 'straight'}\n",
"i8\n",
"{('-571500569_01', '571500583_02'): 'straight', ('-571500569_01', '571500618_01'): 'left', ('571500618_02', '571500583_02'): 'left', ('571500618_02', '571500617_01'): 'straight', ('571500617_02', '571500618_01'): 'straight', ('571500617_02', '571500569_01'): 'left', ('571500583_01', '571500617_01'): 'left', ('571500583_01', '571500569_01'): 'straight'}\n",
"i9\n",
"{('571510152_02', '-571510152_01'): 'straight', ('571510152_01', '571510152_01.65'): 'straight'}\n"
]
}
],
"source": [
"# dictionary that maps node_id to io2turn\n",
"n2io2turn = dict()\n",
"for node_id in self.parent_ids:\n",
" print(node_id)\n",
" turn = self.turn_type[self.turn_type.node_id==node_id]\n",
" io = list(zip(turn.inc_edge_id, turn.out_edge_id))\n",
" # dictionary that maps (inc_edge_id, out_edge_id) to turn_type\n",
" io2turn = dict(zip(io, turn.turn_type))\n",
" n2io2turn[node_id] = io2turn\n",
" print(io2turn)\n",
"\n",
"for i, row in self.match5.iterrows():\n",
" node_id = row.node_id\n",
" inc_edge_id = row.inc_edge_id\n",
" out_edge_id = row.out_edge_id\n",
" if not (pd.isna(inc_edge_id) and pd.isna(out_edge_id)):\n",
" turn_type = n2io2turn[node_id][(inc_edge_id, out_edge_id)]\n",
" self.match5.at[i, 'turn_type'] = turn_type\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"\n",
"# 헤드엣지가 포함된 행\n",
"head_true = cmatch.inc_edge_id==head_edge_id\n",
"\n",
"# 헤드엣지 각도\n",
"inc_angle_head = n2inc_edge2angle[parent_id][head_edge_id]\n",
"print(inc_angle_head)\n",
"\n",
"# 이격각도\n",
"self.angle_separation = 10\n",
"\n",
"# 진입로 각도 목록\n",
"inc_angles = cmatch.inc_angle.astype(int).unique()\n",
"inc_angles = np.sort(inc_angles)\n",
"inc_angles = list(inc_angles - 360) + list(inc_angles) + list(inc_angles + 360)\n",
"inc_angles = np.array(inc_angles)\n",
"print(inc_angles)\n",
"\n",
"# 보행신호시의 진입로 각도\n",
"inc_angles_left = inc_angles[inc_angles >= inc_angle_head + self.angle_separation]\n",
"inc_angle_pedes = np.sort(inc_angles_left)[0] % 360\n",
"print(inc_angles_left)\n",
"print(inc_angle_pedes)\n",
"\n",
"# 보행신호시의 진입로 엣지id\n",
"inc_angle2edge = n2inc_angle2edge[parent_id]\n",
"inc_edge_id_pedes = inc_angle2edge[inc_angle_pedes]\n",
"print(inc_edge_id_pedes)\n",
"\n",
"# 진출로 각도 목록\n",
"out_angles = cmatch.out_angle.astype(int).unique()\n",
"out_angles = np.sort(out_angles)\n",
"out_angles = list(out_angles - 360) + list(out_angles) + list(out_angles + 360)\n",
"out_angles = np.array(out_angles)\n",
"print(out_angles)\n",
"\n",
"# 보행신호시의 진입로 각도\n",
"out_angles_right = out_angles[out_angles <= inc_angle_head - self.angle_separation]\n",
"out_angle_pedes = np.sort(out_angles_right)[-1] % 360\n",
"print(out_angles_right)\n",
"\n",
"print(out_angle_pedes)\n",
"\n",
"# 보행신호시의 진입로 엣지id\n",
"out_angle2edge = n2out_angle2edge[parent_id]\n",
"out_edge_id_pedes = out_angle2edge[out_angle_pedes]\n",
"print(out_edge_id_pedes)\n",
"\n",
"# 보행신호시 조건\n",
"pedes_flag = (cmatch.inc_edge_id==inc_edge_id_pedes) & (cmatch.out_edge_id==out_edge_id_pedes)\n",
"\n",
"# 좌회전시 조건\n",
"right_flag = head_true & (cmatch.turn_type=='left')\n",
"\n",
"# 보행신호시/좌회전시 진입/진출 엣지id 배정\n",
"cmatch[['inc_edge_id', 'out_edge_id']] = np.nan\n",
"if condition == \"보행신호시\":\n",
" cmatch.loc[pedes_flag, ['inc_edge_id', 'out_edge_id']] = [inc_edge_id, out_edge_id]\n",
"elif condition == \"좌회전시\":\n",
" cmatch.loc[right_flag, ['inc_edge_id', 'out_edge_id']] = [inc_edge_id, out_edge_id]\n",
"\n",
"display(cmatch)"
]
},
{
"cell_type": "code",
"execution_count": 190,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"i2 u20 보행신호시\n"
]
},
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>inter_no</th>\n",
" <th>phase_no</th>\n",
" <th>ring_type</th>\n",
" <th>move_no</th>\n",
" <th>inc_dire</th>\n",
" <th>out_dire</th>\n",
" <th>inc_angle</th>\n",
" <th>out_angle</th>\n",
" <th>inc_edge_id</th>\n",
" <th>out_edge_id</th>\n",
" <th>node_id</th>\n",
" <th>turn_type</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>177</td>\n",
" <td>1</td>\n",
" <td>A</td>\n",
" <td>8</td>\n",
" <td>남</td>\n",
" <td>북</td>\n",
" <td>179</td>\n",
" <td>000</td>\n",
" <td>-571542809_01</td>\n",
" <td>571542811_01</td>\n",
" <td>u20</td>\n",
" <td>left</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>177</td>\n",
" <td>1</td>\n",
" <td>B</td>\n",
" <td>4</td>\n",
" <td>북</td>\n",
" <td>남</td>\n",
" <td>000</td>\n",
" <td>180</td>\n",
" <td>571542811_02</td>\n",
" <td>571542809_01</td>\n",
" <td>u20</td>\n",
" <td>straight</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>177</td>\n",
" <td>2</td>\n",
" <td>A</td>\n",
" <td>7</td>\n",
" <td>북</td>\n",
" <td>동</td>\n",
" <td>000</td>\n",
" <td>090</td>\n",
" <td>571542811_02</td>\n",
" <td>571542107_01</td>\n",
" <td>u20</td>\n",
" <td>left</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>177</td>\n",
" <td>2</td>\n",
" <td>B</td>\n",
" <td>3</td>\n",
" <td>남</td>\n",
" <td>서</td>\n",
" <td>179</td>\n",
" <td>270</td>\n",
" <td>-571542809_01</td>\n",
" <td>571542809_01</td>\n",
" <td>u20</td>\n",
" <td>left</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>177</td>\n",
" <td>4</td>\n",
" <td>A</td>\n",
" <td>5</td>\n",
" <td>서</td>\n",
" <td>북</td>\n",
" <td>268</td>\n",
" <td>000</td>\n",
" <td>-571542809_01</td>\n",
" <td>571542811_01</td>\n",
" <td>u20</td>\n",
" <td>left</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>177</td>\n",
" <td>4</td>\n",
" <td>B</td>\n",
" <td>1</td>\n",
" <td>동</td>\n",
" <td>남</td>\n",
" <td>090</td>\n",
" <td>180</td>\n",
" <td>571542107_02</td>\n",
" <td>571542809_01</td>\n",
" <td>u20</td>\n",
" <td>left</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" inter_no phase_no ring_type move_no inc_dire out_dire inc_angle \\\n",
"0 177 1 A 8 남 북 179 \n",
"1 177 1 B 4 북 남 000 \n",
"2 177 2 A 7 북 동 000 \n",
"3 177 2 B 3 남 서 179 \n",
"4 177 4 A 5 서 북 268 \n",
"5 177 4 B 1 동 남 090 \n",
"\n",
" out_angle inc_edge_id out_edge_id node_id turn_type \n",
"0 000 -571542809_01 571542811_01 u20 left \n",
"1 180 571542811_02 571542809_01 u20 straight \n",
"2 090 571542811_02 571542107_01 u20 left \n",
"3 270 -571542809_01 571542809_01 u20 left \n",
"4 000 -571542809_01 571542811_01 u20 left \n",
"5 180 571542107_02 571542809_01 u20 left "
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"0\n",
"[-360 -270 -181 -92 0 90 179 268 360 450 539 628]\n",
"[ 90 179 268 360 450 539 628]\n",
"90\n",
"571542107_02\n",
"[-360 -270 -180 -90 0 90 180 270 360 450 540 630]\n",
"[-360 -270 -180 -90]\n",
"270\n",
"571542809_01\n"
]
},
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>inter_no</th>\n",
" <th>phase_no</th>\n",
" <th>ring_type</th>\n",
" <th>move_no</th>\n",
" <th>inc_dire</th>\n",
" <th>out_dire</th>\n",
" <th>inc_angle</th>\n",
" <th>out_angle</th>\n",
" <th>inc_edge_id</th>\n",
" <th>out_edge_id</th>\n",
" <th>node_id</th>\n",
" <th>turn_type</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>177</td>\n",
" <td>1</td>\n",
" <td>A</td>\n",
" <td>8</td>\n",
" <td>남</td>\n",
" <td>북</td>\n",
" <td>179</td>\n",
" <td>000</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>u20</td>\n",
" <td>left</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>177</td>\n",
" <td>1</td>\n",
" <td>B</td>\n",
" <td>4</td>\n",
" <td>북</td>\n",
" <td>남</td>\n",
" <td>000</td>\n",
" <td>180</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>u20</td>\n",
" <td>straight</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>177</td>\n",
" <td>2</td>\n",
" <td>A</td>\n",
" <td>7</td>\n",
" <td>북</td>\n",
" <td>동</td>\n",
" <td>000</td>\n",
" <td>090</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>u20</td>\n",
" <td>left</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>177</td>\n",
" <td>2</td>\n",
" <td>B</td>\n",
" <td>3</td>\n",
" <td>남</td>\n",
" <td>서</td>\n",
" <td>179</td>\n",
" <td>270</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>u20</td>\n",
" <td>left</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>177</td>\n",
" <td>4</td>\n",
" <td>A</td>\n",
" <td>5</td>\n",
" <td>서</td>\n",
" <td>북</td>\n",
" <td>268</td>\n",
" <td>000</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>u20</td>\n",
" <td>left</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>177</td>\n",
" <td>4</td>\n",
" <td>B</td>\n",
" <td>1</td>\n",
" <td>동</td>\n",
" <td>남</td>\n",
" <td>090</td>\n",
" <td>180</td>\n",
" <td>571542810_01.51</td>\n",
" <td>571542810_02</td>\n",
" <td>u20</td>\n",
" <td>left</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" inter_no phase_no ring_type move_no inc_dire out_dire inc_angle \\\n",
"0 177 1 A 8 남 북 179 \n",
"1 177 1 B 4 북 남 000 \n",
"2 177 2 A 7 북 동 000 \n",
"3 177 2 B 3 남 서 179 \n",
"4 177 4 A 5 서 북 268 \n",
"5 177 4 B 1 동 남 090 \n",
"\n",
" out_angle inc_edge_id out_edge_id node_id turn_type \n",
"0 000 NaN NaN u20 left \n",
"1 180 NaN NaN u20 straight \n",
"2 090 NaN NaN u20 left \n",
"3 270 NaN NaN u20 left \n",
"4 000 NaN NaN u20 left \n",
"5 180 571542810_01.51 571542810_02 u20 left "
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"i = 1\n",
"row = self.u_turn.iloc[i]\n",
"\n",
"parent_id = row.parent_id\n",
"child_id = row.child_id\n",
"condition = row.condition\n",
"inc_edge_id = row.from_edge_id\n",
"out_edge_id = row.to_edge_id\n",
"head_edge_id = row.head_edge_id\n",
"\n",
"# match5에서 부모노드id에 해당하는 행들을 가져옴 (cmatch)\n",
"cmatch = self.match5.copy()[self.match5.node_id==parent_id] # match dataframe for a child node\n",
"cmatch = cmatch.dropna(subset=['inc_angle', 'out_angle'])\n",
"cmatch = cmatch.sort_values(by=['phase_no', 'ring_type']).reset_index(drop=True)\n",
"cmatch['node_id'] = child_id\n",
"print(parent_id, child_id, condition)\n",
"display(cmatch)\n",
"\n",
"# 헤드엣지가 포함된 행\n",
"head_true = cmatch.inc_edge_id==head_edge_id\n",
"\n",
"# 헤드엣지 각도\n",
"inc_angle_head = n2inc_edge2angle[parent_id][head_edge_id]\n",
"print(inc_angle_head)\n",
"\n",
"# 이격각도\n",
"self.angle_separation = 10\n",
"\n",
"# 진입로 각도 목록\n",
"inc_angles = cmatch.inc_angle.astype(int).unique()\n",
"inc_angles = np.sort(inc_angles)\n",
"inc_angles = list(inc_angles - 360) + list(inc_angles) + list(inc_angles + 360)\n",
"inc_angles = np.array(inc_angles)\n",
"print(inc_angles)\n",
"\n",
"# 보행신호시의 진입로 각도\n",
"inc_angles_left = inc_angles[inc_angles >= inc_angle_head + self.angle_separation]\n",
"inc_angle_pedes = np.sort(inc_angles_left)[0] % 360\n",
"print(inc_angles_left)\n",
"print(inc_angle_pedes)\n",
"\n",
"# 보행신호시의 진입로 엣지id\n",
"inc_angle2edge = n2inc_angle2edge[parent_id]\n",
"inc_edge_id_pedes = inc_angle2edge[inc_angle_pedes]\n",
"print(inc_edge_id_pedes)\n",
"\n",
"# 진출로 각도 목록\n",
"out_angles = cmatch.out_angle.astype(int).unique()\n",
"out_angles = np.sort(out_angles)\n",
"out_angles = list(out_angles - 360) + list(out_angles) + list(out_angles + 360)\n",
"out_angles = np.array(out_angles)\n",
"print(out_angles)\n",
"\n",
"# 보행신호시의 진입로 각도\n",
"out_angles_right = out_angles[out_angles <= inc_angle_head - self.angle_separation]\n",
"out_angle_pedes = np.sort(out_angles_right)[-1] % 360\n",
"print(out_angles_right)\n",
"\n",
"print(out_angle_pedes)\n",
"\n",
"# 보행신호시의 진입로 엣지id\n",
"out_angle2edge = n2out_angle2edge[parent_id]\n",
"out_edge_id_pedes = out_angle2edge[out_angle_pedes]\n",
"print(out_edge_id_pedes)\n",
"\n",
"# 보행신호시 조건\n",
"pedes_flag = (cmatch.inc_edge_id==inc_edge_id_pedes) & (cmatch.out_edge_id==out_edge_id_pedes)\n",
"\n",
"# 좌회전시 조건\n",
"right_flag = head_true & (cmatch.turn_type=='left')\n",
"\n",
"# 보행신호시/좌회전시 진입/진출 엣지id 배정\n",
"cmatch[['inc_edge_id', 'out_edge_id']] = np.nan\n",
"if condition == \"보행신호시\":\n",
" cmatch.loc[pedes_flag, ['inc_edge_id', 'out_edge_id']] = [inc_edge_id, out_edge_id]\n",
"elif condition == \"좌회전시\":\n",
" cmatch.loc[right_flag, ['inc_edge_id', 'out_edge_id']] = [inc_edge_id, out_edge_id]\n",
"\n",
"display(cmatch)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# 각 uturn node에 대하여 (inc_edge_id, out_edge_id) 부여\n",
"cmatches = []\n",
"for _, row in self.uturn.iterrows():\n",
" child_id = row.child_id\n",
" parent_id = row.parent_id\n",
" dire = row.direction\n",
" condition = row.condition\n",
" inc_edge_id = row.inc_edge_id\n",
" out_edge_id = row.out_edge_id\n",
"\n",
" print(parent_id, condition)\n",
"\n",
" # match5에서 부모노드id에 해당하는 행들을 가져옴 (cmatch)\n",
" cmatch = self.match5.copy()[self.match5.node_id==parent_id] # match dataframe for a child node\n",
" cmatch = cmatch.sort_values(by=['phase_no', 'ring_type']).reset_index(drop=True)\n",
" cmatch['node_id'] = child_id\n",
" cmatch[['inc_edge_id', 'out_edge_id']] = np.nan\n",
" display(cmatch)\n",
"\n",
" # 보행신호시/좌회전시 진입/진출방향\n",
" ind = self.dires.index(dire)\n",
" inc_dire_pedes = self.dires[(ind + 2) % len(self.dires)]\n",
" out_dire_pedes = self.dires[(ind - 2) % len(self.dires)]\n",
" inc_dire_right = dire\n",
" out_dire_right = self.dires[(ind + 2) % len(self.dires)]\n",
"\n",
" if condition == '보행신호시':\n",
" print(inc_dire_pedes, out_dire_pedes)\n",
" else:\n",
" print(inc_dire_right, out_dire_right)\n",
"\n",
" # 보행신호시/좌회전시 조건\n",
" pedes_exists = (cmatch.inc_dire==inc_dire_pedes) & (cmatch.out_dire==out_dire_pedes)\n",
" right_exists = (cmatch.inc_dire==inc_dire_right) & (cmatch.out_dire==out_dire_right)\n",
"\n",
" # 보행신호시/좌회전시 진입/진출 엣지id 배정\n",
" ind = self.dires.index(dire)\n",
" if condition == \"보행신호시\":\n",
" cmatch.loc[pedes_exists, ['inc_edge_id', 'out_edge_id']] = [inc_edge_id, out_edge_id]\n",
" elif condition == \"좌회전시\":\n",
" cmatch.loc[right_exists, ['inc_edge_id', 'out_edge_id']] = [inc_edge_id, out_edge_id]\n",
" display(cmatch)\n",
"\n",
" # 신호없음이동류발생시/보행신호이동류발생시 조건\n",
" all_redsigns = cmatch.move_no == 18\n",
" crosswalk_on = cmatch.move_no == 17\n",
"\n",
" # 만약 어떤 유턴신호도 배정되지 않았다면\n",
" # 좌회전시 → 보행신호시 → 보행신호이동류발생시 → 신호없음이동류발생시 순으로 진입/진출 엣지id 배정\n",
" uturn_not_assigned = cmatch[['inc_edge_id','out_edge_id']].isna().any(axis=1).all()\n",
" if uturn_not_assigned:\n",
" # 좌회전시\n",
" if right_exists.any():\n",
" cmatch.loc[right_exists, ['inc_edge_id', 'out_edge_id']] = [inc_edge_id, out_edge_id]\n",
" # 보행신호시\n",
" elif pedes_exists.any():\n",
" cmatch.loc[pedes_exists, ['inc_edge_id', 'out_edge_id']] = [inc_edge_id, out_edge_id]\n",
" # 보행신호이동류(17) 발생시\n",
" elif crosswalk_on.any():\n",
" cmatch.loc[crosswalk_on & (cmatch.out_dire!=dire), ['inc_edge_id', 'out_edge_id']] = [inc_edge_id, out_edge_id]\n",
" # 신호없음이동류(18) 발생시\n",
" elif all_redsigns.any():\n",
" cmatch.loc[all_redsigns & (cmatch.out_dire!=dire), ['inc_edge_id', 'out_edge_id']] = [inc_edge_id, out_edge_id]\n",
" display(cmatch)\n",
"cmatches.append(cmatch)\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"'''Given `inter_no`, `inc_edge_id` and `out_edge_id`, we have `inc_vec = inter2inc2vec[inter_no][inc_edge_id]` and `out_vec = inter2out2vec[inter_no][out_edge_id]`.\n",
"Rotate `inc_vec` by 90, 180 and 270 degrees clockwise, to define \n",
"`out_vec_left`, `out_vec_straight` and `out_vec_right`.\n",
"Define `out_vecs={'right':out_vec_left, 'straight':out_vec_straight, 'right':out_vec_right}`.\n",
"Select the key that maximize the similarity of the corresponding value of the key and `inc_vec`.'''"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "sts",
"language": "python",
"name": "sts"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.10"
}
},
"nbformat": 4,
"nbformat_minor": 2
}