LCOV - code coverage report
Current view: top level - ogr/ogrsf_frmts/s101 - ogrs101featurecatalog.h (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 6 6 100.0 %
Date: 2026-05-29 23:25:07 Functions: 3 3 100.0 %

          Line data    Source code
       1             : /******************************************************************************
       2             :  *
       3             :  * Project:  S-101 driver
       4             :  * Purpose:  Header file for OGRS101FeatureCatalog
       5             :  * Author:   Even Rouault <even dot rouault at spatialys.com>
       6             :  *
       7             :  ******************************************************************************
       8             :  * Copyright (c) 2026, Even Rouault <even dot rouault at spatialys.com>
       9             :  *
      10             :  * SPDX-License-Identifier: MIT
      11             :  ****************************************************************************/
      12             : 
      13             : #ifndef OGR_S101_FEATURE_CATALOG_H_INCLUDED
      14             : #define OGR_S101_FEATURE_CATALOG_H_INCLUDED
      15             : 
      16             : struct CPLXMLNode;
      17             : 
      18             : #include <map>
      19             : #include <set>
      20             : #include <string>
      21             : #include <utility>
      22             : 
      23             : namespace OGRS101FeatureCatalogTypes
      24             : {
      25             : struct SimpleAttribute
      26             : {
      27             :     std::string code{};  // short string
      28             :     std::string name{};  // longer string
      29             :     std::string definition{};
      30             :     std::string type{};
      31             :     std::map<int, std::string> enumeratedValues{};
      32             : };
      33             : 
      34             : struct ComplexAttribute
      35             : {
      36             :     std::string code{};  // short string
      37             :     std::string name{};  // longer string
      38             :     std::string definition{};
      39             :     std::set<std::string> attributeBindings{};
      40             : };
      41             : 
      42             : struct InformationType
      43             : {
      44             :     std::string code{};  // short string
      45             :     std::string name{};  // longer string
      46             :     std::string definition{};
      47             :     std::string alias{};
      48             :     std::set<std::string> attributeBindings{};
      49             : };
      50             : 
      51             : struct FeatureType
      52             : {
      53             :     std::string code{};  // short string
      54             :     std::string name{};  // longer string
      55             :     std::string definition{};
      56             :     std::string alias{};
      57             :     std::set<std::string> attributeBindings{};
      58             :     std::set<std::string> permittedPrimitives{};
      59             : };
      60             : }  // namespace OGRS101FeatureCatalogTypes
      61             : 
      62             : /************************************************************************/
      63             : /*                        OGRS101FeatureCatalog                         */
      64             : /************************************************************************/
      65             : 
      66             : class OGRS101FeatureCatalog
      67             : {
      68             :   public:
      69             :     using SimpleAttribute = OGRS101FeatureCatalogTypes::SimpleAttribute;
      70             :     using ComplexAttribute = OGRS101FeatureCatalogTypes::ComplexAttribute;
      71             :     using InformationType = OGRS101FeatureCatalogTypes::InformationType;
      72             :     using FeatureType = OGRS101FeatureCatalogTypes::FeatureType;
      73             : 
      74             :     // Valid values for <permittedPrimitives> element of <S100_FC_FeatureType>
      75             :     static constexpr const char *PERMITTED_PRIMITIVE_NO_GEOMETRY = "noGeometry";
      76             :     static constexpr const char *PERMITTED_PRIMITIVE_POINT = "point";
      77             :     static constexpr const char *PERMITTED_PRIMITIVE_POINTSET = "pointSet";
      78             :     static constexpr const char *PERMITTED_PRIMITIVE_CURVE = "curve";
      79             :     static constexpr const char *PERMITTED_PRIMITIVE_SURFACE = "surface";
      80             : 
      81             :     // Valid values for <valueType> element of <S100_FC_SimpleAttribute>
      82             :     static constexpr const char *VALUE_TYPE_BOOLEAN = "boolean";
      83             :     static constexpr const char *VALUE_TYPE_ENUMERATION = "enumeration";
      84             :     static constexpr const char *VALUE_TYPE_INTEGER = "integer";
      85             :     static constexpr const char *VALUE_TYPE_REAL = "real";
      86             :     static constexpr const char *VALUE_TYPE_TRUNCATED_DATE =
      87             :         "S100_TruncatedDate";
      88             :     static constexpr const char *VALUE_TYPE_TEXT = "text";
      89             :     static constexpr const char *VALUE_TYPE_TIME = "time";
      90             :     static constexpr const char *VALUE_TYPE_URI = "URI";
      91             :     static constexpr const char *VALUE_TYPE_URN = "URN";
      92             : 
      93             :     explicit OGRS101FeatureCatalog(bool bStrict);
      94             : 
      95             :     static void CleanupSingletonFeatureCatalog();
      96             : 
      97             :     enum class LoadingStatus
      98             :     {
      99             :         UNINIT,
     100             :         OK,
     101             :         SKIPPED,
     102             :         ERROR
     103             :     };
     104             : 
     105             :     static std::pair<LoadingStatus, const OGRS101FeatureCatalog *>
     106             :     GetSingletonFeatureCatalog(bool bStrict);
     107             : 
     108             :     std::string GetFilename(bool &bError) const;
     109             : 
     110             :     LoadingStatus Load();
     111             : 
     112             :     /* Return a map from the code of a simple attribute to its definition */
     113         583 :     const std::map<std::string, SimpleAttribute> &GetSimpleAttributes() const
     114             :     {
     115         583 :         return m_simpleAttributes;
     116             :     }
     117             : 
     118             :     /* Return a map from the code of a complex attribute to its definition */
     119         348 :     const std::map<std::string, ComplexAttribute> &GetComplexAttributes() const
     120             :     {
     121         348 :         return m_complexAttributes;
     122             :     }
     123             : 
     124             :     /* Return a map from the code of an information type to its definition */
     125             :     const std::map<std::string, InformationType> &GetInformationTypes() const
     126             :     {
     127             :         return m_informationTypes;
     128             :     }
     129             : 
     130             :     /* Return a map from the code of a feature type to its definition */
     131         600 :     const std::map<std::string, FeatureType> &GetFeatureTypes() const
     132             :     {
     133         600 :         return m_featureTypes;
     134             :     }
     135             : 
     136             :   private:
     137             :     const bool m_bStrict;
     138             : 
     139             :     std::map<std::string, SimpleAttribute> m_simpleAttributes{};
     140             :     std::map<std::string, ComplexAttribute> m_complexAttributes{};
     141             :     std::map<std::string, InformationType> m_informationTypes{};
     142             :     std::map<std::string, FeatureType> m_featureTypes{};
     143             : 
     144             :     static bool EmitErrorOrWarning(const char *pszFile, const char *pszFunc,
     145             :                                    int nLine, const char *pszMsg, bool bError,
     146             :                                    bool bRecoverable);
     147             : 
     148             :     bool LoadSimpleAttributes(const char *pszFC, const CPLXMLNode *psRoot);
     149             :     bool LoadComplexAttributes(const char *pszFC, const CPLXMLNode *psRoot);
     150             :     bool LoadInformationTypes(const char *pszFC, const CPLXMLNode *psRoot);
     151             :     bool LoadFeatureTypes(const char *pszFC, const CPLXMLNode *psRoot);
     152             : };
     153             : 
     154             : #endif  // OGR_S101_FEATURE_CATALOG_H_INCLUDED

Generated by: LCOV version 1.14