mapObj.zoomRectangle from Java Mapscript.

Tamas Szekeres szekerest at GMAIL.COM
Mon Dec 11 11:30:06 EST 2006


Hi All,

Going through the CVS History of mapzoom.i I can see that umberto has
addressed this issue in ver1.3 (2006 05 30) but hobu has reverted the
changes in ver1.4 (2006 07 04)

So the developers should agree with the desired action.

I would vote +1 to correct this issue as logical, that is:

mapzoom.i (282)

  if (poPixRect->miny >= poPixRect->maxy)
        {
            msSetError(MS_MISCERR, "image rectangle miny >= maxy",
                       "mapscript::mapObj::zoomRectangle()");
            return MS_FAILURE;
        }

However it will break the existing code and should be noted as a
backward incompatible change.

Best Regards,

Tamas Szekeres





2006/12/11, Rodrigo Del C. Andrade <rodrigo.andrade at digitro.com.br>:
>
>
>      Hello Javier, thanks for the info.
>
>      We have been struggling for some time now with the zoomRectangle and
> every piece of info is appreciated.
>      Concerning the swap of MinY with MaxY in your code, I gotta say this
> caught me off guard.
>       I couldn't get past a "miny >= 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:
>  if (poPixRect->maxy >= poPixRect->miny) { -- insert nasty error here -- }
>
>
>      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.
>      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.
>      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.
>      Here is what I am doing:
>
>        //Current map geo extent
>        String[] extents = ((String) params.get("extent")).split(" ");
>         rectObj extent = new rectObj(Double.parseDouble(extents[0]),
> Double.parseDouble(extents[1]),
>                                       Double.parseDouble(extents[2]),
> Double.parseDouble(extents[3]), mapscript.MS_FALSE);
>         mapa.setExtent(extent);
>
>          //rectangle Pic coords
>          String[] pxCoordZoom = ((String) params.get("coordenadas")).split("
> ");
>          Double minx = Double.parseDouble(pxCoordZoom[0]);
>          Double miny = Double.parseDouble(pxCoordZoom[1]);
>          Double maxy = Double.parseDouble(pxCoordZoom[2]);
>          Double maxx = Double.parseDouble(pxCoordZoom[3]);
>
>         /*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 > maxX /*
>          double transport;
>          if(minx > maxx){
>              transport = minx;
>              minx = maxx;
>              maxx = transport;
>          }
>          if(miny > maxy){
>              transport = miny;
>              miny = maxy;
>              maxy = transport;
>          }
>
>          rectObj zoomArea = new rectObj(minx, maxy, maxx, miny,
> mapscript.MS_TRUE);   //with MaxY and MinY swapped
>          mapa.zoomRectangle(zoomArea, mapa.getWidth(), mapa.getHeight(),
> extent, getMaxGeorefExtent(mapa));
>
>      Do you see any glaring mistakes that could cause the zoom to behave
> wrongly?
>      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?
>
>      Thanks in advance, any scrap of information helps immensely.
>
>      Rod.
>
>  --
>
>
>  Rodrigo Del C. Andrade
>  Estagiário Nível Superior
>  SIC - SSE - Soluções Segurança Pública
>
>  DÍGITRO TECNOLOGIA
>  E-mail: rodrigo.andrade at digitro.com.br
>  Fone: +55 48 3281- / +55 48 3281-7000
>  Fax: +55 48 3281-7299
>  Site: www.digitro.com
>
>
>  Javier Caicedo wrote:
>  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
>
>
>
>
>
>
>
>



More information about the mapserver-users mailing list