[mapserver-users] Querying layers for feature attributes
Steve Lime
Steve.Lime at dnr.state.mn.us
Fri Oct 9 08:22:56 PDT 2009
Here goes nothing (using the CGI)...
1. to make a layer queryable simply add a TEMPLATE directive to the layer definition. It need not
reference a real template file and just needs some value. I often use:
TEMPLATE 'dummy' # make this layer queryable
2. here you need to define the QUERYMAP object and set its STATUS to ON. The object itself is
very simple. You can choose from 3 types and can change the hilite color. There are three ways
to trigger the creation of the image
a. if the status is on then the image will automatically be created for you (in the temp directory)
and can be referenced in query template processing using the [img] tag.
b. all of the query-related CGI modes have a form that will retrieve just the query map. For example
you can do mode=NQUERYMAP or mode=ITEMNQUERYMAP. The list is long and unwieldy.
c. the newest method to retrieve just the query map is to use the qformat CGI variable. It selects
the output format to use to process the query results. It can be used to select templated formats
but also can be used to select image formats. For example, you might do:
...&mode=nquery&qformat=PNG24&...
This will be the preferred method moving forward. I hope simplify the modes list supported by the CGI
in version 6.0.
3. GML, well I have intended to expose the GML driver(s) as an output format but haven't done so. I'll
see about fixing that bug for 5.6. Besides switching to WFS queries (which return GML by default) you
can use the new style templating to do this for relatively simple data. Polygons with holes cannot be
effectively processes using the [shpxy ...] tag as it sits now. There's an example for GML 3 provided
at:
http://mapserver.org/development/rfc/ms-rfc-36.html
I'll do a documentation review to make sure these options are all described... Hope this helps.
Steve
>>> On 10/8/2009 at 6:29 PM, in message <1255044582462-3791433.post at n2.nabble.com>,
Ted Spradley <tspradley at snoogems.com> wrote:
> Hi all!
>
> Trying to step through building a basic Mapserver application.
>
> I am having difficulty discovering how to query my layers and display
> the query result(s). Can someone point me to documention or outline
> the basic steps needed to:
>
> 1. make a mapfile layer queryable?
> 2. output the query results as an image?
> 3. output the query results as gml?
>
> I have been trying to gleen this information from the documentation for at
> least two weeks and have to admit I am lost.
>
> I have successfully:
>
> 1. output maps to a html template
> 2. output maps to a html template from a mapfile whose
> layers are CONNECTIONTYPE POSTGIS
> 3. output maps from query results with queries built into
> my MAPFILE DATA object using POSTGIS with hardcoded
> values for column names in my pgsql database
>
>
> I have found doc references that are not all clear to:
>
> 1. the QUERYMAP object within the MAP object
> 2. the TEMPLATE object within the LAYER object
> 3. the OUTPUTFORMAT object within the MAP object
> 4. the FORMATOPTION object within the OUTPUTFORMAT object
>
> I am sure there must exist a way to:
>
> 1. pass a query to the mapfile containing cgi variable values
> 2. define the mode for mapserv to know a query is coming
> 3. output the results graphically and as text
>
> Thanks for any guidance,
>
> Ted S.
>
> MapServer version 5.4.1 OUTPUT=GIF OUTPUT=PNG OUTPUT=JPEG OUTPUT=WBMP
> OUTPUT=SVG SUPPORTS=PROJ SUPPORTS=FREETYPE SUPPORTS=ICONV
> SUPPORTS=WMS_SERVER SUPPORTS=WMS_CLIENT SUPPORTS=WFS_SERVER
> SUPPORTS=WFS_CLIENT SUPPORTS=WCS_SERVER SUPPORTS=THREADS INPUT=EPPL7
> INPUT=POSTGIS INPUT=OGR INPUT=GDAL INPUT=SHAPEFILE
More information about the MapServer-users
mailing list