It seems that there is a wealth of knowledge on converting from Longitude and Latitude to X and Y coordinates, but not the reverse.
Here is a function of mine based on Kavrayskiy's math
float xp = kavraX(radians(pv.x), radians(pv.y))*FACTOR;
float yp = kavraY(radians(pv.x), radians(pv.y))*FACTOR;
// mapping -- this gives you screen X and Y coords from LAT and LONG
float kavraX (float latitude, float longitude) // Kavra for Kavrayskiy
// formula from http://en.wikipedia.org/wiki/Kavrayskiy_VII_projection
{
return ((3 * longitude) / TWO_PI)*sqrt(pow(PI, 2)/3 - pow(latitude, 2));
}
float kavraY (float latitude, float longitude)
{
return latitude*-1;
}
pv.x in this case could simply be 34 (for LA) ad pv.y would be -118 in that case. I'm having a hard time turning the equation around, though. Any ideas?