Aggregate query
Benjamin Lloyd-Hughes
blh at MSSL.UCL.AC.UK
Fri Jan 28 05:01:50 PST 2005
Hi Steve,
Thanks for your helpful suggestion - but unfortunately I'm still having
problems. I have...
========header.html==============
<head>
</head>
<body>
<script:language = "javascript">
var num_rows = [nr];
var data = new Array(
========template.html============
[GRID_CODE],
========footer.html==============
0);
alert(num_rows);
</script>
</body>
</html>
Which outputs perfectly good javascript but to the browser window:
var num_rows = 5; var data = new Array( 428825, 490326, 402554, 797648, 109,
0); alert(num_rows);
If I good get this snippet to execute rather than display then my problems
would be over. Any ideas?
Cheers, Ben
> -----Original Message-----
> From: UMN MapServer Users List [mailto:MAPSERVER-USERS at lists.umn.edu]On
> Behalf Of Stephen Woodbridge
> Sent: 27 January 2005 15:12
> To: MAPSERVER-USERS at lists.umn.edu
> Subject: Re: [UMN_MAPSERVER-USERS] Aggregate query
>
>
> Benjamin Lloyd-Hughes wrote:
> > Hi
> >
> > I'm using the cgi mapserver in NQUERY mode to extract values
> within a user
> > defined extent from a point shape file. The query works fine in so much
> > that it returns the desired data and dumps this into the
> specifed template.
> > So far so good... But what I really want to obtain is the
> average of these
> > values. I've been scratching my head and thought I might be able to do
> > something using the EVAL() javascript function but I've not had
> any joy. I
> > would be very grateful I someone could point me in the direction of a
> > solution.
>
> Since you are use a HTML template, I think you are on the right track to
> do this in Javascript. I would not use an eval though, I would create
> and array initializer and just populate the values directly into the
> array. So do something like the following (I will leave the exact syntax
> up to you to figure out):
>
> I think you need to break this into three separate files, ie; header,
> template and footer so if the file names are header.html, template.heml
> and footer.html, you would break up the code like this:
>
> ========header.html==============
> ...
> var num_rows = [nr];
> var data = new Array(
> ========template.html============
> [DBASE column_name],
> ========footer.html==============
> 0); // probably need the trailing "0" beacue of the comma above
> ...
>
> // now loop through your array using num_rows to compute whatever
>
> ==================================
>
> I'm a little rusty with my javascript and use of query templates, but
> this should give you the idea. I am assuming that the mapserver
> templating will repeat the [DBASE column_name], line once for every row.
> if this is not right maybe some else will post the correct syntax.
>
> -Steve W.
>
More information about the MapServer-users
mailing list