add rectangle
This commit is contained in:
parent
dc6046fc68
commit
6d3fcd2ff0
@ -22,15 +22,15 @@ endef
|
||||
|
||||
define gpkg2pdf
|
||||
$(1).pdf: $(1).gpkg
|
||||
./layer2img.py --size=$(2) --infile=$(1).gpkg --outfile $(1).pdf
|
||||
./layer2img.py $(2) --infile=$(1).gpkg --outfile $(1).pdf
|
||||
endef
|
||||
|
||||
$(eval $(call algo2img,sinewave,douglas,52x12))
|
||||
$(eval $(call algo2img,sinewave,visvalingam,52x12))
|
||||
$(eval $(call algo2img,zeimena,douglas,52x74))
|
||||
$(eval $(call algo2img,zeimena,visvalingam,52x74))
|
||||
$(eval $(call gpkg2pdf,sinewave,52x15))
|
||||
$(eval $(call gpkg2pdf,zeimena,148x210))
|
||||
$(eval $(call gpkg2pdf,sinewave,--size=52x15))
|
||||
$(eval $(call gpkg2pdf,zeimena,--size=148x210 --rect $(CROSSING)))
|
||||
|
||||
sinewave.gpkg: sinewave.py
|
||||
./sinewave.py
|
||||
|
@ -5,6 +5,7 @@ import argparse
|
||||
import geopandas
|
||||
import psycopg2
|
||||
import matplotlib.pyplot as plt
|
||||
import matplotlib.patches as patches
|
||||
|
||||
INCH = 25.4 # mm
|
||||
|
||||
@ -32,6 +33,9 @@ def parse_args():
|
||||
parser.add_argument(
|
||||
'--clip', type=float, nargs=4,
|
||||
metavar=('xmin', 'ymin', 'xmax', 'ymax'))
|
||||
parser.add_argument(
|
||||
'--rect', type=float, nargs=4, help="Overlay a rectangle",
|
||||
metavar=('xmin', 'ymin', 'xmax', 'ymax'))
|
||||
return parser.parse_args()
|
||||
|
||||
|
||||
@ -45,9 +49,17 @@ def main():
|
||||
f = geopandas.read_file(args.infile)
|
||||
fig, ax = plt.subplots()
|
||||
f.plot(ax=ax, figsize=args.size)
|
||||
if args.clip:
|
||||
ax.set_xlim(left=args.clip[0], right=args.clip[2])
|
||||
ax.set_ylim(bottom=args.clip[1], top=args.clip[3])
|
||||
if c := args.clip:
|
||||
ax.set_xlim(left=c[0], right=c[2])
|
||||
ax.set_ylim(bottom=c[1], top=c[3])
|
||||
if r := args.rect:
|
||||
w, h = r[2] - r[0], r[3] - r[1]
|
||||
rect = patches.Rectangle(
|
||||
(r[0], r[1]),
|
||||
w, h,
|
||||
linewidth=1,edgecolor='r',facecolor='none')
|
||||
ax.add_patch(rect)
|
||||
|
||||
ax.axis('off')
|
||||
ax.margins(0, 0)
|
||||
fig.tight_layout(0)
|
||||
|
Loading…
Reference in New Issue
Block a user