-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path123.py
57 lines (41 loc) · 1.12 KB
/
123.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import sumolib
import xml.etree.cElementTree as ET
import math
net = sumolib.net.readNet('planet32.net.xml')
# koordinate u stupnjevima
# lat = 45.780814
# lon = 16.001999
lat = 45.810412
lon = 15.973198
# koordinate u metrima
# xc = 13776.76
# yc = 6041.51
xc, yc = net.convertLonLat2XY(lon, lat)
# korekcija koordinata
xc = xc - 8476.015194
yc = yc + 7581.0136319
Listasvih, x, y = [], [], []
tree = ET.parse('planet32.net.xml')
root = tree.getroot()
for junctions in root.findall('junction'):
Listasvih.append(junctions.get('id'))
x.append(float(junctions.get('x')))
y.append(float(junctions.get('y')))
Min = 9999999
Xmin = 0
Ymin = 0
for i in x:
Udaljenost = math.sqrt(math.pow((xc - i), 2) + math.pow((yc - y[x.index(i)]), 2))
if Udaljenost < Min:
Min = Udaljenost
Xmin = i
Ymin = y[x.index(i)]
Index = 0
for i in x:
if i == Xmin and y[x.index(i)] == Ymin:
Index = x.index(i)
Junctionofinterest = Listasvih[Index]
for edges in root.findall('edge'):
if edges.get('from') == str(Junctionofinterest):
edgekojitezanima = edges.attrib['id']
print(edgekojitezanima)