Skip to content

Commit 46dcd39

Browse files
authored
MiramonVector: Cleaning the code and reunification of 3 functions (#12109)
Cleans up the code: * Removes the use of GDAL_COMPILATION. * Rewrites certain wrapper functions to use native GDAL-style implementations. * Moves the following functions from mm_wrlayr.c/h to mm_gdal_functions.c/h: ** MMReturnValueFromSectionINIFile ** MMReturnCodeFromMM_m_idofic ** MMCheck_REL_FILE
1 parent 922276f commit 46dcd39

11 files changed

+1629
-1986
lines changed

ogr/ogrsf_frmts/miramon/mm_constants.h

+2-15
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,7 @@
33
/* -------------------------------------------------------------------- */
44
/* Constants used in GDAL and in MiraMon */
55
/* -------------------------------------------------------------------- */
6-
#ifdef GDAL_COMPILATION
76
CPL_C_START // Necessary for compiling C in GDAL project
8-
#else
9-
#ifndef UINT32_MAX
10-
#define UINT32_MAX _UI32_MAX
11-
#endif
12-
#endif // GDAL_COMPILATION
137

148
#define MM_OFFSET_BYTESxCAMP_CAMP_CLASSIC 16
159
#define MM_OFFSET_BYTESxCAMP_CAMP_ESPECIAL 21
@@ -78,11 +72,6 @@ CPL_C_START // Necessary for compiling C in GDAL project
7872

7973
#define MM_MAX_ID_SNY 41
8074

81-
#ifndef GDAL_COMPILATION
82-
typedef unsigned int uint32_t;
83-
typedef int int32_t;
84-
#endif
85-
8675
// Extended DBF
8776
// Type of the number of records of an extended DBF
8877
#define MM_MAX_N_CAMPS_DBF_CLASSICA 255
@@ -141,7 +130,7 @@ typedef int int32_t;
141130
#define MM_JOC_CARAC_UTF8_DBF 0xFF
142131
#define MM_JOC_CARAC_UTF8_MM 8
143132

144-
typedef unsigned char MM_BYTE;
133+
typedef unsigned char MM_BYTE;
145134

146135
#define MM_PRIMER_OFFSET_a_OFFSET_1a_FITXA 8
147136
#define MM_SEGON_OFFSET_a_OFFSET_1a_FITXA 30
@@ -163,7 +152,5 @@ typedef unsigned char MM_BYTE;
163152

164153
#define MM_CHARACTERS_DOUBLE 40
165154

166-
#ifdef GDAL_COMPILATION
167155
CPL_C_END // Necessary for compiling in GDAL project
168-
#endif
169-
#endif //__MM_CONSTANTS_H
156+
#endif //__MM_CONSTANTS_H

ogr/ogrsf_frmts/miramon/mm_gdal_constants.h

+4-14
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,8 @@
33
/* -------------------------------------------------------------------- */
44
/* Constants used in GDAL and in MiraMon */
55
/* -------------------------------------------------------------------- */
6-
#ifndef GDAL_COMPILATION
7-
#ifdef _WIN64
8-
#include "gdal\release-1911-x64\cpl_port.h" // For GUInt64
9-
#else
10-
#include "gdal\release-1911-32\cpl_port.h" // For GUInt64
11-
#endif
12-
#else
136
#include "cpl_port.h" // For GUInt64
14-
CPL_C_START // Necessary for compiling C in GDAL project
15-
#endif // GDAL_COMPILATION
7+
CPL_C_START // Necessary for compiling C in GDAL project
168

179
#if defined(_WIN32) && !defined(strcasecmp)
1810
#define strcasecmp stricmp
@@ -22,8 +14,8 @@ CPL_C_START // Necessary for compiling C in GDAL project
2214

2315
#define sprintf_UINT64 "%llu"
2416

25-
// Type of the Feature ID: determines the maximum number of features in a layer.
26-
typedef GUInt64 MM_INTERNAL_FID;
17+
// Type of the Feature ID: determines the maximum number of features in a layer.
18+
typedef GUInt64 MM_INTERNAL_FID;
2719
// Offset to the coordinates of the Features.
2820
typedef GUInt64 MM_FILE_OFFSET;
2921

@@ -91,7 +83,5 @@ enum MM_TipusNomCamp
9183
#define MM_DonaBytesNomEstesCamp(camp) \
9284
((MM_BYTE)((camp)->reserved_2[MM_OFFSET_RESERVED2_EXTENDED_NAME_SIZE]))
9385

94-
#ifdef GDAL_COMPILATION
9586
CPL_C_END // Necessary for compiling in GDAL project
96-
#endif
97-
#endif //__MM_GDAL_CONSTANTS_H
87+
#endif //__MM_GDAL_CONSTANTS_H

ogr/ogrsf_frmts/miramon/mm_gdal_driver_structs.h

+14-22
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,10 @@
44
/* Necessary functions to read/write a MiraMon Vector File */
55
/* -------------------------------------------------------------------- */
66

7-
#ifdef GDAL_COMPILATION
87
#include "mm_gdal_constants.h"
98
#include "mm_gdal_structures.h"
109

1110
CPL_C_START // Necessary for compiling in GDAL project
12-
#else
13-
#include <stdio.h> // For FILE
14-
#include "mm_constants.h"
15-
#include "mm_gdal\mm_gdal_structures.h"
16-
#endif
1711

1812
// For MetaData
1913
#define SECTION_VERSIO "VERSIO"
@@ -259,7 +253,7 @@ struct MM_FLUSH_INFO
259253
GUInt64 NTimesFlushed;
260254

261255
// Pointer to an OPEN file where to flush.
262-
FILE_TYPE *pF;
256+
VSILFILE *pF;
263257
// Offset in the disk where to flush
264258
MM_FILE_OFFSET OffsetWhereToFlush;
265259

@@ -493,19 +487,19 @@ struct MiraMonPointLayer
493487
{
494488
// Name of the layer with extension
495489
char pszLayerName[MM_CPL_PATH_BUF_SIZE];
496-
FILE_TYPE *pF;
490+
VSILFILE *pF;
497491

498492
// Coordinates x,y of the points
499493
struct MM_FLUSH_INFO FlushTL;
500494
char *pTL; // (II mode)
501495
char pszTLName[MM_CPL_PATH_BUF_SIZE]; // Temporary file where to flush
502-
FILE_TYPE *pFTL; // Pointer to temporary file where to flush
496+
VSILFILE *pFTL; // Pointer to temporary file where to flush
503497

504498
// Z section
505499
// Temporary file where the Z coordinates are stored
506500
// if necessary
507501
char psz3DLayerName[MM_CPL_PATH_BUF_SIZE];
508-
FILE_TYPE *pF3d;
502+
VSILFILE *pF3d;
509503
struct MM_ZSection pZSection;
510504

511505
// MiraMon table (extended DBF)
@@ -519,7 +513,7 @@ struct MiraMonNodeLayer
519513
{
520514
char
521515
pszLayerName[MM_CPL_PATH_BUF_SIZE]; // Name of the layer with extension
522-
FILE_TYPE *pF;
516+
VSILFILE *pF;
523517

524518
// Header of every node
525519
GUInt32 nSizeNodeHeader;
@@ -530,7 +524,7 @@ struct MiraMonNodeLayer
530524
struct MM_FLUSH_INFO FlushNL; // (II mode)
531525
char *pNL; //
532526
char pszNLName[MM_CPL_PATH_BUF_SIZE]; // Temporary file where to flush
533-
FILE_TYPE *pFNL; // Pointer to temporary file where to flush
527+
VSILFILE *pFNL; // Pointer to temporary file where to flush
534528

535529
struct MMAdmDatabase MMAdmDB;
536530

@@ -542,12 +536,12 @@ struct MiraMonArcLayer
542536
{
543537
char
544538
pszLayerName[MM_CPL_PATH_BUF_SIZE]; // Name of the layer with extension
545-
FILE_TYPE *pF;
539+
VSILFILE *pF;
546540

547541
// Temporal file where the Z coordinates are stored
548542
// if necessary
549543
char psz3DLayerName[MM_CPL_PATH_BUF_SIZE];
550-
FILE_TYPE *pF3d;
544+
VSILFILE *pF3d;
551545

552546
// Header of every arc
553547
GUInt32 nSizeArcHeader;
@@ -559,7 +553,7 @@ struct MiraMonArcLayer
559553
unsigned short int nALElementSize; // 16 bytes: 2 doubles (coordinates)
560554
char *pAL; // Arc List // (II mode)
561555
char pszALName[MM_CPL_PATH_BUF_SIZE]; // Temporary file where to flush
562-
FILE_TYPE *pFAL; // Pointer to temporary file where to flush
556+
VSILFILE *pFAL; // Pointer to temporary file where to flush
563557

564558
// Z section
565559
struct MM_ZSection pZSection;
@@ -583,14 +577,14 @@ struct MiraMonPolygonLayer
583577
{
584578
char
585579
pszLayerName[MM_CPL_PATH_BUF_SIZE]; // Name of the layer with extension
586-
FILE_TYPE *pF;
580+
VSILFILE *pF;
587581

588582
// PS part
589583
struct MM_FLUSH_INFO FlushPS;
590584
unsigned short int nPSElementSize;
591585
char *pPS; // Polygon side (II mode)
592586
char pszPSName[MM_CPL_PATH_BUF_SIZE]; // Temporary file where to flush
593-
FILE_TYPE *pFPS; // Pointer to temporary file where to flush
587+
VSILFILE *pFPS; // Pointer to temporary file where to flush
594588

595589
// Header of every polygon
596590
MM_INTERNAL_FID nMaxPolHeader; // Number of pPolHeader allocated
@@ -602,7 +596,7 @@ struct MiraMonPolygonLayer
602596
unsigned short int nPALElementSize;
603597
char *pPAL; // Polygon Arc List // (II mode)
604598
char pszPALName[MM_CPL_PATH_BUF_SIZE]; // Temporary file where to flush
605-
FILE_TYPE *pFPAL; // Pointer to temporary file where to flush
599+
VSILFILE *pFPAL; // Pointer to temporary file where to flush
606600

607601
// Arc layer associated to the arc layer
608602
struct MM_TH TopArcHeader;
@@ -676,7 +670,7 @@ struct MiraMonFeature
676670
struct MiraMonVectMapInfo
677671
{
678672
char pszMapName[MM_CPL_PATH_BUF_SIZE];
679-
FILE_TYPE *fMMMap;
673+
VSILFILE *fMMMap;
680674
int nNumberOfLayers;
681675
};
682676

@@ -832,7 +826,5 @@ enum TreatmentVariable
832826
MMTVCategorical
833827
};
834828

835-
#ifdef GDAL_COMPILATION
836829
CPL_C_END // Necessary for compiling in GDAL project
837-
#endif
838-
#endif //__MM_GDAL_DRIVER_STRUCTS_H
830+
#endif //__MM_GDAL_DRIVER_STRUCTS_H

0 commit comments

Comments
 (0)