gdal icon indicating copy to clipboard operation
gdal copied to clipboard

DXF: error reading hatch

Open MarcWeustink opened this issue 8 years ago • 3 comments

Expected behavior and actual behavior.

I expected to be able to open this dxf test.zip and it returns an error message instead.

ERROR 1: /build/gdal-hKKMDX/gdal-2.3.2+1/drivers/vector/dxf/ogrdxf_hatch.cpp, 163: error at line 6084 of test.dxf

note: I stripped this file down from a 79MB dxf removing all customer data and other info. As a result it doesn't show anymore in Autodesk Trueview. The error however is still in the same block/line as it was in the original file

Steps to reproduce the problem.

ogrinfo test.dxf entities

Operating system

For example: Ubuntu 16.04.5 64 bit

GDAL version and provenance

GDAL 2.3.2, released 2018/09/21 from NextGIS Ubuntu ppa

MarcWeustink avatar Oct 15 '18 12:10 MarcWeustink

With DraftSight I've stripped down another case resulting in one single object. This sample still shows in DraftSight, TrueView and Teigha Viewer.

The result of running ogrinfo error2.dxf entities > /dev/null ERROR 1: /build/gdal-GEMHj5/gdal-2.3.2+2/drivers/vector/dxf/ogrdxf_hatch.cpp, 517: error at line 808 of error2.dxf ERROR 1: /build/gdal-GEMHj5/gdal-2.3.2+2/drivers/vector/dxf/ogrdxf_hatch.cpp, 517: error at line 808 of error2.dxf ERROR 1: /build/gdal-GEMHj5/gdal-2.3.2+2/drivers/vector/dxf/ogrdxf_hatch.cpp, 517: error at line 808 of error2.dxf

error2.zip

MarcWeustink avatar Oct 23 '18 11:10 MarcWeustink

The issue is that the HATCH boundary contains a spline segment with a sequence of 10,20,42,10,20,42,... group codes. GDAL is expecting the sequence to be 10,20,10,20,...,10,20,42,42,...,42, which is not what AutoCAD generates.

To be honest it looks like I just guessed how this was implemented when I coded 89cb8bafe, and never tested it :(

atlight avatar Nov 23 '18 05:11 atlight

I'm not an expert either. I tried to read the dxf spec to figure out what is expected, but it is way to much reading ;)

MarcWeustink avatar Nov 23 '18 14:11 MarcWeustink