mittagessen/kraken

Region without bounds crashes at serialization

PonteIneptique opened this issue · 0 comments

Currently, any file with no bounds crashes at serialization time:

bpt6k1090049w.zip

│ /home/thibault/dev/release-the-krakens/krakenv/lib/python3.10/site-packages/kraken/serialization │
│ .py:156 in serialize                                                                             │
│                                                                                                  │
│   153 │   │   │   regs_with_lines.add(reg.id)                                                    │
│   154 │   │   │   print(reg)                                                                     │
│   155 │   │   │   region = {'id': reg.id,                                                        │
│ ❱ 156 │   │   │   │   │     'bbox': max_bbox([reg.boundary]),                                    │
│   157 │   │   │   │   │     'boundary': [list(x) for x in reg.boundary],                         │
│   158 │   │   │   │   │     'tags': reg.tags,                                                    │
│   159 │   │   │   │   │     'lines': [],                                                         │
│                                                                                                  │
│ /home/thibault/dev/release-the-krakens/krakenv/lib/python3.10/site-packages/kraken/serialization │
│ .py:65 in max_bbox                                                                               │
│                                                                                                  │
│    62 │   │   A box (x0, y0, x1, y1) covering all bounding boxes in the input                    │
│    63 │   │   argument.                                                                          │
│    64 │   """                                                                                    │
│ ❱  65 │   flat_box = [point for pol in boxes for point in pol]                                   │
│    66 │   flat_box = [x for point in flat_box for x in point]                                    │
│    67 │   xmin, xmax = min(flat_box[::2]), max(flat_box[::2])                                    │
│    68 │   ymin, ymax = min(flat_box[1::2]), max(flat_box[1::2])                                  │
│                                                                                                  │
│ /home/thibault/dev/release-the-krakens/krakenv/lib/python3.10/site-packages/kraken/serialization │
│ .py:65 in <listcomp>                                                                             │
│                                                                                                  │
│    62 │   │   A box (x0, y0, x1, y1) covering all bounding boxes in the input                    │
│    63 │   │   argument.                                                                          │
│    64 │   """                                                                                    │
│ ❱  65 │   flat_box = [point for pol in boxes for point in pol]                                   │
│    66 │   flat_box = [x for point in flat_box for x in point]                                    │
│    67 │   xmin, xmax = min(flat_box[::2]), max(flat_box[::2])                                    │
│    68 │   ymin, ymax = min(flat_box[1::2]), max(flat_box[1::2])                                  │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
TypeError: 'NoneType' object is not iterable

Seems to be the same issue as #609