Problem using zoomPoint() map object method in Python Mapscript

Sean Gillies sgillies at FRII.COM
Thu Sep 2 11:47:32 EDT 2004


On Sep 2, 2004, at 9:37 AM, Bill Hudspeth wrote:

> Hello,
> Having trouble with the map object zoomPoint() function in python
> mapscript. I set up the current view extents in utm coords, a point to
> zoom to in pixel units, and then call zoomPoint() function. Nothing
> changes on my view. I translated this code directly from a set of
> pan/zoom functions that work in PHP. The logic is exactly the same, but
> I don't get any resultant changes on screen. If anyone can spot what I
> might be missing, I would much appreciate some feedback. Otherwise, a
> possible problem with zoomPoint() function or my usage of it?
>
> ***********************************************************************
> **********
> self.nmMap = mapscript.mapObj(self.data)
> ms_temp_dir = '/var/www/html/tmp'
> ms_tmp_url = 'http://hyperion.unm.edu/tmp'
>
> #build path to image
> image_name='first.png'
> self.image_path=os.path.join(ms_temp_dir, image_name)
> #global image_url
> self.image_url = os.path.join(ms_tmp_url, image_name)
>
> #create default map extent object based upon mapfile
> self.default_extent = self.nmMap.extent
> self.img_width = self.nmMap.width
> self.img_height = self.nmMap.height
>
> pminx=450001
> pminy=3567876
> pmaxx=543234
> pmaxy=4565342
>
> #build and populate a rectangle object that represents the extent of
> the
> previous map image
> prevExtent=mapscript.rectObj(pminx, pminy, pmaxx, pmaxy)
>
> #Define the point to pan to
> zoomFactor = 1
> #pan to the north
> zoomToPt = mapscript.pointObj(self.img_width/2, 0)
>
> #Set the extent of the current map to the an extent with the clicked
> point at the center, zoomed by the above defined factor
> self.nmMap.zoomPoint(zoomFactor,zoomToPt,self.img_width,
> self.img_height, prevExtent, prevExtent)
>
> #draw map
> <input ID='mapimg' TYPE='image' SRC='self.image_url'>
>
> ***********************************************************************
> ********************
>
> Thanks, Bill
>

Bill,

The zoomPoint method passes the unit tests I've written for it,
but I'm not testing the case of a zoom factor of 1.  I'm wondering
if your constraining rectangle isn't the problem.  Your constraining
rectangle (6th arg) is the same as your starting rectangle (5th arg)
and I think this should practically prevent any zooming with a
factor of 1.  Could you try again with

self.nmMap.zoomPoint(zoomFactor, zoomToPt, self.img_width,
self.img_height, prevExtent, None)

and let me know if that solves it?

Sean




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



More information about the mapserver-users mailing list