[mapserver-users] query creation issues

Lime, Steve D (MNIT) Steve.Lime at state.mn.us
Wed Mar 20 11:41:52 PDT 2013


Straight item tags like that ARE case sensitive. Try  [item name="name"] and [item name="type"] instead.

From: Mark Mirrlees [mailto:mmirrlees at hotmail.com]
Sent: Wednesday, March 20, 2013 1:33 PM
To: Lime, Steve D (MNIT); mapserver-users at lists.osgeo.org
Subject: RE: [mapserver-users] query creation issues

Hi Steve,

Unfortunately that didn't work! But I did manage to get the ID chracteristic outputted as I forgot to include that previously. As when I went to edit the query.html page it shows this

ID

Name

Type

1275

[name]

[type]


Here is the code that is causing issues for me...

<!-- MapServer Template -->
<!--<IMG src="http://[host]/cgi-bin/mapserv.exe?mode=INDEXQUERY&qformat=png24&qlayer=mjrroads&shapeindex=[shpidx]&shpext=[shpext_esc]&mapext=shape&map=[map<http://[host]/cgi-bin/mapserv.exe?mode=INDEXQUERY&qformat=png24&qlayer=mjrroads&shapeindex=%5bshpidx%5d&shpext=%5bshpext_esc%5d&mapext=shape&map=%5bmap>]">-->
<tr>
 <td>[shpidx]</td>
    <tr><td>[name]</td></tr>
 <tr><td>[type]</td></tr>
</tr>

While this is the code for the header...

<!-- MapServer Template -->
<h3><b>Layer: Major Roads</b></h3>
<br>
<INPUT NAME="img" TYPE="image" SRC="[img]" width=500 height=500 border=0 ALT="Map Image">
<table border=1>
<tr> </td>
 <th>ID</th>
 <th>Name</th>
 <th>Type</th>
</tr>

As what i'm trying to do is get the name (name of road outputted) and the type (either expressway or major road)

Thanks,
Mark

________________________________
From: Steve.Lime at state.mn.us<mailto:Steve.Lime at state.mn.us>
To: mmirrlees at hotmail.com<mailto:mmirrlees at hotmail.com>; mapserver-users at lists.osgeo.org<mailto:mapserver-users at lists.osgeo.org>
Subject: RE: [mapserver-users] query creation issues
Date: Wed, 20 Mar 2013 18:22:29 +0000
You need to refer to the attributes next...

<tr><td>[NAME]</td><td>[TYPE]</td></tr>

Steve

From: Mark Mirrlees [mailto:mmirrlees at hotmail.com]
Sent: Wednesday, March 20, 2013 12:16 PM
To: Lime, Steve D (MNIT); mapserver-users at lists.osgeo.org<mailto:mapserver-users at lists.osgeo.org>
Subject: RE: [mapserver-users] query creation issues


Hi Steve,

Thanks for your help. I've managed to get the query outputted. I have a couple of additional questions...after creating my query I need the footer to show the "name" and the "type" (based on the shapefile information), as based on the footer.html below

<!-- MapServer Template -->
<h3><b>Layer: Major Roads</b></h3>
<br>
<INPUT NAME="img" TYPE="image" SRC="[img]" width=500 height=500 border=0 ALT="Map Image">
<table border=1>
<tr> </td>
 <th>Name</th>
 <th>Type</th>
</tr>
 As when I launch my query it only shows...

Name

Type




Based on readings from the mapserver website, it looks like I have to edit the query.html to make this populated...but not sure where (global.map file?) I can get this information that is supposed to go between the <td> and </td> tags.

<!-- MapServer Template -->
<!--<IMG src="http://[host]/cgi-bin/mapserv.exe?mode=INDEXQUERY&qformat=png24&qlayer=mjrroads&shapeindex=[shpidx]&shpext=[shpext_esc]&mapext=shape&map=[map]<http://[host]/cgi-bin/mapserv.exe?mode=INDEXQUERY&qformat=png24&qlayer=mjrroads&shapeindex=%5bshpidx%5d&shpext=%5bshpext_esc%5d&mapext=shape&map=%5bmap%5d>">-->
<tr>
 <td> </td>
 <td></td>
</tr>

