This repository has been archived on 2024-07-04. You can view files and clone it, but cannot push or open issues or pull requests.
osm_map_processing/process_maps.py

56 lines
3.4 KiB
Python
Executable file

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright 2018 Mike "KemoNine" Crosson
# 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.
import argparse, datetime, os
from pymapsforge import process, download
if __name__ == '__main__':
current_timestamp = datetime.datetime.now().strftime('%Y%m%d-%H%M')
parser = argparse.ArgumentParser()
parser.add_argument('--map-list', action='append', required=True,
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')
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')
parser.add_argument('--output-map-name', action='store', default='output',
help='set the output .map and .poi file names')
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')
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)')
args = parser.parse_args()
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)
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)
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)
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)
process.osmosis_pois(base_path, current_timestamp, args.maps_dir, args.map_list, args.output_map_name, args.max_heap_space)