当前位置: 首页>>代码示例>>C++>>正文


C++ DBFClose函数代码示例

本文整理汇总了C++中DBFClose函数的典型用法代码示例。如果您正苦于以下问题:C++ DBFClose函数的具体用法?C++ DBFClose怎么用?C++ DBFClose使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了DBFClose函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: parse

    void parse(const std::string& path, Visitor& visitor) const
    {
        SHPHandle shpFile = SHPOpen(path.c_str(), "rb");
        if (shpFile == NULL)
            throw std::domain_error("Cannot open shp file.");

        int shapeType, entityCount;
        double adfMinBound[4], adfMaxBound[4];
        SHPGetInfo(shpFile, &entityCount, &shapeType, adfMinBound, adfMaxBound);

        DBFHandle dbfFile = DBFOpen(path.c_str(), "rb");
        if (dbfFile == NULL)
            throw std::domain_error("Cannot open dbf file.");

        if (DBFGetFieldCount(dbfFile) == 0)
            throw std::domain_error("There are no fields in dbf table.");

        if (entityCount != DBFGetRecordCount(dbfFile))
            throw std::domain_error("dbf file has different entity count.");

        for (int k = 0; k < entityCount; k++)
        {
            SHPObject* shape = SHPReadObject(shpFile, k);
            if (shape == NULL)
                throw std::domain_error("Unable to read shape:" + to_string(k));

            Tags tags = parseTags(dbfFile, k);
            visitShape(*shape, tags, visitor);

            SHPDestroyObject(shape);
        }

        DBFClose(dbfFile);
        SHPClose(shpFile);
    }
开发者ID:Euphe,项目名称:utymap,代码行数:35,代码来源:ShapeParser.hpp

示例2: shapes_load_dbf

// extract info from dbf
void
shapes_load_dbf(const char* filename, const char* column){

    DBFHandle hDBF;

    hDBF = DBFOpen( filename, "rb" );
    if( hDBF == NULL ) {
        fprintf(stderr, "DBFOpen(%s,\"r\") failed.\n", filename );
        return;
    }

    // INFO ABOUT DBF
    // int  *panWidth;
    // int  nWidth, nDecimals;
    // fprintf (stderr, "Info for %s\n", filename);
    // i = DBFGetFieldCount(hDBF);
    // fprintf (stderr, "%d Columns,  %d Records in file\n",i,DBFGetRecordCount(hDBF));
    // panWidth = (int *) malloc( DBFGetFieldCount( hDBF ) * sizeof(int) );
    // for( int i = 0; i < DBFGetFieldCount(hDBF); i++ ) {
    //     DBFFieldType    eType;
    //     char szTitle[256];
    //     eType = DBFGetFieldInfo( hDBF, i, szTitle, &nWidth, &nDecimals );
    //     fprintf(stderr, "%4d: %10s %c", i, szTitle, i%4 ? '|':'\n');
    // }
    // fprintf(stderr, "\n");

    // print names
    uint32_t fid = DBFGetFieldIndex(hDBF, column);
    for(uint32_t i = 0; i < DBFGetRecordCount(hDBF); i++ ) {
       char* name_long = (char *) DBFReadStringAttribute(hDBF, i, fid);
       fprintf(stderr, "%d: %s\n", i, name_long);
    }

    DBFClose( hDBF );
}
开发者ID:peko,项目名称:tttm2,代码行数:36,代码来源:shape.c

示例3: ShpLoaderDestroy

void
ShpLoaderDestroy(SHPLOADERSTATE *state)
{
	/* Destroy a state object created with ShpLoaderOpenShape */

	if (state != NULL)
	{
		if (state->hSHPHandle)
			SHPClose(state->hSHPHandle);
		if (state->hDBFHandle)
			DBFClose(state->hDBFHandle);
		if (state->field_names)
		{
			int i;
			for (i = 0; i < state->num_fields; i++)
				free(state->field_names[i]);

			free(state->field_names);
		}
		if (state->types)
			free(state->types);
		if (state->widths)
			free(state->widths);
		if (state->precisions)
			free(state->precisions);
		if (state->col_names)
			free(state->col_names);

		/* Free the state itself */
		free(state);
	}
}
开发者ID:imincik,项目名称:pkg-postgis-1.5,代码行数:32,代码来源:shp2pgsql-core.c

示例4: CPLDebug

OGRShapeLayer::~OGRShapeLayer()

