[mapserver-users] Querying layers for feature attributes

Ted Spradley tspradley at snoogems.com
Sat Oct 10 08:37:09 PDT 2009


Thank you Steve.   A couple of questions.


Steve Lime wrote:
> 
> 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
> 
> 

I believe I have the map file component in place.  (At least GetCapabilities
request for both WMS returns the layers as queryable and WFS GetCapabilities
returns specified layers as <FeatureType>).  Although
I don't believe either WMS or WFS Server is necessary here?  Just a simple
mapfile with a polygon 
layer in my case that is either created by a shapefile or PostGIS data
correct?


Steve Lime wrote:
> 
> 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&...
> 

You posted an example of what I am trying to accomplish at:
http://maps.dnr.state.mn.us/cgi-bin/mapserv48?map=/usr/local/www/docs_maps/eco/rsg/search/search_example.map&qlayer=county&mode=nquery&searchmap=true

Could you post the files associated with this?

I am assuming the components are:
1. mapfile
2. mapserver html template (viewable with view source, but the source prior
to your query building the map image?)
3. These directives referenced by David in his page
http://mapserver.org/output/imagemaps.html:
   LAYER 
      DATA 'aqiAreas'
        TEMPLATE "bodytemplate.html"  #### Is this the same TEMPLATE
directive you made 'dummy'?
        HEADER "imapheader.html"
        FOOTER "imapfooter.html"

4. Seems that the TEMPLATE directive in #3 above is indispensable and is the
heart of the ap.  
    It is the query template file?  Shouldn't that have a format:
<area shape="poly" coords="[shpxy precision=0 proj=image]"
href="http://my.url/mypage.cfm?ID=[SITE_ID]" title="[NAME]" alt="[NAME]">

   If so, then I believe my question boils down to the components in the
url.  
      a. http://my.url/mypage.cfm? - this is a template page with html place
holders for [img], etc?
      b.  [] variables in the url.  These are data variables?  I am assuming
the [NAME] is some
           attribute (column) of a shape file?
          [SITE_ID]? is some other data attribute?

Sorry for being dense here.  It feels kind of like trying to recreate an
orange by having it described 
with out getting to see the orange or missing some key piece of information
like I need to go plant 
a tree :-)

Thanks again.  Your patience is admirable.

Ted S.


Steve Lime wrote:
> 
> 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
> 
> _______________________________________________
> mapserver-users mailing list
> mapserver-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapserver-users
> 
> 

-- 
View this message in context: http://n2.nabble.com/Querying-layers-for-feature-attributes-tp3791433p3800180.html
Sent from the Mapserver - User mailing list archive at Nabble.com.



More information about the MapServer-users mailing list