Zooming to shapes found by queryByAttributes
Volkan Ulukut
vulukut at TESCILTURK.COM
Mon Jun 12 07:02:19 PDT 2006
Solved it now. I was looking for $map->"zoom.." but $map->"setextent" was
the answer.
_____
From: tesciltu at host.tescilturk.com [mailto:tesciltu at host.tescilturk.com] On
Behalf Of Volkan Ulukut
Sent: Monday, June 12, 2006 4:40 PM
To: MAPSERVER-USERS at LISTS.UMN.EDU
Subject: Re: [UMN_MAPSERVER-USERS] Zooming to shapes found by
queryByAttributes
Ok here is the code. I don't think it's a wrong order issue since i'm not
changing any values.
$oExtents = $oMapSession->oMap->extent;
$oldExtents = $oExtents;
$oLayer = $oMapSession->oMap->getLayerByName($http_form_vars['sLayer']);
$result = $oLayer->queryByAttributes($http_form_vars['sAttribute'], "/" .
$http_form_vars['sString'] . "/", MS_SINGLE);
$oLayer->open();
$oRes = $oLayer->getResult(0);
$oShape = $oLayer->getShape($oRes->tileindex,$oRes->shapeindex);
$oExtents = $oShape->bounds;
$oShape->free();
$width=$oMapSession->oMap->width;
$height=$oMapSession->oMap->height;
$oMapSession->oMap->zoomrectangle( $oExtents,$width,$height,$oldExtents);
Ends up with:
Fatal error: [MapServer Error]: msCalculateScale(): Invalid image extent,
minx=-31.418490, miny=75.002064, maxx=-31.418490, maxy=75.002064.
On red line
-----Original Message-----
From: tesciltu at host.tescilturk.com [mailto:tesciltu at host.tescilturk.com] On
Behalf Of Umberto Nicoletti
Sent: Monday, June 12, 2006 4:28 PM
To: Volkan Ulukut; MAPSERVER-USERS at lists.umn.edu
Subject: Re: [UMN_MAPSERVER-USERS] Zooming to shapes found by
queryByAttributes
REMEMBER to cc the list.
PHP mapscript is ok, it was not afffected. Probably you are not using
the correct order for minx, miny, etc.
Umberto
On 6/12/06, Volkan Ulukut <vulukut at tescilturk.com> wrote:
> I'm using mapserver 4.8.3. mapscript was compiled with it. What was wrong
> with zoomRectangle?
>
> -----Original Message-----
> From: tesciltu at host.tescilturk.com [mailto:tesciltu at host.tescilturk.com]
On
> Behalf Of Umberto Nicoletti
> Sent: Monday, June 12, 2006 4:06 PM
> To: Volkan Ulukut
> Subject: Re: [UMN_MAPSERVER-USERS] Zooming to shapes found by
> queryByAttributes
>
> On 6/12/06, Volkan Ulukut <vulukut at tescilturk.com> wrote:
> >
> > void zoomrectangle(rectObj oPixelExt, int nImageWidth, int nImageHeight,
> > rectObj oGeorefExt)
> > Parmeters are :
> > - oPixelExt (rect object) : Pixel Extents, with (0,0) at the top-left
> > The rectangle contains the coordinates of the LL and UR
> > coordinates in pixel.
> >
> > Shape's bounds are georef coordinates. Zoomrectangle takes pixel extents
> as
> > parameter.
> > When i try to use shape's bounds anyway here's the result:
> > Fatal error: [MapServer Error]: msCalculateScale(): Invalid image
extent,
> > minx=-31.418490, miny=75.002064, maxx=-31.418490, maxy=75.002064.
>
> There is a bug in the zoomRectangle code which was fixed last week in
> cvs versions of mapserver. What mapscript are you using?
>
> Umberto
>
> > -----Original Message-----
> > From: tesciltu at host.tescilturk.com [mailto:tesciltu at host.tescilturk.com]
> On
> > Behalf Of Umberto Nicoletti
> > Sent: Monday, June 12, 2006 3:45 PM
> > To: Volkan Ulukut
> > Cc: MAPSERVER-USERS at lists.umn.edu
> > Subject: Re: [UMN_MAPSERVER-USERS] Zooming to shapes found by
> > queryByAttributes
> >
> > Try to zoomRectangle using the shape's bounds.
> >
> > HTH,
> > Umberto
> >
> > On 6/12/06, Volkan Ulukut <vulukut at tescilturk.com> wrote:
> > >
> > >
> > >
> > >
> > > Hey list;
> > >
> > > I'm having trouble zooming to the exact location of the shape after
> doing
> > a
> > > search with queryByAttributes. I'm trying to use zoomrectangle and
> > zoomscale
> > > but they both need pixel position. So i try to convert my georef
> > coordinates
> > > to pixel coordinates. I believe that was successful too, but the
problem
> > is
> > > that the shape is too small (a street in the worldmap) and the pixel i
> > > calculate is not an integer value. The zoom actually happens but not
> > exactly
> > > on the shape just a bit miles west and north. I tried to workaround
this
> > by
> > > zooming step by step. By that i mean zooming to that location a little
> > then
> > > zooming to the centre till i get to the shape. But that won't give the
> > same
> > > result on every search as you may guess. I'm stuck now cause i can't
> zoom
> > to
> > > the right place with pixel coordinates. Is there any way that i can
zoom
> > > with georef coordinates(lat/long)?
> >
> >
> >
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20060612/744d1c8d/attachment.htm>
More information about the MapServer-users
mailing list