Jump to content

New Cache numbering system?


pizzachef

Recommended Posts

I've noticed that the URLs for the individual cache pages look different since the new supercool Nearest Cache Page came out. I thought before the URL had the base 10 number for the 4 character GCxxxx number (or am I way wrong). Did we finally run out of numbers? Or are the new URLs just a better way of doing things...

If this has been discussed already, I'm sure someone will point me in the right direction icon_wink.gif

 

-pizzachef

Link to comment

It used to be hex based. Since we passed GCFFFF, it is now...base-31 or something, I forget exactly. Not all letters are being used, in an effort to avoid nasty words as waypoints and confusing 0/O and 1/I.

 

Edit: D'oh! Misread the question.

 

Flat_MiGeo_B88.gif

Well the mountain was so beautiful that this guy built a mall and a pizza shack

Yeah he built an ugly city because he wanted the mountain to love him back -- Dar Williams

 

[This message was edited by Dinoprophet on June 17, 2003 at 07:32 AM.]

Link to comment

quote:
Originally posted by flowerman:

I too am having problems with the login. My cache page says that I am loged in but when I search by zip code it suddenly says "You are not logged in".

Using Netscape 4.79.


 

I believe this was fixed, though its a bit off-topic icon_wink.gif

 

frog.gif Jeremy Irish

Groundspeak - The Language of Location

Link to comment

Okay, lots of questions in that one post, pc... I'll see if I can hit them all...

 

There are three styles of URLs you can use to get to a particular cache page: id, waypoint, and GUID.

 

Originally, the URLs all ended with "?id=#", where "#" is the decimal equivalent of the value of the GCID. These still work, but you have to use a new function to calculate the ID number of GCIDs > GCFFFF, since from GCG000 upward, they are not hex.

 

After "?id=#" came "?wp=gc____". I first noticed this type of URL in my Pocket Query results. By using this way of simply specifying the canonical waypoint name for the cache, you avoid having to do any messy math. If you know the GCID, this is the easiest way of pulling up the cache page.

 

Finally, the new nearest caches page uses the third type of URL, a GUID. For anyone who doesn't know, a GUID is a "globally unique ID", or in simple terms, a universal serial number. You would never type in this style URL, since the GUID string (in "?guid=___...") makes even Microsoft product keys look short.

 

Here's an example of the three URLs that point to Things that Grow

Finally, the new GCIDs are based on Base31 math with the digit set "0123456789ABCDEFGHJKMNPQRTVWXYZ". If a GCID is <= GCFFFF, you just use the old hex->dec conversion to get the ID, and if the GCID > GCFFFF, you convert the four Base31 digits to decimal and subtract the offset 411120. (You must subtract the offset so that GCG000 == 65536, since GCFFFF is 65535, and GCG000 is the next cache in line.)

 

(Well, I *think* I covered your entire post. Hehe.)

 

[[[ ClayJar Networks ]]]

Home of Watcher downloads, Official Geocaching Chat, and the Geocache Rating System

Link to comment

Sheeesh...is that all? I thought it would be more complicated than that icon_wink.gif

So the waypoint url format is new? I've never noticed that before, but I like it. I don't usually convert hex to decimal in my head, so i'd always have to search for the waypoint...now it seems i can just type it in the url. That's good because it seems my TI-85 doesn't have the Base31 number system anyway, and in my life, I've only been able to memorize 2 or 3 Microsoft product keys.

The only thing I don't get is the offset 411120. Is that not a decimal number? because it sure is innocent-looking.

 

-pizzachef

Link to comment

quote:
Originally posted by jef:

Ok, but how do I convert from the new GUIDs back to old-style decimal IDs? Or should I just live with the new 36-character GUIDs?


Sorry, there is no direct conversion between a decimal ID and a GUID. However. you can convert between the GCxxxx waypoint names and decimal IDs as Clayjar described above.

 

frog.gif Elias

Link to comment

I've been meaning to write this for sometime. When I saw this thread I decided to go ahead and do it. It's lightly commented. It's written in VBScript and tested in WSH. It is case blind and encodes and decodes numeric cache ids to/from "GCxxxx" strings. The only bug which I didn't other to fix is that if you feed it a string like "GC100G" it will cheerfully "convert" it. It does check "GC" strings for valid characters so it won't accept something like "GCG4TL" because "L" is not a valid character.

 

It also includes code at the beginning to check the conversion both ways for all valid cache ids. FYI: With the new system the maximum cache number will be 512400, or "GCZZZZ".

 

