LCOV - code coverage report
Current view: directory - ogr/ogrsf_frmts/tiger - tigerlandmarks.cpp (source / functions) Found Hit Coverage
Test: gdal_filtered.info Lines: 15 14 93.3 %
Date: 2011-12-18 Functions: 4 3 75.0 %

       1                 : /******************************************************************************
       2                 :  * $Id: tigerlandmarks.cpp 22961 2011-08-20 17:09:59Z rouault $
       3                 :  *
       4                 :  * Project:  TIGER/Line Translator
       5                 :  * Purpose:  Implements TigerLandmarks, providing access to .RT7 files.
       6                 :  * Author:   Frank Warmerdam, warmerdam@pobox.com
       7                 :  *
       8                 :  ******************************************************************************
       9                 :  * Copyright (c) 1999, Frank Warmerdam
      10                 :  *
      11                 :  * Permission is hereby granted, free of charge, to any person obtaining a
      12                 :  * copy of this software and associated documentation files (the "Software"),
      13                 :  * to deal in the Software without restriction, including without limitation
      14                 :  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
      15                 :  * and/or sell copies of the Software, and to permit persons to whom the
      16                 :  * Software is furnished to do so, subject to the following conditions:
      17                 :  *
      18                 :  * The above copyright notice and this permission notice shall be included
      19                 :  * in all copies or substantial portions of the Software.
      20                 :  *
      21                 :  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
      22                 :  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
      23                 :  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
      24                 :  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
      25                 :  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
      26                 :  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
      27                 :  * DEALINGS IN THE SOFTWARE.
      28                 :  ****************************************************************************/
      29                 : 
      30                 : #include "ogr_tiger.h"
      31                 : #include "cpl_conv.h"
      32                 : 
      33                 : CPL_CVSID("$Id: tigerlandmarks.cpp 22961 2011-08-20 17:09:59Z rouault $");
      34                 : 
      35                 : #define FILE_CODE "7"
      36                 : 
      37                 : static const TigerFieldInfo rt7_2002_fields[] = {
      38                 :   // fieldname    fmt  type OFTType      beg  end  len  bDefine bSet bWrite
      39                 :   { "MODULE",     ' ', ' ', OFTString,     0,   0,   8,       1,   0,     0 },
      40                 :   { "FILE",       'L', 'N', OFTInteger,    6,  10,   5,       1,   1,     1 },
      41                 :   { "LAND",       'R', 'N', OFTInteger,   11,  20,  10,       1,   1,     1 },
      42                 :   { "SOURCE",     'L', 'A', OFTString,    21,  21,   1,       1,   1,     1 },
      43                 :   { "CFCC",       'L', 'A', OFTString,    22,  24,   3,       1,   1,     1 },
      44                 :   { "LANAME",     'L', 'A', OFTString,    25,  54,  30,       1,   1,     1 },
      45                 :   { "LALONG",     'R', 'N', OFTInteger,   55,  64,  10,       1,   1,     1 },
      46                 :   { "LALAT",      'R', 'N', OFTInteger,   65,  73,   9,       1,   1,     1 },
      47                 :   { "FILLER",     'L', 'A', OFTString,    74,  74,   1,       1,   1,     1 },
      48                 : };
      49                 : static const TigerRecordInfo rt7_2002_info =
      50                 :   {
      51                 :     rt7_2002_fields,
      52                 :     sizeof(rt7_2002_fields) / sizeof(TigerFieldInfo),
      53                 :     74
      54                 :   };
      55                 : 
      56                 : static const TigerFieldInfo rt7_fields[] = {
      57                 :   // fieldname    fmt  type OFTType      beg  end  len  bDefine bSet bWrite
      58                 :   { "MODULE",     ' ', ' ', OFTString,     0,   0,   8,       1,   0,     0 },
      59                 :   { "FILE",       'L', 'N', OFTString,     6,  10,   5,       1,   0,     1 },
      60                 :   { "STATE",      'L', 'N', OFTInteger,    6,   7,   2,       1,   1,     1 },
      61                 :   { "COUNTY",     'L', 'N', OFTInteger,    8,  10,   3,       1,   1,     1 },
      62                 :   { "LAND",       'R', 'N', OFTInteger,   11,  20,  10,       1,   1,     1 },
      63                 :   { "SOURCE",     'L', 'A', OFTString,    21,  21,   1,       1,   1,     1 },
      64                 :   { "CFCC",       'L', 'A', OFTString,    22,  24,   3,       1,   1,     1 },
      65                 :   { "LANAME",     'L', 'A', OFTString,    25,  54,  30,       1,   1,     1 }
      66                 : };
      67                 : static const TigerRecordInfo rt7_info =
      68                 :   {
      69                 :     rt7_fields,
      70                 :     sizeof(rt7_fields) / sizeof(TigerFieldInfo),
      71                 :     74
      72                 :   };
      73                 : 
      74                 : /************************************************************************/
      75                 : /*                            TigerLandmarks()                          */
      76                 : /************************************************************************/
      77                 : 
      78               7 : TigerLandmarks::TigerLandmarks( OGRTigerDataSource * poDSIn,
      79                 :                                 const char * pszPrototypeModule )
      80               7 :   : TigerPoint(FALSE, NULL, FILE_CODE)
      81                 : {
      82               7 :     poDS = poDSIn;
      83               7 :     poFeatureDefn = new OGRFeatureDefn( "Landmarks" );
      84               7 :     poFeatureDefn->Reference();
      85               7 :     poFeatureDefn->SetGeomType( wkbPoint );
      86                 : 
      87               7 :     if (poDS->GetVersion() >= TIGER_2002) {
      88               7 :         psRTInfo = &rt7_2002_info;
      89                 :     } else {
      90               0 :         psRTInfo = &rt7_info;
      91                 :     }
      92                 : 
      93               7 :     AddFieldDefns( psRTInfo, poFeatureDefn );
      94               7 : }
      95                 : 
      96            2948 : OGRFeature *TigerLandmarks::GetFeature( int nRecordId )
      97                 : {
      98                 :   return TigerPoint::GetFeature( nRecordId,
      99                 :                                  55, 64,
     100            2948 :                                  65, 73 );
     101                 : }
     102                 : 
     103             267 : OGRErr TigerLandmarks::CreateFeature( OGRFeature *poFeature )
     104                 : {
     105                 :   return TigerPoint::CreateFeature( poFeature, 
     106             267 :                                     55 );
     107                 : }

Generated by: LCOV version 1.7