def on_button_down_clicked(self, widget, data=None): global start_time start_time = time.time() #zoom is relative to start and zoomfactor zoom = start_zoom + zoomFactor #change the y values for new tiles y.append(y[len(y)-1]+1) y.pop(0) #set new zentral tile global zentral_tile zentral_tile = func.getZentralTile(x,y) #set tile uri tile_uri = tile_dir + str(zoom) #render the new tiles global rendered_tiles rendered_tiles = new_object.render_on_demand(tile_uri, zoom, zentral_tile) #show the new tiles new_object.show_tiles(rendered_tiles)
def __new__(cls, sent): """Special static method that's automatically called by Python when constructing a new instance of this class. Returns a fully instantiated TilesDialog object. """ #set if the tile-bbox should be displayed #very rude functionality...you have to press reload to see bbox global showBbox showBbox = False added = False global added #get the sent informations first_split = sent.split('+')[1] global tile_parts tile_parts = first_split.split(':') #print tile_parts #initialization of all sent data global mapfile mapfile = tile_parts[1] global mapnik_qmap mapnik_qmap = mapnik.Map(256, 256) mapnik.load_map(mapnik_qmap,mapfile) global prj prj = mapnik.Projection(mapnik_qmap.srs)#mapnik.Projection("+proj=merc +lon_0=0 +k=1 +x_0=0 +y_0=0 +a=6371000 +b=6371000 +units=m +no_defs") extent = tile_parts[0].split('(')[1].split(')')[0].split(', ') c0 = prj.inverse(mapnik.Coord(float(extent[0]),float(extent[2]))) c1 = prj.inverse(mapnik.Coord(float(extent[1]),float(extent[3]))) bbox = (c0.x, c0.y, c1.x, c1.y) global tile_dir tile_dir = tile_parts[2] global maxZoom maxZoom = int(tile_parts[4]) minZoom = int(tile_parts[3]) global generalHome generalHome = tile_parts[5] global logs logs = tile_parts[6] #get the minimal tile view for setted dataset -->minimum means: mind. 9 Tiles are created global all_tiles all_tiles = rendering.calcNecTiles(bbox, tile_dir, minZoom, maxZoom) #save start zoom global start_zoom start_zoom = all_tiles[0][2] #find all x and y names of the necessary tiles and... global x x = [] x.append(all_tiles[0][0]) global y y = [] y.append(all_tiles[0][1]) for i in range(1, len(all_tiles)): if (all_tiles[i])[0] > (all_tiles[i-1])[0]: x.append(all_tiles[i][0]) #print 'all x: '+str(x) for j in range(1,len(x)): if (all_tiles[j])[1] > (all_tiles[j-1])[1]: y.append(all_tiles[j][1]) #print 'all y: '+str(y) #...get the zentral tile of all possible global zentral_tile zentral_tile = func.getZentralTile(x,y) #initialize the size of the tile buffer global buffer_size buffer_size = 128 #render the the central and all 8 surrounding tiles global rendered_tiles global first_zentral_uri first_zentral_uri = all_tiles[0][3] zoom = start_zoom # c0, c1 = renderer.calcTileCoordinates(zentral_tile, zoom) #print 'Coordinates of Tile:',c0, c1 #initialize the zoomfactor, that is relative to the start zoom global zoomFactor zoomFactor = 0 builder = get_builder('TilesDialog') global new_object new_object = builder.get_object('tiles_dialog') new_object.finish_initializing(builder) return new_object