LCOV - code coverage report
Current view: top level - ogr/ogrsf_frmts/openfilegdb - filegdb_coordprec_read.h (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 25 25 100.0 %
Date: 2024-05-02 22:57:13 Functions: 1 1 100.0 %

          Line data    Source code
       1             : /******************************************************************************
       2             :  *
       3             :  * Project:  OpenGIS Simple Features Reference Implementation
       4             :  * Purpose:  Implements Open FileGDB OGR driver.
       5             :  * Author:   Even Rouault, <even dot rouault at spatialys.com>
       6             :  *
       7             :  ******************************************************************************
       8             :  * Copyright (c) 2024, Even Rouault <even dot rouault at spatialys.com>
       9             :  *
      10             :  * Permission is hereby granted, free of charge, to any person obtaining a
      11             :  * copy of this software and associated documentation files (the "Software"),
      12             :  * to deal in the Software without restriction, including without limitation
      13             :  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
      14             :  * and/or sell copies of the Software, and to permit persons to whom the
      15             :  * Software is furnished to do so, subject to the following conditions:
      16             :  *
      17             :  * The above copyright notice and this permission notice shall be included
      18             :  * in all copies or substantial portions of the Software.
      19             :  *
      20             :  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
      21             :  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
      22             :  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
      23             :  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
      24             :  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
      25             :  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
      26             :  * DEALINGS IN THE SOFTWARE.
      27             :  ****************************************************************************/
      28             : 
      29             : #ifndef FILEGDB_COORDPREC_READ_H
      30             : #define FILEGDB_COORDPREC_READ_H
      31             : 
      32             : #include "cpl_minixml.h"
      33             : 
      34             : #include "ogr_geomcoordinateprecision.h"
      35             : 
      36             : /*************************************************************************/
      37             : /*                      GDBGridSettingsToOGR()                           */
      38             : /*************************************************************************/
      39             : 
      40             : /** Fill OGRGeomCoordinatePrecision from XML "psSpatialReference" node.
      41             :  */
      42             : static OGRGeomCoordinatePrecision
      43        3012 : GDBGridSettingsToOGR(const CPLXMLNode *psSpatialReference)
      44             : {
      45        3012 :     OGRGeomCoordinatePrecision oCoordPrec;
      46             :     const char *pszXYScale =
      47        3012 :         CPLGetXMLValue(psSpatialReference, "XYScale", nullptr);
      48        3012 :     if (pszXYScale && CPLAtof(pszXYScale) > 0)
      49             :     {
      50        3012 :         oCoordPrec.dfXYResolution = 1.0 / CPLAtof(pszXYScale);
      51             :     }
      52             :     const char *pszZScale =
      53        3012 :         CPLGetXMLValue(psSpatialReference, "ZScale", nullptr);
      54        3012 :     if (pszZScale && CPLAtof(pszZScale) > 0)
      55             :     {
      56        3010 :         oCoordPrec.dfZResolution = 1.0 / CPLAtof(pszZScale);
      57             :     }
      58             :     const char *pszMScale =
      59        3012 :         CPLGetXMLValue(psSpatialReference, "MScale", nullptr);
      60        3012 :     if (pszMScale && CPLAtof(pszMScale) > 0)
      61             :     {
      62         619 :         oCoordPrec.dfMResolution = 1.0 / CPLAtof(pszMScale);
      63             :     }
      64             : 
      65        6024 :     CPLStringList aosSpecificOptions;
      66       37328 :     for (const CPLXMLNode *psChild = psSpatialReference->psChild; psChild;
      67       34316 :          psChild = psChild->psNext)
      68             :     {
      69       34316 :         if (psChild->eType == CXT_Element &&
      70             :             // The 3 below values are only generated by the FileGDB SDK
      71       31304 :             !EQUAL(psChild->pszValue, "WKID") &&
      72       28666 :             !EQUAL(psChild->pszValue, "LatestWKID") &&
      73       28593 :             !EQUAL(psChild->pszValue, "WKT"))
      74             :         {
      75       25971 :             const char *pszValue = CPLGetXMLValue(psChild, "", "");
      76       25971 :             if (CPLGetValueType(pszValue) == CPL_VALUE_REAL)
      77        6719 :                 pszValue = CPLSPrintf("%.15g", CPLAtof(pszValue));
      78       25971 :             aosSpecificOptions.SetNameValue(psChild->pszValue, pszValue);
      79             :         }
      80             :     }
      81        6024 :     oCoordPrec.oFormatSpecificOptions["FileGeodatabase"] =
      82        6024 :         std::move(aosSpecificOptions);
      83        6024 :     return oCoordPrec;
      84             : }
      85             : 
      86             : #endif /* FILEGDB_COORDPREC_READ_H */

Generated by: LCOV version 1.14