Skip to content

Commit

Permalink
Added Australian hexid->registration conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
ausmez committed Feb 3, 2017
1 parent ccd8fd5 commit 9d346f9
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions public_html/registrations.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ registration_from_hexid = (function () {
if (reg)
return reg;

reg = vh_reg(hexid);
if (reg)
return reg;

reg = numeric_reg(hexid);
if (reg)
return reg;
Expand Down Expand Up @@ -306,6 +310,25 @@ registration_from_hexid = (function () {
return reg + limited_alphabet.charAt(letter3) + limited_alphabet.charAt(offset % 24);
}

// Australia
function vh_reg(hexid) {
var offset = hexid - 0x7C0000;
if (offset < 0 || offset > 33325)
return null;

var reg = "VH-";

reg += full_alphabet.charAt(Math.floor(offset / 1296));
offset = offset % 1296;

reg += full_alphabet.charAt(Math.floor(offset / 36));
offset = offset % 36;

reg += full_alphabet.charAt(offset);

return reg;
}

return lookup;
})();

Expand Down

0 comments on commit 9d346f9

Please sign in to comment.