def optimize_tiles(): args = [] # Turn on backup files (just to compare sizes with optimized tiles). #args.append ("-backup") # Set the OptiPNG optimization rate (0 to 7), 7 being very slow. optimization_rate = 2 args.append ("-o{0}".format(optimization_rate)) # We don't want any OptiPNG output text to clutter Maperitive. args.append ("-quiet") args.extend(tiles_to_optimize) # This is one way to execute external programs. App.run_program("tools/OptiPNG/optipng.exe", 100, args) # Clear the list. del tiles_to_optimize[:]
from maperipy import App App.log('script-dir: ' + App.script_dir) App.run_command('change-dir dir="' + App.script_dir +'"') App.run_command("run-script file=IsraelHiking.mscript") # Map Created App.run_command('change-dir dir="Site"') App.run_command("generate-tiles minzoom=7 maxzoom=15 use-fprint=true") App.log("=== Create a Zip file with new tiles ===") App.run_command('zip zip-file="' + App.script_dir +'\output\TileUpdate.zip"') App.log("=== Start uploading of tiles zoom 15 and below ===") App.log('App.start_program("' + App.script_dir + '\UploadTiles.bat")') App.start_program(App.script_dir + "\UploadTiles.bat") App.log("=== Start creation of Oruxmap map ===") App.log('App.start_program(App.script_dir + "\..\..\Mobile Atlas Creator\CreateIsraelHiking.bat", [])') App.start_program(App.script_dir + "\..\..\Mobile Atlas Creator\CreateIsraelHiking.bat", []) App.log("=== Create tiles for zoom 16 ===") App.run_command("generate-tiles minzoom=16 maxzoom=16 use-fprint=true") App.log("=== Create a Zip file with new tiles ===") App.run_command('zip zip-file="' + App.script_dir +'\output\TileUpdate16.zip"') App.log("=== Start uploading of tiles zoom 16 ===") App.log('App.start_program("' + App.script_dir + '\UploadTiles.bat", "TileUpdate16.zip"])') App.start_program(App.script_dir + "\UploadTiles.bat", ["TileUpdate16.zip"]) App.run_command('change-dir dir="' + App.script_dir +'"')
from maperipy import App MinLon=34 MaxLon=36 MinLat=29 MaxLat=34 App.run_command('set-dem-source ASTER') for Lon in range (MinLon, MaxLon, 1) : for Lat in range (MinLat, MaxLat, 1) : App.run_command('generate-contours interval=10 bounds='+str(Lon)+','+str(Lat)+ ',' +str(Lon+1)+','+str(Lat+1)) App.run_command('save-source ASTER-'+str(Lon)+'-'+str(Lat)+'.contours') App.run_command('save-map-script file=Scripts\Contours.mscript')
# http://stackoverflow.com/questions/749711/how-to-get-the-python-exe-location-programmatically MaperitiveDir = os.path.dirname(os.path.dirname( os.path.normpath(os.__file__))) # App.log('MaperitiveDir: '+MaperitiveDir) ProgramFiles = os.path.normpath(os.path.dirname(MaperitiveDir)) # App.log('ProgramFiles: '+ProgramFiles) IsraelHikingDir = os.path.dirname(os.path.dirname( os.path.normpath(App.script_dir))) # App.log('App.script_dir: '+App.script_dir) # App.log('IsraelHikingDir: '+IsraelHikingDir) HGTDir = 'ASTER' os.chdir(os.path.join(IsraelHikingDir, 'Cache', 'Rasters', HGTDir)) App.run_command('change-dir dir="' + os.path.join(IsraelHikingDir, 'Cache', 'Rasters', HGTDir) + '"') # Set bounds to match # http://download.geofabrik.de/asia/israel-and-palestine-latest.osm.pbf App.run_command("set-geo-bounds 34.07929,29.37711,35.91531,33.35091"); # Geo bounds in integer degrees MinLon = int(Map.geo_bounds.min_x) MaxLon = int(math.ceil(Map.geo_bounds.max_x)) MinLat = int(Map.geo_bounds.min_y) MaxLat = int(math.ceil(Map.geo_bounds.max_y)) # Loop throu HGT files # TODO: add support for South and West hemisphares
import os.path import math import sqlite3 from maperipy import App from maperipy import Map import sys # http://stackoverflow.com/questions/749711/how-to-get-the-python-exe-location-programmatically MaperitiveDir = os.path.dirname(os.path.dirname(os.path.normpath(os.__file__))) # App.log('MaperitiveDir: '+MaperitiveDir) ProgramFiles = os.path.normpath(os.path.dirname(MaperitiveDir)) # App.log('ProgramFiles: '+ProgramFiles) IsraelHikingDir = os.path.dirname(os.path.dirname(os.path.normpath(App.script_dir))) # App.log('App.script_dir: '+App.script_dir) # App.log('IsraelHikingDir: '+IsraelHikingDir) App.run_command('change-dir dir="'+IsraelHikingDir +'"') os.chdir(IsraelHikingDir) # Set bounds to match # http://download.geofabrik.de/asia/israel-and-palestine-latest.osm.pbf App.run_command("set-geo-bounds 34.07929,29.37711,35.91531,33.35091"); # Geo bounds in integer degrees MinLon=Map.geo_bounds.min_x MaxLon=Map.geo_bounds.max_x MinLat=int(Map.geo_bounds.min_y) MaxLat=int(math.ceil(Map.geo_bounds.max_y)) HGTDir = 'ASTER'
from maperipy import App import time import os import urllib mobileAtlasCreatorPath = 'D:\Mobile Atlas Creator' startPath = os.path.abspath(App.script_dir + '\..\\') App.log('script-dir: ' + App.script_dir) App.log('change-dir dir="' + startPath + '"') App.run_command('change-dir dir="' + startPath + '"') App.log('=== downloading if needed israel-and-palestine-latest.osm.pbf ===') localFile = os.path.abspath(startPath + '\cache\israel-and-palestine-latest.osm.pbf') remoteFile = 'http://download.geofabrik.de/asia/israel-and-palestine-latest.osm.pbf' urllibobject = urllib.urlopen( "http://download.geofabrik.de/asia/israel-and-palestine-latest.osm.pbf") if os.path.isfile(localFile) == 0 or urllibobject.info( )['Content-Length'] != str(os.stat(localFile).st_size): urllib.urlretrieve(remoteFile, localFile) App.log('=== download complete ===') App.run_command("run-script file=Scripts\IsraelHiking.mscript") sitePath = os.path.abspath(startPath + '\..\Site') App.log('change-dir dir="' + sitePath + '"') App.run_command('change-dir dir="' + sitePath + '"') App.run_command("generate-tiles minzoom=7 maxzoom=15 use-fprint=true") App.log("=== Create a Zip file with new tiles ===") App.run_command('zip zip-file="TileUpdate.zip"')
from maperipy import App App.log('script-dir: ' + App.script_dir) App.run_command('change-dir dir="' + App.script_dir + '"') App.run_command("run-script file=IsraelHiking.mscript") # Map Created App.run_command("generate-tiles minzoom=7 maxzoom=15 use-fprint=true") App.log("=== Create a Zip file with new tiles ===") App.run_command("zip zip-file=output\TileUpdate.zip") App.log("=== Start uploading of tiles zoom 15 and below ===") App.log('App.start_program("' + App.script_dir + '\UploadTiles.bat")') App.start_program(App.script_dir + "\UploadTiles.bat") App.log("=== Start creation of Oruxmap map ===") App.log( 'App.start_program(App.script_dir + "\..\..\Mobile Atlas Creator\CreateIsraelHiking.bat", [])' ) App.start_program( App.script_dir + "\..\..\Mobile Atlas Creator\CreateIsraelHiking.bat", []) App.log("=== Create tiles for zoom 16 ===") App.run_command("generate-tiles minzoom=16 maxzoom=16 use-fprint=true") App.log("=== Create a Zip file with new tiles ===") App.run_command("zip zip-file=output\TileUpdate16.zip") App.log("=== Start uploading of tiles zoom 16 ===") App.log('App.start_program("' + App.script_dir + '\UploadTiles.bat", "TileUpdate16.zip"])') App.start_program(App.script_dir + "\UploadTiles.bat", ["TileUpdate16.zip"])
import math import sqlite3 from maperipy import App from maperipy import Map import sys # http://stackoverflow.com/questions/749711/how-to-get-the-python-exe-location-programmatically MaperitiveDir = os.path.dirname(os.path.dirname(os.path.normpath(os.__file__))) # App.log('MaperitiveDir: '+MaperitiveDir) ProgramFiles = os.path.normpath(os.path.dirname(MaperitiveDir)) # App.log('ProgramFiles: '+ProgramFiles) IsraelHikingDir = os.path.dirname( os.path.dirname(os.path.normpath(App.script_dir))) # App.log('App.script_dir: '+App.script_dir) # App.log('IsraelHikingDir: '+IsraelHikingDir) App.run_command('change-dir dir="' + IsraelHikingDir + '"') os.chdir(IsraelHikingDir) # Set bounds to match # http://download.geofabrik.de/asia/israel-and-palestine-latest.osm.pbf App.run_command("set-geo-bounds 34.07929,29.37711,35.91531,33.35091") # Geo bounds in integer degrees MinLon = Map.geo_bounds.min_x MaxLon = Map.geo_bounds.max_x MinLat = int(Map.geo_bounds.min_y) MaxLat = int(math.ceil(Map.geo_bounds.max_y)) HGTDir = 'ASTER'
# import sys # http://stackoverflow.com/questions/749711/how-to-get-the-python-exe-location-programmatically MaperitiveDir = os.path.dirname(os.path.dirname(os.path.normpath(os.__file__))) # App.log('MaperitiveDir: '+MaperitiveDir) ProgramFiles = os.path.normpath(os.path.dirname(MaperitiveDir)) # App.log('ProgramFiles: '+ProgramFiles) IsraelHikingDir = os.path.dirname( os.path.dirname(os.path.normpath(App.script_dir))) # App.log('App.script_dir: '+App.script_dir) # App.log('IsraelHikingDir: '+IsraelHikingDir) HGTDir = 'ASTER' os.chdir(os.path.join(IsraelHikingDir, 'Cache', 'Rasters', HGTDir)) App.run_command('change-dir dir="' + os.path.join(IsraelHikingDir, 'Cache', 'Rasters', HGTDir) + '"') # Set bounds to match # http://download.geofabrik.de/asia/israel-and-palestine-latest.osm.pbf App.run_command("set-geo-bounds 34.07929,29.37711,35.91531,33.35091") # Geo bounds in integer degrees MinLon = int(Map.geo_bounds.min_x) MaxLon = int(math.ceil(Map.geo_bounds.max_x)) MinLat = int(Map.geo_bounds.min_y) MaxLat = int(math.ceil(Map.geo_bounds.max_y)) # Loop throu HGT files # TODO: add support for South and West hemisphares
from maperipy import App import time import os import urllib mobileAtlasCreatorPath = 'D:\Mobile Atlas Creator' startPath = os.path.abspath(App.script_dir + '\..\\') App.log('script-dir: ' + App.script_dir) App.log('change-dir dir="' + startPath + '"') App.run_command('change-dir dir="' + startPath + '"') App.log('=== downloading if needed israel-and-palestine-latest.osm.pbf ===') localFile = os.path.abspath(startPath + '\cache\israel-and-palestine-latest.osm.pbf') remoteFile = 'http://download.geofabrik.de/asia/israel-and-palestine-latest.osm.pbf' urllibobject = urllib.urlopen("http://download.geofabrik.de/asia/israel-and-palestine-latest.osm.pbf") if os.path.isfile(localFile) == 0 or urllibobject.info()['Content-Length'] != str(os.stat(localFile).st_size) : urllib.urlretrieve(remoteFile, localFile) App.log('=== download complete ===') App.run_command("run-script file=Scripts\IsraelHiking.mscript") sitePath = os.path.abspath(startPath + '\..\Site') App.log('change-dir dir="' + sitePath + '"') App.run_command('change-dir dir="' + sitePath + '"') App.run_command("generate-tiles minzoom=7 maxzoom=15 use-fprint=true") App.log("=== Create a Zip file with new tiles ===") App.run_command('zip zip-file="TileUpdate.zip"') lastModified = sitePath + '\js\LastModified.js' App.log('=== Create LastModified.js file and add it to zip file: ' + lastModified + '===') jsFile = open(lastModified, 'w')
from maperipy import App import os.path App.log('script-dir: ' + App.script_dir) App.run_command('change-dir dir="' + App.script_dir +'"') ProgramFiles = os.path.dirname(os.path.dirname(App.script_dir)) App.log("=== Create Trails Overlay tiles ===") App.run_command("run-script file=IsraelHikingOverlay.mscript") if os.path.exists(App.script_dir + "\UploadTiles.bat"): App.log("=== Upload Trails Overlay tiles ===") App.log('App.start_program("' + App.script_dir + '\UploadTiles.bat", "OverlayTiles.zip"])') App.start_program(App.script_dir + "\UploadTiles.bat", ["OverlayTiles.zip"]) if os.path.exists(ProgramFiles + "\Mobile Atlas Creator\All IsraelHikingOverlay Maps.bat"): App.log("=== Launch creation of All IsraelHikingOverlay Maps ===") App.log('App.start_program(ProgramFiles + "\Mobile Atlas Creator\All IsraelHikingOverlay Maps.bat", [])') App.start_program(ProgramFiles + "\Mobile Atlas Creator\All IsraelHikingOverlay Maps.bat", []) App.collect_garbage() # vim: shiftwidth=4 expandtab
from maperipy import App import os.path App.log('script-dir: ' + App.script_dir) App.run_command('change-dir dir="' + App.script_dir + '"') ProgramFiles = os.path.dirname(os.path.dirname(App.script_dir)) App.log("=== Create Trails Overlay tiles ===") App.run_command("run-script file=IsraelHikingOverlay.mscript") if os.path.exists(App.script_dir + "\UploadTiles.bat"): App.log("=== Upload Trails Overlay tiles ===") App.log('App.start_program("' + App.script_dir + '\UploadTiles.bat", "OverlayTiles.zip"])') App.start_program(App.script_dir + "\UploadTiles.bat", ["OverlayTiles.zip"]) if os.path.exists(ProgramFiles + "\Mobile Atlas Creator\All IsraelHikingOverlay Maps.bat"): App.log("=== Launch creation of All IsraelHikingOverlay Maps ===") App.log( 'App.start_program(ProgramFiles + "\Mobile Atlas Creator\All IsraelHikingOverlay Maps.bat", [])' ) App.start_program( ProgramFiles + "\Mobile Atlas Creator\All IsraelHikingOverlay Maps.bat", []) App.collect_garbage() # vim: shiftwidth=4 expandtab
from maperipy import App import os.path, datetime App.log('script-dir: ' + App.script_dir) App.run_command('change-dir dir="' + App.script_dir + '"') ProgramFiles = os.path.dirname(os.path.dirname(App.script_dir)) if not os.path.exists(App.script_dir + '\output\TileUpdate.zip') and not os.path.exists( App.script_dir + '\output\TileUpdate16.zip'): App.log("=== Update israel-and-palestine-latest.osm.pbf ===") # wget for Windows: http://gnuwin32.sourceforge.net/packages/wget.htm App.run_program(ProgramFiles + '\wget\wget.exe', 1200, [ "--timestamping", "--no-directories", "--no-verbose", '--directory-prefix="' + App.script_dir + '"', "http://download.geofabrik.de/asia/israel-and-palestine-latest.osm.pbf" ]) LastModified = datetime.datetime.fromtimestamp( os.path.getmtime(App.script_dir + '\israel-and-palestine-latest.osm.pbf')) if LastModified + datetime.timedelta(1) < datetime.datetime.today(): App.log("=== pbf file not updated ===") App.run_command("pause 15000") # Create LastModified.js file and add it to zip file App.log("=== Create Last Update info:" + LastModified.strftime("%d-%m-%Y") + " ===") jsFile = open(App.script_dir + '\Site\js\LastModified.js', 'w') jsFile.write("function getLastModifiedDate() { return '" + LastModified.strftime("%d-%m-%Y") + "'; }") jsFile.close()
from maperipy import App import os.path, datetime App.log('script-dir: ' + App.script_dir) App.run_command('change-dir dir="' + App.script_dir +'"') ProgramFiles = os.path.dirname(os.path.dirname(App.script_dir)) if not os.path.exists(App.script_dir +'\output\TileUpdate.zip') and not os.path.exists(App.script_dir +'\output\TileUpdate16.zip'): App.log("=== Update israel-and-palestine-latest.osm.pbf ===") # wget for Windows: http://gnuwin32.sourceforge.net/packages/wget.htm App.run_program(ProgramFiles + '\wget\\bin\wget.exe', 1200, ["--timestamping", "--no-directories", "--no-verbose", '--directory-prefix="' + App.script_dir +'"', "http://download.geofabrik.de/asia/israel-and-palestine-latest.osm.pbf"]) LastModified = datetime.datetime.fromtimestamp(os.path.getmtime('israel-and-palestine-latest.osm.pbf')) if LastModified + datetime.timedelta(1) < datetime.datetime.today(): App.log("=== pbf file not updated ==="); App.run_command("pause 15000") # Create LastModified.js file and add it to zip file App.log("=== Create Last Update info:" + LastModified.strftime("%d-%m-%Y") + " ===") jsFile = open(App.script_dir + '\Site\js\LastModified.js', 'w') jsFile.write("function getLastModifiedDate() { return '" + LastModified.strftime("%d-%m-%Y") + "'; }") jsFile.close() App.run_command('zip base-dir="' + App.script_dir + '\Site" files="' + App.script_dir + '\Site\js\LastModified.js" zip-file="' + App.script_dir +'\output\LastModified.zip"') else : App.log('=== Continueing execution of the previous build ===') App.run_command("pause 15000")