コード例 #1
0
	def clear_extent(self, extent, map_extent):
		tile_coord = tiletree.extent_to_tile_coord(extent, map_extent)
		curs = self.conn.cursor()

		curs.execute(\
"""
DELETE FROM %(node_table)s node
WHERE node.zoom_level >= %%(z)s AND floor(node.tile_x / (2^(node.zoom_level - %%(z)s)))::int = %%(x)s AND
floor(node.tile_y / (2^(node.zoom_level - %%(z)s)))::int = %%(y)s
""" % {'node_table':self.node_table,},
	{'z':tile_coord[0], 'x':tile_coord[1], 'y':tile_coord[2]})
コード例 #2
0
def create_machine_jobs(global_config):
    dist_render_config = global_config['dist_render']

    #override parameteres with render_extent if necessary
    render_extent = global_config['map_extent']
    if ('render_extent' in dist_render_config):
        render_extent = dist_render_config['render_extent']
        tile_coords = tiletree.extent_to_tile_coord(
            render_extent, global_config['map_extent'])
        print 'Root Tile Coordinate:', tile_coords
        dist_render_config['start_zoom'] = tile_coords[0]
        dist_render_config['start_tile_x'] = tile_coords[1]
        dist_render_config['start_tile_y'] = tile_coords[2]
        #get the extent of the root node
        render_extent = tiletree.tile_coord_to_bbox(
            tile_coords[0], tile_coords[1], tile_coords[2],
            global_config['map_extent'])

    total_num_threads = sum(x['num_threads']
                            for x in dist_render_config['render_nodes'])
    min_num_jobs = dist_render_config.get('min_num_jobs', 1)
    if (total_num_threads > min_num_jobs):
        min_num_jobs = total_num_threads
    map_extent = global_config['map_extent']

    jobs = split_bbox(min_num_jobs, dist_render_config['start_zoom'],
                      dist_render_config['start_tile_x'],
                      dist_render_config['start_tile_y'],
                      dist_render_config['stop_zoom'], *render_extent)

    fill_to_zoom_level = jobs[0].zoom_level - 1

    jobs_per_thread = int(math.ceil(len(jobs) / float(total_num_threads)))

    render_node_configs = {}
    for render_node in dist_render_config['render_nodes']:
        this_num_jobs = min(jobs_per_thread * render_node['num_threads'],
                            len(jobs))
        #inherit the stuff from the global config
        this_config = copy.copy(global_config)
        this_config.update({
            'address': render_node['address'],
            'num_threads': render_node['num_threads'],
            'jobs': []
        })
        for job in jobs[0:this_num_jobs]:
            this_config['jobs'].append({
                'extent': [job.min_x, job.min_y, job.max_x, job.max_y],
                'start_zoom':
                job.zoom_level,
                'stop_zoom':
                dist_render_config['stop_zoom'],
                'tile_x':
                job.tile_x,
                'tile_y':
                job.tile_y,
            })
        del jobs[0:this_num_jobs]
        render_node_configs[render_node['address']] = this_config

    #add in any left over bits at the top of the tree
    if (fill_to_zoom_level >= dist_render_config['start_zoom']):
        render_node_configs.values()[0]['jobs'].append({
            'extent':
            render_extent,
            'start_zoom':
            dist_render_config['start_zoom'],
            'stop_zoom':
            fill_to_zoom_level,
            'tile_x':
            dist_render_config['start_tile_x'],
            'tile_y':
            dist_render_config['start_tile_y'],
        })

    #print json.dumps(render_node_configs)

    return render_node_configs
コード例 #3
0
ファイル: dist_render.py プロジェクト: blc56/PlanetWoo
def create_machine_jobs(global_config):
	dist_render_config = global_config['dist_render']

	#override parameteres with render_extent if necessary
	render_extent = global_config['map_extent']
	if('render_extent' in dist_render_config):
		render_extent = dist_render_config['render_extent']
		tile_coords = tiletree.extent_to_tile_coord(render_extent, global_config['map_extent'])
		print 'Root Tile Coordinate:', tile_coords
		dist_render_config['start_zoom'] = tile_coords[0]
		dist_render_config['start_tile_x'] = tile_coords[1]
		dist_render_config['start_tile_y'] = tile_coords[2]
		#get the extent of the root node
		render_extent = tiletree.tile_coord_to_bbox(tile_coords[0], tile_coords[1], tile_coords[2],
				global_config['map_extent'])


	total_num_threads = sum(x['num_threads'] for x in dist_render_config['render_nodes'])
	min_num_jobs = dist_render_config.get('min_num_jobs', 1)
	if(total_num_threads > min_num_jobs):
		min_num_jobs = total_num_threads
	map_extent = global_config['map_extent']

	jobs = split_bbox(min_num_jobs, dist_render_config['start_zoom'],
			dist_render_config['start_tile_x'], dist_render_config['start_tile_y'],
			dist_render_config['stop_zoom'], *render_extent)

	fill_to_zoom_level = jobs[0].zoom_level - 1

	jobs_per_thread = int(math.ceil(len(jobs) / float(total_num_threads)))

	render_node_configs = {}
	for render_node in dist_render_config['render_nodes']:
		this_num_jobs = min(jobs_per_thread * render_node['num_threads'], len(jobs))
		#inherit the stuff from the global config
		this_config = copy.copy(global_config)
		this_config.update({
			'address': render_node['address'],
			'num_threads': render_node['num_threads'],
			'jobs': []
		})
		for job in jobs[0:this_num_jobs]:
			this_config['jobs'].append({
				'extent': [job.min_x, job.min_y, job.max_x, job.max_y],
				'start_zoom': job.zoom_level,
				'stop_zoom': dist_render_config['stop_zoom'],
				'tile_x':job.tile_x,
				'tile_y':job.tile_y,
			})
		del jobs[0:this_num_jobs]
		render_node_configs[render_node['address']] = this_config

	#add in any left over bits at the top of the tree
	if(fill_to_zoom_level >= dist_render_config['start_zoom']):
		render_node_configs.values()[0]['jobs'].append({
			'extent': render_extent,
			'start_zoom': dist_render_config['start_zoom'],
			'stop_zoom': fill_to_zoom_level,
			'tile_x': dist_render_config['start_tile_x'],
			'tile_y': dist_render_config['start_tile_y'],
		})

	#print json.dumps(render_node_configs)

	return render_node_configs