Skip to content

Commit

Permalink
simplify geoarrow logic slightly
Browse files Browse the repository at this point in the history
  • Loading branch information
paleolimbot committed Sep 17, 2023
1 parent 945ab52 commit f75c8c9
Showing 1 changed file with 3 additions and 18 deletions.
21 changes: 3 additions & 18 deletions python/geoarrow-pyarrow/src/geoarrow/pyarrow/_compute.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,12 +240,7 @@ def as_wkt(obj):
VectorArray:WktType(geoarrow.wkt)[1]
<POINT (0 1)>
"""
obj = obj_as_array_or_chunked(obj)

if isinstance(obj.type, _type.WktType):
return obj

return push_all(Kernel.as_wkt, obj)
return as_geoarrow(obj, _type.wkt())


def as_wkb(obj):
Expand All @@ -257,12 +252,7 @@ def as_wkb(obj):
VectorArray:WkbType(geoarrow.wkb)[1]
<POINT (0 1)>
"""
obj = obj_as_array_or_chunked(obj)

if isinstance(obj.type, _type.WkbType):
return obj

return push_all(Kernel.as_wkb, obj)
return as_geoarrow(obj, _type.wkb())


def as_geoarrow(obj, type=None, coord_type=None, promote_multi=False):
Expand All @@ -285,12 +275,7 @@ def as_geoarrow(obj, type=None, coord_type=None, promote_multi=False):
if obj.type.id == type.id:
return obj

if type.extension_name == "geoarrow.wkt":
return push_all(Kernel.as_wkt, obj)
elif type._extension_name == "geoarrow.wkb":
return push_all(Kernel.as_wkb, obj)
else:
return push_all(Kernel.as_geoarrow, obj, args={"type_id": type.id})
return push_all(Kernel.as_geoarrow, obj, args={"type_id": type.id})


def format_wkt(obj, precision=None, max_element_size_bytes=None):
Expand Down

0 comments on commit f75c8c9

Please sign in to comment.