-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmapdraw.py
72 lines (58 loc) · 1.86 KB
/
mapdraw.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import plotly.graph_objects as go
import numpy as np
import os
from pathlib import Path
from src.functions import prepareSpace
ROUTE_PATH = Path(".\\Google Earth Files\\test_map") if os.name != "posix" else Path("./Google Earth Files/test_map")
airspace: dict = prepareSpace(ROUTE_PATH)
print(airspace.keys())
print(airspace["points"])
airspace_poly = np.asarray(airspace["airspace"].exterior.coords.xy)
fig = go.Figure()
center = np.mean(airspace_poly, axis=1)
fig.add_trace(
go.Scattermapbox(
fill="toself",
fillcolor="rgba(0,135,0,0.2)",
opacity=0,
lon=airspace_poly[0, :],
lat=airspace_poly[1, :],
marker={"size": 0, "color": "green", "opacity": 0},
showlegend=False,
)
)
for name, nfz in airspace["nfzs"].items():
nfz_poly = np.asarray(nfz.exterior.coords.xy)
fig.add_trace(
go.Scattermapbox(
fill="toself",
fillcolor="rgba(135,0,0,0.5)",
opacity=0,
lon=nfz_poly[0, :],
lat=nfz_poly[1, :],
marker={"size": 0, "color": "red", "opacity": 0},
showlegend=False,
)
)
for i, vert in enumerate(airspace["points"]):
coords = np.asarray(vert.coords.xy)
fig.add_trace(
go.Scattermapbox(
mode="markers+text",
marker=go.scattermapbox.Marker(size=14),
name=f"Vertiport {i}",
lon=coords[0],
lat=coords[1],
text=[str(f"Vertiport {i}")],
textfont={"color": "royalblue", "family": "Arial", "size": 16},
textposition="bottom right",
marker_color="royalblue",
# texttemplate='(%{lat}, %{lon})%{text}'
)
)
fig.update_layout(
hovermode="closest",
mapbox={"style": "stamen-terrain", "center": {"lon": center[0], "lat": center[1]}, "zoom": 11},
showlegend=False,
)
fig.show()