Commit 807c6bd4 authored by Rick Gruber-Riemer's avatar Rick Gruber-Riemer

Adding required argument to options to make it more clear.

Centralized prefix parsing.
parent a0569367
......@@ -8,7 +8,6 @@ import logging
import sys
import re
import os
import platform
import stat
from _io import open
......@@ -30,8 +29,8 @@ def _get_file_name(name, tile_name):
return name + tile_name + extension
def _open_file(name):
return open(calc_tile.root_directory_name((lon, lat)) + os.sep + name, "wb")
def _open_file(name, directory):
return open(directory + name, "wb")
def _write_to_file(command, file_handle):
......@@ -44,9 +43,9 @@ def _write_to_file(command, file_handle):
if __name__ == '__main__':
logging.basicConfig(level=logging.INFO)
parser = argparse.ArgumentParser(description="build-tiles generates a directory structure capable of generating complete tiles of scenery")
parser.add_argument("-t", "--tile", dest="tilename",
help="The name of the tile", required=True)
parser = argparse.ArgumentParser(description="build-tiles generates a directory structure capable of generating a complete 1 degree lon/lat-areas of scenery")
parser.add_argument("-t", "--tile", dest="tile_name",
help="The name of the lon/lat-area (e.g. e009n47)", required=True)
parser.add_argument("-f", "--properties", dest="properties",
help="The name of the property file to be copied", required=True)
parser.add_argument("-o", "--out", dest="out",
......@@ -72,20 +71,8 @@ if __name__ == '__main__':
args = parser.parse_args()
# if(args.tilename is None):
# logging.error("Tilename is required")
# parser.print_usage()
# exit(1)
# if(args.properties is None):
# logging.error("Input properties are required")
# parser.print_usage()
# exit(1)
# if(args.out is None):
# logging.error("Output properties are required")
# parser.print_usage()
# exit(1)
logging.info('Generating directory structure for %s ', args.tilename)
matched = re.match("([ew])([0-9]{3})([ns])([0-9]{2})", args.tilename)
logging.info('Generating directory structure for %s ', args.tile_name)
matched = re.match("([ew])([0-9]{3})([ns])([0-9]{2})", args.tile_name)
lon = int(matched.group(2))
lat = int(matched.group(4))
if matched.group(1) == 'w':
......@@ -96,31 +83,33 @@ if __name__ == '__main__':
num_rows = 1
else:
num_rows = int(1 / calc_tile.bucket_span(lat))
# int(1/calc_tile.bucket_span(lat))
num_cols = 8
root_dir_name = calc_tile.root_directory_name((lon, lat))
try:
os.makedirs(calc_tile.root_directory_name((lon, lat)))
os.makedirs(root_dir_name)
except OSError, e:
if e.errno != 17:
logging.exception("Unable to create path to output")
download_file = _open_file(_get_file_name("download_", args.tilename))
download_file = _open_file(_get_file_name("download_", args.tile_name), root_dir_name)
files = []
utils = [ 'osm2city', 'osm2pylon', 'tools', 'platforms', 'roads', 'piers', ]
utils = ['tools', 'osm2city', 'osm2pylon', 'platforms', 'roads', 'piers', ]
for util in utils:
files.append((util + '.py',
_open_file(_get_file_name(util + "_", args.tilename)),
_open_file(_get_file_name(util + "_", args.tile_name), root_dir_name),
))
#check if necessary to add parallel processing code
# Check if necessary to add parallel processing code
BASH_PARALLEL_PROCESS = False
is_linux_or_mac = setup.is_linux_or_mac()
if args.parallel:
if re.search('linux|mac', platform.system().lower()):
if is_linux_or_mac:
BASH_PARALLEL_PROCESS = True
#header for bash if necessary
if re.search('linux|mac', platform.system().lower()):
# Header for bash if necessary
if is_linux_or_mac:
header_bash = '''#!/bin/bash''' + os.linesep
if BASH_PARALLEL_PROCESS:
header_bash += '''#
......@@ -190,10 +179,9 @@ done
command[1].close()
# chmod u+x on created scripts for linux
my_os_type = setup.get_os_type()
if my_os_type is setup.OSType.linux or my_os_type is setup.OSType.mac:
if is_linux_or_mac:
for util in utils + ['download', ]:
f = calc_tile.root_directory_name((lon, lat)) + os.sep + _get_file_name(util + "_", args.tilename)
f = calc_tile.root_directory_name((lon, lat)) + os.sep + _get_file_name(util + "_", args.tile_name)
try:
st = os.stat(f)
os.chmod(f, st.st_mode | stat.S_IEXEC)
......
......@@ -52,8 +52,7 @@ if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Copies texture related data in directory 'tex' into the scenery folders.")
parser.add_argument("-f", "--file", dest="filename",
help="Mandatory: read parameters from FILE (e.g. params.ini)", metavar="FILE")
parser.add_argument("-o", dest="o", action="store_true", help="do not overwrite existing elevation data")
help="Mandatory: read parameters from FILE (e.g. params.ini)", metavar="FILE", required=True)
args = parser.parse_args()
if args.filename is not None:
parameters.read_from_file(args.filename)
......
......@@ -58,5 +58,87 @@ In most situations you may want to at least provide command line parameter ``-f`
Remember that the paths are relative to the ``WORKING_DIRECTORY``. Alternatively provide the full path to your ``params.ini`` [#]_ file.
=====================
Working in Batch Mode
=====================
As described in chapter :ref:`Getting OpenStreetMap data <chapter-getting-data-label>` FlightGear works with tiles and you should not cross tiles boundaries. So in order to cover most of Switzerland you need to run ``osm2city`` related programs for 4 degrees longitude and 2 degrees latitude. In this case there are 4 tiles per longitude and 8 tiles per latitude, i.e. a total of 4*2*4*8 = 256 times. In order to make this process a bit easier, you can use ``build_tiles.py``.
The default work flow is based on the sub-chapters of :ref:`Preparation <chapter-preparation-label>`.
#. :ref:`Run setup.py <chapter-run-setup-label>`
#. Adapt ``params.ini``. This will get copied to several subdirectories as part of the next process steps. Most importantly adapt parameters ``PREFIX`` (in the example below "CH_OSM") and ``PATH_TO_OUTPUT`` (in the example below "/home/fg_customscenery/CH_OSM").
#. :ref:`Call build_tiles.py <chapter-build-tiles-label>`. This step creates subdirectories including a set of shell / command scripts. The top directory will be created in your ``WORKING_DIRECTORY`` and have the same name as the lon/lat area specified with parameter ``-t``
#. If needed adapt the params.ini files in the subdirectories if you need to change specific characteristics within one tile (e.g. parameters for building height etc.). In a lot of situations this will not be needed.
#. Call the FIXME scripts
#. FIXME: copy tex
.. _chapter-build-tiles-label:
----------------------
Calling build_tiles.py
----------------------
::
/usr/bin/python2.7 /home/pingu/develop_vcs/osm2city/batch_processing/build_tiles.py -t e009n47 -f CH_OSM/params_kp.ini -o params.ini
Mandatory command line arguments:
* -t: the name of the 1-degree lon/lat-area, e.g. w003n60 or e012s06 (you need to provide 3 digits for longitude and 2 digits for latitude). The lon/lat position is the lower left corner (e.g. e009n47 to cover most of the Lake of Constance region).
* -f: the relative path to the main params.ini file, which is the template copied to all sub-directories.
* -o: the name of the copied params.ini files in the sub-directories
Optional command line arguments:
* -p: You can use this option on linux and mac in order to generate scripts with parallel processing support and specify the max number of parallel processes when calling the generated scripts.
* --url: Which API to use to download OSM data on the fly
* -n: FIXME
tools[ew]XXX[ns][YY].[sh|cmd]
Generated by build-tiles.py and contains the calls to all subdirectories of the tile [ew]XXX[ns][YY].
downloadXXXX.[sh|cmd]
Generated by build-tiles.py and contains wget calls to download all the subtiles of [ew]XXX[ns][YY] into the subdirectories.
osm2cityXXXX.[sh|cmd]
Generated by build-tiles.py and contains the calls to all subdirectories of the tile [ew]XXX[ns][YY].
Example
python osm2city.py -f w010n60/w003n60/2909568/params.ini
python osm2city.py -f w010n60/w003n60/2909569/params.ini
python osm2city.py -f w010n60/w003n60/2909570/params.ini
python osm2city.py -f w010n60/w003n60/2909571/params.ini
python osm2city.py -f w010n60/w003n60/2909576/params.ini
python osm2city.py -f w010n60/w003n60/2909577/params.ini
python osm2city.py -f w010n60/w003n60/2909578/params.ini
python osm2city.py -f w010n60/w003n60/2909579/params.ini
python osm2city.py -f w010n60/w003n60/2909584/params.ini
python osm2city.py -f w010n60/w003n60/2909585/params.ini
python osm2city.py -f w010n60/w003n60/2909586/params.ini
python osm2city.py -f w010n60/w003n60/2909587/params.ini
python osm2city.py -f w010n60/w003n60/2909592/params.ini
python osm2city.py -f w010n60/w003n60/2909593/params.ini
python osm2city.py -f w010n60/w003n60/2909594/params.ini
python osm2city.py -f w010n60/w003n60/2909595/params.ini
python osm2city.py -f w010n60/w003n60/2909600/params.ini
python osm2city.py -f w010n60/w003n60/2909601/params.ini
python osm2city.py -f w010n60/w003n60/2909602/params.ini
python osm2city.py -f w010n60/w003n60/2909603/params.ini
python osm2city.py -f w010n60/w003n60/2909608/params.ini
python osm2city.py -f w010n60/w003n60/2909609/params.ini
python osm2city.py -f w010n60/w003n60/2909610/params.ini
python osm2city.py -f w010n60/w003n60/2909611/params.ini
python osm2city.py -f w010n60/w003n60/2909616/params.ini
python osm2city.py -f w010n60/w003n60/2909617/params.ini
python osm2city.py -f w010n60/w003n60/2909618/params.ini
python osm2city.py -f w010n60/w003n60/2909619/params.ini
python osm2city.py -f w010n60/w003n60/2909624/params.ini
python osm2city.py -f w010n60/w003n60/2909625/params.ini
python osm2city.py -f w010n60/w003n60/2909626/params.ini
python osm2city.py -f w010n60/w003n60/2909627/params.ini
.. [#] ou can name this file whatever you want — "params.ini" is just a convenience / convention.
......@@ -130,7 +130,7 @@ PATH_TO_SCENERY
likely you'll want to use your TerraSync path here.
PATH_TO_OUTPUT
The generated scenery (.stg, .ac, .xml) will be written to this path. If empty then the correct location in PATH_TO_SCENERY is used. Note that if you use TerraSync for PATH_TO_SCENERY, you MUST choose a different path here. Otherwise, TerraSync will overwrite the generated scenery. Unless you know what you are doing, there is no reason not to specify a dedicated path here. While not absolutely needed it is good practice to name the output folder the same as ``PREFIX``.
The generated scenery (.stg, .ac, .xml) will be written to this path — specified without triling slash. If empty then the correct location in PATH_TO_SCENERY is used. Note that if you use TerraSync for PATH_TO_SCENERY, you MUST choose a different path here. Otherwise, TerraSync will overwrite the generated scenery. Unless you know what you are doing, there is no reason not to specify a dedicated path here. While not absolutely needed it is good practice to name the output folder the same as ``PREFIX``.
OSM_FILE
The file containing OpenStreetMap data. See previous chapter :ref:`Getting OpenStreetMap Data <chapter-getting-data-label>`.
BOUNDARY_*
......
......@@ -3,9 +3,8 @@
'''
import argparse
import logging
import os
import re
from subprocess import STDOUT, PIPE
from subprocess import PIPE
import subprocess
import sys
from time import sleep
......@@ -18,7 +17,9 @@ if __name__ == '__main__':
parser = argparse.ArgumentParser(description="Downloads a tile from osm. It handles too many requests and backs off")
parser.add_argument("-f", "--properties", dest="properties",
help="The name of the property file to be copied", required=True)
parser.add_argument("-l", "--loglevel", help="set loglevel. Valid levels are VERBOSE, DEBUG, INFO, WARNING, ERROR, CRITICAL")
parser.add_argument("-l", "--loglevel"
, help="set loglevel. Valid levels are VERBOSE, DEBUG, INFO, WARNING, ERROR, CRITICAL"
, required=False)
args = parser.parse_args()
if args.properties is not None:
......@@ -28,15 +29,20 @@ if __name__ == '__main__':
for x in range(0, 10):
download_command = 'curl -w %s -f --proxy-ntlm -o %s/buildings.osm http://overpass-api.de/api/map?bbox=%f,%f,%f,%f'
path = '%s/buildings.osm' % parameters.PREFIX
url = 'http://overpass-api.de/api/map?bbox=%f,%f,%f,%f' % (parameters.BOUNDARY_WEST, parameters.BOUNDARY_SOUTH, parameters.BOUNDARY_EAST, parameters.BOUNDARY_NORTH)
url = 'http://overpass-api.de/api/map?bbox=%f,%f,%f,%f' % (parameters.BOUNDARY_WEST
, parameters.BOUNDARY_SOUTH
, parameters.BOUNDARY_EAST
, parameters.BOUNDARY_NORTH)
# if parameters.BASH_PARALLEL_PROCESS :
# download_command += '&' + os.linesep + 'parallel_wait $max_parallel_process' + os.linesep
# else :
# download_command += os.linesep
# print download_command % (parameters.PREFIX, parameters.BOUNDARY_WEST, parameters.BOUNDARY_SOUTH, parameters.BOUNDARY_EAST, parameters.BOUNDARY_NORTH)
logging.info("Downloading %s"%parameters.PREFIX)
logging.info("Downloading %s", parameters.PREFIX)
tries = 0
download_command = download_command % ("CODE:%{http_code}:", parameters.PREFIX, parameters.BOUNDARY_WEST, parameters.BOUNDARY_SOUTH, parameters.BOUNDARY_EAST, parameters.BOUNDARY_NORTH)
download_command = download_command % ("CODE:%{http_code}:", parameters.PREFIX, parameters.BOUNDARY_WEST
, parameters.BOUNDARY_SOUTH, parameters.BOUNDARY_EAST
, parameters.BOUNDARY_NORTH)
while tries < 10:
proc = subprocess.Popen(download_command, stderr=PIPE, stdout=PIPE,bufsize=1, universal_newlines=True)
# exitcode = proc.wait()
......@@ -49,22 +55,20 @@ if __name__ == '__main__':
# Already read stderr setting to None lets us get stdout
proc.stderr = None
output = proc.communicate()[0]
exitcode = proc.wait() # wait for the subprocess to exit http_code = re.search("CODE:([0-9]*):", outs).group(1)
exitcode = proc.wait() # wait for the subprocess to exit http_code = re.search("CODE:([0-9]*):", outs).group(1)
http_code = re.search("CODE:([0-9]*):", output).group(1)
logging.info("Received %s" % (http_code))
logging.info("Received %s", http_code)
if http_code != "429":
if http_code == "200":
logging.info("Downloaded sucessfully %s" % (http_code))
logging.info("Downloaded successfully %s", http_code)
exit(0)
else:
logging.error("Non repeatable http_code %s" % (http_code))
logging.error("Non repeatable http_code %s", http_code)
exit(http_code)
tries += 1
wait = 60 * tries
logging.info("Received too many requests retrying in %d s %d" % (wait, tries))
logging.info("Received too many requests retrying in %d s %d", wait, tries)
sleep(wait)
logging.info("Too many requests failing with %s" % (http_code))
logging.info("Too many requests failing with %s", http_code)
exit(http_code)
# exitcode = os.spawnv(os.P_WAIT,'curl', ['-f', '--proxy-ntlm', '-o', path, url])
# print exitcode
......@@ -630,13 +630,19 @@ if __name__ == "__main__":
# -- Parse arguments. Command line overrides config file.
parser = argparse.ArgumentParser(description="osm2city reads OSM data and creates buildings for use with FlightGear")
parser.add_argument("-f", "--file", dest="filename",
help="read parameters from FILE (e.g. params.ini)", metavar="FILE")
parser.add_argument("-e", dest="e", action="store_true", help="skip elevation interpolation")
parser.add_argument("-c", dest="c", action="store_true", help="do not check for overlapping with static objects")
parser.add_argument("-A", "--create-atlas-only", action="store_true", help="create texture atlas and exit")
parser.add_argument("-a", "--create-atlas", action="store_true", help="create texture atlas")
parser.add_argument("-u", dest="uninstall", action="store_true", help="uninstall ours from .stg")
parser.add_argument("-l", "--loglevel", help="set loglevel. Valid levels are VERBOSE, DEBUG, INFO, WARNING, ERROR, CRITICAL")
help="read parameters from FILE (e.g. params.ini)", metavar="FILE", required=True)
parser.add_argument("-e", dest="e", action="store_true"
, help="skip elevation interpolation", required=False)
parser.add_argument("-c", dest="c", action="store_true"
, help="do not check for overlapping with static objects", required=False)
parser.add_argument("-A", "--create-atlas-only", action="store_true"
, help="create texture atlas and exit", required=False)
parser.add_argument("-a", "--create-atlas", action="store_true"
, help="create texture atlas", required=False)
parser.add_argument("-u", dest="uninstall", action="store_true"
, help="uninstall ours from .stg", required=False)
parser.add_argument("-l", "--loglevel"
, help="set loglevel. Valid levels are VERBOSE, DEBUG, INFO, WARNING, ERROR, CRITICAL", required=False)
args = parser.parse_args()
# -- command line args override paramters
......@@ -1244,7 +1250,7 @@ if __name__ == "__main__":
# -- initialize STG_Manager
path_to_output = parameters.get_output_path()
replacement_prefix = re.sub('[\/]', '_', parameters.PREFIX)
replacement_prefix = parameters.get_repl_prefix()
stg_manager = stg_io2.STG_Manager(path_to_output, OUR_MAGIC, replacement_prefix, overwrite=True)
# for node in ac_nodes:
# print node
......@@ -1291,7 +1297,6 @@ if __name__ == "__main__":
#LOD_lists.append([]) # roof-flat
# -- incase PREFIX is a path (batch processing)
replacement_prefix = re.sub('[\/]', '_', parameters.PREFIX)
file_name = replacement_prefix + "city%02i%02i" % (cl.I.x, cl.I.y)
logging.info("writing cluster %s (%i/%i)" % (file_name, ic, len(clusters)))
......@@ -1326,6 +1331,3 @@ if __name__ == "__main__":
troubleshoot.troubleshoot(tools.stats)
logging.info("done.")
sys.exit(0)
# python -m cProfile -s time ./osm2city.py -f ULLL/params.ini -e -c
\ No newline at end of file
......@@ -181,8 +181,7 @@ def main():
# logging.info('Number of forest to process: %s', len(trees))
# # -- initialize STG_Manager
path_to_output = parameters.get_output_path()
replacement_prefix = re.sub('[\/]', '_', parameters.PREFIX)
stg_manager = stg_io2.STG_Manager(path_to_output, OUR_MAGIC, replacement_prefix, overwrite=True)
stg_manager = stg_io2.STG_Manager(path_to_output, OUR_MAGIC, parameters.get_repl_prefix(), overwrite=True)
#write_stg_entries(stg_manager, files_to_remove, trees, "trees", 2000)
for tree in trees.values() :
......
......@@ -505,8 +505,7 @@ class Line(LineWithoutCables):
, end_pylon.lon, end_pylon.lat)
angle_difference = angle_local - angle_global
# write stuff to files
replacement_prefix = re.sub('[\/]', '_', parameters.PREFIX)
cluster_filename = replacement_prefix + wayname + "%05d_%05d" % (line_index, cluster_index)
cluster_filename = parameters.get_repl_prefix() + wayname + "%05d_%05d" % (line_index, cluster_index)
path_to_stg = my_stg_mgr.add_object_static(cluster_filename + '.xml'
, vec2d.vec2d(start_pylon.lon, start_pylon.lat)
, start_pylon.elevation, 90 + angle_difference)
......@@ -1427,10 +1426,13 @@ def main():
parser = argparse.ArgumentParser(
description="osm2pylon reads OSM data and creates pylons, powerlines and aerialways for use with FlightGear")
parser.add_argument("-f", "--file", dest="filename",
help="read parameters from FILE (e.g. params.ini)", metavar="FILE")
parser.add_argument("-e", dest="e", action="store_true", help="skip elevation interpolation")
parser.add_argument("-u", dest="uninstall", action="store_true", help="uninstall ours from .stg")
parser.add_argument("-l", "--loglevel", help="Set loglevel. Valid levels are VERBOSE, DEBUG, INFO, WARNING, ERROR, CRITICAL")
help="read parameters from FILE (e.g. params.ini)", metavar="FILE", required=True)
parser.add_argument("-e", dest="e", action="store_true"
, help="skip elevation interpolation", required=False)
parser.add_argument("-u", dest="uninstall", action="store_true"
, help="uninstall ours from .stg", required=False)
parser.add_argument("-l", "--loglevel"
, help="Set loglevel. Valid levels are VERBOSE, DEBUG, INFO, WARNING, ERROR, CRITICAL", required=False)
args = parser.parse_args()
if args.filename is not None:
parameters.read_from_file(args.filename)
......@@ -1523,8 +1525,7 @@ def main():
# -- initialize STG_Manager
path_to_output = parameters.get_output_path()
replacement_prefix = re.sub('[\/]', '_', parameters.PREFIX)
stg_manager = stg_io2.STG_Manager(path_to_output, OUR_MAGIC, replacement_prefix, overwrite=True)
stg_manager = stg_io2.STG_Manager(path_to_output, OUR_MAGIC, parameters.get_repl_prefix(), overwrite=True)
# Write to Flightgear
if parameters.C2P_PROCESS_POWERLINES:
......
......@@ -16,6 +16,7 @@ Ludomotico contributed a cleaner version of read_from_file().
import argparse
import logging
import os
import re
import sys
import types
import traceback
......@@ -263,6 +264,11 @@ def get_OSM_file_name():
return PREFIX + os.sep + OSM_FILE
def get_repl_prefix():
"""FIXME: what does the REGEXP actually mean?"""
return re.sub('[\/]', '_', PREFIX)
def get_center_global():
cmin = v.vec2d(BOUNDARY_WEST, BOUNDARY_SOUTH)
cmax = v.vec2d(BOUNDARY_EAST, BOUNDARY_NORTH)
......
......@@ -341,10 +341,12 @@ def main():
import argparse
parser = argparse.ArgumentParser(description="Pier.py reads OSM data and creates Pier models for use with FlightGear")
parser.add_argument("-f", "--file", dest="filename",
help="read parameters from FILE (e.g. params.ini)", metavar="FILE")
help="read parameters from FILE (e.g. params.ini)", metavar="FILE", required=True)
# parser.add_argument("-e", dest="e", action="store_true", help="skip elevation interpolation")
# parser.add_argument("-c", dest="c", action="store_true", help="do not check for overlapping with static objects")
parser.add_argument("-l", "--loglevel", help="set loglevel. Valid levels are VERBOSE, DEBUG, INFO, WARNING, ERROR, CRITICAL")
parser.add_argument("-l", "--loglevel"
, help="set loglevel. Valid levels are VERBOSE, DEBUG, INFO, WARNING, ERROR, CRITICAL"
, required=False)
args = parser.parse_args()
if args.filename is not None:
......@@ -410,8 +412,7 @@ def main():
# -- initialize STG_Manager
path_to_output = parameters.get_output_path()
replacement_prefix = re.sub('[\/]', '_', parameters.PREFIX)
stg_manager = stg_io2.STG_Manager(path_to_output, OUR_MAGIC, replacement_prefix, overwrite=True)
stg_manager = stg_io2.STG_Manager(path_to_output, OUR_MAGIC, parameters.get_repl_prefix(), overwrite=True)
ac = piers.write(elev, stg_manager, path, center_global)
logging.info("done.")
......
......@@ -231,9 +231,11 @@ class Platforms(ObjectList):
def main():
import argparse
parser = argparse.ArgumentParser(description="platform.py reads OSM data and creates platform models for use with FlightGear")
parser.add_argument("-f", "--file", dest="filename",
help="read parameters from FILE (e.g. params.ini)", metavar="FILE")
parser.add_argument("-l", "--loglevel", help="set loglevel. Valid levels are VERBOSE, DEBUG, INFO, WARNING, ERROR, CRITICAL")
parser.add_argument("-f", "--file", dest="filename"
, help="read parameters from FILE (e.g. params.ini)", metavar="FILE", required=True)
parser.add_argument("-l", "--loglevel"
, help="set loglevel. Valid levels are VERBOSE, DEBUG, INFO, WARNING, ERROR, CRITICAL"
, required=False)
# parser.add_argument("-e", dest="e", action="store_true", help="skip elevation interpolation")
# parser.add_argument("-c", dest="c", action="store_true", help="do not check for overlapping with static objects")
args = parser.parse_args()
......@@ -302,8 +304,7 @@ def main():
# -- initialize STG_Manager
path_to_output = parameters.get_output_path()
replacement_prefix = re.sub('[\/]', '_', parameters.PREFIX)
stg_manager = stg_io2.STG_Manager(path_to_output, OUR_MAGIC, replacement_prefix, overwrite=True)
stg_manager = stg_io2.STG_Manager(path_to_output, OUR_MAGIC, parameters.get_repl_prefix(), overwrite=True)
ac = platforms.write(elev, stg_manager, path, center_global)
logging.info("done.")
......
......@@ -1084,10 +1084,13 @@ def main():
random.seed(42)
parser = argparse.ArgumentParser(description="bridge.py reads OSM data and creates bridge models for use with FlightGear")
parser.add_argument("-f", "--file", dest="filename",
help="read parameters from FILE (e.g. params.ini)", metavar="FILE")
parser.add_argument("-e", dest="e", action="store_true", help="skip elevation interpolation")
parser.add_argument("-b", "--bridges-only", action="store_true", help="create only bridges and embankments")
parser.add_argument("-l", "--loglevel", help="set loglevel. Valid levels are DEBUG, INFO, WARNING, ERROR, CRITICAL")
help="read parameters from FILE (e.g. params.ini)", metavar="FILE", required=True)
parser.add_argument("-e", dest="e", action="store_true"
, help="skip elevation interpolation", required=False)
parser.add_argument("-b", "--bridges-only", action="store_true"
, help="create only bridges and embankments", required=False)
parser.add_argument("-l", "--loglevel"
, help="set loglevel. Valid levels are DEBUG, INFO, WARNING, ERROR, CRITICAL", required=False)
args = parser.parse_args()
# -- command line args override parameters
......@@ -1119,7 +1122,7 @@ def main():
roads.process() # does the heavy lifting based on OSM data including clustering
replacement_prefix = re.sub('[\/]', '_', parameters.PREFIX)
replacement_prefix = parameters.get_repl_prefix()
stg_manager = stg_io2.STG_Manager(path_to_output, OUR_MAGIC, replacement_prefix, overwrite=True)
# roads.debug_label_nodes(stg_manager)
......
......@@ -53,6 +53,13 @@ def get_os_type():
return OSType.other
def is_linux_or_mac():
my_os_type = get_os_type()
if my_os_type is OSType.linux or my_os_type is OSType.mac:
return True
return False
def get_elev_in_path(home_path):
return home_path + "elev.in"
......@@ -76,7 +83,8 @@ if __name__ == '__main__':
parser = argparse.ArgumentParser(description="Setup will set some properties and copy the elev.nas")
parser.add_argument("-fg", "--fg_root", dest="fg_root",
help="$FG_ROOT see http://wiki.flightgear.org/$FG_ROOT. \
Typically '.../data' or '.../fgdata'.")
Typically '.../data' or '.../fgdata'."
, required=True)
args = parser.parse_args()
if args.fg_root is not None:
......
......@@ -831,8 +831,9 @@ if __name__ == "__main__":
parser = argparse.ArgumentParser(description="tools prepares an elevation grid for Nasal script and then osm2city")
parser.add_argument("-f", "--file", dest="filename",
help="read parameters from FILE (e.g. params.ini)", metavar="FILE")
parser.add_argument("-o", dest="o", action="store_true", help="do not overwrite existing elevation data")
help="read parameters from FILE (e.g. params.ini)", metavar="FILE", required=True)
parser.add_argument("-o", dest="o", action="store_true"
, help="do not overwrite existing elevation data", required=False)
args = parser.parse_args()
if args.filename is not None:
parameters.read_from_file(args.filename)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment