本文整理汇总了C++中DDFSubfieldDefn::GetWidth方法的典型用法代码示例。如果您正苦于以下问题:C++ DDFSubfieldDefn::GetWidth方法的具体用法?C++ DDFSubfieldDefn::GetWidth怎么用?C++ DDFSubfieldDefn::GetWidth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DDFSubfieldDefn
的用法示例。
在下文中一共展示了DDFSubfieldDefn::GetWidth方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetRepeatCount
int DDFField::GetRepeatCount()
{
if( !poDefn->IsRepeating() )
return 1;
/* -------------------------------------------------------------------- */
/* The occurance count depends on how many copies of this */
/* field's list of subfields can fit into the data space. */
/* -------------------------------------------------------------------- */
if( poDefn->GetFixedWidth() )
{
return nDataSize / poDefn->GetFixedWidth();
}
/* -------------------------------------------------------------------- */
/* Note that it may be legal to have repeating variable width */
/* subfields, but I don't have any samples, so I ignore it for */
/* now. */
/* */
/* The file data/cape_royal_AZ_DEM/1183XREF.DDF has a repeating */
/* variable length field, but the count is one, so it isn't */
/* much value for testing. */
/* -------------------------------------------------------------------- */
int iOffset = 0, iRepeatCount = 1;
while( TRUE )
{
for( int iSF = 0; iSF < poDefn->GetSubfieldCount(); iSF++ )
{
int nBytesConsumed;
DDFSubfieldDefn * poThisSFDefn = poDefn->GetSubfield( iSF );
if( poThisSFDefn->GetWidth() > nDataSize - iOffset )
nBytesConsumed = poThisSFDefn->GetWidth();
else
poThisSFDefn->GetDataLength( pachData+iOffset,
nDataSize - iOffset,
&nBytesConsumed);
iOffset += nBytesConsumed;
if( iOffset > nDataSize )
return iRepeatCount - 1;
}
if( iOffset > nDataSize - 2 )
return iRepeatCount;
iRepeatCount++;
}
}
示例2: ApplyATID
void SDTSFeature::ApplyATID( DDFField * poField )
{
DDFSubfieldDefn *poMODN
= poField->GetFieldDefn()->FindSubfieldDefn( "MODN" );
if( poMODN == nullptr )
{
// CPLAssert( false );
return;
}
bool bUsualFormat = poMODN->GetWidth() == 4;
const int nRepeatCount = poField->GetRepeatCount();
for( int iRepeat = 0; iRepeat < nRepeatCount; iRepeat++ )
{
paoATID = reinterpret_cast<SDTSModId *>(
CPLRealloc( paoATID, sizeof(SDTSModId)*(nAttributes+1) ) );
SDTSModId *poModId = paoATID + nAttributes;
*poModId = SDTSModId();
if( bUsualFormat )
{
const char * pabyData
= poField->GetSubfieldData( poMODN, nullptr, iRepeat );
if( pabyData == nullptr || strlen(pabyData) < 5 )
return;
memcpy( poModId->szModule, pabyData, 4 );
poModId->szModule[4] = '\0';
poModId->nRecord = atoi(pabyData + 4);
poModId->szOBRP[0] = '\0';
}
else
{
poModId->Set( poField );
}
nAttributes++;
}
}
示例3: ApplyATID
void SDTSFeature::ApplyATID( DDFField * poField )
{
int nRepeatCount = poField->GetRepeatCount();
int bUsualFormat;
DDFSubfieldDefn *poMODN;
poMODN = poField->GetFieldDefn()->FindSubfieldDefn( "MODN" );
if( poMODN == NULL )
{
CPLAssert( FALSE );
return;
}
bUsualFormat = poMODN->GetWidth() == 4;
for( int iRepeat = 0; iRepeat < nRepeatCount; iRepeat++ )
{
paoATID = (SDTSModId *) CPLRealloc(paoATID,
sizeof(SDTSModId)*(nAttributes+1));
const char * pabyData;
SDTSModId *poModId = paoATID + nAttributes;
if( bUsualFormat )
{
pabyData = poField->GetSubfieldData( poMODN, NULL, iRepeat );
memcpy( poModId->szModule, pabyData, 4 );
poModId->szModule[4] = '\0';
poModId->nRecord = atoi(pabyData + 4);
poModId->szOBRP[0] = '\0';
}
else
{
poModId->Set( poField );
}
nAttributes++;
}
}
示例4: printf
static void
AddPrimaryAttrToDBFSchema( DBFHandle hDBF, SDTSTransfer *poTransfer,
char ** papszModuleList )
{
for( int iModule = 0;
papszModuleList != NULL && papszModuleList[iModule] != NULL;
iModule++ )
{
SDTSAttrReader *poAttrReader;
/* -------------------------------------------------------------------- */
/* Get a reader on the desired module. */
/* -------------------------------------------------------------------- */
poAttrReader = (SDTSAttrReader *)
poTransfer->GetLayerIndexedReader(
poTransfer->FindLayer( papszModuleList[iModule] ) );
if( poAttrReader == NULL )
{
printf( "Unable to open attribute module %s, skipping.\n" ,
papszModuleList[iModule] );
continue;
}
poAttrReader->Rewind();
/* -------------------------------------------------------------------- */
/* Read the first record so we can clone schema information off */
/* of it. */
/* -------------------------------------------------------------------- */
SDTSAttrRecord *poAttrFeature;
poAttrFeature = (SDTSAttrRecord *) poAttrReader->GetNextFeature();
if( poAttrFeature == NULL )
{
fprintf( stderr,
"Didn't find any meaningful attribute records in %s.\n",
papszModuleList[iModule] );
continue;
}
/* -------------------------------------------------------------------- */
/* Clone schema off the first record. Eventually we need to */
/* get the information out of the DDR record, but it isn't */
/* clear to me how to accomplish that with the SDTS++ API. */
/* */
/* The following approach may fail (dramatically) if some */
/* records do not include all subfields. Furthermore, no */
/* effort is made to make DBF field names unique. The SDTS */
/* attributes often have names much beyond the 14 character dbf */
/* limit which may result in non-unique attributes. */
/* -------------------------------------------------------------------- */
DDFFieldDefn *poFDefn = poAttrFeature->poATTR->GetFieldDefn();
int iSF;
DDFField *poSR = poAttrFeature->poATTR;
for( iSF=0; iSF < poFDefn->GetSubfieldCount(); iSF++ )
{
DDFSubfieldDefn *poSFDefn = poFDefn->GetSubfield( iSF );
int nWidth = poSFDefn->GetWidth();
switch( poSFDefn->GetType() )
{
case DDFString:
if( nWidth == 0 )
{
int nMaxBytes;
const char * pachData = poSR->GetSubfieldData(poSFDefn,
&nMaxBytes);
nWidth = strlen(poSFDefn->ExtractStringData(pachData,
nMaxBytes, NULL ));
}
DBFAddField( hDBF, poSFDefn->GetName(), FTString, nWidth, 0 );
break;
case DDFInt:
if( nWidth == 0 )
nWidth = 9;
DBFAddField( hDBF, poSFDefn->GetName(), FTInteger, nWidth, 0 );
break;
case DDFFloat:
DBFAddField( hDBF, poSFDefn->GetName(), FTDouble, 18, 6 );
break;
default:
fprintf( stderr,
"Dropping attribute `%s' of module `%s'. "
"Type unsupported\n",
poSFDefn->GetName(),
papszModuleList[iModule] );
break;
}
}
//.........这里部分代码省略.........
示例5: OGRFeatureDefn
OGRSDTSLayer::OGRSDTSLayer( SDTSTransfer * poTransferIn, int iLayerIn,
OGRSDTSDataSource * poDSIn ) :
bPolygonsBuilt(FALSE)
{
poDS = poDSIn;
poTransfer = poTransferIn;
iLayer = iLayerIn;
poReader = poTransfer->GetLayerIndexedReader( iLayer );
/* -------------------------------------------------------------------- */
/* Define the feature. */
/* -------------------------------------------------------------------- */
int iCATDEntry = poTransfer->GetLayerCATDEntry( iLayer );
poFeatureDefn =
new OGRFeatureDefn(poTransfer->GetCATD()->GetEntryModule(iCATDEntry));
SetDescription( poFeatureDefn->GetName() );
poFeatureDefn->Reference();
poFeatureDefn->GetGeomFieldDefn(0)->SetSpatialRef(poDS->GetSpatialRef());
OGRFieldDefn oRecId( "RCID", OFTInteger );
poFeatureDefn->AddFieldDefn( &oRecId );
if( poTransfer->GetLayerType(iLayer) == SLTPoint )
{
poFeatureDefn->SetGeomType( wkbPoint );
}
else if( poTransfer->GetLayerType(iLayer) == SLTLine )
{
poFeatureDefn->SetGeomType( wkbLineString );
oRecId.SetName( "SNID" );
poFeatureDefn->AddFieldDefn( &oRecId );
oRecId.SetName( "ENID" );
poFeatureDefn->AddFieldDefn( &oRecId );
}
else if( poTransfer->GetLayerType(iLayer) == SLTPoly )
{
poFeatureDefn->SetGeomType( wkbPolygon );
}
else if( poTransfer->GetLayerType(iLayer) == SLTAttr )
{
poFeatureDefn->SetGeomType( wkbNone );
}
/* -------------------------------------------------------------------- */
/* Add schema from referenced attribute records. */
/* -------------------------------------------------------------------- */
char **papszATIDRefs = NULL;
if( poTransfer->GetLayerType(iLayer) != SLTAttr )
papszATIDRefs = poReader->ScanModuleReferences();
else
papszATIDRefs = CSLAddString( papszATIDRefs,
poTransfer->GetCATD()->GetEntryModule(iCATDEntry) );
for( int iTable = 0;
papszATIDRefs != NULL && papszATIDRefs[iTable] != NULL;
iTable++ )
{
SDTSAttrReader *poAttrReader;
DDFFieldDefn *poFDefn;
/* -------------------------------------------------------------------- */
/* Get the attribute table reader, and the associated user */
/* attribute field. */
/* -------------------------------------------------------------------- */
int nLayerIdx = poTransfer->FindLayer( papszATIDRefs[iTable] );
if( nLayerIdx < 0 )
continue;
poAttrReader = (SDTSAttrReader *)
poTransfer->GetLayerIndexedReader(nLayerIdx);
if( poAttrReader == NULL )
continue;
poFDefn = poAttrReader->GetModule()->FindFieldDefn( "ATTP" );
if( poFDefn == NULL )
poFDefn = poAttrReader->GetModule()->FindFieldDefn( "ATTS" );
if( poFDefn == NULL )
continue;
/* -------------------------------------------------------------------- */
/* Process each user subfield on the attribute table into an */
/* OGR field definition. */
/* -------------------------------------------------------------------- */
for( int iSF=0; iSF < poFDefn->GetSubfieldCount(); iSF++ )
{
DDFSubfieldDefn *poSFDefn = poFDefn->GetSubfield( iSF );
int nWidth = poSFDefn->GetWidth();
char *pszFieldName;
if( poFeatureDefn->GetFieldIndex( poSFDefn->GetName() ) != -1 )
pszFieldName = CPLStrdup( CPLSPrintf( "%s_%s",
papszATIDRefs[iTable],
poSFDefn->GetName() ) );
else
//.........这里部分代码省略.........