| 1 | /****************************************************************************** |
| 2 | * |
| 3 | * Project: OpenGIS Simple Features Reference Implementation |
| 4 | * Purpose: Implements OGRGenSQLResultsLayer. |
| 5 | * Author: Frank Warmerdam, [email protected] |
| 6 | * |
| 7 | ****************************************************************************** |
| 8 | * Copyright (c) 2002, Frank Warmerdam |
| 9 | * Copyright (c) 2008-2014, Even Rouault <even dot rouault at spatialys.com> |
| 10 | * |
| 11 | * SPDX-License-Identifier: MIT |
| 12 | ****************************************************************************/ |
| 13 | |
| 14 | #include "ogr_swq.h"cxx . . $ `<file>/ogr/ogr_swq.h`/ |
| 15 | #include "ogr_p.h"cxx . . $ `<file>/ogr/ogr_p.h`/ |
| 16 | #include "ogr_gensql.h"cxx . . $ `<file>/ogr/ogrsf_frmts/generic/ogr_gensql.h`/ |
| 17 | #include "cpl_string.h"cxx . . $ `<file>/port/cpl_string.h`/ |
| 18 | #include "ogr_api.h"cxx . . $ `<file>/ogr/ogr_api.h`/ |
| 19 | #include "ogr_recordbatch.h"cxx . . $ `<file>/ogr/ogr_recordbatch.h`/ |
| 20 | #include "ogrlayerarrow.h"cxx . . $ `<file>/ogr/ogrsf_frmts/generic/ogrlayerarrow.h`/ |
| 21 | #include "cpl_time.h"cxx . . $ `<file>/port/cpl_time.h`/ |
| 22 | #include <algorithm> |
| 23 | #include <limits> |
| 24 | #include <map> |
| 25 | #include <set> |
| 26 | #include <vector> |
| 27 | |
| 28 | //! @cond Doxygen_Suppress |
| 29 | extern const swq_field_typecxx . . $ swq_field_type# SpecialFieldTypescxx . . $ SpecialFieldTypes.[SPECIAL_FIELD_COUNTcxx . . $ `ogr/ogr_p.h:174:9`!]; |
| 30 | |
| 31 | class OGRGenSQLGeomFieldDefncxx . . $ OGRGenSQLGeomFieldDefn# final : public OGRGeomFieldDefncxx . . $ OGRGeomFieldDefn# |
| 32 | { |
| 33 | public: |
| 34 | explicit OGRGenSQLGeomFieldDefncxx . . $ OGRGenSQLGeomFieldDefn#OGRGenSQLGeomFieldDefn(926e7c3bb01b7816).(OGRGeomFieldDefncxx . . $ OGRGeomFieldDefn# *poGeomFieldDefn) |
| 35 | : OGRGeomFieldDefncxx . . $ OGRGeomFieldDefn#(poGeomFieldDefn->GetNameRefcxx . . $ OGRGeomFieldDefn#GetNameRef(a9f41ea0e82d88cf).(), |
| 36 | poGeomFieldDefn->GetTypecxx . . $ OGRGeomFieldDefn#GetType(5a40c54c5ff210ce).()), |
| 37 | bForceGeomTypecxx . . $ OGRGenSQLGeomFieldDefn#bForceGeomType.(FALSEcxx . . $ `port/cpl_port.h:1180:9`!) |
| 38 | { |
| 39 | SetSpatialRefcxx . . $ OGRGeomFieldDefn#SetSpatialRef(9ff39b79387a6086).(poGeomFieldDefn->GetSpatialRefcxx . . $ OGRGeomFieldDefn#GetSpatialRef(8a5496c2eeefaeaf).()); |
| 40 | } |
| 41 | |
| 42 | ~cxx . . $ OGRGenSQLGeomFieldDefn#`~OGRGenSQLGeomFieldDefn`(ced63f7c635d850d).OGRGenSQLGeomFieldDefncxx . . $ OGRGenSQLGeomFieldDefn#() override; |
| 43 | |
| 44 | int bForceGeomTypecxx . . $ OGRGenSQLGeomFieldDefn#bForceGeomType.; |
| 45 | }; |
| 46 | |
| 47 | OGRGenSQLGeomFieldDefncxx . . $ OGRGenSQLGeomFieldDefn#::~cxx . . $ OGRGenSQLGeomFieldDefn#`~OGRGenSQLGeomFieldDefn`(ced63f7c635d850d).OGRGenSQLGeomFieldDefncxx . . $ OGRGenSQLGeomFieldDefn#() = default; |
| 48 | |
| 49 | /************************************************************************/ |
| 50 | /* OGRGenSQLResultsLayerHasSpecialField() */ |
| 51 | /************************************************************************/ |
| 52 | |
| 53 | static bool OGRGenSQLResultsLayerHasSpecialFieldcxx . . $ OGRGenSQLResultsLayerHasSpecialField(62405623713e743f).(swq_expr_nodecxx . . $ swq_expr_node# *expr, |
| 54 | int nMinIndexForSpecialField) |
| 55 | { |
| 56 | if (expr->eNodeTypecxx . . $ swq_expr_node#eNodeType. == SNT_COLUMNcxx . . $ SNT_COLUMN.) |
| 57 | { |
| 58 | if (expr->table_indexcxx . . $ swq_expr_node#table_index. == 0) |
| 59 | { |
| 60 | return expr->field_indexcxx . . $ swq_expr_node#field_index. >= nMinIndexForSpecialField && |
| 61 | expr->field_indexcxx . . $ swq_expr_node#field_index. < |
| 62 | nMinIndexForSpecialField + SPECIAL_FIELD_COUNTcxx . . $ `ogr/ogr_p.h:174:9`!; |
| 63 | } |
| 64 | } |
| 65 | else if (expr->eNodeTypecxx . . $ swq_expr_node#eNodeType. == SNT_OPERATIONcxx . . $ SNT_OPERATION.) |
| 66 | { |
| 67 | for (int i = 0; i < expr->nSubExprCountcxx . . $ swq_expr_node#nSubExprCount.; i++) |
| 68 | { |
| 69 | if (OGRGenSQLResultsLayerHasSpecialFieldcxx . . $ OGRGenSQLResultsLayerHasSpecialField(62405623713e743f).(expr->papoSubExprcxx . . $ swq_expr_node#papoSubExpr.[i], |
| 70 | nMinIndexForSpecialField)) |
| 71 | return true; |
| 72 | } |
| 73 | } |
| 74 | return false; |
| 75 | } |
| 76 | |
| 77 | /************************************************************************/ |
| 78 | /* OGRGenSQLResultsLayer() */ |
| 79 | /************************************************************************/ |
| 80 | |
| 81 | OGRGenSQLResultsLayercxx . . $ OGRGenSQLResultsLayer#::OGRGenSQLResultsLayercxx . . $ OGRGenSQLResultsLayer#OGRGenSQLResultsLayer(3392455f7efad55d).( |
| 82 | GDALDatasetcxx . . $ GDALDataset# *poSrcDSIn, stdcxx . . $ std/::unique_ptr<swq_selectcxx . . $ swq_select#> &&pSelectInfo, |
| 83 | const OGRGeometrycxx . . $ OGRGeometry# *poSpatFilter, const char *pszWHEREIn, |
| 84 | const char *pszDialect) |
| 85 | : m_poSrcDScxx . . $ OGRGenSQLResultsLayer#m_poSrcDS.(poSrcDSIn), m_pSelectInfocxx . . $ OGRGenSQLResultsLayer#m_pSelectInfo.(stdcxx . . $ std/::move(pSelectInfo)) |
| 86 | { |
| 87 | swq_selectcxx . . $ swq_select# *psSelectInfo = m_pSelectInfocxx . . $ OGRGenSQLResultsLayer#m_pSelectInfo..get(); |
| 88 | |
| 89 | /* -------------------------------------------------------------------- */ |
| 90 | /* Identify all the layers involved in the SELECT. */ |
| 91 | /* -------------------------------------------------------------------- */ |
| 92 | m_apoTableLayerscxx . . $ OGRGenSQLResultsLayer#m_apoTableLayers..reserve(psSelectInfo->table_countcxx . . $ swq_select#table_count.); |
| 93 | |
| 94 | for (int iTable = 0; iTable < psSelectInfo->table_countcxx . . $ swq_select#table_count.; iTable++) |
| 95 | { |
| 96 | swq_table_defcxx . . $ swq_table_def# *psTableDef = psSelectInfo->table_defscxx . . $ swq_select#table_defs. + iTable; |
| 97 | GDALDatasetcxx . . $ GDALDataset# *poTableDS = m_poSrcDScxx . . $ OGRGenSQLResultsLayer#m_poSrcDS.; |
| 98 | |
| 99 | if (psTableDef->data_sourcecxx . . $ $anonymous_type_a69ae1a4ba3d583e_4#data_source. != nullptr) |
| 100 | { |
| 101 | stdcxx . . $ std/::unique_ptr<GDALDatasetcxx . . $ GDALDataset#, GDALDatasetUniquePtrReleasercxx . . $ GDALDatasetUniquePtrReleaser#> poNewDS( |
| 102 | GDALDatasetcxx . . $ GDALDataset#::Opencxx . . $ GDALDataset#Open(b5df334a701f7bea).(psTableDef->data_sourcecxx . . $ $anonymous_type_a69ae1a4ba3d583e_4#data_source., |
| 103 | GDAL_OF_VECTORcxx . . $ `gcore/gdal.h:1130:9`! | GDAL_OF_SHAREDcxx . . $ `gcore/gdal.h:1150:9`!)); |
| 104 | if (!poNewDS) |
| 105 | { |
| 106 | if (strlen(CPLGetLastErrorMsg()) == 0) |
| 107 | CPLError(CE_Failure, CPLE_AppDefinedcxx . . $ `port/cpl_error.h:108:9`!, |
| 108 | "Unable to open secondary datasource\n" |
| 109 | "`%s' required by JOIN.", |
| 110 | psTableDef->data_sourcecxx . . $ $anonymous_type_a69ae1a4ba3d583e_4#data_source.); |
| 111 | return; |
| 112 | } |
| 113 | |
| 114 | m_apoExtraDScxx . . $ OGRGenSQLResultsLayer#m_apoExtraDS..emplace_back(stdcxx . . $ std/::move(poNewDS)); |
| 115 | poTableDS = m_apoExtraDScxx . . $ OGRGenSQLResultsLayer#m_apoExtraDS..back().get(); |
| 116 | } |
| 117 | |
| 118 | m_apoTableLayerscxx . . $ OGRGenSQLResultsLayer#m_apoTableLayers..push_back( |
| 119 | poTableDS->GetLayerByNamecxx . . $ GDALDataset#GetLayerByName(5ddf27af0841fa5b).(psTableDef->table_namecxx . . $ $anonymous_type_a69ae1a4ba3d583e_4#table_name.)); |
| 120 | if (!m_apoTableLayerscxx . . $ OGRGenSQLResultsLayer#m_apoTableLayers..back()) |
| 121 | return; |
| 122 | } |
| 123 | |
| 124 | m_poSrcLayercxx . . $ OGRGenSQLResultsLayer#m_poSrcLayer. = m_apoTableLayerscxx . . $ OGRGenSQLResultsLayer#m_apoTableLayers.[0]; |
| 125 | SetMetadatacxx . . $ GDALMajorObject#SetMetadata(6c7b553169186fed).(m_poSrcLayercxx . . $ OGRGenSQLResultsLayer#m_poSrcLayer.->GetMetadatacxx . . $ GDALMajorObject#GetMetadata(2103d2459cfb75c0).("NATIVE_DATA"), "NATIVE_DATA"); |
| 126 | |
| 127 | /* -------------------------------------------------------------------- */ |
| 128 | /* If the user has explicitly requested a OGRSQL dialect, then */ |
| 129 | /* we should avoid to forward the where clause to the source layer */ |
| 130 | /* when there is a risk it cannot understand it (#4022) */ |
| 131 | /* -------------------------------------------------------------------- */ |
| 132 | m_bForwardWhereToSourceLayercxx . . $ OGRGenSQLResultsLayer#m_bForwardWhereToSourceLayer. = true; |
| 133 | if (pszWHEREIn) |
| 134 | { |
| 135 | if (psSelectInfo->where_exprcxx . . $ swq_select#where_expr. && pszDialect != nullptr && |
| 136 | EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszDialect, "OGRSQL")) |
| 137 | { |
| 138 | const int nMinIndexForSpecialField = |
| 139 | m_poSrcLayercxx . . $ OGRGenSQLResultsLayer#m_poSrcLayer.->GetLayerDefncxx . . $ OGRLayer#GetLayerDefn(407fccde18759965).()->GetFieldCountcxx . . $ OGRFeatureDefn#GetFieldCount(455f465bc33b4cdf).(); |
| 140 | m_bForwardWhereToSourceLayercxx . . $ OGRGenSQLResultsLayer#m_bForwardWhereToSourceLayer. = |
| 141 | !OGRGenSQLResultsLayerHasSpecialFieldcxx . . $ OGRGenSQLResultsLayerHasSpecialField(62405623713e743f).(psSelectInfo->where_exprcxx . . $ swq_select#where_expr., |
| 142 | nMinIndexForSpecialField); |
| 143 | } |
| 144 | m_osInitialWHEREcxx . . $ OGRGenSQLResultsLayer#m_osInitialWHERE. = pszWHEREIn; |
| 145 | } |
| 146 | |
| 147 | /* -------------------------------------------------------------------- */ |
| 148 | /* Prepare a feature definition based on the query. */ |
| 149 | /* -------------------------------------------------------------------- */ |
| 150 | OGRFeatureDefncxx . . $ OGRFeatureDefn# *poSrcDefn = m_poSrcLayercxx . . $ OGRGenSQLResultsLayer#m_poSrcLayer.->GetLayerDefncxx . . $ OGRLayer#GetLayerDefn(407fccde18759965).(); |
| 151 | |
| 152 | m_poDefncxx . . $ OGRGenSQLResultsLayer#m_poDefn. = new OGRFeatureDefncxx . . $ OGRFeatureDefn#(psSelectInfo->table_defscxx . . $ swq_select#table_defs.[0].table_aliascxx . . $ $anonymous_type_a69ae1a4ba3d583e_4#table_alias.); |
| 153 | SetDescriptioncxx . . $ GDALMajorObject#SetDescription(85c52e162fed56f9).(m_poDefncxx . . $ OGRGenSQLResultsLayer#m_poDefn.->GetNamecxx . . $ OGRFeatureDefn#GetName(a9f41ea0e82d88cf).()); |
| 154 | m_poDefncxx . . $ OGRGenSQLResultsLayer#m_poDefn.->SetGeomTypecxx . . $ OGRFeatureDefn#SetGeomType(f47ce3f1fe923726).(wkbNone); |
| 155 | m_poDefncxx . . $ OGRGenSQLResultsLayer#m_poDefn.->Referencecxx . . $ OGRFeatureDefn#Reference(b126dc7c1de90089).(); |
| 156 | |
| 157 | m_iFIDFieldIndexcxx . . $ OGRGenSQLResultsLayer#m_iFIDFieldIndex. = poSrcDefn->GetFieldCountcxx . . $ OGRFeatureDefn#GetFieldCount(455f465bc33b4cdf).(); |
| 158 | |
| 159 | for (stdcxx . . $ std/::size_tcxx . . $ std/size_t# iField = 0; iField < psSelectInfo->column_defscxx . . $ swq_select#column_defs..size(); |
| 160 | iField++) |
| 161 | { |
| 162 | swq_col_defcxx . . $ swq_col_def# *psColDef = &psSelectInfo->column_defscxx . . $ swq_select#column_defs.[iField]; |
| 163 | OGRFieldDefncxx . . $ OGRFieldDefn# oFDefncxx . . $ OGRFieldDefn#OGRFieldDefn(786ecb48a0b3b841).("", OFTInteger); |
| 164 | OGRGeomFieldDefncxx . . $ OGRGeomFieldDefn# oGFDefncxx . . $ OGRGeomFieldDefn#OGRGeomFieldDefn(465d6c96388e9b45).("", wkbUnknown); |
| 165 | OGRFieldDefncxx . . $ OGRFieldDefn# *poSrcFDefn = nullptr; |
| 166 | OGRGeomFieldDefncxx . . $ OGRGeomFieldDefn# *poSrcGFDefn = nullptr; |
| 167 | int bIsGeometry = FALSEcxx . . $ `port/cpl_port.h:1180:9`!; |
| 168 | OGRFeatureDefncxx . . $ OGRFeatureDefn# *poLayerDefn = nullptr; |
| 169 | int iSrcGeomField = -1; |
| 170 | |
| 171 | if (psColDef->bHiddencxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#bHidden.) |
| 172 | continue; |
| 173 | |
| 174 | if (psColDef->table_indexcxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#table_index. != -1) |
| 175 | poLayerDefn = |
| 176 | m_apoTableLayerscxx . . $ OGRGenSQLResultsLayer#m_apoTableLayers.[psColDef->table_indexcxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#table_index.]->GetLayerDefncxx . . $ OGRLayer#GetLayerDefn(407fccde18759965).(); |
| 177 | |
| 178 | if (psColDef->field_indexcxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#field_index. > -1 && poLayerDefn != nullptr && |
| 179 | psColDef->field_indexcxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#field_index. < poLayerDefn->GetFieldCountcxx . . $ OGRFeatureDefn#GetFieldCount(455f465bc33b4cdf).()) |
| 180 | { |
| 181 | poSrcFDefn = poLayerDefn->GetFieldDefncxx . . $ OGRFeatureDefn#GetFieldDefn(2ec36f91b6ceefc7).(psColDef->field_indexcxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#field_index.); |
| 182 | } |
| 183 | |
| 184 | if (poLayerDefn != nullptr && |
| 185 | IS_GEOM_FIELD_INDEXcxx . . $ `ogr/ogrsf_frmts/generic/ogr_gensql.h:29:9`!(poLayerDefn, psColDef->field_index)) |
| 186 | { |
| 187 | bIsGeometry = TRUEcxx . . $ `port/cpl_port.h:1184:9`!; |
| 188 | iSrcGeomField = ALL_FIELD_INDEX_TO_GEOM_FIELD_INDEXcxx . . $ `ogr/ogrsf_frmts/generic/ogr_gensql.h:34:9`!( |
| 189 | poLayerDefn, psColDef->field_index); |
| 190 | poSrcGFDefn = poLayerDefn->GetGeomFieldDefncxx . . $ OGRFeatureDefn#GetGeomFieldDefn(39768c424f32bab2).(iSrcGeomField); |
| 191 | } |
| 192 | |
| 193 | if (psColDef->target_typecxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#target_type. == SWQ_GEOMETRYcxx . . $ SWQ_GEOMETRY.) |
| 194 | bIsGeometry = TRUEcxx . . $ `port/cpl_port.h:1184:9`!; |
| 195 | |
| 196 | if (psColDef->col_funccxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#col_func. == SWQCF_COUNTcxx . . $ SWQCF_COUNT.) |
| 197 | bIsGeometry = FALSEcxx . . $ `port/cpl_port.h:1180:9`!; |
| 198 | |
| 199 | if (strlen(psColDef->field_namecxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#field_name.) == 0 && !bIsGeometry) |
| 200 | { |
| 201 | CPLFreecxx . . $ `port/cpl_conv.h:97:9`!(psColDef->field_namecxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#field_name.); |
| 202 | psColDef->field_namecxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#field_name. = static_cast<char *>(CPLMalloc(40)); |
| 203 | snprintf(psColDef->field_namecxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#field_name., 40, "FIELD_%d", |
| 204 | m_poDefncxx . . $ OGRGenSQLResultsLayer#m_poDefn.->GetFieldCountcxx . . $ OGRFeatureDefn#GetFieldCount(455f465bc33b4cdf).() + 1); |
| 205 | } |
| 206 | |
| 207 | if (psColDef->field_aliascxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#field_alias. != nullptr) |
| 208 | { |
| 209 | if (bIsGeometry) |
| 210 | oGFDefn.SetNamecxx . . $ OGRGeomFieldDefn#SetName(85c52e162fed56f9).(psColDef->field_aliascxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#field_alias.); |
| 211 | else |
| 212 | oFDefn.SetNamecxx . . $ OGRFieldDefn#SetName(85c52e162fed56f9).(psColDef->field_aliascxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#field_alias.); |
| 213 | } |
| 214 | else if (psColDef->col_funccxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#col_func. != SWQCF_NONEcxx . . $ SWQCF_NONE.) |
| 215 | { |
| 216 | const swq_operationcxx . . $ swq_operation# *op = swq_op_registrarcxx . . $ swq_op_registrar#::GetOperatorcxx . . $ swq_op_registrar#GetOperator(1354da5907640745).( |
| 217 | static_cast<swq_opcxx . . $ swq_op#>(psColDef->col_funccxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#col_func.)); |
| 218 | |
| 219 | oFDefn.SetNamecxx . . $ OGRFieldDefn#SetName(85c52e162fed56f9).( |
| 220 | CPLSPrintf("%s_%s", op->pszNamecxx . . $ $anonymous_type_a69ae1a4ba3d583e_3#pszName., psColDef->field_namecxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#field_name.)); |
| 221 | } |
| 222 | else |
| 223 | { |
| 224 | CPLString osName; |
| 225 | if (psColDef->table_namecxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#table_name.[0]) |
| 226 | { |
| 227 | osName = psColDef->table_namecxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#table_name.; |
| 228 | osName += "."; |
| 229 | } |
| 230 | osName += psColDef->field_namecxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#field_name.; |
| 231 | |
| 232 | if (bIsGeometry) |
| 233 | oGFDefn.SetNamecxx . . $ OGRGeomFieldDefn#SetName(85c52e162fed56f9).(osName); |
| 234 | else |
| 235 | oFDefn.SetNamecxx . . $ OGRFieldDefn#SetName(85c52e162fed56f9).(osName); |
| 236 | } |
| 237 | |
| 238 | if (psColDef->col_funccxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#col_func. == SWQCF_COUNTcxx . . $ SWQCF_COUNT.) |
| 239 | oFDefn.SetTypecxx . . $ OGRFieldDefn#SetType(cc683e085121359d).(OFTInteger64); |
| 240 | else if (poSrcFDefn != nullptr) |
| 241 | { |
| 242 | if (psColDef->col_funccxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#col_func. == SWQCF_STDDEV_POPcxx . . $ SWQCF_STDDEV_POP. || |
| 243 | psColDef->col_funccxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#col_func. == SWQCF_STDDEV_SAMPcxx . . $ SWQCF_STDDEV_SAMP.) |
| 244 | { |
| 245 | oFDefn.SetTypecxx . . $ OGRFieldDefn#SetType(cc683e085121359d).(OFTReal); |
| 246 | } |
| 247 | else if (psColDef->col_funccxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#col_func. != SWQCF_AVGcxx . . $ SWQCF_AVG. || |
| 248 | psColDef->field_typecxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#field_type. == SWQ_DATEcxx . . $ SWQ_DATE. || |
| 249 | psColDef->field_typecxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#field_type. == SWQ_TIMEcxx . . $ SWQ_TIME. || |
| 250 | psColDef->field_typecxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#field_type. == SWQ_TIMESTAMPcxx . . $ SWQ_TIMESTAMP.) |
| 251 | { |
| 252 | oFDefn.SetTypecxx . . $ OGRFieldDefn#SetType(cc683e085121359d).(poSrcFDefn->GetTypecxx . . $ OGRFieldDefn#GetType(b365ab774e05458e).()); |
| 253 | if (psColDef->col_funccxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#col_func. == SWQCF_NONEcxx . . $ SWQCF_NONE. || |
| 254 | psColDef->col_funccxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#col_func. == SWQCF_MINcxx . . $ SWQCF_MIN. || |
| 255 | psColDef->col_funccxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#col_func. == SWQCF_MAXcxx . . $ SWQCF_MAX.) |
| 256 | { |
| 257 | oFDefn.SetSubTypecxx . . $ OGRFieldDefn#SetSubType(89cba9d8fed1b3f9).(poSrcFDefn->GetSubTypecxx . . $ OGRFieldDefn#GetSubType(4db5e065ad90bc77).()); |
| 258 | } |
| 259 | } |
| 260 | else |
| 261 | { |
| 262 | oFDefn.SetTypecxx . . $ OGRFieldDefn#SetType(cc683e085121359d).(OFTReal); |
| 263 | } |
| 264 | |
| 265 | if (psColDef->col_funccxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#col_func. != SWQCF_AVGcxx . . $ SWQCF_AVG. && |
| 266 | psColDef->col_funccxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#col_func. != SWQCF_STDDEV_POPcxx . . $ SWQCF_STDDEV_POP. && |
| 267 | psColDef->col_funccxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#col_func. != SWQCF_STDDEV_SAMPcxx . . $ SWQCF_STDDEV_SAMP. && |
| 268 | psColDef->col_funccxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#col_func. != SWQCF_SUMcxx . . $ SWQCF_SUM.) |
| 269 | { |
| 270 | oFDefn.SetWidthcxx . . $ OGRFieldDefn#SetWidth(d4f767463ce0a6b3).(poSrcFDefn->GetWidthcxx . . $ OGRFieldDefn#GetWidth(455f465bc33b4cdf).()); |
| 271 | oFDefn.SetPrecisioncxx . . $ OGRFieldDefn#SetPrecision(d4f767463ce0a6b3).(poSrcFDefn->GetPrecisioncxx . . $ OGRFieldDefn#GetPrecision(455f465bc33b4cdf).()); |
| 272 | } |
| 273 | |
| 274 | if (psColDef->col_funccxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#col_func. == SWQCF_NONEcxx . . $ SWQCF_NONE.) |
| 275 | oFDefn.SetDomainNamecxx . . $ OGRFieldDefn#SetDomainName(9c546c94e5fcce4e).(poSrcFDefn->GetDomainNamecxx . . $ OGRFieldDefn#GetDomainName(f4fff0029955a25f).()); |
| 276 | } |
| 277 | else if (poSrcGFDefn != nullptr) |
| 278 | { |
| 279 | oGFDefn.SetTypecxx . . $ OGRGeomFieldDefn#SetType(f47ce3f1fe923726).(poSrcGFDefn->GetTypecxx . . $ OGRGeomFieldDefn#GetType(5a40c54c5ff210ce).()); |
| 280 | oGFDefn.SetSpatialRefcxx . . $ OGRGeomFieldDefn#SetSpatialRef(9ff39b79387a6086).(poSrcGFDefn->GetSpatialRefcxx . . $ OGRGeomFieldDefn#GetSpatialRef(8a5496c2eeefaeaf).()); |
| 281 | } |
| 282 | else if (psColDef->field_indexcxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#field_index. >= m_iFIDFieldIndexcxx . . $ OGRGenSQLResultsLayer#m_iFIDFieldIndex.) |
| 283 | { |
| 284 | switch (SpecialFieldTypescxx . . $ SpecialFieldTypes.[psColDef->field_indexcxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#field_index. - m_iFIDFieldIndexcxx . . $ OGRGenSQLResultsLayer#m_iFIDFieldIndex.]) |
| 285 | { |
| 286 | case SWQ_INTEGERcxx . . $ SWQ_INTEGER.: |
| 287 | oFDefn.SetTypecxx . . $ OGRFieldDefn#SetType(cc683e085121359d).(OFTInteger); |
| 288 | break; |
| 289 | case SWQ_INTEGER64cxx . . $ SWQ_INTEGER64.: |
| 290 | oFDefn.SetTypecxx . . $ OGRFieldDefn#SetType(cc683e085121359d).(OFTInteger64); |
| 291 | break; |
| 292 | case SWQ_FLOATcxx . . $ SWQ_FLOAT.: |
| 293 | oFDefn.SetTypecxx . . $ OGRFieldDefn#SetType(cc683e085121359d).(OFTReal); |
| 294 | break; |
| 295 | default: |
| 296 | oFDefn.SetTypecxx . . $ OGRFieldDefn#SetType(cc683e085121359d).(OFTString); |
| 297 | break; |
| 298 | } |
| 299 | if (psColDef->field_indexcxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#field_index. - m_iFIDFieldIndexcxx . . $ OGRGenSQLResultsLayer#m_iFIDFieldIndex. == SPF_FIDcxx . . $ `ogr/ogr_p.h:169:9`! && |
| 300 | m_poSrcLayercxx . . $ OGRGenSQLResultsLayer#m_poSrcLayer.->GetMetadataItemcxx . . $ GDALMajorObject#GetMetadataItem(1320557f0feba62c).(OLMD_FID64cxx . . $ `ogr/ogr_core.h:1089:9`!) != nullptr && |
| 301 | EQUALcxx . . $ `port/cpl_port.h:532:9`!(m_poSrcLayer->GetMetadataItem(OLMD_FID64cxx . . $ `ogr/ogr_core.h:1089:9`!), "YES")) |
| 302 | { |
| 303 | oFDefn.SetTypecxx . . $ OGRFieldDefn#SetType(cc683e085121359d).(OFTInteger64); |
| 304 | } |
| 305 | } |
| 306 | else |
| 307 | { |
| 308 | switch (psColDef->field_typecxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#field_type.) |
| 309 | { |
| 310 | case SWQ_INTEGERcxx . . $ SWQ_INTEGER.: |
| 311 | oFDefn.SetTypecxx . . $ OGRFieldDefn#SetType(cc683e085121359d).(OFTInteger); |
| 312 | break; |
| 313 | |
| 314 | case SWQ_INTEGER64cxx . . $ SWQ_INTEGER64.: |
| 315 | oFDefn.SetTypecxx . . $ OGRFieldDefn#SetType(cc683e085121359d).(OFTInteger64); |
| 316 | break; |
| 317 | |
| 318 | case SWQ_BOOLEANcxx . . $ SWQ_BOOLEAN.: |
| 319 | oFDefn.SetTypecxx . . $ OGRFieldDefn#SetType(cc683e085121359d).(OFTInteger); |
| 320 | oFDefn.SetSubTypecxx . . $ OGRFieldDefn#SetSubType(89cba9d8fed1b3f9).(OFSTBoolean); |
| 321 | break; |
| 322 | |
| 323 | case SWQ_FLOATcxx . . $ SWQ_FLOAT.: |
| 324 | oFDefn.SetTypecxx . . $ OGRFieldDefn#SetType(cc683e085121359d).(OFTReal); |
| 325 | break; |
| 326 | |
| 327 | default: |
| 328 | oFDefn.SetTypecxx . . $ OGRFieldDefn#SetType(cc683e085121359d).(OFTString); |
| 329 | break; |
| 330 | } |
| 331 | } |
| 332 | |
| 333 | /* setting up the target_type */ |
| 334 | switch (psColDef->target_typecxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#target_type.) |
| 335 | { |
| 336 | case SWQ_OTHERcxx . . $ SWQ_OTHER.: |
| 337 | break; |
| 338 | case SWQ_INTEGERcxx . . $ SWQ_INTEGER.: |
| 339 | oFDefn.SetTypecxx . . $ OGRFieldDefn#SetType(cc683e085121359d).(OFTInteger); |
| 340 | break; |
| 341 | case SWQ_INTEGER64cxx . . $ SWQ_INTEGER64.: |
| 342 | oFDefn.SetTypecxx . . $ OGRFieldDefn#SetType(cc683e085121359d).(OFTInteger64); |
| 343 | break; |
| 344 | case SWQ_BOOLEANcxx . . $ SWQ_BOOLEAN.: |
| 345 | oFDefn.SetTypecxx . . $ OGRFieldDefn#SetType(cc683e085121359d).(OFTInteger); |
| 346 | oFDefn.SetSubTypecxx . . $ OGRFieldDefn#SetSubType(89cba9d8fed1b3f9).(OFSTBoolean); |
| 347 | break; |
| 348 | case SWQ_FLOATcxx . . $ SWQ_FLOAT.: |
| 349 | oFDefn.SetTypecxx . . $ OGRFieldDefn#SetType(cc683e085121359d).(OFTReal); |
| 350 | break; |
| 351 | case SWQ_STRINGcxx . . $ SWQ_STRING.: |
| 352 | oFDefn.SetTypecxx . . $ OGRFieldDefn#SetType(cc683e085121359d).(OFTString); |
| 353 | break; |
| 354 | case SWQ_TIMESTAMPcxx . . $ SWQ_TIMESTAMP.: |
| 355 | oFDefn.SetTypecxx . . $ OGRFieldDefn#SetType(cc683e085121359d).(OFTDateTime); |
| 356 | break; |
| 357 | case SWQ_DATEcxx . . $ SWQ_DATE.: |
| 358 | oFDefn.SetTypecxx . . $ OGRFieldDefn#SetType(cc683e085121359d).(OFTDate); |
| 359 | break; |
| 360 | case SWQ_TIMEcxx . . $ SWQ_TIME.: |
| 361 | oFDefn.SetTypecxx . . $ OGRFieldDefn#SetType(cc683e085121359d).(OFTTime); |
| 362 | break; |
| 363 | case SWQ_GEOMETRYcxx . . $ SWQ_GEOMETRY.: |
| 364 | break; |
| 365 | |
| 366 | default: |
| 367 | CPLAssertcxx . . $ `port/cpl_error.h:353:9`!(false); |
| 368 | oFDefn.SetTypecxx . . $ OGRFieldDefn#SetType(cc683e085121359d).(OFTString); |
| 369 | break; |
| 370 | } |
| 371 | if (psColDef->target_subtypecxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#target_subtype. != OFSTNone) |
| 372 | oFDefn.SetSubTypecxx . . $ OGRFieldDefn#SetSubType(89cba9d8fed1b3f9).(psColDef->target_subtypecxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#target_subtype.); |
| 373 | |
| 374 | if (psColDef->field_lengthcxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#field_length. > 0) |
| 375 | { |
| 376 | oFDefn.SetWidthcxx . . $ OGRFieldDefn#SetWidth(d4f767463ce0a6b3).(psColDef->field_lengthcxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#field_length.); |
| 377 | } |
| 378 | |
| 379 | if (psColDef->field_precisioncxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#field_precision. >= 0) |
| 380 | { |
| 381 | oFDefn.SetPrecisioncxx . . $ OGRFieldDefn#SetPrecision(d4f767463ce0a6b3).(psColDef->field_precisioncxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#field_precision.); |
| 382 | } |
| 383 | |
| 384 | if (bIsGeometry) |
| 385 | { |
| 386 | m_anGeomFieldToSrcGeomFieldcxx . . $ OGRGenSQLResultsLayer#m_anGeomFieldToSrcGeomField..push_back(iSrcGeomField); |
| 387 | /* Hack while drivers haven't been updated so that */ |
| 388 | /* poSrcDefn->GetGeomFieldDefn(0)->GetSpatialRef() == |
| 389 | * m_poSrcLayer->GetSpatialRef() */ |
| 390 | if (iSrcGeomField == 0 && poSrcDefn->GetGeomFieldCountcxx . . $ OGRFeatureDefn#GetGeomFieldCount(455f465bc33b4cdf).() == 1 && |
| 391 | oGFDefn.GetSpatialRefcxx . . $ OGRGeomFieldDefn#GetSpatialRef(8a5496c2eeefaeaf).() == nullptr) |
| 392 | { |
| 393 | oGFDefn.SetSpatialRefcxx . . $ OGRGeomFieldDefn#SetSpatialRef(9ff39b79387a6086).(m_poSrcLayercxx . . $ OGRGenSQLResultsLayer#m_poSrcLayer.->GetSpatialRefcxx . . $ OGRLayer#GetSpatialRef(8a5496c2eeefaeaf).()); |
| 394 | } |
| 395 | int bForceGeomType = FALSEcxx . . $ `port/cpl_port.h:1180:9`!; |
| 396 | if (psColDef->eGeomTypecxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#eGeomType. != wkbUnknown) |
| 397 | { |
| 398 | oGFDefn.SetTypecxx . . $ OGRGeomFieldDefn#SetType(f47ce3f1fe923726).(psColDef->eGeomTypecxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#eGeomType.); |
| 399 | bForceGeomType = TRUEcxx . . $ `port/cpl_port.h:1184:9`!; |
| 400 | } |
| 401 | if (psColDef->nSRIDcxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#nSRID. > 0) |
| 402 | { |
| 403 | OGRSpatialReferencecxx . . $ OGRSpatialReference# *poSRS = new OGRSpatialReferencecxx . . $ OGRSpatialReference#OGRSpatialReference(85c52e162fed56f9).(); |
| 404 | poSRS->SetAxisMappingStrategycxx . . $ OGRSpatialReference#SetAxisMappingStrategy(3d39f43974738d6a).(OAMS_TRADITIONAL_GIS_ORDER); |
| 405 | if (poSRS->importFromEPSGcxx . . $ OGRSpatialReference#importFromEPSG(7864480464b09eea).(psColDef->nSRIDcxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#nSRID.) == OGRERR_NONEcxx . . $ `ogr/ogr_core.h:390:9`!) |
| 406 | { |
| 407 | oGFDefn.SetSpatialRefcxx . . $ OGRGeomFieldDefn#SetSpatialRef(9ff39b79387a6086).(poSRS); |
| 408 | } |
| 409 | poSRS->Releasecxx . . $ OGRSpatialReference#Release(49f6e7a06ebc5aa8).(); |
| 410 | } |
| 411 | |
| 412 | auto poMyGeomFieldDefn = |
| 413 | stdcxx . . $ std/::make_unique<OGRGenSQLGeomFieldDefncxx . . $ OGRGenSQLGeomFieldDefn#>(&oGFDefn); |
| 414 | poMyGeomFieldDefn->bForceGeomTypecxx . . $ OGRGenSQLGeomFieldDefn#bForceGeomType. = bForceGeomType; |
| 415 | m_poDefncxx . . $ OGRGenSQLResultsLayer#m_poDefn.->AddGeomFieldDefncxx . . $ OGRFeatureDefn#AddGeomFieldDefn(cdde49ae50463690).(stdcxx . . $ std/::move(poMyGeomFieldDefn)); |
| 416 | } |
| 417 | else |
| 418 | m_poDefncxx . . $ OGRGenSQLResultsLayer#m_poDefn.->AddFieldDefncxx . . $ OGRFeatureDefn#AddFieldDefn(f8bad7d30df65bbb).(&oFDefn); |
| 419 | } |
| 420 | |
| 421 | /* -------------------------------------------------------------------- */ |
| 422 | /* Add implicit geometry field. */ |
| 423 | /* -------------------------------------------------------------------- */ |
| 424 | if (psSelectInfo->query_modecxx . . $ swq_select#query_mode. == SWQM_RECORDSETcxx . . $ `ogr/ogr_swq.h:321:9`! && |
| 425 | m_poDefncxx . . $ OGRGenSQLResultsLayer#m_poDefn.->GetGeomFieldCountcxx . . $ OGRFeatureDefn#GetGeomFieldCount(455f465bc33b4cdf).() == 0 && |
| 426 | poSrcDefn->GetGeomFieldCountcxx . . $ OGRFeatureDefn#GetGeomFieldCount(455f465bc33b4cdf).() == 1 && !psSelectInfo->bExcludedGeometrycxx . . $ swq_select#bExcludedGeometry.) |
| 427 | { |
| 428 | psSelectInfo->column_defscxx . . $ swq_select#column_defs..emplace_back(); |
| 429 | |
| 430 | swq_col_defcxx . . $ swq_col_def# *col_def = &psSelectInfo->column_defscxx . . $ swq_select#column_defs..back(); |
| 431 | |
| 432 | memset(col_def, 0, sizeof(swq_col_defcxx . . $ swq_col_def#)); |
| 433 | const char *pszName = poSrcDefn->GetGeomFieldDefncxx . . $ OGRFeatureDefn#GetGeomFieldDefn(39768c424f32bab2).(0)->GetNameRefcxx . . $ OGRGeomFieldDefn#GetNameRef(a9f41ea0e82d88cf).(); |
| 434 | if (*pszName != '\0') |
| 435 | col_def->field_namecxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#field_name. = CPLStrdup(pszName); |
| 436 | else |
| 437 | col_def->field_namecxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#field_name. = |
| 438 | CPLStrdup(OGR_GEOMETRY_DEFAULT_NON_EMPTY_NAMEcxx . . $ `ogr/ogr_p.h:35:9`!); |
| 439 | col_def->field_aliascxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#field_alias. = nullptr; |
| 440 | col_def->table_indexcxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#table_index. = 0; |
| 441 | col_def->field_indexcxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#field_index. = |
| 442 | GEOM_FIELD_INDEX_TO_ALL_FIELD_INDEXcxx . . $ `ogr/ogrsf_frmts/generic/ogr_gensql.h:26:9`!(poSrcDefn, 0); |
| 443 | col_def->field_typecxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#field_type. = SWQ_GEOMETRYcxx . . $ SWQ_GEOMETRY.; |
| 444 | col_def->target_typecxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#target_type. = SWQ_GEOMETRYcxx . . $ SWQ_GEOMETRY.; |
| 445 | |
| 446 | m_anGeomFieldToSrcGeomFieldcxx . . $ OGRGenSQLResultsLayer#m_anGeomFieldToSrcGeomField..push_back(0); |
| 447 | |
| 448 | m_poDefncxx . . $ OGRGenSQLResultsLayer#m_poDefn.->AddGeomFieldDefncxx . . $ OGRFeatureDefn#AddGeomFieldDefn(cdde49ae50463690).(stdcxx . . $ std/::make_unique<OGRGenSQLGeomFieldDefncxx . . $ OGRGenSQLGeomFieldDefn#>( |
| 449 | poSrcDefn->GetGeomFieldDefncxx . . $ OGRFeatureDefn#GetGeomFieldDefn(39768c424f32bab2).(0))); |
| 450 | |
| 451 | /* Hack while drivers haven't been updated so that */ |
| 452 | /* poSrcDefn->GetGeomFieldDefn(0)->GetSpatialRef() == |
| 453 | * m_poSrcLayer->GetSpatialRef() */ |
| 454 | if (poSrcDefn->GetGeomFieldDefncxx . . $ OGRFeatureDefn#GetGeomFieldDefn(39768c424f32bab2).(0)->GetSpatialRefcxx . . $ OGRGeomFieldDefn#GetSpatialRef(8a5496c2eeefaeaf).() == nullptr) |
| 455 | { |
| 456 | m_poDefncxx . . $ OGRGenSQLResultsLayer#m_poDefn.->GetGeomFieldDefncxx . . $ OGRFeatureDefn#GetGeomFieldDefn(39768c424f32bab2).(0)->SetSpatialRefcxx . . $ OGRGeomFieldDefn#SetSpatialRef(9ff39b79387a6086).( |
| 457 | m_poSrcLayercxx . . $ OGRGenSQLResultsLayer#m_poSrcLayer.->GetSpatialRefcxx . . $ OGRLayer#GetSpatialRef(8a5496c2eeefaeaf).()); |
| 458 | } |
| 459 | } |
| 460 | |
| 461 | /* -------------------------------------------------------------------- */ |
| 462 | /* Now that we have m_poSrcLayer, we can install a spatial filter */ |
| 463 | /* if there is one. */ |
| 464 | /* -------------------------------------------------------------------- */ |
| 465 | if (poSpatFilter) |
| 466 | { |
| 467 | if (m_poDefncxx . . $ OGRGenSQLResultsLayer#m_poDefn.->GetGeomFieldCountcxx . . $ OGRFeatureDefn#GetGeomFieldCount(455f465bc33b4cdf).() > 0) |
| 468 | { |
| 469 | OGRGenSQLResultsLayercxx . . $ OGRGenSQLResultsLayer#::SetSpatialFiltercxx . . $ OGRLayer#SetSpatialFilter(896393ecef503097).( |
| 470 | 0, const_cast<OGRGeometrycxx . . $ OGRGeometry# *>(poSpatFilter)); |
| 471 | } |
| 472 | else |
| 473 | { |
| 474 | m_bSpatialFilterSetOnSourceLayercxx . . $ OGRGenSQLResultsLayer#m_bSpatialFilterSetOnSourceLayer. = true; |
| 475 | m_poSrcLayercxx . . $ OGRGenSQLResultsLayer#m_poSrcLayer.->SetSpatialFiltercxx . . $ OGRLayer#SetSpatialFilter(896393ecef503097).( |
| 476 | 0, const_cast<OGRGeometrycxx . . $ OGRGeometry# *>(poSpatFilter)); |
| 477 | } |
| 478 | } |
| 479 | |
| 480 | OGRGenSQLResultsLayercxx . . $ OGRGenSQLResultsLayer#::ResetReadingcxx . . $ OGRGenSQLResultsLayer#ResetReading(49f6e7a06ebc5aa8).(); |
| 481 | |
| 482 | FindAndSetIgnoredFieldscxx . . $ OGRGenSQLResultsLayer#FindAndSetIgnoredFields(49f6e7a06ebc5aa8).(); |
| 483 | |
| 484 | if (!m_bForwardWhereToSourceLayercxx . . $ OGRGenSQLResultsLayer#m_bForwardWhereToSourceLayer.) |
| 485 | OGRLayercxx . . $ OGRLayer#::SetAttributeFiltercxx . . $ OGRLayer#SetAttributeFilter(5c4306d8553b3696).(m_osInitialWHEREcxx . . $ OGRGenSQLResultsLayer#m_osInitialWHERE..c_str()); |
| 486 | } |
| 487 | |
| 488 | /************************************************************************/ |
| 489 | /* ~OGRGenSQLResultsLayer() */ |
| 490 | /************************************************************************/ |
| 491 | |
| 492 | OGRGenSQLResultsLayercxx . . $ OGRGenSQLResultsLayer#::~cxx . . $ OGRGenSQLResultsLayer#`~OGRGenSQLResultsLayer`(ced63f7c635d850d).OGRGenSQLResultsLayercxx . . $ OGRGenSQLResultsLayer#() |
| 493 | |
| 494 | { |
| 495 | if (m_nFeaturesReadcxx . . $ OGRLayer#m_nFeaturesRead. > 0 && m_poDefncxx . . $ OGRGenSQLResultsLayer#m_poDefn. != nullptr) |
| 496 | { |
| 497 | CPLDebug("GenSQL", CPL_FRMT_GIBcxx . . $ `port/cpl_port.h:257:9`! " features read on layer '%s'.", |
| 498 | m_nFeaturesReadcxx . . $ OGRLayer#m_nFeaturesRead., m_poDefncxx . . $ OGRGenSQLResultsLayer#m_poDefn.->GetNamecxx . . $ OGRFeatureDefn#GetName(a9f41ea0e82d88cf).()); |
| 499 | } |
| 500 | |
| 501 | OGRGenSQLResultsLayercxx . . $ OGRGenSQLResultsLayer#::ClearFilterscxx . . $ OGRGenSQLResultsLayer#ClearFilters(49f6e7a06ebc5aa8).(); |
| 502 | |
| 503 | if (m_poDefncxx . . $ OGRGenSQLResultsLayer#m_poDefn. != nullptr) |
| 504 | { |
| 505 | m_poDefncxx . . $ OGRGenSQLResultsLayer#m_poDefn.->Releasecxx . . $ OGRFeatureDefn#Release(49f6e7a06ebc5aa8).(); |
| 506 | } |
| 507 | } |
| 508 | |
| 509 | /************************************************************************/ |
| 510 | /* ClearFilters() */ |
| 511 | /* */ |
| 512 | /* Clear up all filters currently in place on the target layer, */ |
| 513 | /* and joined layers. We try not to leave them installed */ |
| 514 | /* except when actively fetching features. */ |
| 515 | /************************************************************************/ |
| 516 | |
| 517 | void OGRGenSQLResultsLayercxx . . $ OGRGenSQLResultsLayer#::ClearFilterscxx . . $ OGRGenSQLResultsLayer#ClearFilters(49f6e7a06ebc5aa8).() |
| 518 | |
| 519 | { |
| 520 | /* -------------------------------------------------------------------- */ |
| 521 | /* Clear any filters installed on the target layer. */ |
| 522 | /* -------------------------------------------------------------------- */ |
| 523 | m_poSrcLayercxx . . $ OGRGenSQLResultsLayer#m_poSrcLayer.->ResetReadingcxx . . $ OGRLayer#ResetReading(49f6e7a06ebc5aa8).(); |
| 524 | m_poSrcLayercxx . . $ OGRGenSQLResultsLayer#m_poSrcLayer.->SetAttributeFiltercxx . . $ OGRLayer#SetAttributeFilter(5c4306d8553b3696).(""); |
| 525 | if (GetLayerDefncxx . . $ OGRGenSQLResultsLayer#GetLayerDefn(448b209f43d15bcc).()->GetGeomFieldCountcxx . . $ OGRFeatureDefn#GetGeomFieldCount(455f465bc33b4cdf).() > 0) |
| 526 | m_poSrcLayercxx . . $ OGRGenSQLResultsLayer#m_poSrcLayer.->SetSpatialFiltercxx . . $ OGRLayer#SetSpatialFilter(fed901b2566802ff).(nullptr); |
| 527 | |
| 528 | /* -------------------------------------------------------------------- */ |
| 529 | /* Clear any attribute filter installed on the joined layers. */ |
| 530 | /* -------------------------------------------------------------------- */ |
| 531 | swq_selectcxx . . $ swq_select# *psSelectInfo = m_pSelectInfocxx . . $ OGRGenSQLResultsLayer#m_pSelectInfo..get(); |
| 532 | |
| 533 | if (psSelectInfo != nullptr) |
| 534 | { |
| 535 | for (int iJoin = 0; iJoin < psSelectInfo->join_countcxx . . $ swq_select#join_count.; iJoin++) |
| 536 | { |
| 537 | swq_join_defcxx . . $ swq_join_def# *psJoinInfo = psSelectInfo->join_defscxx . . $ swq_select#join_defs. + iJoin; |
| 538 | OGRLayercxx . . $ OGRLayer# *poJoinLayer = |
| 539 | m_apoTableLayerscxx . . $ OGRGenSQLResultsLayer#m_apoTableLayers.[psJoinInfo->secondary_tablecxx . . $ $anonymous_type_a69ae1a4ba3d583e_8#secondary_table.]; |
| 540 | |
| 541 | poJoinLayer->SetAttributeFiltercxx . . $ OGRLayer#SetAttributeFilter(5c4306d8553b3696).(""); |
| 542 | } |
| 543 | } |
| 544 | |
| 545 | /* -------------------------------------------------------------------- */ |
| 546 | /* Clear any ignored field lists installed on source layers */ |
| 547 | /* -------------------------------------------------------------------- */ |
| 548 | if (psSelectInfo != nullptr) |
| 549 | { |
| 550 | for (int iTable = 0; iTable < psSelectInfo->table_countcxx . . $ swq_select#table_count.; iTable++) |
| 551 | { |
| 552 | OGRLayercxx . . $ OGRLayer# *poLayer = m_apoTableLayerscxx . . $ OGRGenSQLResultsLayer#m_apoTableLayers.[iTable]; |
| 553 | poLayer->SetIgnoredFieldscxx . . $ OGRLayer#SetIgnoredFields(e464cedb65a3f4c2).(nullptr); |
| 554 | } |
| 555 | } |
| 556 | } |
| 557 | |
| 558 | /************************************************************************/ |
| 559 | /* MustEvaluateSpatialFilterOnGenSQL() */ |
| 560 | /************************************************************************/ |
| 561 | |
| 562 | int OGRGenSQLResultsLayercxx . . $ OGRGenSQLResultsLayer#::MustEvaluateSpatialFilterOnGenSQLcxx . . $ OGRGenSQLResultsLayer#MustEvaluateSpatialFilterOnGenSQL(b126dc7c1de90089).() |
| 563 | { |
| 564 | int bEvaluateSpatialFilter = FALSEcxx . . $ `port/cpl_port.h:1180:9`!; |
| 565 | if (m_poFilterGeomcxx . . $ OGRLayer#m_poFilterGeom. != nullptr && m_iGeomFieldFiltercxx . . $ OGRLayer#m_iGeomFieldFilter. >= 0 && |
| 566 | m_iGeomFieldFiltercxx . . $ OGRLayer#m_iGeomFieldFilter. < GetLayerDefncxx . . $ OGRGenSQLResultsLayer#GetLayerDefn(448b209f43d15bcc).()->GetGeomFieldCountcxx . . $ OGRFeatureDefn#GetGeomFieldCount(455f465bc33b4cdf).()) |
| 567 | { |
| 568 | int iSrcGeomField = m_anGeomFieldToSrcGeomFieldcxx . . $ OGRGenSQLResultsLayer#m_anGeomFieldToSrcGeomField.[m_iGeomFieldFiltercxx . . $ OGRLayer#m_iGeomFieldFilter.]; |
| 569 | if (iSrcGeomField < 0) |
| 570 | bEvaluateSpatialFilter = TRUEcxx . . $ `port/cpl_port.h:1184:9`!; |
| 571 | } |
| 572 | return bEvaluateSpatialFilter; |
| 573 | } |
| 574 | |
| 575 | /************************************************************************/ |
| 576 | /* ApplyFiltersToSource() */ |
| 577 | /************************************************************************/ |
| 578 | |
| 579 | void OGRGenSQLResultsLayercxx . . $ OGRGenSQLResultsLayer#::ApplyFiltersToSourcecxx . . $ OGRGenSQLResultsLayer#ApplyFiltersToSource(49f6e7a06ebc5aa8).() |
| 580 | { |
| 581 | if (m_bForwardWhereToSourceLayercxx . . $ OGRGenSQLResultsLayer#m_bForwardWhereToSourceLayer. && !m_osInitialWHEREcxx . . $ OGRGenSQLResultsLayer#m_osInitialWHERE..empty()) |
| 582 | { |
| 583 | m_poSrcLayercxx . . $ OGRGenSQLResultsLayer#m_poSrcLayer.->SetAttributeFiltercxx . . $ OGRLayer#SetAttributeFilter(5c4306d8553b3696).(m_osInitialWHEREcxx . . $ OGRGenSQLResultsLayer#m_osInitialWHERE..c_str()); |
| 584 | } |
| 585 | else |
| 586 | { |
| 587 | m_poSrcLayercxx . . $ OGRGenSQLResultsLayer#m_poSrcLayer.->SetAttributeFiltercxx . . $ OGRLayer#SetAttributeFilter(5c4306d8553b3696).(nullptr); |
| 588 | } |
| 589 | if (m_iGeomFieldFiltercxx . . $ OGRLayer#m_iGeomFieldFilter. >= 0 && |
| 590 | m_iGeomFieldFiltercxx . . $ OGRLayer#m_iGeomFieldFilter. < GetLayerDefncxx . . $ OGRGenSQLResultsLayer#GetLayerDefn(448b209f43d15bcc).()->GetGeomFieldCountcxx . . $ OGRFeatureDefn#GetGeomFieldCount(455f465bc33b4cdf).()) |
| 591 | { |
| 592 | int iSrcGeomField = m_anGeomFieldToSrcGeomFieldcxx . . $ OGRGenSQLResultsLayer#m_anGeomFieldToSrcGeomField.[m_iGeomFieldFiltercxx . . $ OGRLayer#m_iGeomFieldFilter.]; |
| 593 | if (iSrcGeomField >= 0) |
| 594 | m_poSrcLayercxx . . $ OGRGenSQLResultsLayer#m_poSrcLayer.->SetSpatialFiltercxx . . $ OGRLayer#SetSpatialFilter(896393ecef503097).(iSrcGeomField, m_poFilterGeomcxx . . $ OGRLayer#m_poFilterGeom.); |
| 595 | } |
| 596 | |
| 597 | m_poSrcLayercxx . . $ OGRGenSQLResultsLayer#m_poSrcLayer.->ResetReadingcxx . . $ OGRLayer#ResetReading(49f6e7a06ebc5aa8).(); |
| 598 | } |
| 599 | |
| 600 | /************************************************************************/ |
| 601 | /* ResetReading() */ |
| 602 | /************************************************************************/ |
| 603 | |
| 604 | void OGRGenSQLResultsLayercxx . . $ OGRGenSQLResultsLayer#::ResetReadingcxx . . $ OGRGenSQLResultsLayer#ResetReading(49f6e7a06ebc5aa8).() |
| 605 | |
| 606 | { |
| 607 | swq_selectcxx . . $ swq_select# *psSelectInfo = m_pSelectInfocxx . . $ OGRGenSQLResultsLayer#m_pSelectInfo..get(); |
| 608 | |
| 609 | if (psSelectInfo->query_modecxx . . $ swq_select#query_mode. == SWQM_RECORDSETcxx . . $ `ogr/ogr_swq.h:321:9`!) |
| 610 | { |
| 611 | ApplyFiltersToSourcecxx . . $ OGRGenSQLResultsLayer#ApplyFiltersToSource(49f6e7a06ebc5aa8).(); |
| 612 | } |
| 613 | |
| 614 | m_nNextIndexFIDcxx . . $ OGRGenSQLResultsLayer#m_nNextIndexFID. = psSelectInfo->offsetcxx . . $ swq_select#offset.; |
| 615 | m_nIteratedFeaturescxx . . $ OGRGenSQLResultsLayer#m_nIteratedFeatures. = -1; |
| 616 | m_bEOFcxx . . $ OGRGenSQLResultsLayer#m_bEOF. = false; |
| 617 | } |
| 618 | |
| 619 | /************************************************************************/ |
| 620 | /* SetNextByIndex() */ |
| 621 | /* */ |
| 622 | /* If we already have an FID list, we can easily reposition */ |
| 623 | /* ourselves in it. */ |
| 624 | /************************************************************************/ |
| 625 | |
| 626 | OGRErr OGRGenSQLResultsLayercxx . . $ OGRGenSQLResultsLayer#::SetNextByIndexcxx . . $ OGRGenSQLResultsLayer#SetNextByIndex(a070d6d14e988596).(GIntBigcxx . . $ GIntBig# nIndex) |
| 627 | |
| 628 | { |
| 629 | m_bEOFcxx . . $ OGRGenSQLResultsLayer#m_bEOF. = false; |
| 630 | |
| 631 | if (nIndex < 0) |
| 632 | { |
| 633 | m_bEOFcxx . . $ OGRGenSQLResultsLayer#m_bEOF. = true; |
| 634 | return OGRERR_NON_EXISTING_FEATUREcxx . . $ `ogr/ogr_core.h:399:9`!; |
| 635 | } |
| 636 | |
| 637 | swq_selectcxx . . $ swq_select# *psSelectInfo = m_pSelectInfocxx . . $ OGRGenSQLResultsLayer#m_pSelectInfo..get(); |
| 638 | |
| 639 | if (psSelectInfo->limitcxx . . $ swq_select#limit. >= 0) |
| 640 | { |
| 641 | m_nIteratedFeaturescxx . . $ OGRGenSQLResultsLayer#m_nIteratedFeatures. = nIndex; |
| 642 | if (m_nIteratedFeaturescxx . . $ OGRGenSQLResultsLayer#m_nIteratedFeatures. >= psSelectInfo->limitcxx . . $ swq_select#limit.) |
| 643 | { |
| 644 | return OGRERR_NON_EXISTING_FEATUREcxx . . $ `ogr/ogr_core.h:399:9`!; |
| 645 | } |
| 646 | } |
| 647 | |
| 648 | CreateOrderByIndexcxx . . $ OGRGenSQLResultsLayer#CreateOrderByIndex(49f6e7a06ebc5aa8).(); |
| 649 | |
| 650 | if (nIndex > stdcxx . . $ std/::numeric_limits<GIntBig>::max() - psSelectInfo->offsetcxx . . $ swq_select#offset.) |
| 651 | { |
| 652 | m_bEOFcxx . . $ OGRGenSQLResultsLayer#m_bEOF. = true; |
| 653 | return OGRERR_NON_EXISTING_FEATUREcxx . . $ `ogr/ogr_core.h:399:9`!; |
| 654 | } |
| 655 | if (psSelectInfo->query_modecxx . . $ swq_select#query_mode. == SWQM_SUMMARY_RECORDcxx . . $ `ogr/ogr_swq.h:320:9`! || |
| 656 | psSelectInfo->query_modecxx . . $ swq_select#query_mode. == SWQM_DISTINCT_LISTcxx . . $ `ogr/ogr_swq.h:322:9`! || !m_anFIDIndexcxx . . $ OGRGenSQLResultsLayer#m_anFIDIndex..empty()) |
| 657 | { |
| 658 | m_nNextIndexFIDcxx . . $ OGRGenSQLResultsLayer#m_nNextIndexFID. = nIndex + psSelectInfo->offsetcxx . . $ swq_select#offset.; |
| 659 | return OGRERR_NONEcxx . . $ `ogr/ogr_core.h:390:9`!; |
| 660 | } |
| 661 | else |
| 662 | { |
| 663 | OGRErr eErr = |
| 664 | m_poSrcLayercxx . . $ OGRGenSQLResultsLayer#m_poSrcLayer.->SetNextByIndexcxx . . $ OGRLayer#SetNextByIndex(a070d6d14e988596).(nIndex + psSelectInfo->offsetcxx . . $ swq_select#offset.); |
| 665 | if (eErr != OGRERR_NONEcxx . . $ `ogr/ogr_core.h:390:9`!) |
| 666 | m_bEOFcxx . . $ OGRGenSQLResultsLayer#m_bEOF. = true; |
| 667 | return eErr; |
| 668 | } |
| 669 | } |
| 670 | |
| 671 | /************************************************************************/ |
| 672 | /* IGetExtent() */ |
| 673 | /************************************************************************/ |
| 674 | |
| 675 | OGRErr OGRGenSQLResultsLayercxx . . $ OGRGenSQLResultsLayer#::IGetExtentcxx . . $ OGRGenSQLResultsLayer#IGetExtent(ee9c866093418aa0).(int iGeomField, OGREnvelope *psExtent, |
| 676 | bool bForce) |
| 677 | |
| 678 | { |
| 679 | swq_selectcxx . . $ swq_select# *psSelectInfo = m_pSelectInfocxx . . $ OGRGenSQLResultsLayer#m_pSelectInfo..get(); |
| 680 | |
| 681 | if (psSelectInfo->query_modecxx . . $ swq_select#query_mode. == SWQM_RECORDSETcxx . . $ `ogr/ogr_swq.h:321:9`!) |
| 682 | { |
| 683 | int iSrcGeomField = m_anGeomFieldToSrcGeomFieldcxx . . $ OGRGenSQLResultsLayer#m_anGeomFieldToSrcGeomField.[iGeomField]; |
| 684 | if (iSrcGeomField >= 0) |
| 685 | return m_poSrcLayercxx . . $ OGRGenSQLResultsLayer#m_poSrcLayer.->GetExtentcxx . . $ OGRLayer#GetExtent(ee9c866093418aa0).(iSrcGeomField, psExtent, bForce); |
| 686 | else |
| 687 | return OGRLayercxx . . $ OGRLayer#::IGetExtentcxx . . $ OGRLayer#IGetExtent(ee9c866093418aa0).(iGeomField, psExtent, bForce); |
| 688 | } |
| 689 | else |
| 690 | return OGRERR_FAILUREcxx . . $ `ogr/ogr_core.h:396:9`!; |
| 691 | } |
| 692 | |
| 693 | /************************************************************************/ |
| 694 | /* GetFeatureCount() */ |
| 695 | /************************************************************************/ |
| 696 | |
| 697 | GIntBigcxx . . $ GIntBig# OGRGenSQLResultsLayercxx . . $ OGRGenSQLResultsLayer#::GetFeatureCountcxx . . $ OGRGenSQLResultsLayer#GetFeatureCount(9ccc33c3ebad048d).(int bForce) |
| 698 | |
| 699 | { |
| 700 | swq_selectcxx . . $ swq_select# *psSelectInfo = m_pSelectInfocxx . . $ OGRGenSQLResultsLayer#m_pSelectInfo..get(); |
| 701 | |
| 702 | CreateOrderByIndexcxx . . $ OGRGenSQLResultsLayer#CreateOrderByIndex(49f6e7a06ebc5aa8).(); |
| 703 | |
| 704 | GIntBigcxx . . $ GIntBig# nRet = 0; |
| 705 | if (psSelectInfo->query_modecxx . . $ swq_select#query_mode. == SWQM_DISTINCT_LISTcxx . . $ `ogr/ogr_swq.h:322:9`!) |
| 706 | { |
| 707 | if (!PrepareSummarycxx . . $ OGRGenSQLResultsLayer#PrepareSummary(50ce9a9e25b4a850).()) |
| 708 | return 0; |
| 709 | |
| 710 | if (psSelectInfo->column_summarycxx . . $ swq_select#column_summary..empty()) |
| 711 | return 0; |
| 712 | |
| 713 | nRet = psSelectInfo->column_summarycxx . . $ swq_select#column_summary.[0].countcxx . . $ swq_summary#count.; |
| 714 | } |
| 715 | else if (psSelectInfo->query_modecxx . . $ swq_select#query_mode. != SWQM_RECORDSETcxx . . $ `ogr/ogr_swq.h:321:9`!) |
| 716 | return 1; |
| 717 | else if (m_poAttrQuerycxx . . $ OGRLayer#m_poAttrQuery. == nullptr && !MustEvaluateSpatialFilterOnGenSQLcxx . . $ OGRGenSQLResultsLayer#MustEvaluateSpatialFilterOnGenSQL(b126dc7c1de90089).()) |
| 718 | { |
| 719 | nRet = m_poSrcLayercxx . . $ OGRGenSQLResultsLayer#m_poSrcLayer.->GetFeatureCountcxx . . $ OGRLayer#GetFeatureCount(9ccc33c3ebad048d).(bForce); |
| 720 | } |
| 721 | else |
| 722 | { |
| 723 | nRet = OGRLayercxx . . $ OGRLayer#::GetFeatureCountcxx . . $ OGRLayer#GetFeatureCount(9ccc33c3ebad048d).(bForce); |
| 724 | } |
| 725 | if (nRet < 0) |
| 726 | return nRet; |
| 727 | |
| 728 | nRet = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(static_cast<GIntBigcxx . . $ GIntBig#>(0), nRet - psSelectInfo->offsetcxx . . $ swq_select#offset.); |
| 729 | if (psSelectInfo->limitcxx . . $ swq_select#limit. >= 0) |
| 730 | nRet = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(nRet, psSelectInfo->limitcxx . . $ swq_select#limit.); |
| 731 | return nRet; |
| 732 | } |
| 733 | |
| 734 | /************************************************************************/ |
| 735 | /* TestCapability() */ |
| 736 | /************************************************************************/ |
| 737 | |
| 738 | int OGRGenSQLResultsLayercxx . . $ OGRGenSQLResultsLayer#::TestCapabilitycxx . . $ OGRGenSQLResultsLayer#TestCapability(78f035161ffa9fe2).(const char *pszCap) const |
| 739 | |
| 740 | { |
| 741 | const swq_selectcxx . . $ swq_select# *psSelectInfo = m_pSelectInfocxx . . $ OGRGenSQLResultsLayer#m_pSelectInfo..get(); |
| 742 | |
| 743 | if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszCap, OLCFastSetNextByIndexcxx . . $ `ogr/ogr_core.h:1013:9`!)) |
| 744 | { |
| 745 | if (psSelectInfo->query_modecxx . . $ swq_select#query_mode. == SWQM_SUMMARY_RECORDcxx . . $ `ogr/ogr_swq.h:320:9`! || |
| 746 | psSelectInfo->query_modecxx . . $ swq_select#query_mode. == SWQM_DISTINCT_LISTcxx . . $ `ogr/ogr_swq.h:322:9`! || |
| 747 | !m_anFIDIndexcxx . . $ OGRGenSQLResultsLayer#m_anFIDIndex..empty()) |
| 748 | return TRUEcxx . . $ `port/cpl_port.h:1184:9`!; |
| 749 | else |
| 750 | return m_poSrcLayercxx . . $ OGRGenSQLResultsLayer#m_poSrcLayer.->TestCapabilitycxx . . $ OGRLayer#TestCapability(78f035161ffa9fe2).(pszCap); |
| 751 | } |
| 752 | |
| 753 | if (psSelectInfo->query_modecxx . . $ swq_select#query_mode. == SWQM_RECORDSETcxx . . $ `ogr/ogr_swq.h:321:9`! && |
| 754 | (EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszCap, OLCFastFeatureCountcxx . . $ `ogr/ogr_core.h:983:9`!) || EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszCap, OLCRandomReadcxx . . $ `ogr/ogr_core.h:977:9`!) || |
| 755 | EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszCap, OLCFastGetExtentcxx . . $ `ogr/ogr_core.h:986:9`!))) |
| 756 | return m_poSrcLayercxx . . $ OGRGenSQLResultsLayer#m_poSrcLayer.->TestCapabilitycxx . . $ OGRLayer#TestCapability(78f035161ffa9fe2).(pszCap); |
| 757 | |
| 758 | else if (psSelectInfo->query_modecxx . . $ swq_select#query_mode. != SWQM_RECORDSETcxx . . $ `ogr/ogr_swq.h:321:9`!) |
| 759 | { |
| 760 | if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszCap, OLCFastFeatureCountcxx . . $ `ogr/ogr_core.h:983:9`!)) |
| 761 | return TRUEcxx . . $ `port/cpl_port.h:1184:9`!; |
| 762 | } |
| 763 | |
| 764 | if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszCap, OLCStringsAsUTF8cxx . . $ `ogr/ogr_core.h:1016:9`!) || EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszCap, OLCCurveGeometriescxx . . $ `ogr/ogr_core.h:1023:9`!) || |
| 765 | EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszCap, OLCMeasuredGeometriescxx . . $ `ogr/ogr_core.h:1025:9`!) || EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszCap, OLCZGeometriescxx . . $ `ogr/ogr_core.h:1028:9`!)) |
| 766 | { |
| 767 | return m_poSrcLayercxx . . $ OGRGenSQLResultsLayer#m_poSrcLayer.->TestCapabilitycxx . . $ OGRLayer#TestCapability(78f035161ffa9fe2).(pszCap); |
| 768 | } |
| 769 | |
| 770 | else if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszCap, OLCFastGetArrowStreamcxx . . $ `ogr/ogr_core.h:1033:9`!)) |
| 771 | { |
| 772 | // Make sure the SQL is something as simple as |
| 773 | // "SELECT field1 [AS renamed], ... FROM ... WHERE ....", without |
| 774 | // duplicated fields |
| 775 | if (m_bForwardWhereToSourceLayercxx . . $ OGRGenSQLResultsLayer#m_bForwardWhereToSourceLayer. && |
| 776 | psSelectInfo->query_modecxx . . $ swq_select#query_mode. == SWQM_RECORDSETcxx . . $ `ogr/ogr_swq.h:321:9`! && |
| 777 | psSelectInfo->offsetcxx . . $ swq_select#offset. == 0 && psSelectInfo->join_countcxx . . $ swq_select#join_count. == 0 && |
| 778 | psSelectInfo->order_specscxx . . $ swq_select#order_specs. == 0) |
| 779 | { |
| 780 | stdcxx . . $ std/::setcxx . . $ std/set#<int> oSetFieldIndexcxx . . $ std/set#set(49f6e7a06ebc5aa8).; |
| 781 | int nLastIdxRegularField = -1; |
| 782 | for (stdcxx . . $ std/::size_tcxx . . $ std/size_t# iField = 0; |
| 783 | iField < psSelectInfo->column_defscxx . . $ swq_select#column_defs..size(); iField++) |
| 784 | { |
| 785 | const swq_col_defcxx . . $ swq_col_def# *psColDef = |
| 786 | &psSelectInfo->column_defscxx . . $ swq_select#column_defs.[iField]; |
| 787 | if (psColDef->bHiddencxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#bHidden. || psColDef->table_indexcxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#table_index. < 0 || |
| 788 | psColDef->col_funccxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#col_func. != SWQCF_NONEcxx . . $ SWQCF_NONE. || |
| 789 | cpl::contains(oSetFieldIndex, psColDef->field_indexcxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#field_index.)) |
| 790 | { |
| 791 | return false; |
| 792 | } |
| 793 | |
| 794 | oSetFieldIndex.insertcxx . . $ std/set#insert(411a10a755068dfe).(psColDef->field_indexcxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#field_index.); |
| 795 | |
| 796 | const auto poLayerDefn = |
| 797 | m_apoTableLayerscxx . . $ OGRGenSQLResultsLayer#m_apoTableLayers.[psColDef->table_indexcxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#table_index.]->GetLayerDefncxx . . $ OGRLayer#GetLayerDefn(407fccde18759965).(); |
| 798 | |
| 799 | if (psColDef->field_indexcxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#field_index. >= 0 && poLayerDefn != nullptr && |
| 800 | psColDef->field_indexcxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#field_index. < poLayerDefn->GetFieldCountcxx . . $ OGRFeatureDefn#GetFieldCount(455f465bc33b4cdf).()) |
| 801 | { |
| 802 | // We do not support re-ordered fields |
| 803 | if (psColDef->field_indexcxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#field_index. <= nLastIdxRegularField) |
| 804 | return false; |
| 805 | nLastIdxRegularField = psColDef->field_indexcxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#field_index.; |
| 806 | } |
| 807 | else if (poLayerDefn != nullptr && |
| 808 | IS_GEOM_FIELD_INDEXcxx . . $ `ogr/ogrsf_frmts/generic/ogr_gensql.h:29:9`!(poLayerDefn, |
| 809 | psColDef->field_index)) |
| 810 | { |
| 811 | // ok |
| 812 | } |
| 813 | else |
| 814 | { |
| 815 | return false; |
| 816 | } |
| 817 | } |
| 818 | return m_poSrcLayercxx . . $ OGRGenSQLResultsLayer#m_poSrcLayer.->TestCapabilitycxx . . $ OGRLayer#TestCapability(78f035161ffa9fe2).(pszCap); |
| 819 | } |
| 820 | } |
| 821 | |
| 822 | return FALSEcxx . . $ `port/cpl_port.h:1180:9`!; |
| 823 | } |
| 824 | |
| 825 | /************************************************************************/ |
| 826 | /* ContainGeomSpecialField() */ |
| 827 | /************************************************************************/ |
| 828 | |
| 829 | int OGRGenSQLResultsLayercxx . . $ OGRGenSQLResultsLayer#::ContainGeomSpecialFieldcxx . . $ OGRGenSQLResultsLayer#ContainGeomSpecialField(ccc0574cba9f1f31).( |
| 830 | const swq_expr_nodecxx . . $ swq_expr_node# *expr) const |
| 831 | { |
| 832 | if (expr->eNodeTypecxx . . $ swq_expr_node#eNodeType. == SNT_COLUMNcxx . . $ SNT_COLUMN.) |
| 833 | { |
| 834 | if (expr->table_indexcxx . . $ swq_expr_node#table_index. == 0 && expr->field_indexcxx . . $ swq_expr_node#field_index. != -1) |
| 835 | { |
| 836 | OGRLayercxx . . $ OGRLayer# *poLayer = m_apoTableLayerscxx . . $ OGRGenSQLResultsLayer#m_apoTableLayers.[expr->table_indexcxx . . $ swq_expr_node#table_index.]; |
| 837 | int nSpecialFieldIdx = |
| 838 | expr->field_indexcxx . . $ swq_expr_node#field_index. - poLayer->GetLayerDefncxx . . $ OGRLayer#GetLayerDefn(407fccde18759965).()->GetFieldCountcxx . . $ OGRFeatureDefn#GetFieldCount(455f465bc33b4cdf).(); |
| 839 | if (nSpecialFieldIdx == SPF_OGR_GEOMETRYcxx . . $ `ogr/ogr_p.h:170:9`! || |
| 840 | nSpecialFieldIdx == SPF_OGR_GEOM_WKTcxx . . $ `ogr/ogr_p.h:172:9`! || |
| 841 | nSpecialFieldIdx == SPF_OGR_GEOM_AREAcxx . . $ `ogr/ogr_p.h:173:9`!) |
| 842 | return TRUEcxx . . $ `port/cpl_port.h:1184:9`!; |
| 843 | if (expr->field_indexcxx . . $ swq_expr_node#field_index. == |
| 844 | GEOM_FIELD_INDEX_TO_ALL_FIELD_INDEXcxx . . $ `ogr/ogrsf_frmts/generic/ogr_gensql.h:26:9`!(poLayer->GetLayerDefn(), 0)) |
| 845 | return TRUEcxx . . $ `port/cpl_port.h:1184:9`!; |
| 846 | return FALSEcxx . . $ `port/cpl_port.h:1180:9`!; |
| 847 | } |
| 848 | } |
| 849 | else if (expr->eNodeTypecxx . . $ swq_expr_node#eNodeType. == SNT_OPERATIONcxx . . $ SNT_OPERATION.) |
| 850 | { |
| 851 | for (int i = 0; i < expr->nSubExprCountcxx . . $ swq_expr_node#nSubExprCount.; i++) |
| 852 | { |
| 853 | if (ContainGeomSpecialFieldcxx . . $ OGRGenSQLResultsLayer#ContainGeomSpecialField(ccc0574cba9f1f31).(expr->papoSubExprcxx . . $ swq_expr_node#papoSubExpr.[i])) |
| 854 | return TRUEcxx . . $ `port/cpl_port.h:1184:9`!; |
| 855 | } |
| 856 | } |
| 857 | return FALSEcxx . . $ `port/cpl_port.h:1180:9`!; |
| 858 | } |
| 859 | |
| 860 | /************************************************************************/ |
| 861 | /* PrepareSummary() */ |
| 862 | /************************************************************************/ |
| 863 | |
| 864 | bool OGRGenSQLResultsLayercxx . . $ OGRGenSQLResultsLayer#::PrepareSummarycxx . . $ OGRGenSQLResultsLayer#PrepareSummary(50ce9a9e25b4a850).() const |
| 865 | |
| 866 | { |
| 867 | swq_selectcxx . . $ swq_select# *psSelectInfo = m_pSelectInfocxx . . $ OGRGenSQLResultsLayer#m_pSelectInfo..get(); |
| 868 | |
| 869 | if (m_poSummaryFeaturecxx . . $ OGRGenSQLResultsLayer#m_poSummaryFeature.) |
| 870 | return true; |
| 871 | |
| 872 | m_poSummaryFeaturecxx . . $ OGRGenSQLResultsLayer#m_poSummaryFeature. = stdcxx . . $ std/::make_unique<OGRFeaturecxx . . $ OGRFeature#>(m_poDefncxx . . $ OGRGenSQLResultsLayer#m_poDefn.); |
| 873 | m_poSummaryFeaturecxx . . $ OGRGenSQLResultsLayer#m_poSummaryFeature.->SetFIDcxx . . $ OGRFeature#SetFID(a070d6d14e988596).(0); |
| 874 | |
| 875 | /* -------------------------------------------------------------------- */ |
| 876 | /* Ensure our query parameters are in place on the source */ |
| 877 | /* layer. And initialize reading. */ |
| 878 | /* -------------------------------------------------------------------- */ |
| 879 | const_cast<OGRGenSQLResultsLayercxx . . $ OGRGenSQLResultsLayer# *>(this)->ApplyFiltersToSourcecxx . . $ OGRGenSQLResultsLayer#ApplyFiltersToSource(49f6e7a06ebc5aa8).(); |
| 880 | |
| 881 | /* -------------------------------------------------------------------- */ |
| 882 | /* Ignore geometry reading if no spatial filter in place and that */ |
| 883 | /* the where clause and no column references OGR_GEOMETRY, */ |
| 884 | /* OGR_GEOM_WKT or OGR_GEOM_AREA special fields. */ |
| 885 | /* -------------------------------------------------------------------- */ |
| 886 | |
| 887 | struct TempGeomIgnoredSettercxx . . $ OGRGenSQLResultsLayer#PrepareSummary(50ce9a9e25b4a850).TempGeomIgnoredSetter# |
| 888 | { |
| 889 | OGRFeatureDefncxx . . $ OGRFeatureDefn# &m_oDefncxx . . $ OGRGenSQLResultsLayer#PrepareSummary(50ce9a9e25b4a850).TempGeomIgnoredSetter#m_oDefn.; |
| 890 | const int m_bSaveIsGeomIgnoredcxx . . $ OGRGenSQLResultsLayer#PrepareSummary(50ce9a9e25b4a850).TempGeomIgnoredSetter#m_bSaveIsGeomIgnored.; |
| 891 | |
| 892 | explicit TempGeomIgnoredSettercxx . . $ OGRGenSQLResultsLayer#PrepareSummary(50ce9a9e25b4a850).TempGeomIgnoredSetter#TempGeomIgnoredSetter(8aa07028af15430f).(OGRFeatureDefncxx . . $ OGRFeatureDefn# *poDefn) |
| 893 | : m_oDefncxx . . $ OGRGenSQLResultsLayer#PrepareSummary(50ce9a9e25b4a850).TempGeomIgnoredSetter#m_oDefn.(*poDefn), |
| 894 | m_bSaveIsGeomIgnoredcxx . . $ OGRGenSQLResultsLayer#PrepareSummary(50ce9a9e25b4a850).TempGeomIgnoredSetter#m_bSaveIsGeomIgnored.(poDefn->IsGeometryIgnoredcxx . . $ OGRFeatureDefn#IsGeometryIgnored(455f465bc33b4cdf).()) |
| 895 | { |
| 896 | m_oDefncxx . . $ OGRGenSQLResultsLayer#PrepareSummary(50ce9a9e25b4a850).TempGeomIgnoredSetter#m_oDefn..SetGeometryIgnoredcxx . . $ OGRFeatureDefn#SetGeometryIgnored(d4f767463ce0a6b3).(true); |
| 897 | } |
| 898 | |
| 899 | ~cxx . . $ OGRGenSQLResultsLayer#PrepareSummary(50ce9a9e25b4a850).TempGeomIgnoredSetter#`~TempGeomIgnoredSetter`(ced63f7c635d850d).TempGeomIgnoredSettercxx . . $ OGRGenSQLResultsLayer#PrepareSummary(50ce9a9e25b4a850).TempGeomIgnoredSetter#() |
| 900 | { |
| 901 | m_oDefncxx . . $ OGRGenSQLResultsLayer#PrepareSummary(50ce9a9e25b4a850).TempGeomIgnoredSetter#m_oDefn..SetGeometryIgnoredcxx . . $ OGRFeatureDefn#SetGeometryIgnored(d4f767463ce0a6b3).(m_bSaveIsGeomIgnoredcxx . . $ OGRGenSQLResultsLayer#PrepareSummary(50ce9a9e25b4a850).TempGeomIgnoredSetter#m_bSaveIsGeomIgnored.); |
| 902 | } |
| 903 | }; |
| 904 | |
| 905 | auto poSrcLayerDefn = m_poSrcLayercxx . . $ OGRGenSQLResultsLayer#m_poSrcLayer.->GetLayerDefncxx . . $ OGRLayer#GetLayerDefn(407fccde18759965).(); |
| 906 | stdcxx . . $ std/::unique_ptr<TempGeomIgnoredSettercxx . . $ OGRGenSQLResultsLayer#PrepareSummary(50ce9a9e25b4a850).TempGeomIgnoredSetter#> oTempGeomIgnoredSetter; |
| 907 | |
| 908 | if (!m_bSpatialFilterSetOnSourceLayercxx . . $ OGRGenSQLResultsLayer#m_bSpatialFilterSetOnSourceLayer. && m_poFilterGeomcxx . . $ OGRLayer#m_poFilterGeom. == nullptr && |
| 909 | (psSelectInfo->where_exprcxx . . $ swq_select#where_expr. == nullptr || |
| 910 | !ContainGeomSpecialFieldcxx . . $ OGRGenSQLResultsLayer#ContainGeomSpecialField(ccc0574cba9f1f31).(psSelectInfo->where_exprcxx . . $ swq_select#where_expr.))) |
| 911 | { |
| 912 | bool bFoundGeomExpr = false; |
| 913 | for (int iField = 0; iField < psSelectInfo->result_columnscxx . . $ swq_select#result_columns(455f465bc33b4cdf).(); iField++) |
| 914 | { |
| 915 | const swq_col_defcxx . . $ swq_col_def# *psColDef = &psSelectInfo->column_defscxx . . $ swq_select#column_defs.[iField]; |
| 916 | if (psColDef->table_indexcxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#table_index. == 0 && psColDef->field_indexcxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#field_index. != -1) |
| 917 | { |
| 918 | OGRLayercxx . . $ OGRLayer# *poLayer = m_apoTableLayerscxx . . $ OGRGenSQLResultsLayer#m_apoTableLayers.[psColDef->table_indexcxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#table_index.]; |
| 919 | const int nSpecialFieldIdx = |
| 920 | psColDef->field_indexcxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#field_index. - |
| 921 | poLayer->GetLayerDefncxx . . $ OGRLayer#GetLayerDefn(407fccde18759965).()->GetFieldCountcxx . . $ OGRFeatureDefn#GetFieldCount(455f465bc33b4cdf).(); |
| 922 | if (nSpecialFieldIdx == SPF_OGR_GEOMETRYcxx . . $ `ogr/ogr_p.h:170:9`! || |
| 923 | nSpecialFieldIdx == SPF_OGR_GEOM_WKTcxx . . $ `ogr/ogr_p.h:172:9`! || |
| 924 | nSpecialFieldIdx == SPF_OGR_GEOM_AREAcxx . . $ `ogr/ogr_p.h:173:9`!) |
| 925 | { |
| 926 | bFoundGeomExpr = true; |
| 927 | break; |
| 928 | } |
| 929 | if (psColDef->field_indexcxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#field_index. == |
| 930 | GEOM_FIELD_INDEX_TO_ALL_FIELD_INDEXcxx . . $ `ogr/ogrsf_frmts/generic/ogr_gensql.h:26:9`!(poLayer->GetLayerDefn(), |
| 931 | 0)) |
| 932 | { |
| 933 | bFoundGeomExpr = true; |
| 934 | break; |
| 935 | } |
| 936 | } |
| 937 | if (psColDef->exprcxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#expr. != nullptr && |
| 938 | ContainGeomSpecialFieldcxx . . $ OGRGenSQLResultsLayer#ContainGeomSpecialField(ccc0574cba9f1f31).(psColDef->exprcxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#expr.)) |
| 939 | { |
| 940 | bFoundGeomExpr = true; |
| 941 | break; |
| 942 | } |
| 943 | } |
| 944 | if (!bFoundGeomExpr) |
| 945 | { |
| 946 | // cppcheck-suppress unreadVariable |
| 947 | oTempGeomIgnoredSetter = |
| 948 | stdcxx . . $ std/::make_unique<TempGeomIgnoredSettercxx . . $ OGRGenSQLResultsLayer#PrepareSummary(50ce9a9e25b4a850).TempGeomIgnoredSetter#>(poSrcLayerDefn); |
| 949 | } |
| 950 | } |
| 951 | |
| 952 | /* -------------------------------------------------------------------- */ |
| 953 | /* We treat COUNT(*) as a special case, and fill with */ |
| 954 | /* GetFeatureCount(). */ |
| 955 | /* -------------------------------------------------------------------- */ |
| 956 | |
| 957 | if (psSelectInfo->result_columnscxx . . $ swq_select#result_columns(455f465bc33b4cdf).() == 1 && |
| 958 | psSelectInfo->column_defscxx . . $ swq_select#column_defs.[0].col_funccxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#col_func. == SWQCF_COUNTcxx . . $ SWQCF_COUNT. && |
| 959 | psSelectInfo->column_defscxx . . $ swq_select#column_defs.[0].field_indexcxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#field_index. < 0) |
| 960 | { |
| 961 | GIntBigcxx . . $ GIntBig# nRes = m_poSrcLayercxx . . $ OGRGenSQLResultsLayer#m_poSrcLayer.->GetFeatureCountcxx . . $ OGRLayer#GetFeatureCount(9ccc33c3ebad048d).(TRUEcxx . . $ `port/cpl_port.h:1184:9`!); |
| 962 | m_poSummaryFeaturecxx . . $ OGRGenSQLResultsLayer#m_poSummaryFeature.->SetFieldcxx . . $ OGRFeature#SetField(9ffed314a0a4f263).(0, nRes); |
| 963 | |
| 964 | if (CPL_INT64_FITS_ON_INT32cxx . . $ `port/cpl_port.h:265:9`!(nRes)) |
| 965 | { |
| 966 | m_poSummaryFeaturecxx . . $ OGRGenSQLResultsLayer#m_poSummaryFeature..reset(); |
| 967 | m_poDefncxx . . $ OGRGenSQLResultsLayer#m_poDefn.->GetFieldDefncxx . . $ OGRFeatureDefn#GetFieldDefn(2ec36f91b6ceefc7).(0)->SetTypecxx . . $ OGRFieldDefn#SetType(cc683e085121359d).(OFTInteger); |
| 968 | m_poSummaryFeaturecxx . . $ OGRGenSQLResultsLayer#m_poSummaryFeature. = stdcxx . . $ std/::make_unique<OGRFeaturecxx . . $ OGRFeature#>(m_poDefncxx . . $ OGRGenSQLResultsLayer#m_poDefn.); |
| 969 | m_poSummaryFeaturecxx . . $ OGRGenSQLResultsLayer#m_poSummaryFeature.->SetFIDcxx . . $ OGRFeature#SetFID(a070d6d14e988596).(0); |
| 970 | m_poSummaryFeaturecxx . . $ OGRGenSQLResultsLayer#m_poSummaryFeature.->SetFieldcxx . . $ OGRFeature#SetField(3e454b8ccf442868).(0, static_cast<int>(nRes)); |
| 971 | } |
| 972 | |
| 973 | return TRUEcxx . . $ `port/cpl_port.h:1184:9`!; |
| 974 | } |
| 975 | |
| 976 | /* -------------------------------------------------------------------- */ |
| 977 | /* Otherwise, process all source feature through the summary */ |
| 978 | /* building facilities of SWQ. */ |
| 979 | /* -------------------------------------------------------------------- */ |
| 980 | |
| 981 | for (auto &&poSrcFeature : *m_poSrcLayercxx . . $ OGRGenSQLResultsLayer#m_poSrcLayer.) |
| 982 | { |
| 983 | for (int iField = 0; iField < psSelectInfo->result_columnscxx . . $ swq_select#result_columns(455f465bc33b4cdf).(); iField++) |
| 984 | { |
| 985 | const swq_col_defcxx . . $ swq_col_def# *psColDef = &psSelectInfo->column_defscxx . . $ swq_select#column_defs.[iField]; |
| 986 | const char *pszError = nullptr; |
| 987 | |
| 988 | if (psColDef->col_funccxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#col_func. == SWQCF_COUNTcxx . . $ SWQCF_COUNT.) |
| 989 | { |
| 990 | /* psColDef->field_index can be -1 in the case of a COUNT(*) */ |
| 991 | if (psColDef->field_indexcxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#field_index. < 0) |
| 992 | pszError = |
| 993 | swq_select_summarizecxx . . $ swq_select_summarize(a95c8543a213a532).(psSelectInfo, iField, "", nullptr); |
| 994 | else if (IS_GEOM_FIELD_INDEXcxx . . $ `ogr/ogrsf_frmts/generic/ogr_gensql.h:29:9`!(poSrcLayerDefn, |
| 995 | psColDef->field_index)) |
| 996 | { |
| 997 | const int iSrcGeomField = |
| 998 | ALL_FIELD_INDEX_TO_GEOM_FIELD_INDEXcxx . . $ `ogr/ogrsf_frmts/generic/ogr_gensql.h:34:9`!( |
| 999 | poSrcLayerDefn, psColDef->field_index); |
| 1000 | const OGRGeometrycxx . . $ OGRGeometry# *poGeom = |
| 1001 | poSrcFeature->GetGeomFieldRefcxx . . $ OGRFeature#GetGeomFieldRef(ea443ccec24c6360).(iSrcGeomField); |
| 1002 | if (poGeom != nullptr) |
| 1003 | pszError = swq_select_summarizecxx . . $ swq_select_summarize(a95c8543a213a532).(psSelectInfo, iField, |
| 1004 | "", nullptr); |
| 1005 | } |
| 1006 | else if (poSrcFeature->IsFieldSetAndNotNullcxx . . $ OGRFeature#IsFieldSetAndNotNull(4a668f6de69bf818).( |
| 1007 | psColDef->field_indexcxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#field_index.)) |
| 1008 | { |
| 1009 | if (!psColDef->distinct_flagcxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#distinct_flag.) |
| 1010 | { |
| 1011 | pszError = swq_select_summarizecxx . . $ swq_select_summarize(a95c8543a213a532).(psSelectInfo, iField, |
| 1012 | "", nullptr); |
| 1013 | } |
| 1014 | else |
| 1015 | { |
| 1016 | const char *pszVal = poSrcFeature->GetFieldAsStringcxx . . $ OGRFeature#GetFieldAsString(afbf07f2bc1a9437).( |
| 1017 | psColDef->field_indexcxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#field_index.); |
| 1018 | pszError = swq_select_summarizecxx . . $ swq_select_summarize(a95c8543a213a532).(psSelectInfo, iField, |
| 1019 | pszVal, nullptr); |
| 1020 | } |
| 1021 | } |
| 1022 | } |
| 1023 | else |
| 1024 | { |
| 1025 | if (poSrcFeature->IsFieldSetAndNotNullcxx . . $ OGRFeature#IsFieldSetAndNotNull(4a668f6de69bf818).(psColDef->field_indexcxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#field_index.)) |
| 1026 | { |
| 1027 | if (!psColDef->distinct_flagcxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#distinct_flag. && |
| 1028 | (psColDef->field_typecxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#field_type. == SWQ_BOOLEANcxx . . $ SWQ_BOOLEAN. || |
| 1029 | psColDef->field_typecxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#field_type. == SWQ_INTEGERcxx . . $ SWQ_INTEGER. || |
| 1030 | psColDef->field_typecxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#field_type. == SWQ_INTEGER64cxx . . $ SWQ_INTEGER64. || |
| 1031 | psColDef->field_typecxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#field_type. == SWQ_FLOATcxx . . $ SWQ_FLOAT.)) |
| 1032 | { |
| 1033 | const double dfValue = poSrcFeature->GetFieldAsDoublecxx . . $ OGRFeature#GetFieldAsDouble(8bbae5fb2e9ef7ac).( |
| 1034 | psColDef->field_indexcxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#field_index.); |
| 1035 | pszError = swq_select_summarizecxx . . $ swq_select_summarize(a95c8543a213a532).(psSelectInfo, iField, |
| 1036 | nullptr, &dfValue); |
| 1037 | } |
| 1038 | else |
| 1039 | { |
| 1040 | const char *pszVal = poSrcFeature->GetFieldAsStringcxx . . $ OGRFeature#GetFieldAsString(afbf07f2bc1a9437).( |
| 1041 | psColDef->field_indexcxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#field_index.); |
| 1042 | pszError = swq_select_summarizecxx . . $ swq_select_summarize(a95c8543a213a532).(psSelectInfo, iField, |
| 1043 | pszVal, nullptr); |
| 1044 | } |
| 1045 | } |
| 1046 | else |
| 1047 | { |
| 1048 | pszError = swq_select_summarizecxx . . $ swq_select_summarize(a95c8543a213a532).(psSelectInfo, iField, |
| 1049 | nullptr, nullptr); |
| 1050 | } |
| 1051 | } |
| 1052 | |
| 1053 | if (pszError) |
| 1054 | { |
| 1055 | m_poSummaryFeaturecxx . . $ OGRGenSQLResultsLayer#m_poSummaryFeature..reset(); |
| 1056 | |
| 1057 | CPLError(CE_Failure, CPLE_AppDefinedcxx . . $ `port/cpl_error.h:108:9`!, "%s", pszError); |
| 1058 | return false; |
| 1059 | } |
| 1060 | } |
| 1061 | } |
| 1062 | |
| 1063 | /* -------------------------------------------------------------------- */ |
| 1064 | /* Clear away the filters we have installed till a next run through*/ |
| 1065 | /* the features. */ |
| 1066 | /* -------------------------------------------------------------------- */ |
| 1067 | const_cast<OGRGenSQLResultsLayercxx . . $ OGRGenSQLResultsLayer# *>(this)->ClearFilterscxx . . $ OGRGenSQLResultsLayer#ClearFilters(49f6e7a06ebc5aa8).(); |
| 1068 | |
| 1069 | /* -------------------------------------------------------------------- */ |
| 1070 | /* Now apply the values to the summary feature. If we are in */ |
| 1071 | /* DISTINCT_LIST mode we don't do this step. */ |
| 1072 | /* -------------------------------------------------------------------- */ |
| 1073 | if (psSelectInfo->query_modecxx . . $ swq_select#query_mode. == SWQM_SUMMARY_RECORDcxx . . $ `ogr/ogr_swq.h:320:9`!) |
| 1074 | { |
| 1075 | for (int iField = 0; iField < psSelectInfo->result_columnscxx . . $ swq_select#result_columns(455f465bc33b4cdf).(); iField++) |
| 1076 | { |
| 1077 | const swq_col_defcxx . . $ swq_col_def# *psColDef = &psSelectInfo->column_defscxx . . $ swq_select#column_defs.[iField]; |
| 1078 | if (!psSelectInfo->column_summarycxx . . $ swq_select#column_summary..empty()) |
| 1079 | { |
| 1080 | const swq_summarycxx . . $ swq_summary# &oSummary = |
| 1081 | psSelectInfo->column_summarycxx . . $ swq_select#column_summary.[iField]; |
| 1082 | if (psColDef->col_funccxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#col_func. == SWQCF_COUNTcxx . . $ SWQCF_COUNT.) |
| 1083 | { |
| 1084 | if (CPL_INT64_FITS_ON_INT32cxx . . $ `port/cpl_port.h:265:9`!(oSummary.count)) |
| 1085 | { |
| 1086 | m_poSummaryFeaturecxx . . $ OGRGenSQLResultsLayer#m_poSummaryFeature..reset(); |
| 1087 | m_poDefncxx . . $ OGRGenSQLResultsLayer#m_poDefn.->GetFieldDefncxx . . $ OGRFeatureDefn#GetFieldDefn(2ec36f91b6ceefc7).(iField)->SetTypecxx . . $ OGRFieldDefn#SetType(cc683e085121359d).(OFTInteger); |
| 1088 | } |
| 1089 | } |
| 1090 | } |
| 1091 | } |
| 1092 | |
| 1093 | if (!m_poSummaryFeaturecxx . . $ OGRGenSQLResultsLayer#m_poSummaryFeature.) |
| 1094 | { |
| 1095 | m_poSummaryFeaturecxx . . $ OGRGenSQLResultsLayer#m_poSummaryFeature. = stdcxx . . $ std/::make_unique<OGRFeaturecxx . . $ OGRFeature#>(m_poDefncxx . . $ OGRGenSQLResultsLayer#m_poDefn.); |
| 1096 | m_poSummaryFeaturecxx . . $ OGRGenSQLResultsLayer#m_poSummaryFeature.->SetFIDcxx . . $ OGRFeature#SetFID(a070d6d14e988596).(0); |
| 1097 | } |
| 1098 | |
| 1099 | for (int iField = 0; iField < psSelectInfo->result_columnscxx . . $ swq_select#result_columns(455f465bc33b4cdf).(); iField++) |
| 1100 | { |
| 1101 | const swq_col_defcxx . . $ swq_col_def# *psColDef = &psSelectInfo->column_defscxx . . $ swq_select#column_defs.[iField]; |
| 1102 | if (!psSelectInfo->column_summarycxx . . $ swq_select#column_summary..empty()) |
| 1103 | { |
| 1104 | const swq_summarycxx . . $ swq_summary# &oSummary = |
| 1105 | psSelectInfo->column_summarycxx . . $ swq_select#column_summary.[iField]; |
| 1106 | |
| 1107 | switch (psColDef->col_funccxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#col_func.) |
| 1108 | { |
| 1109 | case SWQCF_NONEcxx . . $ SWQCF_NONE.: |
| 1110 | case SWQCF_CUSTOMcxx . . $ SWQCF_CUSTOM.: |
| 1111 | break; |
| 1112 | |
| 1113 | case SWQCF_AVGcxx . . $ SWQCF_AVG.: |
| 1114 | { |
| 1115 | if (oSummary.countcxx . . $ swq_summary#count. > 0) |
| 1116 | { |
| 1117 | const double dfAvg = |
| 1118 | oSummary.sumcxx . . $ swq_summary#sum(21b6c25e127938e2).() / oSummary.countcxx . . $ swq_summary#count.; |
| 1119 | if (psColDef->field_typecxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#field_type. == SWQ_DATEcxx . . $ SWQ_DATE. || |
| 1120 | psColDef->field_typecxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#field_type. == SWQ_TIMEcxx . . $ SWQ_TIME. || |
| 1121 | psColDef->field_typecxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#field_type. == SWQ_TIMESTAMPcxx . . $ SWQ_TIMESTAMP.) |
| 1122 | { |
| 1123 | struct tmcxx . . $ tm# brokendowntime; |
| 1124 | CPLUnixTimeToYMDHMScxx . . $ CPLUnixTimeToYMDHMS(748f025bea3f4c3e).(static_cast<GIntBigcxx . . $ GIntBig#>(dfAvg), |
| 1125 | &brokendowntime); |
| 1126 | m_poSummaryFeaturecxx . . $ OGRGenSQLResultsLayer#m_poSummaryFeature.->SetFieldcxx . . $ OGRFeature#SetField(40c000d4299afb7e).( |
| 1127 | iField, brokendowntime.tm_yearcxx . . $ tm#tm_year. + 1900, |
| 1128 | brokendowntime.tm_moncxx . . $ tm#tm_mon. + 1, |
| 1129 | brokendowntime.tm_mdaycxx . . $ tm#tm_mday., |
| 1130 | brokendowntime.tm_hourcxx . . $ tm#tm_hour., |
| 1131 | brokendowntime.tm_mincxx . . $ tm#tm_min., |
| 1132 | static_cast<float>(brokendowntime.tm_seccxx . . $ tm#tm_sec. + |
| 1133 | fmodcxx . . $ fmod(9454dda30a4b8335).(dfAvg, 1)), |
| 1134 | 0); |
| 1135 | } |
| 1136 | else |
| 1137 | { |
| 1138 | m_poSummaryFeaturecxx . . $ OGRGenSQLResultsLayer#m_poSummaryFeature.->SetFieldcxx . . $ OGRFeature#SetField(9d6abc0cf25e86e9).(iField, dfAvg); |
| 1139 | } |
| 1140 | } |
| 1141 | break; |
| 1142 | } |
| 1143 | |
| 1144 | case SWQCF_MINcxx . . $ SWQCF_MIN.: |
| 1145 | { |
| 1146 | if (oSummary.countcxx . . $ swq_summary#count. > 0) |
| 1147 | { |
| 1148 | if (psColDef->field_typecxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#field_type. == SWQ_DATEcxx . . $ SWQ_DATE. || |
| 1149 | psColDef->field_typecxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#field_type. == SWQ_TIMEcxx . . $ SWQ_TIME. || |
| 1150 | psColDef->field_typecxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#field_type. == SWQ_TIMESTAMPcxx . . $ SWQ_TIMESTAMP. || |
| 1151 | psColDef->field_typecxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#field_type. == SWQ_STRINGcxx . . $ SWQ_STRING.) |
| 1152 | m_poSummaryFeaturecxx . . $ OGRGenSQLResultsLayer#m_poSummaryFeature.->SetFieldcxx . . $ OGRFeature#SetField(66835f578de1bcb3).( |
| 1153 | iField, oSummary.osMincxx . . $ swq_summary#osMin..c_str()); |
| 1154 | else |
| 1155 | m_poSummaryFeaturecxx . . $ OGRGenSQLResultsLayer#m_poSummaryFeature.->SetFieldcxx . . $ OGRFeature#SetField(9d6abc0cf25e86e9).(iField, |
| 1156 | oSummary.mincxx . . $ swq_summary#min.); |
| 1157 | } |
| 1158 | break; |
| 1159 | } |
| 1160 | |
| 1161 | case SWQCF_MAXcxx . . $ SWQCF_MAX.: |
| 1162 | { |
| 1163 | if (oSummary.countcxx . . $ swq_summary#count. > 0) |
| 1164 | { |
| 1165 | if (psColDef->field_typecxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#field_type. == SWQ_DATEcxx . . $ SWQ_DATE. || |
| 1166 | psColDef->field_typecxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#field_type. == SWQ_TIMEcxx . . $ SWQ_TIME. || |
| 1167 | psColDef->field_typecxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#field_type. == SWQ_TIMESTAMPcxx . . $ SWQ_TIMESTAMP. || |
| 1168 | psColDef->field_typecxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#field_type. == SWQ_STRINGcxx . . $ SWQ_STRING.) |
| 1169 | m_poSummaryFeaturecxx . . $ OGRGenSQLResultsLayer#m_poSummaryFeature.->SetFieldcxx . . $ OGRFeature#SetField(66835f578de1bcb3).( |
| 1170 | iField, oSummary.osMaxcxx . . $ swq_summary#osMax..c_str()); |
| 1171 | else |
| 1172 | m_poSummaryFeaturecxx . . $ OGRGenSQLResultsLayer#m_poSummaryFeature.->SetFieldcxx . . $ OGRFeature#SetField(9d6abc0cf25e86e9).(iField, |
| 1173 | oSummary.maxcxx . . $ swq_summary#max.); |
| 1174 | } |
| 1175 | break; |
| 1176 | } |
| 1177 | |
| 1178 | case SWQCF_COUNTcxx . . $ SWQCF_COUNT.: |
| 1179 | { |
| 1180 | m_poSummaryFeaturecxx . . $ OGRGenSQLResultsLayer#m_poSummaryFeature.->SetFieldcxx . . $ OGRFeature#SetField(9ffed314a0a4f263).(iField, oSummary.countcxx . . $ swq_summary#count.); |
| 1181 | break; |
| 1182 | } |
| 1183 | |
| 1184 | case SWQCF_SUMcxx . . $ SWQCF_SUM.: |
| 1185 | { |
| 1186 | if (oSummary.countcxx . . $ swq_summary#count. > 0) |
| 1187 | m_poSummaryFeaturecxx . . $ OGRGenSQLResultsLayer#m_poSummaryFeature.->SetFieldcxx . . $ OGRFeature#SetField(9d6abc0cf25e86e9).(iField, |
| 1188 | oSummary.sumcxx . . $ swq_summary#sum(21b6c25e127938e2).()); |
| 1189 | break; |
| 1190 | } |
| 1191 | |
| 1192 | case SWQCF_STDDEV_POPcxx . . $ SWQCF_STDDEV_POP.: |
| 1193 | { |
| 1194 | if (oSummary.countcxx . . $ swq_summary#count. > 0) |
| 1195 | { |
| 1196 | const double dfVariance = |
| 1197 | oSummary.sq_dist_from_mean_acccxx . . $ swq_summary#sq_dist_from_mean_acc. / oSummary.countcxx . . $ swq_summary#count.; |
| 1198 | m_poSummaryFeaturecxx . . $ OGRGenSQLResultsLayer#m_poSummaryFeature.->SetFieldcxx . . $ OGRFeature#SetField(9d6abc0cf25e86e9).(iField, |
| 1199 | sqrtcxx . . $ sqrt(fee4f1d22bc8e617).(dfVariance)); |
| 1200 | } |
| 1201 | break; |
| 1202 | } |
| 1203 | |
| 1204 | case SWQCF_STDDEV_SAMPcxx . . $ SWQCF_STDDEV_SAMP.: |
| 1205 | { |
| 1206 | if (oSummary.countcxx . . $ swq_summary#count. > 1) |
| 1207 | { |
| 1208 | const double dfSampleVariance = |
| 1209 | oSummary.sq_dist_from_mean_acccxx . . $ swq_summary#sq_dist_from_mean_acc. / |
| 1210 | (oSummary.countcxx . . $ swq_summary#count. - 1); |
| 1211 | m_poSummaryFeaturecxx . . $ OGRGenSQLResultsLayer#m_poSummaryFeature.->SetFieldcxx . . $ OGRFeature#SetField(9d6abc0cf25e86e9).( |
| 1212 | iField, sqrtcxx . . $ sqrt(fee4f1d22bc8e617).(dfSampleVariance)); |
| 1213 | } |
| 1214 | break; |
| 1215 | } |
| 1216 | } |
| 1217 | } |
| 1218 | else if (psColDef->col_funccxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#col_func. == SWQCF_COUNTcxx . . $ SWQCF_COUNT.) |
| 1219 | m_poSummaryFeaturecxx . . $ OGRGenSQLResultsLayer#m_poSummaryFeature.->SetFieldcxx . . $ OGRFeature#SetField(3e454b8ccf442868).(iField, 0); |
| 1220 | } |
| 1221 | } |
| 1222 | |
| 1223 | return TRUEcxx . . $ `port/cpl_port.h:1184:9`!; |
| 1224 | } |
| 1225 | |
| 1226 | /************************************************************************/ |
| 1227 | /* OGRMultiFeatureFetcher() */ |
| 1228 | /************************************************************************/ |
| 1229 | |
| 1230 | typedef stdcxx . . $ std/::vector<stdcxx . . $ std/::unique_ptr<OGRFeaturecxx . . $ OGRFeature#>> VectorOfUniquePtrFeaturecxx . . $ VectorOfUniquePtrFeature#; |
| 1231 | |
| 1232 | static swq_expr_nodecxx . . $ swq_expr_node# *OGRMultiFeatureFetchercxx . . $ OGRMultiFeatureFetcher(1a578d9b03b1d267).(swq_expr_nodecxx . . $ swq_expr_node# *op, |
| 1233 | void *pFeatureList) |
| 1234 | |
| 1235 | { |
| 1236 | auto &apoFeatures = |
| 1237 | *(static_cast<VectorOfUniquePtrFeaturecxx . . $ VectorOfUniquePtrFeature# *>(pFeatureList)); |
| 1238 | swq_expr_nodecxx . . $ swq_expr_node# *poRetNode = nullptr; |
| 1239 | |
| 1240 | CPLAssertcxx . . $ `port/cpl_error.h:353:9`!(op->eNodeType == SNT_COLUMN); |
| 1241 | |
| 1242 | /* -------------------------------------------------------------------- */ |
| 1243 | /* What feature are we using? The primary or one of the joined ones?*/ |
| 1244 | /* -------------------------------------------------------------------- */ |
| 1245 | if (op->table_indexcxx . . $ swq_expr_node#table_index. < 0 || |
| 1246 | op->table_indexcxx . . $ swq_expr_node#table_index. >= static_cast<int>(apoFeatures.size())) |
| 1247 | { |
| 1248 | CPLError(CE_Failure, CPLE_AppDefinedcxx . . $ `port/cpl_error.h:108:9`!, |
| 1249 | "Request for unexpected table_index (%d) in field fetcher.", |
| 1250 | op->table_indexcxx . . $ swq_expr_node#table_index.); |
| 1251 | return nullptr; |
| 1252 | } |
| 1253 | |
| 1254 | OGRFeaturecxx . . $ OGRFeature# *poFeature = apoFeatures[op->table_indexcxx . . $ swq_expr_node#table_index.].get(); |
| 1255 | |
| 1256 | /* -------------------------------------------------------------------- */ |
| 1257 | /* Fetch the value. */ |
| 1258 | /* -------------------------------------------------------------------- */ |
| 1259 | switch (op->field_typecxx . . $ swq_expr_node#field_type.) |
| 1260 | { |
| 1261 | case SWQ_INTEGERcxx . . $ SWQ_INTEGER.: |
| 1262 | case SWQ_BOOLEANcxx . . $ SWQ_BOOLEAN.: |
| 1263 | if (poFeature == nullptr || |
| 1264 | !poFeature->IsFieldSetAndNotNullcxx . . $ OGRFeature#IsFieldSetAndNotNull(4a668f6de69bf818).(op->field_indexcxx . . $ swq_expr_node#field_index.)) |
| 1265 | { |
| 1266 | poRetNode = new swq_expr_nodecxx . . $ swq_expr_node#swq_expr_node(d4f767463ce0a6b3).(0); |
| 1267 | poRetNode->is_nullcxx . . $ swq_expr_node#is_null. = TRUEcxx . . $ `port/cpl_port.h:1184:9`!; |
| 1268 | } |
| 1269 | else |
| 1270 | poRetNode = new swq_expr_nodecxx . . $ swq_expr_node#swq_expr_node(d4f767463ce0a6b3).( |
| 1271 | poFeature->GetFieldAsIntegercxx . . $ OGRFeature#GetFieldAsInteger(7ccb52b1bfe01045).(op->field_indexcxx . . $ swq_expr_node#field_index.)); |
| 1272 | break; |
| 1273 | |
| 1274 | case SWQ_INTEGER64cxx . . $ SWQ_INTEGER64.: |
| 1275 | if (poFeature == nullptr || |
| 1276 | !poFeature->IsFieldSetAndNotNullcxx . . $ OGRFeature#IsFieldSetAndNotNull(4a668f6de69bf818).(op->field_indexcxx . . $ swq_expr_node#field_index.)) |
| 1277 | { |
| 1278 | poRetNode = new swq_expr_nodecxx . . $ swq_expr_node#swq_expr_node(35cb52607f6af42f).(static_cast<GIntBigcxx . . $ GIntBig#>(0)); |
| 1279 | poRetNode->is_nullcxx . . $ swq_expr_node#is_null. = TRUEcxx . . $ `port/cpl_port.h:1184:9`!; |
| 1280 | } |
| 1281 | else |
| 1282 | poRetNode = new swq_expr_nodecxx . . $ swq_expr_node#swq_expr_node(35cb52607f6af42f).( |
| 1283 | poFeature->GetFieldAsInteger64cxx . . $ OGRFeature#GetFieldAsInteger64(f3f16611d465c84c).(op->field_indexcxx . . $ swq_expr_node#field_index.)); |
| 1284 | break; |
| 1285 | |
| 1286 | case SWQ_FLOATcxx . . $ SWQ_FLOAT.: |
| 1287 | if (poFeature == nullptr || |
| 1288 | !poFeature->IsFieldSetAndNotNullcxx . . $ OGRFeature#IsFieldSetAndNotNull(4a668f6de69bf818).(op->field_indexcxx . . $ swq_expr_node#field_index.)) |
| 1289 | { |
| 1290 | poRetNode = new swq_expr_nodecxx . . $ swq_expr_node#swq_expr_node(ba8836b59fb42830).(0.0); |
| 1291 | poRetNode->is_nullcxx . . $ swq_expr_node#is_null. = TRUEcxx . . $ `port/cpl_port.h:1184:9`!; |
| 1292 | } |
| 1293 | else |
| 1294 | poRetNode = new swq_expr_nodecxx . . $ swq_expr_node#swq_expr_node(ba8836b59fb42830).( |
| 1295 | poFeature->GetFieldAsDoublecxx . . $ OGRFeature#GetFieldAsDouble(8bbae5fb2e9ef7ac).(op->field_indexcxx . . $ swq_expr_node#field_index.)); |
| 1296 | break; |
| 1297 | |
| 1298 | case SWQ_GEOMETRYcxx . . $ SWQ_GEOMETRY.: |
| 1299 | if (poFeature == nullptr) |
| 1300 | { |
| 1301 | poRetNode = |
| 1302 | new swq_expr_nodecxx . . $ swq_expr_node#swq_expr_node(5d090ec403f96684).(static_cast<OGRGeometrycxx . . $ OGRGeometry# *>(nullptr)); |
| 1303 | } |
| 1304 | else |
| 1305 | { |
| 1306 | int iSrcGeomField = ALL_FIELD_INDEX_TO_GEOM_FIELD_INDEXcxx . . $ `ogr/ogrsf_frmts/generic/ogr_gensql.h:34:9`!( |
| 1307 | poFeature->GetDefnRef(), op->field_index); |
| 1308 | poRetNode = new swq_expr_nodecxx . . $ swq_expr_node#swq_expr_node(5d090ec403f96684).( |
| 1309 | poFeature->GetGeomFieldRefcxx . . $ OGRFeature#GetGeomFieldRef(ea443ccec24c6360).(iSrcGeomField)); |
| 1310 | } |
| 1311 | break; |
| 1312 | |
| 1313 | default: |
| 1314 | if (poFeature == nullptr || |
| 1315 | !poFeature->IsFieldSetAndNotNullcxx . . $ OGRFeature#IsFieldSetAndNotNull(4a668f6de69bf818).(op->field_indexcxx . . $ swq_expr_node#field_index.)) |
| 1316 | { |
| 1317 | poRetNode = new swq_expr_nodecxx . . $ swq_expr_node#swq_expr_node(85c52e162fed56f9).(""); |
| 1318 | poRetNode->is_nullcxx . . $ swq_expr_node#is_null. = TRUEcxx . . $ `port/cpl_port.h:1184:9`!; |
| 1319 | } |
| 1320 | else |
| 1321 | poRetNode = new swq_expr_nodecxx . . $ swq_expr_node#swq_expr_node(85c52e162fed56f9).( |
| 1322 | poFeature->GetFieldAsStringcxx . . $ OGRFeature#GetFieldAsString(afbf07f2bc1a9437).(op->field_indexcxx . . $ swq_expr_node#field_index.)); |
| 1323 | break; |
| 1324 | } |
| 1325 | |
| 1326 | return poRetNode; |
| 1327 | } |
| 1328 | |
| 1329 | /************************************************************************/ |
| 1330 | /* GetFilterForJoin() */ |
| 1331 | /************************************************************************/ |
| 1332 | |
| 1333 | static CPLString GetFilterForJoincxx . . $ GetFilterForJoin(168dd4b58d05a2b).(swq_expr_nodecxx . . $ swq_expr_node# *poExpr, OGRFeaturecxx . . $ OGRFeature# *poSrcFeat, |
| 1334 | OGRLayercxx . . $ OGRLayer# *poJoinLayer, int secondary_table) |
| 1335 | { |
| 1336 | if (poExpr->eNodeTypecxx . . $ swq_expr_node#eNodeType. == SNT_CONSTANTcxx . . $ SNT_CONSTANT.) |
| 1337 | { |
| 1338 | char *pszRes = poExpr->Unparsecxx . . $ swq_expr_node#Unparse(ceef723f70169f4d).(nullptr, '"'); |
| 1339 | CPLString osRes(pszRes); |
| 1340 | CPLFreecxx . . $ `port/cpl_conv.h:97:9`!(pszRes); |
| 1341 | return osRes; |
| 1342 | } |
| 1343 | |
| 1344 | if (poExpr->eNodeTypecxx . . $ swq_expr_node#eNodeType. == SNT_COLUMNcxx . . $ SNT_COLUMN.) |
| 1345 | { |
| 1346 | CPLAssertcxx . . $ `port/cpl_error.h:353:9`!(poExpr->field_index != -1); |
| 1347 | CPLAssertcxx . . $ `port/cpl_error.h:353:9`!(poExpr->table_index == 0 || |
| 1348 | poExpr->table_index == secondary_table); |
| 1349 | |
| 1350 | if (poExpr->table_indexcxx . . $ swq_expr_node#table_index. == 0) |
| 1351 | { |
| 1352 | // if source key is null, we can't do join. |
| 1353 | if (!poSrcFeat->IsFieldSetAndNotNullcxx . . $ OGRFeature#IsFieldSetAndNotNull(4a668f6de69bf818).(poExpr->field_indexcxx . . $ swq_expr_node#field_index.)) |
| 1354 | { |
| 1355 | return ""; |
| 1356 | } |
| 1357 | const auto poSrcFDefn = poSrcFeat->GetDefnRefcxx . . $ OGRFeature#GetDefnRef(448b209f43d15bcc).(); |
| 1358 | if (poExpr->field_indexcxx . . $ swq_expr_node#field_index. >= poSrcFDefn->GetFieldCountcxx . . $ OGRFeatureDefn#GetFieldCount(455f465bc33b4cdf).()) |
| 1359 | { |
| 1360 | CPLAssertcxx . . $ `port/cpl_error.h:353:9`!(poExpr->field_index < |
| 1361 | poSrcFDefn->GetFieldCount() + SPECIAL_FIELD_COUNT); |
| 1362 | CPLString osRes; |
| 1363 | switch (SpecialFieldTypescxx . . $ SpecialFieldTypes.[poExpr->field_indexcxx . . $ swq_expr_node#field_index. - |
| 1364 | poSrcFDefn->GetFieldCountcxx . . $ OGRFeatureDefn#GetFieldCount(455f465bc33b4cdf).()]) |
| 1365 | { |
| 1366 | case SWQ_INTEGERcxx . . $ SWQ_INTEGER.: |
| 1367 | case SWQ_INTEGER64cxx . . $ SWQ_INTEGER64.: |
| 1368 | osRes = CPLString().Printf( |
| 1369 | CPL_FRMT_GIBcxx . . $ `port/cpl_port.h:257:9`!, poSrcFeat->GetFieldAsInteger64cxx . . $ OGRFeature#GetFieldAsInteger64(f3f16611d465c84c).( |
| 1370 | poExpr->field_indexcxx . . $ swq_expr_node#field_index.)); |
| 1371 | break; |
| 1372 | |
| 1373 | case SWQ_FLOATcxx . . $ SWQ_FLOAT.: |
| 1374 | osRes = CPLString().Printf( |
| 1375 | "%.17g", |
| 1376 | poSrcFeat->GetFieldAsDoublecxx . . $ OGRFeature#GetFieldAsDouble(8bbae5fb2e9ef7ac).(poExpr->field_indexcxx . . $ swq_expr_node#field_index.)); |
| 1377 | break; |
| 1378 | |
| 1379 | default: |
| 1380 | { |
| 1381 | char *pszEscaped = CPLEscapeString( |
| 1382 | poSrcFeat->GetFieldAsStringcxx . . $ OGRFeature#GetFieldAsString(afbf07f2bc1a9437).(poExpr->field_indexcxx . . $ swq_expr_node#field_index.), |
| 1383 | -1, CPLES_SQLcxx . . $ `port/cpl_string.h:159:9`!); |
| 1384 | osRes = "'"; |
| 1385 | osRes += pszEscaped; |
| 1386 | osRes += "'"; |
| 1387 | CPLFreecxx . . $ `port/cpl_conv.h:97:9`!(pszEscaped); |
| 1388 | break; |
| 1389 | } |
| 1390 | } |
| 1391 | return osRes; |
| 1392 | } |
| 1393 | else |
| 1394 | { |
| 1395 | const OGRFieldType ePrimaryFieldType = |
| 1396 | poSrcFeat->GetFieldDefnRefcxx . . $ OGRFeature#GetFieldDefnRef(53a8093e6b73def).(poExpr->field_indexcxx . . $ swq_expr_node#field_index.)->GetTypecxx . . $ OGRFieldDefn#GetType(b365ab774e05458e).(); |
| 1397 | const OGRField *psSrcField = |
| 1398 | poSrcFeat->GetRawFieldRefcxx . . $ OGRFeature#GetRawFieldRef(4f12117e0ec8b5e4).(poExpr->field_indexcxx . . $ swq_expr_node#field_index.); |
| 1399 | |
| 1400 | CPLString osRet; |
| 1401 | switch (ePrimaryFieldType) |
| 1402 | { |
| 1403 | case OFTInteger: |
| 1404 | osRet.Printf("%d", psSrcField->Integer); |
| 1405 | break; |
| 1406 | |
| 1407 | case OFTInteger64: |
| 1408 | osRet.Printf(CPL_FRMT_GIBcxx . . $ `port/cpl_port.h:257:9`!, psSrcField->Integer64); |
| 1409 | break; |
| 1410 | |
| 1411 | case OFTReal: |
| 1412 | osRet.Printf("%.17g", psSrcField->Real); |
| 1413 | break; |
| 1414 | |
| 1415 | case OFTString: |
| 1416 | { |
| 1417 | char *pszEscaped = CPLEscapeString( |
| 1418 | psSrcField->String, |
| 1419 | static_cast<int>(strlen(psSrcField->String)), |
| 1420 | CPLES_SQLcxx . . $ `port/cpl_string.h:159:9`!); |
| 1421 | osRet = "'"; |
| 1422 | osRet += pszEscaped; |
| 1423 | osRet += "'"; |
| 1424 | CPLFreecxx . . $ `port/cpl_conv.h:97:9`!(pszEscaped); |
| 1425 | break; |
| 1426 | } |
| 1427 | |
| 1428 | default: |
| 1429 | CPLAssertcxx . . $ `port/cpl_error.h:353:9`!(false); |
| 1430 | break; |
| 1431 | } |
| 1432 | |
| 1433 | return osRet; |
| 1434 | } |
| 1435 | } |
| 1436 | |
| 1437 | if (poExpr->table_indexcxx . . $ swq_expr_node#table_index. == secondary_table) |
| 1438 | { |
| 1439 | const auto poJoinFDefn = poJoinLayer->GetLayerDefncxx . . $ OGRLayer#GetLayerDefn(407fccde18759965).(); |
| 1440 | if (poExpr->field_indexcxx . . $ swq_expr_node#field_index. >= poJoinFDefn->GetFieldCountcxx . . $ OGRFeatureDefn#GetFieldCount(455f465bc33b4cdf).()) |
| 1441 | { |
| 1442 | CPLAssertcxx . . $ `port/cpl_error.h:353:9`!(poExpr->field_index < |
| 1443 | poJoinFDefn->GetFieldCount() + SPECIAL_FIELD_COUNT); |
| 1444 | return SpecialFieldNamescxx . . $ SpecialFieldNames.[poExpr->field_indexcxx . . $ swq_expr_node#field_index. - |
| 1445 | poJoinFDefn->GetFieldCountcxx . . $ OGRFeatureDefn#GetFieldCount(455f465bc33b4cdf).()]; |
| 1446 | } |
| 1447 | else |
| 1448 | { |
| 1449 | const OGRFieldDefncxx . . $ OGRFieldDefn# *poSecondaryFieldDefn = |
| 1450 | poJoinFDefn->GetFieldDefncxx . . $ OGRFeatureDefn#GetFieldDefn(2ec36f91b6ceefc7).(poExpr->field_indexcxx . . $ swq_expr_node#field_index.); |
| 1451 | return CPLSPrintf("\"%s\"", poSecondaryFieldDefn->GetNameRefcxx . . $ OGRFieldDefn#GetNameRef(a9f41ea0e82d88cf).()); |
| 1452 | } |
| 1453 | } |
| 1454 | |
| 1455 | CPLAssertcxx . . $ `port/cpl_error.h:353:9`!(false); |
| 1456 | return ""; |
| 1457 | } |
| 1458 | |
| 1459 | if (poExpr->eNodeTypecxx . . $ swq_expr_node#eNodeType. == SNT_OPERATIONcxx . . $ SNT_OPERATION.) |
| 1460 | { |
| 1461 | /* ----------------------------------------------------------------- */ |
| 1462 | /* Operation - start by unparsing all the subexpressions. */ |
| 1463 | /* ----------------------------------------------------------------- */ |
| 1464 | stdcxx . . $ std/::vector<char *> apszSubExpr; |
| 1465 | for (int i = 0; i < poExpr->nSubExprCountcxx . . $ swq_expr_node#nSubExprCount.; i++) |
| 1466 | { |
| 1467 | CPLString osSubExpr = |
| 1468 | GetFilterForJoincxx . . $ GetFilterForJoin(168dd4b58d05a2b).(poExpr->papoSubExprcxx . . $ swq_expr_node#papoSubExpr.[i], poSrcFeat, poJoinLayer, |
| 1469 | secondary_table); |
| 1470 | if (osSubExpr.empty()) |
| 1471 | { |
| 1472 | for (--i; i >= 0; i--) |
| 1473 | CPLFreecxx . . $ `port/cpl_conv.h:97:9`!(apszSubExpr[i]); |
| 1474 | return ""; |
| 1475 | } |
| 1476 | apszSubExpr.push_back(CPLStrdup(osSubExpr)); |
| 1477 | } |
| 1478 | |
| 1479 | CPLString osExpr = |
| 1480 | poExpr->UnparseOperationFromUnparsedSubExprcxx . . $ swq_expr_node#UnparseOperationFromUnparsedSubExpr(b950d603bf20d193).(&apszSubExpr[0]); |
| 1481 | |
| 1482 | /* ----------------------------------------------------------------- */ |
| 1483 | /* cleanup subexpressions. */ |
| 1484 | /* ----------------------------------------------------------------- */ |
| 1485 | for (int i = 0; i < poExpr->nSubExprCountcxx . . $ swq_expr_node#nSubExprCount.; i++) |
| 1486 | CPLFreecxx . . $ `port/cpl_conv.h:97:9`!(apszSubExpr[i]); |
| 1487 | |
| 1488 | return osExpr; |
| 1489 | } |
| 1490 | |
| 1491 | return ""; |
| 1492 | } |
| 1493 | |
| 1494 | /************************************************************************/ |
| 1495 | /* TranslateFeature() */ |
| 1496 | /************************************************************************/ |
| 1497 | |
| 1498 | stdcxx . . $ std/::unique_ptr<OGRFeaturecxx . . $ OGRFeature#> OGRGenSQLResultsLayercxx . . $ OGRGenSQLResultsLayer#::TranslateFeaturecxx . . $ OGRGenSQLResultsLayer#TranslateFeature(c0118f22c2c46cf0).( |
| 1499 | stdcxx . . $ std/::unique_ptr<OGRFeaturecxx . . $ OGRFeature#> poSrcFeatUniquePtr) |
| 1500 | |
| 1501 | { |
| 1502 | swq_selectcxx . . $ swq_select# *psSelectInfo = m_pSelectInfocxx . . $ OGRGenSQLResultsLayer#m_pSelectInfo..get(); |
| 1503 | VectorOfUniquePtrFeaturecxx . . $ VectorOfUniquePtrFeature# apoFeatures; |
| 1504 | |
| 1505 | if (poSrcFeatUniquePtr == nullptr) |
| 1506 | return nullptr; |
| 1507 | |
| 1508 | m_nFeaturesReadcxx . . $ OGRLayer#m_nFeaturesRead.++; |
| 1509 | |
| 1510 | apoFeatures.push_back(stdcxx . . $ std/::move(poSrcFeatUniquePtr)); |
| 1511 | auto poSrcFeat = apoFeatures.front().get(); |
| 1512 | |
| 1513 | /* -------------------------------------------------------------------- */ |
| 1514 | /* Fetch the corresponding features from any jointed tables. */ |
| 1515 | /* -------------------------------------------------------------------- */ |
| 1516 | for (int iJoin = 0; iJoin < psSelectInfo->join_countcxx . . $ swq_select#join_count.; iJoin++) |
| 1517 | { |
| 1518 | const swq_join_defcxx . . $ swq_join_def# *psJoinInfo = psSelectInfo->join_defscxx . . $ swq_select#join_defs. + iJoin; |
| 1519 | |
| 1520 | /* OGRMultiFeatureFetcher assumes that the features are pushed in */ |
| 1521 | /* apoFeatures with increasing secondary_table, so make sure */ |
| 1522 | /* we have taken care of this */ |
| 1523 | CPLAssertcxx . . $ `port/cpl_error.h:353:9`!(psJoinInfo->secondary_table == iJoin + 1); |
| 1524 | |
| 1525 | OGRLayercxx . . $ OGRLayer# *poJoinLayer = m_apoTableLayerscxx . . $ OGRGenSQLResultsLayer#m_apoTableLayers.[psJoinInfo->secondary_tablecxx . . $ $anonymous_type_a69ae1a4ba3d583e_8#secondary_table.]; |
| 1526 | |
| 1527 | const stdcxx . . $ std/::string osFilter = |
| 1528 | GetFilterForJoincxx . . $ GetFilterForJoin(168dd4b58d05a2b).(psJoinInfo->poExprcxx . . $ $anonymous_type_a69ae1a4ba3d583e_8#poExpr., poSrcFeat, poJoinLayer, |
| 1529 | psJoinInfo->secondary_tablecxx . . $ $anonymous_type_a69ae1a4ba3d583e_8#secondary_table.); |
| 1530 | // CPLDebug("OGR", "Filter = %s\n", osFilter.c_str()); |
| 1531 | |
| 1532 | // if source key is null, we can't do join. |
| 1533 | if (osFilter.empty()) |
| 1534 | { |
| 1535 | apoFeatures.push_back(nullptr); |
| 1536 | continue; |
| 1537 | } |
| 1538 | |
| 1539 | stdcxx . . $ std/::unique_ptr<OGRFeaturecxx . . $ OGRFeature#> poJoinFeature; |
| 1540 | |
| 1541 | poJoinLayer->ResetReadingcxx . . $ OGRLayer#ResetReading(49f6e7a06ebc5aa8).(); |
| 1542 | if (poJoinLayer->SetAttributeFiltercxx . . $ OGRLayer#SetAttributeFilter(5c4306d8553b3696).(osFilter.c_str()) == OGRERR_NONEcxx . . $ `ogr/ogr_core.h:390:9`!) |
| 1543 | poJoinFeature.reset(poJoinLayer->GetNextFeaturecxx . . $ OGRLayer#GetNextFeature(ec9eceddec1d9563).()); |
| 1544 | |
| 1545 | apoFeatures.push_back(stdcxx . . $ std/::move(poJoinFeature)); |
| 1546 | } |
| 1547 | |
| 1548 | /* -------------------------------------------------------------------- */ |
| 1549 | /* Create destination feature. */ |
| 1550 | /* -------------------------------------------------------------------- */ |
| 1551 | auto poDstFeat = stdcxx . . $ std/::make_unique<OGRFeaturecxx . . $ OGRFeature#>(m_poDefncxx . . $ OGRGenSQLResultsLayer#m_poDefn.); |
| 1552 | |
| 1553 | poDstFeat->SetFIDcxx . . $ OGRFeature#SetFID(a070d6d14e988596).(poSrcFeat->GetFIDcxx . . $ OGRFeature#GetFID(98833e9ab7de59a4).()); |
| 1554 | |
| 1555 | poDstFeat->SetStyleStringcxx . . $ OGRFeature#SetStyleString(85c52e162fed56f9).(poSrcFeat->GetStyleStringcxx . . $ OGRFeature#GetStyleString(a9f41ea0e82d88cf).()); |
| 1556 | poDstFeat->SetNativeDatacxx . . $ OGRFeature#SetNativeData(85c52e162fed56f9).(poSrcFeat->GetNativeDatacxx . . $ OGRFeature#GetNativeData(a9f41ea0e82d88cf).()); |
| 1557 | poDstFeat->SetNativeMediaTypecxx . . $ OGRFeature#SetNativeMediaType(85c52e162fed56f9).(poSrcFeat->GetNativeMediaTypecxx . . $ OGRFeature#GetNativeMediaType(a9f41ea0e82d88cf).()); |
| 1558 | |
| 1559 | /* -------------------------------------------------------------------- */ |
| 1560 | /* Evaluate fields that are complex expressions. */ |
| 1561 | /* -------------------------------------------------------------------- */ |
| 1562 | int iRegularField = 0; |
| 1563 | int iGeomField = 0; |
| 1564 | swq_evaluation_contextcxx . . $ swq_evaluation_context# sContext; |
| 1565 | for (int iField = 0; iField < psSelectInfo->result_columnscxx . . $ swq_select#result_columns(455f465bc33b4cdf).(); iField++) |
| 1566 | { |
| 1567 | const swq_col_defcxx . . $ swq_col_def# *psColDef = &psSelectInfo->column_defscxx . . $ swq_select#column_defs.[iField]; |
| 1568 | |
| 1569 | if (psColDef->bHiddencxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#bHidden.) |
| 1570 | { |
| 1571 | const char *pszDstFieldName = psColDef->field_aliascxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#field_alias. |
| 1572 | ? psColDef->field_aliascxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#field_alias. |
| 1573 | : psColDef->field_namecxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#field_name.; |
| 1574 | if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszDstFieldName, "OGR_STYLE")) |
| 1575 | { |
| 1576 | if (psColDef->field_typecxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#field_type. == SWQ_STRINGcxx . . $ SWQ_STRING.) |
| 1577 | { |
| 1578 | // Does this column definition directly references a |
| 1579 | // source field ? |
| 1580 | if (psColDef->field_indexcxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#field_index. >= 0) |
| 1581 | { |
| 1582 | if (!IS_GEOM_FIELD_INDEXcxx . . $ `ogr/ogrsf_frmts/generic/ogr_gensql.h:29:9`!(poSrcFeat->GetDefnRef(), |
| 1583 | psColDef->field_index)) |
| 1584 | { |
| 1585 | if (poSrcFeat->IsFieldSetAndNotNullcxx . . $ OGRFeature#IsFieldSetAndNotNull(4a668f6de69bf818).( |
| 1586 | psColDef->field_indexcxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#field_index.)) |
| 1587 | { |
| 1588 | const char *pszVal = |
| 1589 | poSrcFeat->GetFieldAsStringcxx . . $ OGRFeature#GetFieldAsString(afbf07f2bc1a9437).( |
| 1590 | psColDef->field_indexcxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#field_index.); |
| 1591 | poDstFeat->SetStyleStringcxx . . $ OGRFeature#SetStyleString(85c52e162fed56f9).(pszVal); |
| 1592 | } |
| 1593 | else |
| 1594 | { |
| 1595 | poDstFeat->SetStyleStringcxx . . $ OGRFeature#SetStyleString(85c52e162fed56f9).(nullptr); |
| 1596 | } |
| 1597 | } |
| 1598 | else |
| 1599 | { |
| 1600 | CPLError(CE_Warning, CPLE_AppDefinedcxx . . $ `port/cpl_error.h:108:9`!, |
| 1601 | "OGR_STYLE HIDDEN field should reference " |
| 1602 | "a column of type String"); |
| 1603 | } |
| 1604 | } |
| 1605 | else |
| 1606 | { |
| 1607 | auto poResult = stdcxx . . $ std/::unique_ptr<swq_expr_nodecxx . . $ swq_expr_node#>( |
| 1608 | psColDef->exprcxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#expr.->Evaluatecxx . . $ swq_expr_node#Evaluate(65580c8e2086e9a0).(OGRMultiFeatureFetchercxx . . $ OGRMultiFeatureFetcher(1a578d9b03b1d267)., |
| 1609 | &apoFeatures, sContext)); |
| 1610 | |
| 1611 | if (!poResult) |
| 1612 | { |
| 1613 | return nullptr; |
| 1614 | } |
| 1615 | |
| 1616 | poDstFeat->SetStyleStringcxx . . $ OGRFeature#SetStyleString(85c52e162fed56f9).(poResult->is_nullcxx . . $ swq_expr_node#is_null. |
| 1617 | ? nullptr |
| 1618 | : poResult->string_valuecxx . . $ swq_expr_node#string_value.); |
| 1619 | } |
| 1620 | } |
| 1621 | else |
| 1622 | { |
| 1623 | CPLError(CE_Warning, CPLE_AppDefinedcxx . . $ `port/cpl_error.h:108:9`!, |
| 1624 | "OGR_STYLE HIDDEN field should be of type String"); |
| 1625 | } |
| 1626 | } |
| 1627 | continue; |
| 1628 | } |
| 1629 | |
| 1630 | // Does this column definition directly references a |
| 1631 | // source field ? |
| 1632 | // If so, skip it for now, as it will be taken into account in the |
| 1633 | // next loop. |
| 1634 | if (psColDef->field_indexcxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#field_index. >= 0) |
| 1635 | { |
| 1636 | if (psColDef->field_typecxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#field_type. == SWQ_GEOMETRYcxx . . $ SWQ_GEOMETRY. || |
| 1637 | psColDef->target_typecxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#target_type. == SWQ_GEOMETRYcxx . . $ SWQ_GEOMETRY.) |
| 1638 | iGeomField++; |
| 1639 | else |
| 1640 | iRegularField++; |
| 1641 | continue; |
| 1642 | } |
| 1643 | |
| 1644 | auto poResult = stdcxx . . $ std/::unique_ptr<swq_expr_nodecxx . . $ swq_expr_node#>(psColDef->exprcxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#expr.->Evaluatecxx . . $ swq_expr_node#Evaluate(65580c8e2086e9a0).( |
| 1645 | OGRMultiFeatureFetchercxx . . $ OGRMultiFeatureFetcher(1a578d9b03b1d267)., &apoFeatures, sContext)); |
| 1646 | |
| 1647 | if (!poResult) |
| 1648 | { |
| 1649 | return nullptr; |
| 1650 | } |
| 1651 | |
| 1652 | if (poResult->is_nullcxx . . $ swq_expr_node#is_null.) |
| 1653 | { |
| 1654 | if (poResult->field_typecxx . . $ swq_expr_node#field_type. == SWQ_GEOMETRYcxx . . $ SWQ_GEOMETRY.) |
| 1655 | iGeomField++; |
| 1656 | else |
| 1657 | iRegularField++; |
| 1658 | continue; |
| 1659 | } |
| 1660 | |
| 1661 | switch (poResult->field_typecxx . . $ swq_expr_node#field_type.) |
| 1662 | { |
| 1663 | case SWQ_BOOLEANcxx . . $ SWQ_BOOLEAN.: |
| 1664 | case SWQ_INTEGERcxx . . $ SWQ_INTEGER.: |
| 1665 | case SWQ_INTEGER64cxx . . $ SWQ_INTEGER64.: |
| 1666 | poDstFeat->SetFieldcxx . . $ OGRFeature#SetField(9ffed314a0a4f263).(iRegularField++, |
| 1667 | static_cast<GIntBigcxx . . $ GIntBig#>(poResult->int_valuecxx . . $ swq_expr_node#int_value.)); |
| 1668 | break; |
| 1669 | |
| 1670 | case SWQ_FLOATcxx . . $ SWQ_FLOAT.: |
| 1671 | poDstFeat->SetFieldcxx . . $ OGRFeature#SetField(9d6abc0cf25e86e9).(iRegularField++, poResult->float_valuecxx . . $ swq_expr_node#float_value.); |
| 1672 | break; |
| 1673 | |
| 1674 | case SWQ_GEOMETRYcxx . . $ SWQ_GEOMETRY.: |
| 1675 | { |
| 1676 | const OGRGenSQLGeomFieldDefncxx . . $ OGRGenSQLGeomFieldDefn# *poGeomFieldDefn = |
| 1677 | cpl::down_cast<const OGRGenSQLGeomFieldDefncxx . . $ OGRGenSQLGeomFieldDefn# *>( |
| 1678 | poDstFeat->GetGeomFieldDefnRefcxx . . $ OGRFeature#GetGeomFieldDefnRef(801b12ff899738d8).(iGeomField)); |
| 1679 | if (poGeomFieldDefn->bForceGeomTypecxx . . $ OGRGenSQLGeomFieldDefn#bForceGeomType. && |
| 1680 | poResult->geometry_valuecxx . . $ swq_expr_node#geometry_value. != nullptr) |
| 1681 | { |
| 1682 | OGRwkbGeometryType eCurType = |
| 1683 | wkbFlattencxx . . $ `ogr/ogr_core.h:576:9`!(poResult->geometry_value->getGeometryType()); |
| 1684 | OGRwkbGeometryType eReqType = |
| 1685 | wkbFlattencxx . . $ `ogr/ogr_core.h:576:9`!(poGeomFieldDefn->GetType()); |
| 1686 | if (eCurType == wkbPolygon && eReqType == wkbMultiPolygon) |
| 1687 | { |
| 1688 | poResult->geometry_valuecxx . . $ swq_expr_node#geometry_value. = OGRGeometrycxx . . $ OGRGeometry#::FromHandlecxx . . $ OGRGeometry#FromHandle(6c331b48912c44c0).( |
| 1689 | OGR_G_ForceToMultiPolygon(OGRGeometrycxx . . $ OGRGeometry#::ToHandlecxx . . $ OGRGeometry#ToHandle(76b24ad94dcfe536).( |
| 1690 | poResult->geometry_valuecxx . . $ swq_expr_node#geometry_value.))); |
| 1691 | } |
| 1692 | else if ((eCurType == wkbMultiPolygon || |
| 1693 | eCurType == wkbGeometryCollection) && |
| 1694 | eReqType == wkbPolygon) |
| 1695 | { |
| 1696 | poResult->geometry_valuecxx . . $ swq_expr_node#geometry_value. = OGRGeometrycxx . . $ OGRGeometry#::FromHandlecxx . . $ OGRGeometry#FromHandle(6c331b48912c44c0).( |
| 1697 | OGR_G_ForceToPolygon(OGRGeometrycxx . . $ OGRGeometry#::ToHandlecxx . . $ OGRGeometry#ToHandle(76b24ad94dcfe536).( |
| 1698 | poResult->geometry_valuecxx . . $ swq_expr_node#geometry_value.))); |
| 1699 | } |
| 1700 | else if (eCurType == wkbLineString && |
| 1701 | eReqType == wkbMultiLineString) |
| 1702 | { |
| 1703 | poResult->geometry_valuecxx . . $ swq_expr_node#geometry_value. = OGRGeometrycxx . . $ OGRGeometry#::FromHandlecxx . . $ OGRGeometry#FromHandle(6c331b48912c44c0).( |
| 1704 | OGR_G_ForceToMultiLineString(OGRGeometrycxx . . $ OGRGeometry#::ToHandlecxx . . $ OGRGeometry#ToHandle(76b24ad94dcfe536).( |
| 1705 | poResult->geometry_valuecxx . . $ swq_expr_node#geometry_value.))); |
| 1706 | } |
| 1707 | else if ((eCurType == wkbMultiLineString || |
| 1708 | eCurType == wkbGeometryCollection) && |
| 1709 | eReqType == wkbLineString) |
| 1710 | { |
| 1711 | poResult->geometry_valuecxx . . $ swq_expr_node#geometry_value. = OGRGeometrycxx . . $ OGRGeometry#::FromHandlecxx . . $ OGRGeometry#FromHandle(6c331b48912c44c0).( |
| 1712 | OGR_G_ForceToLineString(OGRGeometrycxx . . $ OGRGeometry#::ToHandlecxx . . $ OGRGeometry#ToHandle(76b24ad94dcfe536).( |
| 1713 | poResult->geometry_valuecxx . . $ swq_expr_node#geometry_value.))); |
| 1714 | } |
| 1715 | } |
| 1716 | poDstFeat->SetGeomFieldcxx . . $ OGRFeature#SetGeomField(896393ecef503097).(iGeomField++, poResult->geometry_valuecxx . . $ swq_expr_node#geometry_value.); |
| 1717 | break; |
| 1718 | } |
| 1719 | |
| 1720 | default: |
| 1721 | poDstFeat->SetFieldcxx . . $ OGRFeature#SetField(66835f578de1bcb3).(iRegularField++, poResult->string_valuecxx . . $ swq_expr_node#string_value.); |
| 1722 | break; |
| 1723 | } |
| 1724 | } |
| 1725 | |
| 1726 | /* -------------------------------------------------------------------- */ |
| 1727 | /* Copy fields from primary record to the destination feature. */ |
| 1728 | /* -------------------------------------------------------------------- */ |
| 1729 | iRegularField = 0; |
| 1730 | iGeomField = 0; |
| 1731 | for (int iField = 0; iField < psSelectInfo->result_columnscxx . . $ swq_select#result_columns(455f465bc33b4cdf).(); iField++) |
| 1732 | { |
| 1733 | const swq_col_defcxx . . $ swq_col_def# *psColDef = &psSelectInfo->column_defscxx . . $ swq_select#column_defs.[iField]; |
| 1734 | |
| 1735 | if (psColDef->bHiddencxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#bHidden.) |
| 1736 | { |
| 1737 | continue; |
| 1738 | } |
| 1739 | |
| 1740 | // Skip this column definition if it doesn't reference a field from |
| 1741 | // the main feature |
| 1742 | if (psColDef->table_indexcxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#table_index. != 0) |
| 1743 | { |
| 1744 | if (psColDef->field_typecxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#field_type. == SWQ_GEOMETRYcxx . . $ SWQ_GEOMETRY. || |
| 1745 | psColDef->target_typecxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#target_type. == SWQ_GEOMETRYcxx . . $ SWQ_GEOMETRY.) |
| 1746 | iGeomField++; |
| 1747 | else |
| 1748 | iRegularField++; |
| 1749 | continue; |
| 1750 | } |
| 1751 | |
| 1752 | if (IS_GEOM_FIELD_INDEXcxx . . $ `ogr/ogrsf_frmts/generic/ogr_gensql.h:29:9`!(poSrcFeat->GetDefnRef(), psColDef->field_index)) |
| 1753 | { |
| 1754 | int iSrcGeomField = ALL_FIELD_INDEX_TO_GEOM_FIELD_INDEXcxx . . $ `ogr/ogrsf_frmts/generic/ogr_gensql.h:34:9`!( |
| 1755 | poSrcFeat->GetDefnRef(), psColDef->field_index); |
| 1756 | poDstFeat->SetGeomFieldcxx . . $ OGRFeature#SetGeomField(896393ecef503097).(iGeomField++, |
| 1757 | poSrcFeat->GetGeomFieldRefcxx . . $ OGRFeature#GetGeomFieldRef(ea443ccec24c6360).(iSrcGeomField)); |
| 1758 | } |
| 1759 | else if (psColDef->field_indexcxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#field_index. >= m_iFIDFieldIndexcxx . . $ OGRGenSQLResultsLayer#m_iFIDFieldIndex.) |
| 1760 | { |
| 1761 | CPLAssertcxx . . $ `port/cpl_error.h:353:9`!(psColDef->field_index < |
| 1762 | m_iFIDFieldIndex + SPECIAL_FIELD_COUNT); |
| 1763 | switch (SpecialFieldTypescxx . . $ SpecialFieldTypes.[psColDef->field_indexcxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#field_index. - m_iFIDFieldIndexcxx . . $ OGRGenSQLResultsLayer#m_iFIDFieldIndex.]) |
| 1764 | { |
| 1765 | case SWQ_INTEGERcxx . . $ SWQ_INTEGER.: |
| 1766 | case SWQ_INTEGER64cxx . . $ SWQ_INTEGER64.: |
| 1767 | poDstFeat->SetFieldcxx . . $ OGRFeature#SetField(9ffed314a0a4f263).( |
| 1768 | iRegularField, |
| 1769 | poSrcFeat->GetFieldAsInteger64cxx . . $ OGRFeature#GetFieldAsInteger64(f3f16611d465c84c).(psColDef->field_indexcxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#field_index.)); |
| 1770 | break; |
| 1771 | case SWQ_FLOATcxx . . $ SWQ_FLOAT.: |
| 1772 | poDstFeat->SetFieldcxx . . $ OGRFeature#SetField(9d6abc0cf25e86e9).( |
| 1773 | iRegularField, |
| 1774 | poSrcFeat->GetFieldAsDoublecxx . . $ OGRFeature#GetFieldAsDouble(8bbae5fb2e9ef7ac).(psColDef->field_indexcxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#field_index.)); |
| 1775 | break; |
| 1776 | default: |
| 1777 | poDstFeat->SetFieldcxx . . $ OGRFeature#SetField(66835f578de1bcb3).( |
| 1778 | iRegularField, |
| 1779 | poSrcFeat->GetFieldAsStringcxx . . $ OGRFeature#GetFieldAsString(afbf07f2bc1a9437).(psColDef->field_indexcxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#field_index.)); |
| 1780 | } |
| 1781 | iRegularField++; |
| 1782 | } |
| 1783 | else |
| 1784 | { |
| 1785 | switch (psColDef->target_typecxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#target_type.) |
| 1786 | { |
| 1787 | case SWQ_INTEGERcxx . . $ SWQ_INTEGER.: |
| 1788 | poDstFeat->SetFieldcxx . . $ OGRFeature#SetField(3e454b8ccf442868).( |
| 1789 | iRegularField, |
| 1790 | poSrcFeat->GetFieldAsIntegercxx . . $ OGRFeature#GetFieldAsInteger(7ccb52b1bfe01045).(psColDef->field_indexcxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#field_index.)); |
| 1791 | break; |
| 1792 | |
| 1793 | case SWQ_INTEGER64cxx . . $ SWQ_INTEGER64.: |
| 1794 | poDstFeat->SetFieldcxx . . $ OGRFeature#SetField(9ffed314a0a4f263).( |
| 1795 | iRegularField, |
| 1796 | poSrcFeat->GetFieldAsInteger64cxx . . $ OGRFeature#GetFieldAsInteger64(f3f16611d465c84c).(psColDef->field_indexcxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#field_index.)); |
| 1797 | break; |
| 1798 | |
| 1799 | case SWQ_FLOATcxx . . $ SWQ_FLOAT.: |
| 1800 | poDstFeat->SetFieldcxx . . $ OGRFeature#SetField(9d6abc0cf25e86e9).( |
| 1801 | iRegularField, |
| 1802 | poSrcFeat->GetFieldAsDoublecxx . . $ OGRFeature#GetFieldAsDouble(8bbae5fb2e9ef7ac).(psColDef->field_indexcxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#field_index.)); |
| 1803 | break; |
| 1804 | |
| 1805 | case SWQ_STRINGcxx . . $ SWQ_STRING.: |
| 1806 | case SWQ_TIMESTAMPcxx . . $ SWQ_TIMESTAMP.: |
| 1807 | case SWQ_DATEcxx . . $ SWQ_DATE.: |
| 1808 | case SWQ_TIMEcxx . . $ SWQ_TIME.: |
| 1809 | poDstFeat->SetFieldcxx . . $ OGRFeature#SetField(66835f578de1bcb3).( |
| 1810 | iRegularField, |
| 1811 | poSrcFeat->GetFieldAsStringcxx . . $ OGRFeature#GetFieldAsString(afbf07f2bc1a9437).(psColDef->field_indexcxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#field_index.)); |
| 1812 | break; |
| 1813 | |
| 1814 | case SWQ_GEOMETRYcxx . . $ SWQ_GEOMETRY.: |
| 1815 | CPLAssertcxx . . $ `port/cpl_error.h:353:9`!(false); |
| 1816 | break; |
| 1817 | |
| 1818 | default: |
| 1819 | poDstFeat->SetFieldcxx . . $ OGRFeature#SetField(7180b68df1666ab2).( |
| 1820 | iRegularField, |
| 1821 | poSrcFeat->GetRawFieldRefcxx . . $ OGRFeature#GetRawFieldRef(4f12117e0ec8b5e4).(psColDef->field_indexcxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#field_index.)); |
| 1822 | } |
| 1823 | iRegularField++; |
| 1824 | } |
| 1825 | } |
| 1826 | |
| 1827 | /* -------------------------------------------------------------------- */ |
| 1828 | /* Copy values from any joined tables. */ |
| 1829 | /* -------------------------------------------------------------------- */ |
| 1830 | for (int iJoin = 0; iJoin < psSelectInfo->join_countcxx . . $ swq_select#join_count.; iJoin++) |
| 1831 | { |
| 1832 | const swq_join_defcxx . . $ swq_join_def# *psJoinInfo = psSelectInfo->join_defscxx . . $ swq_select#join_defs. + iJoin; |
| 1833 | const OGRFeaturecxx . . $ OGRFeature# *poJoinFeature = apoFeatures[iJoin + 1].get(); |
| 1834 | |
| 1835 | if (poJoinFeature == nullptr) |
| 1836 | continue; |
| 1837 | |
| 1838 | // Copy over selected field values. |
| 1839 | iRegularField = 0; |
| 1840 | for (int iField = 0; iField < psSelectInfo->result_columnscxx . . $ swq_select#result_columns(455f465bc33b4cdf).(); iField++) |
| 1841 | { |
| 1842 | const swq_col_defcxx . . $ swq_col_def# *psColDef = &psSelectInfo->column_defscxx . . $ swq_select#column_defs.[iField]; |
| 1843 | |
| 1844 | if (psColDef->field_typecxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#field_type. == SWQ_GEOMETRYcxx . . $ SWQ_GEOMETRY. || |
| 1845 | psColDef->target_typecxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#target_type. == SWQ_GEOMETRYcxx . . $ SWQ_GEOMETRY.) |
| 1846 | continue; |
| 1847 | |
| 1848 | if (psColDef->bHiddencxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#bHidden.) |
| 1849 | { |
| 1850 | continue; |
| 1851 | } |
| 1852 | |
| 1853 | if (psColDef->table_indexcxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#table_index. == psJoinInfo->secondary_tablecxx . . $ $anonymous_type_a69ae1a4ba3d583e_8#secondary_table.) |
| 1854 | poDstFeat->SetFieldcxx . . $ OGRFeature#SetField(7180b68df1666ab2).( |
| 1855 | iRegularField, |
| 1856 | poJoinFeature->GetRawFieldRefcxx . . $ OGRFeature#GetRawFieldRef(ec58713283601c73).(psColDef->field_indexcxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#field_index.)); |
| 1857 | |
| 1858 | iRegularField++; |
| 1859 | } |
| 1860 | } |
| 1861 | |
| 1862 | return poDstFeat; |
| 1863 | } |
| 1864 | |
| 1865 | /************************************************************************/ |
| 1866 | /* GetNextFeature() */ |
| 1867 | /************************************************************************/ |
| 1868 | |
| 1869 | OGRFeaturecxx . . $ OGRFeature# *OGRGenSQLResultsLayercxx . . $ OGRGenSQLResultsLayer#::GetNextFeaturecxx . . $ OGRGenSQLResultsLayer#GetNextFeature(ec9eceddec1d9563).() |
| 1870 | |
| 1871 | { |
| 1872 | swq_selectcxx . . $ swq_select# *psSelectInfo = m_pSelectInfocxx . . $ OGRGenSQLResultsLayer#m_pSelectInfo..get(); |
| 1873 | |
| 1874 | if (m_bEOFcxx . . $ OGRGenSQLResultsLayer#m_bEOF.) |
| 1875 | return nullptr; |
| 1876 | if (psSelectInfo->limitcxx . . $ swq_select#limit. >= 0 && |
| 1877 | (m_nIteratedFeaturescxx . . $ OGRGenSQLResultsLayer#m_nIteratedFeatures. < 0 ? 0 : m_nIteratedFeaturescxx . . $ OGRGenSQLResultsLayer#m_nIteratedFeatures.) >= |
| 1878 | psSelectInfo->limitcxx . . $ swq_select#limit.) |
| 1879 | return nullptr; |
| 1880 | |
| 1881 | CreateOrderByIndexcxx . . $ OGRGenSQLResultsLayer#CreateOrderByIndex(49f6e7a06ebc5aa8).(); |
| 1882 | if (m_anFIDIndexcxx . . $ OGRGenSQLResultsLayer#m_anFIDIndex..empty() && m_nIteratedFeaturescxx . . $ OGRGenSQLResultsLayer#m_nIteratedFeatures. < 0 && |
| 1883 | psSelectInfo->offsetcxx . . $ swq_select#offset. > 0 && psSelectInfo->query_modecxx . . $ swq_select#query_mode. == SWQM_RECORDSETcxx . . $ `ogr/ogr_swq.h:321:9`!) |
| 1884 | { |
| 1885 | m_poSrcLayercxx . . $ OGRGenSQLResultsLayer#m_poSrcLayer.->SetNextByIndexcxx . . $ OGRLayer#SetNextByIndex(a070d6d14e988596).(psSelectInfo->offsetcxx . . $ swq_select#offset.); |
| 1886 | } |
| 1887 | if (m_nIteratedFeaturescxx . . $ OGRGenSQLResultsLayer#m_nIteratedFeatures. < 0) |
| 1888 | m_nIteratedFeaturescxx . . $ OGRGenSQLResultsLayer#m_nIteratedFeatures. = 0; |
| 1889 | |
| 1890 | /* -------------------------------------------------------------------- */ |
| 1891 | /* Handle summary sets. */ |
| 1892 | /* -------------------------------------------------------------------- */ |
| 1893 | if (psSelectInfo->query_modecxx . . $ swq_select#query_mode. == SWQM_SUMMARY_RECORDcxx . . $ `ogr/ogr_swq.h:320:9`! || |
| 1894 | psSelectInfo->query_modecxx . . $ swq_select#query_mode. == SWQM_DISTINCT_LISTcxx . . $ `ogr/ogr_swq.h:322:9`!) |
| 1895 | { |
| 1896 | m_nIteratedFeaturescxx . . $ OGRGenSQLResultsLayer#m_nIteratedFeatures.++; |
| 1897 | return GetFeaturecxx . . $ OGRGenSQLResultsLayer#GetFeature(86ac52c37891ada7).(m_nNextIndexFIDcxx . . $ OGRGenSQLResultsLayer#m_nNextIndexFID.++); |
| 1898 | } |
| 1899 | |
| 1900 | int bEvaluateSpatialFilter = MustEvaluateSpatialFilterOnGenSQLcxx . . $ OGRGenSQLResultsLayer#MustEvaluateSpatialFilterOnGenSQL(b126dc7c1de90089).(); |
| 1901 | |
| 1902 | /* -------------------------------------------------------------------- */ |
| 1903 | /* Handle ordered sets. */ |
| 1904 | /* -------------------------------------------------------------------- */ |
| 1905 | while (true) |
| 1906 | { |
| 1907 | stdcxx . . $ std/::unique_ptr<OGRFeaturecxx . . $ OGRFeature#> poSrcFeat; |
| 1908 | if (!m_anFIDIndexcxx . . $ OGRGenSQLResultsLayer#m_anFIDIndex..empty()) |
| 1909 | { |
| 1910 | /* -------------------------------------------------------------------- |
| 1911 | */ |
| 1912 | /* Are we running in sorted mode? If so, run the fid through |
| 1913 | */ |
| 1914 | /* the index. */ |
| 1915 | /* -------------------------------------------------------------------- |
| 1916 | */ |
| 1917 | |
| 1918 | if (m_nNextIndexFIDcxx . . $ OGRGenSQLResultsLayer#m_nNextIndexFID. >= static_cast<GIntBigcxx . . $ GIntBig#>(m_anFIDIndexcxx . . $ OGRGenSQLResultsLayer#m_anFIDIndex..size())) |
| 1919 | return nullptr; |
| 1920 | |
| 1921 | poSrcFeat.reset(m_poSrcLayercxx . . $ OGRGenSQLResultsLayer#m_poSrcLayer.->GetFeaturecxx . . $ OGRLayer#GetFeature(86ac52c37891ada7).( |
| 1922 | m_anFIDIndexcxx . . $ OGRGenSQLResultsLayer#m_anFIDIndex.[static_cast<size_t>(m_nNextIndexFIDcxx . . $ OGRGenSQLResultsLayer#m_nNextIndexFID.)])); |
| 1923 | m_nNextIndexFIDcxx . . $ OGRGenSQLResultsLayer#m_nNextIndexFID.++; |
| 1924 | } |
| 1925 | else |
| 1926 | { |
| 1927 | poSrcFeat.reset(m_poSrcLayercxx . . $ OGRGenSQLResultsLayer#m_poSrcLayer.->GetNextFeaturecxx . . $ OGRLayer#GetNextFeature(ec9eceddec1d9563).()); |
| 1928 | } |
| 1929 | |
| 1930 | if (poSrcFeat == nullptr) |
| 1931 | return nullptr; |
| 1932 | |
| 1933 | auto poFeature = TranslateFeaturecxx . . $ OGRGenSQLResultsLayer#TranslateFeature(c0118f22c2c46cf0).(stdcxx . . $ std/::move(poSrcFeat)); |
| 1934 | if (poFeature == nullptr) |
| 1935 | return nullptr; |
| 1936 | |
| 1937 | if ((m_poAttrQuerycxx . . $ OGRLayer#m_poAttrQuery. == nullptr || |
| 1938 | m_poAttrQuerycxx . . $ OGRLayer#m_poAttrQuery.->Evaluatecxx . . $ OGRFeatureQuery#Evaluate(2048609adab03aab).(poFeature.get())) && |
| 1939 | (!bEvaluateSpatialFilter || |
| 1940 | FilterGeometrycxx . . $ OGRLayer#FilterGeometry(fed901b2566802ff).(poFeature->GetGeomFieldRefcxx . . $ OGRFeature#GetGeomFieldRef(ea443ccec24c6360).(m_iGeomFieldFiltercxx . . $ OGRLayer#m_iGeomFieldFilter.)))) |
| 1941 | { |
| 1942 | m_nIteratedFeaturescxx . . $ OGRGenSQLResultsLayer#m_nIteratedFeatures.++; |
| 1943 | return poFeature.release(); |
| 1944 | } |
| 1945 | } |
| 1946 | } |
| 1947 | |
| 1948 | /************************************************************************/ |
| 1949 | /* GetFeature() */ |
| 1950 | /************************************************************************/ |
| 1951 | |
| 1952 | OGRFeaturecxx . . $ OGRFeature# *OGRGenSQLResultsLayercxx . . $ OGRGenSQLResultsLayer#::GetFeaturecxx . . $ OGRGenSQLResultsLayer#GetFeature(86ac52c37891ada7).(GIntBigcxx . . $ GIntBig# nFID) |
| 1953 | |
| 1954 | { |
| 1955 | swq_selectcxx . . $ swq_select# *psSelectInfo = m_pSelectInfocxx . . $ OGRGenSQLResultsLayer#m_pSelectInfo..get(); |
| 1956 | |
| 1957 | CreateOrderByIndexcxx . . $ OGRGenSQLResultsLayer#CreateOrderByIndex(49f6e7a06ebc5aa8).(); |
| 1958 | |
| 1959 | /* -------------------------------------------------------------------- */ |
| 1960 | /* Handle request for summary record. */ |
| 1961 | /* -------------------------------------------------------------------- */ |
| 1962 | if (psSelectInfo->query_modecxx . . $ swq_select#query_mode. == SWQM_SUMMARY_RECORDcxx . . $ `ogr/ogr_swq.h:320:9`!) |
| 1963 | { |
| 1964 | if (!PrepareSummarycxx . . $ OGRGenSQLResultsLayer#PrepareSummary(50ce9a9e25b4a850).() || nFID != 0 || !m_poSummaryFeaturecxx . . $ OGRGenSQLResultsLayer#m_poSummaryFeature.) |
| 1965 | return nullptr; |
| 1966 | else |
| 1967 | return m_poSummaryFeaturecxx . . $ OGRGenSQLResultsLayer#m_poSummaryFeature.->Clonecxx . . $ OGRFeature#Clone(bcd776315d3947b8).(); |
| 1968 | } |
| 1969 | |
| 1970 | /* -------------------------------------------------------------------- */ |
| 1971 | /* Handle request for distinct list record. */ |
| 1972 | /* -------------------------------------------------------------------- */ |
| 1973 | if (psSelectInfo->query_modecxx . . $ swq_select#query_mode. == SWQM_DISTINCT_LISTcxx . . $ `ogr/ogr_swq.h:322:9`!) |
| 1974 | { |
| 1975 | if (!PrepareSummarycxx . . $ OGRGenSQLResultsLayer#PrepareSummary(50ce9a9e25b4a850).()) |
| 1976 | return nullptr; |
| 1977 | |
| 1978 | if (psSelectInfo->column_summarycxx . . $ swq_select#column_summary..empty()) |
| 1979 | return nullptr; |
| 1980 | |
| 1981 | swq_summarycxx . . $ swq_summary# &oSummary = psSelectInfo->column_summarycxx . . $ swq_select#column_summary.[0]; |
| 1982 | if (psSelectInfo->order_specscxx . . $ swq_select#order_specs. == 0) |
| 1983 | { |
| 1984 | if (nFID < 0 || nFID >= static_cast<GIntBigcxx . . $ GIntBig#>( |
| 1985 | oSummary.oVectorDistinctValuescxx . . $ swq_summary#oVectorDistinctValues..size())) |
| 1986 | { |
| 1987 | return nullptr; |
| 1988 | } |
| 1989 | const size_t nIdx = static_cast<size_t>(nFID); |
| 1990 | if (oSummary.oVectorDistinctValuescxx . . $ swq_summary#oVectorDistinctValues.[nIdx] != SZ_OGR_NULLcxx . . $ `ogr/ogr_swq.h:40:9`!) |
| 1991 | { |
| 1992 | m_poSummaryFeaturecxx . . $ OGRGenSQLResultsLayer#m_poSummaryFeature.->SetFieldcxx . . $ OGRFeature#SetField(66835f578de1bcb3).( |
| 1993 | 0, oSummary.oVectorDistinctValuescxx . . $ swq_summary#oVectorDistinctValues.[nIdx].c_str()); |
| 1994 | } |
| 1995 | else |
| 1996 | m_poSummaryFeaturecxx . . $ OGRGenSQLResultsLayer#m_poSummaryFeature.->SetFieldNullcxx . . $ OGRFeature#SetFieldNull(d4f767463ce0a6b3).(0); |
| 1997 | } |
| 1998 | else |
| 1999 | { |
| 2000 | if (m_aosDistinctListcxx . . $ OGRGenSQLResultsLayer#m_aosDistinctList..empty()) |
| 2001 | { |
| 2002 | stdcxx . . $ std/::setcxx . . $ std/set#<CPLString, swq_summary::Comparator>::const_iteratorcxx . . $ std/set#const_iterator# |
| 2003 | oIter = oSummary.oSetDistinctValuescxx . . $ swq_summary#oSetDistinctValues..begincxx . . $ std/set#begin(3220b82c0db6d2a1).(); |
| 2004 | stdcxx . . $ std/::setcxx . . $ std/set#<CPLString, swq_summary::Comparator>::const_iteratorcxx . . $ std/set#const_iterator# |
| 2005 | oEnd = oSummary.oSetDistinctValuescxx . . $ swq_summary#oSetDistinctValues..endcxx . . $ std/set#end(3220b82c0db6d2a1).(); |
| 2006 | try |
| 2007 | { |
| 2008 | m_aosDistinctListcxx . . $ OGRGenSQLResultsLayer#m_aosDistinctList..reserve( |
| 2009 | oSummary.oSetDistinctValuescxx . . $ swq_summary#oSetDistinctValues..sizecxx . . $ std/set#size(fa801f5ac5d26b4e).()); |
| 2010 | for (; oIter !=cxx . . $ std/`operator!=`(a84eb84a7a5e8237). oEnd; ++cxx . . $ std/_Rb_tree_const_iterator#operator++(9cb79ab07bb244bf).oIter) |
| 2011 | { |
| 2012 | m_aosDistinctListcxx . . $ OGRGenSQLResultsLayer#m_aosDistinctList..push_back(*cxx . . $ std/_Rb_tree_const_iterator#`operator*`(2042464fc1fea03e).oIter); |
| 2013 | } |
| 2014 | } |
| 2015 | catch (stdcxx . . $ std/::bad_alloc &) |
| 2016 | { |
| 2017 | return nullptr; |
| 2018 | } |
| 2019 | oSummary.oSetDistinctValuescxx . . $ swq_summary#oSetDistinctValues..clearcxx . . $ std/set#clear(ced63f7c635d850d).(); |
| 2020 | } |
| 2021 | |
| 2022 | if (nFID < 0 || |
| 2023 | nFID >= static_cast<GIntBigcxx . . $ GIntBig#>(m_aosDistinctListcxx . . $ OGRGenSQLResultsLayer#m_aosDistinctList..size())) |
| 2024 | return nullptr; |
| 2025 | |
| 2026 | const size_t nIdx = static_cast<size_t>(nFID); |
| 2027 | if (m_aosDistinctListcxx . . $ OGRGenSQLResultsLayer#m_aosDistinctList.[nIdx] != SZ_OGR_NULLcxx . . $ `ogr/ogr_swq.h:40:9`!) |
| 2028 | m_poSummaryFeaturecxx . . $ OGRGenSQLResultsLayer#m_poSummaryFeature.->SetFieldcxx . . $ OGRFeature#SetField(66835f578de1bcb3).(0, |
| 2029 | m_aosDistinctListcxx . . $ OGRGenSQLResultsLayer#m_aosDistinctList.[nIdx].c_str()); |
| 2030 | else |
| 2031 | m_poSummaryFeaturecxx . . $ OGRGenSQLResultsLayer#m_poSummaryFeature.->SetFieldNullcxx . . $ OGRFeature#SetFieldNull(d4f767463ce0a6b3).(0); |
| 2032 | } |
| 2033 | |
| 2034 | m_poSummaryFeaturecxx . . $ OGRGenSQLResultsLayer#m_poSummaryFeature.->SetFIDcxx . . $ OGRFeature#SetFID(a070d6d14e988596).(nFID); |
| 2035 | |
| 2036 | return m_poSummaryFeaturecxx . . $ OGRGenSQLResultsLayer#m_poSummaryFeature.->Clonecxx . . $ OGRFeature#Clone(bcd776315d3947b8).(); |
| 2037 | } |
| 2038 | |
| 2039 | /* -------------------------------------------------------------------- */ |
| 2040 | /* Handle request for random record. */ |
| 2041 | /* -------------------------------------------------------------------- */ |
| 2042 | auto poSrcFeature = |
| 2043 | stdcxx . . $ std/::unique_ptr<OGRFeaturecxx . . $ OGRFeature#>(m_poSrcLayercxx . . $ OGRGenSQLResultsLayer#m_poSrcLayer.->GetFeaturecxx . . $ OGRLayer#GetFeature(86ac52c37891ada7).(nFID)); |
| 2044 | if (poSrcFeature == nullptr) |
| 2045 | return nullptr; |
| 2046 | |
| 2047 | return TranslateFeaturecxx . . $ OGRGenSQLResultsLayer#TranslateFeature(c0118f22c2c46cf0).(stdcxx . . $ std/::move(poSrcFeature)).release(); |
| 2048 | } |
| 2049 | |
| 2050 | /************************************************************************/ |
| 2051 | /* GetSpatialFilter() */ |
| 2052 | /************************************************************************/ |
| 2053 | |
| 2054 | OGRGeometrycxx . . $ OGRGeometry# *OGRGenSQLResultsLayercxx . . $ OGRGenSQLResultsLayer#::GetSpatialFiltercxx . . $ OGRGenSQLResultsLayer#GetSpatialFilter(3dfc1d32c7db2584).() |
| 2055 | |
| 2056 | { |
| 2057 | return nullptr; |
| 2058 | } |
| 2059 | |
| 2060 | /************************************************************************/ |
| 2061 | /* GetLayerDefn() */ |
| 2062 | /************************************************************************/ |
| 2063 | |
| 2064 | const OGRFeatureDefncxx . . $ OGRFeatureDefn# *OGRGenSQLResultsLayercxx . . $ OGRGenSQLResultsLayer#::GetLayerDefncxx . . $ OGRGenSQLResultsLayer#GetLayerDefn(448b209f43d15bcc).() const |
| 2065 | |
| 2066 | { |
| 2067 | swq_selectcxx . . $ swq_select# *psSelectInfo = m_pSelectInfocxx . . $ OGRGenSQLResultsLayer#m_pSelectInfo..get(); |
| 2068 | if (psSelectInfo->query_modecxx . . $ swq_select#query_mode. == SWQM_SUMMARY_RECORDcxx . . $ `ogr/ogr_swq.h:320:9`! && !m_poSummaryFeaturecxx . . $ OGRGenSQLResultsLayer#m_poSummaryFeature.) |
| 2069 | { |
| 2070 | // Run PrepareSummary() is we have a COUNT column so as to be |
| 2071 | // able to downcast it from OFTInteger64 to OFTInteger |
| 2072 | for (int iField = 0; iField < psSelectInfo->result_columnscxx . . $ swq_select#result_columns(455f465bc33b4cdf).(); iField++) |
| 2073 | { |
| 2074 | swq_col_defcxx . . $ swq_col_def# *psColDef = &psSelectInfo->column_defscxx . . $ swq_select#column_defs.[iField]; |
| 2075 | if (psColDef->col_funccxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#col_func. == SWQCF_COUNTcxx . . $ SWQCF_COUNT.) |
| 2076 | { |
| 2077 | PrepareSummarycxx . . $ OGRGenSQLResultsLayer#PrepareSummary(50ce9a9e25b4a850).(); |
| 2078 | break; |
| 2079 | } |
| 2080 | } |
| 2081 | } |
| 2082 | |
| 2083 | return m_poDefncxx . . $ OGRGenSQLResultsLayer#m_poDefn.; |
| 2084 | } |
| 2085 | |
| 2086 | /************************************************************************/ |
| 2087 | /* FreeIndexFields() */ |
| 2088 | /************************************************************************/ |
| 2089 | |
| 2090 | void OGRGenSQLResultsLayercxx . . $ OGRGenSQLResultsLayer#::FreeIndexFieldscxx . . $ OGRGenSQLResultsLayer#FreeIndexFields(b118ecfffb1759e4).(OGRField *pasIndexFields, |
| 2091 | size_t l_nIndexSize) |
| 2092 | { |
| 2093 | swq_selectcxx . . $ swq_select# *psSelectInfo = m_pSelectInfocxx . . $ OGRGenSQLResultsLayer#m_pSelectInfo..get(); |
| 2094 | const int nOrderItems = psSelectInfo->order_specscxx . . $ swq_select#order_specs.; |
| 2095 | |
| 2096 | /* -------------------------------------------------------------------- */ |
| 2097 | /* Free the key field values. */ |
| 2098 | /* -------------------------------------------------------------------- */ |
| 2099 | for (int iKey = 0; iKey < nOrderItems; iKey++) |
| 2100 | { |
| 2101 | swq_order_defcxx . . $ swq_order_def# *psKeyDef = psSelectInfo->order_defscxx . . $ swq_select#order_defs. + iKey; |
| 2102 | |
| 2103 | if (psKeyDef->field_indexcxx . . $ $anonymous_type_a69ae1a4ba3d583e_7#field_index. >= m_iFIDFieldIndexcxx . . $ OGRGenSQLResultsLayer#m_iFIDFieldIndex.) |
| 2104 | { |
| 2105 | CPLAssertcxx . . $ `port/cpl_error.h:353:9`!(psKeyDef->field_index < |
| 2106 | m_iFIDFieldIndex + SPECIAL_FIELD_COUNT); |
| 2107 | /* warning: only special fields of type string should be deallocated |
| 2108 | */ |
| 2109 | if (SpecialFieldTypescxx . . $ SpecialFieldTypes.[psKeyDef->field_indexcxx . . $ $anonymous_type_a69ae1a4ba3d583e_7#field_index. - m_iFIDFieldIndexcxx . . $ OGRGenSQLResultsLayer#m_iFIDFieldIndex.] == |
| 2110 | SWQ_STRINGcxx . . $ SWQ_STRING.) |
| 2111 | { |
| 2112 | for (size_t i = 0; i < l_nIndexSize; i++) |
| 2113 | { |
| 2114 | OGRField *psField = pasIndexFields + iKey + i * nOrderItems; |
| 2115 | CPLFreecxx . . $ `port/cpl_conv.h:97:9`!(psField->String); |
| 2116 | } |
| 2117 | } |
| 2118 | continue; |
| 2119 | } |
| 2120 | |
| 2121 | OGRFieldDefncxx . . $ OGRFieldDefn# *poFDefn = |
| 2122 | m_poSrcLayercxx . . $ OGRGenSQLResultsLayer#m_poSrcLayer.->GetLayerDefncxx . . $ OGRLayer#GetLayerDefn(407fccde18759965).()->GetFieldDefncxx . . $ OGRFeatureDefn#GetFieldDefn(2ec36f91b6ceefc7).(psKeyDef->field_indexcxx . . $ $anonymous_type_a69ae1a4ba3d583e_7#field_index.); |
| 2123 | |
| 2124 | if (poFDefn->GetTypecxx . . $ OGRFieldDefn#GetType(b365ab774e05458e).() == OFTString) |
| 2125 | { |
| 2126 | for (size_t i = 0; i < l_nIndexSize; i++) |
| 2127 | { |
| 2128 | OGRField *psField = pasIndexFields + iKey + i * nOrderItems; |
| 2129 | |
| 2130 | if (!OGR_RawField_IsUnset(psField) && |
| 2131 | !OGR_RawField_IsNull(psField)) |
| 2132 | CPLFreecxx . . $ `port/cpl_conv.h:97:9`!(psField->String); |
| 2133 | } |
| 2134 | } |
| 2135 | } |
| 2136 | } |
| 2137 | |
| 2138 | /************************************************************************/ |
| 2139 | /* ReadIndexFields() */ |
| 2140 | /************************************************************************/ |
| 2141 | |
| 2142 | void OGRGenSQLResultsLayercxx . . $ OGRGenSQLResultsLayer#::ReadIndexFieldscxx . . $ OGRGenSQLResultsLayer#ReadIndexFields(6a4a57c95f072e40).(OGRFeaturecxx . . $ OGRFeature# *poSrcFeat, |
| 2143 | int nOrderItems, |
| 2144 | OGRField *pasIndexFields) |
| 2145 | { |
| 2146 | swq_selectcxx . . $ swq_select# *psSelectInfo = m_pSelectInfocxx . . $ OGRGenSQLResultsLayer#m_pSelectInfo..get(); |
| 2147 | for (int iKey = 0; iKey < nOrderItems; iKey++) |
| 2148 | { |
| 2149 | const swq_order_defcxx . . $ swq_order_def# *psKeyDef = psSelectInfo->order_defscxx . . $ swq_select#order_defs. + iKey; |
| 2150 | OGRField *psDstField = pasIndexFields + iKey; |
| 2151 | |
| 2152 | if (psKeyDef->field_indexcxx . . $ $anonymous_type_a69ae1a4ba3d583e_7#field_index. >= m_iFIDFieldIndexcxx . . $ OGRGenSQLResultsLayer#m_iFIDFieldIndex.) |
| 2153 | { |
| 2154 | CPLAssertcxx . . $ `port/cpl_error.h:353:9`!(psKeyDef->field_index < |
| 2155 | m_iFIDFieldIndex + SPECIAL_FIELD_COUNT); |
| 2156 | |
| 2157 | switch (SpecialFieldTypescxx . . $ SpecialFieldTypes.[psKeyDef->field_indexcxx . . $ $anonymous_type_a69ae1a4ba3d583e_7#field_index. - m_iFIDFieldIndexcxx . . $ OGRGenSQLResultsLayer#m_iFIDFieldIndex.]) |
| 2158 | { |
| 2159 | case SWQ_INTEGERcxx . . $ SWQ_INTEGER.: |
| 2160 | case SWQ_INTEGER64cxx . . $ SWQ_INTEGER64.: |
| 2161 | // Yes, store Integer as Integer64. |
| 2162 | // This is consistent with the test in Compare() |
| 2163 | psDstField->Integer64 = |
| 2164 | poSrcFeat->GetFieldAsInteger64cxx . . $ OGRFeature#GetFieldAsInteger64(f3f16611d465c84c).(psKeyDef->field_indexcxx . . $ $anonymous_type_a69ae1a4ba3d583e_7#field_index.); |
| 2165 | break; |
| 2166 | |
| 2167 | case SWQ_FLOATcxx . . $ SWQ_FLOAT.: |
| 2168 | psDstField->Real = |
| 2169 | poSrcFeat->GetFieldAsDoublecxx . . $ OGRFeature#GetFieldAsDouble(8bbae5fb2e9ef7ac).(psKeyDef->field_indexcxx . . $ $anonymous_type_a69ae1a4ba3d583e_7#field_index.); |
| 2170 | break; |
| 2171 | |
| 2172 | default: |
| 2173 | psDstField->String = CPLStrdup( |
| 2174 | poSrcFeat->GetFieldAsStringcxx . . $ OGRFeature#GetFieldAsString(afbf07f2bc1a9437).(psKeyDef->field_indexcxx . . $ $anonymous_type_a69ae1a4ba3d583e_7#field_index.)); |
| 2175 | break; |
| 2176 | } |
| 2177 | |
| 2178 | continue; |
| 2179 | } |
| 2180 | |
| 2181 | OGRFieldDefncxx . . $ OGRFieldDefn# *poFDefn = |
| 2182 | m_poSrcLayercxx . . $ OGRGenSQLResultsLayer#m_poSrcLayer.->GetLayerDefncxx . . $ OGRLayer#GetLayerDefn(407fccde18759965).()->GetFieldDefncxx . . $ OGRFeatureDefn#GetFieldDefn(2ec36f91b6ceefc7).(psKeyDef->field_indexcxx . . $ $anonymous_type_a69ae1a4ba3d583e_7#field_index.); |
| 2183 | |
| 2184 | OGRField *psSrcField = poSrcFeat->GetRawFieldRefcxx . . $ OGRFeature#GetRawFieldRef(4f12117e0ec8b5e4).(psKeyDef->field_indexcxx . . $ $anonymous_type_a69ae1a4ba3d583e_7#field_index.); |
| 2185 | |
| 2186 | if (poFDefn->GetTypecxx . . $ OGRFieldDefn#GetType(b365ab774e05458e).() == OFTInteger || |
| 2187 | poFDefn->GetTypecxx . . $ OGRFieldDefn#GetType(b365ab774e05458e).() == OFTInteger64 || |
| 2188 | poFDefn->GetTypecxx . . $ OGRFieldDefn#GetType(b365ab774e05458e).() == OFTReal || poFDefn->GetTypecxx . . $ OGRFieldDefn#GetType(b365ab774e05458e).() == OFTDate || |
| 2189 | poFDefn->GetTypecxx . . $ OGRFieldDefn#GetType(b365ab774e05458e).() == OFTTime || poFDefn->GetTypecxx . . $ OGRFieldDefn#GetType(b365ab774e05458e).() == OFTDateTime) |
| 2190 | memcpy(psDstField, psSrcField, sizeof(OGRField)); |
| 2191 | else if (poFDefn->GetTypecxx . . $ OGRFieldDefn#GetType(b365ab774e05458e).() == OFTString) |
| 2192 | { |
| 2193 | if (poSrcFeat->IsFieldSetAndNotNullcxx . . $ OGRFeature#IsFieldSetAndNotNull(4a668f6de69bf818).(psKeyDef->field_indexcxx . . $ $anonymous_type_a69ae1a4ba3d583e_7#field_index.)) |
| 2194 | psDstField->String = CPLStrdup(psSrcField->String); |
| 2195 | else |
| 2196 | memcpy(psDstField, psSrcField, sizeof(OGRField)); |
| 2197 | } |
| 2198 | } |
| 2199 | } |
| 2200 | |
| 2201 | /************************************************************************/ |
| 2202 | /* CreateOrderByIndex() */ |
| 2203 | /* */ |
| 2204 | /* This method is responsible for creating an index providing */ |
| 2205 | /* ordered access to the features according to the supplied */ |
| 2206 | /* ORDER BY clauses. */ |
| 2207 | /* */ |
| 2208 | /* This is accomplished by making one pass through all the */ |
| 2209 | /* eligible source features, and capturing the order by fields */ |
| 2210 | /* of all records in memory. A quick sort is then applied to */ |
| 2211 | /* this in memory copy of the order-by fields to create the */ |
| 2212 | /* required index. */ |
| 2213 | /* */ |
| 2214 | /* Keeping all the key values in memory will *not* scale up to */ |
| 2215 | /* very large input datasets. */ |
| 2216 | /************************************************************************/ |
| 2217 | |
| 2218 | void OGRGenSQLResultsLayercxx . . $ OGRGenSQLResultsLayer#::CreateOrderByIndexcxx . . $ OGRGenSQLResultsLayer#CreateOrderByIndex(49f6e7a06ebc5aa8).() |
| 2219 | |
| 2220 | { |
| 2221 | swq_selectcxx . . $ swq_select# *psSelectInfo = m_pSelectInfocxx . . $ OGRGenSQLResultsLayer#m_pSelectInfo..get(); |
| 2222 | const int nOrderItems = psSelectInfo->order_specscxx . . $ swq_select#order_specs.; |
| 2223 | |
| 2224 | if (!(nOrderItems > 0 && psSelectInfo->query_modecxx . . $ swq_select#query_mode. == SWQM_RECORDSETcxx . . $ `ogr/ogr_swq.h:321:9`!)) |
| 2225 | return; |
| 2226 | |
| 2227 | if (m_bOrderByValidcxx . . $ OGRGenSQLResultsLayer#m_bOrderByValid.) |
| 2228 | return; |
| 2229 | |
| 2230 | m_bOrderByValidcxx . . $ OGRGenSQLResultsLayer#m_bOrderByValid. = true; |
| 2231 | m_anFIDIndexcxx . . $ OGRGenSQLResultsLayer#m_anFIDIndex..clear(); |
| 2232 | |
| 2233 | ResetReadingcxx . . $ OGRGenSQLResultsLayer#ResetReading(49f6e7a06ebc5aa8).(); |
| 2234 | |
| 2235 | /* -------------------------------------------------------------------- */ |
| 2236 | /* Optimize (memory-wise) ORDER BY ... LIMIT 1 [OFFSET 0] case. */ |
| 2237 | /* -------------------------------------------------------------------- */ |
| 2238 | if (psSelectInfo->offsetcxx . . $ swq_select#offset. == 0 && psSelectInfo->limitcxx . . $ swq_select#limit. == 1) |
| 2239 | { |
| 2240 | stdcxx . . $ std/::vector<OGRField> asCurrentFields(nOrderItems); |
| 2241 | stdcxx . . $ std/::vector<OGRField> asBestFields(nOrderItems); |
| 2242 | memset(asCurrentFields.data(), 0, sizeof(OGRField) * nOrderItems); |
| 2243 | memset(asBestFields.data(), 0, sizeof(OGRField) * nOrderItems); |
| 2244 | bool bFoundSrcFeature = false; |
| 2245 | GIntBigcxx . . $ GIntBig# nBestFID = 0; |
| 2246 | for (auto &&poSrcFeat : *m_poSrcLayercxx . . $ OGRGenSQLResultsLayer#m_poSrcLayer.) |
| 2247 | { |
| 2248 | ReadIndexFieldscxx . . $ OGRGenSQLResultsLayer#ReadIndexFields(6a4a57c95f072e40).(poSrcFeat.get(), nOrderItems, |
| 2249 | asCurrentFields.data()); |
| 2250 | if (!bFoundSrcFeature || |
| 2251 | Comparecxx . . $ OGRGenSQLResultsLayer#Compare(7c83fe7b3fd17983).(asCurrentFields.data(), asBestFields.data()) < 0) |
| 2252 | { |
| 2253 | bFoundSrcFeature = true; |
| 2254 | nBestFID = poSrcFeat->GetFIDcxx . . $ OGRFeature#GetFID(98833e9ab7de59a4).(); |
| 2255 | FreeIndexFieldscxx . . $ OGRGenSQLResultsLayer#FreeIndexFields(b118ecfffb1759e4).(asBestFields.data(), 1); |
| 2256 | memcpy(asBestFields.data(), asCurrentFields.data(), |
| 2257 | sizeof(OGRField) * nOrderItems); |
| 2258 | } |
| 2259 | else |
| 2260 | { |
| 2261 | FreeIndexFieldscxx . . $ OGRGenSQLResultsLayer#FreeIndexFields(b118ecfffb1759e4).(asCurrentFields.data(), 1); |
| 2262 | } |
| 2263 | memset(asCurrentFields.data(), 0, sizeof(OGRField) * nOrderItems); |
| 2264 | } |
| 2265 | FreeIndexFieldscxx . . $ OGRGenSQLResultsLayer#FreeIndexFields(b118ecfffb1759e4).(asBestFields.data(), 1); |
| 2266 | |
| 2267 | if (bFoundSrcFeature) |
| 2268 | { |
| 2269 | m_anFIDIndexcxx . . $ OGRGenSQLResultsLayer#m_anFIDIndex..resize(1); |
| 2270 | m_anFIDIndexcxx . . $ OGRGenSQLResultsLayer#m_anFIDIndex.[0] = nBestFID; |
| 2271 | } |
| 2272 | return; |
| 2273 | } |
| 2274 | |
| 2275 | /* -------------------------------------------------------------------- */ |
| 2276 | /* Allocate set of key values, and the output index. */ |
| 2277 | /* -------------------------------------------------------------------- */ |
| 2278 | size_t nFeaturesAlloc = 100; |
| 2279 | size_t nIndexSize = 0; |
| 2280 | stdcxx . . $ std/::vector<OGRField> asIndexFields(nOrderItems * nFeaturesAlloc); |
| 2281 | memset(asIndexFields.data(), 0, |
| 2282 | sizeof(OGRField) * nOrderItems * nFeaturesAlloc); |
| 2283 | stdcxx . . $ std/::vector<GIntBigcxx . . $ GIntBig#> anFIDList; |
| 2284 | |
| 2285 | // Frees nIndexSize rows of asIndexFields |
| 2286 | struct IndexFieldsFreercxx . . $ OGRGenSQLResultsLayer#CreateOrderByIndex(49f6e7a06ebc5aa8).IndexFieldsFreer# |
| 2287 | { |
| 2288 | OGRGenSQLResultsLayercxx . . $ OGRGenSQLResultsLayer# &m_oLayercxx . . $ OGRGenSQLResultsLayer#CreateOrderByIndex(49f6e7a06ebc5aa8).IndexFieldsFreer#m_oLayer.; |
| 2289 | stdcxx . . $ std/::vector<OGRField> &m_asIndexFieldscxx . . $ OGRGenSQLResultsLayer#CreateOrderByIndex(49f6e7a06ebc5aa8).IndexFieldsFreer#m_asIndexFields.; |
| 2290 | size_t &m_nIndexSizecxx . . $ OGRGenSQLResultsLayer#CreateOrderByIndex(49f6e7a06ebc5aa8).IndexFieldsFreer#m_nIndexSize.; |
| 2291 | |
| 2292 | IndexFieldsFreercxx . . $ OGRGenSQLResultsLayer#CreateOrderByIndex(49f6e7a06ebc5aa8).IndexFieldsFreer#IndexFieldsFreer(f3b24507d374c4e8).(OGRGenSQLResultsLayercxx . . $ OGRGenSQLResultsLayer# &poLayerIn, |
| 2293 | stdcxx . . $ std/::vector<OGRField> &asIndexFieldsIn, |
| 2294 | size_t &nIndexSizeIn) |
| 2295 | : m_oLayercxx . . $ OGRGenSQLResultsLayer#CreateOrderByIndex(49f6e7a06ebc5aa8).IndexFieldsFreer#m_oLayer.(poLayerIn), m_asIndexFieldscxx . . $ OGRGenSQLResultsLayer#CreateOrderByIndex(49f6e7a06ebc5aa8).IndexFieldsFreer#m_asIndexFields.(asIndexFieldsIn), |
| 2296 | m_nIndexSizecxx . . $ OGRGenSQLResultsLayer#CreateOrderByIndex(49f6e7a06ebc5aa8).IndexFieldsFreer#m_nIndexSize.(nIndexSizeIn) |
| 2297 | { |
| 2298 | } |
| 2299 | |
| 2300 | ~cxx . . $ OGRGenSQLResultsLayer#CreateOrderByIndex(49f6e7a06ebc5aa8).IndexFieldsFreer#`~IndexFieldsFreer`(ced63f7c635d850d).IndexFieldsFreercxx . . $ OGRGenSQLResultsLayer#CreateOrderByIndex(49f6e7a06ebc5aa8).IndexFieldsFreer#() |
| 2301 | { |
| 2302 | m_oLayercxx . . $ OGRGenSQLResultsLayer#CreateOrderByIndex(49f6e7a06ebc5aa8).IndexFieldsFreer#m_oLayer..FreeIndexFieldscxx . . $ OGRGenSQLResultsLayer#FreeIndexFields(b118ecfffb1759e4).(m_asIndexFieldscxx . . $ OGRGenSQLResultsLayer#CreateOrderByIndex(49f6e7a06ebc5aa8).IndexFieldsFreer#m_asIndexFields..data(), m_nIndexSizecxx . . $ OGRGenSQLResultsLayer#CreateOrderByIndex(49f6e7a06ebc5aa8).IndexFieldsFreer#m_nIndexSize.); |
| 2303 | } |
| 2304 | |
| 2305 | IndexFieldsFreercxx . . $ OGRGenSQLResultsLayer#CreateOrderByIndex(49f6e7a06ebc5aa8).IndexFieldsFreer#IndexFieldsFreer(ea0dd3c4536bc0b1).(const IndexFieldsFreercxx . . $ OGRGenSQLResultsLayer#CreateOrderByIndex(49f6e7a06ebc5aa8).IndexFieldsFreer# &) = delete; |
| 2306 | IndexFieldsFreercxx . . $ OGRGenSQLResultsLayer#CreateOrderByIndex(49f6e7a06ebc5aa8).IndexFieldsFreer# &operatorcxx . . $ OGRGenSQLResultsLayer#CreateOrderByIndex(49f6e7a06ebc5aa8).IndexFieldsFreer#`operator=`(f8234f2e2e66bae6).=(const IndexFieldsFreercxx . . $ OGRGenSQLResultsLayer#CreateOrderByIndex(49f6e7a06ebc5aa8).IndexFieldsFreer# &) = delete; |
| 2307 | }; |
| 2308 | |
| 2309 | IndexFieldsFreercxx . . $ OGRGenSQLResultsLayer#CreateOrderByIndex(49f6e7a06ebc5aa8).IndexFieldsFreer# oIndexFieldsFreercxx . . $ OGRGenSQLResultsLayer#CreateOrderByIndex(49f6e7a06ebc5aa8).IndexFieldsFreer#IndexFieldsFreer(f3b24507d374c4e8).(*this, asIndexFields, nIndexSize); |
| 2310 | |
| 2311 | /* -------------------------------------------------------------------- */ |
| 2312 | /* Read in all the key values. */ |
| 2313 | /* -------------------------------------------------------------------- */ |
| 2314 | |
| 2315 | for (auto &&poSrcFeat : *m_poSrcLayercxx . . $ OGRGenSQLResultsLayer#m_poSrcLayer.) |
| 2316 | { |
| 2317 | if (nIndexSize == nFeaturesAlloc) |
| 2318 | { |
| 2319 | const uint64_tcxx . . $ uint64_t# nNewFeaturesAlloc64 = |
| 2320 | static_cast<uint64_tcxx . . $ uint64_t#>(nFeaturesAlloc) + nFeaturesAlloc / 3; |
| 2321 | #if SIZEOF_SIZE_Tcxx . . $ `build/port/cpl_config.h:25:9`! == 4 |
| 2322 | if (static_cast<size_t>(nNewFeaturesAlloc64) != |
| 2323 | nNewFeaturesAlloc64 || |
| 2324 | static_cast<size_t>(sizeof(OGRField) * nOrderItems * |
| 2325 | nNewFeaturesAlloc64) != |
| 2326 | static_cast<uint64_t>(sizeof(OGRField)) * nOrderItems * |
| 2327 | nNewFeaturesAlloc64) |
| 2328 | { |
| 2329 | CPLError(CE_Failure, CPLE_AppDefined, |
| 2330 | "Cannot allocate pasIndexFields"); |
| 2331 | return; |
| 2332 | } |
| 2333 | #endif |
| 2334 | const size_t nNewFeaturesAlloc = |
| 2335 | static_cast<size_t>(nNewFeaturesAlloc64); |
| 2336 | |
| 2337 | try |
| 2338 | { |
| 2339 | asIndexFields.resize(nOrderItems * nNewFeaturesAlloc); |
| 2340 | anFIDList.reserve(nNewFeaturesAlloc); |
| 2341 | } |
| 2342 | catch (const stdcxx . . $ std/::bad_alloc &) |
| 2343 | { |
| 2344 | CPLError(CE_Failure, CPLE_OutOfMemorycxx . . $ `port/cpl_error.h:110:9`!, |
| 2345 | "CreateOrderByIndex(): out of memory"); |
| 2346 | return; |
| 2347 | } |
| 2348 | |
| 2349 | memset(asIndexFields.data() + nFeaturesAlloc * nOrderItems, 0, |
| 2350 | sizeof(OGRField) * nOrderItems * |
| 2351 | (nNewFeaturesAlloc - nFeaturesAlloc)); |
| 2352 | |
| 2353 | nFeaturesAlloc = nNewFeaturesAlloc; |
| 2354 | } |
| 2355 | |
| 2356 | ReadIndexFieldscxx . . $ OGRGenSQLResultsLayer#ReadIndexFields(6a4a57c95f072e40).(poSrcFeat.get(), nOrderItems, |
| 2357 | asIndexFields.data() + nIndexSize * nOrderItems); |
| 2358 | |
| 2359 | anFIDList.push_back(poSrcFeat->GetFIDcxx . . $ OGRFeature#GetFID(98833e9ab7de59a4).()); |
| 2360 | |
| 2361 | nIndexSize++; |
| 2362 | } |
| 2363 | |
| 2364 | // CPLDebug("GenSQL", "CreateOrderByIndex() = %zu features", nIndexSize); |
| 2365 | |
| 2366 | /* -------------------------------------------------------------------- */ |
| 2367 | /* Initialize m_anFIDIndex */ |
| 2368 | /* -------------------------------------------------------------------- */ |
| 2369 | try |
| 2370 | { |
| 2371 | m_anFIDIndexcxx . . $ OGRGenSQLResultsLayer#m_anFIDIndex..reserve(nIndexSize); |
| 2372 | } |
| 2373 | catch (const stdcxx . . $ std/::bad_alloc &) |
| 2374 | { |
| 2375 | CPLError(CE_Failure, CPLE_OutOfMemorycxx . . $ `port/cpl_error.h:110:9`!, |
| 2376 | "CreateOrderByIndex(): out of memory"); |
| 2377 | return; |
| 2378 | } |
| 2379 | for (size_t i = 0; i < nIndexSize; i++) |
| 2380 | m_anFIDIndexcxx . . $ OGRGenSQLResultsLayer#m_anFIDIndex..push_back(static_cast<GIntBigcxx . . $ GIntBig#>(i)); |
| 2381 | |
| 2382 | /* -------------------------------------------------------------------- */ |
| 2383 | /* Quick sort the records. */ |
| 2384 | /* -------------------------------------------------------------------- */ |
| 2385 | |
| 2386 | GIntBigcxx . . $ GIntBig# *panMerged = static_cast<GIntBigcxx . . $ GIntBig# *>( |
| 2387 | VSI_MALLOC_VERBOSEcxx . . $ `port/cpl_vsi.h:375:9`!(sizeof(GIntBig) * nIndexSize)); |
| 2388 | if (panMerged == nullptr) |
| 2389 | { |
| 2390 | m_anFIDIndexcxx . . $ OGRGenSQLResultsLayer#m_anFIDIndex..clear(); |
| 2391 | return; |
| 2392 | } |
| 2393 | |
| 2394 | // Note: this merge sort is slightly faster than std::sort() |
| 2395 | SortIndexSectioncxx . . $ OGRGenSQLResultsLayer#SortIndexSection(a68882c60e1b3453).(asIndexFields.data(), panMerged, 0, nIndexSize); |
| 2396 | VSIFree(panMerged); |
| 2397 | |
| 2398 | /* -------------------------------------------------------------------- */ |
| 2399 | /* Rework the FID map to map to real FIDs. */ |
| 2400 | /* -------------------------------------------------------------------- */ |
| 2401 | bool bAlreadySorted = true; |
| 2402 | for (size_t i = 0; i < nIndexSize; i++) |
| 2403 | { |
| 2404 | if (m_anFIDIndexcxx . . $ OGRGenSQLResultsLayer#m_anFIDIndex.[i] != static_cast<GIntBigcxx . . $ GIntBig#>(i)) |
| 2405 | bAlreadySorted = false; |
| 2406 | m_anFIDIndexcxx . . $ OGRGenSQLResultsLayer#m_anFIDIndex.[i] = anFIDList[static_cast<size_t>(m_anFIDIndexcxx . . $ OGRGenSQLResultsLayer#m_anFIDIndex.[i])]; |
| 2407 | } |
| 2408 | |
| 2409 | /* If it is already sorted, then free than m_anFIDIndex array */ |
| 2410 | /* so that GetNextFeature() can call a sequential GetNextFeature() */ |
| 2411 | /* on the source array. Very useful for layers where random access */ |
| 2412 | /* is slow. */ |
| 2413 | /* Use case: the GML result of a WFS GetFeature with a SORTBY */ |
| 2414 | if (bAlreadySorted) |
| 2415 | { |
| 2416 | m_anFIDIndexcxx . . $ OGRGenSQLResultsLayer#m_anFIDIndex..clear(); |
| 2417 | } |
| 2418 | |
| 2419 | ResetReadingcxx . . $ OGRGenSQLResultsLayer#ResetReading(49f6e7a06ebc5aa8).(); |
| 2420 | } |
| 2421 | |
| 2422 | /************************************************************************/ |
| 2423 | /* SortIndexSection() */ |
| 2424 | /* */ |
| 2425 | /* Sort the records in a section of the index. */ |
| 2426 | /************************************************************************/ |
| 2427 | |
| 2428 | void OGRGenSQLResultsLayercxx . . $ OGRGenSQLResultsLayer#::SortIndexSectioncxx . . $ OGRGenSQLResultsLayer#SortIndexSection(a68882c60e1b3453).(const OGRField *pasIndexFields, |
| 2429 | GIntBigcxx . . $ GIntBig# *panMerged, size_t nStart, |
| 2430 | size_t nEntries) |
| 2431 | |
| 2432 | { |
| 2433 | if (nEntries < 2) |
| 2434 | return; |
| 2435 | |
| 2436 | swq_selectcxx . . $ swq_select# *psSelectInfo = m_pSelectInfocxx . . $ OGRGenSQLResultsLayer#m_pSelectInfo..get(); |
| 2437 | const int nOrderItems = psSelectInfo->order_specscxx . . $ swq_select#order_specs.; |
| 2438 | |
| 2439 | size_t nFirstGroup = nEntries / 2; |
| 2440 | size_t nFirstStart = nStart; |
| 2441 | size_t nSecondGroup = nEntries - nFirstGroup; |
| 2442 | size_t nSecondStart = nStart + nFirstGroup; |
| 2443 | |
| 2444 | SortIndexSectioncxx . . $ OGRGenSQLResultsLayer#SortIndexSection(a68882c60e1b3453).(pasIndexFields, panMerged, nFirstStart, nFirstGroup); |
| 2445 | SortIndexSectioncxx . . $ OGRGenSQLResultsLayer#SortIndexSection(a68882c60e1b3453).(pasIndexFields, panMerged, nSecondStart, nSecondGroup); |
| 2446 | |
| 2447 | for (size_t iMerge = 0; iMerge < nEntries; ++iMerge) |
| 2448 | { |
| 2449 | int nResult = 0; |
| 2450 | |
| 2451 | if (nFirstGroup == 0) |
| 2452 | nResult = 1; |
| 2453 | else if (nSecondGroup == 0) |
| 2454 | nResult = -1; |
| 2455 | else |
| 2456 | nResult = Comparecxx . . $ OGRGenSQLResultsLayer#Compare(7c83fe7b3fd17983).( |
| 2457 | pasIndexFields + m_anFIDIndexcxx . . $ OGRGenSQLResultsLayer#m_anFIDIndex.[nFirstStart] * nOrderItems, |
| 2458 | pasIndexFields + m_anFIDIndexcxx . . $ OGRGenSQLResultsLayer#m_anFIDIndex.[nSecondStart] * nOrderItems); |
| 2459 | |
| 2460 | if (nResult > 0) |
| 2461 | { |
| 2462 | panMerged[iMerge] = m_anFIDIndexcxx . . $ OGRGenSQLResultsLayer#m_anFIDIndex.[nSecondStart]; |
| 2463 | nSecondStart++; |
| 2464 | nSecondGroup--; |
| 2465 | } |
| 2466 | else |
| 2467 | { |
| 2468 | panMerged[iMerge] = m_anFIDIndexcxx . . $ OGRGenSQLResultsLayer#m_anFIDIndex.[nFirstStart]; |
| 2469 | nFirstStart++; |
| 2470 | nFirstGroup--; |
| 2471 | } |
| 2472 | } |
| 2473 | |
| 2474 | /* Copy the merge list back into the main index */ |
| 2475 | memcpy(m_anFIDIndexcxx . . $ OGRGenSQLResultsLayer#m_anFIDIndex..data() + nStart, panMerged, sizeof(GIntBigcxx . . $ GIntBig#) * nEntries); |
| 2476 | } |
| 2477 | |
| 2478 | /************************************************************************/ |
| 2479 | /* ComparePrimitive() */ |
| 2480 | /************************************************************************/ |
| 2481 | |
| 2482 | template <class T> static inline int ComparePrimitivecxx . . $ ComparePrimitive(cdccdbf8e8c94f68).(const T &a, const T &b) |
| 2483 | { |
| 2484 | if (a < b) |
| 2485 | return -1; |
| 2486 | if (a > b) |
| 2487 | return 1; |
| 2488 | return 0; |
| 2489 | } |
| 2490 | |
| 2491 | /************************************************************************/ |
| 2492 | /* Compare() */ |
| 2493 | /************************************************************************/ |
| 2494 | |
| 2495 | int OGRGenSQLResultsLayercxx . . $ OGRGenSQLResultsLayer#::Comparecxx . . $ OGRGenSQLResultsLayer#Compare(7c83fe7b3fd17983).(const OGRField *pasFirstTuple, |
| 2496 | const OGRField *pasSecondTuple) |
| 2497 | |
| 2498 | { |
| 2499 | swq_selectcxx . . $ swq_select# *psSelectInfo = m_pSelectInfocxx . . $ OGRGenSQLResultsLayer#m_pSelectInfo..get(); |
| 2500 | int nResult = 0, iKey; |
| 2501 | |
| 2502 | for (iKey = 0; nResult == 0 && iKey < psSelectInfo->order_specscxx . . $ swq_select#order_specs.; iKey++) |
| 2503 | { |
| 2504 | swq_order_defcxx . . $ swq_order_def# *psKeyDef = psSelectInfo->order_defscxx . . $ swq_select#order_defs. + iKey; |
| 2505 | OGRFieldDefncxx . . $ OGRFieldDefn# *poFDefn = nullptr; |
| 2506 | |
| 2507 | if (psKeyDef->field_indexcxx . . $ $anonymous_type_a69ae1a4ba3d583e_7#field_index. >= m_iFIDFieldIndexcxx . . $ OGRGenSQLResultsLayer#m_iFIDFieldIndex.) |
| 2508 | poFDefn = nullptr; |
| 2509 | else |
| 2510 | poFDefn = m_poSrcLayercxx . . $ OGRGenSQLResultsLayer#m_poSrcLayer.->GetLayerDefncxx . . $ OGRLayer#GetLayerDefn(407fccde18759965).()->GetFieldDefncxx . . $ OGRFeatureDefn#GetFieldDefn(2ec36f91b6ceefc7).( |
| 2511 | psKeyDef->field_indexcxx . . $ $anonymous_type_a69ae1a4ba3d583e_7#field_index.); |
| 2512 | |
| 2513 | if (OGR_RawField_IsUnset(&pasFirstTuple[iKey]) || |
| 2514 | OGR_RawField_IsNull(&pasFirstTuple[iKey])) |
| 2515 | { |
| 2516 | if (OGR_RawField_IsUnset(&pasSecondTuple[iKey]) || |
| 2517 | OGR_RawField_IsNull(&pasSecondTuple[iKey])) |
| 2518 | nResult = 0; |
| 2519 | else |
| 2520 | nResult = -1; |
| 2521 | } |
| 2522 | else if (OGR_RawField_IsUnset(&pasSecondTuple[iKey]) || |
| 2523 | OGR_RawField_IsNull(&pasSecondTuple[iKey])) |
| 2524 | { |
| 2525 | nResult = 1; |
| 2526 | } |
| 2527 | else if (poFDefn == nullptr) |
| 2528 | { |
| 2529 | CPLAssertcxx . . $ `port/cpl_error.h:353:9`!(psKeyDef->field_index < |
| 2530 | m_iFIDFieldIndex + SPECIAL_FIELD_COUNT); |
| 2531 | switch (SpecialFieldTypescxx . . $ SpecialFieldTypes.[psKeyDef->field_indexcxx . . $ $anonymous_type_a69ae1a4ba3d583e_7#field_index. - m_iFIDFieldIndexcxx . . $ OGRGenSQLResultsLayer#m_iFIDFieldIndex.]) |
| 2532 | { |
| 2533 | case SWQ_INTEGERcxx . . $ SWQ_INTEGER.: |
| 2534 | // Yes, read Integer in Integer64. |
| 2535 | // This is consistent with what is done ReadIndexFields() |
| 2536 | case SWQ_INTEGER64cxx . . $ SWQ_INTEGER64.: |
| 2537 | nResult = ComparePrimitivecxx . . $ ComparePrimitive(cdccdbf8e8c94f68).(pasFirstTuple[iKey].Integer64, |
| 2538 | pasSecondTuple[iKey].Integer64); |
| 2539 | break; |
| 2540 | case SWQ_FLOATcxx . . $ SWQ_FLOAT.: |
| 2541 | nResult = ComparePrimitivecxx . . $ ComparePrimitive(cdccdbf8e8c94f68).(pasFirstTuple[iKey].Real, |
| 2542 | pasSecondTuple[iKey].Real); |
| 2543 | break; |
| 2544 | case SWQ_STRINGcxx . . $ SWQ_STRING.: |
| 2545 | nResult = strcmp(pasFirstTuple[iKey].String, |
| 2546 | pasSecondTuple[iKey].String); |
| 2547 | break; |
| 2548 | |
| 2549 | default: |
| 2550 | CPLAssertcxx . . $ `port/cpl_error.h:353:9`!(false); |
| 2551 | nResult = 0; |
| 2552 | } |
| 2553 | } |
| 2554 | else if (poFDefn->GetTypecxx . . $ OGRFieldDefn#GetType(b365ab774e05458e).() == OFTInteger) |
| 2555 | { |
| 2556 | nResult = ComparePrimitivecxx . . $ ComparePrimitive(cdccdbf8e8c94f68).(pasFirstTuple[iKey].Integer, |
| 2557 | pasSecondTuple[iKey].Integer); |
| 2558 | } |
| 2559 | else if (poFDefn->GetTypecxx . . $ OGRFieldDefn#GetType(b365ab774e05458e).() == OFTInteger64) |
| 2560 | { |
| 2561 | nResult = ComparePrimitivecxx . . $ ComparePrimitive(cdccdbf8e8c94f68).(pasFirstTuple[iKey].Integer64, |
| 2562 | pasSecondTuple[iKey].Integer64); |
| 2563 | } |
| 2564 | else if (poFDefn->GetTypecxx . . $ OGRFieldDefn#GetType(b365ab774e05458e).() == OFTString) |
| 2565 | { |
| 2566 | nResult = |
| 2567 | strcmp(pasFirstTuple[iKey].String, pasSecondTuple[iKey].String); |
| 2568 | } |
| 2569 | else if (poFDefn->GetTypecxx . . $ OGRFieldDefn#GetType(b365ab774e05458e).() == OFTReal) |
| 2570 | { |
| 2571 | nResult = ComparePrimitivecxx . . $ ComparePrimitive(cdccdbf8e8c94f68).(pasFirstTuple[iKey].Real, |
| 2572 | pasSecondTuple[iKey].Real); |
| 2573 | } |
| 2574 | else if (poFDefn->GetTypecxx . . $ OGRFieldDefn#GetType(b365ab774e05458e).() == OFTDate || |
| 2575 | poFDefn->GetTypecxx . . $ OGRFieldDefn#GetType(b365ab774e05458e).() == OFTTime || |
| 2576 | poFDefn->GetTypecxx . . $ OGRFieldDefn#GetType(b365ab774e05458e).() == OFTDateTime) |
| 2577 | { |
| 2578 | nResult = |
| 2579 | OGRCompareDatecxx . . $ OGRCompareDate(7c83fe7b3fd17983).(&pasFirstTuple[iKey], &pasSecondTuple[iKey]); |
| 2580 | } |
| 2581 | |
| 2582 | if (!(psKeyDef->ascending_flagcxx . . $ $anonymous_type_a69ae1a4ba3d583e_7#ascending_flag.)) |
| 2583 | nResult *= -1; |
| 2584 | } |
| 2585 | |
| 2586 | return nResult; |
| 2587 | } |
| 2588 | |
| 2589 | /************************************************************************/ |
| 2590 | /* AddFieldDefnToSet() */ |
| 2591 | /************************************************************************/ |
| 2592 | |
| 2593 | void OGRGenSQLResultsLayercxx . . $ OGRGenSQLResultsLayer#::AddFieldDefnToSetcxx . . $ OGRGenSQLResultsLayer#AddFieldDefnToSet(7583a635f4749c74).(int iTable, int iColumn, |
| 2594 | CPLHashSet *hSet) |
| 2595 | { |
| 2596 | if (iTable != -1) |
| 2597 | { |
| 2598 | OGRLayercxx . . $ OGRLayer# *poLayer = m_apoTableLayerscxx . . $ OGRGenSQLResultsLayer#m_apoTableLayers.[iTable]; |
| 2599 | const auto poLayerDefn = poLayer->GetLayerDefncxx . . $ OGRLayer#GetLayerDefn(407fccde18759965).(); |
| 2600 | const int nFieldCount = poLayerDefn->GetFieldCountcxx . . $ OGRFeatureDefn#GetFieldCount(455f465bc33b4cdf).(); |
| 2601 | if (iColumn == -1) |
| 2602 | { |
| 2603 | for (int i = 0; i < nFieldCount; ++i) |
| 2604 | { |
| 2605 | OGRFieldDefncxx . . $ OGRFieldDefn# *poFDefn = poLayerDefn->GetFieldDefncxx . . $ OGRFeatureDefn#GetFieldDefn(2ec36f91b6ceefc7).(i); |
| 2606 | CPLHashSetInsert(hSet, poFDefn); |
| 2607 | } |
| 2608 | |
| 2609 | const int nGeomFieldCount = poLayerDefn->GetGeomFieldCountcxx . . $ OGRFeatureDefn#GetGeomFieldCount(455f465bc33b4cdf).(); |
| 2610 | for (int i = 0; i < nGeomFieldCount; ++i) |
| 2611 | { |
| 2612 | OGRGeomFieldDefncxx . . $ OGRGeomFieldDefn# *poFDefn = poLayerDefn->GetGeomFieldDefncxx . . $ OGRFeatureDefn#GetGeomFieldDefn(39768c424f32bab2).(i); |
| 2613 | CPLHashSetInsert(hSet, poFDefn); |
| 2614 | } |
| 2615 | } |
| 2616 | else |
| 2617 | { |
| 2618 | if (iColumn < nFieldCount) |
| 2619 | { |
| 2620 | OGRFieldDefncxx . . $ OGRFieldDefn# *poFDefn = poLayerDefn->GetFieldDefncxx . . $ OGRFeatureDefn#GetFieldDefn(2ec36f91b6ceefc7).(iColumn); |
| 2621 | CPLHashSetInsert(hSet, poFDefn); |
| 2622 | } |
| 2623 | else if (iColumn == nFieldCount + SPF_OGR_GEOMETRYcxx . . $ `ogr/ogr_p.h:170:9`! || |
| 2624 | iColumn == nFieldCount + SPF_OGR_GEOM_WKTcxx . . $ `ogr/ogr_p.h:172:9`! || |
| 2625 | iColumn == nFieldCount + SPF_OGR_GEOM_AREAcxx . . $ `ogr/ogr_p.h:173:9`!) |
| 2626 | { |
| 2627 | auto poSrcGFDefn = poLayerDefn->GetGeomFieldDefncxx . . $ OGRFeatureDefn#GetGeomFieldDefn(39768c424f32bab2).(0); |
| 2628 | CPLHashSetInsert(hSet, poSrcGFDefn); |
| 2629 | } |
| 2630 | else if (IS_GEOM_FIELD_INDEXcxx . . $ `ogr/ogrsf_frmts/generic/ogr_gensql.h:29:9`!(poLayerDefn, iColumn)) |
| 2631 | { |
| 2632 | const int iSrcGeomField = |
| 2633 | ALL_FIELD_INDEX_TO_GEOM_FIELD_INDEXcxx . . $ `ogr/ogrsf_frmts/generic/ogr_gensql.h:34:9`!(poLayerDefn, iColumn); |
| 2634 | auto poSrcGFDefn = poLayerDefn->GetGeomFieldDefncxx . . $ OGRFeatureDefn#GetGeomFieldDefn(39768c424f32bab2).(iSrcGeomField); |
| 2635 | CPLHashSetInsert(hSet, poSrcGFDefn); |
| 2636 | } |
| 2637 | } |
| 2638 | } |
| 2639 | } |
| 2640 | |
| 2641 | /************************************************************************/ |
| 2642 | /* ExploreExprForIgnoredFields() */ |
| 2643 | /************************************************************************/ |
| 2644 | |
| 2645 | void OGRGenSQLResultsLayercxx . . $ OGRGenSQLResultsLayer#::ExploreExprForIgnoredFieldscxx . . $ OGRGenSQLResultsLayer#ExploreExprForIgnoredFields(cbe083e4eb791fee).(swq_expr_nodecxx . . $ swq_expr_node# *expr, |
| 2646 | CPLHashSet *hSet) |
| 2647 | { |
| 2648 | if (expr->eNodeTypecxx . . $ swq_expr_node#eNodeType. == SNT_COLUMNcxx . . $ SNT_COLUMN.) |
| 2649 | { |
| 2650 | AddFieldDefnToSetcxx . . $ OGRGenSQLResultsLayer#AddFieldDefnToSet(7583a635f4749c74).(expr->table_indexcxx . . $ swq_expr_node#table_index., expr->field_indexcxx . . $ swq_expr_node#field_index., hSet); |
| 2651 | } |
| 2652 | else if (expr->eNodeTypecxx . . $ swq_expr_node#eNodeType. == SNT_OPERATIONcxx . . $ SNT_OPERATION.) |
| 2653 | { |
| 2654 | for (int i = 0; i < expr->nSubExprCountcxx . . $ swq_expr_node#nSubExprCount.; i++) |
| 2655 | ExploreExprForIgnoredFieldscxx . . $ OGRGenSQLResultsLayer#ExploreExprForIgnoredFields(cbe083e4eb791fee).(expr->papoSubExprcxx . . $ swq_expr_node#papoSubExpr.[i], hSet); |
| 2656 | } |
| 2657 | } |
| 2658 | |
| 2659 | /************************************************************************/ |
| 2660 | /* FindAndSetIgnoredFields() */ |
| 2661 | /************************************************************************/ |
| 2662 | |
| 2663 | void OGRGenSQLResultsLayercxx . . $ OGRGenSQLResultsLayer#::FindAndSetIgnoredFieldscxx . . $ OGRGenSQLResultsLayer#FindAndSetIgnoredFields(49f6e7a06ebc5aa8).() |
| 2664 | { |
| 2665 | swq_selectcxx . . $ swq_select# *psSelectInfo = m_pSelectInfocxx . . $ OGRGenSQLResultsLayer#m_pSelectInfo..get(); |
| 2666 | CPLHashSet *hSet = |
| 2667 | CPLHashSetNew(CPLHashSetHashPointer, CPLHashSetEqualPointer, nullptr); |
| 2668 | |
| 2669 | /* -------------------------------------------------------------------- */ |
| 2670 | /* 1st phase : explore the whole select infos to determine which */ |
| 2671 | /* source fields are used */ |
| 2672 | /* -------------------------------------------------------------------- */ |
| 2673 | for (int iField = 0; iField < psSelectInfo->result_columnscxx . . $ swq_select#result_columns(455f465bc33b4cdf).(); iField++) |
| 2674 | { |
| 2675 | swq_col_defcxx . . $ swq_col_def# *psColDef = &psSelectInfo->column_defscxx . . $ swq_select#column_defs.[iField]; |
| 2676 | AddFieldDefnToSetcxx . . $ OGRGenSQLResultsLayer#AddFieldDefnToSet(7583a635f4749c74).(psColDef->table_indexcxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#table_index., psColDef->field_indexcxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#field_index., hSet); |
| 2677 | if (psColDef->exprcxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#expr.) |
| 2678 | ExploreExprForIgnoredFieldscxx . . $ OGRGenSQLResultsLayer#ExploreExprForIgnoredFields(cbe083e4eb791fee).(psColDef->exprcxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#expr., hSet); |
| 2679 | } |
| 2680 | |
| 2681 | if (psSelectInfo->where_exprcxx . . $ swq_select#where_expr.) |
| 2682 | ExploreExprForIgnoredFieldscxx . . $ OGRGenSQLResultsLayer#ExploreExprForIgnoredFields(cbe083e4eb791fee).(psSelectInfo->where_exprcxx . . $ swq_select#where_expr., hSet); |
| 2683 | |
| 2684 | for (int iJoin = 0; iJoin < psSelectInfo->join_countcxx . . $ swq_select#join_count.; iJoin++) |
| 2685 | { |
| 2686 | swq_join_defcxx . . $ swq_join_def# *psJoinDef = psSelectInfo->join_defscxx . . $ swq_select#join_defs. + iJoin; |
| 2687 | ExploreExprForIgnoredFieldscxx . . $ OGRGenSQLResultsLayer#ExploreExprForIgnoredFields(cbe083e4eb791fee).(psJoinDef->poExprcxx . . $ $anonymous_type_a69ae1a4ba3d583e_8#poExpr., hSet); |
| 2688 | } |
| 2689 | |
| 2690 | for (int iOrder = 0; iOrder < psSelectInfo->order_specscxx . . $ swq_select#order_specs.; iOrder++) |
| 2691 | { |
| 2692 | swq_order_defcxx . . $ swq_order_def# *psOrderDef = psSelectInfo->order_defscxx . . $ swq_select#order_defs. + iOrder; |
| 2693 | AddFieldDefnToSetcxx . . $ OGRGenSQLResultsLayer#AddFieldDefnToSet(7583a635f4749c74).(psOrderDef->table_indexcxx . . $ $anonymous_type_a69ae1a4ba3d583e_7#table_index., psOrderDef->field_indexcxx . . $ $anonymous_type_a69ae1a4ba3d583e_7#field_index., |
| 2694 | hSet); |
| 2695 | } |
| 2696 | |
| 2697 | /* -------------------------------------------------------------------- */ |
| 2698 | /* 2nd phase : now, we can exclude the unused fields */ |
| 2699 | /* -------------------------------------------------------------------- */ |
| 2700 | for (int iTable = 0; iTable < psSelectInfo->table_countcxx . . $ swq_select#table_count.; iTable++) |
| 2701 | { |
| 2702 | OGRLayercxx . . $ OGRLayer# *poLayer = m_apoTableLayerscxx . . $ OGRGenSQLResultsLayer#m_apoTableLayers.[iTable]; |
| 2703 | OGRFeatureDefncxx . . $ OGRFeatureDefn# *poSrcFDefn = poLayer->GetLayerDefncxx . . $ OGRLayer#GetLayerDefn(407fccde18759965).(); |
| 2704 | char **papszIgnoredFields = nullptr; |
| 2705 | const int nSrcFieldCount = poSrcFDefn->GetFieldCountcxx . . $ OGRFeatureDefn#GetFieldCount(455f465bc33b4cdf).(); |
| 2706 | for (int iSrcField = 0; iSrcField < nSrcFieldCount; iSrcField++) |
| 2707 | { |
| 2708 | OGRFieldDefncxx . . $ OGRFieldDefn# *poFDefn = poSrcFDefn->GetFieldDefncxx . . $ OGRFeatureDefn#GetFieldDefn(2ec36f91b6ceefc7).(iSrcField); |
| 2709 | if (CPLHashSetLookup(hSet, poFDefn) == nullptr) |
| 2710 | { |
| 2711 | papszIgnoredFields = |
| 2712 | CSLAddString(papszIgnoredFields, poFDefn->GetNameRefcxx . . $ OGRFieldDefn#GetNameRef(a9f41ea0e82d88cf).()); |
| 2713 | // CPLDebug("OGR", "Adding %s to the list of ignored fields of |
| 2714 | // layer %s", |
| 2715 | // poFDefn->GetNameRef(), poLayer->GetName()); |
| 2716 | } |
| 2717 | } |
| 2718 | if (!m_bSpatialFilterSetOnSourceLayercxx . . $ OGRGenSQLResultsLayer#m_bSpatialFilterSetOnSourceLayer.) |
| 2719 | { |
| 2720 | const int nSrcGeomFieldCount = poSrcFDefn->GetGeomFieldCountcxx . . $ OGRFeatureDefn#GetGeomFieldCount(455f465bc33b4cdf).(); |
| 2721 | for (int iSrcField = 0; iSrcField < nSrcGeomFieldCount; iSrcField++) |
| 2722 | { |
| 2723 | OGRGeomFieldDefncxx . . $ OGRGeomFieldDefn# *poFDefn = |
| 2724 | poSrcFDefn->GetGeomFieldDefncxx . . $ OGRFeatureDefn#GetGeomFieldDefn(39768c424f32bab2).(iSrcField); |
| 2725 | if (CPLHashSetLookup(hSet, poFDefn) == nullptr) |
| 2726 | { |
| 2727 | papszIgnoredFields = |
| 2728 | CSLAddString(papszIgnoredFields, poFDefn->GetNameRefcxx . . $ OGRGeomFieldDefn#GetNameRef(a9f41ea0e82d88cf).()); |
| 2729 | // CPLDebug("OGR", "Adding %s to the list of ignored fields of |
| 2730 | // layer %s", |
| 2731 | // poFDefn->GetNameRef(), poLayer->GetName()); |
| 2732 | } |
| 2733 | } |
| 2734 | } |
| 2735 | poLayer->SetIgnoredFieldscxx . . $ OGRLayer#SetIgnoredFields(e464cedb65a3f4c2).( |
| 2736 | const_cast<const char **>(papszIgnoredFields)); |
| 2737 | CSLDestroy(papszIgnoredFields); |
| 2738 | } |
| 2739 | |
| 2740 | CPLHashSetDestroy(hSet); |
| 2741 | } |
| 2742 | |
| 2743 | /************************************************************************/ |
| 2744 | /* InvalidateOrderByIndex() */ |
| 2745 | /************************************************************************/ |
| 2746 | |
| 2747 | void OGRGenSQLResultsLayercxx . . $ OGRGenSQLResultsLayer#::InvalidateOrderByIndexcxx . . $ OGRGenSQLResultsLayer#InvalidateOrderByIndex(49f6e7a06ebc5aa8).() |
| 2748 | { |
| 2749 | m_anFIDIndexcxx . . $ OGRGenSQLResultsLayer#m_anFIDIndex..clear(); |
| 2750 | m_bOrderByValidcxx . . $ OGRGenSQLResultsLayer#m_bOrderByValid. = false; |
| 2751 | } |
| 2752 | |
| 2753 | /************************************************************************/ |
| 2754 | /* SetAttributeFilter() */ |
| 2755 | /************************************************************************/ |
| 2756 | |
| 2757 | OGRErr OGRGenSQLResultsLayercxx . . $ OGRGenSQLResultsLayer#::SetAttributeFiltercxx . . $ OGRGenSQLResultsLayer#SetAttributeFilter(5c4306d8553b3696).(const char *pszAttributeFilter) |
| 2758 | { |
| 2759 | const stdcxx . . $ std/::string osAdditionalWHERE = |
| 2760 | pszAttributeFilter ? pszAttributeFilter : ""; |
| 2761 | stdcxx . . $ std/::string osWHERE; |
| 2762 | if (!m_bForwardWhereToSourceLayercxx . . $ OGRGenSQLResultsLayer#m_bForwardWhereToSourceLayer. && !m_osInitialWHEREcxx . . $ OGRGenSQLResultsLayer#m_osInitialWHERE..empty()) |
| 2763 | { |
| 2764 | if (!osAdditionalWHERE.empty()) |
| 2765 | osWHERE += '('; |
| 2766 | osWHERE += m_osInitialWHEREcxx . . $ OGRGenSQLResultsLayer#m_osInitialWHERE.; |
| 2767 | if (!osAdditionalWHERE.empty()) |
| 2768 | osWHERE += ") AND ("; |
| 2769 | } |
| 2770 | osWHERE += osAdditionalWHERE; |
| 2771 | if (!m_bForwardWhereToSourceLayercxx . . $ OGRGenSQLResultsLayer#m_bForwardWhereToSourceLayer. && !m_osInitialWHEREcxx . . $ OGRGenSQLResultsLayer#m_osInitialWHERE..empty() && |
| 2772 | !osAdditionalWHERE.empty()) |
| 2773 | { |
| 2774 | osWHERE += ')'; |
| 2775 | } |
| 2776 | InvalidateOrderByIndexcxx . . $ OGRGenSQLResultsLayer#InvalidateOrderByIndex(49f6e7a06ebc5aa8).(); |
| 2777 | return OGRLayercxx . . $ OGRLayer#::SetAttributeFiltercxx . . $ OGRLayer#SetAttributeFilter(5c4306d8553b3696).(osWHERE.empty() ? nullptr |
| 2778 | : osWHERE.c_str()); |
| 2779 | } |
| 2780 | |
| 2781 | /************************************************************************/ |
| 2782 | /* ISetSpatialFilter() */ |
| 2783 | /************************************************************************/ |
| 2784 | |
| 2785 | OGRErr OGRGenSQLResultsLayercxx . . $ OGRGenSQLResultsLayer#::ISetSpatialFiltercxx . . $ OGRGenSQLResultsLayer#ISetSpatialFilter(896393ecef503097).(int iGeomField, |
| 2786 | const OGRGeometrycxx . . $ OGRGeometry# *poGeom) |
| 2787 | { |
| 2788 | InvalidateOrderByIndexcxx . . $ OGRGenSQLResultsLayer#InvalidateOrderByIndex(49f6e7a06ebc5aa8).(); |
| 2789 | return OGRLayercxx . . $ OGRLayer#::ISetSpatialFiltercxx . . $ OGRLayer#ISetSpatialFilter(896393ecef503097).(iGeomField, poGeom); |
| 2790 | } |
| 2791 | |
| 2792 | /************************************************************************/ |
| 2793 | /* OGRGenSQLResultsLayerArrowStreamPrivateData */ |
| 2794 | /************************************************************************/ |
| 2795 | |
| 2796 | // Structure whose instances are set on the ArrowArrayStream::private_data |
| 2797 | // member of the ArrowArrayStream returned by OGRGenSQLResultsLayer::GetArrowStream() |
| 2798 | struct OGRGenSQLResultsLayerArrowStreamPrivateDatacxx . . $ OGRGenSQLResultsLayerArrowStreamPrivateData# |
| 2799 | { |
| 2800 | // Member shared with OGRLayer::m_poSharedArrowArrayStreamPrivateData |
| 2801 | // If the layer pointed by poShared->poLayer is destroyed, before its |
| 2802 | // destruction, it nullifies poShared->poLayer, which we can detect. |
| 2803 | stdcxx . . $ std/::shared_ptr<OGRLayercxx . . $ OGRLayer#::ArrowArrayStreamPrivateDatacxx . . $ OGRLayer#ArrowArrayStreamPrivateData#> poSharedcxx . . $ OGRGenSQLResultsLayerArrowStreamPrivateData#poShared.{}; |
| 2804 | |
| 2805 | // ArrowArrayStream to be used with poShared->poLayer |
| 2806 | struct ArrowArrayStreamcxx . . $ ArrowArrayStream# *psSrcLayerStreamcxx . . $ OGRGenSQLResultsLayerArrowStreamPrivateData#psSrcLayerStream. = nullptr; |
| 2807 | |
| 2808 | // Original release() callback of the ArrowArrayStream passed to |
| 2809 | // OGRGenSQLResultsLayer::GetArrowStream() |
| 2810 | void (*release_backupcxx . . $ OGRGenSQLResultsLayerArrowStreamPrivateData#release_backup.)(struct ArrowArrayStreamcxx . . $ ArrowArrayStream# *) = nullptr; |
| 2811 | |
| 2812 | // Original private_data member of the ArrowArrayStream passed to |
| 2813 | // OGRGenSQLResultsLayer::GetArrowStream() |
| 2814 | void *private_data_backupcxx . . $ OGRGenSQLResultsLayerArrowStreamPrivateData#private_data_backup. = nullptr; |
| 2815 | |
| 2816 | // Set as the ArrowArrayStream::release callback member of the |
| 2817 | // ArrowArrayStream returned by OGRGenSQLResultsLayer::GetArrowStream() |
| 2818 | static void Releasecxx . . $ OGRGenSQLResultsLayerArrowStreamPrivateData#Release(3f7a38aa1b87a50e).(struct ArrowArrayStreamcxx . . $ ArrowArrayStream# *self) |
| 2819 | { |
| 2820 | OGRGenSQLResultsLayerArrowStreamPrivateDatacxx . . $ OGRGenSQLResultsLayerArrowStreamPrivateData# *psPrivateData = |
| 2821 | static_cast<OGRGenSQLResultsLayerArrowStreamPrivateDatacxx . . $ OGRGenSQLResultsLayerArrowStreamPrivateData# *>( |
| 2822 | self->private_datacxx . . $ ArrowArrayStream#private_data.); |
| 2823 | |
| 2824 | // Release source layer stream |
| 2825 | if (psPrivateData->psSrcLayerStreamcxx . . $ OGRGenSQLResultsLayerArrowStreamPrivateData#psSrcLayerStream.->releasecxx . . $ ArrowArrayStream#release.) |
| 2826 | psPrivateData->psSrcLayerStreamcxx . . $ OGRGenSQLResultsLayerArrowStreamPrivateData#psSrcLayerStream.->releasecxx . . $ ArrowArrayStream#release.( |
| 2827 | psPrivateData->psSrcLayerStreamcxx . . $ OGRGenSQLResultsLayerArrowStreamPrivateData#psSrcLayerStream.); |
| 2828 | CPLFreecxx . . $ `port/cpl_conv.h:97:9`!(psPrivateData->psSrcLayerStreamcxx . . $ OGRGenSQLResultsLayerArrowStreamPrivateData#psSrcLayerStream.); |
| 2829 | |
| 2830 | // Release ourselves using the base method |
| 2831 | self->private_datacxx . . $ ArrowArrayStream#private_data. = psPrivateData->private_data_backupcxx . . $ OGRGenSQLResultsLayerArrowStreamPrivateData#private_data_backup.; |
| 2832 | self->releasecxx . . $ ArrowArrayStream#release. = psPrivateData->release_backupcxx . . $ OGRGenSQLResultsLayerArrowStreamPrivateData#release_backup.; |
| 2833 | delete psPrivateData; |
| 2834 | if (self->releasecxx . . $ ArrowArrayStream#release.) |
| 2835 | self->releasecxx . . $ ArrowArrayStream#release.(self); |
| 2836 | } |
| 2837 | |
| 2838 | // Set as the ArrowArrayStream::get_schema callback member of the |
| 2839 | // ArrowArrayStream returned by OGRGenSQLResultsLayer::GetArrowStream() |
| 2840 | static int GetSchemacxx . . $ OGRGenSQLResultsLayerArrowStreamPrivateData#GetSchema(75fabee04868d05d).(struct ArrowArrayStreamcxx . . $ ArrowArrayStream# *self, struct ArrowSchema *out) |
| 2841 | { |
| 2842 | OGRGenSQLResultsLayerArrowStreamPrivateDatacxx . . $ OGRGenSQLResultsLayerArrowStreamPrivateData# *psPrivateData = |
| 2843 | static_cast<OGRGenSQLResultsLayerArrowStreamPrivateDatacxx . . $ OGRGenSQLResultsLayerArrowStreamPrivateData# *>( |
| 2844 | self->private_datacxx . . $ ArrowArrayStream#private_data.); |
| 2845 | auto poLayer = dynamic_cast<OGRGenSQLResultsLayercxx . . $ OGRGenSQLResultsLayer# *>( |
| 2846 | psPrivateData->poSharedcxx . . $ OGRGenSQLResultsLayerArrowStreamPrivateData#poShared.->m_poLayercxx . . $ OGRLayer#ArrowArrayStreamPrivateData#m_poLayer.); |
| 2847 | if (!poLayer) |
| 2848 | { |
| 2849 | CPLError( |
| 2850 | CE_Failure, CPLE_NotSupportedcxx . . $ `port/cpl_error.h:118:9`!, |
| 2851 | "Calling get_schema() on a freed OGRLayer is not supported"); |
| 2852 | return EINVALcxx . . $ `<external>/8987895939074593727/errno-base.h:26:9`!; |
| 2853 | } |
| 2854 | return poLayer->GetArrowSchemaForwardedcxx . . $ OGRGenSQLResultsLayer#GetArrowSchemaForwarded(827c1062ac293fca).(self, out); |
| 2855 | } |
| 2856 | |
| 2857 | // Set as the ArrowArrayStream::get_next callback member of the |
| 2858 | // ArrowArrayStream returned by OGRGenSQLResultsLayer::GetArrowStream() |
| 2859 | static int GetNextcxx . . $ OGRGenSQLResultsLayerArrowStreamPrivateData#GetNext(b1dcf2e4b2dc4bae).(struct ArrowArrayStreamcxx . . $ ArrowArrayStream# *self, struct ArrowArray *out) |
| 2860 | { |
| 2861 | OGRGenSQLResultsLayerArrowStreamPrivateDatacxx . . $ OGRGenSQLResultsLayerArrowStreamPrivateData# *psPrivateData = |
| 2862 | static_cast<OGRGenSQLResultsLayerArrowStreamPrivateDatacxx . . $ OGRGenSQLResultsLayerArrowStreamPrivateData# *>( |
| 2863 | self->private_datacxx . . $ ArrowArrayStream#private_data.); |
| 2864 | auto poLayer = dynamic_cast<OGRGenSQLResultsLayercxx . . $ OGRGenSQLResultsLayer# *>( |
| 2865 | psPrivateData->poSharedcxx . . $ OGRGenSQLResultsLayerArrowStreamPrivateData#poShared.->m_poLayercxx . . $ OGRLayer#ArrowArrayStreamPrivateData#m_poLayer.); |
| 2866 | if (!poLayer) |
| 2867 | { |
| 2868 | CPLError(CE_Failure, CPLE_NotSupportedcxx . . $ `port/cpl_error.h:118:9`!, |
| 2869 | "Calling get_next() on a freed OGRLayer is not supported"); |
| 2870 | return EINVALcxx . . $ `<external>/8987895939074593727/errno-base.h:26:9`!; |
| 2871 | } |
| 2872 | return poLayer->GetNextArrowArrayForwardedcxx . . $ OGRGenSQLResultsLayer#GetNextArrowArrayForwarded(b1dcf2e4b2dc4bae).(self, out); |
| 2873 | } |
| 2874 | }; |
| 2875 | |
| 2876 | /************************************************************************/ |
| 2877 | /* GetArrowStream() */ |
| 2878 | /************************************************************************/ |
| 2879 | |
| 2880 | bool OGRGenSQLResultsLayercxx . . $ OGRGenSQLResultsLayer#::GetArrowStreamcxx . . $ OGRGenSQLResultsLayer#GetArrowStream(7c5f6bdcb8e63ef3).(struct ArrowArrayStreamcxx . . $ ArrowArrayStream# *out_stream, |
| 2881 | CSLConstListcxx . . $ CSLConstList# papszOptions) |
| 2882 | { |
| 2883 | if (!TestCapabilitycxx . . $ OGRGenSQLResultsLayer#TestCapability(78f035161ffa9fe2).(OLCFastGetArrowStreamcxx . . $ `ogr/ogr_core.h:1033:9`!) || |
| 2884 | CPLTestBool(CPLGetConfigOption("OGR_GENSQL_STREAM_BASE_IMPL", "NO"))) |
| 2885 | { |
| 2886 | CPLStringList aosOptions(papszOptions); |
| 2887 | aosOptions.SetNameValue("OGR_GENSQL_STREAM_BASE_IMPL", "YES"); |
| 2888 | return OGRLayercxx . . $ OGRLayer#::GetArrowStreamcxx . . $ OGRLayer#GetArrowStream(7c5f6bdcb8e63ef3).(out_stream, aosOptions.List()); |
| 2889 | } |
| 2890 | |
| 2891 | const swq_selectcxx . . $ swq_select# *psSelectInfo = m_pSelectInfocxx . . $ OGRGenSQLResultsLayer#m_pSelectInfo..get(); |
| 2892 | if (m_nIteratedFeaturescxx . . $ OGRGenSQLResultsLayer#m_nIteratedFeatures. != -1) |
| 2893 | { |
| 2894 | CPLError(CE_Failure, CPLE_AppDefinedcxx . . $ `port/cpl_error.h:108:9`!, |
| 2895 | "GetArrowStream() not supported on non-rewinded layer"); |
| 2896 | return false; |
| 2897 | } |
| 2898 | CPLStringList aosOptions(papszOptions); |
| 2899 | if (psSelectInfo->limitcxx . . $ swq_select#limit. > 0) |
| 2900 | { |
| 2901 | aosOptions.SetNameValue( |
| 2902 | "MAX_FEATURES_IN_BATCH", |
| 2903 | CPLSPrintf(CPL_FRMT_GIBcxx . . $ `port/cpl_port.h:257:9`!, |
| 2904 | stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(psSelectInfo->limitcxx . . $ swq_select#limit., |
| 2905 | CPLAtoGIntBig(aosOptions.FetchNameValueDef( |
| 2906 | "MAX_FEATURES_IN_BATCH", "65536"))))); |
| 2907 | } |
| 2908 | bool bRet = OGRLayercxx . . $ OGRLayer#::GetArrowStreamcxx . . $ OGRLayer#GetArrowStream(7c5f6bdcb8e63ef3).(out_stream, aosOptions.List()); |
| 2909 | if (bRet) |
| 2910 | { |
| 2911 | auto psSrcLayerStream = static_cast<struct ArrowArrayStreamcxx . . $ ArrowArrayStream# *>( |
| 2912 | CPLMalloc(sizeof(ArrowArrayStreamcxx . . $ ArrowArrayStream#))); |
| 2913 | if (m_poSrcLayercxx . . $ OGRGenSQLResultsLayer#m_poSrcLayer.->GetArrowStreamcxx . . $ OGRLayer#GetArrowStream(7c5f6bdcb8e63ef3).(psSrcLayerStream, aosOptions.List())) |
| 2914 | { |
| 2915 | auto psPrivateData = |
| 2916 | new OGRGenSQLResultsLayerArrowStreamPrivateDatacxx . . $ OGRGenSQLResultsLayerArrowStreamPrivateData#; |
| 2917 | CPLAssertcxx . . $ `port/cpl_error.h:353:9`!(m_poSharedArrowArrayStreamPrivateData); |
| 2918 | psPrivateData->poSharedcxx . . $ OGRGenSQLResultsLayerArrowStreamPrivateData#poShared. = m_poSharedArrowArrayStreamPrivateDatacxx . . $ OGRLayer#m_poSharedArrowArrayStreamPrivateData.; |
| 2919 | psPrivateData->psSrcLayerStreamcxx . . $ OGRGenSQLResultsLayerArrowStreamPrivateData#psSrcLayerStream. = psSrcLayerStream; |
| 2920 | psPrivateData->release_backupcxx . . $ OGRGenSQLResultsLayerArrowStreamPrivateData#release_backup. = out_stream->releasecxx . . $ ArrowArrayStream#release.; |
| 2921 | psPrivateData->private_data_backupcxx . . $ OGRGenSQLResultsLayerArrowStreamPrivateData#private_data_backup. = out_stream->private_datacxx . . $ ArrowArrayStream#private_data.; |
| 2922 | out_stream->get_schemacxx . . $ ArrowArrayStream#get_schema. = |
| 2923 | OGRGenSQLResultsLayerArrowStreamPrivateDatacxx . . $ OGRGenSQLResultsLayerArrowStreamPrivateData#::GetSchemacxx . . $ OGRGenSQLResultsLayerArrowStreamPrivateData#GetSchema(75fabee04868d05d).; |
| 2924 | out_stream->get_nextcxx . . $ ArrowArrayStream#get_next. = |
| 2925 | OGRGenSQLResultsLayerArrowStreamPrivateDatacxx . . $ OGRGenSQLResultsLayerArrowStreamPrivateData#::GetNextcxx . . $ OGRGenSQLResultsLayerArrowStreamPrivateData#GetNext(b1dcf2e4b2dc4bae).; |
| 2926 | out_stream->releasecxx . . $ ArrowArrayStream#release. = |
| 2927 | OGRGenSQLResultsLayerArrowStreamPrivateDatacxx . . $ OGRGenSQLResultsLayerArrowStreamPrivateData#::Releasecxx . . $ OGRGenSQLResultsLayerArrowStreamPrivateData#Release(3f7a38aa1b87a50e).; |
| 2928 | out_stream->private_datacxx . . $ ArrowArrayStream#private_data. = psPrivateData; |
| 2929 | } |
| 2930 | else |
| 2931 | { |
| 2932 | if (psSrcLayerStream->releasecxx . . $ ArrowArrayStream#release.) |
| 2933 | psSrcLayerStream->releasecxx . . $ ArrowArrayStream#release.(psSrcLayerStream); |
| 2934 | CPLFreecxx . . $ `port/cpl_conv.h:97:9`!(psSrcLayerStream); |
| 2935 | if (out_stream->releasecxx . . $ ArrowArrayStream#release.) |
| 2936 | out_stream->releasecxx . . $ ArrowArrayStream#release.(out_stream); |
| 2937 | bRet = false; |
| 2938 | } |
| 2939 | } |
| 2940 | return bRet; |
| 2941 | } |
| 2942 | |
| 2943 | /************************************************************************/ |
| 2944 | /* GetArrowSchema() */ |
| 2945 | /************************************************************************/ |
| 2946 | |
| 2947 | int OGRGenSQLResultsLayercxx . . $ OGRGenSQLResultsLayer#::GetArrowSchemacxx . . $ OGRGenSQLResultsLayer#GetArrowSchema(75fabee04868d05d).(struct ArrowArrayStreamcxx . . $ ArrowArrayStream# *stream, |
| 2948 | struct ArrowSchema *out_schema) |
| 2949 | { |
| 2950 | if (m_aosArrowArrayStreamOptionscxx . . $ OGRLayer#m_aosArrowArrayStreamOptions..FetchNameValue( |
| 2951 | "OGR_GENSQL_STREAM_BASE_IMPL") || |
| 2952 | !TestCapabilitycxx . . $ OGRGenSQLResultsLayer#TestCapability(78f035161ffa9fe2).(OLCFastGetArrowStreamcxx . . $ `ogr/ogr_core.h:1033:9`!)) |
| 2953 | { |
| 2954 | return OGRLayercxx . . $ OGRLayer#::GetArrowSchemacxx . . $ OGRLayer#GetArrowSchema(75fabee04868d05d).(stream, out_schema); |
| 2955 | } |
| 2956 | |
| 2957 | return GetArrowSchemaForwardedcxx . . $ OGRGenSQLResultsLayer#GetArrowSchemaForwarded(827c1062ac293fca).(stream, out_schema); |
| 2958 | } |
| 2959 | |
| 2960 | /************************************************************************/ |
| 2961 | /* GetArrowSchemaForwarded() */ |
| 2962 | /************************************************************************/ |
| 2963 | |
| 2964 | int OGRGenSQLResultsLayercxx . . $ OGRGenSQLResultsLayer#::GetArrowSchemaForwardedcxx . . $ OGRGenSQLResultsLayer#GetArrowSchemaForwarded(827c1062ac293fca).( |
| 2965 | struct ArrowArrayStreamcxx . . $ ArrowArrayStream# *stream, struct ArrowSchema *out_schema) const |
| 2966 | { |
| 2967 | const swq_selectcxx . . $ swq_select# *psSelectInfo = m_pSelectInfocxx . . $ OGRGenSQLResultsLayer#m_pSelectInfo..get(); |
| 2968 | OGRGenSQLResultsLayerArrowStreamPrivateDatacxx . . $ OGRGenSQLResultsLayerArrowStreamPrivateData# *psPrivateData = |
| 2969 | static_cast<OGRGenSQLResultsLayerArrowStreamPrivateDatacxx . . $ OGRGenSQLResultsLayerArrowStreamPrivateData# *>( |
| 2970 | stream->private_datacxx . . $ ArrowArrayStream#private_data.); |
| 2971 | int ret = m_poSrcLayercxx . . $ OGRGenSQLResultsLayer#m_poSrcLayer.->GetArrowSchemacxx . . $ OGRLayer#GetArrowSchema(75fabee04868d05d).(psPrivateData->psSrcLayerStreamcxx . . $ OGRGenSQLResultsLayerArrowStreamPrivateData#psSrcLayerStream., |
| 2972 | out_schema); |
| 2973 | if (ret == 0) |
| 2974 | { |
| 2975 | struct ArrowSchema newSchema; |
| 2976 | ret = OGRCloneArrowSchemacxx . . $ OGRCloneArrowSchema(89283c64769d0d7c).(out_schema, &newSchema) ? 0 : EIOcxx . . $ `<external>/8987895939074593727/errno-base.h:9:9`!; |
| 2977 | if (out_schema->release) |
| 2978 | out_schema->release(out_schema); |
| 2979 | if (ret == 0) |
| 2980 | { |
| 2981 | stdcxx . . $ std/::mapcxx . . $ std/map#<stdcxx . . $ std/::string, stdcxx . . $ std/::string> oMapSrcNameToRenamedcxx . . $ std/map#map(49f6e7a06ebc5aa8).; |
| 2982 | for (stdcxx . . $ std/::size_tcxx . . $ std/size_t# iField = 0; |
| 2983 | iField < psSelectInfo->column_defscxx . . $ swq_select#column_defs..size(); iField++) |
| 2984 | { |
| 2985 | const swq_col_defcxx . . $ swq_col_def# *psColDef = |
| 2986 | &psSelectInfo->column_defscxx . . $ swq_select#column_defs.[iField]; |
| 2987 | CPLAssertcxx . . $ `port/cpl_error.h:353:9`!(!psColDef->bHidden); |
| 2988 | CPLAssertcxx . . $ `port/cpl_error.h:353:9`!(psColDef->table_index >= 0); |
| 2989 | CPLAssertcxx . . $ `port/cpl_error.h:353:9`!(psColDef->col_func == SWQCF_NONE); |
| 2990 | |
| 2991 | const auto poLayerDefn = |
| 2992 | m_apoTableLayerscxx . . $ OGRGenSQLResultsLayer#m_apoTableLayers.[psColDef->table_indexcxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#table_index.]->GetLayerDefncxx . . $ OGRLayer#GetLayerDefn(407fccde18759965).(); |
| 2993 | CPLAssertcxx . . $ `port/cpl_error.h:353:9`!(poLayerDefn); |
| 2994 | |
| 2995 | if (psColDef->field_indexcxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#field_index. >= 0 && |
| 2996 | psColDef->field_indexcxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#field_index. < poLayerDefn->GetFieldCountcxx . . $ OGRFeatureDefn#GetFieldCount(455f465bc33b4cdf).()) |
| 2997 | { |
| 2998 | const auto poSrcFDefn = |
| 2999 | poLayerDefn->GetFieldDefncxx . . $ OGRFeatureDefn#GetFieldDefn(2ec36f91b6ceefc7).(psColDef->field_indexcxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#field_index.); |
| 3000 | if (psColDef->field_aliascxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#field_alias.) |
| 3001 | oMapSrcNameToRenamed[cxx . . $ std/map#`operator[]`(da459db78e6e18a3).poSrcFDefn->GetNameRefcxx . . $ OGRFieldDefn#GetNameRef(a9f41ea0e82d88cf).()] = |
| 3002 | psColDef->field_aliascxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#field_alias.; |
| 3003 | } |
| 3004 | else if (IS_GEOM_FIELD_INDEXcxx . . $ `ogr/ogrsf_frmts/generic/ogr_gensql.h:29:9`!(poLayerDefn, |
| 3005 | psColDef->field_index)) |
| 3006 | { |
| 3007 | const int iSrcGeomField = |
| 3008 | ALL_FIELD_INDEX_TO_GEOM_FIELD_INDEXcxx . . $ `ogr/ogrsf_frmts/generic/ogr_gensql.h:34:9`!( |
| 3009 | poLayerDefn, psColDef->field_index); |
| 3010 | const auto poSrcGFDefn = |
| 3011 | poLayerDefn->GetGeomFieldDefncxx . . $ OGRFeatureDefn#GetGeomFieldDefn(39768c424f32bab2).(iSrcGeomField); |
| 3012 | if (psColDef->field_aliascxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#field_alias.) |
| 3013 | oMapSrcNameToRenamed[cxx . . $ std/map#`operator[]`(da459db78e6e18a3).poSrcGFDefn->GetNameRefcxx . . $ OGRGeomFieldDefn#GetNameRef(a9f41ea0e82d88cf).()] = |
| 3014 | psColDef->field_aliascxx . . $ $anonymous_type_a69ae1a4ba3d583e_6#field_alias.; |
| 3015 | } |
| 3016 | } |
| 3017 | |
| 3018 | for (int i = 0; i < newSchema.n_children; ++i) |
| 3019 | { |
| 3020 | const auto oIter = |
| 3021 | oMapSrcNameToRenamed.findcxx . . $ std/map#find(36f8d56706583706).(newSchema.children[i]->name); |
| 3022 | if (oIter !=cxx . . $ std/`operator!=`(be6a71a859368080). oMapSrcNameToRenamed.endcxx . . $ std/map#end(7e4de33083b6e738).()) |
| 3023 | { |
| 3024 | CPLFreecxx . . $ `port/cpl_conv.h:97:9`!(const_cast<char *>(newSchema.children[i]->name)); |
| 3025 | newSchema.children[i]->name = |
| 3026 | CPLStrdup(oIter->cxx . . $ std/_Rb_tree_iterator#`operator->`(34d6acfd341ba7ab).second.c_str()); |
| 3027 | } |
| 3028 | } |
| 3029 | |
| 3030 | memcpy(out_schema, &newSchema, sizeof(newSchema)); |
| 3031 | } |
| 3032 | } |
| 3033 | return ret; |
| 3034 | } |
| 3035 | |
| 3036 | /************************************************************************/ |
| 3037 | /* GetNextArrowArray() */ |
| 3038 | /************************************************************************/ |
| 3039 | |
| 3040 | int OGRGenSQLResultsLayercxx . . $ OGRGenSQLResultsLayer#::GetNextArrowArraycxx . . $ OGRGenSQLResultsLayer#GetNextArrowArray(b1dcf2e4b2dc4bae).(struct ArrowArrayStreamcxx . . $ ArrowArrayStream# *stream, |
| 3041 | struct ArrowArray *out_array) |
| 3042 | { |
| 3043 | if (m_aosArrowArrayStreamOptionscxx . . $ OGRLayer#m_aosArrowArrayStreamOptions..FetchNameValue( |
| 3044 | "OGR_GENSQL_STREAM_BASE_IMPL") || |
| 3045 | !TestCapabilitycxx . . $ OGRGenSQLResultsLayer#TestCapability(78f035161ffa9fe2).(OLCFastGetArrowStreamcxx . . $ `ogr/ogr_core.h:1033:9`!)) |
| 3046 | { |
| 3047 | return OGRLayercxx . . $ OGRLayer#::GetNextArrowArraycxx . . $ OGRLayer#GetNextArrowArray(b1dcf2e4b2dc4bae).(stream, out_array); |
| 3048 | } |
| 3049 | |
| 3050 | return GetNextArrowArrayForwardedcxx . . $ OGRGenSQLResultsLayer#GetNextArrowArrayForwarded(b1dcf2e4b2dc4bae).(stream, out_array); |
| 3051 | } |
| 3052 | |
| 3053 | /************************************************************************/ |
| 3054 | /* GetNextArrowArrayForwarded() */ |
| 3055 | /************************************************************************/ |
| 3056 | |
| 3057 | int OGRGenSQLResultsLayercxx . . $ OGRGenSQLResultsLayer#::GetNextArrowArrayForwardedcxx . . $ OGRGenSQLResultsLayer#GetNextArrowArrayForwarded(b1dcf2e4b2dc4bae).( |
| 3058 | struct ArrowArrayStreamcxx . . $ ArrowArrayStream# *stream, struct ArrowArray *out_array) |
| 3059 | { |
| 3060 | const swq_selectcxx . . $ swq_select# *psSelectInfo = m_pSelectInfocxx . . $ OGRGenSQLResultsLayer#m_pSelectInfo..get(); |
| 3061 | if (psSelectInfo->limitcxx . . $ swq_select#limit. >= 0 && m_nIteratedFeaturescxx . . $ OGRGenSQLResultsLayer#m_nIteratedFeatures. >= psSelectInfo->limitcxx . . $ swq_select#limit.) |
| 3062 | { |
| 3063 | memset(out_array, 0, sizeof(*out_array)); |
| 3064 | return 0; |
| 3065 | } |
| 3066 | |
| 3067 | OGRGenSQLResultsLayerArrowStreamPrivateDatacxx . . $ OGRGenSQLResultsLayerArrowStreamPrivateData# *psPrivateData = |
| 3068 | static_cast<OGRGenSQLResultsLayerArrowStreamPrivateDatacxx . . $ OGRGenSQLResultsLayerArrowStreamPrivateData# *>( |
| 3069 | stream->private_datacxx . . $ ArrowArrayStream#private_data.); |
| 3070 | const int ret = m_poSrcLayercxx . . $ OGRGenSQLResultsLayer#m_poSrcLayer.->GetNextArrowArraycxx . . $ OGRLayer#GetNextArrowArray(b1dcf2e4b2dc4bae).( |
| 3071 | psPrivateData->psSrcLayerStreamcxx . . $ OGRGenSQLResultsLayerArrowStreamPrivateData#psSrcLayerStream., out_array); |
| 3072 | if (ret == 0 && psSelectInfo->limitcxx . . $ swq_select#limit. >= 0) |
| 3073 | { |
| 3074 | if (m_nIteratedFeaturescxx . . $ OGRGenSQLResultsLayer#m_nIteratedFeatures. < 0) |
| 3075 | m_nIteratedFeaturescxx . . $ OGRGenSQLResultsLayer#m_nIteratedFeatures. = 0; |
| 3076 | m_nIteratedFeaturescxx . . $ OGRGenSQLResultsLayer#m_nIteratedFeatures. += out_array->length; |
| 3077 | if (m_nIteratedFeaturescxx . . $ OGRGenSQLResultsLayer#m_nIteratedFeatures. > psSelectInfo->limitcxx . . $ swq_select#limit.) |
| 3078 | { |
| 3079 | out_array->length -= m_nIteratedFeaturescxx . . $ OGRGenSQLResultsLayer#m_nIteratedFeatures. - psSelectInfo->limitcxx . . $ swq_select#limit.; |
| 3080 | for (int i = 0; i < out_array->n_children; ++i) |
| 3081 | { |
| 3082 | out_array->children[i]->length -= |
| 3083 | m_nIteratedFeaturescxx . . $ OGRGenSQLResultsLayer#m_nIteratedFeatures. - psSelectInfo->limitcxx . . $ swq_select#limit.; |
| 3084 | } |
| 3085 | } |
| 3086 | } |
| 3087 | return ret; |
| 3088 | } |
| 3089 | |
| 3090 | //! @endcond |