Skip to content

Commit

Permalink
Fixed edge case.
Browse files Browse the repository at this point in the history
  • Loading branch information
alanwatsonforster committed Sep 24, 2023
1 parent 5e51e21 commit 7eee289
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions airpower/hexcode.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,7 @@ def fromxy(x, y):

else:

if x % 1 == 0:
n0 = fromxy(x, y + 0.5)
n1 = fromxy(x, y - 0.5)
elif x % 2 == 0.5 and y % 1 == 0.25:
if x % 2 == 0.5 and y % 1 == 0.25:
n0 = fromxy(x - 0.5, y - 0.25)
n1 = fromxy(x + 0.5, y + 0.25)
elif x % 2 == 0.5 and y % 1 == 0.75:
Expand All @@ -150,6 +147,15 @@ def fromxy(x, y):
elif x % 2 == 1.5 and y % 1 == 0.75:
n0 = fromxy(x - 0.5, y - 0.25)
n1 = fromxy(x + 0.5, y + 0.25)
elif apmap.tosheet(x, y + 0.5) == None:
n0 = fromxy(x, y - 0.5)
n1 = n0 - 1
elif apmap.tosheet(x, y - 0.5) == None:
n0 = fromxy(x, y + 0.5)
n1 = n0 + 1
else:
n0 = fromxy(x, y - 0.5)
n1 = fromxy(x, y + 0.5)

if n0 < n1:
return "%s/%s" % (n0, n1)
Expand Down

0 comments on commit 7eee289

Please sign in to comment.