Esempio n. 1
0
import os.path
from compare import compare, compare_grids

try:
    import json
except ImportError:
    import simplejson as json

visual_output_dir = "/tmp/mapnik-visual-images"

defaults = {
    'sizes': [(500, 100)],
    'scales':[1.0,2.0],
    'agg': True,
    'cairo': mapnik.has_cairo(),
    'grid': mapnik.has_grid_renderer()
}

cairo_threshold = 10
if 'Linux' == os.uname()[0]:
    # we assume if linux then you are running packaged cairo
    # which is older than the 1.12.14 version we used on OS X
    # to generate the expected images, so we'll rachet back the threshold
    # https://github.com/mapnik/mapnik/issues/1868
    cairo_threshold = 181

def render_cairo(m, output, scale_factor):
    mapnik.render_to_file(m, output, 'ARGB32', scale_factor)
    # open and re-save as png8 to save space
    new_im = mapnik.Image.open(output)
    new_im.save(output, 'png8:m=h')
Esempio n. 2
0
    s = mapnik.Style()
    r = mapnik.Rule()
    symb = mapnik.PolygonSymbolizer()
    r.symbols.append(symb)
    s.rules.append(r)
    lyr = mapnik.Layer('Places')
    lyr.datasource = ds
    lyr.styles.append('places_labels')
    width, height = 256, 256
    m = mapnik.Map(width, height)
    m.append_style('places_labels', s)
    m.layers.append(lyr)
    m.zoom_all()
    return m

if mapnik.has_grid_renderer():
    def test_clearing_grid_data():
        g = mapnik.Grid(256, 256)
        utf = g.encode()
        # make sure it equals itself
        eq_(g.encode(), utf)
        m = make_map()
        mapnik.render_layer(m, g, layer=0, fields=['__id__', 'Name'])
        eq_(g.encode() != utf, True)
        # clear grid, should now match original
        g.clear()
        eq_(g.encode(), utf)

if __name__ == "__main__":
    setup()
    exit(run_all(eval(x) for x in dir() if x.startswith("test_")))
    r = mapnik.Rule()
    symb = mapnik.PolygonSymbolizer()
    r.symbols.append(symb)
    s.rules.append(r)
    lyr = mapnik.Layer('Places')
    lyr.datasource = ds
    lyr.styles.append('places_labels')
    width, height = 256, 256
    m = mapnik.Map(width, height)
    m.append_style('places_labels', s)
    m.layers.append(lyr)
    m.zoom_all()
    return m


if mapnik.has_grid_renderer():

    def test_clearing_grid_data():
        g = mapnik.Grid(256, 256)
        utf = g.encode()
        # make sure it equals itself
        eq_(g.encode(), utf)
        m = make_map()
        mapnik.render_layer(m, g, layer=0, fields=['__id__', 'Name'])
        eq_(g.encode() != utf, True)
        # clear grid, should now match original
        g.clear()
        eq_(g.encode(), utf)


if __name__ == "__main__":
Esempio n. 4
0
from compare import compare, compare_grids
import platform

try:
    import json
except ImportError:
    import simplejson as json

visual_output_dir = "/tmp/mapnik-visual-images"

defaults = {
    'sizes': [(500, 100)],
    'scales': [1.0, 2.0],
    'agg': True,
    'cairo': mapnik.has_cairo(),
    'grid': mapnik.has_grid_renderer()
}

cairo_threshold = 10
agg_threshold = 0
if 'Linux' == platform.uname()[0]:
    # we assume if linux then you are running packaged cairo
    # which is older than the 1.12.14 version we used on OS X
    # to generate the expected images, so we'll rachet back the threshold
    # https://github.com/mapnik/mapnik/issues/1868
    cairo_threshold = 230
    agg_threshold = 12


def render_cairo(m, output, scale_factor):
    mapnik.render_to_file(m, output, 'ARGB32', scale_factor)
Esempio n. 5
0
File: test.py Progetto: plepe/mapnik
import os.path
from compare import compare, compare_grids

try:
    import json
except ImportError:
    import simplejson as json

visual_output_dir = "/tmp/mapnik-visual-images"

defaults = {
    "sizes": [(500, 100)],
    "scales": [1.0, 2.0],
    "agg": True,
    "cairo": mapnik.has_cairo(),
    "grid": mapnik.has_grid_renderer(),
}

cairo_threshold = 10
agg_threshold = 0
if "Linux" == os.uname()[0]:
    # we assume if linux then you are running packaged cairo
    # which is older than the 1.12.14 version we used on OS X
    # to generate the expected images, so we'll rachet back the threshold
    # https://github.com/mapnik/mapnik/issues/1868
    cairo_threshold = 230
    agg_threshold = 12


def render_cairo(m, output, scale_factor):
    mapnik.render_to_file(m, output, "ARGB32", scale_factor)