From 5dec06277e22ff050bc978adb7095cd597c85d35 Mon Sep 17 00:00:00 2001 From: mauro Date: Sun, 19 Aug 2018 11:48:57 +0200 Subject: [PATCH] Vers. 0.4.2 RC 1 --- config/settings.py | 3 +++ gis_utils/profile.py | 1 + qProf_QWidget.py | 23 +++++++++++++++++++++-- qProf_main.py | 14 ++++++++++++++ 4 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 config/settings.py diff --git a/config/settings.py b/config/settings.py new file mode 100644 index 0000000..1dc7074 --- /dev/null +++ b/config/settings.py @@ -0,0 +1,3 @@ + + +pt_num_threshold = 10000 \ No newline at end of file diff --git a/gis_utils/profile.py b/gis_utils/profile.py index a8dbf89..342742d 100644 --- a/gis_utils/profile.py +++ b/gis_utils/profile.py @@ -267,6 +267,7 @@ def topoline_from_dem(resampled_trace2d, bOnTheFlyProjection, project_crs, dem, def topoprofiles_from_dems(canvas, source_profile_line, sample_distance, selected_dems, selected_dem_parameters, invert_profile): + # get project CRS information on_the_fly_projection, project_crs = get_on_the_fly_projection(canvas) diff --git a/qProf_QWidget.py b/qProf_QWidget.py index 088e50e..b5ab187 100644 --- a/qProf_QWidget.py +++ b/qProf_QWidget.py @@ -29,6 +29,7 @@ from .string_utils.utils_string import clean_string +from .config.settings import * from .config.output import dem_header_common, dem_single_dem_header, gpx_header from .qProf_plotting import plot_geoprofiles @@ -69,7 +70,6 @@ def __init__(self, plugin_name, canvas): self.profile_windows = [] # used to maintain alive the plots, i.e. to avoid the C++ objects being destroyed self.plane_attitudes_colors = [] - #self.curve_colors = [] self.setup_gui() @@ -207,6 +207,25 @@ def stop_rubberband(): if topo_source_type == self.demline_source: # sources are DEM(s) and line + # check total number of points in line(s) to create + estimated_total_num_pts = 0 + for profile_line in source_profile_lines: + + profile_length = profile_line.length_2d + profile_num_pts = profile_length / sample_distance + estimated_total_num_pts += profile_num_pts + + estimated_total_num_pts = int(ceil(estimated_total_num_pts)) + + if estimated_total_num_pts > pt_num_threshold: + warn( + parent=self, + header=self.plugin_name, + msg="There are {} estimated points (limit is {}) in profile(s) to create.".format(estimated_total_num_pts, pt_num_threshold) + + "\nPlease increase sample distance value" + ) + return + for profile_line in source_profile_lines: try: @@ -265,7 +284,7 @@ def stop_rubberband(): else: # source error error(self, self.plugin_name, - "Algorithm error: profile calculation not defined") + "Debug: profile calculation not defined") return info(self, diff --git a/qProf_main.py b/qProf_main.py index 2dd7b8c..3e36e7e 100644 --- a/qProf_main.py +++ b/qProf_main.py @@ -3,13 +3,18 @@ import os import webbrowser +from qgis.core import * + from qgis.PyQt.QtCore import * from qgis.PyQt.QtGui import * from qgis.PyQt.QtWidgets import * from . import resources + +from .qt_utils.tools import info, warn, error, update_ComboBox from .qgis_utils.utils import create_action + from .qProf_QWidget import qprof_QWidget _plugin_name_ = "qProf" @@ -45,6 +50,15 @@ def unload(self): def open_qprof(self): + project = QgsProject.instance() + + if project.count() == 0: + warn( + parent=None, + header=_plugin_name_, + msg="No project/layer available.\nPlease open project and add layers.") + return + qprof_DockWidget = QDockWidget(self.plugin_name, self.interface.mainWindow()) qprof_DockWidget.setAttribute(Qt.WA_DeleteOnClose)