image swapping and extent calculation

Arnold, Micheal B. Micheal.Arnold at NSCORP.COM
Thu Dec 30 06:32:02 PST 2004


All,



When using image swapping in my map, I am having some trouble calculating
the extents of the new image that was created.  I know that I must keep
track of it on the client side since I am not refreshing the whole page, but
I can't get it to work.  I have tried using the below formula based on what
I saw in both the mapserver source code and mapserv.js:



function AdjustExtent(extent, width, height)

{

  var cellsize = Math.max((extent[2] - extent[0])/width, (extent[3] -
extent[1])/height);



  if(cellsize > 0) {

    var ox = Math.max((width - (extent[2] - extent[0])/cellsize)/2,0);

    var oy = Math.max((height - (extent[3] - extent[1])/cellsize)/2,0);



    extent[0] = extent[0] - ox*cellsize;

    extent[1] = extent[1] - oy*cellsize;

    extent[2] = extent[2] + ox*cellsize;

    extent[3] = extent[3] + oy*cellsize;

  }

  return(cellsize);

}





Here is the projection of my map file:



PROJECTION

  "proj=longlat"

  "ellps=WGS84"

END



After the above function, I am converting to decimal degrees using these
functions:



function DetX(x)

{

  var mapwidth = omaxx - ominx;

  var mappixel = mapwidth / 600;

  GIS_X =  ominx + (x * mappixel);

  return GIS_X;

}





function DetY(y)

{

  var mapheight = omaxy-ominy;

  var mappixel = mapheight / 500;

  GIS_Y = omaxy - (y * mappixel);

  return GIS_Y;

}





This does not seem to be working for me.  Is there any call that I can make
to the mapserver CGI to get the extents of the map?



Thanks for your help.



Mike Arnold

micheal.arnold at nscorp.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20041230/34de7324/attachment.htm>


More information about the MapServer-users mailing list