I'm trying to develop a page in ASP.NET that will act as a tile-server for a Google Map
It will pull a collection of latitude/longitude points from the database, then render them as small red dots on a transparent background, given a zoom-level (default: 15).
It will then return the result as a GIF-type image.
Have any algorithms or libraries been developed that allow me to take this set of latitudes/longitudes and convert them to a set of 2D pixel co-ordinates, given a zoom level?
(This is all being done server-side, so I can't use the Google Maps API.)
Update: Found a code-sample in Perl that does something similar:
http://blog.barros.ws/2009/03/06/convert-lat-lng-and-zoom-values-to-pixel-xy-on-a-map/
Trouble is, I don't know Perl, and don't really have the time to crack open a book and learn it.
Can anyone help me to decipher what's going on in this function?
sub Google_Coord_to_Pix
{
my $value = shift ;
my $lat = shift ;
my $lng = shift ;
my @d = ( ) ;
my $e = 0 ;
$d[1] = sprintf("%0.0f", $$value{'bmO'} + $lng * $$value{'pixLngDeg'} ) ;
$e = sin($lat * $$value{'Wa'}) ;
if( $e > 0.99999 )
{
$e = 0.99999 ;
}
if( $e < -0.99999 )
{
$e = -0.99999 ;
}
$d[0] = sprintf("%0.0f", $$value{'bmO'} + 0.5 * log((1 + $e) / (1 - $e)) * (-1) * $$value{'pixLngRad'} ) ;
return (@d) ;
}