Skip to content

Commit

Permalink
r.in.usgs: move functions to top level to fix python pickling on wind…
Browse files Browse the repository at this point in the history
…ows (#256)

Should fix #254.
  • Loading branch information
petrasovaa committed Jul 17, 2020
1 parent e60177a commit 7b57893
Showing 1 changed file with 35 additions and 33 deletions.
68 changes: 35 additions & 33 deletions grass7/raster/r.in.usgs/r.in.usgs.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,41 @@ def map_exists(element, name, mapset):
return False


def run_file_import(identifier, results,
input, output, resolution,
resolution_value, extent, resample, memory):
result = {}
try:
gscript.run_command('r.import', input=input, output=output,
resolution=resolution,
resolution_value=resolution_value,
extent=extent, resample=resample,
memory=memory)
except CalledModuleError:
error = ("Unable to import <{0}>").format(output)
result["errors"] = error
else:
result["output"] = output
results[identifier] = result


def run_lidar_import(identifier, results,
input, output, input_srs=None):
result = {}
params = {}
if input_srs:
params['input_srs'] = input_srs
try:
gscript.run_command('v.in.pdal', input=input, output=output,
flags='wr', **params)
except CalledModuleError:
error = ("Unable to import <{0}>").format(output)
result["errors"] = error
else:
result["output"] = output
results[identifier] = result


def main():
# Hard-coded parameters needed for USGS datasets
usgs_product_dict = {
Expand Down Expand Up @@ -733,39 +768,6 @@ def exist_list():
mapset = get_current_mapset()
files_to_import = len(local_tile_path_list)

def run_file_import(identifier, results,
input, output, resolution,
resolution_value, extent, resample, memory):
result = {}
try:
gscript.run_command('r.import', input=input, output=output,
resolution=resolution,
resolution_value=resolution_value,
extent=extent, resample=resample,
memory=memory)
except CalledModuleError:
error = ("Unable to import <{0}>").format(output)
result["errors"] = error
else:
result["output"] = output
results[identifier] = result

def run_lidar_import(identifier, results,
input, output, input_srs=None):
result = {}
params = {}
if input_srs:
params['input_srs'] = input_srs
try:
gscript.run_command('v.in.pdal', input=input, output=output,
flags='wr', **params)
except CalledModuleError:
error = ("Unable to import <{0}>").format(output)
result["errors"] = error
else:
result["output"] = output
results[identifier] = result

process_list = []
process_id_list = []
process_count = 0
Expand Down

0 comments on commit 7b57893

Please sign in to comment.