[Mapserver-users] Chaning output projection on request.

Martin Weinelt mweinelt at planiglobe.com
Fri Feb 13 04:01:36 EST 2004


On Friday 13 February 2004 02:17, Jason M. Nielsen wrote:
> Anyone have an example of how one can set it up so a user can select a
> different projection from a list as the display projection (main output)?
>
> I was almost thinking one would have to have a .map file for each
> projection in which the only change was the EXTENT and and Projection
> definitions.
>
> I was rumaging through the dbox code on how one might submit a new extent
> and projection but didnt see anything.
>
> Thanks.

Jason, 

I do it with separate .map-files (and projected data) for each projection. The 
interface has a <FORM> that provides projection selection:

  <form name="proj_form" action="">  
     <select size="1" name="Auswahl" onChange="setProj()" width="150">
       <option value="DD.map">Kartesian</option>
       <option value="ME.map">Mercator</option>
       <option value="LN.map">Lambert Azimuthal North</option>
       <option value="LS.map">Lambert Azimuthal South</option>
     </select>
  </form>

This above form calls a js function ("setProj()"): 

function setProj(theMap) {
  var myForm   = document.forms['map_form'];
  var projForm = document.forms['proj_form'];
  var mapFileName =  
projForm.Auswahl.options[projForm.Auswahl.selectedIndex].value;
   // set the corresponding mapfile
  var mapFile = docRoot + mapFileName;  // docRoot has the path 
   myForm.map.value = mapFile;  
   
  // set the mapextent to initial big map
  switch (mapFileName) {
    case "DD.map": 
      myForm.mapext.value = "-180 -90 180 90";
      // change corresp.  ref-image here
      break;
    case "ME.map":
      myForm.mapext.value = "-20000000 -20000000 20000000 20000000";
      // change  corresp. ref-image here
      break;
    case "LN.map":
      myForm.mapext.value = "-7000000 -7000000  7000000 7000000"; 
      // change corresp. ref-image here
      break;
    case "LS.map": 
      myForm.mapext.value = "-7000000 -7000000  7000000 7000000";
      // change corresp. ref-image here
      break;
    }   
   myForm.mode.value = "browse";
   myForm.submit();
}    

That works for me ...

Cheers, Martin




More information about the mapserver-users mailing list