{
    if( m_nFeaturesRead > 0 && poFeatureDefn != NULL )
    {
        CPLDebug( "Shape", "%d features read on layer '%s'.",
                  (int) m_nFeaturesRead, 
                  poFeatureDefn->GetName() );
    }

    CPLFree( panMatchingFIDs );
    panMatchingFIDs = NULL;

    CPLFree( pszFullName );

    if( poFeatureDefn != NULL )
        poFeatureDefn->Release();

    if( poSRS != NULL )
        poSRS->Release();

    if( hDBF != NULL )
        DBFClose( hDBF );

    if( hSHP != NULL )
        SHPClose( hSHP );

    if( fpQIX != NULL )
        VSIFClose( fpQIX );
}
开发者ID:dlsyaim,项目名称:osgEarthX,代码行数:30,代码来源:ogrshapelayer.cpp

示例5: SHPClose

bool surfaceVectorField::CreateShape()
{
	char 	DataBaseID[64]="";

	hSHP=SHPCreate(ShapeFileName.c_str(), SHPT_POINT);
	if(hSHP==NULL)
		return false;
	SHPClose( hSHP );
	// Create the database.
	hDBF=DBFCreate(DataBaseName.c_str());
	if(hDBF==NULL)
		return false;

     //sprintf(DataBaseID, "%s", "Xcoord");
    	//DBFAddField(hDBF, DataBaseID, FTDouble, 16, 6);
     //sprintf(DataBaseID, "%s", "Ycoord");
    	//DBFAddField(hDBF, DataBaseID, FTDouble, 16, 6);
     sprintf(DataBaseID, "%s", "Windspd");
    	DBFAddField(hDBF, DataBaseID, FTDouble, 16, 6 );
     sprintf(DataBaseID, "%s", "Winddir");
    	DBFAddField(hDBF, DataBaseID, FTInteger, 8, 0);
     sprintf(DataBaseID, "%s", "AV_dir");
    	DBFAddField(hDBF, DataBaseID, FTInteger, 8, 0 );
     sprintf(DataBaseID, "%s", "AM_dir");
    	DBFAddField(hDBF, DataBaseID, FTInteger, 8, 0 );
	DBFClose(hDBF);

     return true;
}
开发者ID:psuliuxf,项目名称:windninja,代码行数:29,代码来源:surfaceVectorField.cpp

示例6: DBFCloneEmpty

DBFHandle DBFCloneEmpty(DBFHandle psDBF, const char * pszFilename ) 
{
    DBFHandle	newDBF;

   newDBF = DBFCreate ( pszFilename );
   if ( newDBF == NULL ) return ( NULL ); 
   
   newDBF->pszHeader = (char *) malloc ( 32 * psDBF->nFields );
   memcpy ( newDBF->pszHeader, psDBF->pszHeader, 32 * psDBF->nFields );
   
   newDBF->nFields = psDBF->nFields;
   newDBF->nRecordLength = psDBF->nRecordLength;
   newDBF->nHeaderLength = psDBF->nHeaderLength;
    
   newDBF->panFieldOffset = (int *) malloc ( sizeof(int) * psDBF->nFields ); 
   memcpy ( newDBF->panFieldOffset, psDBF->panFieldOffset, sizeof(int) * psDBF->nFields );
   newDBF->panFieldSize = (int *) malloc ( sizeof(int) * psDBF->nFields );
   memcpy ( newDBF->panFieldSize, psDBF->panFieldSize, sizeof(int) * psDBF->nFields );
   newDBF->panFieldDecimals = (int *) malloc ( sizeof(int) * psDBF->nFields );
   memcpy ( newDBF->panFieldDecimals, psDBF->panFieldDecimals, sizeof(int) * psDBF->nFields );
   newDBF->pachFieldType = (char *) malloc ( sizeof(int) * psDBF->nFields );
   memcpy ( newDBF->pachFieldType, psDBF->pachFieldType, sizeof(int) * psDBF->nFields );

   newDBF->bNoHeader = TRUE;
   newDBF->bUpdated = TRUE;
   
   DBFWriteHeader ( newDBF );
   DBFClose ( newDBF );
   
   newDBF = DBFOpen ( pszFilename, "rb+" );

   return ( newDBF );
}
开发者ID:bmfekete,项目名称:TauDEM,代码行数:33,代码来源:dbf.cpp

示例7: DBFOpen