Thanks,
Mark
> From: Steve.Lime at state.mn.us<mailto:Steve.Lime at state.mn.us>
> To: mmirrlees at hotmail.com<mailto:mmirrlees at hotmail.com>; mapserver-users at lists.osgeo.org<mailto:mapserver-users at lists.osgeo.org>
> Subject: RE: [mapserver-users] query creation issues
> Date: Wed, 20 Mar 2013 17:00:47 +0000
>
> Hi Mark: Personally I'd steer you to the simplified query templates as described here:
>
> http://mapserver.org/development/rfc/ms-rfc-36.html
>
> This allows you to put everything in one place and better separates data from presentation. No more header/footer's. Plus you can have multiple presentations for the same layer.
>
> That said, the mapfile below doesn't have any queryable layers. There is no TEMPLATE defined for the one layer that is present.
>
> If you want to use the new style templating you'd do something like this:
>
> 1- Define an output format:
>
> OUTPUTFORMAT
> NAME 'my-template'
> DRIVER 'TEMPLATE'
> MIMETYPE 'text/html; subtype=compass'
> FORMATOPTION "FILE=templates/my-template.html"
> END
>
> 2- Optionally make it the default query format (otherwise you need to use qformat CGI parameter):
>
> WEB
> QUERYFORMAT 'my-template'
> ...
> END
>
> 3- Make layers queryable by adding something like:
>
> TEMPLATE 'void'
>
> 4- Write your template, for example my-template.html might look like:
>
> --- snip ---
> <!-- MapServer Template -->
> This is my template:<br/>
>
> [resultset layer="mjrroads"]
> [feature]<b>Type</b>: [TYPE][/feature]
> [/resultset]
>
> Done presenting layers.
> --- snip ---
>
> Steve
>
> From: mapserver-users-bounces at lists.osgeo.org<mailto:mapserver-users-bounces at lists.osgeo.org> [mailto:mapserver-users-bounces at lists.osgeo.org] On Behalf Of Mark Mirrlees
> Sent: Wednesday, March 20, 2013 10:45 AM
> To: mapserver-users at lists.osgeo.org<mailto:mapserver-users at lists.osgeo.org>
> Subject: [mapserver-users] query creation issues
>
> Hello everyone,
>
> I'm trying to create a query so I can query the roads/expressways from the map. I'm pretty sure I have created the headers and footers correctly but not sure...regardless i'm not entirely too sure where to stick the particular code in my .map file (shown below). I have bolded the code that I'm trying to incorporate into the .map file but not sure why it's not working. Thanks Mark
>
> # Map file created from QGIS project file C:/wwwroot/M_Mirrlees_Assign3/markassign3.qgs
> # Edit this file to customize for your map interface
> # (Created with PyQgis MapServer Export plugin)
> MAP
> NAME "QGIS-MAP"
> # Map image size
> SIZE 500 500
> UNITS meters
> EXTENT -2400000 -900000 3100000 4000000
> FONTSET "/wwwroot/fonts/fontset.txt"
> SYMBOLSET "/wwwroot/symbols/symbols.sty"
> PROJECTION
> "proj=lcc"
> "ellps=GRS80"
> "lat_0=49"
> "lon_0=-95"
> "lat_1=49"
> "lat_2=77"
> "datum=NAD83"
> "units=m"
> "no_defs"
> END
> # Background color for the map canvas -- change as desired
> IMAGECOLOR 0 100 250
> IMAGEQUALITY 95
> IMAGETYPE agg
> OUTPUTFORMAT
> NAME agg
> DRIVER AGG/PNG
> IMAGEMODE RGB
> END
> # Legend
> LEGEND
> IMAGECOLOR 255 255 255
> STATUS ON
> KEYSIZE 18 12
> LABEL
> TYPE BITMAP
> SIZE MEDIUM
> COLOR 0 0 89
> END
> END
> # Web interface definition. Only the template parameter
> # is required to display a map. See MapServer documentation
> WEB
> # Set IMAGEPATH to the path where MapServer should
> # write its output.
> IMAGEPATH "/ms4w/tmp/ms_tmp/"
> # Set IMAGEURL to the url that points to IMAGEPATH
> # as defined in your web server configuration
> IMAGEURL "/ms_tmp/"
> # WMS server settings
> METADATA
> 'ows_title' 'QGIS-MAP'
> 'ows_onlineresource' 'localhost.com/cgi-bin/mapserv.exe?map=C:/wwwroot/M_Mirrlees_Assign3/global.map'
> 'ows_srs' 'EPSG:4326'
> END
> #Scale range at which web interface will operate
> # Template and header/footer settings
> # Only the template parameter is required to display a map. See MapServer documentation
> TEMPLATE 'C:/wwwroot/M_Mirrlees_Assign3/global.html'
> END
>
> SCALEBAR
> STATUS EMBED
> UNITS KILOMETERS
> INTERVALS 3
> TRANSPARENT TRUE
> OUTLINECOLOR 0 0 0
> END # End for scalebar
>
> QUERYMAP
> STATUS ON # sets the map to be queryable
> STYLE HILITE # the selected object is highligthed
> END # End for QueryMap
>
> WEB
> TEMPLATE global.html
> IMAGEPATH "/ms4w/tmp/ms_tmp/"
> IMAGEURL "/ms_tmp/"
> HEADER "/maps/M_Mirrlees_assign3/header.html"
> FOOTER "maps/M_Mirrlees_assign3/footer.html"
> EMPTY "/maps/M_Mirrlees_Assign3/blank.html"
> END #End for WEB
>
>
> LAYER
> NAME 'mjrroads'
> TYPE LINE
> DUMP false
> EXTENT -143.210462 39.001401 -50.461045 85.911094
> DATA '../data/mjrroads.shp'
> METADATA
> 'ows_title' 'mjrroads'
> END
> STATUS default
> TRANSPARENCY 100
> PROJECTION
> 'proj=longlat'
> 'datum=WGS84'
> 'no_defs'
> END
>
> CLASSITEM 'TYPE'
> CLASS
> NAME "default"
> EXPRESSION ""
> STYLE
> WIDTH 0.91
> COLOR 201 157 32
> END
> END
> CLASS
> NAME "TYPE = Expressway"
> EXPRESSION "Expressway"
> STYLE
> WIDTH 2.0
> COLOR 255 0 0
> END
> END
> CLASS
> NAME "TYPE = Primary Highway"
> EXPRESSION "Primary Highway"
> MAXSCALEDENOM 2500000
> STYLE
> WIDTH 1.0
> COLOR 0 0 0
> END
> END
> END
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20130320/170d2790/attachment-0001.html>


More information about the mapserver-users mailing list