Skip to content

Commit

Permalink
PDF: rename ROUND_TO_INT_IF_CLOSE() function
Browse files Browse the repository at this point in the history
  • Loading branch information
rouault committed Sep 20, 2024
1 parent f69710d commit faa31be
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 16 deletions.
21 changes: 9 additions & 12 deletions frmts/pdf/pdfdataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3025,9 +3025,9 @@ static int GDALPDFParseStreamContent(const char *pszContent,
INT_MAX &&
dfHeight / dfScaleY * DEFAULT_DPI < INT_MAX)
{
double dfDPI_X = ROUND_TO_INT_IF_CLOSE(
double dfDPI_X = ROUND_IF_CLOSE(
dfWidth / dfScaleX * DEFAULT_DPI, 1e-3);
double dfDPI_Y = ROUND_TO_INT_IF_CLOSE(
double dfDPI_Y = ROUND_IF_CLOSE(
dfHeight / dfScaleY * DEFAULT_DPI,
1e-3);
// CPLDebug("PDF", "Image %s, width = %.16g,
Expand Down Expand Up @@ -3462,8 +3462,7 @@ void PDFDataset::GuessDPI(GDALPDFDictionary *poPageDict, int *pnBands)
(poUserUnit->GetType() == PDFObjectType_Int ||
poUserUnit->GetType() == PDFObjectType_Real))
{
m_dfDPI =
ROUND_TO_INT_IF_CLOSE(Get(poUserUnit) * DEFAULT_DPI, 1e-5);
m_dfDPI = ROUND_IF_CLOSE(Get(poUserUnit) * DEFAULT_DPI, 1e-5);
CPLDebug("PDF", "Found UserUnit in Page --> DPI = %.16g", m_dfDPI);
SetMetadataItem("DPI", CPLSPrintf("%.16g", m_dfDPI));
}
Expand Down Expand Up @@ -5398,13 +5397,11 @@ PDFDataset *PDFDataset::Open(GDALOpenInfo *poOpenInfo)
? 1e-5
: 1e-8;
poDS->m_adfGeoTransform[0] =
ROUND_TO_INT_IF_CLOSE(poDS->m_adfGeoTransform[0], dfEps);
poDS->m_adfGeoTransform[1] =
ROUND_TO_INT_IF_CLOSE(poDS->m_adfGeoTransform[1]);
ROUND_IF_CLOSE(poDS->m_adfGeoTransform[0], dfEps);
poDS->m_adfGeoTransform[1] = ROUND_IF_CLOSE(poDS->m_adfGeoTransform[1]);
poDS->m_adfGeoTransform[3] =
ROUND_TO_INT_IF_CLOSE(poDS->m_adfGeoTransform[3], dfEps);
poDS->m_adfGeoTransform[5] =
ROUND_TO_INT_IF_CLOSE(poDS->m_adfGeoTransform[5]);
ROUND_IF_CLOSE(poDS->m_adfGeoTransform[3], dfEps);
poDS->m_adfGeoTransform[5] = ROUND_IF_CLOSE(poDS->m_adfGeoTransform[5]);

if (bUseLib.test(PDFLIB_PDFIUM))
{
Expand Down Expand Up @@ -7208,8 +7205,8 @@ int PDFDataset::ParseMeasure(GDALPDFObject *poMeasure, double dfMediaBoxWidth,
}
}

x = ROUND_TO_INT_IF_CLOSE(x);
y = ROUND_TO_INT_IF_CLOSE(y);
x = ROUND_IF_CLOSE(x);
y = ROUND_IF_CLOSE(y);

asGCPS[i].dfGCPX = x;
asGCPS[i].dfGCPY = y;
Expand Down
6 changes: 3 additions & 3 deletions frmts/pdf/pdfobject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@
#include "pdfobject.h"

/************************************************************************/
/* ROUND_TO_INT_IF_CLOSE() */
/* ROUND_IF_CLOSE() */
/************************************************************************/

double ROUND_TO_INT_IF_CLOSE(double x, double eps)
double ROUND_IF_CLOSE(double x, double eps)
{
if (eps == 0.0)
eps = fabs(x) < 1 ? 1e-10 : 1e-8;
Expand Down Expand Up @@ -297,7 +297,7 @@ void GDALPDFObject::Serialize(CPLString &osStr, bool bEmitRef)
{
char szReal[512];
double dfRealNonRounded = GetReal();
double dfReal = ROUND_TO_INT_IF_CLOSE(dfRealNonRounded);
double dfReal = ROUND_IF_CLOSE(dfRealNonRounded);
if (dfReal >=
static_cast<double>(std::numeric_limits<GIntBig>::min()) &&
dfReal <=
Expand Down
2 changes: 1 addition & 1 deletion frmts/pdf/pdfobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
#define DEFAULT_DPI (72.0)
#define USER_UNIT_IN_INCH (1.0 / DEFAULT_DPI)

double ROUND_TO_INT_IF_CLOSE(double x, double eps = 0);
double ROUND_IF_CLOSE(double x, double eps = 0);

typedef enum
{
Expand Down

0 comments on commit faa31be

Please sign in to comment.