Continuing problem with rectObj creation in python mapscript

Sean Gillies sgillies at FRII.COM
Mon Aug 30 14:06:00 EDT 2004


On Aug 30, 2004, at 11:55 AM, Bill Hudspeth wrote:

> I am using Mapserver 4.3.1 andI am continuing to experience an unknown
> problem with a call to the map object
> zoomRectangle() function in Python mapscript. My code looks like this:
> *************************************
> self.nmMap = mapscript.mapObj()
> self.img_width = self.nmMap.width
> self.img_height = self.nmMap.height
>
> self.prev_minx=45726.60           #utm coords
> self.prev_miny=3400000.0         #utm coords
> self.prev_maxx=785072.39         #utm coords
> self.prev_maxy=4153198.0         #utm coords
>
> self.down_x=240                         #pixel coords
> self.up_x=330                              #pixel coords
> self.down_y=145                         #pixel coords
> self.up_y=208                              #pixel coords
>
> #create rect object with current utm coords
> prevExtent =mapscript.rectObj(float(self.prev_minx),
> float(self.prev_miny), float(self.prev_maxx), float(self.prev_maxy))
>
> #create rect object from mouse clicks (pixels)
> pix_minx=12.0
> pix_miny=17.0
> pix_maxx=123.0
> pix_maxy=155.0
> zoomRect=mapscript.rectObj(pix_minx, pix_miny, pix_maxx, pix_maxy)
>
> self.nmMap.zoomRectangle(zoomRect, int(self.img_width),
> int(self.img_height), prevExtent, prevExtent)
>
> **************************************
> The error traces back to:
> zoomRect=mapscript.rectObj(pix_minx, pix_miny, pix_maxx, pix_maxy)
>
> REGARDLESS of the values I enter into pix_minx, pix_miny, pix_maxx, and
> pix_maxy, I get the following error.
>
> General error message. Invalid bounds
>
> Given that pixel coordinates on images reverse the directionality of
> increases in the y axis, I have tried all possible combinations of
> values for these four variables just as a test; (minx, miny, maxx,
> maxy)
> i.e.
> (12.0, 23.0, 147.0, 153.0)
> (12.0, 153.0, 147.0, 23.0)
> (147.0, 23.0, 12.0, 153.0)
> (147.0, 153.0, 12.0, 23.0)
>
>
> ***********************
> I would very much appreciate any help on this.
>
> Bill
>
>

Hi Bill,

Problem seems to be new code in 4.3 which checks for valid rectangle
bounds in the rectObj() constructor.  It enforces the requirement
that miny < maxy.  This screws things up for rectangles in image
units because in that case, miny should be greater than maxy.

In both cases miny, minx is the lower left corner and maxx, maxy is
the upper right corner of a rectangle.

I am going to create an issue in the tracker and will CC you on it.

cheers,
Sean

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



More information about the mapserver-users mailing list