Problems with Python Mapscript Zoomrectangle function

Sean Gillies sgillies at FRII.COM
Mon Dec 20 14:04:26 EST 2004


On Dec 20, 2004, at 11:33 AM, William Hudspeth wrote:

> Hello,
>
> I am using Mapserver 4.2, and Python Mapscript revision 1.4.2.1. I have
> written some code to pass pixel values from a user-selected rectangle
> to
> Zoomrectangle. My underlying map is in geographic coordinates with
> approximate borders north=44N south=27N west=125W (or -125) east=93W
> (or
> -93). I have used the code successfully with UTM coordinates, but am
> having trouble with negative DD values. My code is:
>
> #pixel values passed in
> x_min=289
> y_min=78
> x_max=450
> y_max=201
>

This won't work, Bill, because image coordinates have their origin
at the upper left corner of the image.  Don't try to think of the
image in terms of x and y, think in terms of pixels and lines and
save x and y for the spatial coordinates.

Some work was done to tighten up MapServer's rectObj around 4.2.3
and since then you need to use an extra switch if your rectangle
is in image coordinates.  I seem to recall that you helped me find
this issue in the first place.  See the rectObj documentation under
mapscript/doc/mapscript.txt.

> prevExtent=mapscript.rectObj(minx,miny,maxx,maxy)#default x and y
> limits
> of mapfile
> zoomRect=mapscript.rectObj()
> zoomRect.minx, zoomRect.miny, zoomRect.maxx, zoomRect.maxy = (minx,
> miny, maxx, maxy)
> self.map.zoomRectangle(zoomRect, int(self.img_width), int
> (self.img_height), prevExtent, prevExtent)
>
> **I have tried reversing the miny and maxy values where I assign them
> to
> the zoomRect.* variables. Any help appreciated.
>
> Bill
>
>

Sean


--
Sean Gillies
sgillies at frii dot com
http://users.frii.com/sgillies



More information about the mapserver-users mailing list