<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
<br>
    Hello Javier, thanks for the info. <br>
<br>
    We have been struggling for some time now with the zoomRectangle
and every piece of info is appreciated.<br>
    Concerning the swap of MinY with MaxY in your code, I gotta say
this caught me off guard.<br>
     I couldn't get past a "miny &gt;= maxy" error while trying to  use
zoomRectangle before and went as far as changing and recompiling
mapzoom.i where there is a consistency check that looks like:<br>
<pre>
        if (poPixRect-&gt;maxy &gt;= poPixRect-&gt;miny) { -- insert nasty error here -- }

</pre>
    thinking I found a bug. I got past the error after that change,
however the zoom behavior was what could best be described as "all over
the place". Like zooming to the wrong hemisphere and the like. <br>
    So I changed mapzoom.i back to the original code and swapped the
order of arguments on my code following your example, and it worked
better than the last behavior, however the zoom isn't still quite
working in a predictable manner. <br>
    Sometimes when zooming the map will remain at the same zoom factor,
and just pan a little to the sides or actually zooming out instead of
going zooming to the passed coordinates. I am running out of ideas as
to what could be causing this behavior. <br>
    Here is what I am doing:<br>
<br>
      //Current map geo extent<br>
      String[] extents = ((String) params.get("extent")).split(" ");<br>
       rectObj extent = new rectObj(Double.parseDouble(extents[0]),
Double.parseDouble(extents[1]), <br>
                                     Double.parseDouble(extents[2]),
Double.parseDouble(extents[3]), mapscript.MS_FALSE);<br>
       mapa.setExtent(extent);<br>
<br>
        //rectangle Pic coords<br>
        String[] pxCoordZoom = ((String)
params.get("coordenadas")).split(" ");<br>
        Double minx = Double.parseDouble(pxCoordZoom[0]);<br>
        Double miny = Double.parseDouble(pxCoordZoom[1]);<br>
        Double maxy = Double.parseDouble(pxCoordZoom[2]);<br>
        Double maxx = Double.parseDouble(pxCoordZoom[3]);<br>
<br>
       /*We are using a cropper javascript class and the order the
rectangle coordinates where being passed was kind of unpredictable and
causing errors                while trying to create the rectangle with
the eventual minX &gt; maxX /*<br>
        double transport;<br>
        if(minx &gt; maxx){<br>
            transport = minx;<br>
            minx = maxx;<br>
            maxx = transport;<br>
        }          <br>
        if(miny &gt; maxy){<br>
            transport = miny;<br>
            miny = maxy;<br>
            maxy = transport;<br>
        }<br>
<br>
        rectObj zoomArea = new rectObj(minx, maxy, maxx, miny,
mapscript.MS_TRUE);   //with MaxY and MinY swapped <br>
        mapa.zoomRectangle(zoomArea, mapa.getWidth(), mapa.getHeight(),
extent, getMaxGeorefExtent(mapa));<br>
<br>
    Do you see any glaring mistakes that could cause the zoom to behave
wrongly?<br>
    What confuses me is the fact that you mentioned that the rectangle
should be constructed with bottom-left and top-right defined, but isn't
the MinX and MaxY pair actually top-left?<br>
   <br>
    Thanks in advance, any scrap of information helps immensely.<br>
<br>
    Rod.<br>
<br>
-- <br>
<font color="#000000" face="Verdana, Arial, Helvetica" size="1">
<br>
<br>
<font color="#000000" size="2"><b>Rodrigo Del C. Andrade</b></font><br>
<font color="#606060"><i>Estagiário Nível Superior</i></font><br>
<font color="#606060"><i>SIC - SSE - Soluções Segurança Pública</i></font><br>
<br>
<font color="#000080"><b>DÍGITRO TECNOLOGIA</b></font><br>
<font color="#000000"><b>E-mail:</b></font>
<a href="mailto:rodrigo.andrade@digitro.com.br"><font color="#606060">rodrigo.andrade@digitro.com.br</font></a><br>
<font color="#000000"><b>Fone:</b></font>
<font color="#000000">+55 48 3281- / +55 48 3281-7000</font><br>
<font color="#000000"><b>Fax:</b></font>
<font color="#000000">+55 48 3281-7299</font><br>
<font color="#000000"><b>Site:</b></font>
<a href="http://www.digitro.com"><font color="#606060">www.digitro.com</font></a>
</font><br>
<br>
Javier Caicedo wrote:
<blockquote
 cite="mid1238.84.192.187.251.1165521654.squirrel@correo.cti.espol.edu.ec"
 type="cite">
  <pre wrap="">According to the Mapscript API mapObj.zoomRectangle first parameter must
be in  image coordinates, so you should set the last parameter of the
rectObj constructor to TRUE. Here goes an example from my current project:

  //vMap is an instance of mapObj
  rectObj rect = vMap.getExtent(); //map coordinates
  String [] box = getCurrentRequest().getParameter("box").split(" ");
  //box is something like this: 10 10 200 200
  //0,0 is at top left, so box defines top left and bottom right corners
  double mx = Double.parseDouble(box[0]);
  double my = Double.parseDouble(box[1]);
  double mxx = Double.parseDouble(box[2]);
  double mxy = Double.parseDouble(box[3]);

  //bunch of validation code ommitted

  rectObj rbox = new rectObj(mx,mxy,mxx,my,mapscriptConstants.MS_TRUE);
  //notice the switch of mxy and my
  //rectObj constructor requires you define bottom left and top right
  //corners. rbox is in image coordinates
  vMap.zoomRectangle(rbox,w,h,rect,null);

Hopefully this will help you out a little.

Regards,
Javier Caicedo Espinoza
CTI - ESPOL
Guayaquil, Ecuador


  </pre>
</blockquote>
<br>
<br>
<div class="moz-signature"><br>
<font color="#000000" face="Verdana, Arial, Helvetica" size="1"></font></div>
</body>
</html>