[Mapserver-users] Itemquery - zooming to features

Javier Castillejo Montes jcastil1 at tragsa.es
Thu Jul 8 03:11:19 EDT 2004


This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_=_NextPart_001_01C464BA.E333915E
Content-Type: text/plain;
	charset="iso-8859-1"

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

------_=_NextPart_001_01C464BA.E333915E
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Diso-8859-1">
<META NAME=3D"Generator" CONTENT=3D"MS Exchange Server version =
5.5.2650.12">
<TITLE>RE: [Mapserver-users] Itemquery - zooming to features</TITLE>
</HEAD>
<BODY>

<P><FONT SIZE=3D2>Hi Mike </FONT>
<BR><FONT SIZE=3D2>I had the same problem and &quot;David Fawcett&quot; =
told me the solution... here it is</FONT>
</P>

<P><FONT SIZE=3D2>&gt;&gt;&gt;&gt;The syntax for itemqueries changed =
after version 3.5 or so.&nbsp; </FONT>
</P>

<P><FONT SIZE=3D2>&gt;&gt;&gt;&gt;Queries no longer use a filter in the =
Map file.&nbsp; Instead, you need to</FONT>
<BR><FONT SIZE=3D2>&gt;&gt;&gt;&gt;pass the variables 'qlayer', =
'qitem', and 'qstring' in the URL.&nbsp; They</FONT>
<BR><FONT SIZE=3D2>&gt;&gt;&gt;&gt;are documented here: </FONT>
<BR><FONT SIZE=3D2>&gt;&gt;&gt;&gt;<A =
HREF=3D"http://mapserver.gis.umn.edu/doc42/cgi-reference.html#qitem" =
TARGET=3D"_blank">http://mapserver.gis.umn.edu/doc42/cgi-reference.html#=
qitem</A> </FONT>
</P>

<P><FONT SIZE=3D2>&gt;&gt;&gt;&gt;It should look something like:</FONT>
</P>

<P><FONT =
SIZE=3D2>&gt;&gt;&gt;&gt;...&amp;qlayer=3Dlayer1&amp;qitem=3DFIELD2&amp;=
qstring=3D('[FIELD2]'=3D'10')</FONT>
</P>

<P><FONT =
SIZE=3D2>&gt;&gt;&gt;&gt;&amp;qlayer=3Dprovin&amp;qitem=3DNOMBRE&amp;qst=
ring=3D'Juarez'</FONT>
</P>

<P><FONT SIZE=3D2>&gt;&gt;&gt;&gt;(This assumes that there is a =
'provin' with the name 'Juarez'.&nbsp; If you</FONT>
<BR><FONT SIZE=3D2>&gt;&gt;&gt;&gt;build this URL string dynamically in =
the form at the bottom of this</FONT>
<BR><FONT SIZE=3D2>&gt;&gt;&gt;&gt;message, it should look something =
like this:&nbsp; </FONT>
</P>

<P><FONT SIZE=3D2>&gt;&gt;&gt;&gt;&lt;td&gt;&lt;img =
border=3D&quot;2&quot;</FONT>
<BR><FONT =
SIZE=3D2>&gt;&gt;&gt;&gt;src=3D&quot;[mapserv]?map=3D[map]</FONT>
<BR><FONT =
SIZE=3D2>&gt;&gt;&gt;&gt;&amp;name=3D&amp;mode=3Ditemquerymap&amp;mapext=
=3Dshapes&amp;qlayer=3Dprovin&amp;qitem=3DNOMBRE&amp;qstring=3D'[name_es=
c]'</FONT>
<BR><FONT SIZE=3D2>&gt;&gt;&gt;&gt;&quot; height=3D&quot;300&quot; =
width=3D&quot;300&quot;&gt;&lt;/td&gt;</FONT>
</P>
<BR>

<P><FONT SIZE=3D2>my &quot;end&quot; map file!!</FONT>
</P>

<P><FONT SIZE=3D2>&nbsp; LAYER</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp; NAME provin</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp; DATA provin</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp; STATUS DEFAULT</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp; TYPE POLYGON</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp; FILTERITEM nombre</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp; CLASS</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; COLOR 212 212 =
212</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; OUTLINECOLOR 0 0 =
0</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TEMPLATE =
&quot;../html/case1_template.html&quot;</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp; END</FONT>
<BR><FONT SIZE=3D2>&nbsp; END</FONT>
</P>

