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

📄 ogrntfdatasource.cpp

📁 GIS系统支持库Geospatial Data Abstraction Library代码.GDAL is a translator library for raster geospatial dat
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/****************************************************************************** * $Id: ogrntfdatasource.cpp,v 1.15 2002/12/10 04:08:17 warmerda Exp $ * * Project:  UK NTF Reader * Purpose:  Implements OGRNTFDataSource class * Author:   Frank Warmerdam, warmerda@home.com * ****************************************************************************** * Copyright (c) 1999, Frank Warmerdam * * 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: ogrntfdatasource.cpp,v $ * Revision 1.15  2002/12/10 04:08:17  warmerda * updated British National Grid WKT * * Revision 1.14  2002/07/08 16:18:52  warmerda * fix initialization of szCandidateName * * Revision 1.13  2002/07/08 14:49:44  warmerda * added TILE_REF uniquification support * * Revision 1.12  2001/12/12 17:22:15  warmerda * Use CPLStat() instead of VSIStat(). * * Revision 1.11  2001/12/12 02:50:00  warmerda * avoid leaks, and UMC * * Revision 1.10  2001/12/11 20:37:49  warmerda * add option to avoid caching indexed records on multiple readers * * Revision 1.9  2001/07/18 04:55:16  warmerda * added CPL_CSVID * * Revision 1.8  2001/01/19 20:31:12  warmerda * expand tabs * * Revision 1.7  1999/11/04 21:11:37  warmerda * Added TestCapability(). * * 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 "ntf.h"#include "cpl_conv.h"#include "cpl_string.h"CPL_CVSID("$Id: ogrntfdatasource.cpp,v 1.15 2002/12/10 04:08:17 warmerda Exp $");/************************************************************************//*                          OGRNTFDataSource()                          *//************************************************************************/OGRNTFDataSource::OGRNTFDataSource(){    nLayers = 0;    papoLayers = NULL;    nNTFFileCount = 0;    papoNTFFileReader = NULL;    pszName = NULL;    iCurrentReader = -1;    iCurrentFC = 0;    nFCCount = 0;    papszFCNum = NULL;    papszFCName = NULL;    poFCLayer = NULL;    papszOptions = NULL;    poSpatialRef = new OGRSpatialReference( "PROJCS[\"OSGB 1936 / British National Grid\",GEOGCS[\"OSGB 1936\",DATUM[\"OSGB_1936\",SPHEROID[\"Airy 1830\",6377563.396,299.3249646,AUTHORITY[\"EPSG\",\"7001\"]],AUTHORITY[\"EPSG\",\"6277\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.0174532925199433],AUTHORITY[\"EPSG\",\"4277\"]],PROJECTION[\"Transverse_Mercator\"],PARAMETER[\"latitude_of_origin\",49],PARAMETER[\"central_meridian\",-2],PARAMETER[\"scale_factor\",0.999601272],PARAMETER[\"false_easting\",400000],PARAMETER[\"false_northing\",-100000],UNIT[\"metre\",1,AUTHORITY[\"EPSG\",\"9001\"]],AUTHORITY[\"EPSG\",\"27700\"]]" );/* -------------------------------------------------------------------- *//*      Allow initialization of options from the environment.           *//* -------------------------------------------------------------------- */    if( getenv("OGR_NTF_OPTIONS") != NULL )    {        papszOptions =             CSLTokenizeStringComplex( getenv("OGR_NTF_OPTIONS"), ",",                                      FALSE, FALSE );    }}/************************************************************************//*                         ~OGRNTFDataSource()                          *//************************************************************************/OGRNTFDataSource::~OGRNTFDataSource(){    int         i;    for( i = 0; i < nNTFFileCount; i++ )        delete papoNTFFileReader[i];    CPLFree( papoNTFFileReader );    for( i = 0; i < nLayers; i++ )        delete papoLayers[i];    if( poFCLayer != NULL )        delete poFCLayer;        CPLFree( papoLayers );    CPLFree( pszName );    CSLDestroy( papszOptions );    CSLDestroy( papszFCNum );    CSLDestroy( papszFCName );    delete poSpatialRef;}/************************************************************************//*                           TestCapability()                           *//************************************************************************/int OGRNTFDataSource::TestCapability( const char * ){    return FALSE;}/************************************************************************//*                           GetNamedLayer()                            *//************************************************************************/OGRNTFLayer * OGRNTFDataSource::GetNamedLayer( const char * pszName ){    for( int i = 0; i < nLayers; i++ )    {        if( EQUAL(papoLayers[i]->GetLayerDefn()->GetName(),pszName) )            return (OGRNTFLayer *) papoLayers[i];    }    return NULL;}/************************************************************************//*                              AddLayer()                              *//************************************************************************/void OGRNTFDataSource::AddLayer( OGRLayer * poNewLayer ){    papoLayers = (OGRLayer **)        CPLRealloc( papoLayers, sizeof(void*) * ++nLayers );        papoLayers[nLayers-1] = poNewLayer;}/************************************************************************//*                              GetLayer()                              *//************************************************************************/OGRLayer *OGRNTFDataSource::GetLayer( int iLayer ){    if( iLayer < 0 || iLayer > nLayers )        return NULL;    else if( iLayer == nLayers )        return poFCLayer;    else        return papoLayers[iLayer];}/************************************************************************//*                           GetLayerCount()                            *//************************************************************************/int OGRNTFDataSource::GetLayerCount(){    if( poFCLayer == NULL )        return nLayers;    else        return nLayers + 1;}/************************************************************************//*                                Open()                                *//************************************************************************/int OGRNTFDataSource::Open( const char * pszFilename, int bTestOpen,                            char ** papszLimitedFileList ){    VSIStatBuf      stat;    char            **papszFileList = NULL;    pszName = CPLStrdup( pszFilename );/* -------------------------------------------------------------------- *//*      Is the given path a directory or a regular file?                *//* -------------------------------------------------------------------- */    if( CPLStat( pszFilename, &stat ) != 0         || (!VSI_ISDIR(stat.st_mode) && !VSI_ISREG(stat.st_mode)) )    {        if( !bTestOpen )            CPLError( CE_Failure, CPLE_AppDefined,                   "%s is neither a file or directory, NTF access failed.\n",                      pszFilename );        return FALSE;    }    /* -------------------------------------------------------------------- *//*      Build a list of filenames we figure are NTF files.              *//* -------------------------------------------------------------------- */    if( VSI_ISREG(stat.st_mode) )    {        papszFileList = CSLAddString( NULL, pszFilename );    }    else    {        char      **candidateFileList = CPLReadDir( pszFilename );        int         i;        for( i = 0;              candidateFileList != NULL && candidateFileList[i] != NULL;              i++ )         {            if( papszLimitedFileList != NULL                && CSLFindString(papszLimitedFileList,                                 candidateFileList[i]) == -1 )            {                continue;            }                        if( strlen(candidateFileList[i]) > 4              && EQUALN(candidateFileList[i] + strlen(candidateFileList[i])-4,                       ".ntf",4) )            {                char       fullFilename[2048];                sprintf( fullFilename, "%s%c%s",                          pszFilename,#ifdef WIN32                         '\\',#else                         '/',#endif                         candidateFileList[i] );                papszFileList = CSLAddString( papszFileList, fullFilename );            }        }        CSLDestroy( candidateFileList );        if( CSLCount(papszFileList) == 0 )        {            if( !bTestOpen )                CPLError( CE_Failure, CPLE_OpenFailed,                          "No candidate NTF files (.ntf) found in\n"                          "directory: %s",                          pszFilename );

⌨️ 快捷键说明

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