[Mapserver-users] Itemquery - zooming to features

Mike Reilly mikereilly_7 at hotmail.com
Thu Jul 8 04:03:06 EDT 2004


This is a multi-part message in MIME format.

------=_NextPart_000_3378_307b_60ca
Content-Type: text/plain; format=flowed

Thanks Javier and Adam - you both got me past that error - and on to the 
next one:

msQueryByAttributes(): Search returned no results. No matching record(s) 
found.

And after re-reading Javier's response to me, I found that using the 
following did the trick:

qstring=([SITEID]=1003)

At first I tried qstring=([SITEID]="1003") but got a lot of parse fails 
along with the error message.  It now looks like I'm getting the results I 
need, although I'm not getting the maps drawn yet.   No images created in 
the /tmp/ directory.

I'm including a copy of the template file in case I've made an error in it.

>From: Javier Castillejo Montes <jcastil1 at tragsa.es>
>To: Mike Reilly <mikereilly_7 at hotmail.com>
>CC: mapserver-users at lists.gis.umn.edu
>Subject: RE: [Mapserver-users] Itemquery - zooming to features
>Date: Thu, 8 Jul 2004 09:11:19 +0200
>
>Hi Mike
>I had the same problem and "David Fawcett" told me the solution... here it
>is
>
> >>>>The syntax for itemqueries changed after version 3.5 or so.
>
> >>>>Queries no longer use a filter in the Map file.  Instead, you need to
> >>>>pass the variables 'qlayer', 'qitem', and 'qstring' in the URL.  They
> >>>>are documented here:
> >>>>http://mapserver.gis.umn.edu/doc42/cgi-reference.html#qitem
>
> >>>>It should look something like:
>
> >>>>...&qlayer=layer1&qitem=FIELD2&qstring=('[FIELD2]'='10')
>
> >>>>&qlayer=provin&qitem=NOMBRE&qstring='Juarez'
>
> >>>>(This assumes that there is a 'provin' with the name 'Juarez'.  If you
> >>>>build this URL string dynamically in the form at the bottom of this
> >>>>message, it should look something like this:
>
> >>>><td><img border="2"
> >>>>src="[mapserv]?map=[map]
> >>>>&name=&mode=itemquerymap&mapext=shapes&qlayer=provin&qitem=NOMBRE&qstrin
>g='[name_esc]'
> >>>>" height="300" width="300"></td>
>
>
>my "end" map file!!
>
>   LAYER
>     NAME provin
>     DATA provin
>     STATUS DEFAULT
>     TYPE POLYGON
>     FILTERITEM nombre
>     CLASS
>       COLOR 212 212 212
>       OUTLINECOLOR 0 0 0
>       TEMPLATE "../html/case1_template.html"
>     END
>   END
>
>my html snip
>...
><input type="hidden" name="mode" value="itemquery">
><input type="hidden" name="qlayer" value="provin">
>
><input type="hidden" name="qitem" value="Prov">
><input type="hidden" name="qstring" value="[name_esc]">
>...
>
>
>Hope It will help you, for me it works...
>
>
>Javier C.
>
>
>-----Mensaje original-----
>De: Mike Reilly [mailto:mikereilly_7 at hotmail.com]
>Enviado el: jueves, 08 de julio de 2004 0:38
>Para: mapserver-users at lists.gis.umn.edu
>Asunto: [Mapserver-users] Itemquery - zooming to features
>
>
>I have a mapserver application running quite nicely and now want to add the
>ability to create a link that brings up a map zoomed in to a feature based
>on that features SITEID field in a dbf file.  This feature is similar to
>that shown at this tutorial in case 1:
>http://maps.dnr.state.mn.us/mapserver_demos/tests40/itemquery/test.html
>
>To that effect, I've basically copied the tutorial and placed in my own
>customisations to make it work with my data.  So far I've not been terribly
>succesful and get the following error:
>
>msQueryByAttributes(): Query error. No query expression defined.
>
>There is most definitely a field called SITEID in the dbf file for the
>mergeplys layer.  There is also a record with a SITEID of 1003.
>
>I am using mapserver 4.0 windows binary distribution.
>
>The URL that gets generated looks like this:
>
>http://192.168.0.3/cgi-bin/mapserv.exe?mapserv=f%3A%2Fprogram+files%2Fapache
>+group%2Fapache2%2Fcgi-bin%2Fmapserv.exe&map=f%3A%2Fprogram+files%2Fapache+g
>roup%2Fapache2%2Fhtdocs%2FKitasoo%2Fquerytest.map&map_web_imagepath=f%3A%2Fp
>rogram+files%2Fapache+group%2Fapache2%2Ftmp&map_web_imageurl=%2Ftmp%2F&mode=
>itemquery&qlayer=tuspoly&site_id=1003
>
>I'm pretty sure I'm missing something basic somewhere.  One issue (I don't
>think this is what is causing the error message) is found in the template
>file.  I'm not quite sure what to do with some of the variables in this
>spot:
>
>src="[mapserv]?map=[map]&name=[name_esc]&mode=itemquerymap&mapext=shapes&qla
>yer=[qlayer]"
>- I assume I need to change some of the values here.   Any advice or
>pointers to documentation greatly appreciated.
>
>The mapfile I created looks like this:
>
>MAP
>   NAME case1
>   SHAPEPATH tus
>   SIZE 300 300
>   EXTENT 768897.25886 810841.50306 876598.91242 913853.62854
>
>   WEB
>     IMAGEPATH 'f:/program files/apache group/apache2/htdocs/tmp/'
>     IMAGEURL 'http://192.168.0.3/tmp/'
>   END
>
>   QUERYMAP
>     STATUS ON
>     STYLE HILITE
>     COLOR 255 255 0
>   END
>
>   LAYER
>
>     NAME "landpl"
>     DATA "landpl"
>     STATUS DEFAULT
>     TYPE POLYGON
>     CLASS
>       COLOR 212 212 212
>       OUTLINECOLOR 0 0 0
>     END
>   END
>
>   LAYER
>     NAME tuspoly
>     DATA "mergeplys"
>     STATUS ON
>     TYPE POLYGON
>     FILTERITEM SITEID
>     FILTER "%site_id%"
>     CLASS
>	COLOR 160 160 255
>     	OUTLINECOLOR 0 200 0
>	TEMPLATE case1_template.html
>     END
>   END
>END
>
>My HTML file used to generate the URL should be attached (I hope!).
>
>_________________________________________________________________
>Add photos to your e-mail with MSN Premium. Get 2 months FREE*
>http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=htt
>p://hotmail.com/enca&HL=Market_MSNIS_Taglines

_________________________________________________________________
MSN Premium includes powerful parental controls and get 2 months FREE*   
http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines

------=_NextPart_000_3378_307b_60ca
Content-Type: text/html; name="case1_template.html"
Content-Transfer-Encoding: 8bit
Content-Disposition: attachment; filename="case1_template.html"

<html>
<head>
  <title>MapServer Test Suite - ItemQuery</title>
</head>

<body bgcolor="#ffffff">

<font size="+2" face="arial,helvetica"><b>Case 1: Simple ItemQuery With QueryMap</b></font>

<p>

This is just a simple dump of a few attributes for an individual polygon
in the test suites counties layer:

<p>

<b>Name:</b> <br>
<b>ID Number:</b> [SITEID]<br>
<b>Abbreviation Code:</b> <br>

<p>

and here's the map of the query results (you can zoom to a set of results as well):

<p>

<table cellpadding="5">
<tr>
<td><img border="2" src="[img]" height="300" width="300"></td>
<td><img border="2" src="[mapserv]?map=[map]&name=[name_esc]&mode=itemquerymap&mapext=shapes&qlayer=tuspoly&qstring=(SITEID=1003)" height="300" width="300"></td>
</tr>
</table>

</body>
</html>



------=_NextPart_000_3378_307b_60ca--



More information about the mapserver-users mailing list