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

📄 s57reader.cpp

📁 GIS系统支持库Geospatial Data Abstraction Library代码.GDAL is a translator library for raster geospatial dat
💻 CPP
📖 第 1 页 / 共 5 页
字号:
/****************************************************************************** * $Id: s57reader.cpp,v 1.49 2004/08/30 20:10:38 warmerda Exp $ * * Project:  S-57 Translator * Purpose:  Implements S57Reader class. * Author:   Frank Warmerdam, warmerdam@pobox.com * ****************************************************************************** * Copyright (c) 1999, 2001, 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: s57reader.cpp,v $ * Revision 1.49  2004/08/30 20:10:38  warmerda * implemented FetchLine() with optimized access * * Revision 1.48  2004/08/27 20:23:11  warmerda * fixed up a bit of formatting * * Revision 1.47  2004/06/24 00:37:12  warmerda * fixed S57M_OPTIONS logic, support deleting attributes * * Revision 1.46  2004/06/23 19:46:51  warmerda * fixed logic of APPLY updates logic * * Revision 1.45  2004/06/01 14:51:19  warmerda * expand tabs * * Revision 1.44  2003/11/17 20:10:46  warmerda * added support for writing FFPT linkages * * Revision 1.43  2003/11/12 21:23:40  warmerda * updates to new featuredefn generators * * Revision 1.42  2003/09/15 20:53:06  warmerda * fleshed out feature writing * * Revision 1.41  2003/09/12 21:18:06  warmerda * fixed width of AGEN field * * Revision 1.40  2003/09/09 18:11:17  warmerda * capture TOPI field from VRPT * * Revision 1.39  2003/09/09 16:44:51  warmerda * fix sounding support in ReadVector() * * Revision 1.38  2003/09/05 19:12:05  warmerda * added RETURN_PRIMITIVES support to get low level prims * * Revision 1.37  2003/01/02 21:45:23  warmerda * move OGRBuildPolygonsFromEdges into C API * * Revision 1.36  2002/10/28 22:31:00  warmerda * allow wkbMultiPoint25D for SOUNDG * * Revision 1.35  2002/05/14 20:34:27  warmerda * added PRESERVE_EMPTY_NUMBERS support * * Revision 1.34  2002/03/05 14:25:43  warmerda * expanded tabs * * Revision 1.33  2002/02/22 22:23:38  warmerda * added tolerances when assembling polygons * * Revision 1.32  2001/12/19 22:44:53  warmerda * added ADD_SOUNDG_DEPTH support * * Revision 1.31  2001/12/17 22:36:12  warmerda * added readFeature() method * * Revision 1.30  2001/12/14 19:40:18  warmerda * added optimized feature counting, and extents collection * * Revision 1.29  2001/09/12 17:09:44  warmerda * add auto-update support * * Revision 1.28  2001/09/04 16:21:11  warmerda * improved handling of corrupt line geometries * * Revision 1.27  2001/08/30 21:18:35  warmerda * removed debug info * * Revision 1.26  2001/08/30 21:06:55  warmerda * expand tabs * * Revision 1.25  2001/08/30 21:05:32  warmerda * added support for generic object if not recognised * * Revision 1.24  2001/08/30 14:55:23  warmerda * Treat SAT_LIST attributes as strings. * * Revision 1.23  2001/08/30 03:48:43  warmerda * preliminary implementation of S57 Update Support * * Revision 1.22  2001/07/18 04:55:16  warmerda * added CPL_CSVID * * Revision 1.21  2001/01/22 18:00:03  warmerda * Don't completely flip out if there is other than one spatial linkage for * in AssemblePointGeometry().  Record 577 of CA49995B.000 (newfiles) has this. * * Revision 1.20  2000/09/28 16:30:31  warmerda * avoid warnings * * Revision 1.19  2000/09/13 19:19:24  warmerda * added checking on NATF:ATTL values * * Revision 1.18  2000/06/16 18:10:05  warmerda * expanded tabs * * Revision 1.17  2000/06/16 18:00:58  warmerda * Fixed AssembleArea() to support multiple FSPT fields * * Revision 1.16  2000/06/07 21:34:04  warmerda * fixed problem with corrupt datasets with an ATTL value of zero * * Revision 1.15  1999/12/22 15:37:05  warmerda * removed abort * * Revision 1.14  1999/11/26 19:09:29  warmerda * Swapped XY for soundings. * * Revision 1.13  1999/11/26 16:17:58  warmerda * added DSNM * * Revision 1.12  1999/11/26 15:20:54  warmerda * Fixed multipoint. * * Revision 1.11  1999/11/26 15:17:01  warmerda * fixed lname to lnam * * Revision 1.10  1999/11/26 15:08:38  warmerda * added setoptions, and LNAM support * * Revision 1.9  1999/11/26 13:50:34  warmerda * added NATF support * * Revision 1.8  1999/11/26 13:26:03  warmerda * fixed up sounding support * * Revision 1.7  1999/11/25 20:53:49  warmerda * added sounding and S57_SPLIT_MULTIPOINT support * * Revision 1.6  1999/11/18 19:01:25  warmerda * expanded tabs * * Revision 1.5  1999/11/18 18:58:16  warmerda * make permissive of missing geometry so that update files work * * Revision 1.4  1999/11/16 21:47:32  warmerda * updated class occurance collection * * Revision 1.3  1999/11/08 22:23:00  warmerda * added object class support * * Revision 1.2  1999/11/04 21:19:13  warmerda * added polygon support * * Revision 1.1  1999/11/03 22:12:43  warmerda * New * */#include "s57.h"#include "ogr_api.h"#include "cpl_conv.h"#include "cpl_string.h"CPL_CVSID("$Id: s57reader.cpp,v 1.49 2004/08/30 20:10:38 warmerda Exp $");/************************************************************************//*                             S57Reader()                              *//************************************************************************/S57Reader::S57Reader( const char * pszFilename ){    pszModuleName = CPLStrdup( pszFilename );    pszDSNM = NULL;    poModule = NULL;    nFDefnCount = 0;    papoFDefnList = NULL;    nCOMF = 1000000;    nSOMF = 10;    poRegistrar = NULL;    bFileIngested = FALSE;    nNextFEIndex = 0;    nNextVIIndex = 0;    nNextVCIndex = 0;    nNextVEIndex = 0;    nNextVFIndex = 0;    iPointOffset = 0;    poMultiPoint = NULL;    papszOptions = NULL;    nOptionFlags = S57M_UPDATES;    bMissingWarningIssued = FALSE;    bAttrWarningIssued = FALSE;    memset( apoFDefnByOBJL, 0, sizeof(apoFDefnByOBJL) );}/************************************************************************//*                             ~S57Reader()                             *//************************************************************************/S57Reader::~S57Reader(){    Close();        CPLFree( pszModuleName );    CSLDestroy( papszOptions );}/************************************************************************//*                                Open()                                *//************************************************************************/int S57Reader::Open( int bTestOpen ){    if( poModule != NULL )    {        Rewind();        return TRUE;    }    poModule = new DDFModule();    if( !poModule->Open( pszModuleName ) )    {        // notdef: test bTestOpen.        delete poModule;        poModule = NULL;        return FALSE;    }    // note that the following won't work for catalogs.    if( poModule->FindFieldDefn("DSID") == NULL )    {        if( !bTestOpen )        {            CPLError( CE_Failure, CPLE_AppDefined,                      "%s is an ISO8211 file, but not an S-57 data file.\n",                      pszModuleName );        }        delete poModule;        poModule = NULL;        return FALSE;    }    // Make sure the FSPT field is marked as repeating.    DDFFieldDefn *poFSPT = poModule->FindFieldDefn( "FSPT" );    if( poFSPT != NULL && !poFSPT->IsRepeating() )    {        CPLDebug( "S57", "Forcing FSPT field to be repeating." );        poFSPT->SetRepeatingFlag( TRUE );    }    nNextFEIndex = 0;    nNextVIIndex = 0;    nNextVCIndex = 0;    nNextVEIndex = 0;    nNextVFIndex = 0;        return TRUE;}/************************************************************************//*                               Close()                                *//************************************************************************/void S57Reader::Close(){    if( poModule != NULL )    {        oVI_Index.Clear();        oVC_Index.Clear();        oVE_Index.Clear();        oVF_Index.Clear();        oFE_Index.Clear();        ClearPendingMultiPoint();        delete poModule;        poModule = NULL;        bFileIngested = FALSE;        CPLFree( pszDSNM );        pszDSNM = NULL;    }}/************************************************************************//*                       ClearPendingMultiPoint()                       *//************************************************************************/void S57Reader::ClearPendingMultiPoint(){    if( poMultiPoint != NULL )    {        delete poMultiPoint;        poMultiPoint = NULL;    }}/************************************************************************//*                       NextPendingMultiPoint()                        *//************************************************************************/OGRFeature *S57Reader::NextPendingMultiPoint(){    CPLAssert( poMultiPoint != NULL );    CPLAssert( wkbFlatten(poMultiPoint->GetGeometryRef()->getGeometryType())                                                        == wkbMultiPoint );    OGRFeatureDefn *poDefn = poMultiPoint->GetDefnRef();    OGRFeature  *poPoint = new OGRFeature( poDefn );    OGRMultiPoint *poMPGeom = (OGRMultiPoint *) poMultiPoint->GetGeometryRef();    OGRPoint    *poSrcPoint;    poPoint->SetFID( poMultiPoint->GetFID() );        for( int i = 0; i < poDefn->GetFieldCount(); i++ )    {        poPoint->SetField( i, poMultiPoint->GetRawFieldRef(i) );    }    poSrcPoint = (OGRPoint *) poMPGeom->getGeometryRef( iPointOffset++ );    poPoint->SetGeometry( poSrcPoint );    if( poPoint != NULL )        poPoint->SetField( "DEPTH", poSrcPoint->getZ() );    if( iPointOffset >= poMPGeom->getNumGeometries() )        ClearPendingMultiPoint();    return poPoint;}/************************************************************************/

⌨️ 快捷键说明

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