diff options
author | Daniel Friesel <derf@finalrewind.org> | 2020-12-28 14:35:59 +0100 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2020-12-28 14:35:59 +0100 |
commit | 062456c25f078c3296c927640eb977dc828631ad (patch) | |
tree | c0d03371b5d680011c13d77eb25f757faf92297d | |
parent | 08ff22d0a5ad5dde52977c837588e058de0abe04 (diff) |
export-carriage: double decker support
-rwxr-xr-x | lib/export-carriage.py | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/export-carriage.py b/lib/export-carriage.py index 88797b2..a0f6571 100755 --- a/lib/export-carriage.py +++ b/lib/export-carriage.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 import numpy as np +import os import subprocess import sys @@ -43,8 +44,19 @@ def main(infile, *outfiles): ys = list() for o in objects: - if o.is_path() and o.h > 2 and o.h < 4 and o.w > 10: + if o.is_path() and o.h > 2 and o.h < 4 and o.w > 9: ys.append(o.y) + + ys = np.array(ys, dtype=np.int64) + + if "double_decker_export" in os.environ: + # the first object is the "svg2" element describing the entire document + split = objects[0].h * 0.6 + if os.environ["double_decker_export"] == "lower": + ys = ys[ys >= split] + else: + ys = ys[ys <= split] + bins = np.bincount(ys) candidates = list(filter(lambda i: bins[i] > 2, range(len(bins)))) |