Esempio n. 1
0
def render(filename, width, height, bbox, quiet=False):
    m = mapnik.Map(width, height)
    expected = os.path.join(dirname, "images", '%s-%d-reference.png' % (filename, width))
    actual = '%s-%d' % (filename, width)
    try:
        mapnik.load_map(m, os.path.join(dirname, "styles", "%s.xml" % filename), False)
        if bbox is not None:
            m.zoom_to_box(bbox)
        else:
            m.zoom_all()
    except Exception, e:
        sys.stderr.write(e.message + '\n')
        fail(actual,expected,str(e.message))
        return
Esempio n. 2
0
def render(filename, width, height, bbox, quiet=False):
    m = mapnik.Map(width, height)
    expected = os.path.join(dirname, "images",
                            '%s-%d-reference.png' % (filename, width))
    actual = '%s-%d' % (filename, width)
    try:
        mapnik.load_map(m, os.path.join(dirname, "styles",
                                        "%s.xml" % filename), False)
        if bbox is not None:
            m.zoom_to_box(bbox)
        else:
            m.zoom_all()
    except Exception, e:
        sys.stderr.write(e.message + '\n')
        fail(actual, expected, str(e.message))
        return
Esempio n. 3
0
         m.zoom_to_box(bbox)
     else:
         m.zoom_all()
 except Exception, e:
     sys.stderr.write(e.message + '\n')
     fail(actual,expected,str(e.message))
     return
 actual_agg = os.path.join(visual_output_dir, '%s-agg.png' % actual)
 if not quiet:
     print "\"%s\" with size %dx%d with agg..." % (filename, width, height),
 
 try:
     mapnik.render_to_file(m, actual_agg)
     if not os.path.exists(expected):
         # generate it on the fly
         fail(actual_agg,expected,None)
     else:
         diff = compare(actual_agg, expected, threshold=1, alpha=True)
         report(diff,quiet)
 except Exception, e:
     sys.stderr.write(e.message + '\n')
     fail(actual_agg,expected,str(e.message))
 if 'tiff' in actual or 'marker' in actual:
     actual_cairo = os.path.join(visual_output_dir, '%s-cairo.png' % actual)
     if not quiet:
         print "\"%s\" with size %dx%d with cairo..." % (filename, width, height),
     try:
         mapnik.render_to_file(m, actual_cairo,'ARGB32')
         if not os.path.exists(expected):
             pass # will have been generated by agg test
         else:
Esempio n. 4
0
     fail(actual,expected,str(e.message))
     return
 actual_agg = os.path.join(visual_output_dir, '%s-agg.png' % actual)
 if not quiet:
     print "\"%s\" with size %dx%d with agg..." % (filename, width, height),
 try:
     mapnik.render_to_file(m, actual_agg)
     diff = compare(actual_agg, expected)
     if not quiet:
         if diff > 0:
             print '\x1b[31m✘\x1b[0m (\x1b[34m%u different pixels\x1b[0m)' % diff
         else:
             print '\x1b[32m✓\x1b[0m'
 except Exception, e:
     sys.stderr.write(e.message + '\n')
     fail(actual_agg,expected,str(e.message))
 if 'tiff' in actual:
     actual_cairo = os.path.join(visual_output_dir, '%s-cairo.png' % actual)
     if not quiet:
         print "\"%s\" with size %dx%d with cairo..." % (filename, width, height),
     try:
         mapnik.render_to_file(m, actual_cairo,'ARGB32')
         diff = compare(actual_cairo, expected)
         if not quiet:
             if diff > 0:
                 print '\x1b[31m✘\x1b[0m (\x1b[34m%u different pixels\x1b[0m)' % diff
             else:
                 print '\x1b[32m✓\x1b[0m'
     except Exception, e:
         sys.stderr.write(e.message + '\n')
         fail(actual_cairo,expected,str(e.message))
Esempio n. 5
0
            m.zoom_to_box(bbox)
        else:
            m.zoom_all()
    except Exception, e:
        sys.stderr.write(e.message + '\n')
        fail(actual, expected, str(e.message))
        return
    actual_agg = os.path.join(visual_output_dir, '%s-agg.png' % actual)
    if not quiet:
        print "\"%s\" with size %dx%d with agg..." % (filename, width, height),

    try:
        mapnik.render_to_file(m, actual_agg)
        if not os.path.exists(expected):
            # generate it on the fly
            fail(actual_agg, expected, None)
        else:
            diff = compare(actual_agg, expected, threshold=1, alpha=True)
            report(diff, quiet)
    except Exception, e:
        sys.stderr.write(e.message + '\n')
        fail(actual_agg, expected, str(e.message))
    if 'tiff' in actual or 'marker' in actual:
        actual_cairo = os.path.join(visual_output_dir, '%s-cairo.png' % actual)
        if not quiet:
            print "\"%s\" with size %dx%d with cairo..." % (filename, width,
                                                            height),
        try:
            mapnik.render_to_file(m, actual_cairo, 'ARGB32')
            if not os.path.exists(expected):
                pass  # will have been generated by agg test