Skip to content

Instantly share code, notes, and snippets.

@ylashin
Created September 3, 2022 10:34
Show Gist options
  • Select an option

  • Save ylashin/bac0382cb79c7c58242143ba7da8ff30 to your computer and use it in GitHub Desktop.

Select an option

Save ylashin/bac0382cb79c7c58242143ba7da8ff30 to your computer and use it in GitHub Desktop.
def calculate_data_zorder_placement(items: List[DataItem]):
files = {}
for index, item in enumerate(items):
x, y = item.x, item.y
xb = f"{x:>03b}"
yb = f"{y:>03b}"
interleaved = f"{yb[0]}{xb[0]}{yb[1]}{xb[1]}{yb[2]}{xb[2]}"
zorder = int(interleaved, 2)
file_placement = zorder // 4
if not file_placement in files:
files[file_placement] = FileInfo([])
file = files[file_placement]
file.items.append(item)
adjust_file_info(file, item)
return files
zorder_organised_files = calculate_data_zorder_placement(items)
pprint(zorder_organised_files)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment