def add_colorizer_stops(self, limits): rcolors = colors.colormap.get(self.stylename) if rcolors: bins = self._rstore.linear(limits, k=len(rcolors)) symbolizer = self._symbolizer for value, color in zip(bins, rcolors): symbolizer.colorizer.add_stop(value, mapnik.Color(color))
def test_stylesheet(self): m = carto.Map() layer = m.layer(self.object, 'green') layer._symbolizer.colorizer.default_color = mapnik.Color(0, 255, 0) mapnik.save_map(m.map, str(m.mapfile)) form = forms.RasterTileForm(dict(self.ctx, style='green')) r = renderers.MapnikRenderer() imgdata = carto.build_map([self.object], form).render(r.format) im = self._image(r.render(imgdata)) self.assertEqual(im.getpixel((100, 100)), (0, 255, 0, 255))
def symbolizer(self): symbolizer = mapnik.RasterSymbolizer() symbolizer.colorizer = mapnik.RasterColorizer(mapnik.COLORIZER_LINEAR, mapnik.Color(0, 0, 0, 0)) return symbolizer
def add_colorizer_stops(self, bins, rcolors): symbolizer = self._symbolizer for value, color in zip(bins, rcolors): symbolizer.colorizer.add_stop(value, mapnik.Color(color))