LCOV - code coverage report
Current view: top level - ogr/ogrsf_frmts/edigeo - ogr_edigeo.h (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 0 20 0.0 %
Date: 2024-05-02 00:41:30 Functions: 0 9 0.0 %

          Line data    Source code
       1             : /******************************************************************************
       2             :  * $Id$
       3             :  *
       4             :  * Project:  EDIGEO Translator
       5             :  * Purpose:  Definition of classes for OGR .edigeo driver.
       6             :  * Author:   Even Rouault, even dot rouault at spatialys.com
       7             :  *
       8             :  ******************************************************************************
       9             :  * Copyright (c) 2011, Even Rouault <even dot rouault at spatialys.com>
      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             : #ifndef OGR_EDIGEO_H_INCLUDED
      31             : #define OGR_EDIGEO_H_INCLUDED
      32             : 
      33             : #include "ogrsf_frmts.h"
      34             : #include <vector>
      35             : #include <map>
      36             : #include <set>
      37             : 
      38             : /************************************************************************/
      39             : /*                           OGREDIGEOLayer                             */
      40             : /************************************************************************/
      41             : 
      42             : class OGREDIGEODataSource;
      43             : 
      44             : class OGREDIGEOLayer final : public OGRLayer,
      45             :                              public OGRGetNextFeatureThroughRaw<OGREDIGEOLayer>
      46             : {
      47             :     OGREDIGEODataSource *poDS;
      48             : 
      49             :     OGRFeatureDefn *poFeatureDefn;
      50             :     OGRSpatialReference *poSRS;
      51             : 
      52             :     int nNextFID;
      53             : 
      54             :     OGRFeature *GetNextRawFeature();
      55             : 
      56             :     std::vector<OGRFeature *> aosFeatures;
      57             : 
      58             :     /* Map attribute RID ('TEX2_id') to its index in the OGRFeatureDefn */
      59             :     std::map<CPLString, int> mapAttributeToIndex;
      60             : 
      61             :   public:
      62             :     OGREDIGEOLayer(OGREDIGEODataSource *poDS, const char *pszName,
      63             :                    OGRwkbGeometryType eType, OGRSpatialReference *poSRS);
      64             :     virtual ~OGREDIGEOLayer();
      65             : 
      66             :     virtual void ResetReading() override;
      67           0 :     DEFINE_GET_NEXT_FEATURE_THROUGH_RAW(OGREDIGEOLayer)
      68             :     virtual OGRFeature *GetFeature(GIntBig nFID) override;
      69             :     virtual GIntBig GetFeatureCount(int bForce) override;
      70             : 
      71           0 :     virtual OGRFeatureDefn *GetLayerDefn() override
      72             :     {
      73           0 :         return poFeatureDefn;
      74             :     }
      75             : 
      76             :     virtual int TestCapability(const char *) override;
      77             : 
      78             :     virtual OGRErr GetExtent(OGREnvelope *psExtent, int bForce) override;
      79             : 
      80           0 :     virtual OGRErr GetExtent(int iGeomField, OGREnvelope *psExtent,
      81             :                              int bForce) override
      82             :     {
      83           0 :         return OGRLayer::GetExtent(iGeomField, psExtent, bForce);
      84             :     }
      85             : 
      86             :     void AddFeature(OGRFeature *poFeature);
      87             : 
      88             :     int GetAttributeIndex(const CPLString &osRID);
      89             :     void AddFieldDefn(const CPLString &osName, OGRFieldType eType,
      90             :                       const CPLString &osRID);
      91             : };
      92             : 
      93             : /************************************************************************/
      94             : /*                         OGREDIGEODataSource                          */
      95             : /************************************************************************/
      96             : 
      97             : typedef std::pair<int, int> intintType;
      98             : typedef std::pair<double, double> xyPairType;
      99             : typedef std::vector<xyPairType> xyPairListType;
     100             : typedef std::pair<CPLString, CPLString> strstrType;
     101             : typedef std::vector<CPLString> strListType;
     102             : 
     103             : /* From the .DIC file */
     104             : class OGREDIGEOAttributeDef
     105             : {
     106             :   public:
     107           0 :     OGREDIGEOAttributeDef()
     108           0 :     {
     109           0 :     }
     110             : 
     111             :     CPLString osLAB; /* e.g. TEX2 */
     112             :     CPLString osTYP; /* e.g. T */
     113             : };
     114             : 
     115             : /* From the .SCD file */
     116             : class OGREDIGEOObjectDescriptor
     117             : {
     118             :   public:
     119           0 :     OGREDIGEOObjectDescriptor()
     120           0 :     {
     121           0 :     }
     122             : 
     123             :     CPLString osRID;        /* e.g. BATIMENT_id */
     124             :     CPLString osNameRID;    /* e.g. ID_N_OBJ_E_2_1_0 */
     125             :     CPLString osKND;        /* e.g. ARE */
     126             :     strListType aosAttrRID; /* e.g. DUR_id, TEX_id */
     127             : };
     128             : 
     129             : /* From the .SCD file */
     130             : class OGREDIGEOAttributeDescriptor
     131             : {
     132             :   public:
     133           0 :     OGREDIGEOAttributeDescriptor() : nWidth(0)
     134             :     {
     135           0 :     }
     136             : 
     137             :     CPLString osRID;     /* e.g. TEX2_id */
     138             :     CPLString osNameRID; /* e.g. ID_N_ATT_TEX2 */
     139             :     int nWidth;          /* e.g. 80 */
     140             : };
     141             : 
     142             : /* From the .VEC files */
     143             : class OGREDIGEOFEADesc
     144             : {
     145             :   public:
     146           0 :     OGREDIGEOFEADesc()
     147           0 :     {
     148           0 :     }
     149             : 
     150             :     std::vector<strstrType>
     151             :         aosAttIdVal;     /* e.g. (TEX2_id,BECHEREL),(IDU_id,022) */
     152             :     CPLString osSCP;     /* e.g. COMMUNE_id */
     153             :     CPLString osQUP_RID; /* e.g. Actualite_Objet_X */
     154             : };
     155             : 
     156             : class OGREDIGEODataSource final : public OGRDataSource
     157             : {
     158             :     friend class OGREDIGEOLayer;
     159             : 
     160             :     char *pszName;
     161             :     VSILFILE *fpTHF;
     162             : 
     163             :     OGRLayer **papoLayers;
     164             :     int nLayers;
     165             : 
     166             :     VSILFILE *OpenFile(const char *pszType, const CPLString &osExt);
     167             : 
     168             :     // TODO: Translate comments to English.
     169             :     CPLString osLON; /* Nom du lot */
     170             :     CPLString osGNN; /* Nom du sous-ensemble de données générales */
     171             :     CPLString osGON; /* Nom du sous-ensemble de la référence de coordonnées */
     172             :     CPLString osQAN; /* Nom du sous-ensemble de qualité */
     173             :     CPLString osDIN; /* Nom du sous-ensemble de définition de la nomenclature */
     174             :     CPLString osSCN;    /* Nom du sous-ensemble de définition du SCD */
     175             :     strListType aosGDN; /* Nom du sous-ensemble de données géographiques */
     176             :     int ReadTHF(VSILFILE *fp);
     177             : 
     178             :     CPLString osREL;
     179             :     OGRSpatialReference *poSRS;
     180             :     int ReadGEO();
     181             : 
     182             :     /* Map from ID_N_OBJ_E_2_1_0 to OBJ_E_2_1_0 */
     183             :     std::map<CPLString, CPLString> mapObjects;
     184             : 
     185             :     /* Map from ID_N_ATT_TEX2 to (osLAB=TEX2, osTYP=T) */
     186             :     std::map<CPLString, OGREDIGEOAttributeDef> mapAttributes;
     187             :     int ReadDIC();
     188             : 
     189             :     std::vector<OGREDIGEOObjectDescriptor> aoObjList;
     190             :     /* Map from TEX2_id to (osNameRID=ID_N_ATT_TEX2, nWidth=80) */
     191             :     std::map<CPLString, OGREDIGEOAttributeDescriptor> mapAttributesSCD;
     192             :     int ReadSCD();
     193             : 
     194             :     int bExtentValid;
     195             :     double dfMinX;
     196             :     double dfMinY;
     197             :     double dfMaxX;
     198             :     double dfMaxY;
     199             :     int ReadGEN();
     200             : 
     201             :     /* Map from Actualite_Objet_X to (creationData, updateData) */
     202             :     std::map<CPLString, intintType> mapQAL;
     203             :     int ReadQAL();
     204             : 
     205             :     std::map<CPLString, OGREDIGEOLayer *> mapLayer;
     206             : 
     207             :     int CreateLayerFromObjectDesc(const OGREDIGEOObjectDescriptor &objDesc);
     208             : 
     209             :     std::map<CPLString, xyPairType> mapPNO; /* Map Noeud_X to (x,y) */
     210             :     std::map<CPLString, xyPairListType>
     211             :         mapPAR; /* Map Arc_X to ((x1,y1),...(xn,yn)) */
     212             :     std::map<CPLString, OGREDIGEOFEADesc> mapFEA; /* Map Object_X to FEADesc */
     213             :     std::map<CPLString, strListType>
     214             :         mapPFE_PAR; /* Map Face_X to (Arc_X1,..Arc_Xn) */
     215             :     std::vector<std::pair<CPLString, strListType>>
     216             :         listFEA_PFE; /* List of (Object_X,(Face_Y1,..Face_Yn)) */
     217             :     std::vector<std::pair<CPLString, strListType>>
     218             :         listFEA_PAR; /* List of (Object_X,(Arc_Y1,..Arc_Yn))) */
     219             :     std::vector<strstrType> listFEA_PNO; /* List of (Object_X,Noeud_Y) */
     220             :     std::map<CPLString, CPLString>
     221             :         mapFEA_FEA; /* Map Attribut_TEX{X}_id_Objet_{Y} to Objet_Y */
     222             : 
     223             :     int bRecodeToUTF8;
     224             :     int bHasUTF8ContentOnly;
     225             : 
     226             :     int ReadVEC(const char *pszVECName);
     227             : 
     228             :     OGRFeature *CreateFeature(const CPLString &osFEA);
     229             :     int BuildPoints();
     230             :     int BuildLineStrings();
     231             :     int BuildPolygon(const CPLString &osFEA, const strListType &aosPFE);
     232             :     int BuildPolygons();
     233             : 
     234             :     int iATR, iDI3, iDI4, iHEI, iFON;
     235             :     int iATR_VAL, iANGLE, iSIZE, iOBJ_LNK, iOBJ_LNK_LAYER;
     236             :     double dfSizeFactor;
     237             :     int bIncludeFontFamily;
     238             :     int SetStyle(const CPLString &osFEA, OGRFeature *poFeature);
     239             : 
     240             :     std::set<CPLString> setLayersWithLabels;
     241             :     void CreateLabelLayers();
     242             : 
     243             :     int bHasReadEDIGEO;
     244             :     void ReadEDIGEO();
     245             : 
     246             :   public:
     247             :     OGREDIGEODataSource();
     248             :     virtual ~OGREDIGEODataSource();
     249             : 
     250             :     int Open(const char *pszFilename);
     251             : 
     252           0 :     virtual const char *GetName() override
     253             :     {
     254           0 :         return pszName;
     255             :     }
     256             : 
     257             :     virtual int GetLayerCount() override;
     258             :     virtual OGRLayer *GetLayer(int) override;
     259             : 
     260             :     virtual int TestCapability(const char *) override;
     261             : 
     262           0 :     int HasUTF8ContentOnly()
     263             :     {
     264           0 :         return bHasUTF8ContentOnly;
     265             :     }
     266             : };
     267             : 
     268             : #endif /* ndef OGR_EDIGEO_H_INCLUDED */

Generated by: LCOV version 1.14