Ejemplo n.º 1
0
 def execute(self):
     self._progress_zoom = None
     try:
         TileGenCommand.execute(self)
     except BaseException as e:
         print "Exception during TileGenCommand.execute():", e
         if str(e) <> "ValueError: An item with the same key has already been added.":
             raise
Ejemplo n.º 2
0
 def execute(self):
     self._progress_zoom = None
     try:
         TileGenCommand.execute(self)
     except BaseException as e:
         print "Exception during TileGenCommand.execute():", e
         if str(e) <> "ValueError: An item with the same key has already been added.":
             raise
Ejemplo n.º 3
0
 def __new__(cls, *args):
     if isinstance(args[0], Polygon):
         bbox = LineSymbol("Generation filter Polygon", Srid.Wgs84LonLat, [args[0]]).bounding_box
         cmd = TileGenCommand.__new__(cls, bbox, args[1], args[2])
         cmd.generation_polygon = args[0]
     else:
         # Also allow construction with TileGenCommand's original parameters.
         cmd = TileGenCommand.__new__(cls, *args)
         cmd.generation_polygon = None
     return cmd
Ejemplo n.º 4
0
 def __new__(cls, *args):
     if isinstance(args[0], Polygon):
         bbox = LineSymbol("Generation filter Polygon", Srid.Wgs84LonLat, [args[0]]).bounding_box
         cmd = TileGenCommand.__new__(cls, bbox, args[1], args[2])
         cmd.generation_polygon = args[0]
     else:
         # Also allow construction with TileGenCommand's original parameters.
         cmd = TileGenCommand.__new__(cls, *args)
         cmd.generation_polygon = None
     return cmd
Ejemplo n.º 5
0
def generate_tiles(tile):
    min_zoom = min_zoom_value  # get_min_zoom(tile)
    max_zoom = tile[2]
    parent_tile = get_parent_tile(tile, min_zoom_value)
    bounds = tile2bounds(parent_tile)  # tile2middle_bounds(tile)
    if min_zoom <= tile[2]:
        App.log('Generating tiles, bounds: %s, min_zoom: %i, max_zoom: %i' % (
            bounds,
            min_zoom,
            max_zoom,
        ))
        command = TileGenCommand(bounds, min_zoom, max_zoom)
        command.execute()
    else:
        App.log('Tiles already generated, bounds: %s' % bounds)
Ejemplo n.º 6
0
    # Demonstrates how to collect the list of generated tiles.
    # You could, for example, use this function to upload
    # tiles to a Web server.

    # In this case we collect the file names to a list...
    tiles_to_optimize.append("\"{0}\"".format(file_name))

    # ... and then we call OptiPNG when the list gets full.
    if len(tiles_to_optimize) >= 10:
        optimize_tiles()

if App.is_mono:
    raise AssertionError("Sorry, this script does not work when running on Linux or Mac.")

tiles_to_optimize = []

# Generate tiles for the currently set geometry bounds and the current zoom level
min_zoom = Map.position.zoom
max_zoom = Map.position.zoom
cmd = TileGenCommand(Map.geo_bounds, min_zoom, max_zoom)

# This is how we override TileGenCommand with custom functions.
cmd.tile_generation_filter = func1
cmd.tile_save_filter = func2
cmd.after_tile_save = collect_tiles

cmd.execute()

# Run the optimization again for any left-over tiles.
optimize_tiles()
Ejemplo n.º 7
0
    # Demonstrates how to collect the list of generated tiles.
    # You could, for example, use this function to upload
    # tiles to a Web server.

    # In this case we collect the file names to a list...
    tiles_to_optimize.append("\"{0}\"".format(file_name))

    # ... and then we call OptiPNG when the list gets full.
    if len(tiles_to_optimize) >= 10:
        optimize_tiles()

if App.is_mono:
    raise AssertionError("Sorry, this script does not work when running on Linux or Mac.")

tiles_to_optimize = []

# Generate tiles for the currently set geometry bounds and the current zoom level
min_zoom = Map.position.zoom
max_zoom = Map.position.zoom
cmd = TileGenCommand(Map.geo_bounds, min_zoom, max_zoom)

# This is how we override TileGenCommand with custom functions.
cmd.tile_generation_filter = func1
cmd.tile_save_filter = func2
cmd.after_tile_save = collect_tiles

cmd.execute()

# Run the optimization again for any left-over tiles.
optimize_tiles()