LTP GCOV extension - code coverage report
Current view: directory - ogr/ogrsf_frmts/tiger - tigerpoint.cpp
Test: gdal_filtered.info
Date: 2010-07-12 Instrumented lines: 41
Code covered: 0.0 % Executed lines: 0

       1                 : /******************************************************************************
       2                 :  * $Id: tigerpoint.cpp 12745 2007-11-13 14:18:11Z dron $
       3                 :  *
       4                 :  * Project:  TIGER/Line Translator
       5                 :  * Purpose:  Implements TigerPoint class.
       6                 :  * Author:   Mark Phillips, mbp@geomtech.com
       7                 :  *
       8                 :  ******************************************************************************
       9                 :  * Copyright (c) 2002, Mark Phillips
      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: tigerpoint.cpp 12745 2007-11-13 14:18:11Z dron $");
      34                 : 
      35                 : /************************************************************************/
      36                 : /*                             TigerPoint()                             */
      37                 : /************************************************************************/
      38               0 : TigerPoint::TigerPoint( int bRequireGeom )
      39                 : {
      40               0 :     this->bRequireGeom = bRequireGeom;
      41               0 : }
      42                 : 
      43               0 : TigerPoint::~TigerPoint()
      44                 : {
      45               0 : }
      46                 : 
      47                 : /************************************************************************/
      48                 : /*                             SetModule()                              */
      49                 : /************************************************************************/
      50               0 : int TigerPoint::SetModule( const char * pszModule, const char *pszFileCode )
      51                 : {
      52               0 :     if( !OpenFile( pszModule, pszFileCode ) )
      53               0 :         return FALSE;
      54               0 :     EstablishFeatureCount();
      55               0 :     return TRUE;
      56                 : }
      57                 : 
      58                 : /************************************************************************/
      59                 : /*                             GetFeature()                             */
      60                 : /************************************************************************/
      61                 : OGRFeature *TigerPoint::GetFeature( int nRecordId,
      62                 :                                     TigerRecordInfo *psRTInfo,
      63                 :                                     int nX0, int nX1,
      64               0 :                                     int nY0, int nY1 )
      65                 : {
      66                 :     char        achRecord[OGR_TIGER_RECBUF_LEN];
      67                 : 
      68               0 :     if( nRecordId < 0 || nRecordId >= nFeatures ) {
      69                 :         CPLError( CE_Failure, CPLE_FileIO,
      70                 :                   "Request for out-of-range feature %d of %sP",
      71               0 :                   nRecordId, pszModule );
      72               0 :         return NULL;
      73                 :     }
      74                 : 
      75                 :     /* -------------------------------------------------------------------- */
      76                 :     /*      Read the raw record data from the file.                         */
      77                 :     /* -------------------------------------------------------------------- */
      78                 : 
      79               0 :     if( fpPrimary == NULL )
      80               0 :         return NULL;
      81                 : 
      82               0 :     if( VSIFSeek( fpPrimary, nRecordId * nRecordLength, SEEK_SET ) != 0 ) {
      83                 :         CPLError( CE_Failure, CPLE_FileIO,
      84                 :                   "Failed to seek to %d of %sP",
      85               0 :                   nRecordId * nRecordLength, pszModule );
      86               0 :         return NULL;
      87                 :     }
      88                 : 
      89               0 :     if( VSIFRead( achRecord, psRTInfo->nRecordLength, 1, fpPrimary ) != 1 ) {
      90                 :         CPLError( CE_Failure, CPLE_FileIO,
      91                 :                   "Failed to read record %d of %sP",
      92               0 :                   nRecordId, pszModule );
      93               0 :         return NULL;
      94                 :     }
      95                 : 
      96                 :     /* -------------------------------------------------------------------- */
      97                 :     /*      Set fields.                                                     */
      98                 :     /* -------------------------------------------------------------------- */
      99                 : 
     100               0 :     OGRFeature  *poFeature = new OGRFeature( poFeatureDefn );
     101                 : 
     102               0 :     SetFields( psRTInfo, poFeature, achRecord);
     103                 : 
     104                 :     /* -------------------------------------------------------------------- */
     105                 :     /*      Set geometry                                                    */
     106                 :     /* -------------------------------------------------------------------- */
     107                 : 
     108                 :     double      dfX, dfY;
     109                 : 
     110               0 :     dfX = atoi(GetField(achRecord, nX0, nX1)) / 1000000.0;
     111               0 :     dfY = atoi(GetField(achRecord, nY0, nY1)) / 1000000.0;
     112                 : 
     113               0 :     if( dfX != 0.0 || dfY != 0.0 ) {
     114               0 :         poFeature->SetGeometryDirectly( new OGRPoint( dfX, dfY ) );
     115                 :     }
     116                 :         
     117               0 :     return poFeature;
     118                 : }
     119                 : 
     120                 : /************************************************************************/
     121                 : /*                           CreateFeature()                            */
     122                 : /************************************************************************/
     123                 : OGRErr TigerPoint::CreateFeature( OGRFeature *poFeature, 
     124                 :                                   TigerRecordInfo *psRTInfo,
     125                 :                                   int pointIndex,
     126               0 :                                   const char *pszFileCode)
     127                 : 
     128                 : {
     129                 :     char        szRecord[OGR_TIGER_RECBUF_LEN];
     130               0 :     OGRPoint    *poPoint = (OGRPoint *) poFeature->GetGeometryRef();
     131                 : 
     132               0 :     if( !SetWriteModule( pszFileCode, psRTInfo->nRecordLength+2, poFeature ) )
     133               0 :         return OGRERR_FAILURE;
     134                 : 
     135               0 :     memset( szRecord, ' ', psRTInfo->nRecordLength );
     136                 : 
     137               0 :     WriteFields( psRTInfo, poFeature, szRecord );
     138                 : 
     139               0 :     if( poPoint != NULL 
     140                 :         && (poPoint->getGeometryType() == wkbPoint
     141                 :             || poPoint->getGeometryType() == wkbPoint25D) ) {
     142               0 :         WritePoint( szRecord, pointIndex, poPoint->getX(), poPoint->getY() );
     143                 :     } else {
     144               0 :         if (bRequireGeom) {
     145               0 :             return OGRERR_FAILURE;
     146                 :         }
     147                 :     }
     148                 : 
     149               0 :     WriteRecord( szRecord, psRTInfo->nRecordLength, pszFileCode );
     150                 : 
     151               0 :     return OGRERR_NONE;
     152                 : }

Generated by: LTP GCOV extension version 1.5