<html><body><div style="color:#000; background-color:#fff; font-family:times new roman, new york, times, serif;font-size:12pt"><div><span>Steve,</span></div><div><br><span></span></div><div><span>Thank you for your assistance. The code is starting to work. I just have a couple more questions.</span></div><div><br><span></span></div><div><span>1) How can I change the query on the html call to use regular expressions, or more particularly make the search a "begins with" search</span><span>. Using qlayer=myLayer&qitem=MyField&qstring='myValue' obliviously returns only one result, however I would like to search for n items</span></div><div><br><span></span></div><div><span>2) In the JSON template, I have a comma separating each result. I thought that I could remove the final comma by adding </span><span>[feature trimlast=',']</span><span>. The final comment was not removed. how do I correctly use [feature
trimlast=',']</span></div><div><br><span></span></div><div><span>3) for JSON templates is a variable for "total results"? If not is there another way to get a record count?</span></div><div><br><span></span></div><div><span>Thanks</span></div><div><br></div> <div style="font-family: times new roman, new york, times, serif; font-size: 12pt;"> <div style="font-family: times new roman, new york, times, serif; font-size: 12pt;"> <font face="Arial" size="2"> <hr size="1"> <b><span style="font-weight:bold;">From:</span></b> "Lime, Steve D (DNR)" <Steve.Lime@state.mn.us><br> <b><span style="font-weight: bold;">To:</span></b> Mark Volz <volzmark@yahoo.com>; "mapserver-users@lists.osgeo.org" <mapserver-users@lists.osgeo.org> <br> <b><span style="font-weight: bold;">Sent:</span></b> Thursday, December 8, 2011 10:26 AM<br> <b><span style="font-weight: bold;">Subject:</span></b> RE: [mapserver-users] mimic geonames.org JSON
server<br> </font> <br>
<meta http-equiv="x-dns-prefetch-control" content="off"><div id="yiv537795222">
<style><!--
#yiv537795222
_filtered #yiv537795222 {font-family:"Cambria Math";panose-1:2 4 5 3 5 4 6 3 2 4;}
_filtered #yiv537795222 {font-family:Calibri;panose-1:2 15 5 2 2 2 4 3 2 4;}
_filtered #yiv537795222 {font-family:Tahoma;panose-1:2 11 6 4 3 5 4 4 2 4;}
#yiv537795222
#yiv537795222 p.yiv537795222MsoNormal, #yiv537795222 li.yiv537795222MsoNormal, #yiv537795222 div.yiv537795222MsoNormal
{margin:0in;margin-bottom:.0001pt;font-size:12.0pt;font-family:"serif";}
#yiv537795222 a:link, #yiv537795222 span.yiv537795222MsoHyperlink
{color:blue;text-decoration:underline;}
#yiv537795222 a:visited, #yiv537795222 span.yiv537795222MsoHyperlinkFollowed
{color:purple;text-decoration:underline;}
#yiv537795222 p.yiv537795222MsoListParagraph, #yiv537795222 li.yiv537795222MsoListParagraph, #yiv537795222 div.yiv537795222MsoListParagraph
{margin-top:0in;margin-right:0in;margin-bottom:0in;margin-left:.5in;margin-bottom:.0001pt;font-size:12.0pt;font-family:"serif";}
#yiv537795222 span.yiv537795222EmailStyle17
{font-family:"sans-serif";color:#1F497D;}
#yiv537795222 .yiv537795222MsoChpDefault
{font-size:10.0pt;}
_filtered #yiv537795222 {margin:1.0in 1.0in 1.0in 1.0in;}
#yiv537795222 div.yiv537795222WordSection1
{}
#yiv537795222
_filtered #yiv537795222 {}
_filtered #yiv537795222 {margin-left:.25in;}
#yiv537795222 ol
{margin-bottom:0in;}
#yiv537795222 ul
{margin-bottom:0in;}
--></style>
<div>
<div class="yiv537795222WordSection1">
<div class="yiv537795222MsoListParagraph" style="margin-left:.25in;">
<span style="font-size:11.0pt;color:#1F497D;"><span style="">1)<span style="font:7.0pt;">
</span></span></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></div>
<div class="yiv537795222MsoListParagraph" style="margin-left:.25in;">
<span style="font-size:11.0pt;color:#1F497D;"><span style="">2)<span style="font:7.0pt;">
</span></span></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></div>
<div class="yiv537795222MsoNormal"><span style="font-size:11.0pt;color:#1F497D;"> </span></div>
<div class="yiv537795222MsoNormal"><span style="font-size:11.0pt;color:#1F497D;">http://localhost/cgi-bin/mapserv?map=mapfile&mode=itemquery&qlayer=layer&qitem=item&qstring=value&qformat=jsonformat</span></div>
<div class="yiv537795222MsoNormal"><span style="font-size:11.0pt;color:#1F497D;"> </span></div>
<div class="yiv537795222MsoNormal"><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></div>
<div class="yiv537795222MsoNormal"><span style="font-size:11.0pt;color:#1F497D;"> </span></div>
<div class="yiv537795222MsoNormal"><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></div>
<div class="yiv537795222MsoNormal"><span style="font-size:11.0pt;color:#1F497D;"> </span></div>
<div class="yiv537795222MsoNormal"><span style="font-size:11.0pt;color:#1F497D;">Let me know if you have questions.</span></div>
<div class="yiv537795222MsoNormal"><span style="font-size:11.0pt;color:#1F497D;"> </span></div>
<div class="yiv537795222MsoNormal"><span style="font-size:11.0pt;color:#1F497D;">Steve</span></div>
<div class="yiv537795222MsoNormal"><span style="font-size:11.0pt;color:#1F497D;"> </span></div>
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in;">
<div class="yiv537795222MsoNormal"><b><span style="font-size:10.0pt;">From:</span></b><span style="font-size:10.0pt;"> 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 target="_blank" href="http://geonames.org">geonames.org</a> JSON server</span></div>
</div>
</div>
<div class="yiv537795222MsoNormal"> </div>
<div>
<div>
<div class="yiv537795222MsoNormal" style="background:white;"><span style="color:black;">Hello,</span></div>
</div>
<div>
<div class="yiv537795222MsoNormal" style="background:white;"><span style="color:black;"> </span></div>
</div>
<div>
<div class="yiv537795222MsoNormal" style="background:white;"><span style="color:black;">I recently came across an interesting openlayers application that uses geonames.org for a search functionality. I would like to be able to use my own gis data on the searches. I came
across http://mapserver.org/trunk/output/template_output.html, which starts to describe how to make a template. I just have a couple questions.</span></div>
</div>
<div>
<div class="yiv537795222MsoNormal" style="background:white;"><span style="color:black;"> </span></div>
</div>
<div>
<div class="yiv537795222MsoNormal" style="background:white;"><span style="color:black;">1) My understanding is I can use any .map files that have a layer with appropriate fields. 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. Is this correct?</span></div>
</div>
<div>
<div class="yiv537795222MsoNormal" style="background:white;"><span style="color:black;"> </span></div>
</div>
<div>
<div class="yiv537795222MsoNormal" 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?</span></div>
</div>
<div>
<div class="yiv537795222MsoNormal" style="background:white;"><span style="color:black;"> </span></div>
</div>
<div>
<div class="yiv537795222MsoNormal" style="background:white;"><span style="color:black;"> </span></div>
</div>
<div>
<div class="yiv537795222MsoNormal" style="background:white;"><span style="color:black;">Any help and / or examples would be greatly appreciated.</span></div>
</div>
<div>
<div class="yiv537795222MsoNormal" style="background:white;"><span style="color:black;"> </span></div>
</div>
<div>
<div class="yiv537795222MsoNormal" style="background:white;"><span style="color:black;">Thanks</span></div>
</div>
<div>
<div class="yiv537795222MsoNormal" style="background:white;"><span style="color:black;"> </span></div>
</div>
<div>
<div class="yiv537795222MsoNormal" style="background:white;"><span style="color:black;">Mark</span></div>
</div>
<div>
<div class="yiv537795222MsoNormal" style="background:white;"><span style="color:black;"> </span></div>
</div>
</div>
</div>
</div>
</div><meta http-equiv="x-dns-prefetch-control" content="on"><br><br> </div> </div> </div></body></html>