Skip to content

Commit

Permalink
Adjustments in the number of decimals to print in a MiraMon DBF for p…
Browse files Browse the repository at this point in the history
…rivate fields
  • Loading branch information
AbelPau committed Apr 12, 2024
1 parent 6dbc058 commit 1982375
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 10 deletions.
5 changes: 5 additions & 0 deletions ogr/ogrsf_frmts/miramon/mm_gdal_driver_structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,17 @@ CPL_C_START // Necessary for compiling in GDAL project
#define szMMNomCampNArcsDefecte "N_ARCS"
#define szMMNomCampNPoligonsDefecte "N_POLIG"

#define MAX_RELIABLE_SF_DOUBLE \
15 // Maximum nr. of reliable significant figures in any double.

// Initial width of MiraMon fields
#define MM_MIN_WIDTH_ID_GRAFIC 3
#define MM_MIN_WIDTH_N_VERTEXS 5
#define MM_MIN_WIDTH_INITIAL_NODE MM_MIN_WIDTH_ID_GRAFIC + 1
#define MM_MIN_WIDTH_FINAL_NODE MM_MIN_WIDTH_ID_GRAFIC + 1
#define MM_MIN_WIDTH_ARCS_TO_NODE 1
#define MM_MIN_WIDTH_LONG 14 // For LONG_ARC and PERIMETRE
#define MM_MIN_WIDTH_AREA 19 // For LONG_ARC and PERIMETRE

#define MM_MIN_WIDTH_N_ARCS 2
#define MM_MIN_WIDTH_N_POLIG 2
Expand Down
8 changes: 3 additions & 5 deletions ogr/ogrsf_frmts/miramon/mm_gdal_functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -2027,15 +2027,13 @@ size_t MM_DefineFirstPolygonFieldsDB_XP(struct MM_DATA_BASE_XP *bd_xp,

MM_FillFieldDB_XP(bd_xp->pField + i_camp, szMMNomCampPerimetreDefecte,
szPerimeterOfThePolygonEng, szPerimeterOfThePolygonCat,
szPerimeterOfThePolygonSpa, 'N',
MM_MAX_AMPLADA_CAMP_N_DBF, n_decimals);
szPerimeterOfThePolygonSpa, 'N', MM_MIN_WIDTH_LONG, 9);
(bd_xp->pField + i_camp)->GeoTopoTypeField = (MM_BYTE)MM_CAMP_ES_PERIMETRE;
i_camp++;

MM_FillFieldDB_XP(bd_xp->pField + i_camp, szMMNomCampAreaDefecte,
szAreaOfThePolygonEng, szAreaOfThePolygonCat,
szAreaOfThePolygonSpa, 'N', MM_MAX_AMPLADA_CAMP_N_DBF,
n_decimals);
szAreaOfThePolygonSpa, 'N', MM_MIN_WIDTH_AREA, 12);
(bd_xp->pField + i_camp)->GeoTopoTypeField = (MM_BYTE)MM_CAMP_ES_AREA;
i_camp++;

Expand Down Expand Up @@ -2077,7 +2075,7 @@ size_t MM_DefineFirstArcFieldsDB_XP(struct MM_DATA_BASE_XP *bd_xp,

MM_FillFieldDB_XP(bd_xp->pField + i_camp, szMMNomCampLongitudArcDefecte,
szLenghtOfAarcEng, szLenghtOfAarcCat, szLenghtOfAarcSpa,
'N', MM_MAX_AMPLADA_CAMP_N_DBF, n_decimals);
'N', MM_MIN_WIDTH_LONG, 9);
(bd_xp->pField + i_camp)->GeoTopoTypeField = (MM_BYTE)MM_CAMP_ES_LONG_ARC;
i_camp++;

Expand Down
23 changes: 18 additions & 5 deletions ogr/ogrsf_frmts/miramon/ogrmiramonlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1914,12 +1914,25 @@ OGRErr OGRMiraMonLayer::TranslateFieldsToMM()
{
if (m_poFeatureDefn->GetFieldDefn(iField)->GetPrecision() == 0)
{
phMiraMonLayer->pLayerDB->pFields[iField].nFieldSize =
m_poFeatureDefn->GetFieldDefn(iField)->GetWidth();
if (phMiraMonLayer->pLayerDB->pFields[iField].nFieldSize ==
0)
if (m_poFeatureDefn->GetFieldDefn(iField)->GetType() ==
OFTReal ||
m_poFeatureDefn->GetFieldDefn(iField)->GetType() ==
OFTReal)
{
phMiraMonLayer->pLayerDB->pFields[iField].nFieldSize =
1;
20;
phMiraMonLayer->pLayerDB->pFields[iField]
.nNumberOfDecimals = MAX_RELIABLE_SF_DOUBLE;
}
else
{
phMiraMonLayer->pLayerDB->pFields[iField].nFieldSize =
m_poFeatureDefn->GetFieldDefn(iField)->GetWidth();
if (phMiraMonLayer->pLayerDB->pFields[iField]
.nFieldSize == 0)
phMiraMonLayer->pLayerDB->pFields[iField]
.nFieldSize = 1;
}
}
else
{
Expand Down

0 comments on commit 1982375

Please sign in to comment.