Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] master from OSGeo:master #46

Merged
merged 4 commits into from
Jan 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion .github/workflows/code_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,14 @@ jobs:
cd build
cmake ..

- name: Run cppcheck test
- name: Run cppcheck test (on push events)
if: ${{ github.event_name == 'push' }}
run: |
cd build
../scripts/cppcheck.sh

- name: Run cppcheck test, but ignore failures (on pull request)
if: ${{ github.event_name == 'pull_request' }}
run: |
cd build
# Do not fail the job. This is just used as a tool to monitor how we are regarding recent cppcheck
Expand Down
27 changes: 17 additions & 10 deletions ogr/ogr_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ int OGR_G_GetPoints(OGRGeometryH hGeom, void *pabyX, int nXStride, void *pabyY,
{
VALIDATE_POINTER1(hGeom, "OGR_G_GetPoints", 0);

int ret = 0;
switch (wkbFlatten(ToPointer(hGeom)->getGeometryType()))
{
case wkbPoint:
Expand All @@ -370,25 +371,27 @@ int OGR_G_GetPoints(OGRGeometryH hGeom, void *pabyX, int nXStride, void *pabyY,
*(static_cast<double *>(pabyY)) = poPoint->getY();
if (pabyZ)
*(static_cast<double *>(pabyZ)) = poPoint->getZ();
return 1;
ret = 1;
break;
}
break;

case wkbLineString:
case wkbCircularString:
{
OGRSimpleCurve *poSC = ToPointer(hGeom)->toSimpleCurve();
poSC->getPoints(pabyX, nXStride, pabyY, nYStride, pabyZ, nZStride);
return poSC->getNumPoints();
ret = poSC->getNumPoints();
break;
}
break;

default:
{
CPLError(CE_Failure, CPLE_NotSupported,
"Incompatible geometry for operation");
return 0;
break;
}
}
return ret;
}

/************************************************************************/
Expand Down Expand Up @@ -429,6 +432,7 @@ int OGR_G_GetPointsZM(OGRGeometryH hGeom, void *pabyX, int nXStride,
{
VALIDATE_POINTER1(hGeom, "OGR_G_GetPointsZM", 0);

int ret = 0;
switch (wkbFlatten(ToPointer(hGeom)->getGeometryType()))
{
case wkbPoint:
Expand All @@ -442,26 +446,29 @@ int OGR_G_GetPointsZM(OGRGeometryH hGeom, void *pabyX, int nXStride,
*static_cast<double *>(pabyZ) = poPoint->getZ();
if (pabyM)
*static_cast<double *>(pabyM) = poPoint->getM();
return 1;
ret = 1;
break;
}
break;

case wkbLineString:
case wkbCircularString:
{
OGRSimpleCurve *poSC = ToPointer(hGeom)->toSimpleCurve();
poSC->getPoints(pabyX, nXStride, pabyY, nYStride, pabyZ, nZStride,
pabyM, nMStride);
return poSC->getNumPoints();
ret = poSC->getNumPoints();
break;
}
break;

default:
{
CPLError(CE_Failure, CPLE_NotSupported,
"Incompatible geometry for operation");
return 0;
break;
}
}

return ret;
}

/************************************************************************/
Expand Down
21 changes: 11 additions & 10 deletions ogr/ogrsf_frmts/generic/ogr_gensql.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1387,19 +1387,19 @@ static CPLString GetFilterForJoin(swq_expr_node *poExpr, OGRFeature *poSrcFeat,
const OGRField *psSrcField =
poSrcFeat->GetRawFieldRef(poExpr->field_index);

CPLString osRet;
switch (ePrimaryFieldType)
{
case OFTInteger:
return CPLString().Printf("%d", psSrcField->Integer);
osRet.Printf("%d", psSrcField->Integer);
break;

case OFTInteger64:
return CPLString().Printf(CPL_FRMT_GIB,
psSrcField->Integer64);
osRet.Printf(CPL_FRMT_GIB, psSrcField->Integer64);
break;

case OFTReal:
return CPLString().Printf("%.17g", psSrcField->Real);
osRet.Printf("%.17g", psSrcField->Real);
break;

case OFTString:
Expand All @@ -1408,18 +1408,19 @@ static CPLString GetFilterForJoin(swq_expr_node *poExpr, OGRFeature *poSrcFeat,
psSrcField->String,
static_cast<int>(strlen(psSrcField->String)),
CPLES_SQL);
CPLString osRes = "'";
osRes += pszEscaped;
osRes += "'";
osRet = "'";
osRet += pszEscaped;
osRet += "'";
CPLFree(pszEscaped);
return osRes;
break;
}
break;

default:
CPLAssert(false);
return "";
break;
}

return osRet;
}
}

