[postgis] query layer example
Paul Ramsey
pramsey at refractions.net
Wed Nov 7 08:37:11 PST 2001
LAYER
CONNECTIONTYPE postgis
NAME "tcn_highways"
DATA "geo_value from tcn_roads"
CONNECTION "user=pramsey dbname=postgis_demo"
STATUS ON
TYPE LINE
CLASS
COLOR 255 22 22
TEMPLATE postgis-query.html
END
END
Note that this is EXACTLY LIKE A QUERY LAYER USING SHAPEFILES, as noted
in the documentation. The only difference is in the template file
itself. I could completely bypass the need for a template file by
directly to a URL, for example:
LAYER
CONNECTIONTYPE postgis
NAME "tcn_highways"
DATA "geo_value from tcn_roads"
CONNECTION "user=pramsey dbname=postgis_demo"
STATUS ON
TYPE LINE
CLASS
COLOR 255 22 22
TEMPLATE http://qry.host.com/cgi-bin/queryscript.pl?id=[id]
END
END
The [id] parameter will be filled in with the value from the "id" field
of the nearest record to your query, and the request sent off.
The template file in the first example looks like this (rocket science,
this is not):
<HTML>
<HEADER>
<TITLE></TITLE>
</HEADER>
<BODY BGCOLOR=#FFFFFF>
<CENTER>
<TABLE WIDTH=50% BORDER=0 CELLPADDING=4 CELLSPACING=4>
<TR>
<TH BGCOLOR=#EEEEEE>geoid</TH>
<TD BGCOLOR=#EEFFEE>[geoid]</TD>
</TR>
<TR>
<TH BGCOLOR=#EEEEEE>street</TH>
<TD BGCOLOR=#EEFFEE>[street] </TD>
</TR>
<TR>
<TH BGCOLOR=#EEEEEE>fromleft</TH>
<TD BGCOLOR=#EEFFEE>[fromleft] </TD>
</TR>
<TR>
<TH BGCOLOR=#EEEEEE>toleft</TH>
<TD BGCOLOR=#EEFFEE>[toleft] </TD>
</TR>
<TR>
<TH BGCOLOR=#EEEEEE>fromright</TH>
<TD BGCOLOR=#EEFFEE>[fromright] </TD>
</TR>
<TR>
<TH BGCOLOR=#EEEEEE>toright</TH>
<TD BGCOLOR=#EEFFEE>[toright] </TD>
</TR>
<TR>
<TH BGCOLOR=#EEEEEE>type</TH>
<TD BGCOLOR=#EEFFEE>[type] </TD>
</TR>
</TABLE>
</TABLE>
</CENTER>
</BODY>
</HTML>
If you are using PHP mapscript or somesuch and will be processing your
queries with the scripting language, you can just stick a dummy value
into the 'TEMPLATE' mapfile parameter to indicate to the engine that you
want queries processed against that layer.
Remember, queries with postgis are just like queries with shapefiles,
the only difference is that the attributes are referenced in lower case.
That is the *only* difference (unless you find a bug).
gispmpf at yahoo.com.br wrote:
>
> Hello all,
>
> There is anywhere where i can find an example of the use of a
> Mapserver query layer with Postgis?
>
> thanks
> João.
>
> To unsubscribe from this group, send an email to:
> postgis-unsubscribe at yahoogroups.com
>
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
--
__
/
| Paul Ramsey
| Refractions Research
| Email: pramsey at refractions.net
| Phone: (250) 885-0632
\_
------------------------ Yahoo! Groups Sponsor ---------------------~-->
Universal Inkjet Refill Kit $29.95
Refill any ink cartridge for less!
Includes black and color ink.
http://us.click.yahoo.com/Vv.L9D/MkNDAA/ySSFAA/PhFolB/TM
---------------------------------------------------------------------~->
To unsubscribe from this group, send an email to:
postgis-unsubscribe at yahoogroups.com
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the postgis-users
mailing list