Skip to content

datasource plugins could provide statistics #800

Open
artemp opened this Issue Oct 11, 2011 · 3 comments

2 participants

@artemp
Mapnik member
artemp commented Oct 11, 2011

Mapnik's design separates the concerns of data with style, allowing styles to be arbitrarily attached to layers. Thus styles and their logic intentionally have no way to get at data values, individually (like a first value) or in aggregate (like min/max). Styles, through Rules can only filter data based on expressions.

However, for thematic mapping, particularly dynamically changing choropleths, applications using mapnik need an easy way to introspect data, and get statistics before rendering. If this were possible then aggregate statistics could be calculated once, cached, and used then to change stylesheets on the fly.

This could be done by adding new functions on the datasource class: http://trac.mapnik.org/browser/trunk/include/mapnik/datasource.hpp#L104. The current datasource class design is largely based on rendering needs, but functions could be added that accept an attribute name and statistics type request (like max or min) and return the requested value in a boost::optional object (as perhaps some queries will not be possible/efficient for some datasources).

@artemp
Mapnik member
artemp commented Oct 11, 2011

[springmeyer] Since we're after attribute statistics mainly, this ticket is related: http://trac.mapnik.org/ticket/816

@artemp
Mapnik member
artemp commented Oct 11, 2011

[springmeyer] see also the comment at http://trac.mapnik.org/ticket/816#comment:2 which was intended for this ticket.

@tmcw
Mapnik member
tmcw commented Jan 20, 2012

First pass, a simplistic implementation that I'm testing against jit datasource, is in the statistics branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.