Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DXF: add a creation option to set the maximum number of decimal places #10847

Open
agiudiceandrea opened this issue Sep 19, 2024 · 6 comments
Open

Comments

@agiudiceandrea
Copy link
Contributor

agiudiceandrea commented Sep 19, 2024

Feature description

The DXF drivers of GDAL/OGR 3.9.2 - 3.10 writes double precision floating point numbers with 15 significant figures:

static bool WriteValue(VSILFILE *fp, int nCode, double dfValue)
{
char szLinePair[64];
CPLsnprintf(szLinePair, sizeof(szLinePair), "%3d\n%.15g\n", nCode, dfValue);

int OGRDXFWriterLayer::WriteValue(int nCode, double dfValue)
{
char szLinePair[64];
CPLsnprintf(szLinePair, sizeof(szLinePair), "%3d\n%.15g\n", nCode, dfValue);

AFAIK, AutoCAD normally writes coordinates in DXF with 16 significant figures and allows to set the maximum number of decimal places between 0 and 16.
Refs:

Additional context

No response

@agiudiceandrea
Copy link
Contributor Author

@rouault
Copy link
Member

rouault commented Sep 19, 2024

@rouault
Copy link
Member

rouault commented Sep 19, 2024

AutoCAD normally writes coordinates in DXF with 16 significant figures

The documentation you point is a bit confusing. There's a mix between mentions of 16 significant figures and 16 decimal places. The screenshot at https://forums.autodesk.com/t5/autocad-forum/rounding-coordinates-of-line/m-p/8827743/highlight/true#M981665 has a "Decimal places of accuracies" in a label. I'm not sure if there are indeed 2 distinct limitations for the number of sigificant figures and decimal places, or if there's a single one but inaccurate terminology in some of the pages.

CC @atlight

@atlight
Copy link
Contributor

atlight commented Sep 20, 2024

It would be more accurate to say that AutoCAD writes coordinates to DXF with up to 16 significant figures, but no more decimal places than specified in the "Decimal places of accuracy" field in the Saveas Options dialog. This option is really specifying the maximum number of decimal places to write.

For example, here are some coordinates written to a DXF file by AutoCAD with the default value of 16 decimal places:

2.342052207121668
0.3634708370966422
22647145632.09978
-5497270855.233004

Here are those same coordinates written to a DXF file when 3 decimal places were specified:

2.342
0.363
22647145632.1
-5497270855.233

@atlight
Copy link
Contributor

atlight commented Sep 20, 2024

AFAIK, AutoCAD normally writes coordinates in DXF with 16 significant figures and allows to set the maximum number of decimal places between 0 and 16.

...so @agiudiceandrea was right, in other words.

@agiudiceandrea
Copy link
Contributor Author

agiudiceandrea commented Sep 20, 2024

I was also a little bit confused by the available docs when I wrote this feature request's title... So it is actually only needed to make available an option for the maximum number of decimal places and to ensure that the number is written with no more then the specified maximum number of decimal places and also up to and no more then 16 significant figures.

@agiudiceandrea agiudiceandrea changed the title DXF: add a creation option to set the number of significant figures / decimal places DXF: add a creation option to set the maximum number of decimal places Sep 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants