Opened 14 years ago

Closed 14 years ago

#3393 closed defect (fixed)

DXF Doesn't identify polygons correctly

Reported by: gaige Owned by: warmerdam
Priority: normal Milestone: 1.7.2
Component: OGR_SF Version: unspecified
Severity: normal Keywords: DXF

Description (last modified by warmerdam)

There is a test in the OGRDXFWriterLayer::WritePOLYLINE function that is intended to identify a linear ring. Unfortunately, due to the fact that wkbLinearRing is never returned by linear rings, it always sees it as a wkbLineString, which means that polygons are always written as lines, and not closed figures (which is to say that attribute 70 is always set to 0).

Replacing this test with the "standard"

	if( EQUAL( ((OGRGeometry*) hGeom)->getGeometryName(), "LINEARRING" ) )

test fixes the problem.

Attachments (1)

dxflayer-diff (3.8 KB ) - added by gaige 14 years ago.
ogrdxflayer.cpp diffs

Download all attachments as: .zip

Change History (4)

by gaige, 14 years ago

Attachment: dxflayer-diff added

ogrdxflayer.cpp diffs

comment:1 by gaige, 14 years ago

Summary: DXF Doesn't identify polygons correctly on writeDXF Doesn't identify polygons correctly

Found that additionally they were not identified correctly on read either. Any closed form was being tested for closure and was having points added, but the geometry was always a LineString instead of a LinearRing with an encompassing Polygon.

Documentation also indicates that in LWPOLYLINE the attribute for Z is 38, not 30.

Also updated to handle 2D only reads differently from 2.5D reads

ogr/ogrsf_frmts/dxf/ogrdxfwriterlayer.cpp#1 - ogr/ogrsf_frmts/dxf/ogrdxfwriterlayer.cpp

417c417 < if( wkbFlatten(poGeom->getGeometryType()) == wkbLinearRing ) ---

if( EQUAL( ((OGRGeometry*) poLS)->getGeometryName(), "LINEARRING" ) )

470c470,471 < if( WriteValue( 30, poLS->getZ(iVert) ) ) ---

according to DXF reference, this should be 38, not 30 for LWPOLYLINES

if( WriteValue( 38, poLS->getZ(iVert) ) )

485c486 < if( wkbFlatten(poGeom->getGeometryType()) == wkbLinearRing ) ---

if( EQUAL( ((OGRGeometry*) hGeom)->getGeometryName(), "LINEARRING" ) )

comment:2 by warmerdam, 14 years ago

Description: modified (diff)
Keywords: DXF added
Status: newassigned

comment:3 by warmerdam, 14 years ago

Resolution: fixed
Status: assignedclosed

I incorporated the linearring/polygon handling fixes in trunk (r18800). I also fixed up 2d/3d handling in trunk (r18801) though I had to apply the patch by hand since it was difficult to apply to the altered source since it was not a context-diff. These two changes also include additions to the test suite.

I have migrated both changes back into 1.7 branch (r18802).

Note: See TracTickets for help on using tickets.