Ticket #4683 (closed enhancement: fixed)

Opened 12 months ago

Last modified 12 months ago

DXF problem reading polyline splines

Reported by: pduarte Owned by: warmerdam
Priority: normal Milestone: 1.9.2
Component: OGR_SF Version: 1.9.1
Severity: normal Keywords: dxf
Cc:

Description (last modified by pduarte) (diff)

When reading a spline control point vertexes are added to the output line. With this change control points vertexes are discarded.

Attached is a sample dxf file. Bellow is the corrected TranslatePOLYLINE function with the changes in bold style:

/************************************************************************/ /* TranslatePOLYLINE() */ /* */ /* We also capture the following VERTEXes. */ /************************************************************************/

OGRFeature *OGRDXFLayer::TranslatePOLYLINE()

{

char szLineBuf[257]; int nCode; int nPolylineFlag = 0; OGRFeature *poFeature = new OGRFeature( poFeatureDefn );

/* -------------------------------------------------------------------- */ /* Collect information from the POLYLINE object itself. */ /* -------------------------------------------------------------------- */

while( (nCode = poDS->ReadValue?(szLineBuf,sizeof(szLineBuf))) > 0 ) {

switch( nCode ) {

case 70:

nPolylineFlag = atoi(szLineBuf); break;

default:

TranslateGenericProperty?( poFeature, nCode, szLineBuf ); break;

}

}

/* -------------------------------------------------------------------- */ /* Collect VERTEXes as a smooth polyline. */ /* -------------------------------------------------------------------- */

double dfX = 0.0, dfY = 0.0, dfZ = 0.0; double dfBulge = 0.0; DXFSmoothPolyline smoothPolyline;

int nVertexFlag;

smoothPolyline.setCoordinateDimension(2);

while( nCode == 0 && !EQUAL(szLineBuf,"SEQEND") ) {

// Eat non-vertex objects. if( !EQUAL(szLineBuf,"VERTEX") ) {

while( (nCode = poDS->ReadValue?(szLineBuf,sizeof(szLineBuf)))>0 ) {} continue;

}

// process a Vertex while( (nCode = poDS->ReadValue?(szLineBuf,sizeof(szLineBuf))) > 0 ) {

switch( nCode ) {

case 10:

dfX = CPLAtof(szLineBuf); break;

case 20:

dfY = CPLAtof(szLineBuf); break;

case 30:

dfZ = CPLAtof(szLineBuf); smoothPolyline.setCoordinateDimension(3); break;

case 42:

dfBulge = CPLAtof(szLineBuf); break;

case 70:

nVertexFlag = atoi(szLineBuf);

break;

default:

break;

}

}

if (nVertexFlag!=16) { // Ignore Spline frame control points

smoothPolyline.AddPoint?( dfX, dfY, dfZ, dfBulge );

}

dfBulge = 0.0;

}

if(smoothPolyline.IsEmpty?()) {

delete poFeature; return NULL;

}

/* -------------------------------------------------------------------- */ /* Close polyline if necessary. */ /* -------------------------------------------------------------------- */

if(nPolylineFlag & 0x01)

smoothPolyline.Close();

OGRGeometry* poGeom = smoothPolyline.Tesselate(); ApplyOCSTransformer( poGeom ); poFeature->SetGeometryDirectly?( poGeom );

PrepareLineStyle?( poFeature );

return poFeature;

}

Attachments

terreno2010.dxf Download (212.5 KB) - added by pduarte 12 months ago.
dxf test file

Change History

Changed 12 months ago by pduarte

dxf test file

Changed 12 months ago by pduarte

  • description modified (diff)

Changed 12 months ago by rouault

  • status changed from new to closed
  • resolution set to fixed
  • milestone set to 1.9.2

Fixed in trunk (r24510) and branches/1.9 (r24511). Confirmed that GRASS v.in.ogr does the same, and also visually with  http://www.sharecad.org/Default.aspx or  https://docs.google.com/viewer?pli=1

Note: See TracTickets for help on using tickets.