first roads with good alpha

This commit is contained in:
Motiejus Jakštys 2019-11-29 00:08:08 +02:00
parent a761a36c46
commit 67c74d71f1

View File

@ -1,6 +1,9 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import numpy as np
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
from shapely.geometry import LineString from shapely.geometry import LineString, asPolygon
from shapely.coords import CoordinateSequence
from descartes import PolygonPatch
from measure import * from measure import *
@ -9,19 +12,23 @@ fig, ax = plt.subplots()
A08_l = LineString([Points[i].xy for i in [1,2,3] ]) A08_l = LineString([Points[i].xy for i in [1,2,3] ])
A08_multiplier = A08_plotis/(L4+L5+L6+L7+L8+L9) A08_multiplier = A08_plotis/(L4+L5+L6+L7+L8+L9)
A08_offsetR1 = A08_l.parallel_offset(L6*A08_multiplier, 'right', join_style=2) def offset(width, direction):
A08_offsetR2 = A08_l.parallel_offset((L6+L5)*A08_multiplier, 'right', join_style=2) return A08_l.parallel_offset(width * A08_multiplier, direction, join_style=2)
A08_offsetR3 = A08_l.parallel_offset((L6+L5+L4)*A08_multiplier, 'right', join_style=2) offsets = (
A08_offsetL1 = A08_l.parallel_offset(L7*A08_multiplier, 'left', join_style=2) (offset(L6+L5+L4, 'right'), (5,3), 'lightgreen'),
A08_offsetL2 = A08_l.parallel_offset((L7+L8)*A08_multiplier, 'left', join_style=2) (offset(L6+L5, 'right'), (5,3), 'lightgreen'),
A08_offsetL3 = A08_l.parallel_offset((L7+L8+L9)*A08_multiplier, 'left', join_style=2) (offset(L6, 'right'), (1,0), 'black'),
ax.plot(*A08_l.xy, linewidth=2, dashes=[5,2,2,5], color='red', zorder=KAT3) (offset(L7, 'left'), (1,0), 'black'),
ax.plot(*A08_offsetR1.xy, linewidth=.5, zorder=KAT1, color='black') (offset(L7+L8, 'left'), [5,3], 'lightgreen'),
ax.plot(*A08_offsetR2.xy, linewidth=.5, dashes=[5,3], color='lightgreen', zorder=KAT1) (offset(L7+L8+L9, 'left'), [5,3], 'lightgreen'),
ax.plot(*A08_offsetR3.xy, linewidth=.5, dashes=[5,3], color='lightgreen', zorder=KAT1) )
ax.plot(*A08_offsetL1.xy, linewidth=.5, zorder=KAT1, color='black') for line, dashes, color in offsets:
ax.plot(*A08_offsetL2.xy, linewidth=.5, dashes=[5,3], color='lightgreen', zorder=KAT1) ax.plot(*line.xy, linewidth=.5, dashes=dashes, color=color, zorder=KAT1)
ax.plot(*A08_offsetL3.xy, linewidth=.5, dashes=[5,3], color='lightgreen', zorder=KAT1)
A08_poly = np.vstack((offsets[0][0].coords, offsets[-1][0].coords))
ax.add_patch(PolygonPatch(asPolygon(A08_poly), fc='white', zorder=KAT1, linewidth=0))
ax.plot(*A08_l.xy, linewidth=2, dashes=[5,2,2,5], color='red', zorder=KAT1)
A03_l = LineString([Points[i].xy for i in [11,12,13,14,15,16,17,18] ]) A03_l = LineString([Points[i].xy for i in [11,12,13,14,15,16,17,18] ])
A03_offsetR = A03_l.parallel_offset(A03_plotis, 'right', join_style=2) A03_offsetR = A03_l.parallel_offset(A03_plotis, 'right', join_style=2)