Draft: Fix annotation scale to label issue.

The scale_to_label function did not handle scale 5:1, 10:1 or 20:1 properly.
This commit is contained in:
Roy-043
2021-09-20 11:01:59 +02:00
committed by GitHub
parent b8a4d1e07e
commit 07eced129a

View File

@@ -97,14 +97,22 @@ def scale_to_label(scale):
"""
transform a float number into a 1:X or X:1 scale and return it as label
"""
f = 1/scale
f = round(f,2)
f = f.as_integer_ratio()
if f[1] == 1 or f[0] == 1:
label = str(f[1]) + ":" + str(f[0])
return label
f = round(scale, 2)
if f == 1.0:
return "1:1"
elif f > 1.0:
f = f.as_integer_ratio()
if f[1] == 1:
return str(f[0]) + ":1"
else:
return str(scale)
else:
return str(scale)
f = round(1/scale, 2)
f = f.as_integer_ratio()
if f[1] == 1:
return "1:" + str(f[0])
else:
return str(scale)
def label_to_scale(label):
"""