With Mapscript it's easy:
function ll2merc($lon,$lat) {
$projIn = ms_newprojectionobj("proj=latlong");
$projOut = ms_newprojectionobj("proj=merc");
$p = ms_newpointobj();
$p->setXY($lon,$lat);
$p->project($projIn, $projOut);
return($p);
}
If you don't use Mapscript, you have to do the computations in
Javascript. There is a project to implement the Proj package in Javascript:
http://lists.maptools.org/pipermail/proj/2006-February/002125.html
but I have never worked with it
Jan
Jose Olcese wrote:
Hi Jan,
I really appreciate your help!. It seems that it might be the problem!.
I'll try sending Mercator Coordinates in meters as the mapexp parameter
of mapserv.
Do you have the algorithm for converting it?
Thanks again
Jose
On 6/4/07, *Jan Hartmann* < [EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>> wrote:
Hi Jose
Epsg 54004 is the classic Mercator projection. The units it uses are not
degrees but meters (only at the equator these are real meters). Using
proj I get the following boundary values (note that -180W/-90S and
180E/90N cannot be represented in a Mercator projection):
proj +init=epsg:54004
-170 -80
-18924313.43 -15496570.74
170 80
18924313.43 15496570.74
Hope this helps,
Jan
Dr. J. Hartmann
Department of Geography
University of Amsterdam
joseolcese wrote:
> Hi
>
> I'm trying to use Google maps & Mapserver with partial success...
> I have a .shp configured in mapserver and I can get a transparent
tile from
> an html page where it load google satellite view and my tiles.
> The problem is that I wasn't using any projection on my .map so
every tile
> was a little distorted.
> I added the epsg:54004 project to the .map but now the tiles are
empty.
>
> Do you have any idea why this my be happening?
>
> Thanks
> Jose Olcese
>
> .map:
> IMAGETYPE PNG
> EXTENT -64.20 -31.41 -64.19 -31.40
> SIZE 256 256
> SHAPEPATH '/ms4w/apps/tutorial/data_jose'
> FONTSET '/ms4w/apps/tutorial/fonts/fonts.list'
> TRANSPARENT ON
> CONFIG PROJ_LIB '/var/www/html/share/proj/'
> PROJECTION
> "init=esri:54004"
> END
> LAYER
> ...
> ...
>
>
> .html:
> ...
> ...
> tileCountry.getTileUrl=function(xy,zoom)
> {
> var lng = (-180+((xy.x+0.5)*(360/Math.pow(2,zoom))));
// -180
> +180
>
> var merclat_extent = 360/Math.pow(2,zoom);
> var l = 180 - (( xy.y+0.5) * merclat_extent);
> var e = Math.exp(2 * ( l * Math.PI) /180);
> e = (e - 1)/(e + 1);
> var lat = (Math.atan2(e, Math.sqrt(1 - (e * e))) *180 /
> Math.PI );
>
> return
> '
http://127.0.0.1/cgi-bin/mapserv?map=/ms4w/apps/tutorial/htdocs/map_test5.map&mode=map&mapxy=
<http://127.0.0.1/cgi-bin/mapserv?map=/ms4w/apps/tutorial/htdocs/map_test5.map&mode=map&mapxy=>'
> + lng + '+' + lat + '&buffer=' + ((360/Math.pow(2,zoom))/2);
> }
> ...
>
>
>