?? ogravce00layer.cpp
字號(hào):
/****************************************************************************** * $Id: ogravce00layer.cpp 10646 2007-01-18 02:38:10Z warmerdam $ * * Project: OGR * Purpose: Implements OGRAVCE00Layer class. * Author: Frank Warmerdam, warmerdam@pobox.com * James Flemer <jflemer@alum.rpi.edu> * ****************************************************************************** * Copyright (c) 2002, Frank Warmerdam <warmerdam@pobox.com> * Copyright (c) 2006, James Flemer <jflemer@alum.rpi.edu> * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. ****************************************************************************/#include "ogr_avc.h"#include "ogr_api.h"#include "cpl_conv.h"#include "cpl_string.h"CPL_CVSID("$Id: ogravce00layer.cpp 10646 2007-01-18 02:38:10Z warmerdam $");/************************************************************************//* OGRAVCE00Layer() *//************************************************************************/OGRAVCE00Layer::OGRAVCE00Layer( OGRAVCDataSource *poDSIn, AVCE00Section *psSectionIn ) : OGRAVCLayer( psSectionIn->eType, poDSIn ), psSection(psSectionIn), psRead(NULL), poArcLayer(NULL), nFeatureCount(-1), bNeedReset(0), nNextFID(1), psTableSection(NULL), psTableRead(NULL), pszTableFilename(NULL), nTablePos(0), nTableBaseField(0), nTableAttrIndex(-1){ SetupFeatureDefinition( psSection->pszName ); /* psRead = AVCE00ReadOpenE00(psSection->pszFilename); */ #if 0 szTableName[0] = '\0'; if( psSection->eType == AVCFilePAL ) sprintf( szTableName, "%s.PAT", poDS->GetCoverageName() ); else if( psSection->eType == AVCFileRPL ) sprintf( szTableName, "%s.PAT%s", poDS->GetCoverageName(), psSectionIn->pszName ); else if( psSection->eType == AVCFileARC ) sprintf( szTableName, "%s.AAT", poDS->GetCoverageName() ); else if( psSection->eType == AVCFileLAB ) { AVCE00ReadPtr psInfo = ((OGRAVCE00DataSource *) poDS)->GetInfo(); sprintf( szTableName, "%s.PAT", poDS->GetCoverageName() ); for( int iSection = 0; iSection < psInfo->numSections; iSection++ ) { if( psInfo->pasSections[iSection].eType == AVCFilePAL ) nTableAttrIndex = poFeatureDefn->GetFieldIndex( "PolyId" ); } }#endif}/************************************************************************//* ~OGRAVCE00Layer() *//************************************************************************/OGRAVCE00Layer::~OGRAVCE00Layer(){ if (psRead) { AVCE00ReadCloseE00(psRead); psRead = NULL; } if (psTableRead) { AVCE00ReadCloseE00(psTableRead); psTableRead = NULL; } if (pszTableFilename) { CPLFree(pszTableFilename); pszTableFilename = NULL; }}/************************************************************************//* ResetReading() *//************************************************************************/void OGRAVCE00Layer::ResetReading(){ if (psRead) { AVCE00ReadGotoSectionE00(psRead, psSection, 0); } if (psTableRead) { AVCE00ReadGotoSectionE00(psTableRead, psTableSection, 0); } bNeedReset = FALSE; nNextFID = 1;}/************************************************************************//* GetFeature() *//************************************************************************/OGRFeature *OGRAVCE00Layer::GetFeature( long nFID ){/* -------------------------------------------------------------------- *//* If we haven't started yet, open the file now. *//* -------------------------------------------------------------------- */ if( psRead == NULL ) { psRead = AVCE00ReadOpenE00(psSection->pszFilename); if (psRead == NULL) return NULL; /* advance to the specified line number */ if (AVCE00ReadGotoSectionE00(psRead, psSection, 0) != 0) return NULL; nNextFID = 1; }/* -------------------------------------------------------------------- *//* Read the raw feature - the -3 fid is a special flag *//* indicating serial access. *//* -------------------------------------------------------------------- */ void *pFeature; if( nFID == -3 ) { while( (pFeature = AVCE00ReadNextObjectE00(psRead)) != NULL && psRead->hParseInfo->eFileType != AVCFileUnknown && !MatchesSpatialFilter( pFeature ) ) { nNextFID++; } } else { bNeedReset = TRUE; if (nNextFID > nFID) { /* advance to the specified line number */ if (AVCE00ReadGotoSectionE00(psRead, psSection, 0) != 0) return NULL; } do { pFeature = AVCE00ReadNextObjectE00(psRead); ++nNextFID; } while (NULL != pFeature && nNextFID <= nFID); } if( pFeature == NULL ) return NULL;/* -------------------------------------------------------------------- *//* Translate the feature. */ OGRFeature *poFeature; poFeature = TranslateFeature( pFeature ); if( poFeature == NULL ) return NULL;/* -------------------------------------------------------------------- *//* LAB's we have to assign the FID to directly, since it *//* doesn't seem to be stored in the file structure. *//* -------------------------------------------------------------------- */ if( psSection->eType == AVCFileLAB ) { if( nFID == -3 ) poFeature->SetFID( nNextFID++ ); else poFeature->SetFID( nFID ); }/* -------------------------------------------------------------------- *//* If this is a polygon layer, try to assemble the arcs to form *//* the whole polygon geometry. *//* -------------------------------------------------------------------- */ if( psSection->eType == AVCFilePAL || psSection->eType == AVCFileRPL ) { FormPolygonGeometry( poFeature, (AVCPal *) pFeature ); }/* -------------------------------------------------------------------- *//* If we have an attribute table, append the attributes now. *//* -------------------------------------------------------------------- */ AppendTableFields( poFeature ); return poFeature;}/************************************************************************//* GetNextFeature() *//************************************************************************/OGRFeature *OGRAVCE00Layer::GetNextFeature(){ if( bNeedReset ) ResetReading(); OGRFeature *poFeature = GetFeature( -3 ); // Skip universe polygon. if( poFeature != NULL && poFeature->GetFID() == 1 && psSection->eType == AVCFilePAL ) { OGRFeature::DestroyFeature( poFeature ); poFeature = GetFeature( -3 ); } while( poFeature != NULL && ((m_poAttrQuery != NULL && !m_poAttrQuery->Evaluate( poFeature ) ) || !FilterGeometry( poFeature->GetGeometryRef() ) ) ) { OGRFeature::DestroyFeature( poFeature ); poFeature = GetFeature( -3 ); } if( poFeature == NULL ) ResetReading(); return poFeature;}/************************************************************************//* TestCapability() *//************************************************************************/#if 0int OGRAVCE00Layer::TestCapability( const char * pszCap )
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -