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

Followers 1

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

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

##### Link to comment
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:

Edited by HHL
##### Link to comment

I will try base 31. Thank you.

##### Link to comment

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

Have a look here:

##### Link to comment
1 minute ago, Die Batzen said:

Have a look here:

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

I guess you all know what you are talking about, I sure don't!

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

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.