def to_wld(mapnik_map, x_rotation=0.0, y_rotation=0.0):
    """ Generate a World File string from a mapnik::Map."""
    extent = mapnik_map.envelope()
    pixel_x_size = (extent.maxx - extent.minx)/mapnik_map.width
    pixel_y_size = (extent.maxy - extent.miny)/mapnik_map.height
    upper_left_x_center = extent.minx + 0.5 * pixel_x_size + 0.5 * x_rotation
    upper_left_y_center = extent.maxy + 0.5 * (pixel_y_size*-1) + 0.5 * y_rotation
    wld_string = '''%.10f\n%.10f\n%.10f\n-%.10f\n%.10f\n%.10f\n''' % (
        pixel_x_size,
        y_rotation,
        x_rotation,
        pixel_y_size,
        upper_left_x_center,
        upper_left_y_center)
    return wld_string