[mapserver-users] Attribute Query/ItemQuery Mapserver 7.4.2, OS X failure

Serban Constantinescu sconstatinescu at gmail.com
Wed Sep 18 19:36:30 PDT 2019


Hello everybody,

BACKGROUND INFO
------------------------------
I compiled and installed Mapserver 7.4.2 on OS X 10.13.6 as a framework,
64-bit, using CMAKE. It works.
The dependencies I am using are the frameworks from KyngChaos (
http://www.kyngchaos.com/):
GDAL 2.4, PROJ 5.0, GEOS 3.7.x, Postgres 9.6, PostGIS 2.5, etc.

I used on and off Mapserver since version 5.x so, I know how it's supposed
to work. After installation, when I run in terminal
"$ /Library/WebServer/CGI-Executables/mapserv -v"

I get:
MapServer version 7.4.2 OUTPUT=PNG OUTPUT=JPEG OUTPUT=KML SUPPORTS=PROJ
SUPPORTS=AGG SUPPORTS=FREETYPE SUPPORTS=CAIRO SUPPORTS=ICONV
SUPPORTS=WMS_SERVER SUPPORTS=WMS_CLIENT SUPPORTS=WFS_SERVER
SUPPORTS=WFS_CLIENT SUPPORTS=WCS_SERVER SUPPORTS=SOS_SERVER
SUPPORTS=FASTCGI SUPPORTS=GEOS INPUT=JPEG INPUT=POSTGIS INPUT=OGR
INPUT=GDAL INPUT=SHAPEFILE

ISSUE:
----------
I am trying to create simple files (*.map and *.html) in a directory named
"msquery" where I can successfully implement the Search by Attribute,
basically a prototype. For this, I created a shapefile, in EPSG:3857 (web
mercator), with 3 shapes: a rectangle, a circle, and a triangle. The DBF
file shows (wkt_geom is not in the DBF file):

OID (Integer),STYPE(string) -- WKT geometry in Shapefile
1,rectangle, -- wkt_geom: LineString (3194696 5605893, 3196116 5605893,
3196116 5604938, 3194696 5604938, 3194696 5605893)
2,circle, -- ...too many vertices to list here...
3,triangle -- wkt_geom: LineString (3197117 5604282, 3196225 5602525,
3198201 5602525, 3197117 5604282)

What I want is a very simple thing. In an html file displaying the map,
have a form with a text input, where if I enter STYPE="rectangle" or
STYPE="triangle" (qitem=STYPE&qstring=triangle), to take me to the same
html page or another one, that would display a map image, displaying either
the rectangle or the triangle (the queried item), zoomed at the shape's
extent +5% buffer (whatever Mapserver's default is), with a highlighted
color.

Here's my files:

1) index.html -- simple file initializing the map via a form:
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8" />
    <title>Index File - Initialize Mapserver App</title>
</head>
<body>
<p>Set default variables and initialze the Mapserver app and map.</p>
<hr>
<form method="get" name="initialize" action="/cgi-bin/mapserv">
<input type="radio" name="map"
value="/Library/Webserver/Documents/msquery/qry.map" checked> MAP =
qry.map<br>
<input type="radio" name="layer" value="testdata" checked> LAYER =
testdata<br>
<!-- apparently mode=BROWSE is set by default, so it's not needed here-->
<input type="submit" value="display map">
</form>
</body>
</html>

2) qry_browse.html
<!-- Mapserver Template -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Index File Attribute Query Demo</title>
</head>
<body>
<center>

<form method="GET" action="/cgi-bin/mapserv" name="mapserv">
<table>
<tr>
<td>
<!-- map image -->
<input type="image" name="img" src="[img]" width="[mapwidth]"
height="[mapheight]" border="1" alt="this is the map">
<!-- // map image -->
</td>
<td valign="top">
<font size="-1">
<input type="radio" name="map" value="[map]" checked> MAP:
"[map]" <br>
<input type="radio" name="layer" value="[layer]" checked> LAYER:
"[layer]" <br>
  IMGXY = [center] <br>
  IMGEXT = [mapext] <br>
