Multiple Layer Queries
Ken Lord
kenlord at GMAIL.COM
Thu Aug 25 17:27:32 PDT 2005
Hi Rebecca,
It appears you are using the CGI flavour of MapServer, which is also how I
use MapServer.
The header / footer and results templates work as follows: (at least the
way I do it)
1. you submit your query to mapserver, by clicking on the map (or sending
query information via URL parameters).
2. MapServer parses together the results webpage, starting with the main
Header file, which you use to layout the structure of the page, such as a
title, the start of a table to show the results, whatever else you want at
the top of your page, etc.
3. For the first layer containing query results, MapServer parses the
Header template you've made that is specific to that map layer, the HEADER
"xxx" parameter within a layer in your mapfile.
This header can be used to add the layer name, attribute names etc for that
layer, and to layout the table structure specifically for the data that is
retrieved for this layer.
4. MapServer parses through the TEMPLATE "xxx" file for the first layer
that has results. think of this as a 'results' template. This file is
processed once for each result found for that layer by the query, if you've
set it up as a table, this template adds rows of results into the resulting
webpage.
5. steps 3 and 4 are repeated for any other layers that returned results.
6. MapServer closes off the webpage with the Footer template, where you can
close off the html table, or add whatever you want to be shown beneath the
results.
You list your main Header and Footer template files in the WEB section of
your mapfile. Every layer for which you want to show query results must have
its own Header and Template files. I find it convenient to name them to
match the name of your layer, with a _header or _results appended to the
end, such as soilassay_header.htm and soilassay_results.htm.
The CGI values in your result templates need to be [UPPER_CASE] for
shapefile layers, and [lower_case] for postgis layers.
It is a good idea to include a TOLERANCE and TOLERANCEUNITS for each layer
being queried, some versions of mapserver have some funny quirks if you
leave them out.
I would suggest that you take your existing queryresults_template file, and
split it out into the main Header and Footer files, and a header and
template file for that first layer, then copy and modify the header and
template files to suit the other layers for which you want results.
You can view how this system works for me at the following mapserver
website:
http://24.87.220.99/ms/iwafs.html
... Click on the 'Highlights' tab at the top right of the page, and then
view map number 3. Query the map with the ' i ' tool in a spot where there's
lots of big and small point symbols close together. You should end up with a
list of Soil Geochem and Drill Hole query results.
Good luck,
Ken Lord
Vancouver BC
On 8/25/05, Rebecca Colwell <rcolwell at willcountyillinois.com> wrote:
>
> Hi Everybody,
>
> I'm working on a new mapserver app after a long hiatus. I'd like to query
> two layers (Parcels and Zoning Districts)and have their attributes shown
> in
> the QueryResults_template.html. I'm using NQUERY, but am still only
> getting
> results from one layer in the results table.
>
> I know this is not a new question, but I'm having a hard time deciphering
> all the necessary steps from the tutorial, and haven't found the answers
> on
> previous list posts. I don't understand header/footer files. In case
> that's part of the answer, please share their significance in the process.
> Any help would be most appreciated. I'll post my
> queryResults_template.html
> below in case that'll help unlock the mystery.
>
> Thanks!
>
> ~Becky
>
> <html>
> <head>
> <title>Airport Query Results</title>
> </head>
> <body>
> <b><i><font size="5" face="Georgia, Times New Roman, Times, serif">2005
> Will
> County Regional Airport<br>
> </font></i></b>
> <table>
> <tr>
> <td width="300" valign="top"><br><p><font
> face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular"><br>
> <img
>
> src="/cgi-bin/mapserv?map=/home/colwell/public_html/Airport2/Map2.map&mapsize=300+225&mapxy=[shpmidx]+[shpmidy]&mapext=[shpext_esc]&scale=50000&state=[PIN]&mode=map"
> border="1"></font></p></td>
> </tr>
> </table>
> <br>
> <br>
> <table width="331" border="1" cellspacing="2" cellpadding="0"
> height="167">
> <tr>
> <td></td>
> <td align="right"></td>
> </tr>
> <tr>
> <td>Parcel #</td>
> <td align="right">[PIN]</td>
> </tr>
> <tr>
> <td>Owner(s)</td>
> <td align="right">[OWNER_1]</td>
> </tr>
> <tr>
> <td>Address</td>
> <td align="right">[STREET]</td>
> </tr>
> <tr>
> <td>City/State/Zip</td>
> <td align="right">[CITY], [ZIP1]</td>
> </tr>
> <tr>
> <td>Township</td>
> <td align="right">[TWP_NAME]</td>
> </tr>
> <tr>
> <td>Zowning District</td>
> <td align="right">[ZONE_TYPE]</td>
> </tr>
> </table>
> <p></p>
> <table width="331" border="1" cellspacing="2" cellpadding="0" height="98">
> <tr>
> <td>Sale Date</td>
> <td align="right"></td>
> </tr>
> <tr>
> <td>Sale Amount</td>
> <td align="right"></td>
> </tr>
> <tr>
> <td>Acreage</td>
> <td align="right">[ACREAGE] acres</td>
> </tr>
> <tr>
> <td></td>
> <td align="right"></td>
> </tr>
> </table>
> <p><font face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular"></font></p>
> </body>
> </html>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20050825/6a33ce47/attachment.htm>
More information about the MapServer-users
mailing list