Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 3 additions & 21 deletions python/grass/jupyter/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(","))
Comment thread
Valyrian-Code marked this conversation as resolved.
Resolved
return east, north, elev


Expand Down
Loading