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 ' )
2018-03-07 00:19:33 +00:00
parser . add_argument ( ' --tag-mapping ' , action = ' store ' ,
help = ' Specify a custom tag mapping xml file for use with mapsforge processing ' )
parser . add_argument ( ' --tag-transform ' , action = ' store ' ,
help = ' Specify a tag transform file for use PRIOR to mapsforge processing (this is DIFFERENT than the mapsforge mapping xml file) ' )
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 )
2018-03-07 00:19:33 +00:00
if args . tag_transform is not None :
process . process_tag_transform ( base_path , current_timestamp , args . maps_dir , args . map_list , args . output_map_name , args . max_heap_space , args . use_ram , args . tag_transform )
process . osmosis_main ( base_path , current_timestamp , args . maps_dir , args . map_list , args . output_map_name , args . max_heap_space , args . use_ram , args . tag_mapping )
2018-02-28 23:01:27 +00:00
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