OGRDXFBlocksWriterLayer::OGRDXFBlocksWriterLayer( OGRDXFWriterDS * /* poDS */ ) : poFeatureDefn(new OGRFeatureDefn( "blocks" )) { poFeatureDefn->Reference(); OGRFieldDefn oLayerField( "Layer", OFTString ); poFeatureDefn->AddFieldDefn( &oLayerField ); OGRFieldDefn oClassField( "SubClasses", OFTString ); poFeatureDefn->AddFieldDefn( &oClassField ); OGRFieldDefn oExtendedField( "ExtendedEntity", OFTString ); poFeatureDefn->AddFieldDefn( &oExtendedField ); OGRFieldDefn oLinetypeField( "Linetype", OFTString ); poFeatureDefn->AddFieldDefn( &oLinetypeField ); OGRFieldDefn oEntityHandleField( "EntityHandle", OFTString ); poFeatureDefn->AddFieldDefn( &oEntityHandleField ); OGRFieldDefn oTextField( "Text", OFTString ); poFeatureDefn->AddFieldDefn( &oTextField ); OGRFieldDefn oBlockField( "BlockName", OFTString ); poFeatureDefn->AddFieldDefn( &oBlockField ); }
void OGRDXFDataSource::AddStandardFields( OGRFeatureDefn *poFeatureDefn ) { OGRFieldDefn oLayerField( "Layer", OFTString ); poFeatureDefn->AddFieldDefn( &oLayerField ); OGRFieldDefn oClassField( "SubClasses", OFTString ); poFeatureDefn->AddFieldDefn( &oClassField ); OGRFieldDefn oExtendedField( "ExtendedEntity", OFTString ); poFeatureDefn->AddFieldDefn( &oExtendedField ); OGRFieldDefn oLinetypeField( "Linetype", OFTString ); poFeatureDefn->AddFieldDefn( &oLinetypeField ); OGRFieldDefn oEntityHandleField( "EntityHandle", OFTString ); poFeatureDefn->AddFieldDefn( &oEntityHandleField ); OGRFieldDefn oTextField( "Text", OFTString ); poFeatureDefn->AddFieldDefn( &oTextField ); if( !bInlineBlocks ) { OGRFieldDefn oTextField( "BlockName", OFTString ); poFeatureDefn->AddFieldDefn( &oTextField ); } }
OGRDXFWriterLayer::OGRDXFWriterLayer( OGRDXFWriterDS *poDS, VSILFILE *fp ) { this->fp = fp; this->poDS = poDS; nNextAutoID = 1; bWriteHatch = CSLTestBoolean(CPLGetConfigOption("DXF_WRITE_HATCH", "YES")); poFeatureDefn = new OGRFeatureDefn( "entities" ); poFeatureDefn->Reference(); OGRFieldDefn oLayerField( "Layer", OFTString ); poFeatureDefn->AddFieldDefn( &oLayerField ); OGRFieldDefn oClassField( "SubClasses", OFTString ); poFeatureDefn->AddFieldDefn( &oClassField ); OGRFieldDefn oExtendedField( "ExtendedEntity", OFTString ); poFeatureDefn->AddFieldDefn( &oExtendedField ); OGRFieldDefn oLinetypeField( "Linetype", OFTString ); poFeatureDefn->AddFieldDefn( &oLinetypeField ); OGRFieldDefn oEntityHandleField( "EntityHandle", OFTString ); poFeatureDefn->AddFieldDefn( &oEntityHandleField ); OGRFieldDefn oTextField( "Text", OFTString ); poFeatureDefn->AddFieldDefn( &oTextField ); OGRFieldDefn oBlockField( "BlockName", OFTString ); poFeatureDefn->AddFieldDefn( &oBlockField ); OGRFieldDefn oScaleField( "BlockScale", OFTRealList ); poFeatureDefn->AddFieldDefn( &oScaleField ); OGRFieldDefn oBlockAngleField( "BlockAngle", OFTReal ); poFeatureDefn->AddFieldDefn( &oBlockAngleField ); }
OGRCADLayer::OGRCADLayer( CADLayer &poCADLayer_, OGRSpatialReference *poSR, int nEncoding) : poSpatialRef( poSR ), poCADLayer( poCADLayer_ ), nDWGEncoding( nEncoding) { nNextFID = 0; if( poSpatialRef ) poSpatialRef->Reference(); poFeatureDefn = new OGRFeatureDefn( CADRecode( poCADLayer_.getName(), nDWGEncoding ) ); // Setting up layer geometry type OGRwkbGeometryType eGeomType; char dLineStringPresented = 0; char dCircularStringPresented = 0; char dPointPresented = 0; char dPolygonPresented = 0; std::vector<CADObject::ObjectType> aePresentedGeometryTypes = poCADLayer.getGeometryTypes(); for( size_t i = 0; i < aePresentedGeometryTypes.size(); ++i ) { switch( aePresentedGeometryTypes[i] ) { case CADObject::ATTDEF: case CADObject::TEXT: case CADObject::MTEXT: case CADObject::POINT: dPointPresented = 1; break; case CADObject::CIRCLE: dCircularStringPresented = 1; break; case CADObject::SPLINE: case CADObject::ELLIPSE: case CADObject::ARC: case CADObject::POLYLINE3D: case CADObject::POLYLINE2D: case CADObject::LWPOLYLINE: case CADObject::LINE: dLineStringPresented = 1; break; case CADObject::FACE3D: case CADObject::SOLID: dPolygonPresented = 1; break; default: break; } } if( ( dLineStringPresented + dCircularStringPresented + dPointPresented + dPolygonPresented ) > 1 ) { eGeomType = wkbGeometryCollection; } else { if( dLineStringPresented ) { eGeomType = wkbLineString; } else if( dCircularStringPresented ) { eGeomType = wkbCircularString; } else if( dPointPresented ) { eGeomType = wkbPoint; } else if( dPolygonPresented ) { eGeomType = wkbPolygon; } else { eGeomType = wkbUnknown; } } poFeatureDefn->SetGeomType( eGeomType ); OGRFieldDefn oClassField( FIELD_NAME_GEOMTYPE, OFTString ); poFeatureDefn->AddFieldDefn( &oClassField ); OGRFieldDefn oLinetypeField( FIELD_NAME_THICKNESS, OFTReal ); poFeatureDefn->AddFieldDefn( &oLinetypeField ); OGRFieldDefn oColorField( FIELD_NAME_COLOR, OFTString ); poFeatureDefn->AddFieldDefn( &oColorField ); OGRFieldDefn oExtendedField( FIELD_NAME_EXT_DATA, OFTString ); poFeatureDefn->AddFieldDefn( &oExtendedField ); OGRFieldDefn oTextField( FIELD_NAME_TEXT, OFTString ); poFeatureDefn->AddFieldDefn( &oTextField ); auto oAttrTags = poCADLayer.getAttributesTags(); for( const std::string & osTag : oAttrTags ) { auto ret = asFeaturesAttributes.insert( osTag ); if( ret.second == true) { OGRFieldDefn oAttrField( osTag.c_str(), OFTString ); poFeatureDefn->AddFieldDefn( &oAttrField ); } } // Applying spatial ref info if (poFeatureDefn->GetGeomFieldCount() != 0) poFeatureDefn->GetGeomFieldDefn(0)->SetSpatialRef( poSpatialRef ); SetDescription( poFeatureDefn->GetName() ); poFeatureDefn->Reference(); }