Option Explicit' place multipliersConst	Place4	= 1Const	Place3	= 31Const	Place2	= 961Const	Place1	= 29791Const	Base31 = "0123456789ABCDEFGHJKMNPQRTVWXYZ"Const	ERR_LENGTH    = -1Const	ERR_NOTGC     = -2Const	ERR_NOTGCCHAR = -3Dim	iPlaces( 4 )'  ==== This code to verify proper operation ====MainSub Main  Dim iCache, strGC, iId, iErrors  iErrors = 0  For iCache = 1 to 512400    If (iCache Mod 10000) = 0 then WScript.Echo iCache & " " & IDToGC( iCache )    strGC = IDToGC( iCache )    iId = GCToID( strGC )    If ( iCache <> iId ) Then      WScript.Echo iCache & " " & strGC & " " & iId      iErrors = iErrors + 1    End If  Next  WScript.Echo "Errors: " & iErrorsEnd Sub'  ==== End of Test code ========================''' Convert numeric cache Id to a "GCxxxx" string''  Usage:  strGC = IDToGC( cacheid )Function IDToGC( ByVal iId )  Dim strGC  Dim chrDig1, chrDig2, chrDig3, chrDig4  If iId <= 65535 Then  ' simple case is old system    strGC = Hex( iId )    While ( Len( strGC ) < 4 )      strGC = "0" & strGC    Wend    strGC = "GC" & strGC  Else  ' new system    iPlaces(1) = Place1	' Make sure it's base 31    iPlaces(2) = Place2    iPlaces(3) = Place3    iPlaces(4) = Place4    iId = iId - 65536	' remove the base-16 bias from '10000'    iId = iId + 476656	' add a base-31 bias to 'G000'    chrDig1 = Int( iId / Place1 )    iId = iId - ( ChrDig1 * Place1 )    chrDig2 = Int( iId / Place2 )    iId = iId - ( ChrDig2 * Place2 )    chrDig3 = Int( iId / Place3 )    iId = iId - ( ChrDig3 * Place3 )    chrDig4 = Int( iId / Place4 )    iId = iId - ( ChrDig4 * Place4 )    strGC = "GC" & Mid( Base31, chrDig1 + 1, 1 ) & Mid( Base31, chrDig2 + 1, 1 ) & Mid( Base31, chrDig3 + 1, 1 ) & Mid( Base31, chrDig4 + 1, 1 )  End If  IDToGC = strGCEnd Function''' Convert "GCxxxx" cache string to numeric cache Id''  Usage:  cacheid = GCToID( "GCxxxx" )Function GCToID( ByVal strGC )  Dim iPos  Dim iId  Dim iResult  Dim iChrVal  Dim iBase  ' check for a valid geocache  iResult = IsGC( strGC )  If ( iResult <> 1 ) Then    GCToID = iResult    Exit Function  End If  If ( Len( strGC ) = 6 ) Then    strGC = Mid( strGC, 3, 4 )  End If  strGC = UCase( strGC )  ' old or new system?  If ( Left( strGC, 1 ) < "G" ) Then    iPlaces(1) = 4096	' Base 16    iPlaces(2) = 256    iPlaces(3) = 16    iPlaces(4) = 1  Else    iPlaces(1) = Place1	' Base 31    iPlaces(2) = Place2    iPlaces(3) = Place3    iPlaces(4) = Place4  End If  iId = 0  For iPos = 1 to 4    iChrVal = CInt( Instr( 1, Base31, Mid( strGC, iPos, 1 ) ) - 1 )    iId = iId + ( iPlaces(iPos) * iChrVal )  Next  If iPlaces(1) = Place1 Then    iId = iId - 476656	' remove the base-31 bias from 'G000'    iId = iId + 65536	' add a base-16 bias to '10000'  End If  GCToId = iIdEnd Function'''  Checks a "GCxxxx" string for validity''  Usage:  result = IsGC( "GCxxxx" )Function IsGC( ByVal strGC )  Dim iLen, iPos  iLen = Len( strGC )  If ( iLen <> 4 ) and ( iLen <> 6 ) Then    IsGC = ERR_LENGTH    Exit Function  End If  strGC = UCase( strGC )  If ( iLen = 6 ) Then    If ( Left( strGC, 2 ) <> "GC" ) Then      IsGC = ERR_NOTGC      Exit Function    End If    strGC = Mid( strGC, 3, 4 )    iLen = 4  End If  For iPos = 1 to iLen    If ( Instr( 1, Base31, Mid( strGC, iPos, 1 ) ) = 0 ) Then      IsGC = ERR_NOTGCCHAR      Exit Function    End If  Next  IsGC = 1End Function
Link to comment
Guest
This topic is now closed to further replies.
×
×
  • Create New...