[mapserver-users] Itemquery in Mapscript(PHP)

Obe, Regina DND\MIS Regina.Obe.PFD at ci.boston.ma.us
Tue Sep 11 08:16:28 EDT 2001


Stephen,

Thanks for the suggestion.

I was looking for some documentation or examples as to how to go about doing
this, but couldn't find any on using FILTER parameter and queryByAttribute.
Do you have an example of how to use this?

I'm sure I'm way off-base and apologize if this is a really stupid question.
I don't think this existed in the build I had so I upgraded to a newer build
of php mapscript

I tried something like
$map = ms_newMapObj("bosstreets.map"); 

$lzone = $map->getlayerbyname("zones"); //get neighborhood layer
$lzone->set("status", MS_ON);
$lzone->set("filteritem", "NAME"); //NAME is the field in the table that
refers to neighborhood
$map->queryByAttributes("Dorchester", MS_SINGLE, -1);
$img = $map->draw() or die('Unable to draw map');
$url = $img->saveWebImage(MS_GIF, 0, 0, -1);

(I tried a bunch of permutations of queryByAttributes)

But keep on getting the error
Object has an invalid '_map_handle_' property  (at the queryByAttributes
line)







-----Original Message-----
From: Stephen Lime [mailto:steve.lime at dnr.state.mn.us]
Sent: Monday, September 10, 2001 12:32 PM
To: Regina.Obe.PFD at ci.boston.ma.us; mapserver-users at lists.gis.umn.edu
Subject: Re: [mapserver-users] Itemquery in Mapscript(PHP)


The "zoom in" feature is specific to the mapserv CGI. You'd have to
re-create that
code in PHP to achieve functionality. Remember that with queries a result
set is
build and then drawn. During that first step is when shapes are first
processed and
their extents can be looked at. With the setup you have below that first
step doesn't
happen, that is, the extent is provided (probably in your mapfile) BEFORE
the 
expressions are even evaluated.

How to fix? Well you can do a true attribute query using the layer FILTER
parameter
and the queryByAttribute method or you can use other tools like the various
.dbf 
modules and interact with the attribute table that way.

Steve

Stephen Lime
Internet Applications Analyst

Minnesota DNR
500 Lafayette Road
St. Paul, MN 55155
651-297-2937

>>> "Obe, Regina     DND\MIS" <Regina.Obe.PFD at ci.boston.ma.us> 09/10/01
07:58AM >>>
I'm trying to simulate the item query functionality that is in mapserve in
PHP mapscript.  I followed another example I found on this list serv and
that worked fine except I can't get it to zoom in.   It highlights the area
but doesn't zoom in and wondering if this is possible without having to
query a table that has the list of extents for each feature.

This is what my code looks like

$map = ms_newMapObj("bosstreets.map"); 

$lzone = $map->getlayerbyname("zones"); //get neighborhood layer
$lzone->set("status", MS_ON);
$qclass = $lzone->getClass(0);
$qclass->setexpression("Dorchester");
$acolor = $map->addColor(255,40,250);
$qclass->set("color", $acolor);
$img = $map->draw() or die('Unable to draw map');
$url = $img->saveWebImage(MS_GIF, 0, 0, -1);


This is the portion of my map file that I think is relevant

LAYER
  NAME "zones"
  DATA Pdnad83_region
  STATUS DEFAULT
  TYPE POLYGON
  CLASSITEM "NAME"
  CLASS 
	NAME "NAME"
	OUTLINECOLOR 50 230 0
  END	
END

(I'm using mapscript for PHP 3.5 (pre-alpha) (Jul 20,2001) on PHP 4.0.6
running on top of IIS)

Thanks.  I'm really impressed with Mapscript and the Mapserv CGI exe so far.
Never thought mapping could be this easy.


Regina Obe
Senior Programmer
Department Of Neighborhood Development
City of Boston



More information about the mapserver-users mailing list