/usr/share/doc/python-shapely-doc/html/code/multilinestring.py is in python-shapely-doc 1.5.17-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | from matplotlib import pyplot
from shapely.geometry import MultiLineString
from figures import SIZE
COLOR = {
True: '#6699cc',
False: '#ffcc33'
}
def v_color(ob):
return COLOR[ob.is_simple]
def plot_coords(ax, ob):
for line in ob:
x, y = line.xy
ax.plot(x, y, 'o', color='#999999', zorder=1)
def plot_bounds(ax, ob):
x, y = zip(*list((p.x, p.y) for p in ob.boundary))
ax.plot(x, y, 'o', color='#000000', zorder=1)
def plot_lines(ax, ob):
for line in ob:
x, y = line.xy
ax.plot(x, y, color=v_color(ob), alpha=0.7, linewidth=3, solid_capstyle='round', zorder=2)
fig = pyplot.figure(1, figsize=SIZE, dpi=90)
# 1: disconnected multilinestring
ax = fig.add_subplot(121)
mline1 = MultiLineString([((0, 0), (1, 1)), ((0, 2), (1, 1.5), (1.5, 1), (2, 0))])
plot_coords(ax, mline1)
plot_bounds(ax, mline1)
plot_lines(ax, mline1)
ax.set_title('a) simple')
xrange = [-1, 3]
yrange = [-1, 3]
ax.set_xlim(*xrange)
ax.set_xticks(range(*xrange) + [xrange[-1]])
ax.set_ylim(*yrange)
ax.set_yticks(range(*yrange) + [yrange[-1]])
ax.set_aspect(1)
#2: invalid self-touching ring
ax = fig.add_subplot(122)
mline2 = MultiLineString([((0, 0), (1, 1), (1.5, 1)), ((0, 2), (1, 1.5), (1.5, 1), (2, 0))])
plot_coords(ax, mline2)
plot_bounds(ax, mline2)
plot_lines(ax, mline2)
ax.set_title('b) complex')
xrange = [-1, 3]
yrange = [-1, 3]
ax.set_xlim(*xrange)
ax.set_xticks(range(*xrange) + [xrange[-1]])
ax.set_ylim(*yrange)
ax.set_yticks(range(*yrange) + [yrange[-1]])
ax.set_aspect(1)
pyplot.show()
|