int CDbfFile::DBFAddRecord(CStringArray* psDBFFieldValList)
{
    DBFHandle	hDBF;
	int			i;
	int			iRecord;
	int			iNumField;

	if (psDBFFieldValList == NULL)
		iNumField = 0;
	else
		iNumField = psDBFFieldValList->GetSize();

    // Open/Create the database.						
	hDBF = DBFOpen("r+b" );
	if( hDBF == NULL )
	{
		printf("DBFOpen failed: %s", _szDBFName);
		return 1;
	}
    
	// Do we have the correct number of arguments?			
	if( DBFGetFieldCount( hDBF ) != iNumField )
	{
		CString sMsg;
		sMsg.Format("Received %d field(s), but require %d field(s).",iNumField,DBFGetFieldCount(hDBF));
		printf("%s\n",sMsg);

		int		i, iWidth, iDecimals;
		char	psName[257];

		for (i=0; i<DBFGetFieldCount(hDBF); i++)
		{
			DBFGetFieldInfo(hDBF,i,psName,&iWidth,&iDecimals);
			sMsg.Format("%d of %d) FieldName: %s    Width: %d    Decimals: %d",i+1,DBFGetFieldCount(hDBF),psName,iWidth,iDecimals);
			printf("%s\n",sMsg);
		}
		return 1;
	}

	iRecord = DBFGetRecordCount( hDBF );

/* -------------------------------------------------------------------- */
/*	Loop assigning the new field values.				*/
/* -------------------------------------------------------------------- */
	for( i = 0; i < DBFGetFieldCount(hDBF); i++ )
	{
		if( DBFGetFieldInfo( hDBF, i, NULL, NULL, NULL ) == FTString )
			DBFWriteStringAttribute(hDBF, iRecord, i, psDBFFieldValList->GetAt(i) );
		else
			DBFWriteDoubleAttribute(hDBF, iRecord, i, atof(psDBFFieldValList->GetAt(i)) );
	}

/* -------------------------------------------------------------------- */
/*      Close and cleanup.                                              */
/* -------------------------------------------------------------------- */
	DBFClose( hDBF );

	return 0;
}
开发者ID:giulange,项目名称:landmapr-cpp,代码行数:59,代码来源:DBFFile.cpp

示例8: dbf_file_exists

/**

 * \brief Checks DBF file existance and validity
 *
 * \param dbf_file path and file name of DBF file
 *
 * \return Returns true if existing and valid
 * */
bool dbf_file_exists(const char* dbf_file) {
    DBFHandle handle = DBFOpen(dbf_file, "rb");
    if (handle == NULL) {
        return false;
    }
    DBFClose(handle);
    return true;
}
开发者ID:knowname,项目名称:morituri,代码行数:16,代码来源:util.hpp

示例9: main

int main( int argc, char ** argv )

{
    DBFHandle	hDBF;
    int		i, iRecord;

/* -------------------------------------------------------------------- */
/*      Display a usage message.                                        */
/* -------------------------------------------------------------------- */
    if( argc < 3 )
    {
	printf( "dbfadd xbase_file field_values\n" );

	exit( 1 );
    }

/* -------------------------------------------------------------------- */
/*	Create the database.						*/
/* -------------------------------------------------------------------- */
    hDBF = DBFOpen( argv[1], "r+b" );
    if( hDBF == NULL )
    {
	printf( "DBFOpen(%s,\"rb+\") failed.\n", argv[1] );
	exit( 2 );
    }
    
/* -------------------------------------------------------------------- */
/*	Do we have the correct number of arguments?			*/
/* -------------------------------------------------------------------- */
    if( DBFGetFieldCount( hDBF ) != argc - 2 )
    {
	printf( "Got %d fields, but require %d\n",
	        argc - 2, DBFGetFieldCount( hDBF ) );
	exit( 3 );
    }

    iRecord = DBFGetRecordCount( hDBF );

/* -------------------------------------------------------------------- */
/*	Loop assigning the new field values.				*/
/* -------------------------------------------------------------------- */
    for( i = 0; i < DBFGetFieldCount(hDBF); i++ )
    {
        if( strcmp( argv[i+2], "" ) == 0 )
            DBFWriteNULLAttribute(hDBF, iRecord, i );
	else if( DBFGetFieldInfo( hDBF, i, NULL, NULL, NULL ) == FTString )
	    DBFWriteStringAttribute(hDBF, iRecord, i, argv[i+2] );
	else
	    DBFWriteDoubleAttribute(hDBF, iRecord, i, atof(argv[i+2]) );
    }

/* -------------------------------------------------------------------- */
/*      Close and cleanup.                                              */
/* -------------------------------------------------------------------- */
    DBFClose( hDBF );

    return( 0 );
}
开发者ID:dranch,项目名称:Xastir,代码行数:58,代码来源:dbfadd.c

示例10: DBFClose

void rspfShapeDatabase::close()
{
    if(isOpen())
    {
        DBFClose(theHandle);
        theHandle = NULL;
        theRecordNumber = -1;
    }
}
开发者ID:vapd-radi,项目名称:rspf_v2.0,代码行数:9,代码来源:rspfShapeDatabase.cpp

