New getGeographUrl function - update for passing 1M photos

Skip to first unread message


Sep 21, 2008, 4:03:22 PM9/21/08
to Geograph-API-Users
Pretty soon we will be passing 1 million photos, (whoop!) and as such
the current folder structure for storing photos, which will while will
continue to work, is not ideal, so we are implementing a small change
to the folder structure.

This only affects people building their own url to the image file, the
API of course will simply return the appropiate url. I've previouslly
given a simple php function to calculate the url, so a new version is
included below.


and 1M will be

NOTE: we will continue to serve existing photos on the current
structure, but images past 1M will use the new structure. And for a
time photos will be available on both, so its not urgent that you
update your code, as long as it follows the old getGeographUrl exactly
it will work even past 1M - or at least upto image id 1.1M (which is
maintained via symlinks)

... see you again when we near 100M images.... :)


function getGeographUrl($gridimage_id,$hash,$size ='small') {

$yz=sprintf("%02d", floor($gridimage_id/1000000));
$ab=sprintf("%02d", floor(($gridimage_id%1000000)/10000));
$cd=sprintf("%02d", floor(($gridimage_id%10000)/100));
$abcdef=sprintf("%06d", $gridimage_id);

$server = "http://s".($gridimage_id%4)."";

switch($size) {
case 'full': return "
$fullpath.jpg"; break;
case 'med': return "$server{$fullpath}_213x160.jpg";
case 'small':
default: return "$server{$fullpath}_120x120.jpg";

Reply all
Reply to author
0 new messages