Ticket #3393 (closed defect: fixed)

Opened 3 years ago

Last modified 3 years ago

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
Cc:

Description (last modified by warmerdam) (diff)

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

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

Change History

Changed 3 years ago by gaige

ogrdxflayer.cpp diffs

Changed 3 years ago by gaige

  • summary changed from DXF Doesn't identify polygons correctly on write to DXF 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" ) )

Changed 3 years ago by warmerdam

  • keywords DXF added
  • status changed from new to assigned
  • description modified (diff)

Changed 3 years ago by warmerdam

  • status changed from assigned to closed
  • resolution set to fixed

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.