示例11: close_baseline_shape

void close_baseline_shape(DBFHandle dbase, SHPHandle shape)
{
    // Close database
    DBFClose(dbase);
    dbase = NULL;

    // Close shapefile
    SHPClose(shape);
    shape = NULL;
}
开发者ID:rudigens,项目名称:ASF_MapReady,代码行数:10,代码来源:baseline2vector.c

示例12: close

 void close() {
     if (m_dbf_handle) {
         DBFClose(m_dbf_handle);
         m_dbf_handle = 0;
     }
     if (m_shp_handle) {
         SHPClose(m_shp_handle);
         m_shp_handle = 0;
     }
 }
开发者ID:MaZderMind,项目名称:osmium,代码行数:10,代码来源:shapefile.hpp

示例13: CStringArray

int CDbfFile::AddDBF4(char* psDBFAttList,CString sDelimiter, int nSize)
//used when strings separated by '\0'
{
	DBFHandle	hDBF;

	int			kk;
	CFileFind	ShapeFile;
	CString		sTmp;
	CStringArray	*psDBFAtt;
	psDBFAtt = new CStringArray();

	if (_bInit)
	{
		_bInit = false;
		ValidateDBF();
		DBFSetColumn(&_psDBFAttList);
	}
    // Open/Create the database.						
	hDBF = DBFOpen("r+b" );
	if( hDBF == NULL )
	{
		printf("DBFOpen failed: %s\n", _szDBFName);
		return 1;
	}
	
	int nStrStart = 0;
	for (kk = 0; kk < nSize; kk++)
	{
		psDBFAtt->RemoveAll();
		sTmp = "";
		while(psDBFAttList[nStrStart]!='\0')
		{
			sTmp = sTmp + psDBFAttList[nStrStart++];
		}
		nStrStart++;
		while (sTmp.Find(sDelimiter) != -1)
		{
			psDBFAtt->Add(sTmp.Left(sTmp.Find(sDelimiter)));
			sTmp.Delete(0, (sTmp.Find(sDelimiter) + 1));
		}
		if (!sTmp.IsEmpty())
			psDBFAtt->Add(sTmp);
		DBFAddRecord(hDBF, psDBFAtt);

	}

	psDBFAtt->RemoveAll();

/* -------------------------------------------------------------------- */
/*      Close and cleanup.                                              */
/* -------------------------------------------------------------------- */
	DBFClose( hDBF );
	delete(psDBFAtt);
	return 0;
}
开发者ID:giulange,项目名称:landmapr-cpp,代码行数:55,代码来源:DBFFile.cpp

示例14: Java_org_maptools_shapelib_android_util_TestUtils_updateShapefile

jboolean Java_org_maptools_shapelib_android_util_TestUtils_updateShapefile(JNIEnv * env, jclass clazz,
                                                                jstring file, jobject listObject) {
    // open an existing shapefile and dbf (e.g. /sdcard/foo/bar)
    const char *fileStr = (*env)->GetStringUTFChars(env, file, 0);
    SHPHandle hSHP = SHPOpen(fileStr, "rb+");
    DBFHandle hDBF = DBFOpen(fileStr, "rb+");
    (*env)->ReleaseStringUTFChars(env, file, fileStr);

    process(env, hSHP, hDBF, file, listObject);

    SHPClose(hSHP);
    DBFClose(hDBF);
}
开发者ID:jessisena,项目名称:shapelib-android-demo,代码行数:13,代码来源:hello-shapelib.c

示例15: Java_org_maptools_shapelib_android_util_TestUtils_createShapefile

jboolean Java_org_maptools_shapelib_android_util_TestUtils_createShapefile(JNIEnv * env, jclass clazz,
                                                                jstring file, jobject listObject) {
    // create a shapefile and dbf (e.g. /sdcard/foo/bar)
    const char *fileStr = (*env)->GetStringUTFChars(env, file, 0);
    SHPHandle hSHP = SHPCreate(fileStr, SHPT_POINT);
    DBFHandle hDBF = DBFCreate(fileStr);

    // define the shapefile attributes
    DBFAddField(hDBF, "name", FTString, 25, 0);
    DBFAddField(hDBF, "height", FTDouble, 8, 8);
    DBFAddField(hDBF, "apples", FTInteger, 1, 0);

    process(env, hSHP, hDBF, file, listObject);

    SHPClose(hSHP);
    DBFClose(hDBF);
}
开发者ID:jessisena,项目名称:shapelib-android-demo,代码行数:17,代码来源:hello-shapelib.c


注:本文中的DBFClose函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。