Skip to content

Commit

Permalink
Fix 3d coords for non-points (#160)
Browse files Browse the repository at this point in the history
  • Loading branch information
kylebarron authored Oct 27, 2023
1 parent 712d98a commit 400ed8f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lonboard/geoarrow/extension_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ def construct_geometry_array(
elif geom_type == GeometryType.LINESTRING:
assert len(offsets) == 1, "Expected one offsets array"
(geom_offsets,) = offsets
_parr = pa.FixedSizeListArray.from_arrays(coords.flatten(), 2)
_parr = pa.FixedSizeListArray.from_arrays(coords.flatten(), len(dims))
parr = pa.ListArray.from_arrays(pa.array(geom_offsets), _parr)
field = pa.field(
"geometry",
Expand All @@ -321,7 +321,7 @@ def construct_geometry_array(
elif geom_type == GeometryType.POLYGON:
assert len(offsets) == 2, "Expected two offsets arrays"
ring_offsets, geom_offsets = offsets
_parr = pa.FixedSizeListArray.from_arrays(coords.flatten(), 2)
_parr = pa.FixedSizeListArray.from_arrays(coords.flatten(), len(dims))
_parr1 = pa.ListArray.from_arrays(pa.array(ring_offsets), _parr)
parr = pa.ListArray.from_arrays(pa.array(geom_offsets), _parr1)
field = pa.field(
Expand All @@ -335,7 +335,7 @@ def construct_geometry_array(
elif geom_type == GeometryType.MULTIPOINT:
assert len(offsets) == 1, "Expected one offsets array"
(geom_offsets,) = offsets
_parr = pa.FixedSizeListArray.from_arrays(coords.flatten(), 2)
_parr = pa.FixedSizeListArray.from_arrays(coords.flatten(), len(dims))
parr = pa.ListArray.from_arrays(pa.array(geom_offsets), _parr)
field = pa.field(
"geometry",
Expand All @@ -348,7 +348,7 @@ def construct_geometry_array(
elif geom_type == GeometryType.MULTILINESTRING:
assert len(offsets) == 2, "Expected two offsets arrays"
ring_offsets, geom_offsets = offsets
_parr = pa.FixedSizeListArray.from_arrays(coords.flatten(), 2)
_parr = pa.FixedSizeListArray.from_arrays(coords.flatten(), len(dims))
_parr1 = pa.ListArray.from_arrays(pa.array(ring_offsets), _parr)
parr = pa.ListArray.from_arrays(pa.array(geom_offsets), _parr1)
field = pa.field(
Expand All @@ -362,7 +362,7 @@ def construct_geometry_array(
elif geom_type == GeometryType.MULTIPOLYGON:
assert len(offsets) == 3, "Expected three offsets arrays"
ring_offsets, polygon_offsets, geom_offsets = offsets
_parr = pa.FixedSizeListArray.from_arrays(coords.flatten(), 2)
_parr = pa.FixedSizeListArray.from_arrays(coords.flatten(), len(dims))
_parr1 = pa.ListArray.from_arrays(pa.array(ring_offsets), _parr)
_parr2 = pa.ListArray.from_arrays(pa.array(polygon_offsets), _parr1)
parr = pa.ListArray.from_arrays(pa.array(geom_offsets), _parr2)
Expand Down

0 comments on commit 400ed8f

Please sign in to comment.