[mapserver-users] Query result attribute sums / totals

Richard Greenwood richard.greenwood at gmail.com
Fri Jan 9 05:30:30 PST 2009


On Fri, Jan 9, 2009 at 12:51 AM, Ben Madin <ben at remoteinformation.com.au> wrote:
> G'day all,
>
> I have a straightforward query setup on a line layer showing movements
> between locations over a selected time period.
>
> When I select query mode, the data is returned beautifully (well, it's nice
> to see it!)
>
> #       Date    Species         Number          Purpose         Origin
>    Destination     Movement id
> 1       07/07/2008      Cattle  40      Slaughter       Luangprabang
>  Vientiane Capital       More Information
> 2       15/07/2008      Cattle  7       Sell To Middle Man      Luangprabang
>    Vientiane Capital         More Information
> 3       27/07/2008      Cattle  5       Slaughter       Luangprabang
>  Vientiane Capital       More Information
>
> etc
>
> However it would be really really great if the total Number over this time
> could be calculated as a total, and put in the footer row.
>
> (I have done this previously using mapscript, but for time reasons don't
> want to go there at the moment.)
>
> Is there an [attribute_sum] type of tag I can embed in the footer... or any
> other suggestions?
>

You could easily calculate the sum with JavaScript in the browser.
Declare a variable "total" and then for each row, within a JavaScript
tag, something like:
  total += [Number]

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



More information about the MapServer-users mailing list