Python mapscript zoomrectangle
Sean Gillies
sgillies at FRII.COM
Fri Jan 7 08:59:34 PST 2005
On Jan 7, 2005, at 9:34 AM, William Hudspeth wrote:
> I am using Mapserver 4.2, and Python Mapscript revision 1.4.2.1. As I
> wrote recently, I have written some code to pass pixel values from a
> user-selected rectangle to Zoomrectangle. Sean Gillies made changes to
> the Python Mapscript code to handle pixel values and make the
> appropriate conversions (with an additional flag to the rectObj
> constructor). He also suggested a workaround for the older Mapscript
> version that I am using. It involved directly assigning pixel values to
> a rectObj:
>
> #pixel values passed in
> x_min=289 (left)
> y_min=78 (top)
> x_max=450 (right)
> y_max=201 (bottom)
>
This is correct.
> zoomRect=mapscript.rectObj()
> zoomRect.minx, zoomRect.miny, zoomRect.maxx, zoomRect.maxy=
> (minx,maxy,maxx,miny)
> self.mapObj.zoomRectanlge(rectObj, width, height, rectObj, rectObj)
>
Bill, you are screwing up your zoom rectangle by switching the
miny/maxy values. The first two lines above should be written as
zoomRect = mapscript.rectObj(x_min, y_min, x_max, y_max)
With MapServer 4.4, because of the added rectObj extent checking, you
will need to add a imageunits flag as the 5th argument to rectObj
zoomRect = mapscript.rectObj(x_min, y_min, x_max, y_max, 1)
See the API reference:
http://users.frii.com/sgillies/projects/mapscript/
mapscript.html#rectobj
> This solution worked well for maps in a UTM coordinate system with a
> "normal" cartesian layout (e.g. x increases to the right, y increases
> to
> the north). However, my current map is in geographic coordinates with
> approximate borders north=44N south=27N west=125W (or -125) east=93W
> (or
> -93) - e.g. x values increase to the left. The same code that worked
> with UTM's is not working with Geographic coords. Hence my interest on
> a
> workaround for this particular problem, or whether it would be easier
> to
> upgrade the version of Mapscript.
>
> Bill
>
>
No, Bill, x values need to decrease to the left! 125W needs to be
treated as -125 degrees for use with MapServer. I wonder if this was a
mistake in your email, or maybe a misunderstanding that is the root of
your problem?
regards,
Sean
--
Sean Gillies
sgillies at frii dot com
http://users.frii.com/sgillies
More information about the MapServer-users
mailing list