Change Projection on-the-fly; Using PostGIS - How?

Stefan Schwarzer stefan.schwarzer at GRID.UNEP.CH
Fri Apr 20 02:02:47 PDT 2007


Hi there,

i am struggling since quite a while to set-up a change-projection-on- 
the-fly possibility for our website mapserver. But somehow, I don't  
really have the clue how to do it. Now, making things "worse" (more  
complicated for me) we have migrated from MySql to Postgres/Postgis.

------------------------------------------------------------------------ 
----

So, first question would be: What code to use to change the  
projection via PHP/Mapscript, should be something like this, I guess:

$newproj=ms_newprojectionObj("proj=robin,lon_0=0,x_0=0,y_0=0");
$latlon=ms_newprojectionObj("+proj=longlat +ellps=WGS84 +datum=WGS84 
+no_defs");
$oldext=ms_newRectObj();
$oldext->setextent(-180,-90,180,90);  //this is the extent of my map  
in geographic
$oldext->project($latlon,$newproj);  //reproject to Robinson
$map->setextent($oldext->minx,$oldext->miny,$oldext->maxx,$oldext- 
 >maxy);  //set the new map extent

But I guess, something is still missing... (What about $map- 
 >setProjection ?)

------------------------------------------------------------------------ 
----

And the second question is: As my mapfile queries the postgis  
database, using "SRID", I guess I need to change that one too, then?  
Instead of 4326 for Geographic I would have to use the one for  
Robinson (or Mollweide or so) ??

------------------------------------------------------------------------ 
----

Thanks for giving me any hints...

Stef



More information about the MapServer-users mailing list