Expand Down
33 changes: 20 additions & 13 deletions ogr/ogrsf_frmts/mitab/mitab_imapinfofile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ TABFeature *IMapInfoFile::CreateTABFeature(OGRFeature *poFeature)
*------------------------------------------------------------*/
case wkbPolygon:
case wkbMultiPolygon:
{
poTABFeature = new TABRegion(poFeature->GetDefnRef());
if (poFeature->GetStyleString())
{
Expand All @@ -308,11 +309,13 @@ TABFeature *IMapInfoFile::CreateTABFeature(OGRFeature *poFeature)
poFeature->GetStyleString());
}
break;
}
/*-------------------------------------------------------------
* LINE/PLINE/MULTIPLINE
*------------------------------------------------------------*/
case wkbLineString:
case wkbMultiLineString:
{
poTABFeature = new TABPolyline(poFeature->GetDefnRef());
if (poFeature->GetStyleString())
{
Expand All @@ -322,6 +325,7 @@ TABFeature *IMapInfoFile::CreateTABFeature(OGRFeature *poFeature)
poFeature->GetStyleString());
}
break;
}
/*-------------------------------------------------------------
* Collection types that are not directly supported... convert
* to multiple features in output file through recursive calls.
Expand All @@ -332,38 +336,41 @@ TABFeature *IMapInfoFile::CreateTABFeature(OGRFeature *poFeature)
OGRErr eStatus = OGRERR_NONE;
assert(poGeom); // for clang static analyzer
OGRGeometryCollection *poColl = poGeom->toGeometryCollection();
OGRFeature *poTmpFeature = poFeature->Clone();
auto poTmpFeature = std::unique_ptr<OGRFeature>(poFeature->Clone());

for (int i = 0; eStatus == OGRERR_NONE && poColl != nullptr &&
i < poColl->getNumGeometries();
i++)
{
poTmpFeature->SetFID(OGRNullFID);
poTmpFeature->SetGeometry(poColl->getGeometryRef(i));
eStatus = ICreateFeature(poTmpFeature);
eStatus = ICreateFeature(poTmpFeature.get());
}
delete poTmpFeature;
return nullptr;
break;
}
break;

/*-------------------------------------------------------------
* Unsupported type.... convert to MapInfo geometry NONE
*------------------------------------------------------------*/
case wkbUnknown:
default:
{
poTABFeature = new TABFeature(poFeature->GetDefnRef());
break;
}
}

if (poGeom != nullptr)
poTABFeature->SetGeometryDirectly(poGeom->clone());

for (int i = 0; i < poFeature->GetDefnRef()->GetFieldCount(); i++)
if (poTABFeature)
{
poTABFeature->SetField(i, poFeature->GetRawFieldRef(i));
}
if (poGeom != nullptr)
poTABFeature->SetGeometryDirectly(poGeom->clone());

poTABFeature->SetFID(poFeature->GetFID());
for (int i = 0; i < poFeature->GetDefnRef()->GetFieldCount(); i++)
{
poTABFeature->SetField(i, poFeature->GetRawFieldRef(i));
}

poTABFeature->SetFID(poFeature->GetFID());
}

return poTABFeature;
}
Expand Down
8 changes: 8 additions & 0 deletions port/cpl_known_config_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -348,12 +348,19 @@ constexpr static const char* const apszKnownConfigOptions[] =
"GDAL_PAM_ENABLED", // from gdalpamdataset.cpp
"GDAL_PAM_MODE", // from gdalpamdataset.cpp
"GDAL_PAM_PROXY_DIR", // from gdalpamproxydb.cpp
"GDAL_PDF_BANDS", // from pdfdrivercore.cpp
"GDAL_PDF_DPI", // from pdfdrivercore.cpp
"GDAL_PDF_GEO_ENCODING", // from pdfcreatecopy.cpp, pdfdataset.cpp
"GDAL_PDF_LAUNDER_LAYER_NAMES", // from pdfdataset.cpp
"GDAL_PDF_LAYERS", // from pdfdrivercore.cpp
"GDAL_PDF_LAYERS_OFF", // from pdfdrivercore.cpp
"GDAL_PDF_LIB", // from pdfdrivercore.cpp
"GDAL_PDF_LIMIT_PAGE_COUNT", // from pdfdataset.cpp
"GDAL_PDF_NEATLINE", // from pdfdrivercore.cpp
"GDAL_PDF_OGC_BP_READ_WKT", // from pdfdataset.cpp
"GDAL_PDF_OGC_BP_WRITE_WKT", // from pdfcreatecopy.cpp, pdfcreatefromcomposition.cpp
"GDAL_PDF_PRINT_COMMANDS", // from pdfdataset.cpp
"GDAL_PDF_RENDERING_OPTIONS", // from pdfdrivercore.cpp
"GDAL_PDF_USE_SPAWN", // from pdfdataset.cpp
"GDAL_PDF_WRITE_ESRI_CODE_AS_EPSG", // from pdfcreatecopy.cpp
"GDAL_PDF_WRITE_GEOREF_ON_IMAGE", // from pdfcreatecopy.cpp
Expand Down Expand Up @@ -899,6 +906,7 @@ constexpr static const char* const apszKnownConfigOptions[] =
"PDF_DUMP_STREAM", // from pdfdataset.cpp
"PDF_REPORT_GCPS", // from pdfdataset.cpp
"PDF_USE_CTM", // from pdfdataset.cpp
"PDF_USER_PWD", // from pdfdrivercore.cpp
"PDS4_ENDIANNESS", // from pds4vector.cpp
"PDS4_FORCE_MASK", // from pds4dataset.cpp
"PDS4_SIGNEDNESS", // from pds4vector.cpp
Expand Down
10 changes: 10 additions & 0 deletions scripts/collect_config_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,16 @@ def collect_config_options(filename):
else:
options[option].add(os.path.basename(filename))

pos = l.find("alt_config_option='")
if pos >= 0:
pos_start = pos + len("alt_config_option='")
pos_end = l.find("'", pos_start)
option = l[pos_start:pos_end]
if option not in options:
options[option] = set([os.path.basename(filename)])
else:
options[option].add(os.path.basename(filename))


def explore(dirname):
for filename in glob.glob(dirname + "/*"):
Expand Down
Loading