| 1 | /****************************************************************************** |
| 2 | * |
| 3 | * Project: MSSQL Spatial driver |
| 4 | * Purpose: Definition of classes for OGR MSSQL Spatial driver. |
| 5 | * Author: Tamas Szekeres, szekerest at gmail.com |
| 6 | * |
| 7 | ****************************************************************************** |
| 8 | * Copyright (c) 2010, Tamas Szekeres |
| 9 | * |
| 10 | * SPDX-License-Identifier: MIT |
| 11 | ****************************************************************************/ |
| 12 | |
| 13 | #include "ogr_mssqlspatial.h"cxx . . $ `<file>/ogr/ogrsf_frmts/mssqlspatial/ogr_mssqlspatial.h`/ |
| 14 | |
| 15 | #include <algorithm> |
| 16 | |
| 17 | /************************************************************************/ |
| 18 | /* OGRMSSQLSpatialLayer() */ |
| 19 | /************************************************************************/ |
| 20 | |
| 21 | OGRMSSQLSpatialLayercxx . . $ OGRMSSQLSpatialLayer#::OGRMSSQLSpatialLayercxx . . $ OGRMSSQLSpatialLayer#OGRMSSQLSpatialLayer(47a9d72c223b3598).(OGRMSSQLSpatialDataSourcecxx . . $ OGRMSSQLSpatialDataSource# *poDSIn) |
| 22 | : poDScxx . . $ OGRMSSQLSpatialLayer#poDS.(poDSIn) |
| 23 | |
| 24 | { |
| 25 | } |
| 26 | |
| 27 | /************************************************************************/ |
| 28 | /* ~OGRMSSQLSpatialLayer() */ |
| 29 | /************************************************************************/ |
| 30 | |
| 31 | OGRMSSQLSpatialLayercxx . . $ OGRMSSQLSpatialLayer#::~cxx . . $ OGRMSSQLSpatialLayer#`~OGRMSSQLSpatialLayer`(ced63f7c635d850d).OGRMSSQLSpatialLayercxx . . $ OGRMSSQLSpatialLayer#() |
| 32 | |
| 33 | { |
| 34 | if (m_nFeaturesReadcxx . . $ OGRLayer#m_nFeaturesRead. > 0 && poFeatureDefncxx . . $ OGRMSSQLSpatialLayer#poFeatureDefn. != nullptr) |
| 35 | { |
| 36 | CPLDebug("OGR_MSSQLSpatial", "%d features read on layer '%s'.", |
| 37 | static_cast<int>(m_nFeaturesReadcxx . . $ OGRLayer#m_nFeaturesRead.), poFeatureDefncxx . . $ OGRMSSQLSpatialLayer#poFeatureDefn.->GetNamecxx . . $ OGRFeatureDefn#GetName(a9f41ea0e82d88cf).()); |
| 38 | } |
| 39 | |
| 40 | ClearStatementcxx . . $ OGRMSSQLSpatialLayer#ClearStatement(49f6e7a06ebc5aa8).(); |
| 41 | |
| 42 | CPLFreecxx . . $ `port/cpl_conv.h:97:9`!(pszGeomColumncxx . . $ OGRMSSQLSpatialLayer#pszGeomColumn.); |
| 43 | CPLFreecxx . . $ `port/cpl_conv.h:97:9`!(pszFIDColumncxx . . $ OGRMSSQLSpatialLayer#pszFIDColumn.); |
| 44 | CPLFreecxx . . $ `port/cpl_conv.h:97:9`!(panFieldOrdinalscxx . . $ OGRMSSQLSpatialLayer#panFieldOrdinals.); |
| 45 | |
| 46 | if (poFeatureDefncxx . . $ OGRMSSQLSpatialLayer#poFeatureDefn.) |
| 47 | { |
| 48 | poFeatureDefncxx . . $ OGRMSSQLSpatialLayer#poFeatureDefn.->Releasecxx . . $ OGRFeatureDefn#Release(49f6e7a06ebc5aa8).(); |
| 49 | poFeatureDefncxx . . $ OGRMSSQLSpatialLayer#poFeatureDefn. = nullptr; |
| 50 | } |
| 51 | |
| 52 | if (poSRScxx . . $ OGRMSSQLSpatialLayer#poSRS.) |
| 53 | poSRScxx . . $ OGRMSSQLSpatialLayer#poSRS.->Releasecxx . . $ OGRSpatialReference#Release(49f6e7a06ebc5aa8).(); |
| 54 | } |
| 55 | |
| 56 | /************************************************************************/ |
| 57 | /* BuildFeatureDefn() */ |
| 58 | /* */ |
| 59 | /* Build feature definition from a set of column definitions */ |
| 60 | /* set on a statement. Sift out geometry and FID fields. */ |
| 61 | /************************************************************************/ |
| 62 | |
| 63 | void OGRMSSQLSpatialLayercxx . . $ OGRMSSQLSpatialLayer#::BuildFeatureDefncxx . . $ OGRMSSQLSpatialLayer#BuildFeatureDefn(eaca0ddd83674a84).(const char *pszLayerName, |
| 64 | CPLODBCStatementcxx . . $ CPLODBCStatement# *poStmtIn) |
| 65 | |
| 66 | { |
| 67 | bool bShowFidColumn = |
| 68 | CPLTestBool(CPLGetConfigOption("MSSQLSPATIAL_SHOW_FID_COLUMN", "NO")); |
| 69 | |
| 70 | if (!poFeatureDefncxx . . $ OGRMSSQLSpatialLayer#poFeatureDefn.) |
| 71 | { |
| 72 | poFeatureDefncxx . . $ OGRMSSQLSpatialLayer#poFeatureDefn. = new OGRFeatureDefncxx . . $ OGRFeatureDefn#(pszLayerName); |
| 73 | poFeatureDefncxx . . $ OGRMSSQLSpatialLayer#poFeatureDefn.->Referencecxx . . $ OGRFeatureDefn#Reference(b126dc7c1de90089).(); |
| 74 | } |
| 75 | else |
| 76 | { |
| 77 | for (int iFieldIdx = poFeatureDefncxx . . $ OGRMSSQLSpatialLayer#poFeatureDefn.->GetFieldCountcxx . . $ OGRFeatureDefn#GetFieldCount(455f465bc33b4cdf).() - 1; iFieldIdx >= 0; |
| 78 | --iFieldIdx) |
| 79 | { |
| 80 | poFeatureDefncxx . . $ OGRMSSQLSpatialLayer#poFeatureDefn.->DeleteFieldDefncxx . . $ OGRFeatureDefn#DeleteFieldDefn(7864480464b09eea).(iFieldIdx); |
| 81 | } |
| 82 | for (int iFieldIdx = poFeatureDefncxx . . $ OGRMSSQLSpatialLayer#poFeatureDefn.->GetGeomFieldCountcxx . . $ OGRFeatureDefn#GetGeomFieldCount(455f465bc33b4cdf).() - 1; |
| 83 | iFieldIdx >= 0; --iFieldIdx) |
| 84 | { |
| 85 | poFeatureDefncxx . . $ OGRMSSQLSpatialLayer#poFeatureDefn.->DeleteGeomFieldDefncxx . . $ OGRFeatureDefn#DeleteGeomFieldDefn(7864480464b09eea).(iFieldIdx); |
| 86 | } |
| 87 | poFeatureDefncxx . . $ OGRMSSQLSpatialLayer#poFeatureDefn.->SetNamecxx . . $ OGRFeatureDefn#SetName(85c52e162fed56f9).(pszLayerName); |
| 88 | } |
| 89 | |
| 90 | nRawColumnscxx . . $ OGRMSSQLSpatialLayer#nRawColumns. = poStmtIn->GetColCountcxx . . $ CPLODBCStatement#GetColCount(b126dc7c1de90089).(); |
| 91 | |
| 92 | CPLFreecxx . . $ `port/cpl_conv.h:97:9`!(panFieldOrdinalscxx . . $ OGRMSSQLSpatialLayer#panFieldOrdinals.); |
| 93 | panFieldOrdinalscxx . . $ OGRMSSQLSpatialLayer#panFieldOrdinals. = static_cast<int *>(CPLMalloc(sizeof(int) * nRawColumnscxx . . $ OGRMSSQLSpatialLayer#nRawColumns.)); |
| 94 | |
| 95 | for (int iCol = 0; iCol < nRawColumnscxx . . $ OGRMSSQLSpatialLayer#nRawColumns.; iCol++) |
| 96 | { |
| 97 | if (pszGeomColumncxx . . $ OGRMSSQLSpatialLayer#pszGeomColumn. == nullptr) |
| 98 | { |
| 99 | /* need to identify the geometry column */ |
| 100 | if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(poStmtIn->GetColTypeName(iCol), "geometry")) |
| 101 | { |
| 102 | nGeomColumnTypecxx . . $ OGRMSSQLSpatialLayer#nGeomColumnType. = MSSQLCOLTYPE_GEOMETRYcxx . . $ `ogr/ogrsf_frmts/mssqlspatial/ogr_mssqlspatial.h:44:9`!; |
| 103 | pszGeomColumncxx . . $ OGRMSSQLSpatialLayer#pszGeomColumn. = CPLStrdup(poStmtIn->GetColNamecxx . . $ CPLODBCStatement#GetColName(f7ae7e56280f18ae).(iCol)); |
| 104 | if (poFeatureDefncxx . . $ OGRMSSQLSpatialLayer#poFeatureDefn.->GetGeomFieldCountcxx . . $ OGRFeatureDefn#GetGeomFieldCount(455f465bc33b4cdf).() == 1) |
| 105 | { |
| 106 | poFeatureDefncxx . . $ OGRMSSQLSpatialLayer#poFeatureDefn.->GetGeomFieldDefncxx . . $ OGRFeatureDefn#GetGeomFieldDefn(39768c424f32bab2).(0)->SetNullablecxx . . $ OGRGeomFieldDefn#SetNullable(d4f767463ce0a6b3).( |
| 107 | poStmtIn->GetColNullablecxx . . $ CPLODBCStatement#GetColNullable(60050ad348e56ea6).(iCol)); |
| 108 | poFeatureDefncxx . . $ OGRMSSQLSpatialLayer#poFeatureDefn.->GetGeomFieldDefncxx . . $ OGRFeatureDefn#GetGeomFieldDefn(39768c424f32bab2).(0)->SetNamecxx . . $ OGRGeomFieldDefn#SetName(85c52e162fed56f9).(pszGeomColumncxx . . $ OGRMSSQLSpatialLayer#pszGeomColumn.); |
| 109 | } |
| 110 | nGeomColumnIndexcxx . . $ OGRMSSQLSpatialLayer#nGeomColumnIndex. = iCol; |
| 111 | continue; |
| 112 | } |
| 113 | else if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(poStmtIn->GetColTypeName(iCol), "geography")) |
| 114 | { |
| 115 | nGeomColumnTypecxx . . $ OGRMSSQLSpatialLayer#nGeomColumnType. = MSSQLCOLTYPE_GEOGRAPHYcxx . . $ `ogr/ogrsf_frmts/mssqlspatial/ogr_mssqlspatial.h:45:9`!; |
| 116 | pszGeomColumncxx . . $ OGRMSSQLSpatialLayer#pszGeomColumn. = CPLStrdup(poStmtIn->GetColNamecxx . . $ CPLODBCStatement#GetColName(f7ae7e56280f18ae).(iCol)); |
| 117 | if (poFeatureDefncxx . . $ OGRMSSQLSpatialLayer#poFeatureDefn.->GetGeomFieldCountcxx . . $ OGRFeatureDefn#GetGeomFieldCount(455f465bc33b4cdf).() == 1) |
| 118 | { |
| 119 | poFeatureDefncxx . . $ OGRMSSQLSpatialLayer#poFeatureDefn.->GetGeomFieldDefncxx . . $ OGRFeatureDefn#GetGeomFieldDefn(39768c424f32bab2).(0)->SetNullablecxx . . $ OGRGeomFieldDefn#SetNullable(d4f767463ce0a6b3).( |
| 120 | poStmtIn->GetColNullablecxx . . $ CPLODBCStatement#GetColNullable(60050ad348e56ea6).(iCol)); |
| 121 | poFeatureDefncxx . . $ OGRMSSQLSpatialLayer#poFeatureDefn.->GetGeomFieldDefncxx . . $ OGRFeatureDefn#GetGeomFieldDefn(39768c424f32bab2).(0)->SetNamecxx . . $ OGRGeomFieldDefn#SetName(85c52e162fed56f9).(pszGeomColumncxx . . $ OGRMSSQLSpatialLayer#pszGeomColumn.); |
| 122 | } |
| 123 | nGeomColumnIndexcxx . . $ OGRMSSQLSpatialLayer#nGeomColumnIndex. = iCol; |
| 124 | continue; |
| 125 | } |
| 126 | } |
| 127 | else |
| 128 | { |
| 129 | if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(poStmtIn->GetColName(iCol), pszGeomColumn)) |
| 130 | { |
| 131 | if (poFeatureDefncxx . . $ OGRMSSQLSpatialLayer#poFeatureDefn.->GetGeomFieldCountcxx . . $ OGRFeatureDefn#GetGeomFieldCount(455f465bc33b4cdf).() == 1) |
| 132 | { |
| 133 | poFeatureDefncxx . . $ OGRMSSQLSpatialLayer#poFeatureDefn.->GetGeomFieldDefncxx . . $ OGRFeatureDefn#GetGeomFieldDefn(39768c424f32bab2).(0)->SetNullablecxx . . $ OGRGeomFieldDefn#SetNullable(d4f767463ce0a6b3).( |
| 134 | poStmtIn->GetColNullablecxx . . $ CPLODBCStatement#GetColNullable(60050ad348e56ea6).(iCol)); |
| 135 | poFeatureDefncxx . . $ OGRMSSQLSpatialLayer#poFeatureDefn.->GetGeomFieldDefncxx . . $ OGRFeatureDefn#GetGeomFieldDefn(39768c424f32bab2).(0)->SetNamecxx . . $ OGRGeomFieldDefn#SetName(85c52e162fed56f9).(pszGeomColumncxx . . $ OGRMSSQLSpatialLayer#pszGeomColumn.); |
| 136 | } |
| 137 | nGeomColumnIndexcxx . . $ OGRMSSQLSpatialLayer#nGeomColumnIndex. = iCol; |
| 138 | continue; |
| 139 | } |
| 140 | } |
| 141 | |
| 142 | if (pszFIDColumncxx . . $ OGRMSSQLSpatialLayer#pszFIDColumn. != nullptr) |
| 143 | { |
| 144 | if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(poStmtIn->GetColName(iCol), pszFIDColumn)) |
| 145 | { |
| 146 | bool bIntegerFID = false; |
| 147 | switch (CPLODBCStatementcxx . . $ CPLODBCStatement#::GetTypeMappingcxx . . $ CPLODBCStatement#GetTypeMapping(14a1761c3ef4450f).( |
| 148 | poStmtIn->GetColTypecxx . . $ CPLODBCStatement#GetColType(60050ad348e56ea6).(iCol))) |
| 149 | { |
| 150 | case SQL_C_SSHORTcxx . . $ `<external>/17685670438680797515/sqlext.h:554:9`!: |
| 151 | case SQL_C_USHORTcxx . . $ `<external>/17685670438680797515/sqlext.h:557:9`!: |
| 152 | case SQL_C_SLONGcxx . . $ `<external>/17685670438680797515/sqlext.h:553:9`!: |
| 153 | case SQL_C_ULONGcxx . . $ `<external>/17685670438680797515/sqlext.h:556:9`!: |
| 154 | case SQL_C_SBIGINTcxx . . $ `<external>/17685670438680797515/sqlext.h:549:9`!: |
| 155 | case SQL_C_UBIGINTcxx . . $ `<external>/17685670438680797515/sqlext.h:550:9`!: |
| 156 | bIntegerFID = true; |
| 157 | break; |
| 158 | default: |
| 159 | break; |
| 160 | } |
| 161 | if (!bIntegerFID) |
| 162 | { |
| 163 | CPLDebug( |
| 164 | "MSSQL", |
| 165 | "Ignoring FID column %s as it is of non integer type", |
| 166 | pszFIDColumncxx . . $ OGRMSSQLSpatialLayer#pszFIDColumn.); |
| 167 | CPLFreecxx . . $ `port/cpl_conv.h:97:9`!(pszFIDColumncxx . . $ OGRMSSQLSpatialLayer#pszFIDColumn.); |
| 168 | pszFIDColumncxx . . $ OGRMSSQLSpatialLayer#pszFIDColumn. = nullptr; |
| 169 | } |
| 170 | else |
| 171 | { |
| 172 | if (STARTS_WITH_CIcxx . . $ `port/cpl_port.h:543:9`!(poStmtIn->GetColTypeName(iCol), |
| 173 | "bigint")) |
| 174 | SetMetadataItemcxx . . $ GDALMajorObject#SetMetadataItem(216fc8eb9053a851).(OLMD_FID64cxx . . $ `ogr/ogr_core.h:1089:9`!, "YES"); |
| 175 | |
| 176 | if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(poStmtIn->GetColTypeName(iCol), "int identity") || |
| 177 | EQUALcxx . . $ `port/cpl_port.h:532:9`!(poStmtIn->GetColTypeName(iCol), |
| 178 | "bigint identity")) |
| 179 | bIsIdentityFidcxx . . $ OGRMSSQLSpatialLayer#bIsIdentityFid. = TRUEcxx . . $ `port/cpl_port.h:1184:9`!; |
| 180 | |
| 181 | nFIDColumnIndexcxx . . $ OGRMSSQLSpatialLayer#nFIDColumnIndex. = iCol; |
| 182 | |
| 183 | if (!bShowFidColumn) |
| 184 | continue; |
| 185 | } |
| 186 | } |
| 187 | } |
| 188 | else |
| 189 | { |
| 190 | if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(poStmtIn->GetColTypeName(iCol), "int identity")) |
| 191 | { |
| 192 | pszFIDColumncxx . . $ OGRMSSQLSpatialLayer#pszFIDColumn. = CPLStrdup(poStmtIn->GetColNamecxx . . $ CPLODBCStatement#GetColName(f7ae7e56280f18ae).(iCol)); |
| 193 | bIsIdentityFidcxx . . $ OGRMSSQLSpatialLayer#bIsIdentityFid. = TRUEcxx . . $ `port/cpl_port.h:1184:9`!; |
| 194 | nFIDColumnIndexcxx . . $ OGRMSSQLSpatialLayer#nFIDColumnIndex. = iCol; |
| 195 | |
| 196 | if (!bShowFidColumn) |
| 197 | continue; |
| 198 | } |
| 199 | else if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(poStmtIn->GetColTypeName(iCol), "bigint identity")) |
| 200 | { |
| 201 | pszFIDColumncxx . . $ OGRMSSQLSpatialLayer#pszFIDColumn. = CPLStrdup(poStmtIn->GetColNamecxx . . $ CPLODBCStatement#GetColName(f7ae7e56280f18ae).(iCol)); |
| 202 | bIsIdentityFidcxx . . $ OGRMSSQLSpatialLayer#bIsIdentityFid. = TRUEcxx . . $ `port/cpl_port.h:1184:9`!; |
| 203 | SetMetadataItemcxx . . $ GDALMajorObject#SetMetadataItem(216fc8eb9053a851).(OLMD_FID64cxx . . $ `ogr/ogr_core.h:1089:9`!, "YES"); |
| 204 | nFIDColumnIndexcxx . . $ OGRMSSQLSpatialLayer#nFIDColumnIndex. = iCol; |
| 205 | |
| 206 | if (!bShowFidColumn) |
| 207 | continue; |
| 208 | } |
| 209 | } |
| 210 | |
| 211 | OGRFieldDefncxx . . $ OGRFieldDefn# oFieldcxx . . $ OGRFieldDefn#OGRFieldDefn(786ecb48a0b3b841).(poStmtIn->GetColNamecxx . . $ CPLODBCStatement#GetColName(f7ae7e56280f18ae).(iCol), OFTString); |
| 212 | |
| 213 | switch (CPLODBCStatementcxx . . $ CPLODBCStatement#::GetTypeMappingcxx . . $ CPLODBCStatement#GetTypeMapping(14a1761c3ef4450f).(poStmtIn->GetColTypecxx . . $ CPLODBCStatement#GetColType(60050ad348e56ea6).(iCol))) |
| 214 | { |
| 215 | case SQL_C_SSHORTcxx . . $ `<external>/17685670438680797515/sqlext.h:554:9`!: |
| 216 | oField.SetTypecxx . . $ OGRFieldDefn#SetType(cc683e085121359d).(OFTInteger); |
| 217 | oField.SetSubTypecxx . . $ OGRFieldDefn#SetSubType(89cba9d8fed1b3f9).(OFSTInt16); |
| 218 | break; |
| 219 | |
| 220 | case SQL_C_USHORTcxx . . $ `<external>/17685670438680797515/sqlext.h:557:9`!: |
| 221 | case SQL_C_SLONGcxx . . $ `<external>/17685670438680797515/sqlext.h:553:9`!: |
| 222 | case SQL_C_ULONGcxx . . $ `<external>/17685670438680797515/sqlext.h:556:9`!: |
| 223 | oField.SetTypecxx . . $ OGRFieldDefn#SetType(cc683e085121359d).(OFTInteger); |
| 224 | break; |
| 225 | |
| 226 | case SQL_C_SBIGINTcxx . . $ `<external>/17685670438680797515/sqlext.h:549:9`!: |
| 227 | case SQL_C_UBIGINTcxx . . $ `<external>/17685670438680797515/sqlext.h:550:9`!: |
| 228 | oField.SetTypecxx . . $ OGRFieldDefn#SetType(cc683e085121359d).(OFTInteger64); |
| 229 | break; |
| 230 | |
| 231 | case SQL_C_BINARYcxx . . $ `<external>/17685670438680797515/sqlext.h:546:9`!: |
| 232 | oField.SetTypecxx . . $ OGRFieldDefn#SetType(cc683e085121359d).(OFTBinary); |
| 233 | oField.SetWidthcxx . . $ OGRFieldDefn#SetWidth(d4f767463ce0a6b3).(stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).<int>(0, poStmtIn->GetColSizecxx . . $ CPLODBCStatement#GetColSize(60050ad348e56ea6).(iCol))); |
| 234 | break; |
| 235 | |
| 236 | case SQL_C_NUMERICcxx . . $ `<external>/17685670438680797515/sqlext.h:517:9`!: |
| 237 | oField.SetTypecxx . . $ OGRFieldDefn#SetType(cc683e085121359d).(OFTReal); |
| 238 | oField.SetPrecisioncxx . . $ OGRFieldDefn#SetPrecision(d4f767463ce0a6b3).(poStmtIn->GetColPrecisioncxx . . $ CPLODBCStatement#GetColPrecision(60050ad348e56ea6).(iCol)); |
| 239 | oField.SetWidthcxx . . $ OGRFieldDefn#SetWidth(d4f767463ce0a6b3).(stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).<int>(0, poStmtIn->GetColSizecxx . . $ CPLODBCStatement#GetColSize(60050ad348e56ea6).(iCol))); |
| 240 | if (oField.GetPrecisioncxx . . $ OGRFieldDefn#GetPrecision(455f465bc33b4cdf).() == 0 && oField.GetWidthcxx . . $ OGRFieldDefn#GetWidth(455f465bc33b4cdf).() <= 9) |
| 241 | oField.SetTypecxx . . $ OGRFieldDefn#SetType(cc683e085121359d).(OFTInteger); |
| 242 | else if (oField.GetPrecisioncxx . . $ OGRFieldDefn#GetPrecision(455f465bc33b4cdf).() == 0 && oField.GetWidthcxx . . $ OGRFieldDefn#GetWidth(455f465bc33b4cdf).() <= 18) |
| 243 | oField.SetTypecxx . . $ OGRFieldDefn#SetType(cc683e085121359d).(OFTInteger64); |
| 244 | break; |
| 245 | |
| 246 | case SQL_C_FLOATcxx . . $ `<external>/17685670438680797515/sqlext.h:514:9`!: |
| 247 | oField.SetTypecxx . . $ OGRFieldDefn#SetType(cc683e085121359d).(OFTReal); |
| 248 | oField.SetSubTypecxx . . $ OGRFieldDefn#SetSubType(89cba9d8fed1b3f9).(OFSTFloat32); |
| 249 | break; |
| 250 | |
| 251 | case SQL_C_DOUBLEcxx . . $ `<external>/17685670438680797515/sqlext.h:515:9`!: |
| 252 | oField.SetTypecxx . . $ OGRFieldDefn#SetType(cc683e085121359d).(OFTReal); |
| 253 | break; |
| 254 | |
| 255 | case SQL_C_DATEcxx . . $ `<external>/17685670438680797515/sqlext.h:525:9`!: |
| 256 | oField.SetTypecxx . . $ OGRFieldDefn#SetType(cc683e085121359d).(OFTDate); |
| 257 | break; |
| 258 | |
| 259 | case SQL_C_TIMEcxx . . $ `<external>/17685670438680797515/sqlext.h:526:9`!: |
| 260 | oField.SetTypecxx . . $ OGRFieldDefn#SetType(cc683e085121359d).(OFTTime); |
| 261 | break; |
| 262 | |
| 263 | case SQL_C_TIMESTAMPcxx . . $ `<external>/17685670438680797515/sqlext.h:527:9`!: |
| 264 | oField.SetTypecxx . . $ OGRFieldDefn#SetType(cc683e085121359d).(OFTDateTime); |
| 265 | break; |
| 266 | |
| 267 | case SQL_C_GUIDcxx . . $ `<external>/17685670438680797515/sqlext.h:567:9`!: |
| 268 | m_bHasUUIDColumncxx . . $ OGRMSSQLSpatialLayer#m_bHasUUIDColumn. = true; |
| 269 | oField.SetTypecxx . . $ OGRFieldDefn#SetType(cc683e085121359d).(OFTString); |
| 270 | oField.SetSubTypecxx . . $ OGRFieldDefn#SetSubType(89cba9d8fed1b3f9).(OFSTUUID); |
| 271 | break; |
| 272 | |
| 273 | default: |
| 274 | oField.SetWidthcxx . . $ OGRFieldDefn#SetWidth(d4f767463ce0a6b3).(stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).<int>(0, poStmtIn->GetColSizecxx . . $ CPLODBCStatement#GetColSize(60050ad348e56ea6).(iCol))); |
| 275 | /* leave it as OFTString */; |
| 276 | } |
| 277 | |
| 278 | oField.SetNullablecxx . . $ OGRFieldDefn#SetNullable(d4f767463ce0a6b3).(poStmtIn->GetColNullablecxx . . $ CPLODBCStatement#GetColNullable(60050ad348e56ea6).(iCol)); |
| 279 | |
| 280 | if (poStmtIn->GetColColumnDefcxx . . $ CPLODBCStatement#GetColColumnDef(f7ae7e56280f18ae).(iCol)) |
| 281 | { |
| 282 | /* process default value specification */ |
| 283 | if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(poStmtIn->GetColColumnDef(iCol), "(getdate())")) |
| 284 | oField.SetDefaultcxx . . $ OGRFieldDefn#SetDefault(85c52e162fed56f9).("CURRENT_TIMESTAMP"); |
| 285 | else if (STARTS_WITH_CIcxx . . $ `port/cpl_port.h:543:9`!(poStmtIn->GetColColumnDef(iCol), |
| 286 | "(CONVERT([time],getdate()")) |
| 287 | oField.SetDefaultcxx . . $ OGRFieldDefn#SetDefault(85c52e162fed56f9).("CURRENT_TIME"); |
| 288 | else if (STARTS_WITH_CIcxx . . $ `port/cpl_port.h:543:9`!(poStmtIn->GetColColumnDef(iCol), |
| 289 | "(CONVERT([date],getdate()")) |
| 290 | oField.SetDefaultcxx . . $ OGRFieldDefn#SetDefault(85c52e162fed56f9).("CURRENT_DATE"); |
| 291 | else |
| 292 | { |
| 293 | char *pszDefault = CPLStrdup(poStmtIn->GetColColumnDefcxx . . $ CPLODBCStatement#GetColColumnDef(f7ae7e56280f18ae).(iCol)); |
| 294 | int nLen = static_cast<int>(strlen(pszDefault)); |
| 295 | if (nLen >= 1 && pszDefault[0] == '(' && |
| 296 | pszDefault[nLen - 1] == ')') |
| 297 | { |
| 298 | // All default values are encapsulated in brackets |
| 299 | // by MSSQL server. |
| 300 | if (nLen >= 4 && pszDefault[1] == '(' && |
| 301 | pszDefault[nLen - 2] == ')') |
| 302 | { |
| 303 | /* for numeric values double brackets are used */ |
| 304 | pszDefault[nLen - 2] = '\0'; |
| 305 | oField.SetDefaultcxx . . $ OGRFieldDefn#SetDefault(85c52e162fed56f9).(pszDefault + 2); |
| 306 | } |
| 307 | else |
| 308 | { |
| 309 | pszDefault[nLen - 1] = '\0'; |
| 310 | oField.SetDefaultcxx . . $ OGRFieldDefn#SetDefault(85c52e162fed56f9).(pszDefault + 1); |
| 311 | } |
| 312 | } |
| 313 | else |
| 314 | oField.SetDefaultcxx . . $ OGRFieldDefn#SetDefault(85c52e162fed56f9).(pszDefault); |
| 315 | |
| 316 | CPLFreecxx . . $ `port/cpl_conv.h:97:9`!(pszDefault); |
| 317 | } |
| 318 | } |
| 319 | |
| 320 | poFeatureDefncxx . . $ OGRMSSQLSpatialLayer#poFeatureDefn.->AddFieldDefncxx . . $ OGRFeatureDefn#AddFieldDefn(f8bad7d30df65bbb).(&oField); |
| 321 | panFieldOrdinalscxx . . $ OGRMSSQLSpatialLayer#panFieldOrdinals.[poFeatureDefncxx . . $ OGRMSSQLSpatialLayer#poFeatureDefn.->GetFieldCountcxx . . $ OGRFeatureDefn#GetFieldCount(455f465bc33b4cdf).() - 1] = iCol; |
| 322 | } |
| 323 | |
| 324 | /* -------------------------------------------------------------------- */ |
| 325 | /* If we don't already have an FID, check if there is a special */ |
| 326 | /* FID named column available. */ |
| 327 | /* -------------------------------------------------------------------- */ |
| 328 | if (pszFIDColumncxx . . $ OGRMSSQLSpatialLayer#pszFIDColumn. == nullptr) |
| 329 | { |
| 330 | const char *pszOGR_FID = |
| 331 | CPLGetConfigOption("MSSQLSPATIAL_OGR_FID", "OGR_FID"); |
| 332 | if (poFeatureDefncxx . . $ OGRMSSQLSpatialLayer#poFeatureDefn.->GetFieldIndexcxx . . $ OGRFeatureDefn#GetFieldIndex(78f035161ffa9fe2).(pszOGR_FID) != -1) |
| 333 | pszFIDColumncxx . . $ OGRMSSQLSpatialLayer#pszFIDColumn. = CPLStrdup(pszOGR_FID); |
| 334 | } |
| 335 | |
| 336 | if (pszFIDColumncxx . . $ OGRMSSQLSpatialLayer#pszFIDColumn. != nullptr) |
| 337 | CPLDebug("OGR_MSSQLSpatial", "Using column %s as FID for table %s.", |
| 338 | pszFIDColumncxx . . $ OGRMSSQLSpatialLayer#pszFIDColumn., poFeatureDefncxx . . $ OGRMSSQLSpatialLayer#poFeatureDefn.->GetNamecxx . . $ OGRFeatureDefn#GetName(a9f41ea0e82d88cf).()); |
| 339 | else |
| 340 | CPLDebug("OGR_MSSQLSpatial", "Table %s has no identified FID column.", |
| 341 | poFeatureDefncxx . . $ OGRMSSQLSpatialLayer#poFeatureDefn.->GetNamecxx . . $ OGRFeatureDefn#GetName(a9f41ea0e82d88cf).()); |
| 342 | } |
| 343 | |
| 344 | /************************************************************************/ |
| 345 | /* ClearStatement() */ |
| 346 | /************************************************************************/ |
| 347 | |
| 348 | void OGRMSSQLSpatialLayercxx . . $ OGRMSSQLSpatialLayer#::ClearStatementcxx . . $ OGRMSSQLSpatialLayer#ClearStatement(49f6e7a06ebc5aa8).() |
| 349 | |
| 350 | { |
| 351 | if (poStmtcxx . . $ OGRMSSQLSpatialLayer#poStmt. != nullptr) |
| 352 | { |
| 353 | delete poStmtcxx . . $ OGRMSSQLSpatialLayer#poStmt.; |
| 354 | poStmtcxx . . $ OGRMSSQLSpatialLayer#poStmt. = nullptr; |
| 355 | } |
| 356 | } |
| 357 | |
| 358 | /************************************************************************/ |
| 359 | /* ResetReading() */ |
| 360 | /************************************************************************/ |
| 361 | |
| 362 | void OGRMSSQLSpatialLayercxx . . $ OGRMSSQLSpatialLayer#::ResetReadingcxx . . $ OGRMSSQLSpatialLayer#ResetReading(49f6e7a06ebc5aa8).() |
| 363 | |
| 364 | { |
| 365 | if (m_bResetNeededcxx . . $ OGRMSSQLSpatialLayer#m_bResetNeeded.) |
| 366 | { |
| 367 | iNextShapeIdcxx . . $ OGRMSSQLSpatialLayer#iNextShapeId. = 0; |
| 368 | ClearStatementcxx . . $ OGRMSSQLSpatialLayer#ClearStatement(49f6e7a06ebc5aa8).(); |
| 369 | m_bEOFcxx . . $ OGRMSSQLSpatialLayer#m_bEOF. = false; |
| 370 | m_bResetNeededcxx . . $ OGRMSSQLSpatialLayer#m_bResetNeeded. = false; |
| 371 | } |
| 372 | } |
| 373 | |
| 374 | /************************************************************************/ |
| 375 | /* GetNextFeature() */ |
| 376 | /************************************************************************/ |
| 377 | |
| 378 | OGRFeaturecxx . . $ OGRFeature# *OGRMSSQLSpatialLayercxx . . $ OGRMSSQLSpatialLayer#::GetNextFeaturecxx . . $ OGRMSSQLSpatialLayer#GetNextFeature(ec9eceddec1d9563).() |
| 379 | |
| 380 | { |
| 381 | if (m_bEOFcxx . . $ OGRMSSQLSpatialLayer#m_bEOF.) |
| 382 | return nullptr; |
| 383 | |
| 384 | while (true) |
| 385 | { |
| 386 | OGRFeaturecxx . . $ OGRFeature# *poFeature; |
| 387 | |
| 388 | poFeature = GetNextRawFeaturecxx . . $ OGRMSSQLSpatialLayer#GetNextRawFeature(ec9eceddec1d9563).(); |
| 389 | if (poFeature == nullptr) |
| 390 | { |
| 391 | m_bEOFcxx . . $ OGRMSSQLSpatialLayer#m_bEOF. = true; |
| 392 | return nullptr; |
| 393 | } |
| 394 | |
| 395 | if ((m_poFilterGeomcxx . . $ OGRLayer#m_poFilterGeom. == nullptr || |
| 396 | FilterGeometrycxx . . $ OGRLayer#FilterGeometry(fed901b2566802ff).(poFeature->GetGeometryRefcxx . . $ OGRFeature#GetGeometryRef(3dfc1d32c7db2584).())) && |
| 397 | (m_poAttrQuerycxx . . $ OGRLayer#m_poAttrQuery. == nullptr || m_poAttrQuerycxx . . $ OGRLayer#m_poAttrQuery.->Evaluatecxx . . $ OGRFeatureQuery#Evaluate(2048609adab03aab).(poFeature))) |
| 398 | return poFeature; |
| 399 | |
| 400 | delete poFeature; |
| 401 | } |
| 402 | } |
| 403 | |
| 404 | /************************************************************************/ |
| 405 | /* GetNextRawFeature() */ |
| 406 | /************************************************************************/ |
| 407 | |
| 408 | OGRFeaturecxx . . $ OGRFeature# *OGRMSSQLSpatialLayercxx . . $ OGRMSSQLSpatialLayer#::GetNextRawFeaturecxx . . $ OGRMSSQLSpatialLayer#GetNextRawFeature(ec9eceddec1d9563).() |
| 409 | |
| 410 | { |
| 411 | m_bResetNeededcxx . . $ OGRMSSQLSpatialLayer#m_bResetNeeded. = true; |
| 412 | if (GetStatementcxx . . $ OGRMSSQLSpatialLayer#GetStatement(5b19ef686033c18a).() == nullptr) |
| 413 | return nullptr; |
| 414 | |
| 415 | /* -------------------------------------------------------------------- */ |
| 416 | /* If we are marked to restart then do so, and fetch a record. */ |
| 417 | /* -------------------------------------------------------------------- */ |
| 418 | if (!poStmtcxx . . $ OGRMSSQLSpatialLayer#poStmt.->Fetchcxx . . $ CPLODBCStatement#Fetch(9b79fb6aee4c0440).()) |
| 419 | { |
| 420 | delete poStmtcxx . . $ OGRMSSQLSpatialLayer#poStmt.; |
| 421 | poStmtcxx . . $ OGRMSSQLSpatialLayer#poStmt. = nullptr; |
| 422 | return nullptr; |
| 423 | } |
| 424 | |
| 425 | /* -------------------------------------------------------------------- */ |
| 426 | /* Create a feature from the current result. */ |
| 427 | /* -------------------------------------------------------------------- */ |
| 428 | OGRFeaturecxx . . $ OGRFeature# *poFeature = new OGRFeaturecxx . . $ OGRFeature#OGRFeature(dc2636911e7adfe).(poFeatureDefncxx . . $ OGRMSSQLSpatialLayer#poFeatureDefn.); |
| 429 | |
| 430 | const char *pszFID; |
| 431 | if (pszFIDColumncxx . . $ OGRMSSQLSpatialLayer#pszFIDColumn. != nullptr && poStmtcxx . . $ OGRMSSQLSpatialLayer#poStmt.->GetColIdcxx . . $ CPLODBCStatement#GetColId(78f035161ffa9fe2).(pszFIDColumncxx . . $ OGRMSSQLSpatialLayer#pszFIDColumn.) > -1 && |
| 432 | (pszFID = poStmtcxx . . $ OGRMSSQLSpatialLayer#poStmt.->GetColDatacxx . . $ CPLODBCStatement#GetColData(75c700d7e7a896fe).(poStmtcxx . . $ OGRMSSQLSpatialLayer#poStmt.->GetColIdcxx . . $ CPLODBCStatement#GetColId(78f035161ffa9fe2).(pszFIDColumncxx . . $ OGRMSSQLSpatialLayer#pszFIDColumn.))) != |
| 433 | nullptr) |
| 434 | poFeature->SetFIDcxx . . $ OGRFeature#SetFID(a070d6d14e988596).(CPLAtoGIntBig(pszFID)); |
| 435 | else |
| 436 | poFeature->SetFIDcxx . . $ OGRFeature#SetFID(a070d6d14e988596).(iNextShapeIdcxx . . $ OGRMSSQLSpatialLayer#iNextShapeId.); |
| 437 | |
| 438 | iNextShapeIdcxx . . $ OGRMSSQLSpatialLayer#iNextShapeId.++; |
| 439 | m_nFeaturesReadcxx . . $ OGRLayer#m_nFeaturesRead.++; |
| 440 | |
| 441 | /* -------------------------------------------------------------------- */ |
| 442 | /* Set the fields. */ |
| 443 | /* -------------------------------------------------------------------- */ |
| 444 | for (int iField = 0; iField < poFeatureDefncxx . . $ OGRMSSQLSpatialLayer#poFeatureDefn.->GetFieldCountcxx . . $ OGRFeatureDefn#GetFieldCount(455f465bc33b4cdf).(); iField++) |
| 445 | { |
| 446 | if (poFeatureDefncxx . . $ OGRMSSQLSpatialLayer#poFeatureDefn.->GetFieldDefncxx . . $ OGRFeatureDefn#GetFieldDefn(2ec36f91b6ceefc7).(iField)->IsIgnoredcxx . . $ OGRFieldDefn#IsIgnored(455f465bc33b4cdf).()) |
| 447 | continue; |
| 448 | |
| 449 | int iSrcField = panFieldOrdinalscxx . . $ OGRMSSQLSpatialLayer#panFieldOrdinals.[iField]; |
| 450 | const char *pszValue = poStmtcxx . . $ OGRMSSQLSpatialLayer#poStmt.->GetColDatacxx . . $ CPLODBCStatement#GetColData(75c700d7e7a896fe).(iSrcField); |
| 451 | |
| 452 | if (pszValue == nullptr) |
| 453 | poFeature->SetFieldNullcxx . . $ OGRFeature#SetFieldNull(d4f767463ce0a6b3).(iField); |
| 454 | else if (poFeature->GetFieldDefnRefcxx . . $ OGRFeature#GetFieldDefnRef(53a8093e6b73def).(iField)->GetTypecxx . . $ OGRFieldDefn#GetType(b365ab774e05458e).() == OFTBinary) |
| 455 | poFeature->SetFieldcxx . . $ OGRFeature#SetField(fa49024a5dd9af3b).(iField, poStmtcxx . . $ OGRMSSQLSpatialLayer#poStmt.->GetColDataLengthcxx . . $ CPLODBCStatement#GetColDataLength(7864480464b09eea).(iSrcField), |
| 456 | reinterpret_cast<const GBytecxx . . $ GByte# *>(pszValue)); |
| 457 | else |
| 458 | poFeature->SetFieldcxx . . $ OGRFeature#SetField(66835f578de1bcb3).(iField, pszValue); |
| 459 | } |
| 460 | |
| 461 | /* -------------------------------------------------------------------- */ |
| 462 | /* Try to extract a geometry. */ |
| 463 | /* -------------------------------------------------------------------- */ |
| 464 | if (pszGeomColumncxx . . $ OGRMSSQLSpatialLayer#pszGeomColumn. != nullptr && !poFeatureDefncxx . . $ OGRMSSQLSpatialLayer#poFeatureDefn.->IsGeometryIgnoredcxx . . $ OGRFeatureDefn#IsGeometryIgnored(455f465bc33b4cdf).()) |
| 465 | { |
| 466 | int iField = poStmtcxx . . $ OGRMSSQLSpatialLayer#poStmt.->GetColIdcxx . . $ CPLODBCStatement#GetColId(78f035161ffa9fe2).(pszGeomColumncxx . . $ OGRMSSQLSpatialLayer#pszGeomColumn.); |
| 467 | const char *pszGeomText = poStmtcxx . . $ OGRMSSQLSpatialLayer#poStmt.->GetColDatacxx . . $ CPLODBCStatement#GetColData(75c700d7e7a896fe).(iField); |
| 468 | OGRGeometrycxx . . $ OGRGeometry# *poGeom = nullptr; |
| 469 | OGRErr eErr = OGRERR_NONEcxx . . $ `ogr/ogr_core.h:390:9`!; |
| 470 | |
| 471 | if (pszGeomText != nullptr) |
| 472 | { |
| 473 | int nLength = poStmtcxx . . $ OGRMSSQLSpatialLayer#poStmt.->GetColDataLengthcxx . . $ CPLODBCStatement#GetColDataLength(7864480464b09eea).(iField); |
| 474 | |
| 475 | if (nGeomColumnTypecxx . . $ OGRMSSQLSpatialLayer#nGeomColumnType. == MSSQLCOLTYPE_GEOMETRYcxx . . $ `ogr/ogrsf_frmts/mssqlspatial/ogr_mssqlspatial.h:44:9`! || |
| 476 | nGeomColumnTypecxx . . $ OGRMSSQLSpatialLayer#nGeomColumnType. == MSSQLCOLTYPE_GEOGRAPHYcxx . . $ `ogr/ogrsf_frmts/mssqlspatial/ogr_mssqlspatial.h:45:9`! || |
| 477 | nGeomColumnTypecxx . . $ OGRMSSQLSpatialLayer#nGeomColumnType. == MSSQLCOLTYPE_BINARYcxx . . $ `ogr/ogrsf_frmts/mssqlspatial/ogr_mssqlspatial.h:46:9`!) |
| 478 | { |
| 479 | switch (poDScxx . . $ OGRMSSQLSpatialLayer#poDS.->GetGeometryFormatcxx . . $ OGRMSSQLSpatialDataSource#GetGeometryFormat(b126dc7c1de90089).()) |
| 480 | { |
| 481 | case MSSQLGEOMETRY_NATIVEcxx . . $ `ogr/ogrsf_frmts/mssqlspatial/ogr_mssqlspatial.h:38:9`!: |
| 482 | { |
| 483 | OGRMSSQLGeometryParsercxx . . $ OGRMSSQLGeometryParser# oParsercxx . . $ OGRMSSQLGeometryParser#OGRMSSQLGeometryParser(d4f767463ce0a6b3).(nGeomColumnTypecxx . . $ OGRMSSQLSpatialLayer#nGeomColumnType.); |
| 484 | eErr = oParser.ParseSqlGeometrycxx . . $ OGRMSSQLGeometryParser#ParseSqlGeometry(96f7aed9b94ceb41).( |
| 485 | reinterpret_cast<const unsigned char *>( |
| 486 | pszGeomText), |
| 487 | nLength, &poGeom); |
| 488 | nSRSIdcxx . . $ OGRMSSQLSpatialLayer#nSRSId. = oParser.GetSRSIdcxx . . $ OGRMSSQLGeometryParser#GetSRSId(b126dc7c1de90089).(); |
| 489 | } |
| 490 | break; |
| 491 | case MSSQLGEOMETRY_WKBcxx . . $ `ogr/ogrsf_frmts/mssqlspatial/ogr_mssqlspatial.h:39:9`!: |
| 492 | case MSSQLGEOMETRY_WKBZMcxx . . $ `ogr/ogrsf_frmts/mssqlspatial/ogr_mssqlspatial.h:41:9`!: |
| 493 | eErr = OGRGeometryFactorycxx . . $ OGRGeometryFactory#::createFromWkbcxx . . $ OGRGeometryFactory#createFromWkb(7c877ec657b71ad6).( |
| 494 | pszGeomText, nullptr, &poGeom, nLength); |
| 495 | break; |
| 496 | case MSSQLGEOMETRY_WKTcxx . . $ `ogr/ogrsf_frmts/mssqlspatial/ogr_mssqlspatial.h:40:9`!: |
| 497 | eErr = OGRGeometryFactorycxx . . $ OGRGeometryFactory#::createFromWktcxx . . $ OGRGeometryFactory#createFromWkt(804c4203ca576ed8).( |
| 498 | pszGeomText, nullptr, &poGeom); |
| 499 | break; |
| 500 | } |
| 501 | } |
| 502 | else if (nGeomColumnTypecxx . . $ OGRMSSQLSpatialLayer#nGeomColumnType. == MSSQLCOLTYPE_TEXTcxx . . $ `ogr/ogrsf_frmts/mssqlspatial/ogr_mssqlspatial.h:47:9`!) |
| 503 | { |
| 504 | eErr = OGRGeometryFactorycxx . . $ OGRGeometryFactory#::createFromWktcxx . . $ OGRGeometryFactory#createFromWkt(804c4203ca576ed8).(pszGeomText, nullptr, |
| 505 | &poGeom); |
| 506 | } |
| 507 | } |
| 508 | |
| 509 | if (eErr != OGRERR_NONEcxx . . $ `ogr/ogr_core.h:390:9`!) |
| 510 | { |
| 511 | const char *pszMessage; |
| 512 | |
| 513 | switch (eErr) |
| 514 | { |
| 515 | case OGRERR_NOT_ENOUGH_DATAcxx . . $ `ogr/ogr_core.h:391:9`!: |
| 516 | pszMessage = "Not enough data to deserialize"; |
| 517 | break; |
| 518 | case OGRERR_UNSUPPORTED_GEOMETRY_TYPEcxx . . $ `ogr/ogr_core.h:393:9`!: |
| 519 | pszMessage = "Unsupported geometry type"; |
| 520 | break; |
| 521 | case OGRERR_CORRUPT_DATAcxx . . $ `ogr/ogr_core.h:395:9`!: |
| 522 | pszMessage = "Corrupt data"; |
| 523 | break; |
| 524 | default: |
| 525 | pszMessage = "Unrecognized error"; |
| 526 | } |
| 527 | CPLError(CE_Failure, CPLE_AppDefinedcxx . . $ `port/cpl_error.h:108:9`!, "GetNextRawFeature(): %s", |
| 528 | pszMessage); |
| 529 | } |
| 530 | |
| 531 | if (poGeom != nullptr) |
| 532 | { |
| 533 | if (GetSpatialRefcxx . . $ OGRMSSQLSpatialLayer#GetSpatialRef(8a5496c2eeefaeaf).()) |
| 534 | poGeom->assignSpatialReferencecxx . . $ OGRGeometry#assignSpatialReference(9ff39b79387a6086).(poSRScxx . . $ OGRMSSQLSpatialLayer#poSRS.); |
| 535 | |
| 536 | poFeature->SetGeometryDirectlycxx . . $ OGRFeature#SetGeometryDirectly(cec3429dca426eb8).(poGeom); |
| 537 | } |
| 538 | } |
| 539 | |
| 540 | return poFeature; |
| 541 | } |
| 542 | |
| 543 | /************************************************************************/ |
| 544 | /* GetFeature() */ |
| 545 | /************************************************************************/ |
| 546 | |
| 547 | OGRFeaturecxx . . $ OGRFeature# *OGRMSSQLSpatialLayercxx . . $ OGRMSSQLSpatialLayer#::GetFeaturecxx . . $ OGRMSSQLSpatialLayer#GetFeature(86ac52c37891ada7).(GIntBigcxx . . $ GIntBig# nFeatureId) |
| 548 | |
| 549 | { |
| 550 | /* This should be implemented directly! */ |
| 551 | |
| 552 | return OGRLayercxx . . $ OGRLayer#::GetFeaturecxx . . $ OGRLayer#GetFeature(86ac52c37891ada7).(nFeatureId); |
| 553 | } |
| 554 | |
| 555 | /************************************************************************/ |
| 556 | /* TestCapability() */ |
| 557 | /************************************************************************/ |
| 558 | |
| 559 | int OGRMSSQLSpatialLayercxx . . $ OGRMSSQLSpatialLayer#::TestCapabilitycxx . . $ OGRMSSQLSpatialLayer#TestCapability(78f035161ffa9fe2).(const char *) const |
| 560 | { |
| 561 | return FALSEcxx . . $ `port/cpl_port.h:1180:9`!; |
| 562 | } |
| 563 | |
| 564 | /************************************************************************/ |
| 565 | /* StartTransaction() */ |
| 566 | /************************************************************************/ |
| 567 | |
| 568 | OGRErr OGRMSSQLSpatialLayercxx . . $ OGRMSSQLSpatialLayer#::StartTransactioncxx . . $ OGRMSSQLSpatialLayer#StartTransaction(b126dc7c1de90089).() |
| 569 | |
| 570 | { |
| 571 | if (!poDScxx . . $ OGRMSSQLSpatialLayer#poDS.->GetSessioncxx . . $ OGRMSSQLSpatialDataSource#GetSession(c2971156c0911dd3).()->BeginTransactioncxx . . $ CPLODBCSession#BeginTransaction(b126dc7c1de90089).()) |
| 572 | { |
| 573 | CPLError(CE_Failure, CPLE_AppDefinedcxx . . $ `port/cpl_error.h:108:9`!, "Failed to start transaction: %s", |
| 574 | poDScxx . . $ OGRMSSQLSpatialLayer#poDS.->GetSessioncxx . . $ OGRMSSQLSpatialDataSource#GetSession(c2971156c0911dd3).()->GetLastErrorcxx . . $ CPLODBCSession#GetLastError(33a1f659e94feb42).()); |
| 575 | return OGRERR_FAILUREcxx . . $ `ogr/ogr_core.h:396:9`!; |
| 576 | } |
| 577 | return OGRERR_NONEcxx . . $ `ogr/ogr_core.h:390:9`!; |
| 578 | } |
| 579 | |
| 580 | /************************************************************************/ |
| 581 | /* CommitTransaction() */ |
| 582 | /************************************************************************/ |
| 583 | |
| 584 | OGRErr OGRMSSQLSpatialLayercxx . . $ OGRMSSQLSpatialLayer#::CommitTransactioncxx . . $ OGRMSSQLSpatialLayer#CommitTransaction(b126dc7c1de90089).() |
| 585 | |
| 586 | { |
| 587 | if (!poDScxx . . $ OGRMSSQLSpatialLayer#poDS.->GetSessioncxx . . $ OGRMSSQLSpatialDataSource#GetSession(c2971156c0911dd3).()->CommitTransactioncxx . . $ CPLODBCSession#CommitTransaction(b126dc7c1de90089).()) |
| 588 | { |
| 589 | CPLError(CE_Failure, CPLE_AppDefinedcxx . . $ `port/cpl_error.h:108:9`!, |
| 590 | "Failed to commit transaction: %s", |
| 591 | poDScxx . . $ OGRMSSQLSpatialLayer#poDS.->GetSessioncxx . . $ OGRMSSQLSpatialDataSource#GetSession(c2971156c0911dd3).()->GetLastErrorcxx . . $ CPLODBCSession#GetLastError(33a1f659e94feb42).()); |
| 592 | return OGRERR_FAILUREcxx . . $ `ogr/ogr_core.h:396:9`!; |
| 593 | } |
| 594 | return OGRERR_NONEcxx . . $ `ogr/ogr_core.h:390:9`!; |
| 595 | } |
| 596 | |
| 597 | /************************************************************************/ |
| 598 | /* RollbackTransaction() */ |
| 599 | /************************************************************************/ |
| 600 | |
| 601 | OGRErr OGRMSSQLSpatialLayercxx . . $ OGRMSSQLSpatialLayer#::RollbackTransactioncxx . . $ OGRMSSQLSpatialLayer#RollbackTransaction(b126dc7c1de90089).() |
| 602 | |
| 603 | { |
| 604 | if (!poDScxx . . $ OGRMSSQLSpatialLayer#poDS.->GetSessioncxx . . $ OGRMSSQLSpatialDataSource#GetSession(c2971156c0911dd3).()->RollbackTransactioncxx . . $ CPLODBCSession#RollbackTransaction(b126dc7c1de90089).()) |
| 605 | { |
| 606 | CPLError(CE_Failure, CPLE_AppDefinedcxx . . $ `port/cpl_error.h:108:9`!, |
| 607 | "Failed to roll back transaction: %s", |
| 608 | poDScxx . . $ OGRMSSQLSpatialLayer#poDS.->GetSessioncxx . . $ OGRMSSQLSpatialDataSource#GetSession(c2971156c0911dd3).()->GetLastErrorcxx . . $ CPLODBCSession#GetLastError(33a1f659e94feb42).()); |
| 609 | return OGRERR_FAILUREcxx . . $ `ogr/ogr_core.h:396:9`!; |
| 610 | } |
| 611 | return OGRERR_NONEcxx . . $ `ogr/ogr_core.h:390:9`!; |
| 612 | } |
| 613 | |
| 614 | /************************************************************************/ |
| 615 | /* GetSpatialRef() */ |
| 616 | /************************************************************************/ |
| 617 | |
| 618 | const OGRSpatialReferencecxx . . $ OGRSpatialReference# *OGRMSSQLSpatialLayercxx . . $ OGRMSSQLSpatialLayer#::GetSpatialRefcxx . . $ OGRMSSQLSpatialLayer#GetSpatialRef(8a5496c2eeefaeaf).() const |
| 619 | |
| 620 | { |
| 621 | if (poSRScxx . . $ OGRMSSQLSpatialLayer#poSRS. == nullptr && nSRSIdcxx . . $ OGRMSSQLSpatialLayer#nSRSId. > 0) |
| 622 | { |
| 623 | poSRScxx . . $ OGRMSSQLSpatialLayer#poSRS. = poDScxx . . $ OGRMSSQLSpatialLayer#poDS.->FetchSRScxx . . $ OGRMSSQLSpatialDataSource#FetchSRS(40ace22e4b36bd01).(nSRSIdcxx . . $ OGRMSSQLSpatialLayer#nSRSId.); |
| 624 | if (poSRScxx . . $ OGRMSSQLSpatialLayer#poSRS. != nullptr) |
| 625 | poSRScxx . . $ OGRMSSQLSpatialLayer#poSRS.->Referencecxx . . $ OGRSpatialReference#Reference(b126dc7c1de90089).(); |
| 626 | else |
| 627 | nSRSIdcxx . . $ OGRMSSQLSpatialLayer#nSRSId. = 0; |
| 628 | } |
| 629 | |
| 630 | return poSRScxx . . $ OGRMSSQLSpatialLayer#poSRS.; |
| 631 | } |
| 632 | |
| 633 | /************************************************************************/ |
| 634 | /* GetFIDColumn() */ |
| 635 | /************************************************************************/ |
| 636 | |
| 637 | const char *OGRMSSQLSpatialLayercxx . . $ OGRMSSQLSpatialLayer#::GetFIDColumncxx . . $ OGRMSSQLSpatialLayer#GetFIDColumn(a9f41ea0e82d88cf).() const |
| 638 | |
| 639 | { |
| 640 | GetLayerDefncxx . . $ OGRMSSQLSpatialLayer#GetLayerDefn(448b209f43d15bcc).(); |
| 641 | |
| 642 | if (pszFIDColumncxx . . $ OGRMSSQLSpatialLayer#pszFIDColumn. != nullptr) |
| 643 | return pszFIDColumncxx . . $ OGRMSSQLSpatialLayer#pszFIDColumn.; |
| 644 | else |
| 645 | return ""; |
| 646 | } |
| 647 | |
| 648 | /************************************************************************/ |
| 649 | /* GetGeometryColumn() */ |
| 650 | /************************************************************************/ |
| 651 | |
| 652 | const char *OGRMSSQLSpatialLayercxx . . $ OGRMSSQLSpatialLayer#::GetGeometryColumncxx . . $ OGRMSSQLSpatialLayer#GetGeometryColumn(a9f41ea0e82d88cf).() const |
| 653 | |
| 654 | { |
| 655 | GetLayerDefncxx . . $ OGRMSSQLSpatialLayer#GetLayerDefn(448b209f43d15bcc).(); |
| 656 | |
| 657 | if (pszGeomColumncxx . . $ OGRMSSQLSpatialLayer#pszGeomColumn. != nullptr) |
| 658 | return pszGeomColumncxx . . $ OGRMSSQLSpatialLayer#pszGeomColumn.; |
| 659 | else |
| 660 | return ""; |
| 661 | } |
| 662 | |
| 663 | /************************************************************************/ |
| 664 | /* GByteArrayToHexString() */ |
| 665 | /************************************************************************/ |
| 666 | |
| 667 | char *OGRMSSQLSpatialLayercxx . . $ OGRMSSQLSpatialLayer#::GByteArrayToHexStringcxx . . $ OGRMSSQLSpatialLayer#GByteArrayToHexString(a386a6bb1ec60e10).(const GBytecxx . . $ GByte# *pabyData, |
| 668 | int nLen) |
| 669 | { |
| 670 | const size_t nTextBufLen = nLen * 2 + 3; |
| 671 | char *pszTextBuf = static_cast<char *>(CPLMalloc(nTextBufLen)); |
| 672 | |
| 673 | int iSrc, iDst = 0; |
| 674 | |
| 675 | for (iSrc = 0; iSrc < nLen; iSrc++) |
| 676 | { |
| 677 | if (iSrc == 0) |
| 678 | { |
| 679 | snprintf(pszTextBuf + iDst, nTextBufLen - iDst, "0x%02x", |
| 680 | pabyData[iSrc]); |
| 681 | iDst += 4; |
| 682 | } |
| 683 | else |
| 684 | { |
| 685 | snprintf(pszTextBuf + iDst, nTextBufLen - iDst, "%02x", |
| 686 | pabyData[iSrc]); |
| 687 | iDst += 2; |
| 688 | } |
| 689 | } |
| 690 | pszTextBuf[iDst] = 0; |
| 691 | |
| 692 | return pszTextBuf; |
| 693 | } |
| 694 | |
| 695 | /************************************************************************/ |
| 696 | /* GetDataset() */ |
| 697 | /************************************************************************/ |
| 698 | |
| 699 | GDALDatasetcxx . . $ GDALDataset# *OGRMSSQLSpatialLayercxx . . $ OGRMSSQLSpatialLayer#::GetDatasetcxx . . $ OGRMSSQLSpatialLayer#GetDataset(76c1989f6ffbc048).() |
| 700 | { |
| 701 | return poDScxx . . $ OGRMSSQLSpatialLayer#poDS.; |
| 702 | } |