2019-11-28 18:54:24 +02:00
|
|
|
#!/usr/bin/env python3
|
2019-11-29 00:08:08 +02:00
|
|
|
import numpy as np
|
2019-11-28 18:54:24 +02:00
|
|
|
import matplotlib.pyplot as plt
|
2019-11-29 00:34:41 +02:00
|
|
|
|
|
|
|
from collections import namedtuple
|
2019-11-29 00:08:08 +02:00
|
|
|
from shapely.geometry import LineString, asPolygon
|
|
|
|
from descartes import PolygonPatch
|
2019-11-28 18:54:24 +02:00
|
|
|
|
2019-11-28 19:55:27 +02:00
|
|
|
from measure import *
|
2019-11-28 18:54:24 +02:00
|
|
|
|
2019-11-29 00:46:31 +02:00
|
|
|
juosta = namedtuple('juosta', ['plotis', 'kryptis', 'dashes', 'spalva'])
|
|
|
|
kelias = namedtuple('kelias', ['virsunes', 'plotis', 'kat', 'dashes', 'spalva', 'juostos'])
|
2019-11-28 18:54:24 +02:00
|
|
|
|
2019-11-29 00:59:37 +02:00
|
|
|
CONTINUOUS = (1,0)
|
|
|
|
DASHDOTX2 = (10,3,2,3)
|
|
|
|
DASHED = (100,20)
|
|
|
|
|
2019-11-28 22:45:37 +02:00
|
|
|
|
2019-11-29 00:34:41 +02:00
|
|
|
a08 = kelias(
|
2019-11-29 00:46:31 +02:00
|
|
|
virsunes=[1,2,3],
|
|
|
|
plotis=A08_plotis,
|
2019-11-29 00:34:41 +02:00
|
|
|
kat=KAT1,
|
2019-11-29 00:59:37 +02:00
|
|
|
dashes=DASHDOTX2,
|
2019-11-29 00:46:31 +02:00
|
|
|
spalva='red',
|
|
|
|
juostos=(
|
2019-11-29 00:59:37 +02:00
|
|
|
juosta(L6+L5+L4, 'right', DASHED, 'lightgreen'),
|
|
|
|
juosta(L6+L5, 'right', DASHED, 'lightgreen'),
|
|
|
|
juosta(L6, 'right', CONTINUOUS, 'black'),
|
|
|
|
juosta(L7, 'left', CONTINUOUS, 'black'),
|
|
|
|
juosta(L7+L8, 'left', DASHED, 'lightgreen'),
|
|
|
|
juosta(L7+L8+L9, 'left', DASHED, 'lightgreen'),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
|
|
|
|
a05 = kelias(
|
|
|
|
virsunes=[4,5,6,7,8,9,10],
|
|
|
|
plotis=A05_plotis,
|
|
|
|
kat=KAT2,
|
|
|
|
dashes=DASHDOTX2,
|
|
|
|
spalva='red',
|
|
|
|
juostos=(
|
|
|
|
juosta(L3, 'right', CONTINUOUS, 'brown'),
|
|
|
|
juosta(L2, 'left', CONTINUOUS, 'brown'),
|
2019-11-29 00:34:41 +02:00
|
|
|
),
|
2019-11-29 00:08:08 +02:00
|
|
|
)
|
2019-11-29 00:34:41 +02:00
|
|
|
|
2019-11-29 00:46:31 +02:00
|
|
|
a03 = kelias(
|
|
|
|
virsunes=[11,12,13,14,15,16,17,18],
|
|
|
|
plotis=A03_plotis,
|
|
|
|
kat=KAT3,
|
2019-11-29 00:59:37 +02:00
|
|
|
dashes=CONTINUOUS,
|
2019-11-29 00:46:31 +02:00
|
|
|
spalva='pink',
|
|
|
|
juostos=(
|
2019-11-29 00:59:37 +02:00
|
|
|
juosta(L1, 'right', DASHED, 'pink'),
|
2019-11-29 00:46:31 +02:00
|
|
|
),
|
|
|
|
)
|
|
|
|
|
2019-11-29 00:59:37 +02:00
|
|
|
g11 = kelias(
|
|
|
|
virsunes=[19,20,21,22,23],
|
|
|
|
plotis=G11_plotis,
|
|
|
|
kat=KAT4,
|
|
|
|
dashes=CONTINUOUS,
|
|
|
|
spalva='red',
|
|
|
|
juostos=(
|
|
|
|
juosta(L10+L11, 'right', CONTINUOUS, 'blue'),
|
|
|
|
juosta(L11, 'right', CONTINUOUS, 'lightblue'),
|
|
|
|
juosta(L12, 'left', CONTINUOUS, 'lightblue'),
|
|
|
|
juosta(L12+L13, 'left', CONTINUOUS, 'blue'),
|
|
|
|
),
|
|
|
|
)
|
2019-11-29 00:46:31 +02:00
|
|
|
|
2019-11-29 14:11:51 +02:00
|
|
|
N, E, S, W = (0,15), (15,0), (0,-15), (-15,0)
|
|
|
|
point_annotations = {
|
|
|
|
1: S, 2: E, 3: N, 4: E,
|
|
|
|
5: N, 6: S, 7: S, 8: N,
|
|
|
|
9: E, 10: N, 11: N, 12: N,
|
|
|
|
13: S, 14: W, 15: N, 16: N,
|
|
|
|
17: N, 18: E, 19: N, 20: S,
|
|
|
|
21: N, 22: N, 23: E, 24: N,
|
|
|
|
}
|
2019-11-29 00:46:31 +02:00
|
|
|
|
2019-11-29 00:59:37 +02:00
|
|
|
# implementacija
|
|
|
|
fig, ax = plt.subplots()
|
2019-11-29 14:11:51 +02:00
|
|
|
plt.grid(True)
|
2019-11-29 00:59:37 +02:00
|
|
|
|
2019-11-29 14:11:51 +02:00
|
|
|
# taškų anotacijos
|
|
|
|
for v in vertices:
|
|
|
|
ax.annotate(v.point, xy=v.xy, zorder=99, textcoords='offset points', xytext=point_annotations[v.point])
|
|
|
|
|
|
|
|
# kelių piešimas
|
2019-11-29 00:59:37 +02:00
|
|
|
for kelias in [a08, a05, a03, g11]:
|
2019-11-29 00:34:41 +02:00
|
|
|
# ašis
|
2019-11-29 00:46:31 +02:00
|
|
|
kelias_line = LineString([Points[i].xy for i in kelias.virsunes ])
|
|
|
|
ax.plot(*kelias_line.xy, linewidth=2, dashes=kelias.dashes, color=kelias.spalva, zorder=kelias.kat)
|
2019-11-29 00:34:41 +02:00
|
|
|
# offset'ai
|
2019-11-29 00:46:31 +02:00
|
|
|
offset_multiplier = kelias.plotis/(kelias.juostos[0].plotis + kelias.juostos[-1].plotis)
|
2019-11-29 00:34:41 +02:00
|
|
|
offset_lines = []
|
2019-11-29 00:46:31 +02:00
|
|
|
for offset in kelias.juostos:
|
|
|
|
l = kelias_line.parallel_offset(offset.plotis * offset_multiplier, offset.kryptis, join_style=2)
|
2019-11-29 00:34:41 +02:00
|
|
|
offset_lines.append(l)
|
2019-11-29 00:46:31 +02:00
|
|
|
ax.plot(*l.xy, linewidth=.5, dashes=offset.dashes, color=offset.spalva, zorder=kelias.kat)
|
2019-11-29 00:34:41 +02:00
|
|
|
# kelio poligonas su plotu
|
|
|
|
kelias_poly = np.vstack((offset_lines[0].coords, offset_lines[-1].coords))
|
|
|
|
ax.add_patch(PolygonPatch(asPolygon(kelias_poly), fc='white', zorder=kelias.kat, linewidth=0))
|
|
|
|
|
2019-11-29 00:08:08 +02:00
|
|
|
|
2019-11-28 18:54:24 +02:00
|
|
|
plt.show()
|