[Mapserver-users] Itemquery - zooming to features

Javier Castillejo Montes jcastil1 at tragsa.es
Thu Jul 8 00:11:19 PDT 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 "David Fawcett" =
told me the solution... here it is</FONT>
</P>

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

<P><FONT SIZE=3D2>>>>>Queries no longer use a filter in the =
Map file.  Instead, you need to</FONT>
<BR><FONT SIZE=3D2>>>>>pass the variables 'qlayer', =
'qitem', and 'qstring' in the URL.  They</FONT>
<BR><FONT SIZE=3D2>>>>>are documented here: </FONT>
<BR><FONT SIZE=3D2>>>>><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>>>>>It should look something like:</FONT>
</P>

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

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

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

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

<P><FONT SIZE=3D2>my "end" map file!!</FONT>
</P>

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

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

<P><FONT SIZE=3D2><input type=3D"hidden" =
name=3D"qitem" value=3D"Prov"></FONT>
<BR><FONT SIZE=3D2><input type=3D"hidden" =
name=3D"qstring" value=3D"[name_esc]"></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.  =
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.  =
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.  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&map=3Df%3A%2=
Fprogram+files%2Fapache+group%2Fapache2%2Fhtdocs%2FKitasoo%2Fquerytest.m=
ap&map_web_imagepath=3Df%3A%2Fprogram+files%2Fapache+group%2Fapache2=
%2Ftmp&map_web_imageurl=3D%2Ftmp%2F&mode=3Ditemquery&qlayer=3D=
tuspoly&site_id=3D1003</FONT></P>

<P><FONT SIZE=3D2>I'm pretty sure I'm missing something basic =
somewhere.  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.  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"[mapserv]?map=3D[map]&name=3D[name_esc]&mod=
e=3Ditemquerymap&mapext=3Dshapes&qlayer=3D[qlayer]"</FONT>
<BR><FONT SIZE=3D2>- I assume I need to change some of the values =
here.   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>  NAME case1</FONT>
<BR><FONT SIZE=3D2>  SHAPEPATH tus</FONT>
<BR><FONT SIZE=3D2>  SIZE 300 300</FONT>
<BR><FONT SIZE=3D2>  EXTENT 768897.25886 810841.50306 876598.91242 =
913853.62854</FONT>
</P>

<P><FONT SIZE=3D2>  WEB</FONT>
<BR><FONT SIZE=3D2>    IMAGEPATH 'f:/program =
files/apache group/apache2/htdocs/tmp/'</FONT>
<BR><FONT SIZE=3D2>    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>  END</FONT>
</P>

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

<P><FONT SIZE=3D2>  LAYER</FONT>
</P>

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

<P><FONT SIZE=3D2>  LAYER</FONT>
<BR><FONT SIZE=3D2>    NAME tuspoly</FONT>
<BR><FONT SIZE=3D2>    DATA "mergeplys"</FONT>
<BR><FONT SIZE=3D2>    STATUS ON</FONT>
<BR><FONT SIZE=3D2>    TYPE POLYGON</FONT>
<BR><FONT SIZE=3D2>    FILTERITEM SITEID</FONT>
<BR><FONT SIZE=3D2>    FILTER =
"%site_id%"</FONT>
<BR><FONT SIZE=3D2>    CLASS</FONT>
<BR>        <FONT SIZE=3D2>COLOR 160 =
160 255</FONT>
<BR><FONT SIZE=3D2>        OUTLINECOLOR 0 =
200 0</FONT>
<BR>        <FONT SIZE=3D2>TEMPLATE =
case1_template.html</FONT>
<BR><FONT SIZE=3D2>    END</FONT>
<BR><FONT SIZE=3D2>  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*  </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