Skip to content

Commit

Permalink
DXF: handle MultiPoints in writer (fixes #11686) (#11687)
Browse files Browse the repository at this point in the history
Fixes #11686
  • Loading branch information
michkowalczuk authored Jan 21, 2025
1 parent 5212909 commit 63cd33a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
27 changes: 25 additions & 2 deletions autotest/ogr/ogr_dxf.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ def test_ogr_dxf_11():


###############################################################################
# Write a simple file with a polygon and a line, and read back.
# Write a simple file with a few geometries of different types, and read back.


def test_ogr_dxf_12(tmp_path):
Expand Down Expand Up @@ -467,6 +467,14 @@ def test_ogr_dxf_12(tmp_path):
lyr.CreateFeature(dst_feat)
dst_feat = None

# Test multipoint
dst_feat = ogr.Feature(feature_def=lyr.GetLayerDefn())
dst_feat.SetGeometryDirectly(
ogr.CreateGeometryFromWkt("MULTIPOINT((10 40),(40 30))")
)
lyr.CreateFeature(dst_feat)
dst_feat = None

lyr = None
ds = None

Expand Down Expand Up @@ -514,9 +522,24 @@ def test_ogr_dxf_12(tmp_path):
), feat.GetGeometryRef().ExportToWkt()
feat = None

# Check 5th feature (1st multipoint part)
feat = lyr.GetNextFeature()

ogrtest.check_feature_geometry(
feat, "POINT(10 40)"
), feat.GetGeometryRef().ExportToWkt()
feat = None

# Check 6th feature (2nd multipoint part)
feat = lyr.GetNextFeature()

ogrtest.check_feature_geometry(
feat, "POINT(40 30)"
), feat.GetGeometryRef().ExportToWkt()
feat = None

lyr = None
ds = None
ds = None


###############################################################################
Expand Down
2 changes: 1 addition & 1 deletion ogr/ogrsf_frmts/dxf/ogrdxfwriterlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1278,7 +1278,7 @@ OGRErr OGRDXFWriterLayer::ICreateFeature(OGRFeature *poFeature)
}

// Explode geometry collections into multiple entities.
else if (eGType == wkbGeometryCollection)
else if (eGType == wkbGeometryCollection || eGType == wkbMultiPoint)
{
OGRGeometryCollection *poGC =
poFeature->StealGeometry()->toGeometryCollection();
Expand Down

0 comments on commit 63cd33a

Please sign in to comment.