LCOV - code coverage report
Current view: top level - ogr/ogrsf_frmts/sxf - org_sxf_defs.h (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 6 6 100.0 %
Date: 2025-01-18 12:42:00 Functions: 1 1 100.0 %

          Line data    Source code
       1             : /******************************************************************************
       2             :  *
       3             :  * Project:  SXF Translator
       4             :  * Purpose:  Include file defining Records Structures for file reading and
       5             :  *           basic constants.
       6             :  * Author:   Ben Ahmed Daho Ali, bidandou(at)yahoo(dot)fr
       7             :  *           Dmitry Baryshnikov, polimax@mail.ru
       8             :  *           Alexandr Lisovenko, alexander.lisovenko@gmail.com
       9             :  *
      10             :  ******************************************************************************
      11             :  * Copyright (c) 2011, Ben Ahmed Daho Ali
      12             :  * Copyright (c) 2013, NextGIS
      13             :  *
      14             :  * SPDX-License-Identifier: MIT
      15             :  *
      16             :  ******************************************************************************
      17             :  * Structure of the SXF file :
      18             :  * ----------------------
      19             :  *    - Header
      20             :  *    - Passport
      21             :  *    - Descriptor of data
      22             :  *    - Records
      23             :  *         - Title of the record
      24             :  *         - The certificate of the object (the geometry)
      25             :  *             - sub-objects
      26             :  *             - The graphic description of object
      27             :  *             - The description of the vector of the tying of the 3d- model of
      28             :  *object
      29             :  *         - Semantics of object
      30             :  *
      31             :  * Notes  :
      32             :  * -------
      33             :  * Note 1.  Flag of the state of data (2 bits):
      34             :  * xxxxxx11- given in the state e (size of the exchange of data).
      35             :  *
      36             :  * Note 2.  Flag of the correspondence to projection (1 bit):
      37             :  * xxxxx0xx - do not correspond to the projection (i.e. map it can have turning
      38             :  *                 relative to true position and certain deformation);
      39             :  * xxxxx1xx - correspond to projection.
      40             :  *
      41             :  * Note 3.  Flag of the presence of real coordinates (2 bits):
      42             :  * xxx00xxx - entire certificate of objects is represented in the conditional
      43             :  *                                 system of coordinates (in the samples);
      44             :  * xxx11xxx - entire certificate of objects is represented in the real
      45             :  *coordinates in the locality in accordance with the specifications of sheet
      46             :  *            (projection, the coordinate system, unit of measurement),
      47             :  *            the data about the scale and the discretion of digitization bear
      48             :  *            reference nature.
      49             :  *
      50             :  * Note 4. Flag of the method of coding (2 bits):
      51             :  * x00xxxxx - the classification codes of objects and semantic characteristics
      52             :  *          are represented by the decimal numbers, recorded in the binary
      53             :  *          form (for example: the code of the object "32100000" will be written
      54             :  *          down in the form 0x01E9CEA0, the code of semantics "253" - in the
      55             :  *form 0x00FD).
      56             :  *
      57             :  * Note 5. Table of generalization (1 bit):
      58             :  * 0xxxxxxx - the level of generalization is assigned according to the table of
      59             :  *the general maps (it is described in Table 2.4); 1xxxxxxx - noload condition
      60             :  *the level of generalization is assigned according to the table of the
      61             :  *large-scale maps (it is described in Table 2.5).
      62             :  *
      63             :  * Note 6.  Flag of coding the texts of the Texts objects (1 bytes):
      64             :  * 0- in the coding ASCIIZ (Dos);
      65             :  * 1- in the coding ANSI (Windows);
      66             :  * 2- in the coding KOI-8 (Unix).
      67             :  *
      68             :  * Note 7.  Flag of the accuracy of coordinates (1 bytes):
      69             :  * 0 - are not established;
      70             :  * 1 - the increased accuracy of storage of coordinates (meters, radians or
      71             :  *degrees); 2 - of coordinate are recorded with an accuracy to centimeter
      72             :  *(meters, 2 signs after comma); 3 - coordinates are recorded with an accuracy
      73             :  *to millimeter (meters, 3 sign after comma).
      74             :  *
      75             :  * Note 8. Form of the framework (1 byte):
      76             :  * -1- it is not established;
      77             :  *  0- map is unconfined by the framework;
      78             :  *  1- trapeziform without the salient points;
      79             :  *  2- trapeziform with the salient points;
      80             :  *  3- rectangular;
      81             :  *  4- circular;
      82             :  *  5- arbitrary.
      83             :  *
      84             :  * Note 9. Sign of output to the framework (4 bits):
      85             :  * 0000xxxx - there are no outputs to the framework;
      86             :  * 1000xxxx - northern framework;
      87             :  * 0100xxxx - eastern framework;
      88             :  * 0010xxxx - southern framework;
      89             :  * 0001xxxx - western framework.
      90             :  *
      91             :  * Note 10. Size of the element of certificate (1 bit):
      92             :  * xxxxx0xx - 2 bytes (for the integer value);
      93             :  *            4 bytes (for the floating point);
      94             :  * xxxxx1xx - 4 bytes (for the integer value);
      95             :  *            8 bytes (for the floating point).
      96             :  *
      97             :  * Note 11. Sign of certificate with the text (1 bit):
      98             :  * xxxx0xxx - certificate contains only the coordinates of points;
      99             :  * xxxx1xxx - no-load condition certificate contains the text of signature,
     100             :  *         is allowed only for the objects of the type "signature" or
     101             :  *         "the template of signature".
     102             :  *
     103             :  * Note 12. [Masshtabiruemost] of drawing (sign) (1 bit):
     104             :  * xx0xxxxx - arbitrary symbol of object not scaled;
     105             :  * xx1xxxxx - the arbitrary symbol of object is scaled during the mapping.
     106             :  *
     107             :  * Note 13. Sign of the construction of spline on the certificate (2 bits):
     108             :  * 00xxxxxx - the construction of spline with the visualization is not carried
     109             :  *out; 01xxxxxx - smoothing out spline (cutting angles); 10xxxxxx - enveloping
     110             :  *spline (it penetrates all points of certificate).
     111             :  ****************************************************************************/
     112             : 
     113             : #ifndef SXF_DEFS_H
     114             : #define SXF_DEFS_H
     115             : 
     116             : #define IDSXF 0x00465853 /* SXF  */
     117             : 
     118             : #define IDSXFDATA 0x00544144   /* DAT  */
     119             : #define IDSXFOBJ 0X7FFF7FFF    /* Object */
     120             : #define IDSXFGRAPH 0X7FFF7FFE  /* graphics section */
     121             : #define IDSXFVECT3D 0X7FFF7FFD /* 3D vector section */
     122             : 
     123             : #include <map>
     124             : 
     125             : #include "cpl_port.h"
     126             : 
     127             : enum SXFDataState /* Flag of the state of the data (Note 1) */
     128             : {
     129             :     SXF_DS_UNKNOWN = 0,
     130             :     SXF_DS_EXCHANGE = 8
     131             : };
     132             : 
     133             : enum SXFCodingType /* Flag of the semantics coding type (Note 4) */
     134             : {
     135             :     SXF_SEM_DEC = 0,
     136             :     SXF_SEM_HEX = 1,
     137             :     SXF_SEM_TXT = 2
     138             : };
     139             : 
     140             : enum SXFGeneralizationType /* Flag of the source for generalization data (Note
     141             :                               5) */
     142             : {
     143             :     SXF_GT_SMALL_SCALE = 0,
     144             :     SXF_GT_LARGE_SCALE = 1
     145             : };
     146             : 
     147             : enum SXFTextEncoding /* Flag of text encoding (Note 6) */
     148             : {
     149             :     SXF_ENC_DOS = 0,
     150             :     SXF_ENC_WIN = 1,
     151             :     SXF_ENC_KOI_8 = 2
     152             : 
     153             : #define SXF_ENC_LAST SXF_ENC_KOI_8
     154             : };
     155             : 
     156             : enum SXFCoordinatesAccuracy /* Flag of coordinate storing accuracy (Note 7) */
     157             : {
     158             :     SXF_COORD_ACC_UNDEFINED = 0,
     159             :     SXF_COORD_ACC_HIGH = 1,  // meters, radians or degree
     160             :     SXF_COORD_ACC_CM = 2,    // cantimeters
     161             :     SXF_COORD_ACC_MM = 3,    // millimeters
     162             :     SXF_COORD_ACC_DM = 4     // decimeters
     163             : 
     164             : #define SXF_COORD_ACC_LAST SXF_COORD_ACC_DM
     165             : };
     166             : 
     167             : typedef struct
     168             : {
     169             :     //    SXFDataState   stDataState;         /* Flag of the state of the data
     170             :     //    (Note 1) may be will be needed in future*/
     171             :     bool bProjectionDataCompliance;  /* Flag of the correspondence to the
     172             :                                         projection (Note 2) */
     173             :     bool bRealCoordinatesCompliance; /* Flag of the presence of the real
     174             :                                         coordinates (Note 3) */
     175             :     SXFCodingType stCodingType; /* Flag of the semantics coding type (Note 4) */
     176             :     SXFGeneralizationType
     177             :         stGenType; /* Flag of the source for generalization data (Note 5) */
     178             :     SXFTextEncoding stEnc; /* Flag of text encoding (Note 6) */
     179             :     SXFCoordinatesAccuracy
     180             :         stCoordAcc; /* Flag of coordinate storing accuracy (Note 7) */
     181             :     bool bSort;
     182             : } SXFInformationFlags;
     183             : 
     184             : enum SXFCoordinateMeasUnit
     185             : {
     186             :     SXF_COORD_MU_METRE = 1,
     187             :     SXF_COORD_MU_DECIMETRE,
     188             :     SXF_COORD_MU_CENTIMETRE,
     189             :     SXF_COORD_MU_MILLIMETRE,
     190             :     SXF_COORD_MU_DEGREE,
     191             :     SXF_COORD_MU_RADIAN
     192             : };
     193             : 
     194             : struct SXFMapDescription
     195             : {
     196             :     double stProjCoords[8];  // X(0) & Y(1) South West, X(2) & Y(3) North West,
     197             :                              // X(4) & Y(5) North East, X(6) & Y(7) South East
     198             :     double stGeoCoords[8];
     199             :     double stFrameCoords[8];
     200             :     OGREnvelope Env{};
     201             :     OGRSpatialReference *pSpatRef = nullptr;
     202             :     SXFCoordinateMeasUnit eUnitInPlan = SXF_COORD_MU_METRE;
     203             :     double dfXOr = 0;
     204             :     double dfYOr = 0;
     205             :     double dfFalseNorthing = 0;
     206             :     double dfFalseEasting = 0;
     207             :     GUInt32 nResolution = 0;
     208             :     double dfScale = 0;
     209             :     bool bIsRealCoordinates = false;
     210             :     SXFCoordinatesAccuracy stCoordAcc = SXF_COORD_ACC_UNDEFINED;
     211             : 
     212           6 :     SXFMapDescription()
     213           6 :     {
     214           6 :         memset(stProjCoords, 0, sizeof(stProjCoords));
     215           6 :         memset(stGeoCoords, 0, sizeof(stProjCoords));
     216           6 :         memset(stFrameCoords, 0, sizeof(stFrameCoords));
     217           6 :     }
     218             : };
     219             : 
     220             : enum SXFCoordinateType
     221             : {
     222             :     SXF_CT_RECTANGULAR = 0,
     223             :     SXF_CT_GEODETIC
     224             : };
     225             : 
     226             : /*
     227             :  * List of SXF file format geometry types.
     228             :  */
     229             : enum SXFGeometryType
     230             : {
     231             :     SXF_GT_Unknown = -1,
     232             :     SXF_GT_Line = 0,    /* MultiLineString geometric object                  */
     233             :     SXF_GT_Polygon = 1, /* Polygon geometric object                          */
     234             :     SXF_GT_Point = 2,   /* MultiPoint geometric object                       */
     235             :     SXF_GT_Text = 3,    /* LineString geometric object with associated label */
     236             :     SXF_GT_Vector = 4,  /* Vector geometric object with associated label */
     237             :     SXF_GT_TextTemplate = 5, /* Text template */
     238             :     SXF_GT_VectorAngle = 21, /* Rotated symbol */
     239             :     SXF_GT_VectorScaled = 22 /* Scaled symbol */
     240             : };
     241             : 
     242             : enum SXFValueType
     243             : {
     244             :     SXF_VT_SHORT = 0, /* 2 byte integer */
     245             :     SXF_VT_FLOAT = 1, /* 2 byte float */
     246             :     SXF_VT_INT = 2,   /* 4 byte integer*/
     247             :     SXF_VT_DOUBLE = 3 /* 8 byte float */
     248             : };
     249             : 
     250             : typedef struct
     251             : {
     252             :     SXFGeometryType eGeomType;  // Geometry type (Note 1)
     253             :     SXFValueType eValType;      // size of values (Note 3)
     254             :     int bFormat;  // Has 3D vector (Note 4) /* Format of the certificate (0-
     255             :                   // linear size, 1-vector format ) */
     256             :     GByte bDim;   // Dimensionality of the idea (0- 2D, 1- 3D) (Note 6)
     257             :     bool bHasTextSign;        // Sign of certificate with the text (Note 8)
     258             :     GUInt32 nPointCount;      // Point count
     259             :     GUInt16 nSubObjectCount;  // The sub object count
     260             : 
     261             : } SXFRecordDescription;
     262             : 
     263             : typedef struct
     264             : {
     265             :     GUInt32 nID; /* Identifier of the beginning of record (0x7FFF7FFF) */
     266             :     GUInt32 nFullLength;     /* The overall length of record (with the title) */
     267             :     GUInt32 nGeometryLength; /* Length of certificate (in bytes) */
     268             :     GUInt32 nClassifyCode;   /* Classification code */
     269             :     GUInt16 anGroup[2];      /* 0 - group no, 1 - no in group */
     270             :     GByte nRef[3];           /* Reference data */
     271             :     GByte byPadding;
     272             :     GUInt32 nPointCount;      /* Point count */
     273             :     GUInt16 nSubObjectCount;  /* The sub object count */
     274             :     GUInt16 nPointCountSmall; /* Point count in small geometries */
     275             : } SXFRecordHeader;
     276             : 
     277             : typedef struct
     278             : {
     279             :     GUInt16 nCode;  // type
     280             :     char nType;
     281             :     char nScale;
     282             : } SXFRecordAttributeInfo;
     283             : 
     284             : enum SXFRecordAttributeType
     285             : {
     286             :     SXF_RAT_ASCIIZ_DOS = 0,  // text in DOS encoding
     287             :     SXF_RAT_ONEBYTE = 1,     // number 1 byte
     288             :     SXF_RAT_TWOBYTE = 2,     // number 2 byte
     289             :     SXF_RAT_FOURBYTE = 4,    // number 4 byte
     290             :     SXF_RAT_EIGHTBYTE = 8,   // float point number 8 byte
     291             :     SXF_RAT_ANSI_WIN = 126,  // text in Win encoding
     292             :     SXF_RAT_UNICODE = 127,   // text in unicode
     293             :     SXF_RAT_BIGTEXT = 128    // text more than 255 chars
     294             : };
     295             : 
     296             : /************************************************************************/
     297             : /*                         SXFPassport                                  */
     298             : /************************************************************************/
     299             : 
     300             : struct SXFDate
     301             : {
     302             :     GUInt16 nYear = 0, nMonth = 0, nDay = 0;
     303             : };
     304             : 
     305             : struct SXFPassport
     306             : {
     307             :     GUInt32 version = 0;
     308             :     SXFDate dtCrateDate{};
     309             :     CPLString sMapSheet{};
     310             :     GUInt32 nScale = 0;
     311             :     CPLString sMapSheetName{};
     312             :     SXFInformationFlags informationFlags;
     313             :     SXFMapDescription stMapDescription{};
     314             : };
     315             : 
     316             : typedef struct
     317             : {
     318             :     char szID[4];             // the file ID should be "SXF"
     319             :     GUInt32 nHeaderLength;    // the Header length
     320             :     GByte nFormatVersion[4];  // the format version (e.g. 4)
     321             :     GUInt32 nCheckSum;        // check sum
     322             : } SXFHeader;
     323             : 
     324             : /************************************************************************/
     325             : /*                         RSCInfo                                      */
     326             : /************************************************************************/
     327             : 
     328             : /*
     329             :     RSC File record
     330             : */
     331             : typedef struct
     332             : {
     333             :     GUInt32 nOffset;  // RSC Section offset in bytes from the beginning of the
     334             :                       // RSC file
     335             :     GUInt32 nLength;  // RSC Section record length
     336             :     GUInt32 nRecordCount;  // count of records in the section
     337             : } RSCSection;
     338             : 
     339             : /*
     340             :     RSC File header
     341             : */
     342             : typedef struct
     343             : {
     344             :     char szID[4];
     345             :     GUInt32 nFileLength;
     346             :     GUInt32 nVersion;
     347             :     GUInt32 nEncoding;
     348             :     GUInt32 nFileState;
     349             :     GUInt32 nFileModState;
     350             :     GUInt32 nLang;  // 1 - en, 2 - rus
     351             :     GUInt32 nNextID;
     352             :     GByte date[8];
     353             :     char szMapType[32];
     354             :     char szClassifyName[32];
     355             :     char szClassifyCode[8];
     356             :     GUInt32 nScale;
     357             :     char nScales[4];
     358             :     RSCSection Objects;
     359             :     RSCSection Semantic;
     360             :     RSCSection ClassifySemantic;
     361             :     RSCSection Defaults;
     362             :     RSCSection Semantics;
     363             :     RSCSection Layers;
     364             :     RSCSection Limits;
     365             :     RSCSection Parameters;
     366             :     RSCSection Print;
     367             :     RSCSection Palettes;
     368             :     RSCSection Fonts;
     369             :     RSCSection Libs;
     370             :     RSCSection ImageParams;
     371             :     RSCSection Tables;
     372             :     GByte nFlagKeysAsCodes;
     373             :     GByte nFlagPaletteMods;
     374             :     GByte Reserved[30];
     375             :     GUInt32 nFontEnc;
     376             :     GUInt32 nColorsInPalette;
     377             : } RSCHeader;
     378             : 
     379             : #endif /* SXF_DEFS_H */

Generated by: LCOV version 1.14