Jump to content

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


===sgb

Recommended Posts

Posted

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.

Posted (edited)
52 minutes ago, ===sgb said:

What is the conversion algorithm please

It's Base31. Groundspeak's reference code never contains: ISOUL

I use a GSAK macro to do the maths:

 

ce79dc6b7019dc5d5b9ae4ed1f54542e.png

Edited by HHL
Posted

No base 31 doesn't work.

16183305 remainder 0123456789ABCDEFGHJKMNPQRTVWXYZ (wanted)
522042 3 2 1
16840 2 1 W
543 7 6 0
17 16 F Z
0 17 G H
Posted
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.

Posted
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)
Posted
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).

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...