s+: convert to latlong
This commit is contained in:
parent
996b973533
commit
8ddde41a2e
|
@ -446,7 +446,7 @@ class LatlongQuery(NamedTuple):
|
||||||
|
|
||||||
def __str__(self) -> str:
|
def __str__(self) -> str:
|
||||||
"""method that returns string representation of query"""
|
"""method that returns string representation of query"""
|
||||||
return f"{self.latlong.latitude}, {self.latlong.longitude}"
|
return f"{str(self.latlong)}"
|
||||||
|
|
||||||
|
|
||||||
class StringQuery(NamedTuple):
|
class StringQuery(NamedTuple):
|
||||||
|
@ -1058,13 +1058,20 @@ def surplus(query: Query | str, behaviour: Behaviour) -> Result[str]:
|
||||||
)
|
)
|
||||||
|
|
||||||
case ConversionResultTypeEnum.LATLONG:
|
case ConversionResultTypeEnum.LATLONG:
|
||||||
# TODO: https://github.com/markjoshwel/surplus/issues/18
|
# return the latlong if already given a latlong
|
||||||
return Result[str](
|
if isinstance(query, LatlongQuery):
|
||||||
text,
|
return Result[str](str(query))
|
||||||
error=UnavailableFeatureError(
|
|
||||||
"converting to Latlong is not implemented yet"
|
# get latlong and handle result
|
||||||
),
|
latlong = query.to_lat_long_coord(geocoder=behaviour.geocoder)
|
||||||
)
|
|
||||||
|
if not latlong:
|
||||||
|
return Result[str]("", error=latlong.error)
|
||||||
|
|
||||||
|
if behaviour.debug:
|
||||||
|
print(f"debug: cli: {latlong.get()=}", file=behaviour.stderr)
|
||||||
|
|
||||||
|
return Result[str](str(latlong.get()))
|
||||||
|
|
||||||
case _:
|
case _:
|
||||||
return Result[str](
|
return Result[str](
|
||||||
|
|
Loading…
Reference in a new issue