Mapserver - Mapscript PHP - Proj - Projection Parameter Question

Sven Borgers Sven.Borgers at KINEOINTERACTIVE.COM
Wed Aug 2 02:29:09 PDT 2006


Hi!
 
I am working on an application where I need to translate screen pixel xy
coordinates to latlon. The basic mapserver template variables seem to
give me the correct result, I can replicate that result with cs2cs but
have so far not been able to get that out of the mapscript php project
function. Any pointers would be greatly appreciated.
 
I have a very simple mapfile with following projection spec and no
projection in the layers:
PROJECTION
  "proj=tmerc"
  "lat_0=49.000000000"
  "lon_0=-2.000000000"
  "k=0.999601"
  "x_0=400000.000"
  "y_0=-100000.000"
  "ellps=airy"
  "towgs84=375,-111,431,0,0,0,0"
END
 
When I use the mapserver application to find the latlon for:
x : 533604.343541
y: 180566.045573
The mapserver template MAPLAT, MAPLON variables return:
Lat: -0.076218
Lon: 51.508185
Which, when I look them up on MapQuest put me on the right spot.
 
When I use the command line proj4 applications I get following results:
invproj  -f "%.6f" +proj=tmerc +lat_0=49 +lon_0=-2 +k=0.999601
+x_0=400000 +y_0=-100000 +ellps=airy +towgs84=375,-111,431,0,0,0,0 <<EOF
> 533604.343541 180566.045573
> EOF
Lat: -0.074626      
Lon: 51.507727
Which is not exactly the same point.
 
When I use the cs2cs command I get following result:
cs2cs  -f "%.6f" +proj=tmerc +lat_0=49 +lon_0=-2 +k=0.999601 +x_0=400000
+y_0=-100000 +ellps=airy +towgs84=375,-111,431,0,0,0,0 +to +proj=latlong
+ellps=WGS84 +datum=WGS84 <<EOF
> 533604.343541 180566.045573
> EOF
Lat: -0.076218       
Lon: 51.508185 45.074824
Which is what I would like to find
 
When I use Mapscript PHP:
   $projInObj = ms_newProjectionObj( "proj=tmerc,".
  "lat_0=49,".
  "lon_0=-2,".
  "k=0.999601,".
  "x_0=400000,".
  "y_0=-100000,".
  "ellps=airy,".
  "towgs84=375,-111,431,0,0,0,0");
 
  $projOutObj = ms_newProjectionObj("proj=latlong,  ellps=WGS84,
datum=WGS84");
 
  $poPoint = ms_newPointObj();
  $poPoint->setXY($_REQUEST["lon"],$_REQUEST["lat"]);
  $poPoint->project($projInObj, $projOutObj);
 
I get: 
Lat: -0.074619464992752 
Lon: 51.505774438372
Which is close but still about 1km out of where it should land.
 
Sven Borgers.
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20060802/fc7ab6ca/attachment.htm>


More information about the MapServer-users mailing list