position_north=36.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]) # - the original 'name' and calulated center will be changed ; here 'Europe/Africa' and Piazza della Signoria, Florence as center # use u'äöüßÄÖÜ' syntax in insure unicode when inserting into sqlite3 metadata_list = [ (u'name',u'1861 Mercator Europe/Africa'), (u'center',u'11.255867505557262,43.76961577178412,3'), ] 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 #---------------------------------------------------------------------------------- # Step 2 - we will add to an existing mbtiles a portion from another mbtiles file #---------------------------------------------------------------------------------- # zoom-levels 0-8 [this file is the complete collection - it includes the same tiles as 1861_Mercator_World.mbtiles] # 'wget http://www.mj10777.de/public/download/mbtiles/1861_Mercator_Countries.mbtiles -o source/1861_Mercator_Countries.mbtiles Source_filepath="%s/1861_Mercator_Countries.mbtiles" % input_directory if os.path.exists(Source_filepath): # we will be adding an area from another mbtiles file to the existing one Output_filepath="%s/1861_Mercator_Europe.mbtiles" % output_directory if os.path.exists(Output_filepath): print "Step 2\nSource: ",Source_filepath," \nOutput: ",Output_filepath mb_step2 = MBTilesBuilder(mbtiles_input=Source_filepath,mbtiles_output=Output_filepath) # 12.656250,51.618017,14.062500,53.330873 position_west=12.656250
# -*- coding: utf-8 -*- import logging from mapmbtiles import MBTilesBuilder # .bashrc # export PYTHONPATH=/usr/lib/mapmbtiles:$PYTHONPATH logging.basicConfig(level=logging.DEBUG) input_directory="source" output_directory="output" s_name=""; # zoom-levels 0-3 Source_filepath="%s/lidarplots.mbtiles" % input_directory for i_loop in range(0,1): if i_loop == 0: # this db was to big to include in GitHub # remote: warning: File samples/source/lidarplots.mbtiles is 90.62 MB; this is larger than GitHub's recommended maximum file size of 50 MB # 'wget http://www.mj10777.de/public/download/mbtiles/test_mbtiles/lidarplots.mbtiles -o source/lidarplots.mbtiles Output_filepath="%s/lidarplots.mbtiles" % output_directory print "Loop: ",i_loop,"\nSource: ",Source_filepath," \nOutput: ",Output_filepath mb = MBTilesBuilder(mbtiles_input=Source_filepath, mbtiles_output=Output_filepath) # lidarplots.mbtiles db used 'tiles' as a table and not a view # - the result will be created with 'tiles' as a view with 'map' and 'images' as a table # the metadata table used mixed lettering for 'name' : 'minZoom' # - these will be recognized and changed to lower case # 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 mb.run()