<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 12 (filtered medium)">
<!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
        {mso-style-priority:34;
        margin-top:0in;
        margin-right:0in;
        margin-bottom:0in;
        margin-left:.5in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
p.yiv537795222msolistparagraph, li.yiv537795222msolistparagraph, div.yiv537795222msolistparagraph
        {mso-style-name:yiv537795222msolistparagraph;
        mso-margin-top-alt:auto;
        margin-right:0in;
        mso-margin-bottom-alt:auto;
        margin-left:0in;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
p.yiv537795222msonormal, li.yiv537795222msonormal, div.yiv537795222msonormal
        {mso-style-name:yiv537795222msonormal;
        mso-margin-top-alt:auto;
        margin-right:0in;
        mso-margin-bottom-alt:auto;
        margin-left:0in;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
p.yiv537795222msochpdefault, li.yiv537795222msochpdefault, div.yiv537795222msochpdefault
        {mso-style-name:yiv537795222msochpdefault;
        mso-margin-top-alt:auto;
        margin-right:0in;
        mso-margin-bottom-alt:auto;
        margin-left:0in;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
span.yiv537795222msohyperlink
        {mso-style-name:yiv537795222msohyperlink;}
span.yiv537795222msohyperlinkfollowed
        {mso-style-name:yiv537795222msohyperlinkfollowed;}
span.yiv537795222emailstyle17
        {mso-style-name:yiv537795222emailstyle17;}
p.yiv537795222msonormal1, li.yiv537795222msonormal1, div.yiv537795222msonormal1
        {mso-style-name:yiv537795222msonormal1;
        margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
span.yiv537795222msohyperlink1
        {mso-style-name:yiv537795222msohyperlink1;
        color:blue;
        text-decoration:underline;}
span.yiv537795222msohyperlinkfollowed1
        {mso-style-name:yiv537795222msohyperlinkfollowed1;
        color:purple;
        text-decoration:underline;}
p.yiv537795222msolistparagraph1, li.yiv537795222msolistparagraph1, div.yiv537795222msolistparagraph1
        {mso-style-name:yiv537795222msolistparagraph1;
        margin-top:0in;
        margin-right:0in;
        margin-bottom:0in;
        margin-left:.5in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
span.yiv537795222emailstyle171
        {mso-style-name:yiv537795222emailstyle171;
        font-family:"Arial","sans-serif";
        color:#1F497D;}
p.yiv537795222msochpdefault1, li.yiv537795222msochpdefault1, div.yiv537795222msochpdefault1
        {mso-style-name:yiv537795222msochpdefault1;
        mso-margin-top-alt:auto;
        margin-right:0in;
        mso-margin-bottom-alt:auto;
        margin-left:0in;
        font-size:10.0pt;
        font-family:"Times New Roman","serif";}
span.EmailStyle29
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
/* List Definitions */
@list l0
        {mso-list-id:608510610;
        mso-list-type:hybrid;
        mso-list-template-ids:-185044392 67698705 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;}
@list l0:level1
        {mso-level-text:"%1\)";
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;}
ol
        {margin-bottom:0in;}
ul
        {margin-bottom:0in;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoListParagraph" style="text-indent:-.25in;mso-list:l0 level1 lfo1"><![if !supportLists]><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D"><span style="mso-list:Ignore">1)<span style="font:7.0pt &quot;Times New Roman&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span></span><![endif]><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D">Use mode=itemnquery and a regex search, something like qstring=/^value/. You’ll need to account for this in your validation string.<o:p></o:p></span></p>
<p class="MsoListParagraph" style="text-indent:-.25in;mso-list:l0 level1 lfo1"><![if !supportLists]><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D"><span style="mso-list:Ignore">2)<span style="font:7.0pt &quot;Times New Roman&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span></span><![endif]><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D">There is an outstanding bug regarding trimlast (see
<a href="http://trac.osgeo.org/mapserver/ticket/4063">http://trac.osgeo.org/mapserver/ticket/4063</a>) but I’m starting to think it’s a problem with single vs. double quotes in tag arguments. Try using double quotes…
<o:p></o:p></span></p>
<p class="MsoListParagraph" style="text-indent:-.25in;mso-list:l0 level1 lfo1"><![if !supportLists]><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D"><span style="mso-list:Ignore">3)<span style="font:7.0pt &quot;Times New Roman&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span></span><![endif]><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D">There are a number of counter tags that should be available. See
<a href="http://mapserver.org/mapfile/template.html">http://mapserver.org/mapfile/template.html</a> and search for the [nr] tag and you’ll see the others documented below.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D">Steve<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;">From:</span></b><span style="font-size:10.0pt;font-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;"> Mark Volz [mailto:volzmark@yahoo.com]
<br>
<b>Sent:</b> Thursday, December 08, 2011 10:11 PM<br>
<b>To:</b> Lime, Steve D (DNR); mapserver-users@lists.osgeo.org<br>
<b>Subject:</b> Re: [mapserver-users] mimic geonames.org JSON server<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<div>
<div>
<p class="MsoNormal" style="background:white"><span style="color:black">Steve,<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="color:black"><o:p>&nbsp;</o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="color:black">Thank you for your assistance.&nbsp; The code is starting to work.&nbsp; I just have a couple more questions.<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="color:black"><o:p>&nbsp;</o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="color:black">1)&nbsp; How can I change the query on the html call to use regular expressions, or more particularly make the search a &quot;begins with&quot; search. Using qlayer=myLayer&amp;qitem=MyField&amp;qstring='myValue'
 obliviously returns only one result, however I would like to search for n items<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="color:black"><o:p>&nbsp;</o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="color:black">2) In the JSON template, I have a comma separating each result.&nbsp; I thought that I could remove the final comma by adding [feature trimlast=','].&nbsp; The final comment was not removed.&nbsp; how
 do I correctly use [feature trimlast=',']<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="color:black"><o:p>&nbsp;</o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="color:black">3)&nbsp; for JSON templates is a variable for &quot;total results&quot;?&nbsp; If not is there another way to get a record count?<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="color:black"><o:p>&nbsp;</o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="color:black">Thanks<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="color:black"><o:p>&nbsp;</o:p></span></p>
</div>
<div>
<div>
<div class="MsoNormal" align="center" style="text-align:center;background:white">
<span style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:black">
<hr size="1" width="100%" align="center">
</span></div>
<p class="MsoNormal" style="background:white"><b><span style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:black">From:</span></b><span style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:black"> &quot;Lime, Steve D (DNR)&quot; &lt;Steve.Lime@state.mn.us&gt;<br>
<b>To:</b> Mark Volz &lt;volzmark@yahoo.com&gt;; &quot;mapserver-users@lists.osgeo.org&quot; &lt;mapserver-users@lists.osgeo.org&gt;
<br>
<b>Sent:</b> Thursday, December 8, 2011 10:26 AM<br>
<b>Subject:</b> RE: [mapserver-users] mimic geonames.org JSON server<br>
</span><span style="color:black"><br>
<br>
<o:p></o:p></span></p>
<div id="yiv537795222">
<div>
<div>
<div style="margin-left:.25in">
<p class="MsoNormal" style="background:white"><span style="font-size:11.0pt;color:#1F497D">1)</span><span style="font-size:7.0pt;color:#1F497D">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span><span style="font-size:11.0pt;color:#1F497D">Correct. Templates are just a means of presenting the results of a query operation. I’ve used templates to return json successfully.
</span><span style="color:black"><o:p></o:p></span></p>
</div>
<div style="margin-left:.25in">
<p class="MsoNormal" style="background:white"><span style="font-size:11.0pt;color:#1F497D">2)</span><span style="font-size:7.0pt;color:#1F497D">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span><span style="font-size:11.0pt;color:#1F497D">Again, you need to issue a query. So to find a record in a layer you might do something like:</span><span style="color:black"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:11.0pt;color:#1F497D">&nbsp;</span><span style="color:black"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:11.0pt;color:#1F497D">http://localhost/cgi-bin/mapserv?map=mapfile&amp;mode=itemquery&amp;qlayer=layer&amp;qitem=item&amp;qstring=value&amp;qformat=jsonformat</span><span style="color:black"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:11.0pt;color:#1F497D">&nbsp;</span><span style="color:black"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:11.0pt;color:#1F497D">This assumes that: for the layer in question you’ve setup a validation pattern for qstring and you’ve defined a output format called ‘jsonformat’.</span><span style="color:black"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:11.0pt;color:#1F497D">&nbsp;</span><span style="color:black"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:11.0pt;color:#1F497D">The one limitation I’ve found (and would like to fix) is that there’s no easy way to handle exceptions relative to the output format. For example, if you’re outputting
 json it would be nice to return errors (if possible, certain ones like mapfile not found can’t be dealt with other than in the default way) as json too.</span><span style="color:black"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:11.0pt;color:#1F497D">&nbsp;</span><span style="color:black"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:11.0pt;color:#1F497D">Let me know if you have questions.</span><span style="color:black"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:11.0pt;color:#1F497D">&nbsp;</span><span style="color:black"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:11.0pt;color:#1F497D">Steve</span><span style="color:black"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:11.0pt;color:#1F497D">&nbsp;</span><span style="color:black"><o:p></o:p></span></p>
</div>
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<div>
<p class="MsoNormal" style="background:white"><b><span style="font-size:10.0pt;color:black">From:</span></b><span style="font-size:10.0pt;color:black"> mapserver-users-bounces@lists.osgeo.org [mailto:mapserver-users-bounces@lists.osgeo.org]
<b>On Behalf Of </b>Mark Volz<br>
<b>Sent:</b> Wednesday, December 07, 2011 10:06 PM<br>
<b>To:</b> mapserver-users@lists.osgeo.org; volzmark@yahoo.com<br>
<b>Subject:</b> [mapserver-users] mimic <a href="http://geonames.org" target="_blank">
geonames.org</a> JSON server</span><span style="color:black"><o:p></o:p></span></p>
</div>
</div>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="color:black">&nbsp;<o:p></o:p></span></p>
</div>
<div>
<div>
<div>
<p class="MsoNormal" style="background:white"><span style="color:black">Hello,<o:p></o:p></span></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal" style="background:white"><span style="color:black">&nbsp;<o:p></o:p></span></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal" style="background:white"><span style="color:black">I recently came across an interesting openlayers application that uses geonames.org for a search functionality.&nbsp; I would like to be able to use my own gis data on the searches.&nbsp;&nbsp; I came
 across http://mapserver.org/trunk/output/template_output.html, which starts to describe how to make a template.&nbsp; I just have a couple questions.<o:p></o:p></span></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal" style="background:white"><span style="color:black">&nbsp;<o:p></o:p></span></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal" style="background:white"><span style="color:black">1)&nbsp; My understanding is I can use any .map files that have a layer with appropriate fields.&nbsp; I just need to add another output format so that my .map file references a JSON template, and
 I can keep the standard image output formats.&nbsp; Is this correct?<o:p></o:p></span></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal" style="background:white"><span style="color:black">&nbsp;<o:p></o:p></span></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal" style="background:white"><span style="color:black">2) How would the html request need to be formatted to search a specific value in a specific layer and return JSON?<o:p></o:p></span></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal" style="background:white"><span style="color:black">&nbsp;<o:p></o:p></span></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal" style="background:white"><span style="color:black">&nbsp;<o:p></o:p></span></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal" style="background:white"><span style="color:black">Any help and / or examples would be greatly appreciated.<o:p></o:p></span></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal" style="background:white"><span style="color:black">&nbsp;<o:p></o:p></span></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal" style="background:white"><span style="color:black">Thanks<o:p></o:p></span></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal" style="background:white"><span style="color:black">&nbsp;<o:p></o:p></span></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal" style="background:white"><span style="color:black">Mark<o:p></o:p></span></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal" style="background:white"><span style="color:black">&nbsp;<o:p></o:p></span></p>
</div>
</div>
</div>
</div>
</div>
</div>
<p class="MsoNormal" style="margin-bottom:12.0pt;background:white"><span style="color:black"><o:p>&nbsp;</o:p></span></p>
</div>
</div>
</div>
</div>
</body>
</html>