From eff9058f8d7a39eb6e5a6a8f327915cada6d9d2d Mon Sep 17 00:00:00 2001 From: Tomas Zigo Date: Wed, 27 Sep 2023 13:05:48 +0200 Subject: [PATCH] r.in.wms: fix get region extent for WMS query, if location is 'XY location (unprojected)' --- scripts/m.proj/m.proj.py | 2 +- scripts/r.in.wms/wms_base.py | 22 +++++++++++++--------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/scripts/m.proj/m.proj.py b/scripts/m.proj/m.proj.py index 3aeafcc2cbf..6c5c2c0eed7 100755 --- a/scripts/m.proj/m.proj.py +++ b/scripts/m.proj/m.proj.py @@ -163,7 +163,7 @@ def main(): # set up projection params s = gcore.read_command("g.proj", flags="j") kv = parse_key_val(s) - if "XY location" in kv["+proj"] and (ll_in or ll_out): + if "XY location" in kv: gcore.fatal(_("Unable to project to or from a XY location")) in_proj = None diff --git a/scripts/r.in.wms/wms_base.py b/scripts/r.in.wms/wms_base.py index 56158635d53..cf2a9c1c38f 100644 --- a/scripts/r.in.wms/wms_base.py +++ b/scripts/r.in.wms/wms_base.py @@ -350,16 +350,20 @@ def _computeBbox(self): grass.fatal(_("Unable to write data into tempfile")) finally: temp_region_opened.close() + try: + points = grass.read_command( + "m.proj", + flags="d", + proj_out=self.proj_srs, + proj_in=self.proj_location, + input=temp_region, + quiet=True, + ) # TODO: stdin + except CalledModuleError: + points = None + finally: + grass.try_remove(temp_region) - points = grass.read_command( - "m.proj", - flags="d", - proj_out=self.proj_srs, - proj_in=self.proj_location, - input=temp_region, - quiet=True, - ) # TODO: stdin - grass.try_remove(temp_region) if not points: grass.fatal(_("Unable to determine region, %s failed") % "m.proj")