Skip to content

Commit

Permalink
Fixed problems with download types "all available" and "catalonia"
Browse files Browse the repository at this point in the history
  • Loading branch information
icgcaadell committed May 23, 2023
1 parent 89d4963 commit 4fef6db
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 15 deletions.
7 changes: 5 additions & 2 deletions metadata.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,11 @@ [email protected]

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
Expand Down
31 changes: 20 additions & 11 deletions openicgc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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")

Expand Down
4 changes: 2 additions & 2 deletions resources3/fme.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 4fef6db

Please sign in to comment.