OSGeo / gdal

GDAL is an open source MIT licensed translator library for raster and vector geospatial data formats.
https://gdal.org
Other
4.81k stars 2.52k forks source link

error on DXF if CUSTOMPROPERTYTAG is present #3828

Closed loicroybon closed 3 years ago

loicroybon commented 3 years ago

Hello,

orginfo can't display dxf file informations containing those headers :

  0
SECTION
  2
HEADER
  9
$ACADVER
  1
AC1024
  9
$ACADMAINTVER
 70
     6
  9
$DWGCODEPAGE
  3
ANSI_1252
  9
$AUTHOR
  1
lidar
  9
$LASTSAVEDBY
  1
my.name
  9
$CUSTOMPROPERTYTAG
  1
BentleyWorkSetProperties
  9
$CUSTOMPROPERTY
  1
02050000000B000000540200000000000000000200000057006F0072006B005300650074004E0061006D00650000000000000001000109040000000200000000000000000000000100000057006F0072006B005300650074004400650073006300720069007000740069006F006E0000000000000001000109080000000000000000000000000000000200000057006F0072006B00530070006100630065004E0061006D006500000000000000010001090C0000000200000000000000000000000400000043006F006E006E00650063007400500072006F006A006500630074004700550049004400000000000000010001091000000000000000000000000000000008000000500072006F006A00650063007400410073007300650074005400790070006500000000000000010001091400000000000000000000000000000010000000500072006F006A0065006300740049006E00640075007300740072007900000000000000010001091800000000000000000000000000000020000000500072006F006A006500630074004C006F0063006100740069006F006E00000000000000010001091C00000000000000000000000000000040000000500072006F006A006500630074004E0075006D00620065007200000000000000010001092000000000000000000000000000000080000000500072006F006A00650063007400530074006100740075007300000000000000010001092400000000000000000000000000000000010000500072006F006A006500630074004E0061006D00650000000000000001000109280000000000000000000000000000000002000031010000000000050002FCFFFF300000004A0000004A0000005A000000A4000000D2000000F4000000F600000004010000120100002C0100004D006500740072006F00530074006100740069006F006E0000004500780061006D0070006C0065000000350039003800370063003200620065002D0066003000660064002D0034003300660038002D0039006100610031002D00620039003100360035006200350030003400650032003300000050006C006100740066006F0072006D007300200061006E0064002000530074006100740069006F006E00730000005200610069006C00200061006E00640020005400720061006E0073006900740000000000310030003000310030003000000041006300740069007600650000004D006500740072006F00530074006100740069006F006E000000
  9
$INSBASE
 10
0.0
 20
0.0

but if I remove some lines like this, orginfo is able to read the file

  0
SECTION
  2
HEADER
  9
$ACADVER
  1
AC1024
  9
$ACADMAINTVER
 70
     6
  9
$DWGCODEPAGE
  3
ANSI_1252
  9
$AUTHOR
  1
lidar
  9
$LASTSAVEDBY
  1
my.name
$INSBASE
 10
0.0
 20
0.0

Could you fix this please and ingnor or delete DXF CUSTOMPROPERTYTAG ?

Thanks a lot

rouault commented 3 years ago

CC @atlight

atlight commented 3 years ago

I'm aware of this issue. It seems to appear when using ODA conversion tools to convert a Bentley MicroStation .dgn file to a DXF file and then using GDAL to read that DXF file.

This DXF file is probably "invalid", as lines are not supposed to be longer than 255 characters, but as we know, the term "invalid" is meaningless when it comes to the DXF format. I think the correct solution is to implement special handing in OGRDXFReader to skip over these long lines, as the information they contain is useless.

loicroybon commented 3 years ago

At this step, I had to modify the DXF file content with a python script before launching ogrinfo. My script remove lines from $CUSTOMPROPERTYTAG to $INSBASE. I don't know if this method will work each time. Probably not.

atlight commented 3 years ago

I confess I do a similar thing in my code. It would be better to have a solution in GDAL itself, of course!