Skip to content

Commit

Permalink
adjust merging with land and sea processing based on discussion in PR
Browse files Browse the repository at this point in the history
  • Loading branch information
treee111 committed Sep 29, 2022
1 parent c5515de commit 57affb6
Showing 1 changed file with 47 additions and 47 deletions.
94 changes: 47 additions & 47 deletions wahoomc/osm_maps_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -604,60 +604,60 @@ def merge_splitted_tiles_with_land_and_sea(self, process_border_countries):

land_files = glob.glob(os.path.join(out_tile_dir, 'land*.osm'))

if not os.path.isfile(out_file) or self.o_osm_data.force_processing is True:
# sort land* osm files
self.sort_osm_files(tile)
# merge splitted tiles with land and sea every time because the result is different per constants
# sort land* osm files
self.sort_osm_files(tile)

# Windows
if platform.system() == "Windows":
cmd = [self.osmosis_win_file_path]
loop = 0
# loop through all countries of tile, if border-countries should be processed.
# if border-countries should not be processed, only process the "entered" country
for country in tile['countries']:
if process_border_countries or country in self.o_osm_data.border_countries:
cmd.append('--rbf')
cmd.append(os.path.join(
out_tile_dir, f'split-{country}.osm.pbf'))
cmd.append('workers=' + self.workers)
if loop > 0:
cmd.append('--merge')

cmd.append('--rbf')
cmd.append(os.path.join(
out_tile_dir, f'split-{country}-names.osm.pbf'))
cmd.append('workers=' + self.workers)
# Windows
if platform.system() == "Windows":
cmd = [self.osmosis_win_file_path]
loop = 0
# loop through all countries of tile, if border-countries should be processed.
# if border-countries should not be processed, only process the "entered" country
for country in tile['countries']:
if process_border_countries or country in self.o_osm_data.border_countries:
cmd.append('--rbf')
cmd.append(os.path.join(
out_tile_dir, f'split-{country}.osm.pbf'))
cmd.append('workers=' + self.workers)
if loop > 0:
cmd.append('--merge')

loop += 1
cmd.append('--rbf')
cmd.append(os.path.join(
out_tile_dir, f'split-{country}-names.osm.pbf'))
cmd.append('workers=' + self.workers)
cmd.append('--merge')

for land in land_files:
cmd.extend(
['--rx', 'file='+os.path.join(out_tile_dir, f'{land}'), '--s', '--m'])
loop += 1

for land in land_files:
cmd.extend(
['--rx', 'file='+os.path.join(out_tile_dir, 'sea.osm'), '--s', '--m'])
cmd.extend(['--tag-transform', 'file=' + os.path.join(RESOURCES_DIR,
'tunnel-transform.xml'), '--wb', out_file, 'omitmetadata=true'])
['--rx', 'file='+os.path.join(out_tile_dir, f'{land}'), '--s', '--m'])
cmd.extend(
['--rx', 'file='+os.path.join(out_tile_dir, 'sea.osm'), '--s', '--m'])
cmd.extend(['--tag-transform', 'file=' + os.path.join(RESOURCES_DIR,
'tunnel-transform.xml'), '--wb', out_file, 'omitmetadata=true'])

# Non-Windows
else:
cmd = ['osmium', 'merge', '--overwrite']
# loop through all countries of tile, if border-countries should be processed.
# if border-countries should not be processed, only process the "entered" country
for country in tile['countries']:
if process_border_countries or country in self.o_osm_data.border_countries:
cmd.append(os.path.join(
out_tile_dir, f'split-{country}.osm.pbf'))
cmd.append(os.path.join(
out_tile_dir, f'split-{country}-names.osm.pbf'))

for land in land_files:
cmd.append(land)
cmd.append(os.path.join(out_tile_dir, 'sea.osm'))
cmd.extend(['-o', out_file])
# Non-Windows
else:
cmd = ['osmium', 'merge', '--overwrite']
# loop through all countries of tile, if border-countries should be processed.
# if border-countries should not be processed, only process the "entered" country
for country in tile['countries']:
if process_border_countries or country in self.o_osm_data.border_countries:
cmd.append(os.path.join(
out_tile_dir, f'split-{country}.osm.pbf'))
cmd.append(os.path.join(
out_tile_dir, f'split-{country}-names.osm.pbf'))

for land in land_files:
cmd.append(land)
cmd.append(os.path.join(out_tile_dir, 'sea.osm'))
cmd.extend(['-o', out_file])

run_subprocess_and_log_output(
cmd, f'! Error in Osmosis with tile: {tile["x"]},{tile["y"]}')
run_subprocess_and_log_output(
cmd, f'! Error in Osmosis with tile: {tile["x"]},{tile["y"]}')

tile_count += 1

Expand Down

0 comments on commit 57affb6

Please sign in to comment.