# 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()