Ejemplo n.º 1
0
# export PYTHONPATH=/usr/lib/mapmbtiles:$PYTHONPATH

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
Ejemplo n.º 2
0
# Step 1 - we will subdivide an existing mbtiles
#----------------------------------------------------------------------------------
i_min_level=0
i_max_level=3
# zoom-levels 0-3
Source_filepath="%s/1861_Mercator_World.mbtiles" % input_directory
if os.path.exists(Source_filepath):
 for i_loop in range(i_min_level,i_max_level+1):
  if i_loop == 0:
   Output_filepath="%s/1861_Mercator_World.mbtiles" % output_directory
  if i_loop == 1:
   Output_filepath="%s/1861_Mercator_Europe.mbtiles" % output_directory
  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 = [
Ejemplo n.º 3
0
# -*- 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()