#7005 closed enhancement (fixed)

DXF: Allow user to set the tolerance used when joining parts of a hatch boundary

Reported by: Alan Thomas Owned by: warmerdam
Priority: normal Milestone:
Component: OGR_SF Version: svn-trunk
Severity: normal Keywords: dxf
Cc:

Description

The attached DXF file is part of a real-world CAD drawing which we were putting through OGR as part of our professional work. It contains one HATCH entity. The file is intended to be projected in a southern hemisphere UTM zone.

This HATCH is incorrectly converted to a MULTILINESTRING instead of a POLYGON, because the endpoint of one segment of the hatch boundary doesn't coincide closely enough with the endpoint of the next segment.

The DXF code uses a hard-coded tolerance of 0.0000001 (1e-7) which might be OK for lat/long coordinate systems, but is unreasonably small when working in grid-based coordinate systems in metres or feet.

The DXF driver seems to operate without knowledge of the spatial reference system, so my patch adds a new configuration parameter allowing the user to choose an appropriate hatch tolerance.

Attachments (4)

u-turn-hatch-UTM-55SNEW.dxf (346.7 KB) - added by Alan Thomas 11 months ago.
u-turn-hatch-UTM-55S.png (6.7 KB) - added by Alan Thomas 11 months ago.
OGR-DXF-hatch-tolerance.diff (1.8 KB) - added by Alan Thomas 11 months ago.
Patch
OGR-DXF-hatch-tolerance-v2.diff (2.5 KB) - added by Alan Thomas 10 months ago.
Re-add accidentally omitted change to the doc html file

Download all attachments as: .zip

Change History (9)

Changed 11 months ago by Alan Thomas

Attachment: u-turn-hatch-UTM-55SNEW.dxf added

Changed 11 months ago by Alan Thomas

Attachment: u-turn-hatch-UTM-55S.png added

Changed 11 months ago by Alan Thomas

Patch

comment:1 Changed 11 months ago by Even Rouault

@atlight Your patch is reasonable, but I think it could be improved. For example what do you think about computing the bounding box of the coordinates of the geometry, taking the maximum of the absolute value of the x and y, and setting the default threshold to let's say 1e-8 of that value ? The configuration option could then override this default

comment:2 Changed 10 months ago by Even Rouault

Atlight, would you be willing to rework your patch with my above suggestion ?

comment:3 Changed 10 months ago by Alan Thomas

@rouault I will do it when I have the time. If you feel that you will have time within the next two weeks or so, then of course you may take it on. I suppose it is not very difficult.

comment:4 Changed 10 months ago by Alan Thomas

How about this?

I am still working out how to get the test suite working (Python is a mystery to me). Once I do that, my patches will have test cases incorporated in them instead of being separate files.

Changed 10 months ago by Alan Thomas

Re-add accidentally omitted change to the doc html file

comment:5 Changed 10 months ago by Even Rouault

Resolution: fixed
Status: newclosed

In 40351:

DXF: allow user to set the tolerance used when joining parts of a hatch boundary with a DXF_HATCH_TOLERANCE config option, and default to 1e-7 of the extent of the geometry (patch by atlight, fixes #7005)

Note: See TracTickets for help on using tickets.