LCOV - code coverage report
Current view: top level - ogr/ogrsf_frmts/gmlas - ogrgmlasfeatureclass.cpp (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 71 75 94.7 %
Date: 2024-11-21 22:18:42 Functions: 8 8 100.0 %

          Line data    Source code
       1             : /******************************************************************************
       2             :  * Project:  OGR
       3             :  * Purpose:  OGRGMLASDriver implementation
       4             :  * Author:   Even Rouault, <even dot rouault at spatialys dot com>
       5             :  *
       6             :  * Initial development funded by the European Earth observation programme
       7             :  * Copernicus
       8             :  *
       9             :  ******************************************************************************
      10             :  * Copyright (c) 2016, Even Rouault, <even dot rouault at spatialys dot com>
      11             :  *
      12             :  * SPDX-License-Identifier: MIT
      13             :  ****************************************************************************/
      14             : 
      15             : #include "ogr_gmlas.h"
      16             : 
      17             : /************************************************************************/
      18             : /*                             GetTypeFromString()                      */
      19             : /************************************************************************/
      20             : 
      21      195276 : GMLASFieldType GMLASField::GetTypeFromString(const CPLString &osType)
      22             : {
      23      404519 :     if (osType == szXS_STRING || osType == szXS_TOKEN ||
      24      204176 :         osType == szXS_NMTOKEN || osType == szXS_NCNAME ||
      25      404509 :         osType == szXS_QNAME || osType == szXS_IDREF)
      26             :     {
      27             :         // token has special processing by XML processor: all leading/trailing
      28             :         // white space is removed
      29      127256 :         return GMLAS_FT_STRING;
      30             :     }
      31       68020 :     else if (osType == szXS_ID)
      32        6827 :         return GMLAS_FT_ID;
      33       61193 :     else if (osType == szXS_BOOLEAN)
      34         977 :         return GMLAS_FT_BOOLEAN;
      35       60216 :     else if (osType == szXS_SHORT)
      36          51 :         return GMLAS_FT_SHORT;
      37       60165 :     else if (osType == szXS_INT)
      38         817 :         return GMLAS_FT_INT32;
      39      176787 :     else if (osType == szXS_BYTE || osType == szXS_INTEGER ||
      40      116284 :              osType == szXS_NEGATIVE_INTEGER ||
      41      116208 :              osType == szXS_NON_NEGATIVE_INTEGER ||
      42      116132 :              osType == szXS_NON_POSITIVE_INTEGER ||
      43      174090 :              osType == szXS_POSITIVE_INTEGER || osType == szXS_UNSIGNED_BYTE ||
      44      176657 :              osType == szXS_UNSIGNED_SHORT ||
      45       58012 :              osType == szXS_UNSIGNED_INT)  // FIXME ?
      46        1336 :         return GMLAS_FT_INT32;
      47       58012 :     else if (osType == szXS_LONG || osType == szXS_UNSIGNED_LONG)
      48       22301 :         return GMLAS_FT_INT64;
      49       35711 :     else if (osType == szXS_FLOAT)
      50         102 :         return GMLAS_FT_FLOAT;
      51       35609 :     else if (osType == szXS_DOUBLE)
      52       29662 :         return GMLAS_FT_DOUBLE;
      53        5947 :     else if (osType == szXS_DECIMAL)
      54          57 :         return GMLAS_FT_DECIMAL;
      55        5890 :     else if (osType == szXS_DATE)
      56          51 :         return GMLAS_FT_DATE;
      57        5839 :     else if (osType == szXS_GYEAR)
      58           0 :         return GMLAS_FT_GYEAR;
      59        5839 :     else if (osType == szXS_GYEAR_MONTH)
      60           0 :         return GMLAS_FT_GYEAR_MONTH;
      61        5839 :     else if (osType == szXS_TIME)
      62          51 :         return GMLAS_FT_TIME;
      63        5788 :     else if (osType == szXS_DATETIME)
      64         430 :         return GMLAS_FT_DATETIME;
      65        5358 :     else if (osType == szXS_ANY_URI)
      66        2329 :         return GMLAS_FT_ANYURI;
      67        3029 :     else if (osType == szXS_ANY_TYPE)
      68          16 :         return GMLAS_FT_ANYTYPE;
      69        3013 :     else if (osType == szXS_ANY_SIMPLE_TYPE)
      70        2909 :         return GMLAS_FT_ANYSIMPLETYPE;
      71         104 :     else if (osType == szXS_DURATION)
      72           2 :         return GMLAS_FT_STRING;
      73         102 :     else if (osType == szXS_BASE64BINARY)
      74          51 :         return GMLAS_FT_BASE64BINARY;
      75          51 :     else if (osType == szXS_HEXBINARY)
      76          51 :         return GMLAS_FT_HEXBINARY;
      77             :     else
      78             :     {
      79           0 :         CPLError(CE_Warning, CPLE_AppDefined, "Unhandled type: %s",
      80             :                  osType.c_str());
      81           0 :         return GMLAS_FT_STRING;
      82             :     }
      83             : }
      84             : 
      85             : /************************************************************************/
      86             : /*                               SetType()                              */
      87             : /************************************************************************/
      88             : 
      89      204234 : void GMLASField::SetType(GMLASFieldType eType, const char *pszTypeName)
      90             : {
      91      204234 :     m_eType = eType;
      92      204234 :     m_osTypeName = pszTypeName;
      93      204234 : }
      94             : 
      95             : /************************************************************************/
      96             : /*                                 SetName()                            */
      97             : /************************************************************************/
      98             : 
      99       56387 : void GMLASFeatureClass::SetName(const CPLString &osName)
     100             : {
     101       56387 :     m_osName = osName;
     102       56387 : }
     103             : 
     104             : /************************************************************************/
     105             : /*                                SetXPath()                            */
     106             : /************************************************************************/
     107             : 
     108       41290 : void GMLASFeatureClass::SetXPath(const CPLString &osXPath)
     109             : {
     110       41290 :     m_osXPath = osXPath;
     111       41290 : }
     112             : 
     113             : /************************************************************************/
     114             : /*                                AddField()                            */
     115             : /************************************************************************/
     116             : 
     117      313429 : void GMLASFeatureClass::AddField(const GMLASField &oField)
     118             : {
     119      313429 :     m_aoFields.push_back(oField);
     120      313429 : }
     121             : 
     122             : /************************************************************************/
     123             : /*                            PrependFields()                           */
     124             : /************************************************************************/
     125             : 
     126        3901 : void GMLASFeatureClass::PrependFields(const std::vector<GMLASField> &aoFields)
     127             : {
     128        3901 :     m_aoFields.insert(m_aoFields.begin(), aoFields.begin(), aoFields.end());
     129        3901 : }
     130             : 
     131             : /************************************************************************/
     132             : /*                             AppendFields()                           */
     133             : /************************************************************************/
     134             : 
     135       40127 : void GMLASFeatureClass::AppendFields(const std::vector<GMLASField> &aoFields)
     136             : {
     137       40127 :     m_aoFields.insert(m_aoFields.end(), aoFields.begin(), aoFields.end());
     138       40127 : }
     139             : 
     140             : /************************************************************************/
     141             : /*                             AddNestedClass()                         */
     142             : /************************************************************************/
     143             : 
     144        7509 : void GMLASFeatureClass::AddNestedClass(const GMLASFeatureClass &oNestedClass)
     145             : {
     146        7509 :     m_aoNestedClasses.push_back(oNestedClass);
     147        7509 : }

Generated by: LCOV version 1.14