Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BREAKING] Remove primary CLI input option -fi, that is giving a json-file with tile(s). It is replaced by #99 #105

Merged
merged 2 commits into from
Apr 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 7 additions & 48 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,15 @@
"version": "0.2.0",
"configurations": [
{
"name": "only1-tile",
"name": "x/y: 134/88 (STG)",
"type": "python",
"request": "launch",
"program": "${workspaceRoot}/wahoo_map_creator.py",
"console": "integratedTerminal",
"args": [
"cli",
"-fi",
"${workspaceRoot}/tests/json/germany-only1.json",
"-md",
"100",
"-fp",
"-c",
"-om"
]
},
{
"name": "only1-tag-hidrive2",
"type": "python",
"request": "launch",
"program": "${workspaceRoot}/wahoo_map_creator.py",
"console": "integratedTerminal",
"args": [
"cli",
"-fi",
"${workspaceRoot}/tests/json/germany-only1.json",
"-tag",
"tag-wahoo-hidrive2.xml",
"-xy",
"134/88",
"-md",
"100",
"-fp",
Expand All @@ -38,15 +19,15 @@
]
},
{
"name": "only2-tile",
"name": "x/y: 134/88,134/87 (STG+HN)",
"type": "python",
"request": "launch",
"program": "${workspaceRoot}/wahoo_map_creator.py",
"console": "integratedTerminal",
"args": [
"cli",
"-fi",
"${workspaceRoot}/tests/json/germany-only2.json",
"-xy",
"134/88,134/87",
"-md",
"100",
"-fp",
Expand Down Expand Up @@ -160,29 +141,7 @@
]
},
{
"name": "old shape2osm",
"type": "python",
"request": "launch",
"program": "${workspaceRoot}/tooling/shape2osm.py",
"console": "integratedTerminal",
"args": [
"C:\\VSCode\\python\\wahooMapsCreator\\output\\138\\100\\land.shp",
"C:\\VSCode\\python\\wahooMapsCreator\\output\\138\\100\\land1.osm"
]
},
{
"name": "new shape2osm",
"type": "python",
"request": "launch",
"program": "${workspaceRoot}/tooling/shape2osm/shape2osm.py",
"console": "integratedTerminal",
"args": [
"C:\\VSCode\\python\\wahooMapsCreator\\output\\138\\100\\land.shp",
"C:\\VSCode\\python\\wahooMapsCreator\\output\\138\\100\\land1.osm"
]
},
{
"name": "x/y: 133/88",
"name": "x/y: 133/88 (germany&france)",
"type": "python",
"request": "launch",
"program": "${workspaceRoot}/wahoo_map_creator.py",
Expand Down
7 changes: 1 addition & 6 deletions common_python/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@ def process_call_of_the_tool():
# X/Y coordinates to create maps for
primary_args_excl.add_argument(
"-xy", "--xy_coordinates", help="x/y coordinates to generate maps for. Example: 133/88")
# file to create maps for
primary_args_excl.add_argument(
"-fi", "--tile_file", help="file with tiles to generate maps for")

# group: options for map generation
options_args = parser_cli.add_argument_group(
Expand Down Expand Up @@ -103,7 +100,6 @@ def process_call_of_the_tool():
o_input_data = InputData()
o_input_data.country = args.country
o_input_data.xy_coordinates = args.xy_coordinates
o_input_data.tile_file = args.tile_file
o_input_data.max_days_old = args.maxdays

o_input_data.border_countries = args.bordercountries
Expand Down Expand Up @@ -146,7 +142,6 @@ class InputData():
def __init__(self):
self.country = ""
self.xy_coordinates = ""
self.tile_file = ""
self.max_days_old = 14

self.force_download = False
Expand Down Expand Up @@ -174,7 +169,7 @@ def is_required_input_given_or_exit(self, issue_message):
- file with tile coordinates
If not, depending on the import parameter, the
"""
if (self.country in ('None', '') and self.xy_coordinates in ('None', '') and self.tile_file in ('None', '')):
if (self.country in ('None', '') and self.xy_coordinates in ('None', '')):
if issue_message:
sys.exit("Nothing to do. Start with -h or --help to see command line options."
"Or in the GUI select a country to create maps for.")
Expand Down
31 changes: 11 additions & 20 deletions common_python/osm_maps_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,32 +122,23 @@ def process_input(self, calc_border_countries):

log.info('-' * 80)

# option 1: have a .json file as input parameter
if self.o_input_data.tile_file:
log.info('# Input json file: %s.', self.o_input_data.tile_file)
if self.o_input_data.country and self.o_input_data.xy_coordinates:
log.error(
"! country and X/Y coordinates are given. Only one of both is allowed!")
sys.exit()

if os.path.isfile(self.o_input_data.tile_file):
self.tiles = fd_fct.read_json_file(self.o_input_data.tile_file)

# country name is the last part of the input filename
self.country_name = os.path.split(
self.o_input_data.tile_file)[1][:-5]

# calc border country when input tiles via json file
calc_border_countries = True

# option 2: input a country as parameter, e.g. germany
elif self.o_input_data.country:
# option 1: input a country as parameter, e.g. germany
if self.o_input_data.country:
log.info('# Input country: %s.', self.o_input_data.country)

# option 2a: use Geofabrik-URL to calculate the relevant tiles
# option 1a: use Geofabrik-URL to calculate the relevant tiles
if self.o_input_data.geofabrik_tiles:
self.force_processing = self.o_downloader.check_and_download_geofabrik_if_needed()

o_geofabrik = Geofabrik(self.o_input_data.country)
self.tiles = o_geofabrik.get_tiles_of_country()

# option 2b: use static json files in the repo to calculate relevant tiles
# option 1b: use static json files in the repo to calculate relevant tiles
else:
json_file_path = os.path.join(fd_fct.COMMON_DIR, 'json',
const_fct.get_region_of_country(self.o_input_data.country), self.o_input_data.country + '.json')
Expand All @@ -156,16 +147,16 @@ def process_input(self, calc_border_countries):
# country name is the input argument
self.country_name = self.o_input_data.country

# option 3: input a x/y combinations as parameter, e.g. 134/88 or 133/88,130/100
# option 2: input a x/y combinations as parameter, e.g. 134/88 or 133/88,130/100
elif self.o_input_data.xy_coordinates:
log.info(
'# Input X/Y coordinates: %s.', self.o_input_data.xy_coordinates)

# # option 3a: use Geofabrik-URL to get the relevant tiles
# option 2a: use Geofabrik-URL to get the relevant tiles
if self.o_input_data.geofabrik_tiles:
sys.exit("X/Y coordinated via Geofabrik not implemented now")

# option 3b: use static json files in the repo to get relevant tiles
# option 2b: use static json files in the repo to get relevant tiles
else:
xy_coordinates = get_xy_coordinates_from_input(
self.o_input_data.xy_coordinates)
Expand Down
14 changes: 0 additions & 14 deletions tests/json/germany-france-only1.json

This file was deleted.

13 changes: 0 additions & 13 deletions tests/json/germany-koblenz.json

This file was deleted.

13 changes: 0 additions & 13 deletions tests/json/germany-only1.json

This file was deleted.

24 changes: 0 additions & 24 deletions tests/json/germany-only2.json

This file was deleted.

109 changes: 0 additions & 109 deletions tests/json/germany-only9.json

This file was deleted.

Loading