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

[FEAT] Integrate contour lines (elevation) into generated maps with argument -con #188

Merged
merged 31 commits into from
Apr 25, 2023
Merged
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
f0e470b
dev environment for countour lines
treee111 Mar 11, 2023
bfd81f2
Added contour lines py code
masc4ii Feb 18, 2023
fc5475c
Fix polygon lines
masc4ii Feb 19, 2023
70e1332
elevation: refactor, fix pylint findings
treee111 Mar 11, 2023
2a8ef8a
launch config for contour lines
treee111 Mar 16, 2023
1d387fc
correctly check if elevation file is already there in X/Y directory
treee111 Mar 17, 2023
1be92ae
refactor, separat user/pw
treee111 Mar 17, 2023
91122fa
add cli argument for contour lines
treee111 Mar 17, 2023
40f8289
handle FileNotFoundError in function instead of the caller level
treee111 Mar 17, 2023
e3f4ef8
save and read earthexplorer username & password from config file
treee111 Mar 17, 2023
b5df746
set Cache directory for hgt files to user dir instead of cwd
treee111 Mar 17, 2023
36bf409
move contour packages into conda env .yml files + delete separate con…
treee111 Mar 24, 2023
622b1d9
add contour lines to documentation
treee111 Mar 24, 2023
16c6a57
mention -con in USAGE.md and cleanup/restructure
treee111 Apr 1, 2023
0a87a9c
check for phyghtmap on macOS
treee111 Apr 1, 2023
e6a71e2
ask for -con on main.py level
treee111 Apr 1, 2023
5a6a16a
Bump version to v4.0.0a3
treee111 Apr 1, 2023
71143a3
Merge branch 'release-v4.0.0' into contour-lines
treee111 Apr 1, 2023
8c2e2e1
Bump version to v4.0.0a5
treee111 Apr 1, 2023
9a96cae
Merge branch 'release-v4.0.0' into contour-lines
treee111 Apr 2, 2023
03c3c19
Bump version to v4.0.0a8
treee111 Apr 2, 2023
77e0bba
update QUICKSTART documentation
treee111 Apr 2, 2023
de7ead4
make logging identical to other processing functions
treee111 Apr 3, 2023
b229f7f
launch config & documentation
treee111 Apr 3, 2023
f8513af
setup check can be equal for both OS
treee111 Apr 3, 2023
51f2589
Merge branch 'release-v4.0.0' into contour-lines
treee111 Apr 3, 2023
cad2743
Merge branch 'release-v4.0.0' into contour-lines
treee111 Apr 3, 2023
9e3ab34
update misc stuff (leftovers)
treee111 Apr 3, 2023
9aa5492
Bump version to v4.0.0a10
treee111 Apr 3, 2023
9a64f21
move earthexplorer credentials prompt to the beginning
treee111 Apr 25, 2023
e843caa
add GUI checkbox for contour lines
treee111 Apr 25, 2023
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
Prev Previous commit
Next Next commit
ask for -con on main.py level
treee111 committed Apr 1, 2023
commit e6a71e2f1ae27e4e5d9cb3e1a8e2413964bfd8dd
3 changes: 2 additions & 1 deletion wahoomc/main.py
Original file line number Diff line number Diff line change
@@ -77,7 +77,8 @@ def run(run_level):
o_osm_maps.generate_sea()

# Generate elevation
o_osm_maps.generate_elevation(o_input_data)
if o_input_data.contour:
o_osm_maps.generate_elevation()

# Split filtered country files to tiles
o_osm_maps.split_filtered_country_files_to_tiles()
74 changes: 36 additions & 38 deletions wahoomc/osm_maps_functions.py
Original file line number Diff line number Diff line change
@@ -477,49 +477,47 @@ def generate_sea(self):

log.info('+ Generate sea for each coordinate: OK')

def generate_elevation(self, o_input_data):
def generate_elevation(self):
"""
Generate contour lines for all tiles
"""
if o_input_data.contour:

username, password = read_earthexplorer_credentials()

if not username or not password:
username, password = ask_for_and_write_earthexplorer_credentials()