<hr>
Map Mode:<br>
<input type="radio" name="mode" value="browse" selected> browse<br>
------------------------ <br>
<input type="radio" name="mode" value="itemquery"> itemquery<br>
QLAYER: "testdata"<br>
<input type="hidden" name="qlayer" value="testdata">
QITEM: "STYPE"<br>
<input type="hidden" name="qitem" value="STYPE">
QSTRING: <input type="text" name="qstring" value=""><br>
</font>
</td>
</tr>
</table>
<hr>
<!-- these 2 are required for centering the map where clicked, while
panning the image in BROWSE mode -->
<input type="hidden" name="imgxy" value="[center]">
<input type="hidden" name="imgext" value="[mapext]">

<input type="submit" value="refresh">
</form>

</center>
</body>
</html>

3) qry.map

MAP

IMAGETYPE PNG24
NAME QUERYDEMO
SIZE 1000 800
EXTENT 3192000 5601300 3202000 5608000 # in epsg:3857
PROJECTION
"init=epsg:3857"
END
UNITS METERS
SHAPEPATH "data"
IMAGECOLOR 255 255 255
# TEMPLATEPATTERN may not be needed
TRANSPARENT ON

CONFIG "MS_ERRORFILE"
"/Library/WebServer/Documents/msquery/ms_error_log.txt"
DEBUG 5

WEB
MINSCALEDENOM 106
MAXSCALEDENOM 54167.9728005186
IMAGEPATH "/Library/WebServer/Documents/msquery/tmp/"
IMAGEURL "/msquery/tmp/"
LOG "/Library/WebServer/Documents/msquery/ms_error_log.txt"
METADATA
# no need for WMS/WFS for this demo
END
TEMPLATE qry_browse.html
VALIDATION
'qstring'  '.'
'STYPE' '.'
'OID' '.'
END
END # WEB

# SYMBOL DEFINITIONS
SYMBOL
NAME 'circle'
TYPE ELLIPSE
POINTS 1 1 END
FILLED TRUE
END


QUERYMAP
COLOR 0 0 255
STATUS ON
STYLE HILITE
END

LAYER # line layer begins here
NAME         testdata
DATA         "testdata.shp"
STATUS       ON
TYPE         LINE
PROJECTION
"init=epsg:3857"
END
CLASS
TEMPLATE "qry_browse.html" # this seems to be ncecessary to make the
layer/class queriable
NAME 'default'# Name to use in legends for this class. If not set class
won’t show up in legend.
STYLE
SYMBOL     0
COLOR      255 0 0
SIZE       1
END
STATUS on
# TEMPLATE # Template file or URL to use in presenting query results to the
user. See Templating for more info.
END # end of CLASS
#VALIDATION # As of MapServer 5.4.0, VALIDATION blocks are the preferred
mechanism for specifying validation patterns for CGI param runtime
substitutions. See Run-time Substitution.
#END # end of VALIDATION
END # end of LAYER

END # end of mapfile

At this point the error I'm getting is:
msQueryByFilter(): Search returned no results. No matching record(s) found.

I don't know of the VALIDATION block is correct (syntax) and/or if it's
placed where it should be.
I also don't know if the "qry_browse.html" html is is supposed to display
the query results, or the query form should redirect the display to a
different html template.
I also don't know if the search map file should be different than qry.map.

I've been banging my head against the walls for the past 2.5 days and it
seems to go nowhere, for such a simple feature. The documentation did not
help me very much, nor did the Mapserver demo files, as the examples are
old, they do not contain text/attribute based queries, plus the query
validation has changed several times across version since the demo was
built.

I am attaching a zipped copy of my prototype folder for ease of evaluation.

Thanks in advance for your help.

PS: this should eventually make it in the demo, as it is probably one of
the most necessary features users look for.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20190919/564b1bc9/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: msquery.zip
Type: application/zip
Size: 11920 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20190919/564b1bc9/attachment.zip>


More information about the MapServer-users mailing list