Skip to content

Commit

Permalink
DXF: interpret INSERT blocks with row count or column count equal to …
Browse files Browse the repository at this point in the history
…0 as 1
  • Loading branch information
rouault committed Jan 21, 2025
1 parent 8221e12 commit 8056d2f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 2 additions & 4 deletions autotest/ogr/ogr_dxf.py
Original file line number Diff line number Diff line change
Expand Up @@ -4129,17 +4129,15 @@ def test_ogr_dxf_write_MEASUREMENT(tmp_vsimem):
###############################################################################
# Use case of https://github.com/OSGeo/gdal/issues/11591
# Test reading a INSERT block whose column count is zero.
# Not totally sure about the exact behavior we should do. Currently
# the zero count is strictly honored and no geometry from the block will be
# inserted into the regular geometries. LibreCAD 2.1.3 does the same thing
# Interpretating it as 1, as AutoCAD does


@gdaltest.enable_exceptions()
def test_ogr_dxf_insert_col_count_zero():

with ogr.Open("data/dxf/insert_only_col_count_zero.dxf") as ds:
lyr = ds.GetLayer(0)
assert lyr.GetFeatureCount() == 0
assert lyr.GetFeatureCount() == 1

with gdal.config_option("DXF_INLINE_BLOCKS", "NO"):
with ogr.Open("data/dxf/insert_only_col_count_zero.dxf") as ds:
Expand Down
6 changes: 4 additions & 2 deletions ogr/ogrsf_frmts/dxf/ogrdxflayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3207,8 +3207,10 @@ bool OGRDXFLayer::TranslateINSERT()

if (m_oInsertState.m_nRowCount == 0 || m_oInsertState.m_nColumnCount == 0)
{
m_oInsertState.m_nRowCount = 0;
m_oInsertState.m_nColumnCount = 0;
// AutoCad doesn't allow setting to 0 in its UI, but interprets 0
// as 1 (but other software such as LibreCAD interpret 0 as 0)
m_oInsertState.m_nRowCount = 1;
m_oInsertState.m_nColumnCount = 1;
}

/* -------------------------------------------------------------------- */
Expand Down

0 comments on commit 8056d2f

Please sign in to comment.