NaN results for itemquery with Dbox

william paul williampaul28 at YAHOO.COM
Thu Mar 22 10:24:55 EDT 2007


As usually: Thank you Rich
  The strange part is that I have a match in my database, but I still get the NaN results. If I use the query tool from mapserver I get the proper results.
The only difference is that when I send text (the qstring is a text) from the database to mapserver I get the proper results. When I send numbers (the qstring is a number) I get NaN results. Do you think it could be related to the type of the data used for query?
   
  I will make other tests
   
  William
   
  
Richard Greenwood <richard.greenwood at gmail.com> wrote:
  On 3/20/07, william paul wrote:
> Hi:
>
> I am using Dbox and the example provided by Rich Greenwood, to map the
> results from a database query. I have modified the script so you can change
> the queryfile, qitem and qstring. The script works OK on 1 layer, but for
> others I get NaN. Before to map the results I test ( alert(qlayer, qitem,
> qstring)) to see if the queryfile, qitem and qstring are correct. Even
> though I have the core ct names for each one I still get NaN results
> What could be the problem?
>
> script from the database query results
>  
> var qlayer = "anyQlayer";
> var qitem = "anyQitem";
> function map(qstring)
> {
> opener.itemQueryModified(qstring, qitem, qlayer);
> window.close();
> opener.focus();
> }
>    
>
>
> modified itemQuery script
> ms.itemqueryoptions = "&mapext=shapes&savequery=true&";
> function itemQueryModified(qstring, qitem, qlayer)
> {
> //ms.setLayer(qlayer, true);
> var uri = ms.mapserver + '?map=' + ms.mapfile + "&layers=" +
> ms.getLayers("+") + "&mapsize=" + ms.width + "+" + ms.height;
> uri += ms.itemqueryoptions;
> uri += '&mode=itemquery'
> uri += '&qlayer=' + qlayer;
> uri += '&qitem=' + qitem;
> uri += '&qstring=' + qstring;
> var response = get_content(uri);
> var tokens = response.split(',');
> alert(qstring + qitem + qlayer + ", " + Number(tokens[1]),
> Number(tokens[2]), Number(tokens[3]), Number(tokens[4]));
> ms.setExtent(Number(tokens[1]), Number(tokens[2]), Number(tokens[3]),
> Number(tokens[4]));
> main.setImage(tokens[5]);
> ms.savedqueryfile=tokens[6];
> domouseclick('pan');
> }

You probably didn't get a match in your database. NaN means "Not a
Number". MapServer did not return an extent for the selection because
it could not find anything, and so your browser was not able to
convert the tokens 1-4 into numbers.

I try to catch that and tell the user something like "no results found".

Rich

-- 
Richard Greenwood
richard.greenwood at gmail.com
www.greenwoodmap.com


 
---------------------------------
It's here! Your new message!
Get new email alerts with the free Yahoo! Toolbar.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/mapserver-users/attachments/20070322/de7aacd4/attachment.html


More information about the mapserver-users mailing list