LCOV - code coverage report
Current view: directory - ogr/ogrsf_frmts/ili - iomhelper.cpp (source / functions) Found Hit Coverage
Test: gdal_filtered.info Lines: 46 44 95.7 %
Date: 2012-12-26 Functions: 7 6 85.7 %

       1                 : /******************************************************************************
       2                 :  * $Id: iomhelper.cpp 10645 2007-01-18 02:22:39Z warmerdam $
       3                 :  *
       4                 :  * Project:  Interlis 1/2 Translator
       5                 :  * Purpose:  Implementation of ILI1Reader class.
       6                 :  * Author:   Pirmin Kalberer, Sourcepole AG
       7                 :  *
       8                 :  ******************************************************************************
       9                 :  * Copyright (c) 2004, Pirmin Kalberer, Sourcepole AG
      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                 : 
      31                 : #include "iomhelper.h"
      32                 : #include "cpl_port.h"
      33                 : 
      34                 : CPL_CVSID("$Id: iomhelper.cpp 10645 2007-01-18 02:22:39Z warmerdam $");
      35                 : 
      36                 : 
      37            1944 : IOM_OBJECT GetAttrObj(IOM_BASKET model, IOM_OBJECT obj, const char* attrname) {
      38            1944 :     IOM_OBJECT attrobj = iom_getattrobj(obj, attrname, 0);
      39            1944 :     if (attrobj == NULL) return NULL;
      40            1779 :     const char *refoid=iom_getobjectrefoid(attrobj);
      41            1779 :     if (refoid == NULL) return NULL;
      42            1779 :     return iom_getobject(model, refoid);
      43                 : }
      44                 : 
      45              86 : int GetAttrObjPos(IOM_OBJECT obj, const char* attrname) {
      46              86 :     IOM_OBJECT attrobj = iom_getattrobj(obj, attrname, 0);
      47              86 :     if (attrobj == NULL) return -1;
      48              86 :     return iom_getobjectreforderpos(attrobj);
      49                 : }
      50                 : 
      51               0 : const char* GetAttrObjName(IOM_BASKET model, IOM_OBJECT obj, const char* attrname) {
      52               0 :     return iom_getattrvalue(GetAttrObj(model, obj, attrname), "name");
      53                 : }
      54                 : 
      55             192 : IOM_OBJECT GetTypeObj(IOM_BASKET model, IOM_OBJECT obj) {
      56             192 :     IOM_OBJECT typeobj = GetAttrObj(model, obj, "type");
      57             192 :     if (typeobj && EQUAL(iom_getobjecttag(typeobj), "iom04.metamodel.TypeAlias")) {
      58              24 :         typeobj = GetTypeObj(model, GetAttrObj(model, typeobj, "aliasing"));
      59                 :     }
      60             192 :     return typeobj;
      61                 : }
      62                 : 
      63             153 : const char* GetTypeName(IOM_BASKET model, IOM_OBJECT obj) {
      64             153 :     IOM_OBJECT typeobj = GetTypeObj(model, obj);
      65             153 :     if (typeobj == NULL) return "(null)";
      66             148 :     return iom_getobjecttag(typeobj);
      67                 : }
      68                 : 
      69              10 : unsigned int GetCoordDim(IOM_BASKET model, IOM_OBJECT typeobj) {
      70              10 :   unsigned int dim = 0;
      71                 :   //find attribute of this type with highest orderpos
      72              10 :   IOM_ITERATOR modelelei=iom_iteratorobject(model);
      73              10 :   IOM_OBJECT modelele=iom_nextobject(modelelei);
      74            2790 :   while(modelele){
      75            2770 :     const char *tag=iom_getobjecttag(modelele);
      76            2770 :     if (tag && EQUAL(tag,"iom04.metamodel.NumericType")) {
      77             200 :       if (GetAttrObj(model, modelele, "coordType") == typeobj) {
      78              20 :         unsigned int orderpos = GetAttrObjPos(modelele, "coordType");
      79              20 :         if (orderpos > dim) dim = orderpos;
      80                 :       }
      81                 :     }
      82            2770 :     iom_releaseobject(modelele);
      83            2770 :     modelele=iom_nextobject(modelelei);
      84                 :   }
      85              10 :   iom_releaseiterator(modelelei);
      86                 : 
      87              10 :   return dim;
      88                 : }
      89                 : 
      90               2 : const char* GetAttrObjName(IOM_BASKET model, const char* tagname) {
      91               2 :   const char* result = NULL;
      92               2 :   IOM_ITERATOR modelelei = iom_iteratorobject(model);
      93               2 :   IOM_OBJECT modelele = iom_nextobject(modelelei);
      94               7 :   while (modelele && result == NULL)
      95                 :   {
      96               3 :       if(EQUAL(iom_getobjecttag(modelele), tagname)){
      97                 :           // get name of topic
      98               2 :           result = iom_getattrvalue(modelele, "name");
      99                 :       }
     100               3 :       iom_releaseobject(modelele);
     101               3 :       modelele=iom_nextobject(modelelei);
     102                 :   }
     103               2 :   iom_releaseiterator(modelelei);
     104               2 :   return result;
     105                 : }

Generated by: LCOV version 1.7