From 4fef6dbf5fc2c90c84e73beba8e38529403a5356 Mon Sep 17 00:00:00 2001 From: "a.adell" Date: Tue, 23 May 2023 12:14:37 +0200 Subject: [PATCH] Fixed problems with download types "all available" and "catalonia" --- metadata.txt | 7 +++++-- openicgc.py | 31 ++++++++++++++++++++----------- resources3/fme.py | 4 ++-- 3 files changed, 27 insertions(+), 15 deletions(-) diff --git a/metadata.txt b/metadata.txt index 5824188..eb3a0f9 100644 --- a/metadata.txt +++ b/metadata.txt @@ -28,8 +28,11 @@ email=qgis.openicgc@icgc.cat qgisMinimumVersion=2.99 qgisMaximumVersion=3.99 -version=1.1.13 -changelog=v1.1.13 (2023-04-18) +version=1.1.14 +changelog=v1.1.14 (2023-05-23) + - Fixed problems with download types "all available" and "catalonia" + + v1.1.13 (2023-04-18) - Added FiraSans font to symbolization - Fixed problems with selection in photograms dialog based on geojson query with regional settings not in english - Fixed problems loading Catalonia limit geojsons with regional settings not in english diff --git a/openicgc.py b/openicgc.py index f075183..6618208 100644 --- a/openicgc.py +++ b/openicgc.py @@ -1159,7 +1159,14 @@ def pair_photo_search_checks(self, status): def run(self, _checked=False): # I add checked param, because the mapping of the signal triggered passes a parameter """ Basic plugin call, which reads the text of the combobox and the search for the different web services available """ - self.find(self.combobox.currentText()) + search_text = self.combobox.currentText() + self.find(search_text) + # Set search text on top of combobox + pos = self.combobox.findText(search_text) + if pos != 0: + self.combobox.removeItem(pos) + self.combobox.insertItem(0, search_text) + self.combobox.setCurrentIndex(0) # Save last searches in persistent app settings searches_list = [self.combobox.itemText(i) for i in range(self.combobox.count())][:self.combobox.maxVisibleItems()] self.set_setting_value("last_searches", searches_list) @@ -1398,9 +1405,10 @@ def download_map_area(self, geo, data_type, min_side, max_download_area, min_px_ filename = "%s_%s" % (os.path.splitext(filename)[0], time_code) # Get download geometry - geo = self.download_get_geometry(geo, download_epsg, min_side, max_download_area, min_px_side, max_px_area, gsd, limits) - if not geo: - return + if self.download_type not in ["dt_cat", "dt_all"]: + geo = self.download_get_geometry(geo, download_epsg, min_side, max_download_area, min_px_side, max_px_area, gsd, limits) + if not geo: + return is_polygon = (type(geo) == QgsGeometry) is_area = (type(geo) == QgsRectangle and not geo.isEmpty()) title = self.tr("Download map area") if is_area or is_polygon else self.tr("Download point") @@ -1440,7 +1448,7 @@ def download_map_area(self, geo, data_type, min_side, max_download_area, min_px_ self.log.debug("Download filename: %s", local_filename) # Get URL with FME action - west, south, east, north = (geo.xMinimum(), geo.yMinimum(), geo.xMaximum(), geo.yMaximum()) if not is_polygon else (None, None, None, None) + west, south, east, north = (geo.xMinimum(), geo.yMinimum(), geo.xMaximum(), geo.yMaximum()) if geo and not is_polygon else (None, None, None, None) points_list = [(vertex.x(), vertex.y()) for vertex in geo.vertices()] if is_polygon else [] referrer = "%s_v%s" % (self.metadata.get_name().replace(" ", ""), self.metadata.get_version()) url = get_clip_data_url(data_type, download_operation_code, west, south, east, north, points_list, extra_params, referrer=referrer) @@ -1579,12 +1587,13 @@ def download_get_geometry(self, geo, download_epsg, min_side, max_download_area, epsg = int(self.project.get_epsg()) self.log.debug("Use project EPSG for geometry: %s", epsg) # Check CS and transform - if epsg == download_epsg: - self.log.debug("Download geometry %s (EPSG:%s)", geo.asWkt() if is_polygon else geo.asWktCoordinates(), download_epsg) - else: - self.log.debug("User geometry %s (EPSG:%s)", geo.asWkt() if is_polygon else geo.asWktCoordinates(), epsg) - geo = self.crs.transform(geo, epsg, download_epsg) - self.log.debug("Download (transformed) geometry %s (EPSG:%s)", geo.asWkt() if is_polygon else geo.asWktCoordinates(), download_epsg) + if geo: + if epsg == download_epsg: + self.log.debug("Download geometry %s (EPSG:%s)", geo.asWkt() if is_polygon else geo.asWktCoordinates(), download_epsg) + else: + self.log.debug("User geometry %s (EPSG:%s)", geo.asWkt() if is_polygon else geo.asWktCoordinates(), epsg) + geo = self.crs.transform(geo, epsg, download_epsg) + self.log.debug("Download (transformed) geometry %s (EPSG:%s)", geo.asWkt() if is_polygon else geo.asWktCoordinates(), download_epsg) title = self.tr("Download map area") if is_area or is_polygon else self.tr("Download point") diff --git a/resources3/fme.py b/resources3/fme.py index 755fc00..4f25e6e 100644 --- a/resources3/fme.py +++ b/resources3/fme.py @@ -249,8 +249,8 @@ def get_services(): def get_clip_data_url(data_type, mode, xmin, ymin, xmax, ymax, points_list=[], extra_params=[], referrer=None, url_base=FME_URL): """ Retorna la peticiĆ³ URL FME per descarregar un producte """ _name, _min_side, _max_query_area, _min_px_side, _max_px_area, _gsd, _time_list, download_list, _filename, _limits, url_pattern, _url_ref_or_wms_tuple = services_dict.get(data_type, (None, None, None, None, None, None, None, None, None, None, None, None)) - rect_list = [("%.2f" % v if v is not None else "") for v in [xmin, ymin, xmax, ymax]] - points_list = [",".join(["%.2f %.2f" % (x, y) for x, y in points_list])] if "pol" in download_list else [None] + rect_list = [("%.2f" % v if v is not None else "0") for v in [xmin, ymin, xmax, ymax]] + points_list = [",".join(["%.2f %.2f" % (x, y) for x, y in points_list])] if "pol" in download_list else [""] values_list = [url_base] + rect_list + points_list + [mode] + extra_params url = (url_pattern % tuple(values_list)) if url_pattern else None if url and referrer: