Opened 12 years ago
Closed 12 years ago
#4683 closed enhancement (fixed)
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 )
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 (1)
Change History (3)
by , 12 years ago
Attachment: | terreno2010.dxf added |
---|
comment:1 by , 12 years ago
Description: | modified (diff) |
---|
comment:2 by , 12 years ago
Milestone: | → 1.9.2 |
---|---|
Resolution: | → fixed |
Status: | new → closed |
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
dxf test file