Skip to content

Commit

Permalink
Fix geometry type "2.5D Unknown" is not supported (#229)
Browse files Browse the repository at this point in the history
  • Loading branch information
theroggy authored Mar 18, 2023
1 parent 069fd47 commit 686216e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

### Improvements

- Add automatic detection of 2.5D geometries in write_dataframe (#223)
- Add automatic detection of 2.5D geometries in write_dataframe (#223, #229)
- Add "driver" property to read_info result (#224)

## 0.5.1 (2023-01-26)
Expand Down
2 changes: 1 addition & 1 deletion pyogrio/geopandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ def write_dataframe(

if geometry_type is None:
geometry_type = tmp_geometry_type
if has_z:
if has_z and geometry_type != "Unknown":
geometry_type = f"2.5D {geometry_type}"

crs = None
Expand Down
14 changes: 13 additions & 1 deletion pyogrio/tests/test_geopandas_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -891,14 +891,26 @@ def test_write_geometry_z_types(tmp_path, wkt, geom_types):
),
("Point Z + Point", "2.5D Point", True, ["Point Z (0 0 0)", "Point (0 0)"]),
("Point Z + None", "2.5D Point", False, ["Point Z (0 0 0)", None]),
(
"Point Z + LineString Z",
"Unknown",
False,
["LineString Z (0 0 0, 1 1 0)", "Point Z (0 0 0)"],
),
(
"Point Z + LineString",
"Unknown",
True,
["LineString (0 0, 1 1)", "Point Z (0 0 0)"],
),
],
)
def test_write_geometry_z_types_auto(
tmp_path, ext, test_descr, exp_geometry_type, mixed_dimensions, wkt
):
# Shapefile has some different behaviour that other file types
if ext == ".shp":
if exp_geometry_type == "2.5D GeometryCollection":
if exp_geometry_type in ("2.5D GeometryCollection", "Unknown"):
pytest.skip(f"ext {ext} doesn't support {exp_geometry_type}")
elif exp_geometry_type == "2.5D MultiLineString":
exp_geometry_type = "2.5D LineString"
Expand Down

0 comments on commit 686216e

Please sign in to comment.