LTP GCOV extension - code coverage report
Current view: directory - ogr/ogrsf_frmts/s57 - s57.h
Test: gdal_filtered.info
Date: 2010-07-12 Instrumented lines: 6
Code covered: 100.0 % Executed lines: 6

       1                 : /******************************************************************************
       2                 :  * $Id: s57.h 11537 2007-05-16 03:35:17Z warmerdam $
       3                 :  *
       4                 :  * Project:  S-57 Translator
       5                 :  * Purpose:  Declarations for S-57 translator not including the
       6                 :  *           binding onto OGRLayer/DataSource/Driver which are found in
       7                 :  *           ogr_s57.h.
       8                 :  * Author:   Frank Warmerdam, warmerdam@pobox.com
       9                 :  *
      10                 :  ******************************************************************************
      11                 :  * Copyright (c) 1999, Frank Warmerdam
      12                 :  *
      13                 :  * Permission is hereby granted, free of charge, to any person obtaining a
      14                 :  * copy of this software and associated documentation files (the "Software"),
      15                 :  * to deal in the Software without restriction, including without limitation
      16                 :  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
      17                 :  * and/or sell copies of the Software, and to permit persons to whom the
      18                 :  * Software is furnished to do so, subject to the following conditions:
      19                 :  *
      20                 :  * The above copyright notice and this permission notice shall be included
      21                 :  * in all copies or substantial portions of the Software.
      22                 :  *
      23                 :  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
      24                 :  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
      25                 :  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
      26                 :  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
      27                 :  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
      28                 :  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
      29                 :  * DEALINGS IN THE SOFTWARE.
      30                 :  ****************************************************************************/
      31                 : 
      32                 : #ifndef _S57_H_INCLUDED
      33                 : #define _S57_H_INCLUDED
      34                 : 
      35                 : #include "ogr_feature.h"
      36                 : #include "iso8211.h"
      37                 : 
      38                 : class S57Reader;
      39                 : 
      40                 : char **S57FileCollector( const char * pszDataset );
      41                 : 
      42                 : #define EMPTY_NUMBER_MARKER 2147483641  /* MAXINT-6 */
      43                 : 
      44                 : /* -------------------------------------------------------------------- */
      45                 : /*      Various option strings.                                         */
      46                 : /* -------------------------------------------------------------------- */
      47                 : #define S57O_UPDATES "UPDATES"
      48                 : #define S57O_LNAM_REFS "LNAM_REFS"
      49                 : #define S57O_SPLIT_MULTIPOINT "SPLIT_MULTIPOINT"
      50                 : #define S57O_ADD_SOUNDG_DEPTH "ADD_SOUNDG_DEPTH"
      51                 : #define S57O_PRESERVE_EMPTY_NUMBERS "PRESERVE_EMPTY_NUMBERS"
      52                 : #define S57O_RETURN_PRIMITIVES "RETURN_PRIMITIVES"
      53                 : #define S57O_RETURN_LINKAGES "RETURN_LINKAGES"
      54                 : #define S57O_RETURN_DSID     "RETURN_DSID"
      55                 : 
      56                 : #define S57M_UPDATES                    0x01
      57                 : #define S57M_LNAM_REFS                  0x02
      58                 : #define S57M_SPLIT_MULTIPOINT           0x04
      59                 : #define S57M_ADD_SOUNDG_DEPTH           0x08
      60                 : #define S57M_PRESERVE_EMPTY_NUMBERS     0x10
      61                 : #define S57M_RETURN_PRIMITIVES          0x20
      62                 : #define S57M_RETURN_LINKAGES            0x40
      63                 : #define S57M_RETURN_DSID                0x80
      64                 : 
      65                 : /* -------------------------------------------------------------------- */
      66                 : /*      RCNM values.                                                    */
      67                 : /* -------------------------------------------------------------------- */
      68                 : 
      69                 : #define RCNM_FE         100     /* Feature record */
      70                 : 
      71                 : #define RCNM_VI         110     /* Isolated Node */
      72                 : #define RCNM_VC         120     /* Connected Node */
      73                 : #define RCNM_VE         130     /* Edge */
      74                 : #define RCNM_VF         140     /* Face */
      75                 : 
      76                 : #define RCNM_DSID       10
      77                 : 
      78                 : #define OGRN_VI         "IsolatedNode"
      79                 : #define OGRN_VC         "ConnectedNode"
      80                 : #define OGRN_VE         "Edge"
      81                 : #define OGRN_VF         "Face"
      82                 : 
      83                 : /* -------------------------------------------------------------------- */
      84                 : /*      FRID PRIM values.                                               */
      85                 : /* -------------------------------------------------------------------- */
      86                 : #define PRIM_P          1       /* point feature */
      87                 : #define PRIM_L          2       /* line feature */
      88                 : #define PRIM_A          3       /* area feature */
      89                 : #define PRIM_N          4       /* non-spatial feature  */
      90                 : 
      91                 : /************************************************************************/
      92                 : /*                          S57ClassRegistrar                           */
      93                 : /************************************************************************/
      94                 : 
      95                 : #define MAX_CLASSES 23000
      96                 : #define MAX_ATTRIBUTES 25000
      97                 : 
      98                 : class CPL_DLL S57ClassRegistrar
      99                 : {
     100                 :     // Class information:
     101                 :     int         nClasses;
     102                 :     char      **papszClassesInfo;
     103                 :     char     ***papapszClassesFields;
     104                 : 
     105                 :     int         iCurrentClass;
     106                 : 
     107                 :     char      **papszCurrentFields;
     108                 : 
     109                 :     char      **papszTempResult;
     110                 : 
     111                 :     // Attribute Information:
     112                 :     int         nAttrMax;
     113                 :     int         nAttrCount;
     114                 :     char      **papszAttrNames;
     115                 :     char      **papszAttrAcronym;
     116                 :     char     ***papapszAttrValues;
     117                 :     char       *pachAttrType;
     118                 :     char       *pachAttrClass;
     119                 :     int        *panAttrIndex; // sorted by acronym.
     120                 : 
     121                 :     int         FindFile( const char *pszTarget, const char *pszDirectory,
     122                 :                           int bReportErr, FILE **fp );
     123                 : 
     124                 :     const char *ReadLine( FILE * fp );
     125                 :     char      **papszNextLine;
     126                 : 
     127                 : public:
     128                 :                 S57ClassRegistrar();
     129                 :                ~S57ClassRegistrar();
     130                 : 
     131                 :     int         LoadInfo( const char *, const char *, int );
     132                 : 
     133                 :     // class table methods.
     134                 :     int         SelectClassByIndex( int );
     135                 :     int         SelectClass( int );
     136                 :     int         SelectClass( const char * );
     137                 : 
     138                 :     int         Rewind() { return SelectClassByIndex(0); }
     139                 :     int         NextClass() { return SelectClassByIndex(iCurrentClass+1); }
     140                 : 
     141                 :     int         GetOBJL();
     142                 :     const char *GetDescription();
     143                 :     const char *GetAcronym();
     144                 : 
     145                 :     char      **GetAttributeList( const char * = NULL );
     146                 : 
     147                 :     char        GetClassCode();
     148                 :     char      **GetPrimitives();
     149                 : 
     150                 :     // attribute table methods.
     151               4 :     int         GetMaxAttrIndex() { return nAttrMax; }
     152                 :     const char *GetAttrName( int i ) { return papszAttrNames[i]; }
     153               4 :     const char *GetAttrAcronym( int i ) { return papszAttrAcronym[i]; }
     154                 :     char      **GetAttrValues( int i ) { return papapszAttrValues[i]; }
     155             553 :     char        GetAttrType( int i ) { return pachAttrType[i]; }
     156                 : #define SAT_ENUM        'E'
     157                 : #define SAT_LIST        'L'
     158                 : #define SAT_FLOAT       'F'
     159                 : #define SAT_INT         'I'
     160                 : #define SAT_CODE_STRING 'A'
     161                 : #define SAT_FREE_TEXT   'S'
     162                 : 
     163                 :     char        GetAttrClass( int i ) { return pachAttrClass[i]; }
     164                 :     int         FindAttrByAcronym( const char * );
     165                 : 
     166                 : };
     167                 : 
     168                 : /************************************************************************/
     169                 : /*                            DDFRecordIndex                            */
     170                 : /*                                                                      */
     171                 : /*      Maintain an index of DDF records based on an integer key.       */
     172                 : /************************************************************************/
     173                 : 
     174                 : typedef struct
     175                 : {
     176                 :     int         nKey;
     177                 :     DDFRecord   *poRecord;
     178                 :     void        *pClientData;
     179                 : } DDFIndexedRecord;
     180                 : 
     181                 : class CPL_DLL DDFRecordIndex
     182                 : {
     183                 :     int         bSorted;
     184                 : 
     185                 :     int         nRecordCount;
     186                 :     int         nRecordMax;
     187                 : 
     188                 :     int         nLastObjlPos;            /* rjensen. added for FindRecordByObjl() */
     189                 :     int         nLastObjl;                  /* rjensen. added for FindRecordByObjl() */
     190                 : 
     191                 :     DDFIndexedRecord *pasRecords;
     192                 : 
     193                 :     void        Sort();
     194                 : 
     195                 : public:
     196                 :                 DDFRecordIndex();
     197                 :                ~DDFRecordIndex();
     198                 : 
     199                 :     void        AddRecord( int nKey, DDFRecord * );
     200                 :     int         RemoveRecord( int nKey );
     201                 : 
     202                 :     DDFRecord  *FindRecord( int nKey );
     203                 : 
     204                 :     DDFRecord  *FindRecordByObjl( int nObjl );    /* rjensen. added for FindRecordByObjl() */
     205                 : 
     206                 :     void        Clear();
     207                 : 
     208             378 :     int         GetCount() { return nRecordCount; }
     209                 : 
     210                 :     DDFRecord  *GetByIndex( int i );
     211                 :     void        *GetClientInfoByIndex( int i );
     212                 :     void        SetClientInfoByIndex( int i, void *pClientInfo );
     213                 : };
     214                 : 
     215                 : /************************************************************************/
     216                 : /*                              S57Reader                               */
     217                 : /************************************************************************/
     218                 : 
     219                 : class CPL_DLL S57Reader
     220                 : {
     221                 :     S57ClassRegistrar  *poRegistrar;
     222                 : 
     223                 :     int                 nFDefnCount;
     224                 :     OGRFeatureDefn      **papoFDefnList;
     225                 : 
     226                 :     OGRFeatureDefn      *apoFDefnByOBJL[MAX_CLASSES];
     227                 : 
     228                 :     char                *pszModuleName;
     229                 :     char                *pszDSNM;
     230                 : 
     231                 :     DDFModule           *poModule;
     232                 : 
     233                 :     int                 nCOMF;  /* Coordinate multiplier */
     234                 :     int                 nSOMF;  /* Vertical (sounding) multiplier */
     235                 : 
     236                 :     int                 bFileIngested;
     237                 :     DDFRecordIndex      oVI_Index;
     238                 :     DDFRecordIndex      oVC_Index;
     239                 :     DDFRecordIndex      oVE_Index;
     240                 :     DDFRecordIndex      oVF_Index;
     241                 : 
     242                 :     int                 nNextVIIndex;
     243                 :     int                 nNextVCIndex;
     244                 :     int                 nNextVEIndex;
     245                 :     int                 nNextVFIndex;
     246                 : 
     247                 :     int                 nNextFEIndex;
     248                 :     DDFRecordIndex      oFE_Index;
     249                 : 
     250                 :     int                 nNextDSIDIndex;
     251                 :     DDFRecord           *poDSIDRecord;
     252                 :     DDFRecord           *poDSPMRecord;
     253                 :     char                szUPDNUpdate[10];
     254                 : 
     255                 :     char                **papszOptions;
     256                 : 
     257                 :     int                 nOptionFlags; 
     258                 : 
     259                 :     int                 iPointOffset;
     260                 :     OGRFeature          *poMultiPoint;
     261                 : 
     262                 :     void                ClearPendingMultiPoint();
     263                 :     OGRFeature         *NextPendingMultiPoint();
     264                 : 
     265                 :     OGRFeature         *AssembleFeature( DDFRecord  *, OGRFeatureDefn * );
     266                 : 
     267                 :     void                ApplyObjectClassAttributes( DDFRecord *, OGRFeature *);
     268                 :     void                GenerateLNAMAndRefs( DDFRecord *, OGRFeature * );
     269                 :     void                GenerateFSPTAttributes( DDFRecord *, OGRFeature * );
     270                 : 
     271                 :     void                AssembleSoundingGeometry( DDFRecord *, OGRFeature * );
     272                 :     void                AssemblePointGeometry( DDFRecord *, OGRFeature * );
     273                 :     void                AssembleLineGeometry( DDFRecord *, OGRFeature * );
     274                 :     void                AssembleAreaGeometry( DDFRecord *, OGRFeature * );
     275                 : 
     276                 :     int                 FetchPoint( int, int,
     277                 :                                     double *, double *, double * = NULL );
     278                 :     int                 FetchLine( DDFRecord *, int, int, OGRLineString * );
     279                 : 
     280                 :     OGRFeatureDefn     *FindFDefn( DDFRecord * );
     281                 :     int                 ParseName( DDFField *, int = 0, int * = NULL );
     282                 : 
     283                 :     int                 ApplyRecordUpdate( DDFRecord *, DDFRecord * );
     284                 : 
     285                 :     int                 bMissingWarningIssued;
     286                 :     int                 bAttrWarningIssued;
     287                 : 
     288                 :   public:
     289                 :                         S57Reader( const char * );
     290                 :                        ~S57Reader();
     291                 : 
     292                 :     void                SetClassBased( S57ClassRegistrar * );
     293                 :     void                SetOptions( char ** );
     294              39 :     int                 GetOptionFlags() { return nOptionFlags; }
     295                 : 
     296                 :     int                 Open( int bTestOpen );
     297                 :     void                Close();
     298               6 :     DDFModule           *GetModule() { return poModule; }
     299                 :     const char          *GetDSNM() { return pszDSNM; }
     300                 : 
     301                 :     int                 Ingest();
     302                 :     int                 ApplyUpdates( DDFModule * );
     303                 :     int                 FindAndApplyUpdates( const char *pszPath=NULL );
     304                 : 
     305                 :     void                Rewind();
     306                 :     OGRFeature          *ReadNextFeature( OGRFeatureDefn * = NULL );
     307                 :     OGRFeature          *ReadFeature( int nFID, OGRFeatureDefn * = NULL );
     308                 :     OGRFeature          *ReadVector( int nFID, int nRCNM );
     309                 :     OGRFeature          *ReadDSID( void );
     310                 : 
     311                 :     int                 GetNextFEIndex( int nRCNM = 100 );
     312                 :     void                SetNextFEIndex( int nNewIndex, int nRCNM = 100 );
     313                 : 
     314                 :     void                AddFeatureDefn( OGRFeatureDefn * );
     315                 : 
     316                 :     int                 CollectClassList( int *, int);
     317                 : 
     318                 :     OGRErr              GetExtent( OGREnvelope *psExtent, int bForce );
     319                 :  };
     320                 : 
     321                 : /************************************************************************/
     322                 : /*                              S57Writer                               */
     323                 : /************************************************************************/
     324                 : 
     325                 : class CPL_DLL S57Writer
     326                 : {
     327                 : public:
     328                 :                         S57Writer();
     329                 :                         ~S57Writer();
     330                 : 
     331                 :     void                SetClassBased( S57ClassRegistrar * );
     332                 :     int                 CreateS57File( const char *pszFilename );
     333                 :     int                 Close();
     334                 : 
     335                 :     int                 WriteGeometry( DDFRecord *, int, double *, double *,
     336                 :                                        double * );
     337                 :     int                 WriteATTF( DDFRecord *, OGRFeature * );
     338                 :     int                 WritePrimitive( OGRFeature *poFeature );
     339                 :     int                 WriteCompleteFeature( OGRFeature *poFeature );
     340                 :     int                 WriteDSID( const char *pszDSNM = NULL, 
     341                 :                                    const char *pszISDT = NULL, 
     342                 :                                    const char *pszSTED = NULL,
     343                 :                                    int nAGEN = 0,
     344                 :                                    const char *pszCOMT = NULL );
     345                 :     int                 WriteDSPM( int nScale = 0 );
     346                 : 
     347                 : // semi-private - for sophisticated writers.
     348                 :     DDFRecord           *MakeRecord();
     349                 :     DDFModule           *poModule;
     350                 : 
     351                 : private:
     352                 :     int                 nNext0001Index;
     353                 :     S57ClassRegistrar   *poRegistrar;
     354                 : 
     355                 :     int                 nCOMF;  /* Coordinate multiplier */
     356                 :     int                 nSOMF;  /* Vertical (sounding) multiplier */
     357                 : };
     358                 : 
     359                 : /* -------------------------------------------------------------------- */
     360                 : /*      Functions to create OGRFeatureDefns.                            */
     361                 : /* -------------------------------------------------------------------- */
     362                 : void           CPL_DLL  S57GenerateStandardAttributes( OGRFeatureDefn *, int );
     363                 : OGRFeatureDefn CPL_DLL *S57GenerateGeomFeatureDefn( OGRwkbGeometryType, int );
     364                 : OGRFeatureDefn CPL_DLL *S57GenerateObjectClassDefn( S57ClassRegistrar *, 
     365                 :                                                     int, int );
     366                 : OGRFeatureDefn CPL_DLL  *S57GenerateVectorPrimitiveFeatureDefn( int, int );
     367                 : OGRFeatureDefn CPL_DLL  *S57GenerateDSIDFeatureDefn( void );
     368                 : 
     369                 : #endif /* ndef _S57_H_INCLUDED */

Generated by: LTP GCOV extension version 1.5