Google maps & Mapserver projection issue
joseolcese
jolcese at GMAIL.COM
Tue Jun 5 11:08:44 PDT 2007
Jan,
Thanks a lot for your responses!
I still have no success getting the right tile with mapscript or even
mapserv.
I implemented a code that Ei Fujioka sent me and this is the result:
I guess I've nailed down the problem to this:
**** .map with no PROJECTION and latlon coordinates:
http://127.0.0.1/cgi-bin/mapserv?map=/mapear/map/mapNoProjection.map&mode=map&mapext=-64.171142578125+-31.419288124288343+-64.1656494140625+-31.41460027631321
This gives me an image with some data printed -> OK
**** .map with PROJECTION and latlon coordinates:
http://127.0.0.1/cgi-bin/mapserv?map=/mapear/map/mapProjection.map&mode=map&mapext=-64.171142578125+-31.419288124288343+-64.1656494140625+-31.41460027631321
This gives me an image with NO data printed -> WRONG
Only difference between mapNoProjection.map and mapProjection.map is that
the second one has:
CONFIG PROJ_LIB '/usr/local/share/proj/'
PROJECTION
"init=esri:54004"
END
Now, using the code to convert coordinates to mercator meters, I got
-64.171142578125+-31.419288124288343+-64.1656494140625+-31.41460027631321
equal to:
-7143498.91542,-3665050.56612,-7142887.41919,-3664442.05663
But if I request
**** .map with PROJECTION and mercator meters coordinates:
http://127.0.0.1/cgi-bin/mapserv?map=/mapear/map/mapProjection.map&mode=map&mapext=-7143498.91542+-3665050.56612+-7142887.41919+-3664442.05663
This gives me an image with NO data printed -> WRONG
Any ideas??
Jose
Jan Hartmann wrote:
>
> 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* < j.l.h.hartmann at uva.nl
>> <mailto:j.l.h.hartmann at uva.nl>> 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);
>> > }
>> > ...
>> >
>> >
>> >
>>
>>
>
>
--
View this message in context: http://www.nabble.com/Google-maps---Mapserver-projection-issue-tf3852632.html#a10974827
Sent from the Mapserver - User mailing list archive at Nabble.com.
More information about the MapServer-users
mailing list