2016-01-12 21:17:06 +00:00
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
2018-02-28 23:01:27 +00:00
# Copyright 2018 Mike "KemoNine" Crosson
2016-01-12 22:51:36 +00:00
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
2018-02-28 23:01:27 +00:00
import argparse , datetime , os
from pymapsforge import process , download
2016-01-12 21:17:06 +00:00
if __name__ == ' __main__ ' :
current_timestamp = datetime . datetime . now ( ) . strftime ( ' % Y % m %d - % H % M ' )
parser = argparse . ArgumentParser ( )
2018-02-28 23:01:27 +00:00
parser . add_argument ( ' --map-list ' , action = ' append ' , required = True ,
2017-01-20 17:29:54 +00:00
help = ' a text file with one map URL per line, can be specified more than once ' )
parser . add_argument ( ' --use-ram ' , action = ' store_true ' ,
help = ' use RAM for mapsforge processing -- WARNING mapsforge uses 10x the map size in RAM for processing (ie. 100Mb map = 1Gb RAM usage), you want a LOT of RAM for this option ' )
2018-02-28 23:01:27 +00:00
parser . add_argument ( ' --max-heap-space ' , action = ' store ' , default = ' 1g ' ,
help = ' set the max heap space for the JVM, use standard -Xmx values, default (1g) should be fine if not using --use-ram argument ' )
2018-02-25 19:01:12 +00:00
parser . add_argument ( ' --output-map-name ' , action = ' store ' , default = ' output ' ,
help = ' set the output .map and .poi file names ' )
2018-02-28 23:01:27 +00:00
parser . add_argument ( ' --maps-dir ' , action = ' store ' , required = True ,
help = ' Where downloaded maps will be stored/read from ' )
parser . add_argument ( ' --no-map-download ' , action = ' store_true ' ,
help = ' Do NOT download maps, re-use maps from maps-dir ' )
2016-01-12 21:17:06 +00:00
args = parser . parse_args ( )
2018-02-28 23:01:27 +00:00
current_timestamp = datetime . datetime . now ( ) . strftime ( ' % Y % m %d - % H % M ' )
base_path = os . path . abspath ( os . path . join ( os . path . dirname ( os . path . realpath ( __file__ ) ) ) )
args . maps_dir = os . path . abspath ( args . maps_dir )
2016-08-28 18:05:11 +00:00
2018-02-28 23:01:27 +00:00
process . setup_working_dirs ( base_path , current_timestamp , args . output_map_name )
if not args . no_map_download :
download . download ( args . maps_dir , args . map_list )
2016-01-12 21:17:06 +00:00
2018-02-28 23:01:27 +00:00
process . prep_land_sea_polys ( base_path , current_timestamp , args . maps_dir , args . map_list , args . output_map_name )
process . process_land_sea_polys ( base_path , current_timestamp , args . maps_dir , args . map_list , args . output_map_name , args . max_heap_space , args . use_ram )
process . osmosis_main ( base_path , current_timestamp , args . maps_dir , args . map_list , args . output_map_name , args . max_heap_space , args . use_ram )
process . osmosis_pois ( base_path , current_timestamp , args . maps_dir , args . map_list , args . output_map_name , args . max_heap_space )
2016-08-28 18:05:11 +00:00