New getGeographUrl function - update for passing 1M photos

15 views
Skip to first unread message

barryhunter

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

So
http://s3.www.geograph.org.uk/photos/97/11/971163_f4c1bc89_120x120.jpg
becomes
http://s3.geograph.org.uk/geophotos/00/97/11/971163_f4c1bc89_120x120.jpg

and 1M will be
http://s0.geograph.org.uk/geophotos/01/00/00/1000000_xxxxxxx_120x120.jpg


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);
$fullpath="/geophotos/$yz/$ab/$cd/{$abcdef}_{$hash}";

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

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



Reply all
Reply to author
Forward
0 new messages