?? ogravcbinlayer.cpp
字號:
if( poFeature == NULL ) ResetReading(); return poFeature;}/************************************************************************//* TestCapability() *//************************************************************************/int OGRAVCBinLayer::TestCapability( const char * pszCap ){ if( eSectionType == AVCFileARC && EQUAL(pszCap,OLCRandomRead) ) return TRUE; else return OGRAVCLayer::TestCapability( pszCap );}/************************************************************************//* FormPolygonGeometry() *//* *//* Collect all the arcs forming edges to this polygon and form *//* them into the appropriate OGR geometry on the target feature. *//************************************************************************/int OGRAVCBinLayer::FormPolygonGeometry( OGRFeature *poFeature, AVCPal *psPAL ){/* -------------------------------------------------------------------- *//* Try to find the corresponding ARC layer if not already *//* recorded. *//* -------------------------------------------------------------------- */ if( poArcLayer == NULL ) { int i; for( i = 0; i < poDS->GetLayerCount(); i++ ) { OGRAVCBinLayer *poLayer = (OGRAVCBinLayer *) poDS->GetLayer(i); if( poLayer->eSectionType == AVCFileARC ) poArcLayer = poLayer; } if( poArcLayer == NULL ) return FALSE; }/* -------------------------------------------------------------------- *//* Read all the arcs related to this polygon, making a working *//* copy of them since the one returned by AVC is temporary. *//* -------------------------------------------------------------------- */ OGRGeometryCollection oArcs; int iArc; for( iArc = 0; iArc < psPAL->numArcs; iArc++ ) { OGRFeature *poArc; if( psPAL->pasArcs[iArc].nArcId == 0 ) continue; // If the other side of the line is the same polygon then this // arc is a "bridge" arc and can be discarded. If we don't discard // it, then we should double it as bridge arcs seem to only appear // once. But by discarding it we ensure a multi-ring polygon will be // properly formed. if( psPAL->pasArcs[iArc].nAdjPoly == psPAL->nPolyId ) continue; poArc = poArcLayer->GetFeature( ABS(psPAL->pasArcs[iArc].nArcId) ); if( poArc == NULL ) return FALSE; if( poArc->GetGeometryRef() == NULL ) return FALSE; oArcs.addGeometry( poArc->GetGeometryRef() ); OGRFeature::DestroyFeature( poArc ); } OGRErr eErr; OGRPolygon *poPolygon; poPolygon = (OGRPolygon *) OGRBuildPolygonFromEdges( (OGRGeometryH) &oArcs, TRUE, FALSE, 0.0, &eErr ); if( poPolygon != NULL ) poFeature->SetGeometryDirectly( poPolygon ); return eErr == OGRERR_NONE;}/************************************************************************//* CheckSetupTable() *//* *//* Check if the named table exists, and if so, setup access to *//* it (open it), and add it's fields to the feature class *//* definition. *//************************************************************************/int OGRAVCBinLayer::CheckSetupTable(){ if( szTableName[0] == '\0' ) return FALSE;/* -------------------------------------------------------------------- *//* Scan for the indicated section. *//* -------------------------------------------------------------------- */ AVCE00ReadPtr psInfo = ((OGRAVCBinDataSource *) poDS)->GetInfo(); int iSection; AVCE00Section *psSection = NULL; char szPaddedName[65]; sprintf( szPaddedName, "%s%32s", szTableName, " " ); szPaddedName[32] = '\0'; for( iSection = 0; iSection < psInfo->numSections; iSection++ ) { if( EQUAL(szPaddedName,psInfo->pasSections[iSection].pszName) && psInfo->pasSections[iSection].eType == AVCFileTABLE ) psSection = psInfo->pasSections + iSection; } if( psSection == NULL ) { szTableName[0] = '\0'; return FALSE; }/* -------------------------------------------------------------------- *//* Try opening the table. *//* -------------------------------------------------------------------- */ hTable = AVCBinReadOpen( psInfo->pszInfoPath, szTableName, psInfo->eCoverType, AVCFileTABLE, psInfo->psDBCSInfo); if( hTable == NULL ) { szTableName[0] = '\0'; return FALSE; } /* -------------------------------------------------------------------- *//* Setup attributes. *//* -------------------------------------------------------------------- */ nTableBaseField = poFeatureDefn->GetFieldCount(); AppendTableDefinition( hTable->hdr.psTableDef );/* -------------------------------------------------------------------- *//* Close table so we don't have to many files open at once. *//* -------------------------------------------------------------------- */ AVCBinReadClose( hTable ); hTable = NULL; return TRUE;}/************************************************************************//* AppendTableFields() *//************************************************************************/int OGRAVCBinLayer::AppendTableFields( OGRFeature *poFeature ){ AVCE00ReadPtr psInfo = ((OGRAVCBinDataSource *) poDS)->GetInfo(); if( szTableName[0] == '\0' ) return FALSE;/* -------------------------------------------------------------------- *//* Open the table if it is currently closed. *//* -------------------------------------------------------------------- */ if( hTable == NULL ) { hTable = AVCBinReadOpen( psInfo->pszInfoPath, szTableName, psInfo->eCoverType, AVCFileTABLE, psInfo->psDBCSInfo); } if( hTable == NULL ) return FALSE;/* -------------------------------------------------------------------- *//* Read the info record. *//* *//* We usually assume the FID of the feature is the key but in a *//* polygon coverage we need to use the PolyId attribute of LAB *//* features to lookup the related attributes. In this case *//* nTableAttrIndex will already be setup to refer to the *//* PolyId field. *//* -------------------------------------------------------------------- */ int nRecordId; void *hRecord; if( nTableAttrIndex == -1 ) nRecordId = poFeature->GetFID(); else nRecordId = poFeature->GetFieldAsInteger( nTableAttrIndex ); hRecord = AVCBinReadObject( hTable, nRecordId ); if( hRecord == NULL ) return FALSE;/* -------------------------------------------------------------------- *//* Translate it. *//* -------------------------------------------------------------------- */ return TranslateTableFields( poFeature, nTableBaseField, hTable->hdr.psTableDef, (AVCField *) hRecord );}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -