Opened 7 years ago

Closed 7 years ago

#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 7 years ago.
u-turn-hatch-UTM-55S.png (6.7 KB ) - added by Alan Thomas 7 years ago.
OGR-DXF-hatch-tolerance.diff (1.8 KB ) - added by Alan Thomas 7 years ago.
Patch
OGR-DXF-hatch-tolerance-v2.diff (2.5 KB ) - added by Alan Thomas 7 years ago.
Re-add accidentally omitted change to the doc html file

Download all attachments as: .zip

Change History (9)

by Alan Thomas, 7 years ago

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

by Alan Thomas, 7 years ago

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

by Alan Thomas, 7 years ago

Patch

comment:1 by Even Rouault, 7 years ago

@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 by Even Rouault, 7 years ago

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

comment:3 by Alan Thomas, 7 years ago

@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 by Alan Thomas, 7 years ago

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.

by Alan Thomas, 7 years ago

Re-add accidentally omitted change to the doc html file

comment:5 by Even Rouault, 7 years ago

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.