LL_X = -149.348145; longitude

LAYER = 13; zoom level

answers should be

697 for xtile and 2311 for ytile;

I have the xtile working in FileMaker. I believe I am having problems with the deg2rad()conversion. Any help would be appreciated. Both PHP statements work perfectly in PHP.

The FM conversion for ytile is off by about a third.

PHP:

$ytile = floor((1 - log(tan(deg2rad($lat)) + 1 / cos(deg2rad($lat))) / pi()) /2 * pow(2, $zoom));

FM:

Floor((1 - Log(Tan( LL_Y * (Pi / 180)) + 1 / Cos(LL_Y * (Pi / 180))) / Pi) /2 * (2 ^ LAYER))

*/ The FileMaker conversion of the xtile works, so I believe I have the pow() correct. */

PHP:

$xtile = floor((($lon + 180) / 360) * pow(2, $zoom));

FM:

Floor(((LL_X + 180) / 360) * (2 ^ LAYER))