<P><FONT SIZE=3D2>my html snip</FONT>
<BR><FONT SIZE=3D2>...</FONT>
<BR><FONT SIZE=3D2>&lt;input type=3D&quot;hidden&quot; =
name=3D&quot;mode&quot; value=3D&quot;itemquery&quot;&gt;</FONT>
<BR><FONT SIZE=3D2>&lt;input type=3D&quot;hidden&quot; =
name=3D&quot;qlayer&quot; value=3D&quot;provin&quot;&gt;</FONT>
</P>

<P><FONT SIZE=3D2>&lt;input type=3D&quot;hidden&quot; =
name=3D&quot;qitem&quot; value=3D&quot;Prov&quot;&gt;</FONT>
<BR><FONT SIZE=3D2>&lt;input type=3D&quot;hidden&quot; =
name=3D&quot;qstring&quot; value=3D&quot;[name_esc]&quot;&gt;</FONT>
<BR><FONT SIZE=3D2>...</FONT>
</P>
<BR>

<P><FONT SIZE=3D2>Hope It will help you, for me it works...</FONT>
</P>
<BR>

<P><FONT SIZE=3D2>Javier C.</FONT>
</P>
<BR>

<P><FONT SIZE=3D2>-----Mensaje original-----</FONT>
<BR><FONT SIZE=3D2>De: Mike Reilly [<A =
HREF=3D"mailto:mikereilly_7 at hotmail.com">mailto:mikereilly_7 at hotmail.com=
</A>]</FONT>
<BR><FONT SIZE=3D2>Enviado el: jueves, 08 de julio de 2004 0:38</FONT>
<BR><FONT SIZE=3D2>Para: mapserver-users at lists.gis.umn.edu</FONT>
<BR><FONT SIZE=3D2>Asunto: [Mapserver-users] Itemquery - zooming to =
features</FONT>
</P>
<BR>

<P><FONT SIZE=3D2>I have a mapserver application running quite nicely =
and now want to add the </FONT>
<BR><FONT SIZE=3D2>ability to create a link that brings up a map zoomed =
in to a feature based </FONT>
<BR><FONT SIZE=3D2>on that features SITEID field in a dbf file.&nbsp; =
This feature is similar to </FONT>
<BR><FONT SIZE=3D2>that shown at this tutorial in case 1: </FONT>
<BR><FONT SIZE=3D2><A =
HREF=3D"http://maps.dnr.state.mn.us/mapserver_demos/tests40/itemquery/te=
st.html" =
TARGET=3D"_blank">http://maps.dnr.state.mn.us/mapserver_demos/tests40/it=
emquery/test.html</A></FONT>
</P>

<P><FONT SIZE=3D2>To that effect, I've basically copied the tutorial =
and placed in my own </FONT>
<BR><FONT SIZE=3D2>customisations to make it work with my data.&nbsp; =
So far I've not been terribly </FONT>
<BR><FONT SIZE=3D2>succesful and get the following error:</FONT>
</P>

<P><FONT SIZE=3D2>msQueryByAttributes(): Query error. No query =
expression defined.</FONT>
</P>

<P><FONT SIZE=3D2>There is most definitely a field called SITEID in the =
dbf file for the </FONT>
<BR><FONT SIZE=3D2>mergeplys layer.&nbsp; There is also a record with a =
SITEID of 1003.</FONT>
</P>

<P><FONT SIZE=3D2>I am using mapserver 4.0 windows binary =
distribution.</FONT>
</P>

<P><FONT SIZE=3D2>The URL that gets generated looks like this:</FONT>
</P>

<P><FONT =
SIZE=3D2>http://192.168.0.3/cgi-bin/mapserv.exe?mapserv=3Df%3A%2Fprogram=
+files%2Fapache+group%2Fapache2%2Fcgi-bin%2Fmapserv.exe&amp;map=3Df%3A%2=
Fprogram+files%2Fapache+group%2Fapache2%2Fhtdocs%2FKitasoo%2Fquerytest.m=
ap&amp;map_web_imagepath=3Df%3A%2Fprogram+files%2Fapache+group%2Fapache2=
%2Ftmp&amp;map_web_imageurl=3D%2Ftmp%2F&amp;mode=3Ditemquery&amp;qlayer=3D=
tuspoly&amp;site_id=3D1003</FONT></P>