log.info('-' * 80)
log.info('# Generate contour lines for each coordinate')

hgt_path = os.path.join(USER_DL_DIR, 'hgt')

tile_count = 1
for tile in self.o_osm_data.tiles:
out_file_elevation = os.path.join(
USER_OUTPUT_DIR, f'{tile["x"]}', f'{tile["y"]}', 'elevation')
# as the elevation file has a suffix, they need to be searched with glob.glob
# example elevation filename: elevation_lon14.06_15.47lat35.46_36.60_view1,view3.osm
out_file_elevation_existing = glob.glob(os.path.join(
USER_OUTPUT_DIR, str(tile["x"]), str(tile["y"]), 'elevation*.osm'))
# check for already existing .osm file
if not (len(out_file_elevation_existing) == 1 and os.path.isfile(out_file_elevation_existing[0])) \
or self.o_osm_data.force_processing is True:
print(
f'# Generate elevation {tile_count} for coordinates: {tile["x"]} {tile["y"]}')
cmd = ['phyghtmap']
cmd.append('-a ' + f'{tile["left"]}' + ':' + f'{tile["bottom"]}' +
':' + f'{tile["right"]}' + ':' + f'{tile["top"]}')
cmd.extend(['-o', f'{out_file_elevation}', '-s 10', '-c 100,50', '--source=view1,view3,srtm3',
'--jobs=8', '--viewfinder-mask=1', '--start-node-id=20000000000',
'--max-nodes-per-tile=0', '--start-way-id=2000000000', '--write-timestamp',
'--no-zero-contour', '--hgtdir=' + hgt_path])
cmd.append('--earthexplorer-user=' + username)
cmd.append('--earthexplorer-password=' + password)
username, password = read_earthexplorer_credentials()

run_subprocess_and_log_output(
cmd, f'! Error in phyghtmap with tile: {tile["x"]},{tile["y"]}. Win/out_file')
if not username or not password:
username, password = ask_for_and_write_earthexplorer_credentials()

log.info('-' * 80)
log.info('# Generate contour lines for each coordinate')

hgt_path = os.path.join(USER_DL_DIR, 'hgt')

tile_count = 1
for tile in self.o_osm_data.tiles:
out_file_elevation = os.path.join(
USER_OUTPUT_DIR, f'{tile["x"]}', f'{tile["y"]}', 'elevation')
# as the elevation file has a suffix, they need to be searched with glob.glob
# example elevation filename: elevation_lon14.06_15.47lat35.46_36.60_view1,view3.osm
out_file_elevation_existing = glob.glob(os.path.join(
USER_OUTPUT_DIR, str(tile["x"]), str(tile["y"]), 'elevation*.osm'))
# check for already existing .osm file
if not (len(out_file_elevation_existing) == 1 and os.path.isfile(out_file_elevation_existing[0])) \
or self.o_osm_data.force_processing is True:
print(
f'# Generate elevation {tile_count} for coordinates: {tile["x"]} {tile["y"]}')
cmd = ['phyghtmap']
cmd.append('-a ' + f'{tile["left"]}' + ':' + f'{tile["bottom"]}' +
':' + f'{tile["right"]}' + ':' + f'{tile["top"]}')
cmd.extend(['-o', f'{out_file_elevation}', '-s 10', '-c 100,50', '--source=view1,view3,srtm3',
'--jobs=8', '--viewfinder-mask=1', '--start-node-id=20000000000',
'--max-nodes-per-tile=0', '--start-way-id=2000000000', '--write-timestamp',
'--no-zero-contour', '--hgtdir=' + hgt_path])
cmd.append('--earthexplorer-user=' + username)
cmd.append('--earthexplorer-password=' + password)

run_subprocess_and_log_output(
cmd, f'! Error in phyghtmap with tile: {tile["x"]},{tile["y"]}. Win/out_file')

log.info('+ Generate contour lines for each coordinate: OK')
log.info('+ Generate contour lines for each coordinate: OK')

def split_filtered_country_files_to_tiles(self):
"""