Jump to content

How do I convert a "log id" (numeric) into the log page name (starts GL)?


===sgb

Recommended Posts

How do I convert a "log id" (numeric) into the log page name (starts GL)?

 

The "My Finds" GPX file you can download from the Pocket Query page includes log ids as a number (eg 16183305).

When you view that log on the website, it has an alphanumeric name starting GL (for the above log, it is GLHZ0W1)

 

It is not a simple "base 36" conversion between the two. What is the conversion algorithm please.

Link to comment
On 5/15/2021 at 8:24 AM, barefootjeff said:

Try the GC-code to/from ID conversion tool in the Geocaching Toolbox. It gives the correct result for the example you gave.

This is to convert between GCcode and ID (cache) not GLcode and ID (log). But as you say, it gets it right albeit GCHZ0W1 not GLHZ0W1. But that should be enough for me to determine the algorithm.

1..15 -> 1..F (hexadecimal)

16 -> 10 also hex. I'll experiment to find it. Thanks.

Link to comment
1 minute ago, Die Batzen said:

THANK you - that was what I was seeking. Excellent.

 

Base16_Characters = [
    '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
]

Base31_Characters = [
    '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F',
    'G', 'H', 'J', 'K', 'M', 'N', 'P', 'Q', 'R', 'T', 'V', 'W', 'X', 'Y', 'Z'
]


Id to Reference Code
--------------------

If Id < 65536
    ReferenceCode = Base16(Id) // Decimal to Hex
else
    ReferenceCode = Base31(Id + 411120)


    
Reference Code to Id
--------------------

if Prefix == "GC" 
    ReferenceCode = Replace(code, "S", "5")
    ReferenceCode = Replace(code, "O", "0")

ReferenceCode = RemovePrefix(ReferenceCode)
    
FirstChar = substring(ReferenceCode, 0, 1)
    
if len(ReferenceCode) >= 5 or FirstChar >= 'G'
    Id = Base31(ReferenceCode) - 411120
else
    Id = Base16(ReferenceCode)
Link to comment
47 minutes ago, ===sgb said:

This is to convert between GCcode and ID (cache) not GLcode and ID (log). But as you say, it gets it right albeit GCHZ0W1 not GLHZ0W1. But that should be enough for me to determine the algorithm.

 

The same encoding is used for caches (GC prefix), logs (GL prefix) and trackables (TB prefix).

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...