if i_loop == 2: Output_filepath="%s/1861_Mercator_Europe_Africa.mbtiles" % output_directory print "Loop: ",i_loop,"\nSource: ",Source_filepath," \nOutput: ",Output_filepath mb_step1 = MBTilesBuilder(mbtiles_input=Source_filepath, mbtiles_output=Output_filepath) # all of the 'metadata' of the 'input' will be placed in the 'output' mbtiles.db # for i_loop == 0 : the file will be rewritten and all metadata saved # for i_loop == 1 : the area of Europe will be extracted # for i_loop == 2 : the area of Europe and Africa will be extracted # when finished with the inserts, the the min/max zoom_levels, bounds and center will be calculated and saved if i_loop == 1: position_west=-8.0 position_south=36.0 position_east=80.0 position_north=77.0 # Add area and do zoom-level 3 only mb_step1.add_coverage(bbox=(position_west,position_south,position_east,position_north), zoomlevels=[3]) # - the original 'name' and calulated center will be changed ; here 'Europe' and the Brandenburg Gate, Berlin as center # use u'äöüßÄÖÜ' syntax in insure unicode when inserting into sqlite3 metadata_list = [ (u'name',u'1861 Mercator Europe'), (u'center',u'13.3777065575123,52.5162690144797,3'), ] mb_step1.add_metadata(metadata_list) if i_loop == 2: position_west=-8.0 position_south=36.0 position_east=80.0 position_north=77.0 # Add area and do zoom-levels 2 to 3 (inclusive) mb_step1.add_coverage(bbox=(position_west,position_south,position_east,position_north),zoomlevels=[2,3]) position_west=-32.0
logging.basicConfig(level=logging.DEBUG) output_directory="output" # i_parm=0: run programm ; = 1 show info only and return i_parm=0 i_min_level=2 i_max_level=2 #---------------------------------------------------------------------------------- for i_loop in range(i_min_level,i_max_level+1): if i_loop == 0: # this will create a 'mbtiles_output.mbtiles' in the directory where called # using: 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y_osm}.png' # as default: 'jpg' images in the mbtiles files are stored as 'jpg' with 75% quality # - the recieved png will be converted to jpg mb_step1 = MBTilesBuilder(cache=False) mb_step1.add_coverage(bbox=(-180.0, -90.0, 180.0, 90.0), zoomlevels=[0,1]) # use u'äöüßÄÖÜ' syntax in insure unicode when inserting into sqlite3 metadata_list = [ (u'name',u'World OpenStreetMap'), (u'description',u'World OpenStreet Map with jpg tiles'), (u'center',u'13.3777065575123,52.5162690144797,1'), ] mb_step1.add_metadata(metadata_list) # with 'False' we are telling MBTilesBuilder to exit if the file exists # with 'True' we are telling MBTilesBuilder to use an existing mbtiles file # i_parm=0: run programm ; = 1 show info only and return # - if no parmameters are given: 'False,0' is assumed # i_parm=1 mb_step1.run(False,i_parm) del mb_step1 #----------------------------------------------------------------------------------