LCOV - code coverage report
Current view: directory - ogr/ogrsf_frmts/gtm - ogrgtmlayer.cpp (source / functions) Found Hit Coverage
Test: gdal_filtered.info Lines: 51 27 52.9 %
Date: 2010-01-09 Functions: 10 6 60.0 %

       1                 : /******************************************************************************
       2                 :  * $Id: ogrgtmlayer.cpp 17588 2009-08-27 20:52:33Z rouault $
       3                 :  *
       4                 :  * Project:  GTM Driver
       5                 :  * Purpose:  Implementation of OGRGTMLayer class.
       6                 :  * Author:   Leonardo de Paula Rosa Piga; http://lampiao.lsc.ic.unicamp.br/~piga
       7                 :  *
       8                 :  ******************************************************************************
       9                 :  * Copyright (c) 2009, Leonardo de Paula Rosa Piga
      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_gtm.h"
      31                 : 
      32               9 : OGRGTMLayer::OGRGTMLayer()
      33                 : {
      34               9 :     poDS = NULL;
      35               9 :     poSRS = NULL;
      36               9 :     poCT = NULL;
      37               9 :     pszName = NULL;
      38               9 :     poFeatureDefn = NULL;
      39               9 :     nNextFID = 0;
      40               9 :     nTotalFCount = 0;
      41               9 :     bError = FALSE;
      42               9 : }
      43                 : 
      44               9 : OGRGTMLayer::~OGRGTMLayer()
      45                 : {
      46               9 :     if (poFeatureDefn != NULL)
      47                 :     {
      48               9 :         poFeatureDefn->Release();
      49               9 :         poFeatureDefn = NULL;
      50                 :     }
      51                 : 
      52               9 :     if (poSRS != NULL)
      53                 :     {
      54               6 :         poSRS->Release();
      55               6 :         poSRS = NULL;
      56                 :     }
      57                 : 
      58               9 :     if (poCT != NULL)
      59                 :     {
      60               0 :         delete poCT;
      61               0 :         poCT = NULL;
      62                 :     }
      63                 : 
      64               9 :     CPLFree( pszName );
      65               9 : }
      66                 : 
      67                 : /************************************************************************/
      68                 : /*                            GetLayerDefn()                            */
      69                 : /************************************************************************/
      70                 : 
      71              14 : OGRFeatureDefn* OGRGTMLayer::GetLayerDefn()
      72                 : {
      73              14 :     return poFeatureDefn;
      74                 : }
      75                 : 
      76                 : /************************************************************************/
      77                 : /*                           TestCapability()                           */
      78                 : /************************************************************************/
      79                 : 
      80               0 : int OGRGTMLayer::TestCapability( const char * pszCap ) 
      81                 : {
      82               0 :     if (EQUAL(pszCap,OLCFastFeatureCount) &&
      83                 :         m_poFilterGeom == NULL && m_poAttrQuery == NULL )
      84               0 :         return TRUE;
      85                 :     else
      86               0 :         return FALSE;
      87                 : }
      88                 : 
      89                 : 
      90                 : /************************************************************************/
      91                 : /*                CheckAndFixCoordinatesValidity()                      */
      92                 : /************************************************************************/
      93                 : 
      94              18 : OGRErr OGRGTMLayer::CheckAndFixCoordinatesValidity( double& pdfLatitude, double& pdfLongitude )
      95                 : {
      96              18 :     if (pdfLatitude < -90 || pdfLatitude > 90)
      97                 :     {
      98                 :         static int bFirstWarning = TRUE;
      99               0 :         if (bFirstWarning)
     100                 :         {
     101                 :             CPLError(CE_Failure, CPLE_AppDefined,
     102                 :                      "Latitude %f is invalid. Valid range is [-90,90]. This warning will not be issued any more",
     103               0 :                      pdfLatitude);
     104               0 :             bFirstWarning = FALSE;
     105                 :         }
     106               0 :         return CE_Failure;
     107                 :     }
     108                 : 
     109              18 :     if (pdfLongitude < -180 || pdfLongitude > 180)
     110                 :     {
     111                 :         static int bFirstWarning = TRUE;
     112               0 :         if (bFirstWarning)
     113                 :         {
     114                 :             CPLError(CE_Warning, CPLE_AppDefined,
     115                 :                      "Longitude %f has been modified to fit into range [-180,180]. This warning will not be issued any more",
     116               0 :                      pdfLongitude);
     117               0 :             bFirstWarning = FALSE;
     118                 :         }
     119                 : 
     120               0 :         if (pdfLongitude > 180)
     121               0 :             pdfLongitude -= ((int) ((pdfLongitude+180)/360)*360);
     122               0 :         else if (pdfLongitude < -180)
     123               0 :             pdfLongitude += ((int) (180 - pdfLongitude)/360)*360;
     124                 : 
     125               0 :         return CE_None;
     126                 :     }
     127                 : 
     128              18 :     return CE_None;
     129                 : }
     130                 : 
     131                 : /************************************************************************/
     132                 : /*                            CreateField()                             */
     133                 : /************************************************************************/
     134                 : 
     135               0 : OGRErr OGRGTMLayer::CreateField( OGRFieldDefn *poField, int bApproxOK )
     136                 : 
     137                 : {
     138               0 :     for( int iField = 0; iField < poFeatureDefn->GetFieldCount(); iField++ )
     139                 :     {
     140               0 :         if (strcmp(poFeatureDefn->GetFieldDefn(iField)->GetNameRef(),
     141                 :                    poField->GetNameRef() ) == 0)
     142                 :         {
     143               0 :             return OGRERR_NONE;
     144                 :         }
     145                 :     }
     146                 :     CPLError(CE_Failure, CPLE_NotSupported,
     147                 :             "Field of name '%s' is not supported. ",
     148               0 :              poField->GetNameRef());
     149               0 :     return OGRERR_FAILURE;
     150            1140 : }

Generated by: LCOV version 1.7