Merge pull request #5048 from Roy-043/Draft-Fix-annotation-scale-to-label-issue

Draft: Fix annotation scale to label issue.
This commit is contained in:
Chris Hennes
2021-09-20 07:47:38 -05:00
committed by GitHub

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):
"""