<P><FONT SIZE=3D2>I'm pretty sure I'm missing something basic =
somewhere.&nbsp; One issue (I don't </FONT>
<BR><FONT SIZE=3D2>think this is what is causing the error message) is =
found in the template </FONT>
<BR><FONT SIZE=3D2>file.&nbsp; I'm not quite sure what to do with some =
of the variables in this </FONT>
<BR><FONT SIZE=3D2>spot:</FONT>
</P>

<P><FONT =
SIZE=3D2>src=3D&quot;[mapserv]?map=3D[map]&amp;name=3D[name_esc]&amp;mod=
e=3Ditemquerymap&amp;mapext=3Dshapes&amp;qlayer=3D[qlayer]&quot;</FONT>
<BR><FONT SIZE=3D2>- I assume I need to change some of the values =
here.&nbsp;&nbsp; Any advice or </FONT>
<BR><FONT SIZE=3D2>pointers to documentation greatly =
appreciated.</FONT>
</P>

<P><FONT SIZE=3D2>The mapfile I created looks like this:</FONT>
</P>

<P><FONT SIZE=3D2>MAP</FONT>
<BR><FONT SIZE=3D2>&nbsp; NAME case1</FONT>
<BR><FONT SIZE=3D2>&nbsp; SHAPEPATH tus</FONT>
<BR><FONT SIZE=3D2>&nbsp; SIZE 300 300</FONT>
<BR><FONT SIZE=3D2>&nbsp; EXTENT 768897.25886 810841.50306 876598.91242 =
913853.62854</FONT>
</P>

<P><FONT SIZE=3D2>&nbsp; WEB</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp; IMAGEPATH 'f:/program =
files/apache group/apache2/htdocs/tmp/'</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp; IMAGEURL '<A =
HREF=3D"http://192.168.0.3/tmp/'" =
TARGET=3D"_blank">http://192.168.0.3/tmp/'</A></FONT>
<BR><FONT SIZE=3D2>&nbsp; END</FONT>
</P>

<P><FONT SIZE=3D2>&nbsp; QUERYMAP</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp; STATUS ON</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp; STYLE HILITE</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp; COLOR 255 255 0</FONT>
<BR><FONT SIZE=3D2>&nbsp; END</FONT>
</P>

<P><FONT SIZE=3D2>&nbsp; LAYER</FONT>
</P>

<P><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp; NAME &quot;landpl&quot;</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp; DATA &quot;landpl&quot;</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp; STATUS DEFAULT</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp; TYPE POLYGON</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp; CLASS</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; COLOR 212 212 =
212</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; OUTLINECOLOR 0 0 =
0</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp; END</FONT>
<BR><FONT SIZE=3D2>&nbsp; END</FONT>
</P>

<P><FONT SIZE=3D2>&nbsp; LAYER</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp; NAME tuspoly</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp; DATA &quot;mergeplys&quot;</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp; STATUS ON</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp; TYPE POLYGON</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp; FILTERITEM SITEID</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp; FILTER =
&quot;%site_id%&quot;</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp; CLASS</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=3D2>COLOR 160 =
160 255</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; OUTLINECOLOR 0 =
200 0</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=3D2>TEMPLATE =
case1_template.html</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp; END</FONT>
<BR><FONT SIZE=3D2>&nbsp; END</FONT>
<BR><FONT SIZE=3D2>END</FONT>
</P>

<P><FONT SIZE=3D2>My HTML file used to generate the URL should be =
attached (I hope!).</FONT>
</P>

<P><FONT =
SIZE=3D2>_______________________________________________________________=
__</FONT>
<BR><FONT SIZE=3D2>Add photos to your e-mail with MSN Premium. Get 2 =
months FREE*&nbsp; </FONT>
<BR><FONT SIZE=3D2><A =
HREF=3D"http://join.msn.com/?pgmarket=3Den-ca&page=3Dbyoa/prem&xAPID=3D1=
994&DI=3D1034&SU=3Dhttp://hotmail.com/enca&HL=3DMarket_MSNIS_Taglines" =
TARGET=3D"_blank">http://join.msn.com/?pgmarket=3Den-ca&page=3Dbyoa/prem=
&xAPID=3D1994&DI=3D1034&SU=3Dhttp://hotmail.com/enca&HL=3DMarket_MSNIS_T=
aglines</A></FONT></P>

</BODY>
</HTML>
------_=_NextPart_001_01C464BA.E333915E--



More information about the mapserver-users mailing list