OSGeo / gdal

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

DXF driver: ogr2ogr created DXF file lacks the OGR Feature Style LABEL's background/outline color #3648

Open faridcher opened 3 years ago

faridcher commented 3 years ago
echo a,b > dummy.csv
# A LABEL's foreground color (c:#B3B3B3) is set to gray and works as expected. The color is translated into an index number (253) with group code 62 in the DXF file.
\ogr2ogr -dialect sqlite \
  -sql 'select "LABEL(f:Arial,t:OGR2OGR,c:#B3B3B3)" OGR_STYLE, GeomFromText("POINT(0 0)") geom' \
  b.dxf dummy.csv

# However, ogr2ogr DXF driver withholds the application of the background color (b:#B3B3B3) to the MTEXT entity.
\ogr2ogr -dialect sqlite \
  -sql 'select "LABEL(f:Arial,t:OGR2OGR,b:#B3B3B3)" OGR_STYLE, GeomFromText("POINT(0 0)") geom' \
  b.dxf dummy.csv

# The expected output DXF should look like this. 63 DXF code is for bg color and 90 is to enable it
sed 's/AcDbMText/&\n 63\n253\n 90\n1/' b.dxf > b2.dxf

the same problem presists with a LABEL outline color.

ogr2ogr --version GDAL 3.2.2, released 2021/03/05

rouault commented 3 years ago

CC @atlight

atlight commented 3 years ago

The docs are clear that b is not supported in style strings. This support can easily be added as a copy-paste of https://github.com/OSGeo/gdal/blob/814434983f73c2917ceb36ee8a72fa3225ce646c/gdal/ogr/ogrsf_frmts/dxf/ogrdxfwriterlayer.cpp#L514-L519 with appropriate changes - not a hard change to make, but I won't have time to address it in the immediate future.