⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ogrtigerdatasource.cpp

📁 GIS系统支持库Geospatial Data Abstraction Library代码.GDAL is a translator library for raster geospatial dat
💻 CPP
📖 第 1 页 / 共 3 页
字号:
/****************************************************************************** * $Id: ogrtigerdatasource.cpp,v 1.31 2004/09/22 16:17:06 fwarmerdam Exp $ * * Project:  TIGER/Line Translator * Purpose:  Implements OGRTigerDataSource class * Author:   Frank Warmerdam, warmerdam@pobox.com * ****************************************************************************** * Copyright (c) 1999, Frank Warmerdam <warmerdam@pobox.com> * * 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. ****************************************************************************** * * $Log: ogrtigerdatasource.cpp,v $ * Revision 1.31  2004/09/22 16:17:06  fwarmerdam * Make GDT support work even if version number seems weird. * * Revision 1.30  2004/08/17 20:54:00  warmerda * Avoid out-of-buffer read for very short filenames. * * Revision 1.29  2004/02/12 16:00:41  warmerda * weaken test for candidate files so all Dynamap files found * * Revision 1.28  2004/02/12 06:39:16  warmerda * added preliminary support for some GDT quirks * * Revision 1.27  2003/11/05 20:57:19  warmerda * Added special hack mapping versioncodde 9999 to UA2000 for FME * bug 7625. * * Revision 1.26  2003/11/05 18:41:07  warmerda * added TIGER_VERSION setting to override file type on read * * Revision 1.25  2003/10/15 19:04:44  warmerda * fix a couple memory leaks * * Revision 1.24  2003/08/27 02:26:56  warmerda * fixed overlap in 2002/2003 version classification * * Revision 1.23  2003/08/18 14:47:53  warmerda * upgraded with *untested* TIGER 2003 support * * Revision 1.22  2003/03/20 19:10:37  warmerda * fixed memory leak * * Revision 1.21  2003/02/27 16:02:46  warmerda * Handle case with filename without path properly in BuildFilename(). * * Revision 1.20  2003/01/13 17:06:10  warmerda * added support for a single county as a dataset * * Revision 1.19  2003/01/11 15:29:55  warmerda * expanded tabs * * Revision 1.18  2003/01/04 23:21:56  mbp * Minor bug fixes and field definition changes.  Cleaned * up and commented code written for TIGER 2002 support. * * Revision 1.17  2002/12/28 05:18:59  warmerda * Loosen candidate file constraints in Open() to include TST* files. * * Revision 1.16  2002/12/26 00:20:19  mbp * re-organized code to hold TIGER-version details in TigerRecordInfo structs; * first round implementation of TIGER_2002 support * * Revision 1.15  2001/12/12 17:25:07  warmerda * Use CPLStat instead of VSIStat. * * Revision 1.14  2001/07/19 16:58:39  warmerda * ensure version initialized, even if not testopen * * Revision 1.13  2001/07/19 16:05:49  warmerda * clear out tabs * * Revision 1.12  2001/07/19 16:03:11  warmerda * allow VERSION override on write * * Revision 1.11  2001/07/19 13:26:32  warmerda * enable override of existing modules * * Revision 1.10  2001/07/18 04:55:16  warmerda * added CPL_CSVID * * Revision 1.9  2001/07/04 23:25:32  warmerda * first round implementation of writer * * Revision 1.8  2001/07/04 05:40:35  warmerda * upgraded to support FILE, and Tiger2000 schema * * Revision 1.7  2001/01/19 21:15:20  warmerda * expanded tabs * * Revision 1.6  2000/01/13 16:39:17  warmerda * Use CPLGetBasename() to compare to limitedFileList. * * Revision 1.5  2000/01/13 05:18:11  warmerda * added support for multiple versions * * Revision 1.4  1999/12/22 15:38:15  warmerda * major update * * Revision 1.3  1999/12/15 19:59:52  warmerda * added new file types * * Revision 1.2  1999/11/04 21:14:31  warmerda * various improvements, and TestCapability() * * Revision 1.1  1999/10/07 18:19:21  warmerda * New * * Revision 1.6  1999/10/04 03:08:52  warmerda * added raster support * * Revision 1.5  1999/10/01 14:47:51  warmerda * major upgrade: generic, string feature codes, etc * * Revision 1.4  1999/09/29 16:43:43  warmerda * added spatial ref, improved test open for non-os files * * Revision 1.3  1999/09/08 00:58:40  warmerda * Added limiting list of files for FME. * * Revision 1.2  1999/08/30 16:49:26  warmerda * added feature class layer support * * Revision 1.1  1999/08/28 03:13:35  warmerda * New */#include "ogr_tiger.h"#include "cpl_conv.h"#include "cpl_string.h"#include <ctype.h>CPL_CVSID("$Id: ogrtigerdatasource.cpp,v 1.31 2004/09/22 16:17:06 fwarmerdam Exp $");/************************************************************************//*                        TigerClassifyVersion()                        *//************************************************************************/TigerVersion TigerClassifyVersion( int nVersionCode ){    TigerVersion        nVersion;    int                 nYear, nMonth;/*** TIGER Versions**** 0000           TIGER/Line Precensus Files, 1990 ** 0002           TIGER/Line Initial Voting District Codes Files, 1990 ** 0003           TIGER/Line Files, 1990 ** 0005           TIGER/Line Files, 1992 ** 0021           TIGER/Line Files, 1994 ** 0024           TIGER/Line Files, 1995 ** 9706 to 9810   TIGER/Line Files, 1997 ** 9812 to 9904   TIGER/Line Files, 1998 ** 0006 to 0008   TIGER/Line Files, 1999 ** 0010 to 0011   TIGER/Line Files, Redistricting Census 2000** 0103 to 0108   TIGER/Line Files, Census 2000**** 0203 to 0205   TIGER/Line Files, UA 2000** ????    ????**** 0206 to 0299   TIGER/Line Files, 2002** 0300 and up    TIGER/Line Files, 2003** ????*/    nVersion = TIGER_Unknown;    if( nVersionCode == 0 )        nVersion = TIGER_1990_Precensus;    else if( nVersionCode == 2 )        nVersion = TIGER_1990;    else if( nVersionCode == 3 )        nVersion = TIGER_1992;    else if( nVersionCode == 5 )        nVersion = TIGER_1994;    else if( nVersionCode == 21 )        nVersion = TIGER_1994;    else if( nVersionCode == 24 )        nVersion = TIGER_1995;    else if( nVersionCode == 9999 )  /* special hack, fme bug 7625 */        nVersion = TIGER_UA2000;    nYear = nVersionCode % 100;    nMonth = nVersionCode / 100;    nVersionCode = nYear * 100 + nMonth;    if( nVersion != TIGER_Unknown )        /* do nothing */;    else if( nVersionCode >= 9706 && nVersionCode <= 9810 )        nVersion = TIGER_1997;    else if( nVersionCode >= 9812 && nVersionCode <= 9904 )        nVersion = TIGER_1998;    else if( nVersionCode >=    6 /*0006*/ && nVersionCode <=    8 /*0008*/ )        nVersion = TIGER_1999;    else if( nVersionCode >=   10 /*0010*/ && nVersionCode <=   11 /*0011*/ )        nVersion = TIGER_2000_Redistricting;    else if( nVersionCode >=  103 /*0103*/ && nVersionCode <=  108 /*0108*/ )        nVersion = TIGER_2000_Census;    else if( nVersionCode >=  203 /*0203*/ && nVersionCode <=  205 /*0205*/ )        nVersion = TIGER_UA2000;    else if( nVersionCode >=  206 /*0206*/ && nVersionCode < 300 /* 2003 */ )        nVersion = TIGER_2002;    else if( nVersionCode >=  300 /*0300*/ )        nVersion = TIGER_2003;    return nVersion;}/************************************************************************//*                         TigerVersionString()                         *//************************************************************************/char * TigerVersionString( TigerVersion nVersion ){  if (nVersion == TIGER_1990_Precensus) { return "TIGER_1990_Precensus"; }  if (nVersion == TIGER_1990) { return "TIGER_1990"; }  if (nVersion == TIGER_1992) { return "TIGER_1992"; }  if (nVersion == TIGER_1994) { return "TIGER_1994"; }  if (nVersion == TIGER_1995) { return "TIGER_1995"; }  if (nVersion == TIGER_1997) { return "TIGER_1997"; }  if (nVersion == TIGER_1998) { return "TIGER_1998"; }  if (nVersion == TIGER_1999) { return "TIGER_1999"; }  if (nVersion == TIGER_2000_Redistricting) { return "TIGER_2000_Redistricting"; }  if (nVersion == TIGER_UA2000) { return "TIGER_UA2000"; }  if (nVersion == TIGER_2002) { return "TIGER_2002"; }  if (nVersion == TIGER_2003) { return "TIGER_2003"; }  if (nVersion == TIGER_Unknown) { return "TIGER_Unknown"; }  return "???";}/************************************************************************//*                         OGRTigerDataSource()                         *//************************************************************************/OGRTigerDataSource::OGRTigerDataSource(){    bWriteMode = FALSE;    nLayers = 0;    papoLayers = NULL;    nModules = 0;    papszModules = NULL;    pszName = NULL;    pszPath = NULL;    papszOptions = NULL;    poSpatialRef = new OGRSpatialReference( "GEOGCS[\"NAD83\",DATUM[\"North_American_Datum_1983\",SPHEROID[\"GRS 1980\",6378137,298.257222101]],PRIMEM[\"Greenwich\",0],UNIT[\"degree\",0.0174532925199433]]" );}/************************************************************************//*                        ~OGRTigerDataSource()                         *//************************************************************************/OGRTigerDataSource::~OGRTigerDataSource(){    int         i;    for( i = 0; i < nLayers; i++ )        delete papoLayers[i];        CPLFree( papoLayers );    CPLFree( pszName );    CPLFree( pszPath );    CSLDestroy( papszOptions );    CSLDestroy( papszModules );    delete poSpatialRef;}/************************************************************************//*                              AddLayer()                              *//************************************************************************/void OGRTigerDataSource::AddLayer( OGRTigerLayer * poNewLayer ){    papoLayers = (OGRTigerLayer **)        CPLRealloc( papoLayers, sizeof(void*) * ++nLayers );        papoLayers[nLayers-1] = poNewLayer;}/************************************************************************//*                              GetLayer()                              *//************************************************************************/OGRLayer *OGRTigerDataSource::GetLayer( int iLayer ){    if( iLayer < 0 || iLayer >= nLayers )        return NULL;    else        return papoLayers[iLayer];}/************************************************************************//*                              GetLayer()                              *//************************************************************************/OGRLayer *OGRTigerDataSource::GetLayer( const char *pszLayerName ){    for( int iLayer = 0; iLayer < nLayers; iLayer++ )    {        if( EQUAL(papoLayers[iLayer]->GetLayerDefn()->GetName(),pszLayerName) )            return papoLayers[iLayer];    }    return NULL;}/************************************************************************/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -