mapObj.zoomRectangle from Java Mapscript.

Umberto Nicoletti umberto.nicoletti at GMAIL.COM
Thu Dec 7 02:51:21 EST 2006


I build the rect for use with queryByRectangle as follows:

        return new rectObj(
                (x1<x2) ? x1 : x2,
                (y1<y2) ? y1 : y2,
                (x1<x2) ? x2 : x1,
                (y1<y2) ? y2 : y1,
                0
        );

x1,x2,y1,y2 need to be in map coordinates (not pizels).

Umberto

On 12/6/06, José Vilson de Mello de Farias <vilson.farias at digitro.com.br> wrote:
>
>  Greetings people from Mapserver,
>
>     I've been unsuccessfully trying to make mapObj.zoomRectangle work. My
> goal is to write a simple zoom by rectangle, which lets you to select an
> image area from web browser and submit those coordenates for zoom processing
> inside mapserver. Although I've checked my code more than once, the error
> seems to be related to the way mapserver deals with these coordenates. Do
> you know if there is any problem in mapObj.zoomRectangle tool in Java
> Mapscript?  How could I zoom to a specific pixel location using
> zoomRectangle?
>
>    Suppose I have a map with the following size and extent :
>
>   SIZE 800 450
>    EXTENT -180.000000 -90.000000 180.000000 90
>     Here is my Java code :
>
> mapObj mapa = new mapObj("./world.map");
>  ...
>  rectObj maxExtent = new rectObj(-180, -90, 180, 90, mapscript.MS_FALSE);
> //map full extent
>  rectObj actualExtent = new rectObj(-120, -60, 160, 45, mapscript.MS_FALSE);
> //map actual extent
>  rectObj pxArea = new rectObj(170, 200, 270, 400, mapscript.MS_FALSE);
> //image coordenates for zooming
>  mapa.zoomRectangle(pxArea, mapa.getWidth(), mapa.getHeight(), actualExtent,
> maxExtent);
>     When I try to execute the zoomRectangle command, the following exception
> is thrown :
>
> java.lang.UnknownError: mapscript::mapObj::zoomRectangle():
> General error message. image rectangle miny >= maxy
>
> edu.umn.gis.mapscript.mapscriptJNI.mapObj_zoomRectangle(Native
> Method)
> edu.umn.gis.mapscript.mapObj.zoomRectangle(mapObj.java:554)
>  ...
>
>     By the way, what does the last param of rectObj constructor mean? Is
> imageunits a boolean to indicate whether coordenates are image-relative or
> geographical values? If I try to set it to MS_TRUE I get a different
> exception.
>
>
>  java.lang.UnknownError: rectObj(): Invalid rectangle. image (pixel/line)
> units { 'minx': 248.000000 , 'miny': 194.000000 , 'maxx': 387.000000 ,
> 'maxy': 259.000000 }
>  edu.umn.gis.mapscript.mapscriptJNI.new_rectObj(Native
> Method)
>  edu.umn.gis.mapscript.rectObj.<init>(rectObj.java:69)
>
>  Could you please help me to solve this situation?
>
>  Best regards,
>
>
> --
>  José Vilson de Mello de Farias
>  Analista de Sistemas
>  SSE - Segurança Pública
>
>  DÍGITRO TECNOLOGIA
>  E-mail: vilson.farias at digitro.com.br
>  Messenger: vilsonfarias at hotmail.com
>  Site: www.digitro.com.br



More information about the mapserver-users mailing list