From 3f4f05f6391be941cef190a0eaf027a0179d736b Mon Sep 17 00:00:00 2001 From: Piero Toffanin Date: Thu, 17 Sep 2020 14:03:17 +0000 Subject: [PATCH] Fixed locale complaints from GRASS --- opendm/grass/compute_cutline.grass | 2 +- opendm/grass_engine.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/opendm/grass/compute_cutline.grass b/opendm/grass/compute_cutline.grass index 299411c9..2a062ef2 100644 --- a/opendm/grass/compute_cutline.grass +++ b/opendm/grass/compute_cutline.grass @@ -23,7 +23,7 @@ i.cutlinesmod.py --overwrite input=ortho output=cutline number_lines=${number_li v.select ainput=cutline binput=crop_area output=result operator=within # Export -v.out.ogr input=result output="result.gpkg" format=GPKG +v.out.ogr input=result output="result.gpkg" format=GPKG --overwrite # Merge all geometries, select only the largest one (remove islands) ogr2ogr -f GPKG -overwrite -explodecollections -dialect SQLite -sql "SELECT ST_Union(geom) FROM result ORDER BY ST_AREA(geom) DESC LIMIT 1" cutline.gpkg result.gpkg diff --git a/opendm/grass_engine.py b/opendm/grass_engine.py index 95ea7647..11d14fa7 100644 --- a/opendm/grass_engine.py +++ b/opendm/grass_engine.py @@ -6,6 +6,7 @@ import sys import time from opendm import log from opendm import system +import locale from string import Template @@ -94,7 +95,8 @@ class GrassContext: log.ODM_INFO("Executing grass script from {}: {} --tmp-location {} --exec bash script.sh".format(self.get_cwd(), self.grass_binary, self.location)) env = os.environ.copy() env["GRASS_ADDON_PATH"] = env.get("GRASS_ADDON_PATH", "") + os.path.abspath(os.path.join("opendm/grass/addons")) - + env["LC_ALL"] = locale.getdefaultlocale()[1] or "C.UTF-8" + filename = os.path.join(self.get_cwd(), 'output.log') with open(filename, 'wb') as writer, open(filename, 'rb', 1) as reader: p = subprocess.Popen([self.grass_binary, '--tmp-location', self.location, '--exec', 'bash', 'script.sh'],