diff --git a/python/grass/jupyter/utils.py b/python/grass/jupyter/utils.py index 95d4a0ce4d5..902ee3d6fcc 100644 --- a/python/grass/jupyter/utils.py +++ b/python/grass/jupyter/utils.py @@ -13,6 +13,7 @@ """Utility functions wrapping existing processes in a suitable way""" from collections.abc import Mapping +from io import StringIO import tempfile import json import os @@ -92,28 +93,9 @@ def reproject_latlon(coord): :param coord: coordinates given as tuple (latitude, longitude) :return: reprojected coordinates (returned as tuple) """ - # Prepare the input coordinate string coord_str = f"{coord[1]} {coord[0]}\n" - - # Start the m.proj command - proc = gs.start_command( - "m.proj", - input="-", - flags="i", - separator=",", - stdin=gs.PIPE, - stdout=gs.PIPE, - stderr=gs.PIPE, - ) - - proc.stdin.write(gs.encode(coord_str)) - proc.stdin.close() - proc.stdin = None - proj_output, _ = proc.communicate() - - output = gs.decode(proj_output).splitlines() - east, north, elev = map(float, output[0].split(",")) - + output = Tools().m_proj(input=StringIO(coord_str), flags="i", separator=",").text + east, north, elev = map(float, output.splitlines()[0].split(",")) return east, north, elev