예제 #1
0
    def _renderBackground(self, metric, z, x, y):
        (polys, points) = self.countryService.getPolys(z, x, y)
        clusterIds = set()
        polysByName = {}
        for pinfo in polys:
            layer, shp, props = pinfo
            if layer == 'countries':
                polysByName[props['clusterId']] = shp
                clusterIds.add(props['clusterId'])
            else:
                assert(layer == 'centroid_contours')
                polysByName[props['clusterId'], int(props['contourNum'])] = shp

        numContours = self.conf.getint('PreprocessingConstants', 'num_contours')
        colors = Config.getFullColorWheel()
        surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, self.size, self.size)
        context = cairo.Context(surface)
        # First draw clusters
        for i in clusterIds:
            shp = polysByName[i]
            c = metric.adjustCountryColor(colors[i][numContours], 0)
            self._drawPoly(z, x, y, context, shp, c, (0.7, 0.7, 0.7))
            for j in range(numContours):
                if (i, j) in polysByName:
                    shp = polysByName[i, j]
                    c = metric.adjustCountryColor(colors[i][j], j + 1)
                    self._drawPoly(z, x, y, context, shp, c)
        return surface
예제 #2
0
    def __init__(self, conf):
        self.fields = []

        nc = conf.getint('PreprocessingConstants', 'num_contours')
        self.colors = {}
        self.colorCountries = True
        for cid, ccolors in Config.getFullColorWheel().items():
            self.colors[cid] = colour.Color(ccolors[nc - 1]).rgb

        self.neutralColor = colour.Color("#777").rgb