LCOV - code coverage report
Current view: directory - ogr/ogrsf_frmts/tiger - tigerentitynames.cpp (source / functions) Found Hit Coverage
Test: gdal_filtered.info Lines: 13 10 76.9 %
Date: 2011-12-18 Functions: 2 1 50.0 %

       1                 : /******************************************************************************
       2                 :  * $Id: tigerentitynames.cpp 22961 2011-08-20 17:09:59Z rouault $
       3                 :  *
       4                 :  * Project:  TIGER/Line Translator
       5                 :  * Purpose:  Implements TigerEntityNames, providing access to .RTC 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: tigerentitynames.cpp 22961 2011-08-20 17:09:59Z rouault $");
      34                 : 
      35                 : #define FILE_CODE "C"
      36                 : 
      37                 : static const TigerFieldInfo rtC_2002_fields[] = {
      38                 :   // fieldname    fmt  type OFTType      beg  end  len  bDefine bSet bWrite
      39                 :   { "MODULE",     ' ', ' ', OFTString,     0,   0,   8,       1,   0,     0 },
      40                 :   { "STATE",      'L', 'N', OFTInteger,    6,   7,   2,       1,   1,     1 },
      41                 :   { "COUNTY",     'L', 'N', OFTInteger,    8,  10,   3,       1,   1,     1 },
      42                 :   { "DATAYR",     'L', 'A', OFTString,    11,  14,   4,       1,   1,     1 },
      43                 :   { "FIPS",       'L', 'N', OFTInteger,   15,  19,   5,       1,   1,     1 },
      44                 :   { "FIPSCC",     'L', 'A', OFTString,    20,  21,   2,       1,   1,     1 },
      45                 :   { "PLACEDC",    'L', 'A', OFTString,    22,  22,   1,       1,   1,     1 },
      46                 :   { "LSADC",      'L', 'A', OFTString,    23,  24,   2,       1,   1,     1 },
      47                 :   { "ENTITY",     'L', 'A', OFTString,    25,  25,   1,       1,   1,     1 },
      48                 :   { "MA",         'L', 'N', OFTInteger,   26,  29,   4,       1,   1,     1 },
      49                 :   { "SD",         'L', 'N', OFTInteger,   30,  34,   5,       1,   1,     1 },
      50                 :   { "AIANHH",     'L', 'N', OFTInteger,   35,  38,   4,       1,   1,     1 },
      51                 :   { "VTDTRACT",   'R', 'A', OFTString,    39,  44,   6,       1,   1,     1 },
      52                 :   { "UAUGA",      'L', 'N', OFTInteger,   45,  49,   5,       1,   1,     1 },
      53                 :   { "AITSCE",     'L', 'N', OFTInteger,   50,  52,   3,       1,   1,     1 },
      54                 :   { "RS_C1",      'L', 'N', OFTInteger,   53,  54,   2,       1,   1,     1 },
      55                 :   { "RS_C2",      'L', 'N', OFTInteger,   55,  62,   8,       1,   1,     1 },
      56                 :   { "NAME",       'L', 'A', OFTString,    63, 122,  60,       1,   1,     1 },
      57                 : };
      58                 : static const TigerRecordInfo rtC_2002_info =
      59                 :   {
      60                 :     rtC_2002_fields,
      61                 :     sizeof(rtC_2002_fields) / sizeof(TigerFieldInfo),
      62                 :     122
      63                 :   };
      64                 : 
      65                 : static const TigerFieldInfo rtC_2000_Redistricting_fields[] = {
      66                 :   // fieldname    fmt  type OFTType      beg  end  len  bDefine bSet bWrite
      67                 :   { "MODULE",     ' ', ' ', OFTString,     0,   0,   8,       1,   0,     0 },
      68                 :   { "STATE",      'L', 'N', OFTInteger,    6,   7,   2,       1,   1,     1 },
      69                 :   { "COUNTY",     'L', 'N', OFTInteger,    8,  10,   3,       1,   1,     1 },
      70                 :   { "FIPSYR",     'L', 'N', OFTString,    11,  14,   4,       1,   1,     1 },
      71                 :   { "FIPS",       'L', 'N', OFTInteger,   15,  19,   5,       1,   1,     1 },
      72                 :   { "FIPSCC",     'L', 'A', OFTString,    20,  21,   2,       1,   1,     1 },
      73                 :   { "PDC",        'L', 'A', OFTString,    22,  22,   1,       1,   1,     1 },
      74                 :   { "LASAD",      'L', 'A', OFTString,    23,  24,   2,       1,   1,     1 },
      75                 :   { "ENTITY",     'L', 'A', OFTString,    25,  25,   1,       1,   1,     1 },
      76                 :   { "MA",         'L', 'N', OFTInteger,   26,  29,   4,       1,   1,     1 },
      77                 :   { "SD",         'L', 'N', OFTInteger,   30,  34,   5,       1,   1,     1 },
      78                 :   { "AIR",        'L', 'N', OFTInteger,   35,  38,   4,       1,   1,     1 },
      79                 :   { "VTD",        'R', 'A', OFTString,    39,  44,   6,       1,   1,     1 },
      80                 :   { "UA",         'L', 'N', OFTInteger,   45,  49,   5,       1,   1,     1 },
      81                 :   { "AITSCE",     'L', 'N', OFTInteger,   50,  52,   3,       1,   1,     1 },
      82                 :   { "NAME",       'L', 'A', OFTString,    53, 112,  66,       1,   1,     1 }
      83                 : };
      84                 : static const TigerRecordInfo rtC_2000_Redistricting_info =
      85                 :   {
      86                 :     rtC_2000_Redistricting_fields,
      87                 :     sizeof(rtC_2000_Redistricting_fields) / sizeof(TigerFieldInfo),
      88                 :     112
      89                 :   };
      90                 : 
      91                 : static const TigerFieldInfo rtC_fields[] = {
      92                 :   // fieldname    fmt  type OFTType      beg  end  len  bDefine bSet bWrite
      93                 :   { "MODULE",     ' ', ' ', OFTString,     0,   0,   8,       1,   0,     0 },
      94                 :   { "STATE",      'L', 'N', OFTInteger,    6,   7,   2,       1,   1,     1 },
      95                 :   { "COUNTY",     'L', 'N', OFTInteger,    8,  10,   3,       1,   1,     1 },
      96                 :   { "FIPSYR",     'L', 'N', OFTString,    11,  12,   4,       1,   1,     1 },
      97                 :   { "FIPS",       'L', 'N', OFTInteger,   13,  17,   5,       1,   1,     1 },
      98                 :   { "FIPSCC",     'L', 'A', OFTString,    18,  19,   2,       1,   1,     1 },
      99                 :   { "PDC",        'L', 'A', OFTString,    20,  20,   1,       1,   1,     1 },
     100                 :   { "LASAD",      'L', 'A', OFTString,    21,  22,   2,       1,   1,     1 },
     101                 :   { "ENTITY",     'L', 'A', OFTString,    23,  23,   1,       1,   1,     1 },
     102                 :   { "MA",         'L', 'N', OFTInteger,   24,  27,   4,       1,   1,     1 },
     103                 :   { "SD",         'L', 'N', OFTInteger,   28,  32,   5,       1,   1,     1 },
     104                 :   { "AIR",        'L', 'N', OFTInteger,   33,  36,   4,       1,   1,     1 },
     105                 :   { "VTD",        'R', 'A', OFTString,    37,  42,   6,       1,   1,     1 },
     106                 :   { "UA",         'L', 'N', OFTInteger,   43,  46,   4,       1,   1,     1 },
     107                 :   { "NAME",       'L', 'A', OFTString,    47, 112,  66,       1,   1,     1 }
     108                 : };
     109                 : static const TigerRecordInfo rtC_info =
     110                 :   {
     111                 :     rtC_fields,
     112                 :     sizeof(rtC_fields) / sizeof(TigerFieldInfo),
     113                 :     112
     114                 :   };
     115                 : 
     116                 : 
     117                 : /************************************************************************/
     118                 : /*                          TigerEntityNames()                          */
     119                 : /************************************************************************/
     120                 : 
     121               7 : TigerEntityNames::TigerEntityNames( OGRTigerDataSource * poDSIn,
     122               7 :                             const char * pszPrototypeModule ) : TigerFileBase(NULL, FILE_CODE)
     123                 : 
     124                 : {
     125               7 :     poDS = poDSIn;
     126               7 :     poFeatureDefn = new OGRFeatureDefn( "EntityNames" );
     127               7 :     poFeatureDefn->Reference();
     128               7 :     poFeatureDefn->SetGeomType( wkbPoint );
     129                 : 
     130               7 :     if( poDS->GetVersion() >= TIGER_2002 ) {
     131               7 :       psRTInfo = &rtC_2002_info;
     132               0 :     } else if( poDS->GetVersion() >= TIGER_2000_Redistricting ) {
     133               0 :       psRTInfo = &rtC_2000_Redistricting_info;
     134                 :     } else {
     135               0 :       psRTInfo = &rtC_info;
     136                 :     }
     137                 : 
     138               7 :     AddFieldDefns( psRTInfo, poFeatureDefn );
     139               7 : }

Generated by: LCOV version 1.7