diff --git a/pygeoapi/provider/speckle_utils/patch/server.py b/pygeoapi/provider/speckle_utils/patch/server.py index f1050e0..d2102a2 100644 --- a/pygeoapi/provider/speckle_utils/patch/server.py +++ b/pygeoapi/provider/speckle_utils/patch/server.py @@ -169,13 +169,34 @@ class ServerTransport(AbstractTransport): endpoint, data={"objects": json.dumps(new_children_ids)}, stream=True ) r.encoding = "utf-8" - lines = r.iter_lines(decode_unicode=True) + lines = r.iter_lines(decode_unicode=True, delimiter="},{") # iter through returned objects saving them as we go target_transport.begin_write() - for line in lines: - if line: - hash, obj = line.split("\t") + all_lines = [line for _,line in enumerate(lines)] + + # fix wrongly split lines + for i, line in enumerate(all_lines): + if line and i!= 0 and (len(line)<=10 or'"id": "' not in line[:10]): + # find the last line with ID + matching_index = -1 + for k, id_line in enumerate(all_lines): + if k10 and '"id": "' in line[:10]: + hash = line.split('"id": "')[1].split('"')[0] + obj = "{" + line + "}" + if i==0: + obj = obj[2:] + elif i==len(all_lines)-1: + obj = obj[:-2] target_transport.save_object(hash, obj) target_transport.save_object(id, root_obj_serialized)