Skip to content

Commit

Permalink
0.4
Browse files Browse the repository at this point in the history
0.4
  • Loading branch information
fzahner authored Jun 28, 2022
2 parents 451dd96 + 5600169 commit 43d65d9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion metadata.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
name=Raster Cutter
qgisMinimumVersion=3.0
description=Export a raster layer as an image. Select extent, reproject, create Worldfile or Lexocad sidecar files.
version=0.3
version=0.4
author=IFS Institute for Software
email=feedback.ifs@ost.ch

Expand Down
24 changes: 14 additions & 10 deletions raster_cutter.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ def run(self):
src=src,
iface=self.iface,
directory_url=directory_url,
src_srs=get_source_projection(self).authid(),
dest_srs=get_target_projection(self).authid(),
format_string=format_string,
options_string=options_string,
Expand Down Expand Up @@ -349,6 +350,8 @@ def select_current_layer(self):
def get_target_projection(self):
return self.dlg.proj_selection.crs()

def get_source_projection(self):
return self.dlg.extent_box.outputCrs()

# returns extent window as a string for use in gdal
def get_extent_win(self):
Expand All @@ -366,12 +369,12 @@ def get_resampling_method(self):


# this is where all calculations actually happen
def process(task, src, iface, directory_url, dest_srs, format_string, extent_win_string, options_string,
def process(task, src, iface, directory_url, src_srs, dest_srs, format_string, extent_win_string, options_string,
generate_lexocad: bool,
add_to_map: bool, target_resolution: {"x": float, "y": float}, resampling_method):
# Crop raster, so that only the needed parts are reprojected, saving processing time
QgsMessageLog.logMessage('Cropping raster (possibly downloading)...', MESSAGE_CATEGORY, Qgis.Info)
cropped = crop('/vsimem/cropped.tif', src, extent_win_string, dest_srs, resampling_method)
cropped = crop('/vsimem/cropped.tif', src, extent_win_string, src_srs, resampling_method)
if task.isCanceled(): # check if task was cancelled between each step
stopped(task)
return None
Expand Down Expand Up @@ -524,14 +527,15 @@ def generate_lexocad_files(directoryUrl):
xMinimum = float(lines[4])
yMinimum = float(lines[5]) - height
with open(directoryUrl + "l", 'w') as f:
f.write(f"{str(xMinimum)}"
f"{str(yMinimum)}"
f"str(float(width))"
f"str(float(height))"
f"# cadwork swisstopo"
f"# {str(xMinimum)} {str(yMinimum)}"
f"# {str(width)} {str(height)}"
f"# projection: EPSG:2056 - CH1903+ / LV95"
f.write(f"{round(xMinimum)} \n"
f"{round(yMinimum)} \n"
f"{round(float(width))} \n"
f"{round(float(height))} \n"
f"\n"
f"# cadwork swisstopo \n"
f"# {round(xMinimum)} {round(yMinimum)} \n"
f"# {round(width)} {round(height)} \n"
f"# projection: EPSG:2056 - CH1903+ / LV95 \n"
)


Expand Down

0 comments on commit 43d65d9

Please sign in to comment.