<html>

<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">


<meta name=Generator content="Microsoft Word 10 (filtered)">

<style>
<!--
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman";}
a:link, span.MsoHyperlink
        {color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {color:purple;
        text-decoration:underline;}
p.MsoAutoSig, li.MsoAutoSig, div.MsoAutoSig
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman";}
span.EmailStyle17
        {font-family:Arial;
        color:windowtext;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.25in 1.0in 1.25in;}
div.Section1
        {page:Section1;}
-->
</style>

</head>

<body lang=EN-US link=blue vlink=purple>

<div class=Section1>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>All,</span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'> </span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>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:</span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'> </span></font></p>

<p class=MsoNormal style='margin-left:.5in'><i><font size=2 face=Arial><span
style='font-size:10.0pt;font-family:Arial;font-style:italic'>function AdjustExtent(extent,
width, height)</span></font></i></p>

<p class=MsoNormal style='margin-left:.5in'><i><font size=2 face=Arial><span
style='font-size:10.0pt;font-family:Arial;font-style:italic'>{</span></font></i></p>

<p class=MsoNormal style='margin-left:.5in'><i><font size=2 face=Arial><span
style='font-size:10.0pt;font-family:Arial;font-style:italic'>  var cellsize
= Math.max((extent[2] - extent[0])/width, (extent[3] - extent[1])/height);</span></font></i></p>

<p class=MsoNormal style='margin-left:.5in'><i><font size=2 face=Arial><span
style='font-size:10.0pt;font-family:Arial;font-style:italic'> </span></font></i></p>

<p class=MsoNormal style='margin-left:.5in'><i><font size=2 face=Arial><span
style='font-size:10.0pt;font-family:Arial;font-style:italic'>  if(cellsize
> 0) {</span></font></i></p>

<p class=MsoNormal style='margin-left:.5in'><i><font size=2 face=Arial><span
style='font-size:10.0pt;font-family:Arial;font-style:italic'>   
var ox = Math.max((width - (extent[2] - extent[0])/cellsize)/2,0);</span></font></i></p>

<p class=MsoNormal style='margin-left:.5in'><i><font size=2 face=Arial><span
style='font-size:10.0pt;font-family:Arial;font-style:italic'>   
var oy = Math.max((height - (extent[3] - extent[1])/cellsize)/2,0);</span></font></i></p>

<p class=MsoNormal style='margin-left:.5in'><i><font size=2 face=Arial><span
style='font-size:10.0pt;font-family:Arial;font-style:italic'> </span></font></i></p>

<p class=MsoNormal style='margin-left:.5in'><i><font size=2 face=Arial><span
style='font-size:10.0pt;font-family:Arial;font-style:italic'>   
extent[0] = extent[0] - ox*cellsize;</span></font></i></p>

<p class=MsoNormal style='margin-left:.5in'><i><font size=2 face=Arial><span
style='font-size:10.0pt;font-family:Arial;font-style:italic'>   
extent[1] = extent[1] - oy*cellsize;</span></font></i></p>

<p class=MsoNormal style='margin-left:.5in'><i><font size=2 face=Arial><span
style='font-size:10.0pt;font-family:Arial;font-style:italic'>   
extent[2] = extent[2] + ox*cellsize;</span></font></i></p>

<p class=MsoNormal style='margin-left:.5in'><i><font size=2 face=Arial><span
style='font-size:10.0pt;font-family:Arial;font-style:italic'>   
extent[3] = extent[3] + oy*cellsize;</span></font></i></p>

<p class=MsoNormal style='margin-left:.5in'><i><font size=2 face=Arial><span
style='font-size:10.0pt;font-family:Arial;font-style:italic'>  }</span></font></i></p>

<p class=MsoNormal style='margin-left:.5in'><i><font size=2 face=Arial><span
style='font-size:10.0pt;font-family:Arial;font-style:italic'>  return(cellsize);</span></font></i></p>

<p class=MsoNormal style='margin-left:.5in'><i><font size=2 face=Arial><span
style='font-size:10.0pt;font-family:Arial;font-style:italic'>}</span></font></i></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'> </span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'> </span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>Here is the projection of my map file:</span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'> </span></font></p>

<p class=MsoNormal style='margin-left:.5in'><i><font size=2 face=Arial><span
style='font-size:10.0pt;font-family:Arial;font-style:italic'>PROJECTION</span></font></i></p>

<p class=MsoNormal style='margin-left:.5in'><i><font size=2 face=Arial><span
style='font-size:10.0pt;font-family:Arial;font-style:italic'>  "proj=longlat"</span></font></i></p>

<p class=MsoNormal style='margin-left:.5in'><i><font size=2 face=Arial><span
style='font-size:10.0pt;font-family:Arial;font-style:italic'>  "ellps=WGS84" 
</span></font></i></p>

<p class=MsoNormal style='margin-left:.5in'><i><font size=2 face=Arial><span
style='font-size:10.0pt;font-family:Arial;font-style:italic'>END</span></font></i></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'> </span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>After the above function, I am converting to decimal degrees
using these functions:</span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'> </span></font></p>

<p class=MsoNormal style='margin-left:.5in'><i><font size=2 face=Arial><span
style='font-size:10.0pt;font-family:Arial;font-style:italic'>function DetX(x)</span></font></i></p>

<p class=MsoNormal style='margin-left:.5in'><i><font size=2 face=Arial><span
style='font-size:10.0pt;font-family:Arial;font-style:italic'>{</span></font></i></p>

<p class=MsoNormal style='margin-left:.5in'><i><font size=2 face=Arial><span
style='font-size:10.0pt;font-family:Arial;font-style:italic'>  var mapwidth
= omaxx - ominx;</span></font></i></p>

<p class=MsoNormal style='margin-left:.5in'><i><font size=2 face=Arial><span
style='font-size:10.0pt;font-family:Arial;font-style:italic'>  var mappixel
= mapwidth / 600;</span></font></i></p>

<p class=MsoNormal style='margin-left:.5in'><i><font size=2 face=Arial><span
style='font-size:10.0pt;font-family:Arial;font-style:italic'>  GIS_X = 
ominx + (x * mappixel);</span></font></i></p>

<p class=MsoNormal style='margin-left:.5in'><i><font size=2 face=Arial><span
style='font-size:10.0pt;font-family:Arial;font-style:italic'>  return
GIS_X;</span></font></i></p>

<p class=MsoNormal style='margin-left:.5in'><i><font size=2 face=Arial><span
style='font-size:10.0pt;font-family:Arial;font-style:italic'>}</span></font></i></p>

<p class=MsoNormal style='margin-left:.5in'><i><font size=2 face=Arial><span
style='font-size:10.0pt;font-family:Arial;font-style:italic'> </span></font></i></p>

<p class=MsoNormal style='margin-left:.5in'><i><font size=2 face=Arial><span
style='font-size:10.0pt;font-family:Arial;font-style:italic'> </span></font></i></p>

<p class=MsoNormal style='margin-left:.5in'><i><font size=2 face=Arial><span
style='font-size:10.0pt;font-family:Arial;font-style:italic'>function DetY(y)</span></font></i></p>

<p class=MsoNormal style='margin-left:.5in'><i><font size=2 face=Arial><span
style='font-size:10.0pt;font-family:Arial;font-style:italic'>{</span></font></i></p>

<p class=MsoNormal style='margin-left:.5in'><i><font size=2 face=Arial><span
style='font-size:10.0pt;font-family:Arial;font-style:italic'>  var mapheight
= omaxy-ominy;</span></font></i></p>

<p class=MsoNormal style='margin-left:.5in'><i><font size=2 face=Arial><span
style='font-size:10.0pt;font-family:Arial;font-style:italic'>  var mappixel
= mapheight / 500;</span></font></i></p>

<p class=MsoNormal style='margin-left:.5in'><i><font size=2 face=Arial><span
style='font-size:10.0pt;font-family:Arial;font-style:italic'>  GIS_Y = omaxy
- (y * mappixel);</span></font></i></p>

<p class=MsoNormal style='margin-left:.5in'><i><font size=2 face=Arial><span
style='font-size:10.0pt;font-family:Arial;font-style:italic'>  return
GIS_Y;</span></font></i></p>

<p class=MsoNormal style='margin-left:.5in'><i><font size=2 face=Arial><span
style='font-size:10.0pt;font-family:Arial;font-style:italic'>}</span></font></i></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'> </span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'> </span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>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?</span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'> </span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>Thanks for your help.</span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'> </span></font></p>

<p class=MsoAutoSig><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>Mike Arnold</span></font></p>

<p class=MsoAutoSig><font size=3 face="Times New Roman"><span style='font-size:
 12.0pt'>micheal.arnold@nscorp.com</span></font></p>

</div>

</body>

</html>