Skip to content

Commit c61b1eb

Browse files
authored
feat(geoarrow-types): Add support for GeoArrow 0.2 edge types (#67)
1 parent a2e6f1a commit c61b1eb

File tree

4 files changed

+20
-4
lines changed

4 files changed

+20
-4
lines changed

geoarrow-pyarrow/src/geoarrow/pyarrow/_compute.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -423,8 +423,8 @@ def box_agg(obj):
423423
obj = obj_as_array_or_chunked(obj)
424424

425425
# Spherical edges aren't supported by this algorithm
426-
if obj.type.edge_type == EdgeType.SPHERICAL:
427-
raise TypeError("Can't compute box of type with spherical edges")
426+
if obj.type.edge_type != EdgeType.PLANAR:
427+
raise TypeError("Can't compute box of type with non-planar edges")
428428

429429
# Optimization: pyarrow's minmax kernel is fast and we can use it if we have struct
430430
# coords. So far, only a measurable improvement for points.

geoarrow-types/src/geoarrow/types/constants.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,18 @@ class EdgeType(TypeSpecEnum):
243243
SPHERICAL = 2
244244
"""Edges are geodesic on a sphere"""
245245

246+
VINCENTY = 3
247+
"""Edges are geodesic on a spheroid according to the Vincenty algorithm"""
248+
249+
THOMAS = 4
250+
"""Edges are geodesic on a spheroid according to the Thomas algorithm"""
251+
252+
ANDOYER = 5
253+
"""Edges are geodesic on a spheroid according to the Andoyer algorithm"""
254+
255+
KARNEY = 6
256+
"""Edges are geodesic on a spheroid according to the Karney algorithm"""
257+
246258

247259
_VALUE_COMMON_HELPER = {
248260
(Encoding.WKB, Encoding.LARGE_WKB): Encoding.LARGE_WKB,

geoarrow-types/src/geoarrow/types/type_spec.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ def extension_metadata(self) -> str:
7777
"edge_type or crs is unspecified"
7878
)
7979

80-
if self.edge_type == EdgeType.SPHERICAL:
81-
metadata["edges"] = "spherical"
80+
if self.edge_type != EdgeType.PLANAR:
81+
metadata["edges"] = self.edge_type.name.lower()
8282

8383
if self.crs is None:
8484
pass

geoarrow-types/tests/test_type_spec.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ def test_type_spec_extension_metadata():
4949
TypeSpec(edge_type=EdgeType.SPHERICAL).with_defaults().extension_metadata()
5050
== '{"edges": "spherical"}'
5151
)
52+
assert (
53+
TypeSpec(edge_type=EdgeType.VINCENTY).with_defaults().extension_metadata()
54+
== '{"edges": "vincenty"}'
55+
)
5256
assert (
5357
TypeSpec(crs=gt.OGC_CRS84)
5458
.with_defaults()

0 commit comments

Comments
 (0)