| 1 | /****************************************************************************** |
| 2 | * |
| 3 | * Project: OpenGIS Simple Features Reference Implementation |
| 4 | * Purpose: Implements OGROSMDataSource class. |
| 5 | * Author: Even Rouault, <even dot rouault at spatialys.com> |
| 6 | * |
| 7 | ****************************************************************************** |
| 8 | * Copyright (c) 2012-2014, Even Rouault <even dot rouault at spatialys.com> |
| 9 | * |
| 10 | * SPDX-License-Identifier: MIT |
| 11 | ****************************************************************************/ |
| 12 | |
| 13 | #include "gpb.h"cxx . . $ `<file>/ogr/ogrsf_frmts/osm/gpb.h`/ |
| 14 | #include "ogr_osm.h"cxx . . $ `<file>/ogr/ogrsf_frmts/osm/ogr_osm.h`/ |
| 15 | |
| 16 | #include <cassert> |
| 17 | #include <cerrno> |
| 18 | #include <climits> |
| 19 | #include <cmath> |
| 20 | #include <cstddef> |
| 21 | #include <cstdio> |
| 22 | #include <cstdlib> |
| 23 | #include <cstring> |
| 24 | #include <ctime> |
| 25 | #include <algorithm> |
| 26 | #include <limits> |
| 27 | #include <map> |
| 28 | #include <memory> |
| 29 | #include <set> |
| 30 | #include <string> |
| 31 | #include <unordered_set> |
| 32 | #include <utility> |
| 33 | #include <vector> |
| 34 | |
| 35 | #include "cpl_conv.h"cxx . . $ `<file>/port/cpl_conv.h`/ |
| 36 | #include "cpl_error.h"cxx . . $ `<file>/port/cpl_error.h`/ |
| 37 | #include "cpl_multiproc.h"cxx . . $ `<file>/port/cpl_multiproc.h`/ |
| 38 | #include "cpl_port.h"cxx . . $ `<file>/port/cpl_port.h`/ |
| 39 | #include "cpl_progress.h"cxx . . $ `<file>/port/cpl_progress.h`/ |
| 40 | #include "cpl_string.h"cxx . . $ `<file>/port/cpl_string.h`/ |
| 41 | #include "cpl_time.h"cxx . . $ `<file>/port/cpl_time.h`/ |
| 42 | #include "cpl_vsi.h"cxx . . $ `<file>/port/cpl_vsi.h`/ |
| 43 | #include "ogr_api.h"cxx . . $ `<file>/ogr/ogr_api.h`/ |
| 44 | #include "ogr_core.h"cxx . . $ `<file>/ogr/ogr_core.h`/ |
| 45 | #include "ogr_feature.h"cxx . . $ `<file>/ogr/ogr_feature.h`/ |
| 46 | #include "ogr_geometry.h"cxx . . $ `<file>/ogr/ogr_geometry.h`/ |
| 47 | #include "ogr_p.h"cxx . . $ `<file>/ogr/ogr_p.h`/ |
| 48 | #include "ogrlayerdecorator.h"cxx . . $ `<file>/ogr/ogrsf_frmts/generic/ogrlayerdecorator.h`/ |
| 49 | #include "ogrsf_frmts.h"cxx . . $ `<file>/ogr/ogrsf_frmts/ogrsf_frmts.h`/ |
| 50 | #include "ogrsqliteexecutesql.h"cxx . . $ `<file>/ogr/ogrsf_frmts/sqlite/ogrsqliteexecutesql.h`/ |
| 51 | #include "osm_parser.h"cxx . . $ `<file>/ogr/ogrsf_frmts/osm/osm_parser.h`/ |
| 52 | #include "ogr_swq.h"cxx . . $ `<file>/ogr/ogr_swq.h`/ |
| 53 | #include "sqlite3.h" |
| 54 | |
| 55 | #ifdef EMBED_RESOURCE_FILES |
| 56 | #include "embedded_resources.h" |
| 57 | #endif |
| 58 | |
| 59 | #undef SQLITE_STATICcxx . . $ `<external>/2400532043262193228/sqlite3.h:6429:9`! |
| 60 | #define SQLITE_STATICcxx . . $ `ogr/ogrsf_frmts/osm/ogrosmdatasource.cpp:60:9`! (static_cast<sqlite3_destructor_type>(nullptr)) |
| 61 | |
| 62 | constexpr int LIMIT_IDS_PER_REQUESTcxx . . $ LIMIT_IDS_PER_REQUEST. = 200; |
| 63 | |
| 64 | constexpr int IDX_LYR_POINTScxx . . $ IDX_LYR_POINTS. = 0; |
| 65 | constexpr int IDX_LYR_LINEScxx . . $ IDX_LYR_LINES. = 1; |
| 66 | constexpr int IDX_LYR_MULTILINESTRINGScxx . . $ IDX_LYR_MULTILINESTRINGS. = 2; |
| 67 | constexpr int IDX_LYR_MULTIPOLYGONScxx . . $ IDX_LYR_MULTIPOLYGONS. = 3; |
| 68 | constexpr int IDX_LYR_OTHER_RELATIONScxx . . $ IDX_LYR_OTHER_RELATIONS. = 4; |
| 69 | |
| 70 | static int DBL_TO_INTcxx . . $ DBL_TO_INT(620b9ac44d2573a6).(double x) |
| 71 | { |
| 72 | return static_cast<int>(floorcxx . . $ floor(fee4f1d22bc8e617).(x * 1.0e7 + 0.5)); |
| 73 | } |
| 74 | |
| 75 | static double INT_TO_DBLcxx . . $ INT_TO_DBL(4badf5dbac1308a7).(int x) |
| 76 | { |
| 77 | return x / 1.0e7; |
| 78 | } |
| 79 | |
| 80 | constexpr unsigned int MAX_COUNT_FOR_TAGS_IN_WAYcxx . . $ MAX_COUNT_FOR_TAGS_IN_WAY. = 255; // Must fit on 1 byte. |
| 81 | |
| 82 | constexpr int NODE_PER_BUCKETcxx . . $ NODE_PER_BUCKET. = 65536; |
| 83 | |
| 84 | static bool VALID_ID_FOR_CUSTOM_INDEXINGcxx . . $ VALID_ID_FOR_CUSTOM_INDEXING(49597d8fcab147c1).(GIntBigcxx . . $ GIntBig# _id) |
| 85 | { |
| 86 | return _id >= 0 && _id / NODE_PER_BUCKETcxx . . $ NODE_PER_BUCKET. < INT_MAXcxx . . $ `<external>/2419331716647297546/limits.h:120:9`!; |
| 87 | } |
| 88 | |
| 89 | // Minimum size of data written on disk, in *uncompressed* case. |
| 90 | constexpr int SECTOR_SIZEcxx . . $ SECTOR_SIZE. = 512; |
| 91 | // Which represents, 64 nodes |
| 92 | // constexpr int NODE_PER_SECTOR = SECTOR_SIZE / (2 * 4); |
| 93 | constexpr int NODE_PER_SECTORcxx . . $ NODE_PER_SECTOR. = 64; |
| 94 | constexpr int NODE_PER_SECTOR_SHIFTcxx . . $ NODE_PER_SECTOR_SHIFT. = 6; |
| 95 | |
| 96 | // Per bucket, we keep track of the absence/presence of sectors |
| 97 | // only, to reduce memory usage. |
| 98 | // #define BUCKET_BITMAP_SIZE NODE_PER_BUCKET / (8 * NODE_PER_SECTOR) |
| 99 | constexpr int BUCKET_BITMAP_SIZEcxx . . $ BUCKET_BITMAP_SIZE. = 128; |
| 100 | |
| 101 | // #define BUCKET_SECTOR_SIZE_ARRAY_SIZE NODE_PER_BUCKET / NODE_PER_SECTOR |
| 102 | // Per bucket, we keep track of the real size of the sector. Each sector |
| 103 | // size is encoded in a single byte, whose value is: |
| 104 | // (sector_size in bytes - 8 ) / 2, minus 8. 252 means uncompressed |
| 105 | constexpr int BUCKET_SECTOR_SIZE_ARRAY_SIZEcxx . . $ BUCKET_SECTOR_SIZE_ARRAY_SIZE. = 1024; |
| 106 | |
| 107 | // Must be a multiple of both BUCKET_BITMAP_SIZE and |
| 108 | // BUCKET_SECTOR_SIZE_ARRAY_SIZE |
| 109 | constexpr int knPAGE_SIZEcxx . . $ knPAGE_SIZE. = 4096; |
| 110 | |
| 111 | // compressSize should not be greater than 512, so COMPRESS_SIZE_TO_BYTE() fits |
| 112 | // on a byte. |
| 113 | static GBytecxx . . $ GByte# COMPRESS_SIZE_TO_BYTEcxx . . $ COMPRESS_SIZE_TO_BYTE(a50939744455e523).(size_t nCompressSize) |
| 114 | { |
| 115 | return static_cast<GBytecxx . . $ GByte#>((nCompressSize - 8) / 2); |
| 116 | } |
| 117 | |
| 118 | template <typename T> static T ROUND_COMPRESS_SIZEcxx . . $ ROUND_COMPRESS_SIZE(ada6a8422704cf8a).(T nCompressSize) |
| 119 | { |
| 120 | return ((nCompressSize + 1) / 2) * 2; |
| 121 | } |
| 122 | |
| 123 | static int COMPRESS_SIZE_FROM_BYTEcxx . . $ COMPRESS_SIZE_FROM_BYTE(b27dbea426b7b93).(GBytecxx . . $ GByte# byte_on_size) |
| 124 | { |
| 125 | return static_cast<int>(byte_on_size) * 2 + 8; |
| 126 | } |
| 127 | |
| 128 | // Max number of features that are accumulated in pasWayFeaturePairs. |
| 129 | constexpr int MAX_DELAYED_FEATUREScxx . . $ MAX_DELAYED_FEATURES. = 75000; |
| 130 | // Max number of tags that are accumulated in pasAccumulatedTags. |
| 131 | constexpr int MAX_ACCUMULATED_TAGScxx . . $ MAX_ACCUMULATED_TAGS. = MAX_DELAYED_FEATUREScxx . . $ MAX_DELAYED_FEATURES. * 5; |
| 132 | // Max size of the string with tag values that are accumulated in |
| 133 | // pabyNonRedundantValues. |
| 134 | constexpr int MAX_NON_REDUNDANT_VALUEScxx . . $ MAX_NON_REDUNDANT_VALUES. = MAX_DELAYED_FEATUREScxx . . $ MAX_DELAYED_FEATURES. * 10; |
| 135 | // Max size of the string with tag values that are accumulated in |
| 136 | // pabyNonRedundantKeys. |
| 137 | constexpr int MAX_NON_REDUNDANT_KEYScxx . . $ MAX_NON_REDUNDANT_KEYS. = MAX_DELAYED_FEATUREScxx . . $ MAX_DELAYED_FEATURES. * 10; |
| 138 | // Max number of features that are accumulated in panUnsortedReqIds |
| 139 | constexpr int MAX_ACCUMULATED_NODEScxx . . $ MAX_ACCUMULATED_NODES. = 1000000; |
| 140 | |
| 141 | #ifdef ENABLE_NODE_LOOKUP_BY_HASHINGcxx . . $ `ogr/ogrsf_frmts/osm/ogr_osm.h:17:9`! |
| 142 | // Size of panHashedIndexes array. Must be in the list at |
| 143 | // http://planetmath.org/goodhashtableprimes , and greater than |
| 144 | // MAX_ACCUMULATED_NODES. |
| 145 | constexpr int HASHED_INDEXES_ARRAY_SIZEcxx . . $ HASHED_INDEXES_ARRAY_SIZE. = 3145739; |
| 146 | // #define HASHED_INDEXES_ARRAY_SIZE 1572869 |
| 147 | constexpr int COLLISION_BUCKET_ARRAY_SIZEcxx . . $ COLLISION_BUCKET_ARRAY_SIZE. = (MAX_ACCUMULATED_NODEScxx . . $ MAX_ACCUMULATED_NODES. / 100) * 40; |
| 148 | |
| 149 | // hash function = identity |
| 150 | #define HASH_ID_FUNCcxx . . $ `ogr/ogrsf_frmts/osm/ogrosmdatasource.cpp:150:9`!(x) (static_cast<std::uintptr_t>(x)) |
| 151 | #endif // ENABLE_NODE_LOOKUP_BY_HASHING |
| 152 | |
| 153 | // #define FAKE_LOOKUP_NODES |
| 154 | |
| 155 | // #define DEBUG_MEM_USAGE |
| 156 | #ifdef DEBUG_MEM_USAGE |
| 157 | size_t GetMaxTotalAllocs(); |
| 158 | #endif |
| 159 | |
| 160 | static void WriteVarSInt64cxx . . $ WriteVarSInt64(31fb2bddd178366d).(GIntBigcxx . . $ GIntBig# nSVal, GBytecxx . . $ GByte# **ppabyData); |
| 161 | |
| 162 | class DSToBeOpenedcxx . . $ DSToBeOpened# |
| 163 | { |
| 164 | public: |
| 165 | GIntBigcxx . . $ GIntBig# nPIDcxx . . $ DSToBeOpened#nPID.{}; |
| 166 | CPLString osDSNamecxx . . $ DSToBeOpened#osDSName.{}; |
| 167 | CPLString osInterestLayerscxx . . $ DSToBeOpened#osInterestLayers.{}; |
| 168 | }; |
| 169 | |
| 170 | static CPLMutexcxx . . $ CPLMutex# *hMutexcxx . . $ hMutex. = nullptr; |
| 171 | static stdcxx . . $ std/::vector<DSToBeOpenedcxx . . $ DSToBeOpened#> oListDSToBeOpenedcxx . . $ oListDSToBeOpened.; |
| 172 | |
| 173 | /************************************************************************/ |
| 174 | /* AddInterestLayersForDSName() */ |
| 175 | /************************************************************************/ |
| 176 | |
| 177 | static void AddInterestLayersForDSNamecxx . . $ AddInterestLayersForDSName(417a6461aa4d910b).(const CPLString &osDSName, |
| 178 | const CPLString &osInterestLayers) |
| 179 | { |
| 180 | CPLMutexHoldercxx . . $ CPLMutexHolder# oMutexHoldercxx . . $ CPLMutexHolder#CPLMutexHolder(395251a8a2a007dc).(&hMutexcxx . . $ hMutex.); |
| 181 | DSToBeOpenedcxx . . $ DSToBeOpened# oDSToBeOpened; |
| 182 | oDSToBeOpened.nPIDcxx . . $ DSToBeOpened#nPID. = CPLGetPID(); |
| 183 | oDSToBeOpened.osDSNamecxx . . $ DSToBeOpened#osDSName. = osDSName; |
| 184 | oDSToBeOpened.osInterestLayerscxx . . $ DSToBeOpened#osInterestLayers. = osInterestLayers; |
| 185 | oListDSToBeOpenedcxx . . $ oListDSToBeOpened..push_back(stdcxx . . $ std/::move(oDSToBeOpened)); |
| 186 | } |
| 187 | |
| 188 | /************************************************************************/ |
| 189 | /* GetInterestLayersForDSName() */ |
| 190 | /************************************************************************/ |
| 191 | |
| 192 | static CPLString GetInterestLayersForDSNamecxx . . $ GetInterestLayersForDSName(385147141d89f498).(const CPLString &osDSName) |
| 193 | { |
| 194 | CPLMutexHoldercxx . . $ CPLMutexHolder# oMutexHoldercxx . . $ CPLMutexHolder#CPLMutexHolder(395251a8a2a007dc).(&hMutexcxx . . $ hMutex.); |
| 195 | GIntBigcxx . . $ GIntBig# nPID = CPLGetPID(); |
| 196 | for (auto oIter = oListDSToBeOpenedcxx . . $ oListDSToBeOpened..begin(); |
| 197 | oIter < oListDSToBeOpenedcxx . . $ oListDSToBeOpened..end(); ++oIter) |
| 198 | { |
| 199 | const auto &ds = *oIter; |
| 200 | if (ds.nPIDcxx . . $ DSToBeOpened#nPID. == nPID && ds.osDSNamecxx . . $ DSToBeOpened#osDSName. == osDSName) |
| 201 | { |
| 202 | CPLString osInterestLayers = ds.osInterestLayerscxx . . $ DSToBeOpened#osInterestLayers.; |
| 203 | oListDSToBeOpenedcxx . . $ oListDSToBeOpened..erase(oIter); |
| 204 | return osInterestLayers; |
| 205 | } |
| 206 | } |
| 207 | return ""; |
| 208 | } |
| 209 | |
| 210 | /************************************************************************/ |
| 211 | /* OGROSMDataSource() */ |
| 212 | /************************************************************************/ |
| 213 | |
| 214 | OGROSMDataSourcecxx . . $ OGROSMDataSource#::OGROSMDataSourcecxx . . $ OGROSMDataSource#OGROSMDataSource(49f6e7a06ebc5aa8).() |
| 215 | { |
| 216 | m_apsKeyscxx . . $ OGROSMDataSource#m_apsKeys..push_back(nullptr); // guard to avoid index 0 to be used |
| 217 | |
| 218 | MAX_INDEXED_KEYScxx . . $ OGROSMDataSource#MAX_INDEXED_KEYS. = static_cast<unsigned>( |
| 219 | atoicxx . . $ atoi(f5ecf3191ed0cd93).(CPLGetConfigOption("OSM_MAX_INDEXED_KEYS", "32768"))); |
| 220 | MAX_INDEXED_VALUES_PER_KEYcxx . . $ OGROSMDataSource#MAX_INDEXED_VALUES_PER_KEY. = static_cast<unsigned>( |
| 221 | atoicxx . . $ atoi(f5ecf3191ed0cd93).(CPLGetConfigOption("OSM_MAX_INDEXED_VALUES_PER_KEY", "1024"))); |
| 222 | } |
| 223 | |
| 224 | /************************************************************************/ |
| 225 | /* ~OGROSMDataSource() */ |
| 226 | /************************************************************************/ |
| 227 | |
| 228 | OGROSMDataSourcecxx . . $ OGROSMDataSource#::~cxx . . $ OGROSMDataSource#`~OGROSMDataSource`(ced63f7c635d850d).OGROSMDataSourcecxx . . $ OGROSMDataSource#() |
| 229 | |
| 230 | { |
| 231 | m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers..clear(); |
| 232 | |
| 233 | if (m_psParsercxx . . $ OGROSMDataSource#m_psParser. != nullptr) |
| 234 | CPLDebug("OSM", "Number of bytes read in file : " CPL_FRMT_GUIBcxx . . $ `port/cpl_port.h:259:9`!, |
| 235 | OSM_GetBytesRead(m_psParsercxx . . $ OGROSMDataSource#m_psParser.)); |
| 236 | OSM_Close(m_psParsercxx . . $ OGROSMDataSource#m_psParser.); |
| 237 | |
| 238 | if (m_hDBcxx . . $ OGROSMDataSource#m_hDB. != nullptr) |
| 239 | CloseDBcxx . . $ OGROSMDataSource#CloseDB(49f6e7a06ebc5aa8).(); |
| 240 | |
| 241 | if (m_hDBForComputedAttributescxx . . $ OGROSMDataSource#m_hDBForComputedAttributes. != nullptr) |
| 242 | sqlite3_close(m_hDBForComputedAttributescxx . . $ OGROSMDataSource#m_hDBForComputedAttributes.); |
| 243 | |
| 244 | if (m_pMyVFScxx . . $ OGROSMDataSource#m_pMyVFS.) |
| 245 | { |
| 246 | sqlite3_vfs_unregister(m_pMyVFScxx . . $ OGROSMDataSource#m_pMyVFS.); |
| 247 | CPLFreecxx . . $ `port/cpl_conv.h:97:9`!(m_pMyVFScxx . . $ OGROSMDataSource#m_pMyVFS.->pAppDatacxx . . $ sqlite3_vfs#pAppData.); |
| 248 | CPLFreecxx . . $ `port/cpl_conv.h:97:9`!(m_pMyVFScxx . . $ OGROSMDataSource#m_pMyVFS.); |
| 249 | } |
| 250 | |
| 251 | if (!m_osTmpDBNamecxx . . $ OGROSMDataSource#m_osTmpDBName..empty() && m_bMustUnlinkcxx . . $ OGROSMDataSource#m_bMustUnlink.) |
| 252 | { |
| 253 | const char *pszVal = CPLGetConfigOption("OSM_UNLINK_TMPFILE", "YES"); |
| 254 | if (!EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszVal, "NOT_EVEN_AT_END")) |
| 255 | VSIUnlink(m_osTmpDBNamecxx . . $ OGROSMDataSource#m_osTmpDBName.); |
| 256 | } |
| 257 | |
| 258 | CPLFreecxx . . $ `port/cpl_conv.h:97:9`!(m_panReqIdscxx . . $ OGROSMDataSource#m_panReqIds.); |
| 259 | #ifdef ENABLE_NODE_LOOKUP_BY_HASHINGcxx . . $ `ogr/ogrsf_frmts/osm/ogr_osm.h:17:9`! |
| 260 | CPLFreecxx . . $ `port/cpl_conv.h:97:9`!(m_panHashedIndexescxx . . $ OGROSMDataSource#m_panHashedIndexes.); |
| 261 | CPLFreecxx . . $ `port/cpl_conv.h:97:9`!(m_psCollisionBucketscxx . . $ OGROSMDataSource#m_psCollisionBuckets.); |
| 262 | #endif |
| 263 | CPLFreecxx . . $ `port/cpl_conv.h:97:9`!(m_pasLonLatArraycxx . . $ OGROSMDataSource#m_pasLonLatArray.); |
| 264 | CPLFreecxx . . $ `port/cpl_conv.h:97:9`!(m_panUnsortedReqIdscxx . . $ OGROSMDataSource#m_panUnsortedReqIds.); |
| 265 | |
| 266 | CPLFreecxx . . $ `port/cpl_conv.h:97:9`!(m_pasAccumulatedTagscxx . . $ OGROSMDataSource#m_pasAccumulatedTags.); |
| 267 | CPLFreecxx . . $ `port/cpl_conv.h:97:9`!(pabyNonRedundantKeyscxx . . $ OGROSMDataSource#pabyNonRedundantKeys.); |
| 268 | CPLFreecxx . . $ `port/cpl_conv.h:97:9`!(pabyNonRedundantValuescxx . . $ OGROSMDataSource#pabyNonRedundantValues.); |
| 269 | |
| 270 | #ifdef OSM_DEBUG |
| 271 | FILE *f = fopen("keys.txt", "wt"); |
| 272 | for (int i = 1; i < static_cast<int>(asKeys.size()); i++) |
| 273 | { |
| 274 | KeyDesc *psKD = asKeys[i]; |
| 275 | if (psKD) |
| 276 | { |
| 277 | fprintf(f, "%08d idx=%d %s\n", psKD->nOccurrences, psKD->nKeyIndex, |
| 278 | psKD->pszK); |
| 279 | } |
| 280 | } |
| 281 | fclose(f); |
| 282 | #endif |
| 283 | |
| 284 | for (int i = 1; i < static_cast<int>(m_apsKeyscxx . . $ OGROSMDataSource#m_apsKeys..size()); i++) |
| 285 | { |
| 286 | KeyDesccxx . . $ KeyDesc# *psKD = m_apsKeyscxx . . $ OGROSMDataSource#m_apsKeys.[i]; |
| 287 | if (psKD) |
| 288 | { |
| 289 | CPLFreecxx . . $ `port/cpl_conv.h:97:9`!(psKD->pszKcxx . . $ KeyDesc#pszK.); |
| 290 | for (int j = 0; j < static_cast<int>(psKD->apszValuescxx . . $ KeyDesc#apszValues..size()); j++) |
| 291 | CPLFreecxx . . $ `port/cpl_conv.h:97:9`!(psKD->apszValuescxx . . $ KeyDesc#apszValues.[j]); |
| 292 | delete psKD; |
| 293 | } |
| 294 | } |
| 295 | |
| 296 | if (m_fpNodescxx . . $ OGROSMDataSource#m_fpNodes.) |
| 297 | VSIFCloseL(m_fpNodescxx . . $ OGROSMDataSource#m_fpNodes.); |
| 298 | if (!m_osNodesFilenamecxx . . $ OGROSMDataSource#m_osNodesFilename..empty() && m_bMustUnlinkNodesFilecxx . . $ OGROSMDataSource#m_bMustUnlinkNodesFile.) |
| 299 | { |
| 300 | const char *pszVal = CPLGetConfigOption("OSM_UNLINK_TMPFILE", "YES"); |
| 301 | if (!EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszVal, "NOT_EVEN_AT_END")) |
| 302 | VSIUnlink(m_osNodesFilenamecxx . . $ OGROSMDataSource#m_osNodesFilename.); |
| 303 | } |
| 304 | |
| 305 | CPLFreecxx . . $ `port/cpl_conv.h:97:9`!(m_pabySectorcxx . . $ OGROSMDataSource#m_pabySector.); |
| 306 | for (auto &oIter : m_oMapBucketscxx . . $ OGROSMDataSource#m_oMapBuckets.) |
| 307 | { |
| 308 | if (m_bCompressNodescxx . . $ OGROSMDataSource#m_bCompressNodes.) |
| 309 | { |
| 310 | int nRem = |
| 311 | oIter.first % (knPAGE_SIZEcxx . . $ knPAGE_SIZE. / BUCKET_SECTOR_SIZE_ARRAY_SIZEcxx . . $ BUCKET_SECTOR_SIZE_ARRAY_SIZE.); |
| 312 | if (nRem == 0) |
| 313 | CPLFreecxx . . $ `port/cpl_conv.h:97:9`!(oIter.second.ucxx . . $ $anonymous_type_52aecf065e0c3ab0_3#u..panSectorSizecxx . . $ $anonymous_type_52aecf065e0c3ab0_3#$anonymous_type_4#panSectorSize.); |
| 314 | } |
| 315 | else |
| 316 | { |
| 317 | int nRem = oIter.first % (knPAGE_SIZEcxx . . $ knPAGE_SIZE. / BUCKET_BITMAP_SIZEcxx . . $ BUCKET_BITMAP_SIZE.); |
| 318 | if (nRem == 0) |
| 319 | CPLFreecxx . . $ `port/cpl_conv.h:97:9`!(oIter.second.ucxx . . $ $anonymous_type_52aecf065e0c3ab0_3#u..pabyBitmapcxx . . $ $anonymous_type_52aecf065e0c3ab0_3#$anonymous_type_4#pabyBitmap.); |
| 320 | } |
| 321 | } |
| 322 | } |
| 323 | |
| 324 | /************************************************************************/ |
| 325 | /* CloseDB() */ |
| 326 | /************************************************************************/ |
| 327 | |
| 328 | void OGROSMDataSourcecxx . . $ OGROSMDataSource#::CloseDBcxx . . $ OGROSMDataSource#CloseDB(49f6e7a06ebc5aa8).() |
| 329 | { |
| 330 | if (m_hInsertNodeStmtcxx . . $ OGROSMDataSource#m_hInsertNodeStmt. != nullptr) |
| 331 | sqlite3_finalize(m_hInsertNodeStmtcxx . . $ OGROSMDataSource#m_hInsertNodeStmt.); |
| 332 | m_hInsertNodeStmtcxx . . $ OGROSMDataSource#m_hInsertNodeStmt. = nullptr; |
| 333 | |
| 334 | if (m_hInsertWayStmtcxx . . $ OGROSMDataSource#m_hInsertWayStmt. != nullptr) |
| 335 | sqlite3_finalize(m_hInsertWayStmtcxx . . $ OGROSMDataSource#m_hInsertWayStmt.); |
| 336 | m_hInsertWayStmtcxx . . $ OGROSMDataSource#m_hInsertWayStmt. = nullptr; |
| 337 | |
| 338 | if (m_hInsertPolygonsStandaloneStmtcxx . . $ OGROSMDataSource#m_hInsertPolygonsStandaloneStmt. != nullptr) |
| 339 | sqlite3_finalize(m_hInsertPolygonsStandaloneStmtcxx . . $ OGROSMDataSource#m_hInsertPolygonsStandaloneStmt.); |
| 340 | m_hInsertPolygonsStandaloneStmtcxx . . $ OGROSMDataSource#m_hInsertPolygonsStandaloneStmt. = nullptr; |
| 341 | |
| 342 | if (m_hDeletePolygonsStandaloneStmtcxx . . $ OGROSMDataSource#m_hDeletePolygonsStandaloneStmt. != nullptr) |
| 343 | sqlite3_finalize(m_hDeletePolygonsStandaloneStmtcxx . . $ OGROSMDataSource#m_hDeletePolygonsStandaloneStmt.); |
| 344 | m_hDeletePolygonsStandaloneStmtcxx . . $ OGROSMDataSource#m_hDeletePolygonsStandaloneStmt. = nullptr; |
| 345 | |
| 346 | if (m_hSelectPolygonsStandaloneStmtcxx . . $ OGROSMDataSource#m_hSelectPolygonsStandaloneStmt. != nullptr) |
| 347 | sqlite3_finalize(m_hSelectPolygonsStandaloneStmtcxx . . $ OGROSMDataSource#m_hSelectPolygonsStandaloneStmt.); |
| 348 | m_hSelectPolygonsStandaloneStmtcxx . . $ OGROSMDataSource#m_hSelectPolygonsStandaloneStmt. = nullptr; |
| 349 | |
| 350 | if (m_pahSelectNodeStmtcxx . . $ OGROSMDataSource#m_pahSelectNodeStmt. != nullptr) |
| 351 | { |
| 352 | for (int i = 0; i < LIMIT_IDS_PER_REQUESTcxx . . $ LIMIT_IDS_PER_REQUEST.; i++) |
| 353 | { |
| 354 | if (m_pahSelectNodeStmtcxx . . $ OGROSMDataSource#m_pahSelectNodeStmt.[i] != nullptr) |
| 355 | sqlite3_finalize(m_pahSelectNodeStmtcxx . . $ OGROSMDataSource#m_pahSelectNodeStmt.[i]); |
| 356 | } |
| 357 | CPLFreecxx . . $ `port/cpl_conv.h:97:9`!(m_pahSelectNodeStmtcxx . . $ OGROSMDataSource#m_pahSelectNodeStmt.); |
| 358 | m_pahSelectNodeStmtcxx . . $ OGROSMDataSource#m_pahSelectNodeStmt. = nullptr; |
| 359 | } |
| 360 | |
| 361 | if (m_pahSelectWayStmtcxx . . $ OGROSMDataSource#m_pahSelectWayStmt. != nullptr) |
| 362 | { |
| 363 | for (int i = 0; i < LIMIT_IDS_PER_REQUESTcxx . . $ LIMIT_IDS_PER_REQUEST.; i++) |
| 364 | { |
| 365 | if (m_pahSelectWayStmtcxx . . $ OGROSMDataSource#m_pahSelectWayStmt.[i] != nullptr) |
| 366 | sqlite3_finalize(m_pahSelectWayStmtcxx . . $ OGROSMDataSource#m_pahSelectWayStmt.[i]); |
| 367 | } |
| 368 | CPLFreecxx . . $ `port/cpl_conv.h:97:9`!(m_pahSelectWayStmtcxx . . $ OGROSMDataSource#m_pahSelectWayStmt.); |
| 369 | m_pahSelectWayStmtcxx . . $ OGROSMDataSource#m_pahSelectWayStmt. = nullptr; |
| 370 | } |
| 371 | |
| 372 | if (m_bInTransactioncxx . . $ OGROSMDataSource#m_bInTransaction.) |
| 373 | CommitTransactionCacheDBcxx . . $ OGROSMDataSource#CommitTransactionCacheDB(c9857a73d68e59ba).(); |
| 374 | |
| 375 | sqlite3_close(m_hDBcxx . . $ OGROSMDataSource#m_hDB.); |
| 376 | m_hDBcxx . . $ OGROSMDataSource#m_hDB. = nullptr; |
| 377 | } |
| 378 | |
| 379 | /************************************************************************/ |
| 380 | /* IndexPoint() */ |
| 381 | /************************************************************************/ |
| 382 | |
| 383 | constexpr GBytecxx . . $ GByte# abyBitsCountcxx . . $ abyBitsCount.[] = { |
| 384 | 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, 1, 2, 2, 3, 2, 3, 3, 4, |
| 385 | 2, 3, 3, 4, 3, 4, 4, 5, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, |
| 386 | 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 1, 2, 2, 3, 2, 3, 3, 4, |
| 387 | 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, |
| 388 | 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, |
| 389 | 4, 5, 5, 6, 5, 6, 6, 7, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, |
| 390 | 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 2, 3, 3, 4, 3, 4, 4, 5, |
| 391 | 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, |
| 392 | 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, |
| 393 | 4, 5, 5, 6, 5, 6, 6, 7, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, |
| 394 | 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8}; |
| 395 | |
| 396 | bool OGROSMDataSourcecxx . . $ OGROSMDataSource#::IndexPointcxx . . $ OGROSMDataSource#IndexPoint(5f9734eb9599a018).(const OSMNode *psNode) |
| 397 | { |
| 398 | if (!m_bIndexPointscxx . . $ OGROSMDataSource#m_bIndexPoints.) |
| 399 | return true; |
| 400 | |
| 401 | if (m_bCustomIndexingcxx . . $ OGROSMDataSource#m_bCustomIndexing.) |
| 402 | return IndexPointCustomcxx . . $ OGROSMDataSource#IndexPointCustom(5f9734eb9599a018).(psNode); |
| 403 | |
| 404 | return IndexPointSQLitecxx . . $ OGROSMDataSource#IndexPointSQLite(5f9734eb9599a018).(psNode); |
| 405 | } |
| 406 | |
| 407 | /************************************************************************/ |
| 408 | /* IndexPointSQLite() */ |
| 409 | /************************************************************************/ |
| 410 | |
| 411 | bool OGROSMDataSourcecxx . . $ OGROSMDataSource#::IndexPointSQLitecxx . . $ OGROSMDataSource#IndexPointSQLite(5f9734eb9599a018).(const OSMNode *psNode) |
| 412 | { |
| 413 | sqlite3_bind_int64(m_hInsertNodeStmtcxx . . $ OGROSMDataSource#m_hInsertNodeStmt., 1, psNode->nID); |
| 414 | |
| 415 | LonLatcxx . . $ LonLat# sLonLat; |
| 416 | sLonLat.nLoncxx . . $ $anonymous_type_52aecf065e0c3ab0_5#nLon. = DBL_TO_INTcxx . . $ DBL_TO_INT(620b9ac44d2573a6).(psNode->dfLon); |
| 417 | sLonLat.nLatcxx . . $ $anonymous_type_52aecf065e0c3ab0_5#nLat. = DBL_TO_INTcxx . . $ DBL_TO_INT(620b9ac44d2573a6).(psNode->dfLat); |
| 418 | |
| 419 | sqlite3_bind_blob(m_hInsertNodeStmtcxx . . $ OGROSMDataSource#m_hInsertNodeStmt., 2, &sLonLat, sizeof(sLonLat), |
| 420 | SQLITE_STATICcxx . . $ `ogr/ogrsf_frmts/osm/ogrosmdatasource.cpp:60:9`!); |
| 421 | |
| 422 | const int rc = sqlite3_step(m_hInsertNodeStmtcxx . . $ OGROSMDataSource#m_hInsertNodeStmt.); |
| 423 | sqlite3_reset(m_hInsertNodeStmtcxx . . $ OGROSMDataSource#m_hInsertNodeStmt.); |
| 424 | if (!(rc == SQLITE_OKcxx . . $ `<external>/2400532043262193228/sqlite3.h:449:9`! || rc == SQLITE_DONEcxx . . $ `<external>/2400532043262193228/sqlite3.h:480:9`!)) |
| 425 | { |
| 426 | CPLError(CE_Failure, CPLE_AppDefinedcxx . . $ `port/cpl_error.h:108:9`!, |
| 427 | "Failed inserting node " CPL_FRMT_GIBcxx . . $ `port/cpl_port.h:257:9`! ": %s", psNode->nID, |
| 428 | sqlite3_errmsg(m_hDBcxx . . $ OGROSMDataSource#m_hDB.)); |
| 429 | return false; |
| 430 | } |
| 431 | |
| 432 | return true; |
| 433 | } |
| 434 | |
| 435 | /************************************************************************/ |
| 436 | /* FlushCurrentSector() */ |
| 437 | /************************************************************************/ |
| 438 | |
| 439 | bool OGROSMDataSourcecxx . . $ OGROSMDataSource#::FlushCurrentSectorcxx . . $ OGROSMDataSource#FlushCurrentSector(c9857a73d68e59ba).() |
| 440 | { |
| 441 | #ifndef FAKE_LOOKUP_NODES |
| 442 | if (m_bCompressNodescxx . . $ OGROSMDataSource#m_bCompressNodes.) |
| 443 | return FlushCurrentSectorCompressedCasecxx . . $ OGROSMDataSource#FlushCurrentSectorCompressedCase(c9857a73d68e59ba).(); |
| 444 | |
| 445 | return FlushCurrentSectorNonCompressedCasecxx . . $ OGROSMDataSource#FlushCurrentSectorNonCompressedCase(c9857a73d68e59ba).(); |
| 446 | #else |
| 447 | return true; |
| 448 | #endif |
| 449 | } |
| 450 | |
| 451 | /************************************************************************/ |
| 452 | /* AllocBucket() */ |
| 453 | /************************************************************************/ |
| 454 | |
| 455 | Bucketcxx . . $ Bucket# *OGROSMDataSourcecxx . . $ OGROSMDataSource#::AllocBucketcxx . . $ OGROSMDataSource#AllocBucket(b15d78e282f52d63).(int iBucket) |
| 456 | { |
| 457 | if (m_bCompressNodescxx . . $ OGROSMDataSource#m_bCompressNodes.) |
| 458 | { |
| 459 | const int nRem = |
| 460 | iBucket % (knPAGE_SIZEcxx . . $ knPAGE_SIZE. / BUCKET_SECTOR_SIZE_ARRAY_SIZEcxx . . $ BUCKET_SECTOR_SIZE_ARRAY_SIZE.); |
| 461 | Bucketcxx . . $ Bucket# *psPrevBucket = GetBucketcxx . . $ OGROSMDataSource#GetBucket(b15d78e282f52d63).(iBucket - nRem); |
| 462 | if (psPrevBucket->ucxx . . $ $anonymous_type_52aecf065e0c3ab0_3#u..panSectorSizecxx . . $ $anonymous_type_52aecf065e0c3ab0_3#$anonymous_type_4#panSectorSize. == nullptr) |
| 463 | psPrevBucket->ucxx . . $ $anonymous_type_52aecf065e0c3ab0_3#u..panSectorSizecxx . . $ $anonymous_type_52aecf065e0c3ab0_3#$anonymous_type_4#panSectorSize. = |
| 464 | static_cast<GBytecxx . . $ GByte# *>(VSI_CALLOC_VERBOSEcxx . . $ `port/cpl_vsi.h:397:9`!(1, knPAGE_SIZE)); |
| 465 | GBytecxx . . $ GByte# *panSectorSize = psPrevBucket->ucxx . . $ $anonymous_type_52aecf065e0c3ab0_3#u..panSectorSizecxx . . $ $anonymous_type_52aecf065e0c3ab0_3#$anonymous_type_4#panSectorSize.; |
| 466 | Bucketcxx . . $ Bucket# *psBucket = GetBucketcxx . . $ OGROSMDataSource#GetBucket(b15d78e282f52d63).(iBucket); |
| 467 | if (panSectorSize != nullptr) |
| 468 | { |
| 469 | psBucket->ucxx . . $ $anonymous_type_52aecf065e0c3ab0_3#u..panSectorSizecxx . . $ $anonymous_type_52aecf065e0c3ab0_3#$anonymous_type_4#panSectorSize. = |
| 470 | panSectorSize + nRem * BUCKET_SECTOR_SIZE_ARRAY_SIZEcxx . . $ BUCKET_SECTOR_SIZE_ARRAY_SIZE.; |
| 471 | return psBucket; |
| 472 | } |
| 473 | psBucket->ucxx . . $ $anonymous_type_52aecf065e0c3ab0_3#u..panSectorSizecxx . . $ $anonymous_type_52aecf065e0c3ab0_3#$anonymous_type_4#panSectorSize. = nullptr; |
| 474 | } |
| 475 | else |
| 476 | { |
| 477 | const int nRem = iBucket % (knPAGE_SIZEcxx . . $ knPAGE_SIZE. / BUCKET_BITMAP_SIZEcxx . . $ BUCKET_BITMAP_SIZE.); |
| 478 | Bucketcxx . . $ Bucket# *psPrevBucket = GetBucketcxx . . $ OGROSMDataSource#GetBucket(b15d78e282f52d63).(iBucket - nRem); |
| 479 | if (psPrevBucket->ucxx . . $ $anonymous_type_52aecf065e0c3ab0_3#u..pabyBitmapcxx . . $ $anonymous_type_52aecf065e0c3ab0_3#$anonymous_type_4#pabyBitmap. == nullptr) |
| 480 | psPrevBucket->ucxx . . $ $anonymous_type_52aecf065e0c3ab0_3#u..pabyBitmapcxx . . $ $anonymous_type_52aecf065e0c3ab0_3#$anonymous_type_4#pabyBitmap. = |
| 481 | static_cast<GBytecxx . . $ GByte# *>(VSI_CALLOC_VERBOSEcxx . . $ `port/cpl_vsi.h:397:9`!(1, knPAGE_SIZE)); |
| 482 | GBytecxx . . $ GByte# *pabyBitmap = psPrevBucket->ucxx . . $ $anonymous_type_52aecf065e0c3ab0_3#u..pabyBitmapcxx . . $ $anonymous_type_52aecf065e0c3ab0_3#$anonymous_type_4#pabyBitmap.; |
| 483 | Bucketcxx . . $ Bucket# *psBucket = GetBucketcxx . . $ OGROSMDataSource#GetBucket(b15d78e282f52d63).(iBucket); |
| 484 | if (pabyBitmap != nullptr) |
| 485 | { |
| 486 | psBucket->ucxx . . $ $anonymous_type_52aecf065e0c3ab0_3#u..pabyBitmapcxx . . $ $anonymous_type_52aecf065e0c3ab0_3#$anonymous_type_4#pabyBitmap. = pabyBitmap + nRem * BUCKET_BITMAP_SIZEcxx . . $ BUCKET_BITMAP_SIZE.; |
| 487 | return psBucket; |
| 488 | } |
| 489 | psBucket->ucxx . . $ $anonymous_type_52aecf065e0c3ab0_3#u..pabyBitmapcxx . . $ $anonymous_type_52aecf065e0c3ab0_3#$anonymous_type_4#pabyBitmap. = nullptr; |
| 490 | } |
| 491 | |
| 492 | // Out of memory. |
| 493 | CPLError(CE_Failure, CPLE_AppDefinedcxx . . $ `port/cpl_error.h:108:9`!, |
| 494 | "AllocBucket() failed. Use OSM_USE_CUSTOM_INDEXING=NO"); |
| 495 | m_bStopParsingcxx . . $ OGROSMDataSource#m_bStopParsing. = true; |
| 496 | return nullptr; |
| 497 | } |
| 498 | |
| 499 | /************************************************************************/ |
| 500 | /* GetBucket() */ |
| 501 | /************************************************************************/ |
| 502 | |
| 503 | Bucketcxx . . $ Bucket# *OGROSMDataSourcecxx . . $ OGROSMDataSource#::GetBucketcxx . . $ OGROSMDataSource#GetBucket(b15d78e282f52d63).(int nBucketId) |
| 504 | { |
| 505 | auto oIter = m_oMapBucketscxx . . $ OGROSMDataSource#m_oMapBuckets..findcxx . . $ std/map#find(36f8d56706583706).(nBucketId); |
| 506 | if (oIter ==cxx . . $ std/`operator==`(be6a71a859368080). m_oMapBucketscxx . . $ OGROSMDataSource#m_oMapBuckets..endcxx . . $ std/map#end(7e4de33083b6e738).()) |
| 507 | { |
| 508 | Bucketcxx . . $ Bucket# *psBucket = &m_oMapBucketscxx . . $ OGROSMDataSource#m_oMapBuckets.[cxx . . $ std/map#`operator[]`(bbd415b616967878).nBucketId]; |
| 509 | psBucket->nOffcxx . . $ $anonymous_type_52aecf065e0c3ab0_3#nOff. = -1; |
| 510 | if (m_bCompressNodescxx . . $ OGROSMDataSource#m_bCompressNodes.) |
| 511 | psBucket->ucxx . . $ $anonymous_type_52aecf065e0c3ab0_3#u..panSectorSizecxx . . $ $anonymous_type_52aecf065e0c3ab0_3#$anonymous_type_4#panSectorSize. = nullptr; |
| 512 | else |
| 513 | psBucket->ucxx . . $ $anonymous_type_52aecf065e0c3ab0_3#u..pabyBitmapcxx . . $ $anonymous_type_52aecf065e0c3ab0_3#$anonymous_type_4#pabyBitmap. = nullptr; |
| 514 | return psBucket; |
| 515 | } |
| 516 | return &(oIter->cxx . . $ std/_Rb_tree_iterator#`operator->`(34d6acfd341ba7ab).second); |
| 517 | } |
| 518 | |
| 519 | /************************************************************************/ |
| 520 | /* FlushCurrentSectorCompressedCase() */ |
| 521 | /************************************************************************/ |
| 522 | |
| 523 | bool OGROSMDataSourcecxx . . $ OGROSMDataSource#::FlushCurrentSectorCompressedCasecxx . . $ OGROSMDataSource#FlushCurrentSectorCompressedCase(c9857a73d68e59ba).() |
| 524 | { |
| 525 | GBytecxx . . $ GByte# abyOutBuffer[2 * SECTOR_SIZEcxx . . $ SECTOR_SIZE.]; |
| 526 | GBytecxx . . $ GByte# *pabyOut = abyOutBuffer; |
| 527 | LonLatcxx . . $ LonLat# *pasLonLatIn = reinterpret_cast<LonLatcxx . . $ LonLat# *>(m_pabySectorcxx . . $ OGROSMDataSource#m_pabySector.); |
| 528 | int nLastLon = 0; |
| 529 | int nLastLat = 0; |
| 530 | bool bLastValid = false; |
| 531 | |
| 532 | CPLAssertcxx . . $ `port/cpl_error.h:353:9`!((NODE_PER_SECTOR % 8) == 0); |
| 533 | memset(abyOutBuffer, 0, NODE_PER_SECTORcxx . . $ NODE_PER_SECTOR. / 8); |
| 534 | pabyOut += NODE_PER_SECTORcxx . . $ NODE_PER_SECTOR. / 8; |
| 535 | for (int i = 0; i < NODE_PER_SECTORcxx . . $ NODE_PER_SECTOR.; i++) |
| 536 | { |
| 537 | if (pasLonLatIn[i].nLoncxx . . $ $anonymous_type_52aecf065e0c3ab0_5#nLon. || pasLonLatIn[i].nLatcxx . . $ $anonymous_type_52aecf065e0c3ab0_5#nLat.) |
| 538 | { |
| 539 | abyOutBuffer[i >> 3] |= (1 << (i % 8)); |
| 540 | if (bLastValid) |
| 541 | { |
| 542 | const GIntBigcxx . . $ GIntBig# nDiff64Lon = |
| 543 | static_cast<GIntBigcxx . . $ GIntBig#>(pasLonLatIn[i].nLoncxx . . $ $anonymous_type_52aecf065e0c3ab0_5#nLon.) - |
| 544 | static_cast<GIntBigcxx . . $ GIntBig#>(nLastLon); |
| 545 | const GIntBigcxx . . $ GIntBig# nDiff64Lat = pasLonLatIn[i].nLatcxx . . $ $anonymous_type_52aecf065e0c3ab0_5#nLat. - nLastLat; |
| 546 | WriteVarSInt64cxx . . $ WriteVarSInt64(31fb2bddd178366d).(nDiff64Lon, &pabyOut); |
| 547 | WriteVarSInt64cxx . . $ WriteVarSInt64(31fb2bddd178366d).(nDiff64Lat, &pabyOut); |
| 548 | } |
| 549 | else |
| 550 | { |
| 551 | memcpy(pabyOut, &pasLonLatIn[i], sizeof(LonLatcxx . . $ LonLat#)); |
| 552 | pabyOut += sizeof(LonLatcxx . . $ LonLat#); |
| 553 | } |
| 554 | bLastValid = true; |
| 555 | |
| 556 | nLastLon = pasLonLatIn[i].nLoncxx . . $ $anonymous_type_52aecf065e0c3ab0_5#nLon.; |
| 557 | nLastLat = pasLonLatIn[i].nLatcxx . . $ $anonymous_type_52aecf065e0c3ab0_5#nLat.; |
| 558 | } |
| 559 | } |
| 560 | |
| 561 | size_t nCompressSize = static_cast<size_t>(pabyOut - abyOutBuffer); |
| 562 | CPLAssertcxx . . $ `port/cpl_error.h:353:9`!(nCompressSize < sizeof(abyOutBuffer) - 1); |
| 563 | abyOutBuffer[nCompressSize] = 0; |
| 564 | |
| 565 | nCompressSize = ROUND_COMPRESS_SIZEcxx . . $ ROUND_COMPRESS_SIZE(ada6a8422704cf8a).(nCompressSize); |
| 566 | GBytecxx . . $ GByte# *pabyToWrite = nullptr; |
| 567 | if (nCompressSize >= static_cast<size_t>(SECTOR_SIZEcxx . . $ SECTOR_SIZE.)) |
| 568 | { |
| 569 | nCompressSize = SECTOR_SIZEcxx . . $ SECTOR_SIZE.; |
| 570 | pabyToWrite = m_pabySectorcxx . . $ OGROSMDataSource#m_pabySector.; |
| 571 | } |
| 572 | else |
| 573 | pabyToWrite = abyOutBuffer; |
| 574 | |
| 575 | if (VSIFWriteL(pabyToWrite, 1, nCompressSize, m_fpNodescxx . . $ OGROSMDataSource#m_fpNodes.) == nCompressSize) |
| 576 | { |
| 577 | memset(m_pabySectorcxx . . $ OGROSMDataSource#m_pabySector., 0, SECTOR_SIZEcxx . . $ SECTOR_SIZE.); |
| 578 | m_nNodesFileSizecxx . . $ OGROSMDataSource#m_nNodesFileSize. += nCompressSize; |
| 579 | |
| 580 | Bucketcxx . . $ Bucket# *psBucket = GetBucketcxx . . $ OGROSMDataSource#GetBucket(b15d78e282f52d63).(m_nBucketOldcxx . . $ OGROSMDataSource#m_nBucketOld.); |
| 581 | if (psBucket->ucxx . . $ $anonymous_type_52aecf065e0c3ab0_3#u..panSectorSizecxx . . $ $anonymous_type_52aecf065e0c3ab0_3#$anonymous_type_4#panSectorSize. == nullptr) |
| 582 | { |
| 583 | psBucket = AllocBucketcxx . . $ OGROSMDataSource#AllocBucket(b15d78e282f52d63).(m_nBucketOldcxx . . $ OGROSMDataSource#m_nBucketOld.); |
| 584 | if (psBucket == nullptr) |
| 585 | return false; |
| 586 | } |
| 587 | CPLAssertcxx . . $ `port/cpl_error.h:353:9`!(psBucket->u.panSectorSize != nullptr); |
| 588 | psBucket->ucxx . . $ $anonymous_type_52aecf065e0c3ab0_3#u..panSectorSizecxx . . $ $anonymous_type_52aecf065e0c3ab0_3#$anonymous_type_4#panSectorSize.[m_nOffInBucketReducedOldcxx . . $ OGROSMDataSource#m_nOffInBucketReducedOld.] = |
| 589 | COMPRESS_SIZE_TO_BYTEcxx . . $ COMPRESS_SIZE_TO_BYTE(a50939744455e523).(nCompressSize); |
| 590 | |
| 591 | return true; |
| 592 | } |
| 593 | |
| 594 | CPLError(CE_Failure, CPLE_AppDefinedcxx . . $ `port/cpl_error.h:108:9`!, |
| 595 | "Cannot write in temporary node file %s : %s", |
| 596 | m_osNodesFilenamecxx . . $ OGROSMDataSource#m_osNodesFilename..c_str(), VSIStrerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 597 | |
| 598 | return false; |
| 599 | } |
| 600 | |
| 601 | /************************************************************************/ |
| 602 | /* FlushCurrentSectorNonCompressedCase() */ |
| 603 | /************************************************************************/ |
| 604 | |
| 605 | bool OGROSMDataSourcecxx . . $ OGROSMDataSource#::FlushCurrentSectorNonCompressedCasecxx . . $ OGROSMDataSource#FlushCurrentSectorNonCompressedCase(c9857a73d68e59ba).() |
| 606 | { |
| 607 | if (VSIFWriteL(m_pabySectorcxx . . $ OGROSMDataSource#m_pabySector., 1, static_cast<size_t>(SECTOR_SIZEcxx . . $ SECTOR_SIZE.), |
| 608 | m_fpNodescxx . . $ OGROSMDataSource#m_fpNodes.) == static_cast<size_t>(SECTOR_SIZEcxx . . $ SECTOR_SIZE.)) |
| 609 | { |
| 610 | memset(m_pabySectorcxx . . $ OGROSMDataSource#m_pabySector., 0, SECTOR_SIZEcxx . . $ SECTOR_SIZE.); |
| 611 | m_nNodesFileSizecxx . . $ OGROSMDataSource#m_nNodesFileSize. += SECTOR_SIZEcxx . . $ SECTOR_SIZE.; |
| 612 | return true; |
| 613 | } |
| 614 | |
| 615 | CPLError(CE_Failure, CPLE_AppDefinedcxx . . $ `port/cpl_error.h:108:9`!, |
| 616 | "Cannot write in temporary node file %s : %s", |
| 617 | m_osNodesFilenamecxx . . $ OGROSMDataSource#m_osNodesFilename..c_str(), VSIStrerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 618 | |
| 619 | return false; |
| 620 | } |
| 621 | |
| 622 | /************************************************************************/ |
| 623 | /* IndexPointCustom() */ |
| 624 | /************************************************************************/ |
| 625 | |
| 626 | bool OGROSMDataSourcecxx . . $ OGROSMDataSource#::IndexPointCustomcxx . . $ OGROSMDataSource#IndexPointCustom(5f9734eb9599a018).(const OSMNode *psNode) |
| 627 | { |
| 628 | if (psNode->nID <= m_nPrevNodeIdcxx . . $ OGROSMDataSource#m_nPrevNodeId.) |
| 629 | { |
| 630 | CPLError(CE_Failure, CPLE_AppDefinedcxx . . $ `port/cpl_error.h:108:9`!, |
| 631 | "Non increasing node id. Use OSM_USE_CUSTOM_INDEXING=NO"); |
| 632 | m_bStopParsingcxx . . $ OGROSMDataSource#m_bStopParsing. = true; |
| 633 | return false; |
| 634 | } |
| 635 | if (!VALID_ID_FOR_CUSTOM_INDEXINGcxx . . $ VALID_ID_FOR_CUSTOM_INDEXING(49597d8fcab147c1).(psNode->nID)) |
| 636 | { |
| 637 | CPLError(CE_Failure, CPLE_AppDefinedcxx . . $ `port/cpl_error.h:108:9`!, |
| 638 | "Unsupported node id value (" CPL_FRMT_GIBcxx . . $ `port/cpl_port.h:257:9`! |
| 639 | "). Use OSM_USE_CUSTOM_INDEXING=NO", |
| 640 | psNode->nID); |
| 641 | m_bStopParsingcxx . . $ OGROSMDataSource#m_bStopParsing. = true; |
| 642 | return false; |
| 643 | } |
| 644 | |
| 645 | const int nBucket = static_cast<int>(psNode->nID / NODE_PER_BUCKETcxx . . $ NODE_PER_BUCKET.); |
| 646 | const int nOffInBucket = static_cast<int>(psNode->nID % NODE_PER_BUCKETcxx . . $ NODE_PER_BUCKET.); |
| 647 | const int nOffInBucketReduced = nOffInBucket >> NODE_PER_SECTOR_SHIFTcxx . . $ NODE_PER_SECTOR_SHIFT.; |
| 648 | const int nOffInBucketReducedRemainder = |
| 649 | nOffInBucket & ((1 << NODE_PER_SECTOR_SHIFTcxx . . $ NODE_PER_SECTOR_SHIFT.) - 1); |
| 650 | |
| 651 | Bucketcxx . . $ Bucket# *psBucket = GetBucketcxx . . $ OGROSMDataSource#GetBucket(b15d78e282f52d63).(nBucket); |
| 652 | |
| 653 | if (!m_bCompressNodescxx . . $ OGROSMDataSource#m_bCompressNodes.) |
| 654 | { |
| 655 | const int nBitmapIndex = nOffInBucketReduced / 8; |
| 656 | const int nBitmapRemainder = nOffInBucketReduced % 8; |
| 657 | if (psBucket->ucxx . . $ $anonymous_type_52aecf065e0c3ab0_3#u..pabyBitmapcxx . . $ $anonymous_type_52aecf065e0c3ab0_3#$anonymous_type_4#pabyBitmap. == nullptr) |
| 658 | { |
| 659 | psBucket = AllocBucketcxx . . $ OGROSMDataSource#AllocBucket(b15d78e282f52d63).(nBucket); |
| 660 | if (psBucket == nullptr) |
| 661 | return false; |
| 662 | } |
| 663 | CPLAssertcxx . . $ `port/cpl_error.h:353:9`!(psBucket->u.pabyBitmap != nullptr); |
| 664 | psBucket->ucxx . . $ $anonymous_type_52aecf065e0c3ab0_3#u..pabyBitmapcxx . . $ $anonymous_type_52aecf065e0c3ab0_3#$anonymous_type_4#pabyBitmap.[nBitmapIndex] |= (1 << nBitmapRemainder); |
| 665 | } |
| 666 | |
| 667 | if (nBucket != m_nBucketOldcxx . . $ OGROSMDataSource#m_nBucketOld.) |
| 668 | { |
| 669 | CPLAssertcxx . . $ `port/cpl_error.h:353:9`!(nBucket > m_nBucketOld); |
| 670 | if (m_nBucketOldcxx . . $ OGROSMDataSource#m_nBucketOld. >= 0) |
| 671 | { |
| 672 | if (!FlushCurrentSectorcxx . . $ OGROSMDataSource#FlushCurrentSector(c9857a73d68e59ba).()) |
| 673 | { |
| 674 | m_bStopParsingcxx . . $ OGROSMDataSource#m_bStopParsing. = true; |
| 675 | return false; |
| 676 | } |
| 677 | } |
| 678 | m_nBucketOldcxx . . $ OGROSMDataSource#m_nBucketOld. = nBucket; |
| 679 | m_nOffInBucketReducedOldcxx . . $ OGROSMDataSource#m_nOffInBucketReducedOld. = nOffInBucketReduced; |
| 680 | CPLAssertcxx . . $ `port/cpl_error.h:353:9`!(psBucket->nOff == -1); |
| 681 | psBucket->nOffcxx . . $ $anonymous_type_52aecf065e0c3ab0_3#nOff. = VSIFTellL(m_fpNodescxx . . $ OGROSMDataSource#m_fpNodes.); |
| 682 | } |
| 683 | else if (nOffInBucketReduced != m_nOffInBucketReducedOldcxx . . $ OGROSMDataSource#m_nOffInBucketReducedOld.) |
| 684 | { |
| 685 | CPLAssertcxx . . $ `port/cpl_error.h:353:9`!(nOffInBucketReduced > m_nOffInBucketReducedOld); |
| 686 | if (!FlushCurrentSectorcxx . . $ OGROSMDataSource#FlushCurrentSector(c9857a73d68e59ba).()) |
| 687 | { |
| 688 | m_bStopParsingcxx . . $ OGROSMDataSource#m_bStopParsing. = true; |
| 689 | return false; |
| 690 | } |
| 691 | m_nOffInBucketReducedOldcxx . . $ OGROSMDataSource#m_nOffInBucketReducedOld. = nOffInBucketReduced; |
| 692 | } |
| 693 | |
| 694 | LonLatcxx . . $ LonLat# *psLonLat = reinterpret_cast<LonLatcxx . . $ LonLat# *>( |
| 695 | m_pabySectorcxx . . $ OGROSMDataSource#m_pabySector. + sizeof(LonLatcxx . . $ LonLat#) * nOffInBucketReducedRemainder); |
| 696 | psLonLat->nLoncxx . . $ $anonymous_type_52aecf065e0c3ab0_5#nLon. = DBL_TO_INTcxx . . $ DBL_TO_INT(620b9ac44d2573a6).(psNode->dfLon); |
| 697 | psLonLat->nLatcxx . . $ $anonymous_type_52aecf065e0c3ab0_5#nLat. = DBL_TO_INTcxx . . $ DBL_TO_INT(620b9ac44d2573a6).(psNode->dfLat); |
| 698 | |
| 699 | m_nPrevNodeIdcxx . . $ OGROSMDataSource#m_nPrevNodeId. = psNode->nID; |
| 700 | |
| 701 | return true; |
| 702 | } |
| 703 | |
| 704 | /************************************************************************/ |
| 705 | /* NotifyNodes() */ |
| 706 | /************************************************************************/ |
| 707 | |
| 708 | void OGROSMDataSourcecxx . . $ OGROSMDataSource#::NotifyNodescxx . . $ OGROSMDataSource#NotifyNodes(c2b667c6e077c27d).(unsigned int nNodes, const OSMNode *pasNodes) |
| 709 | { |
| 710 | const OGREnvelope *psEnvelope = |
| 711 | m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers.[IDX_LYR_POINTScxx . . $ IDX_LYR_POINTS.]->GetSpatialFilterEnvelopecxx . . $ OGROSMLayer#GetSpatialFilterEnvelope(c528e81f9aba64d9).(); |
| 712 | |
| 713 | for (unsigned int i = 0; i < nNodes; i++) |
| 714 | { |
| 715 | /* If the point doesn't fit into the envelope of the spatial filter */ |
| 716 | /* then skip it */ |
| 717 | if (psEnvelope != nullptr && !(pasNodes[i].dfLon >= psEnvelope->MinX && |
| 718 | pasNodes[i].dfLon <= psEnvelope->MaxX && |
| 719 | pasNodes[i].dfLat >= psEnvelope->MinY && |
| 720 | pasNodes[i].dfLat <= psEnvelope->MaxY)) |
| 721 | continue; |
| 722 | |
| 723 | if (!IndexPointcxx . . $ OGROSMDataSource#IndexPoint(5f9734eb9599a018).(&pasNodes[i])) |
| 724 | break; |
| 725 | |
| 726 | if (!m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers.[IDX_LYR_POINTScxx . . $ IDX_LYR_POINTS.]->IsUserInterestedcxx . . $ OGROSMLayer#IsUserInterested(50ce9a9e25b4a850).()) |
| 727 | continue; |
| 728 | |
| 729 | bool bInterestingTag = m_bReportAllNodescxx . . $ OGROSMDataSource#m_bReportAllNodes.; |
| 730 | const OSMTag *pasTags = pasNodes[i].pasTags; |
| 731 | |
| 732 | if (!m_bReportAllNodescxx . . $ OGROSMDataSource#m_bReportAllNodes.) |
| 733 | { |
| 734 | for (unsigned int j = 0; j < pasNodes[i].nTags; j++) |
| 735 | { |
| 736 | const char *pszK = pasTags[j].pszK; |
| 737 | if (m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers.[IDX_LYR_POINTScxx . . $ IDX_LYR_POINTS.]->IsSignificantKeycxx . . $ OGROSMLayer#IsSignificantKey(78f035161ffa9fe2).(pszK)) |
| 738 | { |
| 739 | bInterestingTag = true; |
| 740 | break; |
| 741 | } |
| 742 | } |
| 743 | } |
| 744 | |
| 745 | if (bInterestingTag) |
| 746 | { |
| 747 | auto poFeature = stdcxx . . $ std/::make_unique<OGRFeaturecxx . . $ OGRFeature#>( |
| 748 | m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers.[IDX_LYR_POINTScxx . . $ IDX_LYR_POINTS.]->GetLayerDefncxx . . $ OGRLayer#GetLayerDefn(407fccde18759965).()); |
| 749 | |
| 750 | poFeature->SetGeometryDirectlycxx . . $ OGRFeature#SetGeometryDirectly(cec3429dca426eb8).( |
| 751 | new OGRPointcxx . . $ OGRPoint#OGRPoint(bc12c9ec15586e6a).(pasNodes[i].dfLon, pasNodes[i].dfLat)); |
| 752 | |
| 753 | m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers.[IDX_LYR_POINTScxx . . $ IDX_LYR_POINTS.]->SetFieldsFromTagscxx . . $ OGROSMLayer#SetFieldsFromTags(49bbf9dc4001c2e3).( |
| 754 | poFeature.get(), pasNodes[i].nID, false, pasNodes[i].nTags, |
| 755 | pasTags, &pasNodes[i].sInfo); |
| 756 | |
| 757 | bool bFilteredOut = false; |
| 758 | if (!m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers.[IDX_LYR_POINTScxx . . $ IDX_LYR_POINTS.]->AddFeaturecxx . . $ OGROSMLayer#AddFeature(12b17bec2ef920e4).(stdcxx . . $ std/::move(poFeature), |
| 759 | false, &bFilteredOut, |
| 760 | !m_bFeatureAddedcxx . . $ OGROSMDataSource#m_bFeatureAdded.)) |
| 761 | { |
| 762 | m_bStopParsingcxx . . $ OGROSMDataSource#m_bStopParsing. = true; |
| 763 | break; |
| 764 | } |
| 765 | else if (!bFilteredOut) |
| 766 | m_bFeatureAddedcxx . . $ OGROSMDataSource#m_bFeatureAdded. = true; |
| 767 | } |
| 768 | } |
| 769 | } |
| 770 | |
| 771 | static void OGROSMNotifyNodescxx . . $ OGROSMNotifyNodes(96d80dda9c2b6398).(unsigned int nNodes, OSMNode *pasNodes, |
| 772 | OSMContext * /* psOSMContext */, void *user_data) |
| 773 | { |
| 774 | static_cast<OGROSMDataSourcecxx . . $ OGROSMDataSource# *>(user_data)->NotifyNodescxx . . $ OGROSMDataSource#NotifyNodes(c2b667c6e077c27d).(nNodes, pasNodes); |
| 775 | } |
| 776 | |
| 777 | /************************************************************************/ |
| 778 | /* LookupNodes() */ |
| 779 | /************************************************************************/ |
| 780 | |
| 781 | // #define DEBUG_COLLISIONS 1 |
| 782 | |
| 783 | void OGROSMDataSourcecxx . . $ OGROSMDataSource#::LookupNodescxx . . $ OGROSMDataSource#LookupNodes(49f6e7a06ebc5aa8).() |
| 784 | { |
| 785 | if (m_bCustomIndexingcxx . . $ OGROSMDataSource#m_bCustomIndexing.) |
| 786 | LookupNodesCustomcxx . . $ OGROSMDataSource#LookupNodesCustom(49f6e7a06ebc5aa8).(); |
| 787 | else |
| 788 | LookupNodesSQLitecxx . . $ OGROSMDataSource#LookupNodesSQLite(49f6e7a06ebc5aa8).(); |
| 789 | |
| 790 | #ifdef ENABLE_NODE_LOOKUP_BY_HASHINGcxx . . $ `ogr/ogrsf_frmts/osm/ogr_osm.h:17:9`! |
| 791 | if (m_nReqIdscxx . . $ OGROSMDataSource#m_nReqIds. > 1 && m_bEnableHashedIndexcxx . . $ OGROSMDataSource#m_bEnableHashedIndex.) |
| 792 | { |
| 793 | memset(m_panHashedIndexescxx . . $ OGROSMDataSource#m_panHashedIndexes., 0xFF, |
| 794 | HASHED_INDEXES_ARRAY_SIZEcxx . . $ HASHED_INDEXES_ARRAY_SIZE. * sizeof(int)); |
| 795 | m_bHashedIndexValidcxx . . $ OGROSMDataSource#m_bHashedIndexValid. = true; |
| 796 | #ifdef DEBUG_COLLISIONS |
| 797 | int nCollisions = 0; |
| 798 | #endif |
| 799 | int iNextFreeBucket = 0; |
| 800 | for (unsigned int i = 0; i < m_nReqIdscxx . . $ OGROSMDataSource#m_nReqIds.; i++) |
| 801 | { |
| 802 | int nIndInHashArray = static_cast<int>( |
| 803 | HASH_ID_FUNCcxx . . $ `ogr/ogrsf_frmts/osm/ogrosmdatasource.cpp:150:9`!(m_panReqIds[i]) % HASHED_INDEXES_ARRAY_SIZEcxx . . $ HASHED_INDEXES_ARRAY_SIZE.); |
| 804 | int nIdx = m_panHashedIndexescxx . . $ OGROSMDataSource#m_panHashedIndexes.[nIndInHashArray]; |
| 805 | if (nIdx == -1) |
| 806 | { |
| 807 | m_panHashedIndexescxx . . $ OGROSMDataSource#m_panHashedIndexes.[nIndInHashArray] = i; |
| 808 | } |
| 809 | else |
| 810 | { |
| 811 | #ifdef DEBUG_COLLISIONS |
| 812 | nCollisions++; |
| 813 | #endif |
| 814 | int iBucket = 0; |
| 815 | if (nIdx >= 0) |
| 816 | { |
| 817 | if (iNextFreeBucket == COLLISION_BUCKET_ARRAY_SIZEcxx . . $ COLLISION_BUCKET_ARRAY_SIZE.) |
| 818 | { |
| 819 | CPLDebug( |
| 820 | "OSM", |
| 821 | "Too many collisions. Disabling hashed indexing"); |
| 822 | m_bHashedIndexValidcxx . . $ OGROSMDataSource#m_bHashedIndexValid. = false; |
| 823 | m_bEnableHashedIndexcxx . . $ OGROSMDataSource#m_bEnableHashedIndex. = false; |
| 824 | break; |
| 825 | } |
| 826 | iBucket = iNextFreeBucket; |
| 827 | m_psCollisionBucketscxx . . $ OGROSMDataSource#m_psCollisionBuckets.[iNextFreeBucket].nIndcxx . . $ $anonymous_type_52aecf065e0c3ab0_6#nInd. = nIdx; |
| 828 | m_psCollisionBucketscxx . . $ OGROSMDataSource#m_psCollisionBuckets.[iNextFreeBucket].nNextcxx . . $ $anonymous_type_52aecf065e0c3ab0_6#nNext. = -1; |
| 829 | m_panHashedIndexescxx . . $ OGROSMDataSource#m_panHashedIndexes.[nIndInHashArray] = -iNextFreeBucket - 2; |
| 830 | iNextFreeBucket++; |
| 831 | } |
| 832 | else |
| 833 | { |
| 834 | iBucket = -nIdx - 2; |
| 835 | } |
| 836 | if (iNextFreeBucket == COLLISION_BUCKET_ARRAY_SIZEcxx . . $ COLLISION_BUCKET_ARRAY_SIZE.) |
| 837 | { |
| 838 | CPLDebug("OSM", |
| 839 | "Too many collisions. Disabling hashed indexing"); |
| 840 | m_bHashedIndexValidcxx . . $ OGROSMDataSource#m_bHashedIndexValid. = false; |
| 841 | m_bEnableHashedIndexcxx . . $ OGROSMDataSource#m_bEnableHashedIndex. = false; |
| 842 | break; |
| 843 | } |
| 844 | while (true) |
| 845 | { |
| 846 | int iNext = m_psCollisionBucketscxx . . $ OGROSMDataSource#m_psCollisionBuckets.[iBucket].nNextcxx . . $ $anonymous_type_52aecf065e0c3ab0_6#nNext.; |
| 847 | if (iNext < 0) |
| 848 | { |
| 849 | m_psCollisionBucketscxx . . $ OGROSMDataSource#m_psCollisionBuckets.[iBucket].nNextcxx . . $ $anonymous_type_52aecf065e0c3ab0_6#nNext. = iNextFreeBucket; |
| 850 | m_psCollisionBucketscxx . . $ OGROSMDataSource#m_psCollisionBuckets.[iNextFreeBucket].nIndcxx . . $ $anonymous_type_52aecf065e0c3ab0_6#nInd. = i; |
| 851 | m_psCollisionBucketscxx . . $ OGROSMDataSource#m_psCollisionBuckets.[iNextFreeBucket].nNextcxx . . $ $anonymous_type_52aecf065e0c3ab0_6#nNext. = -1; |
| 852 | iNextFreeBucket++; |
| 853 | break; |
| 854 | } |
| 855 | iBucket = iNext; |
| 856 | } |
| 857 | } |
| 858 | } |
| 859 | #ifdef DEBUG_COLLISIONS |
| 860 | /* Collision rate in practice is around 12% on France, Germany, ... */ |
| 861 | /* Maximum seen ~ 15.9% on a planet file but often much smaller. */ |
| 862 | CPLDebug("OSM", |
| 863 | "nCollisions = %d/%d (%.1f %%), iNextFreeBucket = %d/%d", |
| 864 | nCollisions, nReqIds, nCollisions * 100.0 / nReqIds, |
| 865 | iNextFreeBucket, COLLISION_BUCKET_ARRAY_SIZE); |
| 866 | #endif |
| 867 | } |
| 868 | else |
| 869 | m_bHashedIndexValidcxx . . $ OGROSMDataSource#m_bHashedIndexValid. = false; |
| 870 | #endif // ENABLE_NODE_LOOKUP_BY_HASHING |
| 871 | } |
| 872 | |
| 873 | /************************************************************************/ |
| 874 | /* LookupNodesSQLite() */ |
| 875 | /************************************************************************/ |
| 876 | |
| 877 | void OGROSMDataSourcecxx . . $ OGROSMDataSource#::LookupNodesSQLitecxx . . $ OGROSMDataSource#LookupNodesSQLite(49f6e7a06ebc5aa8).() |
| 878 | { |
| 879 | CPLAssertcxx . . $ `port/cpl_error.h:353:9`!(m_nUnsortedReqIds <= |
| 880 | static_cast<unsigned int>(MAX_ACCUMULATED_NODES)); |
| 881 | |
| 882 | m_nReqIdscxx . . $ OGROSMDataSource#m_nReqIds. = 0; |
| 883 | for (unsigned int i = 0; i < m_nUnsortedReqIdscxx . . $ OGROSMDataSource#m_nUnsortedReqIds.; i++) |
| 884 | { |
| 885 | GIntBigcxx . . $ GIntBig# id = m_panUnsortedReqIdscxx . . $ OGROSMDataSource#m_panUnsortedReqIds.[i]; |
| 886 | m_panReqIdscxx . . $ OGROSMDataSource#m_panReqIds.[m_nReqIdscxx . . $ OGROSMDataSource#m_nReqIds.++] = id; |
| 887 | } |
| 888 | |
| 889 | stdcxx . . $ std/::sortcxx . . $ std/sort(249673c20e2b8d5).(m_panReqIdscxx . . $ OGROSMDataSource#m_panReqIds., m_panReqIdscxx . . $ OGROSMDataSource#m_panReqIds. + m_nReqIdscxx . . $ OGROSMDataSource#m_nReqIds.); |
| 890 | |
| 891 | /* Remove duplicates */ |
| 892 | unsigned int j = 0; |
| 893 | for (unsigned int i = 0; i < m_nReqIdscxx . . $ OGROSMDataSource#m_nReqIds.; i++) |
| 894 | { |
| 895 | if (!(i > 0 && m_panReqIdscxx . . $ OGROSMDataSource#m_panReqIds.[i] == m_panReqIdscxx . . $ OGROSMDataSource#m_panReqIds.[i - 1])) |
| 896 | m_panReqIdscxx . . $ OGROSMDataSource#m_panReqIds.[j++] = m_panReqIdscxx . . $ OGROSMDataSource#m_panReqIds.[i]; |
| 897 | } |
| 898 | m_nReqIdscxx . . $ OGROSMDataSource#m_nReqIds. = j; |
| 899 | |
| 900 | unsigned int iCur = 0; |
| 901 | j = 0; |
| 902 | while (iCur < m_nReqIdscxx . . $ OGROSMDataSource#m_nReqIds.) |
| 903 | { |
| 904 | unsigned int nToQuery = m_nReqIdscxx . . $ OGROSMDataSource#m_nReqIds. - iCur; |
| 905 | if (nToQuery > static_cast<unsigned int>(LIMIT_IDS_PER_REQUESTcxx . . $ LIMIT_IDS_PER_REQUEST.)) |
| 906 | nToQuery = static_cast<unsigned int>(LIMIT_IDS_PER_REQUESTcxx . . $ LIMIT_IDS_PER_REQUEST.); |
| 907 | |
| 908 | assertcxx . . $ `<external>/4398592474888995393/assert.h:137:11`!(nToQuery > 0); |
| 909 | sqlite3_stmt *hStmt = m_pahSelectNodeStmtcxx . . $ OGROSMDataSource#m_pahSelectNodeStmt.[nToQuery - 1]; |
| 910 | for (unsigned int i = iCur; i < iCur + nToQuery; i++) |
| 911 | { |
| 912 | sqlite3_bind_int64(hStmt, i - iCur + 1, m_panReqIdscxx . . $ OGROSMDataSource#m_panReqIds.[i]); |
| 913 | } |
| 914 | iCur += nToQuery; |
| 915 | |
| 916 | while (sqlite3_step(hStmt) == SQLITE_ROWcxx . . $ `<external>/2400532043262193228/sqlite3.h:479:9`!) |
| 917 | { |
| 918 | const GIntBigcxx . . $ GIntBig# id = sqlite3_column_int64(hStmt, 0); |
| 919 | const LonLatcxx . . $ LonLat# *psLonLat = |
| 920 | reinterpret_cast<const LonLatcxx . . $ LonLat# *>(sqlite3_column_blob(hStmt, 1)); |
| 921 | |
| 922 | m_panReqIdscxx . . $ OGROSMDataSource#m_panReqIds.[j] = id; |
| 923 | m_pasLonLatArraycxx . . $ OGROSMDataSource#m_pasLonLatArray.[j].nLoncxx . . $ $anonymous_type_52aecf065e0c3ab0_5#nLon. = psLonLat->nLoncxx . . $ $anonymous_type_52aecf065e0c3ab0_5#nLon.; |
| 924 | m_pasLonLatArraycxx . . $ OGROSMDataSource#m_pasLonLatArray.[j].nLatcxx . . $ $anonymous_type_52aecf065e0c3ab0_5#nLat. = psLonLat->nLatcxx . . $ $anonymous_type_52aecf065e0c3ab0_5#nLat.; |
| 925 | j++; |
| 926 | } |
| 927 | |
| 928 | sqlite3_reset(hStmt); |
| 929 | } |
| 930 | m_nReqIdscxx . . $ OGROSMDataSource#m_nReqIds. = j; |
| 931 | } |
| 932 | |
| 933 | /************************************************************************/ |
| 934 | /* DecompressSector() */ |
| 935 | /************************************************************************/ |
| 936 | |
| 937 | static bool DecompressSectorcxx . . $ DecompressSector(a111e121668dc15b).(const GBytecxx . . $ GByte# *pabyIn, int nSectorSize, |
| 938 | GBytecxx . . $ GByte# *pabyOut) |
| 939 | { |
| 940 | const GBytecxx . . $ GByte# *pabyPtr = pabyIn; |
| 941 | LonLatcxx . . $ LonLat# *pasLonLatOut = reinterpret_cast<LonLatcxx . . $ LonLat# *>(pabyOut); |
| 942 | int nLastLon = 0; |
| 943 | int nLastLat = 0; |
| 944 | bool bLastValid = false; |
| 945 | |
| 946 | pabyPtr += NODE_PER_SECTORcxx . . $ NODE_PER_SECTOR. / 8; |
| 947 | for (int i = 0; i < NODE_PER_SECTORcxx . . $ NODE_PER_SECTOR.; i++) |
| 948 | { |
| 949 | if (pabyIn[i >> 3] & (1 << (i % 8))) |
| 950 | { |
| 951 | if (bLastValid) |
| 952 | { |
| 953 | pasLonLatOut[i].nLoncxx . . $ $anonymous_type_52aecf065e0c3ab0_5#nLon. = |
| 954 | static_cast<int>(nLastLon + ReadVarSInt64cxx . . $ ReadVarSInt64(e22d836dbc1e94a2).(&pabyPtr)); |
| 955 | pasLonLatOut[i].nLatcxx . . $ $anonymous_type_52aecf065e0c3ab0_5#nLat. = |
| 956 | static_cast<int>(nLastLat + ReadVarSInt64cxx . . $ ReadVarSInt64(e22d836dbc1e94a2).(&pabyPtr)); |
| 957 | } |
| 958 | else |
| 959 | { |
| 960 | bLastValid = true; |
| 961 | memcpy(&(pasLonLatOut[i]), pabyPtr, sizeof(LonLatcxx . . $ LonLat#)); |
| 962 | pabyPtr += sizeof(LonLatcxx . . $ LonLat#); |
| 963 | } |
| 964 | |
| 965 | nLastLon = pasLonLatOut[i].nLoncxx . . $ $anonymous_type_52aecf065e0c3ab0_5#nLon.; |
| 966 | nLastLat = pasLonLatOut[i].nLatcxx . . $ $anonymous_type_52aecf065e0c3ab0_5#nLat.; |
| 967 | } |
| 968 | else |
| 969 | { |
| 970 | pasLonLatOut[i].nLoncxx . . $ $anonymous_type_52aecf065e0c3ab0_5#nLon. = 0; |
| 971 | pasLonLatOut[i].nLatcxx . . $ $anonymous_type_52aecf065e0c3ab0_5#nLat. = 0; |
| 972 | } |
| 973 | } |
| 974 | |
| 975 | int nRead = static_cast<int>(pabyPtr - pabyIn); |
| 976 | nRead = ROUND_COMPRESS_SIZEcxx . . $ ROUND_COMPRESS_SIZE(ada6a8422704cf8a).(nRead); |
| 977 | return nRead == nSectorSize; |
| 978 | } |
| 979 | |
| 980 | /************************************************************************/ |
| 981 | /* LookupNodesCustom() */ |
| 982 | /************************************************************************/ |
| 983 | |
| 984 | void OGROSMDataSourcecxx . . $ OGROSMDataSource#::LookupNodesCustomcxx . . $ OGROSMDataSource#LookupNodesCustom(49f6e7a06ebc5aa8).() |
| 985 | { |
| 986 | m_nReqIdscxx . . $ OGROSMDataSource#m_nReqIds. = 0; |
| 987 | |
| 988 | if (m_nBucketOldcxx . . $ OGROSMDataSource#m_nBucketOld. >= 0) |
| 989 | { |
| 990 | if (!FlushCurrentSectorcxx . . $ OGROSMDataSource#FlushCurrentSector(c9857a73d68e59ba).()) |
| 991 | { |
| 992 | m_bStopParsingcxx . . $ OGROSMDataSource#m_bStopParsing. = true; |
| 993 | return; |
| 994 | } |
| 995 | |
| 996 | m_nBucketOldcxx . . $ OGROSMDataSource#m_nBucketOld. = -1; |
| 997 | } |
| 998 | |
| 999 | CPLAssertcxx . . $ `port/cpl_error.h:353:9`!(m_nUnsortedReqIds <= |
| 1000 | static_cast<unsigned int>(MAX_ACCUMULATED_NODES)); |
| 1001 | |
| 1002 | for (unsigned int i = 0; i < m_nUnsortedReqIdscxx . . $ OGROSMDataSource#m_nUnsortedReqIds.; i++) |
| 1003 | { |
| 1004 | GIntBigcxx . . $ GIntBig# id = m_panUnsortedReqIdscxx . . $ OGROSMDataSource#m_panUnsortedReqIds.[i]; |
| 1005 | |
| 1006 | if (!VALID_ID_FOR_CUSTOM_INDEXINGcxx . . $ VALID_ID_FOR_CUSTOM_INDEXING(49597d8fcab147c1).(id)) |
| 1007 | continue; |
| 1008 | |
| 1009 | int nBucket = static_cast<int>(id / NODE_PER_BUCKETcxx . . $ NODE_PER_BUCKET.); |
| 1010 | int nOffInBucket = static_cast<int>(id % NODE_PER_BUCKETcxx . . $ NODE_PER_BUCKET.); |
| 1011 | int nOffInBucketReduced = nOffInBucket >> NODE_PER_SECTOR_SHIFTcxx . . $ NODE_PER_SECTOR_SHIFT.; |
| 1012 | |
| 1013 | const auto oIter = m_oMapBucketscxx . . $ OGROSMDataSource#m_oMapBuckets..findcxx . . $ std/map#find(36f8d56706583706).(nBucket); |
| 1014 | if (oIter ==cxx . . $ std/`operator==`(be6a71a859368080). m_oMapBucketscxx . . $ OGROSMDataSource#m_oMapBuckets..endcxx . . $ std/map#end(7e4de33083b6e738).()) |
| 1015 | continue; |
| 1016 | const Bucketcxx . . $ Bucket# *psBucket = &(oIter->cxx . . $ std/_Rb_tree_iterator#`operator->`(34d6acfd341ba7ab).second); |
| 1017 | |
| 1018 | if (m_bCompressNodescxx . . $ OGROSMDataSource#m_bCompressNodes.) |
| 1019 | { |
| 1020 | if (psBucket->ucxx . . $ $anonymous_type_52aecf065e0c3ab0_3#u..panSectorSizecxx . . $ $anonymous_type_52aecf065e0c3ab0_3#$anonymous_type_4#panSectorSize. == nullptr || |
| 1021 | !(psBucket->ucxx . . $ $anonymous_type_52aecf065e0c3ab0_3#u..panSectorSizecxx . . $ $anonymous_type_52aecf065e0c3ab0_3#$anonymous_type_4#panSectorSize.[nOffInBucketReduced])) |
| 1022 | continue; |
| 1023 | } |
| 1024 | else |
| 1025 | { |
| 1026 | int nBitmapIndex = nOffInBucketReduced / 8; |
| 1027 | int nBitmapRemainder = nOffInBucketReduced % 8; |
| 1028 | if (psBucket->ucxx . . $ $anonymous_type_52aecf065e0c3ab0_3#u..pabyBitmapcxx . . $ $anonymous_type_52aecf065e0c3ab0_3#$anonymous_type_4#pabyBitmap. == nullptr || |
| 1029 | !(psBucket->ucxx . . $ $anonymous_type_52aecf065e0c3ab0_3#u..pabyBitmapcxx . . $ $anonymous_type_52aecf065e0c3ab0_3#$anonymous_type_4#pabyBitmap.[nBitmapIndex] & |
| 1030 | (1 << nBitmapRemainder))) |
| 1031 | continue; |
| 1032 | } |
| 1033 | |
| 1034 | m_panReqIdscxx . . $ OGROSMDataSource#m_panReqIds.[m_nReqIdscxx . . $ OGROSMDataSource#m_nReqIds.++] = id; |
| 1035 | } |
| 1036 | |
| 1037 | stdcxx . . $ std/::sortcxx . . $ std/sort(249673c20e2b8d5).(m_panReqIdscxx . . $ OGROSMDataSource#m_panReqIds., m_panReqIdscxx . . $ OGROSMDataSource#m_panReqIds. + m_nReqIdscxx . . $ OGROSMDataSource#m_nReqIds.); |
| 1038 | |
| 1039 | /* Remove duplicates */ |
| 1040 | unsigned int j = 0; // Used after for. |
| 1041 | for (unsigned int i = 0; i < m_nReqIdscxx . . $ OGROSMDataSource#m_nReqIds.; i++) |
| 1042 | { |
| 1043 | if (!(i > 0 && m_panReqIdscxx . . $ OGROSMDataSource#m_panReqIds.[i] == m_panReqIdscxx . . $ OGROSMDataSource#m_panReqIds.[i - 1])) |
| 1044 | m_panReqIdscxx . . $ OGROSMDataSource#m_panReqIds.[j++] = m_panReqIdscxx . . $ OGROSMDataSource#m_panReqIds.[i]; |
| 1045 | } |
| 1046 | m_nReqIdscxx . . $ OGROSMDataSource#m_nReqIds. = j; |
| 1047 | |
| 1048 | #ifdef FAKE_LOOKUP_NODES |
| 1049 | for (unsigned int i = 0; i < nReqIds; i++) |
| 1050 | { |
| 1051 | pasLonLatArray[i].nLon = 0; |
| 1052 | pasLonLatArray[i].nLat = 0; |
| 1053 | } |
| 1054 | #else |
| 1055 | if (m_bCompressNodescxx . . $ OGROSMDataSource#m_bCompressNodes.) |
| 1056 | LookupNodesCustomCompressedCasecxx . . $ OGROSMDataSource#LookupNodesCustomCompressedCase(49f6e7a06ebc5aa8).(); |
| 1057 | else |
| 1058 | LookupNodesCustomNonCompressedCasecxx . . $ OGROSMDataSource#LookupNodesCustomNonCompressedCase(49f6e7a06ebc5aa8).(); |
| 1059 | #endif |
| 1060 | } |
| 1061 | |
| 1062 | /************************************************************************/ |
| 1063 | /* LookupNodesCustomCompressedCase() */ |
| 1064 | /************************************************************************/ |
| 1065 | |
| 1066 | void OGROSMDataSourcecxx . . $ OGROSMDataSource#::LookupNodesCustomCompressedCasecxx . . $ OGROSMDataSource#LookupNodesCustomCompressedCase(49f6e7a06ebc5aa8).() |
| 1067 | { |
| 1068 | constexpr int SECURITY_MARGIN = 8 + 8 + 2 * NODE_PER_SECTORcxx . . $ NODE_PER_SECTOR.; |
| 1069 | GBytecxx . . $ GByte# abyRawSector[SECTOR_SIZEcxx . . $ SECTOR_SIZE. + SECURITY_MARGIN]; |
| 1070 | memset(abyRawSector + SECTOR_SIZEcxx . . $ SECTOR_SIZE., 0, SECURITY_MARGIN); |
| 1071 | |
| 1072 | int l_nBucketOld = -1; |
| 1073 | int l_nOffInBucketReducedOld = -1; |
| 1074 | int k = 0; |
| 1075 | int nOffFromBucketStart = 0; |
| 1076 | |
| 1077 | unsigned int j = 0; // Used after for. |
| 1078 | for (unsigned int i = 0; i < m_nReqIdscxx . . $ OGROSMDataSource#m_nReqIds.; i++) |
| 1079 | { |
| 1080 | const GIntBigcxx . . $ GIntBig# id = m_panReqIdscxx . . $ OGROSMDataSource#m_panReqIds.[i]; |
| 1081 | const int nBucket = static_cast<int>(id / NODE_PER_BUCKETcxx . . $ NODE_PER_BUCKET.); |
| 1082 | const int nOffInBucket = static_cast<int>(id % NODE_PER_BUCKETcxx . . $ NODE_PER_BUCKET.); |
| 1083 | const int nOffInBucketReduced = nOffInBucket >> NODE_PER_SECTOR_SHIFTcxx . . $ NODE_PER_SECTOR_SHIFT.; |
| 1084 | const int nOffInBucketReducedRemainder = |
| 1085 | nOffInBucket & ((1 << NODE_PER_SECTOR_SHIFTcxx . . $ NODE_PER_SECTOR_SHIFT.) - 1); |
| 1086 | |
| 1087 | if (nBucket != l_nBucketOld) |
| 1088 | { |
| 1089 | l_nOffInBucketReducedOld = -1; |
| 1090 | k = 0; |
| 1091 | nOffFromBucketStart = 0; |
| 1092 | } |
| 1093 | |
| 1094 | if (nOffInBucketReduced != l_nOffInBucketReducedOld) |
| 1095 | { |
| 1096 | const auto oIter = m_oMapBucketscxx . . $ OGROSMDataSource#m_oMapBuckets..findcxx . . $ std/map#find(36f8d56706583706).(nBucket); |
| 1097 | if (oIter ==cxx . . $ std/`operator==`(be6a71a859368080). m_oMapBucketscxx . . $ OGROSMDataSource#m_oMapBuckets..endcxx . . $ std/map#end(7e4de33083b6e738).()) |
| 1098 | { |
| 1099 | CPLError(CE_Failure, CPLE_AppDefinedcxx . . $ `port/cpl_error.h:108:9`!, |
| 1100 | "Cannot read node " CPL_FRMT_GIBcxx . . $ `port/cpl_port.h:257:9`!, id); |
| 1101 | continue; |
| 1102 | // FIXME ? |
| 1103 | } |
| 1104 | const Bucketcxx . . $ Bucket# *psBucket = &(oIter->cxx . . $ std/_Rb_tree_iterator#`operator->`(34d6acfd341ba7ab).second); |
| 1105 | if (psBucket->ucxx . . $ $anonymous_type_52aecf065e0c3ab0_3#u..panSectorSizecxx . . $ $anonymous_type_52aecf065e0c3ab0_3#$anonymous_type_4#panSectorSize. == nullptr) |
| 1106 | { |
| 1107 | CPLError(CE_Failure, CPLE_AppDefinedcxx . . $ `port/cpl_error.h:108:9`!, |
| 1108 | "Cannot read node " CPL_FRMT_GIBcxx . . $ `port/cpl_port.h:257:9`!, id); |
| 1109 | continue; |
| 1110 | // FIXME ? |
| 1111 | } |
| 1112 | const int nSectorSize = COMPRESS_SIZE_FROM_BYTEcxx . . $ COMPRESS_SIZE_FROM_BYTE(b27dbea426b7b93).( |
| 1113 | psBucket->ucxx . . $ $anonymous_type_52aecf065e0c3ab0_3#u..panSectorSizecxx . . $ $anonymous_type_52aecf065e0c3ab0_3#$anonymous_type_4#panSectorSize.[nOffInBucketReduced]); |
| 1114 | |
| 1115 | /* If we stay in the same bucket, we can reuse the previously */ |
| 1116 | /* computed offset, instead of starting from bucket start */ |
| 1117 | for (; k < nOffInBucketReduced; k++) |
| 1118 | { |
| 1119 | if (psBucket->ucxx . . $ $anonymous_type_52aecf065e0c3ab0_3#u..panSectorSizecxx . . $ $anonymous_type_52aecf065e0c3ab0_3#$anonymous_type_4#panSectorSize.[k]) |
| 1120 | nOffFromBucketStart += |
| 1121 | COMPRESS_SIZE_FROM_BYTEcxx . . $ COMPRESS_SIZE_FROM_BYTE(b27dbea426b7b93).(psBucket->ucxx . . $ $anonymous_type_52aecf065e0c3ab0_3#u..panSectorSizecxx . . $ $anonymous_type_52aecf065e0c3ab0_3#$anonymous_type_4#panSectorSize.[k]); |
| 1122 | } |
| 1123 | |
| 1124 | VSIFSeekL( |
| 1125 | m_fpNodescxx . . $ OGROSMDataSource#m_fpNodes., |
| 1126 | static_cast<vsi_l_offset>(psBucket->nOffcxx . . $ $anonymous_type_52aecf065e0c3ab0_3#nOff. + nOffFromBucketStart), |
| 1127 | SEEK_SETcxx . . $ `<external>/232824719582829767/stdio.h:114:9`!); |
| 1128 | if (nSectorSize == SECTOR_SIZEcxx . . $ SECTOR_SIZE.) |
| 1129 | { |
| 1130 | if (VSIFReadL(m_pabySectorcxx . . $ OGROSMDataSource#m_pabySector., 1, static_cast<size_t>(SECTOR_SIZEcxx . . $ SECTOR_SIZE.), |
| 1131 | m_fpNodescxx . . $ OGROSMDataSource#m_fpNodes.) != static_cast<size_t>(SECTOR_SIZEcxx . . $ SECTOR_SIZE.)) |
| 1132 | { |
| 1133 | CPLError(CE_Failure, CPLE_AppDefinedcxx . . $ `port/cpl_error.h:108:9`!, |
| 1134 | "Cannot read node " CPL_FRMT_GIBcxx . . $ `port/cpl_port.h:257:9`!, id); |
| 1135 | continue; |
| 1136 | // FIXME ? |
| 1137 | } |
| 1138 | } |
| 1139 | else |
| 1140 | { |
| 1141 | if (static_cast<int>(VSIFReadL(abyRawSector, 1, nSectorSize, |
| 1142 | m_fpNodescxx . . $ OGROSMDataSource#m_fpNodes.)) != nSectorSize) |
| 1143 | { |
| 1144 | CPLError(CE_Failure, CPLE_AppDefinedcxx . . $ `port/cpl_error.h:108:9`!, |
| 1145 | "Cannot read sector for node " CPL_FRMT_GIBcxx . . $ `port/cpl_port.h:257:9`!, id); |
| 1146 | continue; |
| 1147 | // FIXME ? |
| 1148 | } |
| 1149 | abyRawSector[nSectorSize] = 0; |
| 1150 | |
| 1151 | if (!DecompressSectorcxx . . $ DecompressSector(a111e121668dc15b).(abyRawSector, nSectorSize, m_pabySectorcxx . . $ OGROSMDataSource#m_pabySector.)) |
| 1152 | { |
| 1153 | CPLError(CE_Failure, CPLE_AppDefinedcxx . . $ `port/cpl_error.h:108:9`!, |
| 1154 | "Error while uncompressing sector for " |
| 1155 | "node " CPL_FRMT_GIBcxx . . $ `port/cpl_port.h:257:9`!, |
| 1156 | id); |
| 1157 | continue; |
| 1158 | // FIXME ? |
| 1159 | } |
| 1160 | } |
| 1161 | |
| 1162 | l_nBucketOld = nBucket; |
| 1163 | l_nOffInBucketReducedOld = nOffInBucketReduced; |
| 1164 | } |
| 1165 | |
| 1166 | m_panReqIdscxx . . $ OGROSMDataSource#m_panReqIds.[j] = id; |
| 1167 | memcpy(m_pasLonLatArraycxx . . $ OGROSMDataSource#m_pasLonLatArray. + j, |
| 1168 | m_pabySectorcxx . . $ OGROSMDataSource#m_pabySector. + nOffInBucketReducedRemainder * sizeof(LonLatcxx . . $ LonLat#), |
| 1169 | sizeof(LonLatcxx . . $ LonLat#)); |
| 1170 | |
| 1171 | if (m_pasLonLatArraycxx . . $ OGROSMDataSource#m_pasLonLatArray.[j].nLoncxx . . $ $anonymous_type_52aecf065e0c3ab0_5#nLon. || m_pasLonLatArraycxx . . $ OGROSMDataSource#m_pasLonLatArray.[j].nLatcxx . . $ $anonymous_type_52aecf065e0c3ab0_5#nLat.) |
| 1172 | j++; |
| 1173 | } |
| 1174 | m_nReqIdscxx . . $ OGROSMDataSource#m_nReqIds. = j; |
| 1175 | } |
| 1176 | |
| 1177 | /************************************************************************/ |
| 1178 | /* LookupNodesCustomNonCompressedCase() */ |
| 1179 | /************************************************************************/ |
| 1180 | |
| 1181 | void OGROSMDataSourcecxx . . $ OGROSMDataSource#::LookupNodesCustomNonCompressedCasecxx . . $ OGROSMDataSource#LookupNodesCustomNonCompressedCase(49f6e7a06ebc5aa8).() |
| 1182 | { |
| 1183 | unsigned int j = 0; // Used after for. |
| 1184 | |
| 1185 | int l_nBucketOld = -1; |
| 1186 | const Bucketcxx . . $ Bucket# *psBucket = nullptr; |
| 1187 | // To be glibc friendly, we will do reads aligned on 4096 byte offsets |
| 1188 | const int knDISK_SECTOR_SIZE = 4096; |
| 1189 | CPL_STATIC_ASSERTcxx . . $ `port/cpl_port.h:637:9`!((knDISK_SECTOR_SIZE % SECTOR_SIZE) == 0); |
| 1190 | GBytecxx . . $ GByte# abyDiskSector[knDISK_SECTOR_SIZE]; |
| 1191 | // Offset in the nodes files for which abyDiskSector was read |
| 1192 | GIntBigcxx . . $ GIntBig# nOldOffset = -knDISK_SECTOR_SIZE - 1; |
| 1193 | // Number of valid bytes in abyDiskSector |
| 1194 | size_t nValidBytes = 0; |
| 1195 | int k = 0; |
| 1196 | int nSectorBase = 0; |
| 1197 | for (unsigned int i = 0; i < m_nReqIdscxx . . $ OGROSMDataSource#m_nReqIds.; i++) |
| 1198 | { |
| 1199 | const GIntBigcxx . . $ GIntBig# id = m_panReqIdscxx . . $ OGROSMDataSource#m_panReqIds.[i]; |
| 1200 | const int nBucket = static_cast<int>(id / NODE_PER_BUCKETcxx . . $ NODE_PER_BUCKET.); |
| 1201 | const int nOffInBucket = static_cast<int>(id % NODE_PER_BUCKETcxx . . $ NODE_PER_BUCKET.); |
| 1202 | const int nOffInBucketReduced = nOffInBucket >> NODE_PER_SECTOR_SHIFTcxx . . $ NODE_PER_SECTOR_SHIFT.; |
| 1203 | const int nOffInBucketReducedRemainder = |
| 1204 | nOffInBucket & ((1 << NODE_PER_SECTOR_SHIFTcxx . . $ NODE_PER_SECTOR_SHIFT.) - 1); |
| 1205 | |
| 1206 | const int nBitmapIndex = nOffInBucketReduced / 8; |
| 1207 | const int nBitmapRemainder = nOffInBucketReduced % 8; |
| 1208 | |
| 1209 | if (psBucket == nullptr || nBucket != l_nBucketOld) |
| 1210 | { |
| 1211 | const auto oIter = m_oMapBucketscxx . . $ OGROSMDataSource#m_oMapBuckets..findcxx . . $ std/map#find(36f8d56706583706).(nBucket); |
| 1212 | if (oIter ==cxx . . $ std/`operator==`(be6a71a859368080). m_oMapBucketscxx . . $ OGROSMDataSource#m_oMapBuckets..endcxx . . $ std/map#end(7e4de33083b6e738).()) |
| 1213 | { |
| 1214 | CPLError(CE_Failure, CPLE_AppDefinedcxx . . $ `port/cpl_error.h:108:9`!, |
| 1215 | "Cannot read node " CPL_FRMT_GIBcxx . . $ `port/cpl_port.h:257:9`!, id); |
| 1216 | continue; |
| 1217 | // FIXME ? |
| 1218 | } |
| 1219 | psBucket = &(oIter->cxx . . $ std/_Rb_tree_iterator#`operator->`(34d6acfd341ba7ab).second); |
| 1220 | if (psBucket->ucxx . . $ $anonymous_type_52aecf065e0c3ab0_3#u..pabyBitmapcxx . . $ $anonymous_type_52aecf065e0c3ab0_3#$anonymous_type_4#pabyBitmap. == nullptr) |
| 1221 | { |
| 1222 | CPLError(CE_Failure, CPLE_AppDefinedcxx . . $ `port/cpl_error.h:108:9`!, |
| 1223 | "Cannot read node " CPL_FRMT_GIBcxx . . $ `port/cpl_port.h:257:9`!, id); |
| 1224 | continue; |
| 1225 | // FIXME ? |
| 1226 | } |
| 1227 | l_nBucketOld = nBucket; |
| 1228 | nOldOffset = -knDISK_SECTOR_SIZE - 1; |
| 1229 | k = 0; |
| 1230 | nSectorBase = 0; |
| 1231 | } |
| 1232 | |
| 1233 | /* If we stay in the same bucket, we can reuse the previously */ |
| 1234 | /* computed offset, instead of starting from bucket start */ |
| 1235 | for (; k < nBitmapIndex; k++) |
| 1236 | { |
| 1237 | assertcxx . . $ `<external>/4398592474888995393/assert.h:137:11`!(psBucket->u.pabyBitmap); |
| 1238 | // psBucket->u.pabyBitmap cannot be NULL |
| 1239 | // coverity[var_deref_op] |
| 1240 | nSectorBase += abyBitsCountcxx . . $ abyBitsCount.[psBucket->ucxx . . $ $anonymous_type_52aecf065e0c3ab0_3#u..pabyBitmapcxx . . $ $anonymous_type_52aecf065e0c3ab0_3#$anonymous_type_4#pabyBitmap.[k]]; |
| 1241 | } |
| 1242 | int nSector = nSectorBase; |
| 1243 | if (nBitmapRemainder) |
| 1244 | { |
| 1245 | assertcxx . . $ `<external>/4398592474888995393/assert.h:137:11`!(psBucket->u.pabyBitmap); |
| 1246 | nSector += abyBitsCountcxx . . $ abyBitsCount.[psBucket->ucxx . . $ $anonymous_type_52aecf065e0c3ab0_3#u..pabyBitmapcxx . . $ $anonymous_type_52aecf065e0c3ab0_3#$anonymous_type_4#pabyBitmap.[nBitmapIndex] & |
| 1247 | ((1 << nBitmapRemainder) - 1)]; |
| 1248 | } |
| 1249 | |
| 1250 | const GIntBigcxx . . $ GIntBig# nNewOffset = psBucket->nOffcxx . . $ $anonymous_type_52aecf065e0c3ab0_3#nOff. + nSector * SECTOR_SIZEcxx . . $ SECTOR_SIZE.; |
| 1251 | if (nNewOffset - nOldOffset >= knDISK_SECTOR_SIZE) |
| 1252 | { |
| 1253 | // Align on 4096 boundary to be glibc caching friendly |
| 1254 | const vsi_l_offset nAlignedNewPos = |
| 1255 | nNewOffset & |
| 1256 | ~(static_cast<vsi_l_offset>(knDISK_SECTOR_SIZE) - 1); |
| 1257 | VSIFSeekL(m_fpNodescxx . . $ OGROSMDataSource#m_fpNodes., nAlignedNewPos, SEEK_SETcxx . . $ `<external>/232824719582829767/stdio.h:114:9`!); |
| 1258 | nValidBytes = |
| 1259 | VSIFReadL(abyDiskSector, 1, knDISK_SECTOR_SIZE, m_fpNodescxx . . $ OGROSMDataSource#m_fpNodes.); |
| 1260 | nOldOffset = nAlignedNewPos; |
| 1261 | } |
| 1262 | |
| 1263 | const size_t nOffsetInDiskSector = |
| 1264 | static_cast<size_t>(nNewOffset - nOldOffset) + |
| 1265 | nOffInBucketReducedRemainder * sizeof(LonLatcxx . . $ LonLat#); |
| 1266 | if (nValidBytes < sizeof(LonLatcxx . . $ LonLat#) || |
| 1267 | nOffsetInDiskSector > nValidBytes - sizeof(LonLatcxx . . $ LonLat#)) |
| 1268 | { |
| 1269 | CPLError(CE_Failure, CPLE_AppDefinedcxx . . $ `port/cpl_error.h:108:9`!, |
| 1270 | "Cannot read node " CPL_FRMT_GIBcxx . . $ `port/cpl_port.h:257:9`!, id); |
| 1271 | continue; |
| 1272 | } |
| 1273 | memcpy(&m_pasLonLatArraycxx . . $ OGROSMDataSource#m_pasLonLatArray.[j], abyDiskSector + nOffsetInDiskSector, |
| 1274 | sizeof(LonLatcxx . . $ LonLat#)); |
| 1275 | |
| 1276 | m_panReqIdscxx . . $ OGROSMDataSource#m_panReqIds.[j] = id; |
| 1277 | if (m_pasLonLatArraycxx . . $ OGROSMDataSource#m_pasLonLatArray.[j].nLoncxx . . $ $anonymous_type_52aecf065e0c3ab0_5#nLon. || m_pasLonLatArraycxx . . $ OGROSMDataSource#m_pasLonLatArray.[j].nLatcxx . . $ $anonymous_type_52aecf065e0c3ab0_5#nLat.) |
| 1278 | j++; |
| 1279 | } |
| 1280 | m_nReqIdscxx . . $ OGROSMDataSource#m_nReqIds. = j; |
| 1281 | } |
| 1282 | |
| 1283 | /************************************************************************/ |
| 1284 | /* WriteVarInt() */ |
| 1285 | /************************************************************************/ |
| 1286 | |
| 1287 | static void WriteVarIntcxx . . $ WriteVarInt(49e908dec5fdd84f).(unsigned int nVal, stdcxx . . $ std/::vector<GBytecxx . . $ GByte#> &abyData) |
| 1288 | { |
| 1289 | while (true) |
| 1290 | { |
| 1291 | if ((nVal & (~0x7fU)) == 0) |
| 1292 | { |
| 1293 | abyData.push_back(static_cast<GBytecxx . . $ GByte#>(nVal)); |
| 1294 | return; |
| 1295 | } |
| 1296 | |
| 1297 | abyData.push_back(0x80 | static_cast<GBytecxx . . $ GByte#>(nVal & 0x7f)); |
| 1298 | nVal >>= 7; |
| 1299 | } |
| 1300 | } |
| 1301 | |
| 1302 | /************************************************************************/ |
| 1303 | /* WriteVarInt64() */ |
| 1304 | /************************************************************************/ |
| 1305 | |
| 1306 | static void WriteVarInt64cxx . . $ WriteVarInt64(3c816b9c3c30e934).(GUIntBigcxx . . $ GUIntBig# nVal, stdcxx . . $ std/::vector<GBytecxx . . $ GByte#> &abyData) |
| 1307 | { |
| 1308 | while (true) |
| 1309 | { |
| 1310 | if ((static_cast<uint32_tcxx . . $ uint32_t#>(nVal) & (~0x7fU)) == 0) |
| 1311 | { |
| 1312 | abyData.push_back(static_cast<GBytecxx . . $ GByte#>(nVal)); |
| 1313 | return; |
| 1314 | } |
| 1315 | |
| 1316 | abyData.push_back(0x80 | static_cast<GBytecxx . . $ GByte#>(nVal & 0x7f)); |
| 1317 | nVal >>= 7; |
| 1318 | } |
| 1319 | } |
| 1320 | |
| 1321 | /************************************************************************/ |
| 1322 | /* WriteVarSInt64() */ |
| 1323 | /************************************************************************/ |
| 1324 | |
| 1325 | static void WriteVarSInt64cxx . . $ WriteVarSInt64(f75019a8a294c62d).(GIntBigcxx . . $ GIntBig# nSVal, stdcxx . . $ std/::vector<GBytecxx . . $ GByte#> &abyData) |
| 1326 | { |
| 1327 | GIntBigcxx . . $ GIntBig# nVal = nSVal >= 0 ? nSVal << 1 : ((-1 - nSVal) << 1) + 1; |
| 1328 | |
| 1329 | while (true) |
| 1330 | { |
| 1331 | if ((nVal & (~0x7f)) == 0) |
| 1332 | { |
| 1333 | abyData.push_back(static_cast<GBytecxx . . $ GByte#>(nVal)); |
| 1334 | return; |
| 1335 | } |
| 1336 | |
| 1337 | abyData.push_back(0x80 | static_cast<GBytecxx . . $ GByte#>(nVal & 0x7f)); |
| 1338 | nVal >>= 7; |
| 1339 | } |
| 1340 | } |
| 1341 | |
| 1342 | /************************************************************************/ |
| 1343 | /* WriteVarSInt64() */ |
| 1344 | /************************************************************************/ |
| 1345 | |
| 1346 | static void WriteVarSInt64cxx . . $ WriteVarSInt64(31fb2bddd178366d).(GIntBigcxx . . $ GIntBig# nSVal, GBytecxx . . $ GByte# **ppabyData) |
| 1347 | { |
| 1348 | GIntBigcxx . . $ GIntBig# nVal = nSVal >= 0 ? nSVal << 1 : ((-1 - nSVal) << 1) + 1; |
| 1349 | |
| 1350 | GBytecxx . . $ GByte# *pabyData = *ppabyData; |
| 1351 | while (true) |
| 1352 | { |
| 1353 | if ((nVal & (~0x7f)) == 0) |
| 1354 | { |
| 1355 | *pabyData = static_cast<GBytecxx . . $ GByte#>(nVal); |
| 1356 | *ppabyData = pabyData + 1; |
| 1357 | return; |
| 1358 | } |
| 1359 | |
| 1360 | *pabyData = 0x80 | static_cast<GBytecxx . . $ GByte#>(nVal & 0x7f); |
| 1361 | nVal >>= 7; |
| 1362 | pabyData++; |
| 1363 | } |
| 1364 | } |
| 1365 | |
| 1366 | /************************************************************************/ |
| 1367 | /* CompressWay() */ |
| 1368 | /************************************************************************/ |
| 1369 | |
| 1370 | void OGROSMDataSourcecxx . . $ OGROSMDataSource#::CompressWaycxx . . $ OGROSMDataSource#CompressWay(b1c2f6fe7fd6d995).(bool bIsArea, unsigned int nTags, |
| 1371 | const IndexedKVPcxx . . $ IndexedKVP# *pasTags, int nPoints, |
| 1372 | const LonLatcxx . . $ LonLat# *pasLonLatPairs, |
| 1373 | const OSMInfo *psInfo, |
| 1374 | stdcxx . . $ std/::vector<GBytecxx . . $ GByte#> &abyCompressedWay) |
| 1375 | { |
| 1376 | abyCompressedWay.clear(); |
| 1377 | abyCompressedWay.push_back((bIsArea) ? 1 : 0); |
| 1378 | CPLAssertcxx . . $ `port/cpl_error.h:353:9`!(nTags <= MAX_COUNT_FOR_TAGS_IN_WAY); |
| 1379 | abyCompressedWay.push_back(static_cast<GBytecxx . . $ GByte#>(nTags)); |
| 1380 | |
| 1381 | for (unsigned int iTag = 0; iTag < nTags; iTag++) |
| 1382 | { |
| 1383 | if (pasTags[iTag].bKIsIndexcxx . . $ $anonymous_type_52aecf065e0c3ab0_0#bKIsIndex.) |
| 1384 | { |
| 1385 | WriteVarIntcxx . . $ WriteVarInt(49e908dec5fdd84f).(pasTags[iTag].uKeycxx . . $ $anonymous_type_52aecf065e0c3ab0_0#uKey..nKeyIndexcxx . . $ $anonymous_type_52aecf065e0c3ab0_0#$anonymous_type_1#nKeyIndex., abyCompressedWay); |
| 1386 | } |
| 1387 | else |
| 1388 | { |
| 1389 | const char *pszK = |
| 1390 | reinterpret_cast<const char *>(pabyNonRedundantKeyscxx . . $ OGROSMDataSource#pabyNonRedundantKeys.) + |
| 1391 | pasTags[iTag].uKeycxx . . $ $anonymous_type_52aecf065e0c3ab0_0#uKey..nOffsetInpabyNonRedundantKeyscxx . . $ $anonymous_type_52aecf065e0c3ab0_0#$anonymous_type_1#nOffsetInpabyNonRedundantKeys.; |
| 1392 | |
| 1393 | abyCompressedWay.push_back(0); |
| 1394 | |
| 1395 | abyCompressedWay.insert( |
| 1396 | abyCompressedWay.end(), reinterpret_cast<const GBytecxx . . $ GByte# *>(pszK), |
| 1397 | reinterpret_cast<const GBytecxx . . $ GByte# *>(pszK) + strlen(pszK) + 1); |
| 1398 | } |
| 1399 | |
| 1400 | if (pasTags[iTag].bVIsIndexcxx . . $ $anonymous_type_52aecf065e0c3ab0_0#bVIsIndex.) |
| 1401 | { |
| 1402 | WriteVarIntcxx . . $ WriteVarInt(49e908dec5fdd84f).(pasTags[iTag].uValcxx . . $ $anonymous_type_52aecf065e0c3ab0_0#uVal..nValueIndexcxx . . $ $anonymous_type_52aecf065e0c3ab0_0#$anonymous_type_2#nValueIndex., abyCompressedWay); |
| 1403 | } |
| 1404 | else |
| 1405 | { |
| 1406 | const char *pszV = |
| 1407 | reinterpret_cast<const char *>(pabyNonRedundantValuescxx . . $ OGROSMDataSource#pabyNonRedundantValues.) + |
| 1408 | pasTags[iTag].uValcxx . . $ $anonymous_type_52aecf065e0c3ab0_0#uVal..nOffsetInpabyNonRedundantValuescxx . . $ $anonymous_type_52aecf065e0c3ab0_0#$anonymous_type_2#nOffsetInpabyNonRedundantValues.; |
| 1409 | |
| 1410 | if (pasTags[iTag].bKIsIndexcxx . . $ $anonymous_type_52aecf065e0c3ab0_0#bKIsIndex.) |
| 1411 | abyCompressedWay.push_back(0); |
| 1412 | |
| 1413 | abyCompressedWay.insert( |
| 1414 | abyCompressedWay.end(), reinterpret_cast<const GBytecxx . . $ GByte# *>(pszV), |
| 1415 | reinterpret_cast<const GBytecxx . . $ GByte# *>(pszV) + strlen(pszV) + 1); |
| 1416 | } |
| 1417 | } |
| 1418 | |
| 1419 | if (m_bNeedsToSaveWayInfocxx . . $ OGROSMDataSource#m_bNeedsToSaveWayInfo.) |
| 1420 | { |
| 1421 | if (psInfo != nullptr) |
| 1422 | { |
| 1423 | abyCompressedWay.push_back(1); |
| 1424 | WriteVarInt64cxx . . $ WriteVarInt64(3c816b9c3c30e934).(psInfo->ts.nTimeStamp, abyCompressedWay); |
| 1425 | WriteVarInt64cxx . . $ WriteVarInt64(3c816b9c3c30e934).(psInfo->nChangeset, abyCompressedWay); |
| 1426 | WriteVarIntcxx . . $ WriteVarInt(49e908dec5fdd84f).(psInfo->nVersion, abyCompressedWay); |
| 1427 | WriteVarIntcxx . . $ WriteVarInt(49e908dec5fdd84f).(psInfo->nUID, abyCompressedWay); |
| 1428 | // FIXME : do something with pszUserSID |
| 1429 | } |
| 1430 | else |
| 1431 | { |
| 1432 | abyCompressedWay.push_back(0); |
| 1433 | } |
| 1434 | } |
| 1435 | |
| 1436 | abyCompressedWay.insert( |
| 1437 | abyCompressedWay.end(), |
| 1438 | reinterpret_cast<const GBytecxx . . $ GByte# *>(&(pasLonLatPairs[0])), |
| 1439 | reinterpret_cast<const GBytecxx . . $ GByte# *>(&(pasLonLatPairs[0])) + sizeof(LonLatcxx . . $ LonLat#)); |
| 1440 | for (int i = 1; i < nPoints; i++) |
| 1441 | { |
| 1442 | GIntBigcxx . . $ GIntBig# nDiff64 = static_cast<GIntBigcxx . . $ GIntBig#>(pasLonLatPairs[i].nLoncxx . . $ $anonymous_type_52aecf065e0c3ab0_5#nLon.) - |
| 1443 | static_cast<GIntBigcxx . . $ GIntBig#>(pasLonLatPairs[i - 1].nLoncxx . . $ $anonymous_type_52aecf065e0c3ab0_5#nLon.); |
| 1444 | WriteVarSInt64cxx . . $ WriteVarSInt64(f75019a8a294c62d).(nDiff64, abyCompressedWay); |
| 1445 | |
| 1446 | nDiff64 = pasLonLatPairs[i].nLatcxx . . $ $anonymous_type_52aecf065e0c3ab0_5#nLat. - pasLonLatPairs[i - 1].nLatcxx . . $ $anonymous_type_52aecf065e0c3ab0_5#nLat.; |
| 1447 | WriteVarSInt64cxx . . $ WriteVarSInt64(f75019a8a294c62d).(nDiff64, abyCompressedWay); |
| 1448 | } |
| 1449 | } |
| 1450 | |
| 1451 | /************************************************************************/ |
| 1452 | /* UncompressWay() */ |
| 1453 | /************************************************************************/ |
| 1454 | |
| 1455 | void OGROSMDataSourcecxx . . $ OGROSMDataSource#::UncompressWaycxx . . $ OGROSMDataSource#UncompressWay(58972fd431d5ed14).(int nBytes, const GBytecxx . . $ GByte# *pabyCompressedWay, |
| 1456 | bool *pbIsArea, |
| 1457 | stdcxx . . $ std/::vector<LonLatcxx . . $ LonLat#> &asCoords, |
| 1458 | unsigned int *pnTags, OSMTag *pasTags, |
| 1459 | OSMInfo *psInfo) |
| 1460 | { |
| 1461 | asCoords.clear(); |
| 1462 | const GBytecxx . . $ GByte# *pabyPtr = pabyCompressedWay; |
| 1463 | if (pbIsArea) |
| 1464 | *pbIsArea = (*pabyPtr == 1) ? true : false; |
| 1465 | pabyPtr++; |
| 1466 | unsigned int nTags = *pabyPtr; |
| 1467 | pabyPtr++; |
| 1468 | |
| 1469 | if (pnTags) |
| 1470 | *pnTags = nTags; |
| 1471 | |
| 1472 | assertcxx . . $ `<external>/4398592474888995393/assert.h:137:11`!(nTags <= MAX_COUNT_FOR_TAGS_IN_WAY); |
| 1473 | for (unsigned int iTag = 0; iTag < nTags; iTag++) |
| 1474 | { |
| 1475 | const int nK = ReadVarInt32cxx . . $ ReadVarInt32(93853586e289cf68).(&pabyPtr); |
| 1476 | const GBytecxx . . $ GByte# *pszK = nullptr; |
| 1477 | if (nK == 0) |
| 1478 | { |
| 1479 | pszK = pabyPtr; |
| 1480 | while (*pabyPtr != '\0') |
| 1481 | pabyPtr++; |
| 1482 | pabyPtr++; |
| 1483 | } |
| 1484 | |
| 1485 | const int nV = nK == 0 ? 0 : ReadVarInt32cxx . . $ ReadVarInt32(93853586e289cf68).(&pabyPtr); |
| 1486 | const GBytecxx . . $ GByte# *pszV = nullptr; |
| 1487 | if (nV == 0) |
| 1488 | { |
| 1489 | pszV = pabyPtr; |
| 1490 | while (*pabyPtr != '\0') |
| 1491 | pabyPtr++; |
| 1492 | pabyPtr++; |
| 1493 | } |
| 1494 | |
| 1495 | if (pasTags) |
| 1496 | { |
| 1497 | CPLAssertcxx . . $ `port/cpl_error.h:353:9`!(nK >= 0 && static_cast<unsigned>(nK) < m_apsKeys.size()); |
| 1498 | pasTags[iTag].pszK = |
| 1499 | nK ? m_apsKeyscxx . . $ OGROSMDataSource#m_apsKeys.[nK]->pszKcxx . . $ KeyDesc#pszK. : reinterpret_cast<const char *>(pszK); |
| 1500 | |
| 1501 | CPLAssertcxx . . $ `port/cpl_error.h:353:9`!(nK == 0 || |
| 1502 | (nV >= 0 && static_cast<unsigned>(nV) < |
| 1503 | m_apsKeys[nK]->apszValues.size())); |
| 1504 | pasTags[iTag].pszV = nV ? m_apsKeyscxx . . $ OGROSMDataSource#m_apsKeys.[nK]->apszValuescxx . . $ KeyDesc#apszValues.[nV] |
| 1505 | : reinterpret_cast<const char *>(pszV); |
| 1506 | } |
| 1507 | } |
| 1508 | |
| 1509 | if (m_bNeedsToSaveWayInfocxx . . $ OGROSMDataSource#m_bNeedsToSaveWayInfo.) |
| 1510 | { |
| 1511 | if (*pabyPtr) |
| 1512 | { |
| 1513 | pabyPtr++; |
| 1514 | |
| 1515 | OSMInfo sInfo; |
| 1516 | if (psInfo == nullptr) |
| 1517 | psInfo = &sInfo; |
| 1518 | |
| 1519 | psInfo->ts.nTimeStamp = ReadVarInt64cxx . . $ ReadVarInt64(e22d836dbc1e94a2).(&pabyPtr); |
| 1520 | psInfo->nChangeset = ReadVarInt64cxx . . $ ReadVarInt64(e22d836dbc1e94a2).(&pabyPtr); |
| 1521 | psInfo->nVersion = ReadVarInt32cxx . . $ ReadVarInt32(93853586e289cf68).(&pabyPtr); |
| 1522 | psInfo->nUID = ReadVarInt32cxx . . $ ReadVarInt32(93853586e289cf68).(&pabyPtr); |
| 1523 | |
| 1524 | psInfo->bTimeStampIsStr = false; |
| 1525 | psInfo->pszUserSID = ""; // FIXME |
| 1526 | } |
| 1527 | else |
| 1528 | pabyPtr++; |
| 1529 | } |
| 1530 | |
| 1531 | LonLatcxx . . $ LonLat# lonLat; |
| 1532 | memcpy(&lonLat.nLoncxx . . $ $anonymous_type_52aecf065e0c3ab0_5#nLon., pabyPtr, sizeof(int)); |
| 1533 | memcpy(&lonLat.nLatcxx . . $ $anonymous_type_52aecf065e0c3ab0_5#nLat., pabyPtr + sizeof(int), sizeof(int)); |
| 1534 | asCoords.emplace_back(lonLat); |
| 1535 | pabyPtr += 2 * sizeof(int); |
| 1536 | do |
| 1537 | { |
| 1538 | lonLat.nLoncxx . . $ $anonymous_type_52aecf065e0c3ab0_5#nLon. = static_cast<int>(lonLat.nLoncxx . . $ $anonymous_type_52aecf065e0c3ab0_5#nLon. + ReadVarSInt64cxx . . $ ReadVarSInt64(e22d836dbc1e94a2).(&pabyPtr)); |
| 1539 | lonLat.nLatcxx . . $ $anonymous_type_52aecf065e0c3ab0_5#nLat. = static_cast<int>(lonLat.nLatcxx . . $ $anonymous_type_52aecf065e0c3ab0_5#nLat. + ReadVarSInt64cxx . . $ ReadVarSInt64(e22d836dbc1e94a2).(&pabyPtr)); |
| 1540 | asCoords.emplace_back(lonLat); |
| 1541 | } while (pabyPtr < pabyCompressedWay + nBytes); |
| 1542 | } |
| 1543 | |
| 1544 | /************************************************************************/ |
| 1545 | /* IndexWay() */ |
| 1546 | /************************************************************************/ |
| 1547 | |
| 1548 | void OGROSMDataSourcecxx . . $ OGROSMDataSource#::IndexWaycxx . . $ OGROSMDataSource#IndexWay(cc5e18ca7d13d53b).(GIntBigcxx . . $ GIntBig# nWayID, bool bIsArea, |
| 1549 | unsigned int nTags, const IndexedKVPcxx . . $ IndexedKVP# *pasTags, |
| 1550 | const LonLatcxx . . $ LonLat# *pasLonLatPairs, int nPairs, |
| 1551 | const OSMInfo *psInfo) |
| 1552 | { |
| 1553 | if (!m_bIndexWayscxx . . $ OGROSMDataSource#m_bIndexWays.) |
| 1554 | return; |
| 1555 | |
| 1556 | sqlite3_bind_int64(m_hInsertWayStmtcxx . . $ OGROSMDataSource#m_hInsertWayStmt., 1, nWayID); |
| 1557 | |
| 1558 | const unsigned nTagsClamped = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(nTags, MAX_COUNT_FOR_TAGS_IN_WAYcxx . . $ MAX_COUNT_FOR_TAGS_IN_WAY.); |
| 1559 | if (nTagsClamped < nTags) |
| 1560 | { |
| 1561 | CPLDebug("OSM", |
| 1562 | "Too many tags for way " CPL_FRMT_GIBcxx . . $ `port/cpl_port.h:257:9`! ": %u. " |
| 1563 | "Clamping to %u", |
| 1564 | nWayID, nTags, nTagsClamped); |
| 1565 | } |
| 1566 | CompressWaycxx . . $ OGROSMDataSource#CompressWay(b1c2f6fe7fd6d995).(bIsArea, nTagsClamped, pasTags, nPairs, pasLonLatPairs, psInfo, |
| 1567 | m_abyWayBuffercxx . . $ OGROSMDataSource#m_abyWayBuffer.); |
| 1568 | sqlite3_bind_blob(m_hInsertWayStmtcxx . . $ OGROSMDataSource#m_hInsertWayStmt., 2, m_abyWayBuffercxx . . $ OGROSMDataSource#m_abyWayBuffer..data(), |
| 1569 | static_cast<int>(m_abyWayBuffercxx . . $ OGROSMDataSource#m_abyWayBuffer..size()), SQLITE_STATICcxx . . $ `ogr/ogrsf_frmts/osm/ogrosmdatasource.cpp:60:9`!); |
| 1570 | |
| 1571 | int rc = sqlite3_step(m_hInsertWayStmtcxx . . $ OGROSMDataSource#m_hInsertWayStmt.); |
| 1572 | sqlite3_reset(m_hInsertWayStmtcxx . . $ OGROSMDataSource#m_hInsertWayStmt.); |
| 1573 | if (!(rc == SQLITE_OKcxx . . $ `<external>/2400532043262193228/sqlite3.h:449:9`! || rc == SQLITE_DONEcxx . . $ `<external>/2400532043262193228/sqlite3.h:480:9`!)) |
| 1574 | { |
| 1575 | CPLError(CE_Failure, CPLE_AppDefinedcxx . . $ `port/cpl_error.h:108:9`!, |
| 1576 | "Failed inserting way " CPL_FRMT_GIBcxx . . $ `port/cpl_port.h:257:9`! ": %s", nWayID, |
| 1577 | sqlite3_errmsg(m_hDBcxx . . $ OGROSMDataSource#m_hDB.)); |
| 1578 | } |
| 1579 | } |
| 1580 | |
| 1581 | /************************************************************************/ |
| 1582 | /* FindNode() */ |
| 1583 | /************************************************************************/ |
| 1584 | |
| 1585 | int OGROSMDataSourcecxx . . $ OGROSMDataSource#::FindNodecxx . . $ OGROSMDataSource#FindNode(a070d6d14e988596).(GIntBigcxx . . $ GIntBig# nID) |
| 1586 | { |
| 1587 | if (m_nReqIdscxx . . $ OGROSMDataSource#m_nReqIds. == 0) |
| 1588 | return -1; |
| 1589 | int iFirst = 0; |
| 1590 | int iLast = m_nReqIdscxx . . $ OGROSMDataSource#m_nReqIds. - 1; |
| 1591 | while (iFirst < iLast) |
| 1592 | { |
| 1593 | int iMid = (iFirst + iLast) / 2; |
| 1594 | if (nID > m_panReqIdscxx . . $ OGROSMDataSource#m_panReqIds.[iMid]) |
| 1595 | iFirst = iMid + 1; |
| 1596 | else |
| 1597 | iLast = iMid; |
| 1598 | } |
| 1599 | if (iFirst == iLast && nID == m_panReqIdscxx . . $ OGROSMDataSource#m_panReqIds.[iFirst]) |
| 1600 | return iFirst; |
| 1601 | return -1; |
| 1602 | } |
| 1603 | |
| 1604 | /************************************************************************/ |
| 1605 | /* ProcessWaysBatch() */ |
| 1606 | /************************************************************************/ |
| 1607 | |
| 1608 | void OGROSMDataSourcecxx . . $ OGROSMDataSource#::ProcessWaysBatchcxx . . $ OGROSMDataSource#ProcessWaysBatch(49f6e7a06ebc5aa8).() |
| 1609 | { |
| 1610 | if (m_asWayFeaturePairscxx . . $ OGROSMDataSource#m_asWayFeaturePairs..empty()) |
| 1611 | return; |
| 1612 | |
| 1613 | // printf("nodes = %d, features = %d\n", nUnsortedReqIds, int(m_asWayFeaturePairs.size())); |
| 1614 | LookupNodescxx . . $ OGROSMDataSource#LookupNodes(49f6e7a06ebc5aa8).(); |
| 1615 | |
| 1616 | for (WayFeaturePaircxx . . $ WayFeaturePair# &sWayFeaturePairs : m_asWayFeaturePairscxx . . $ OGROSMDataSource#m_asWayFeaturePairs.) |
| 1617 | { |
| 1618 | const bool bIsArea = sWayFeaturePairs.bIsAreacxx . . $ WayFeaturePair#bIsArea.; |
| 1619 | m_asLonLatCachecxx . . $ OGROSMDataSource#m_asLonLatCache..clear(); |
| 1620 | |
| 1621 | #ifdef ENABLE_NODE_LOOKUP_BY_HASHINGcxx . . $ `ogr/ogrsf_frmts/osm/ogr_osm.h:17:9`! |
| 1622 | if (m_bHashedIndexValidcxx . . $ OGROSMDataSource#m_bHashedIndexValid.) |
| 1623 | { |
| 1624 | for (unsigned int i = 0; i < sWayFeaturePairs.nRefscxx . . $ WayFeaturePair#nRefs.; i++) |
| 1625 | { |
| 1626 | int nIndInHashArray = static_cast<int>( |
| 1627 | HASH_ID_FUNCcxx . . $ `ogr/ogrsf_frmts/osm/ogrosmdatasource.cpp:150:9`!(sWayFeaturePairs.panNodeRefs[i]) % |
| 1628 | HASHED_INDEXES_ARRAY_SIZEcxx . . $ HASHED_INDEXES_ARRAY_SIZE.); |
| 1629 | int nIdx = m_panHashedIndexescxx . . $ OGROSMDataSource#m_panHashedIndexes.[nIndInHashArray]; |
| 1630 | if (nIdx < -1) |
| 1631 | { |
| 1632 | int iBucket = -nIdx - 2; |
| 1633 | while (true) |
| 1634 | { |
| 1635 | nIdx = m_psCollisionBucketscxx . . $ OGROSMDataSource#m_psCollisionBuckets.[iBucket].nIndcxx . . $ $anonymous_type_52aecf065e0c3ab0_6#nInd.; |
| 1636 | if (m_panReqIdscxx . . $ OGROSMDataSource#m_panReqIds.[nIdx] == |
| 1637 | sWayFeaturePairs.panNodeRefscxx . . $ WayFeaturePair#panNodeRefs.[i]) |
| 1638 | break; |
| 1639 | iBucket = m_psCollisionBucketscxx . . $ OGROSMDataSource#m_psCollisionBuckets.[iBucket].nNextcxx . . $ $anonymous_type_52aecf065e0c3ab0_6#nNext.; |
| 1640 | if (iBucket < 0) |
| 1641 | { |
| 1642 | nIdx = -1; |
| 1643 | break; |
| 1644 | } |
| 1645 | } |
| 1646 | } |
| 1647 | else if (nIdx >= 0 && |
| 1648 | m_panReqIdscxx . . $ OGROSMDataSource#m_panReqIds.[nIdx] != sWayFeaturePairs.panNodeRefscxx . . $ WayFeaturePair#panNodeRefs.[i]) |
| 1649 | nIdx = -1; |
| 1650 | |
| 1651 | if (nIdx >= 0) |
| 1652 | { |
| 1653 | m_asLonLatCachecxx . . $ OGROSMDataSource#m_asLonLatCache..push_back(m_pasLonLatArraycxx . . $ OGROSMDataSource#m_pasLonLatArray.[nIdx]); |
| 1654 | } |
| 1655 | } |
| 1656 | } |
| 1657 | else |
| 1658 | #endif // ENABLE_NODE_LOOKUP_BY_HASHING |
| 1659 | { |
| 1660 | int nIdx = -1; |
| 1661 | for (unsigned int i = 0; i < sWayFeaturePairs.nRefscxx . . $ WayFeaturePair#nRefs.; i++) |
| 1662 | { |
| 1663 | if (nIdx >= 0 && sWayFeaturePairs.panNodeRefscxx . . $ WayFeaturePair#panNodeRefs.[i] == |
| 1664 | sWayFeaturePairs.panNodeRefscxx . . $ WayFeaturePair#panNodeRefs.[i - 1] + 1) |
| 1665 | { |
| 1666 | if (static_cast<unsigned>(nIdx + 1) < m_nReqIdscxx . . $ OGROSMDataSource#m_nReqIds. && |
| 1667 | m_panReqIdscxx . . $ OGROSMDataSource#m_panReqIds.[nIdx + 1] == |
| 1668 | sWayFeaturePairs.panNodeRefscxx . . $ WayFeaturePair#panNodeRefs.[i]) |
| 1669 | nIdx++; |
| 1670 | else |
| 1671 | nIdx = -1; |
| 1672 | } |
| 1673 | else |
| 1674 | nIdx = FindNodecxx . . $ OGROSMDataSource#FindNode(a070d6d14e988596).(sWayFeaturePairs.panNodeRefscxx . . $ WayFeaturePair#panNodeRefs.[i]); |
| 1675 | if (nIdx >= 0) |
| 1676 | { |
| 1677 | m_asLonLatCachecxx . . $ OGROSMDataSource#m_asLonLatCache..push_back(m_pasLonLatArraycxx . . $ OGROSMDataSource#m_pasLonLatArray.[nIdx]); |
| 1678 | } |
| 1679 | } |
| 1680 | } |
| 1681 | |
| 1682 | if (!m_asLonLatCachecxx . . $ OGROSMDataSource#m_asLonLatCache..empty() && bIsArea) |
| 1683 | { |
| 1684 | m_asLonLatCachecxx . . $ OGROSMDataSource#m_asLonLatCache..push_back(m_asLonLatCachecxx . . $ OGROSMDataSource#m_asLonLatCache.[0]); |
| 1685 | } |
| 1686 | |
| 1687 | if (m_asLonLatCachecxx . . $ OGROSMDataSource#m_asLonLatCache..size() < 2) |
| 1688 | { |
| 1689 | CPLDebug("OSM", |
| 1690 | "Way " CPL_FRMT_GIBcxx . . $ `port/cpl_port.h:257:9`! |
| 1691 | " with %d nodes that could be found. Discarding it", |
| 1692 | sWayFeaturePairs.nWayIDcxx . . $ WayFeaturePair#nWayID., |
| 1693 | static_cast<int>(m_asLonLatCachecxx . . $ OGROSMDataSource#m_asLonLatCache..size())); |
| 1694 | sWayFeaturePairs.poFeaturecxx . . $ WayFeaturePair#poFeature..reset(); |
| 1695 | sWayFeaturePairs.bIsAreacxx . . $ WayFeaturePair#bIsArea. = false; |
| 1696 | continue; |
| 1697 | } |
| 1698 | |
| 1699 | if (bIsArea && m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers.[IDX_LYR_MULTIPOLYGONScxx . . $ IDX_LYR_MULTIPOLYGONS.]->IsUserInterestedcxx . . $ OGROSMLayer#IsUserInterested(50ce9a9e25b4a850).()) |
| 1700 | { |
| 1701 | IndexWaycxx . . $ OGROSMDataSource#IndexWay(cc5e18ca7d13d53b).(sWayFeaturePairs.nWayIDcxx . . $ WayFeaturePair#nWayID., /*bIsArea = */ true, |
| 1702 | sWayFeaturePairs.nTagscxx . . $ WayFeaturePair#nTags., sWayFeaturePairs.pasTagscxx . . $ WayFeaturePair#pasTags., |
| 1703 | m_asLonLatCachecxx . . $ OGROSMDataSource#m_asLonLatCache..data(), |
| 1704 | static_cast<int>(m_asLonLatCachecxx . . $ OGROSMDataSource#m_asLonLatCache..size()), |
| 1705 | &sWayFeaturePairs.sInfocxx . . $ WayFeaturePair#sInfo.); |
| 1706 | } |
| 1707 | else |
| 1708 | IndexWaycxx . . $ OGROSMDataSource#IndexWay(cc5e18ca7d13d53b).(sWayFeaturePairs.nWayIDcxx . . $ WayFeaturePair#nWayID., bIsArea, 0, nullptr, |
| 1709 | m_asLonLatCachecxx . . $ OGROSMDataSource#m_asLonLatCache..data(), |
| 1710 | static_cast<int>(m_asLonLatCachecxx . . $ OGROSMDataSource#m_asLonLatCache..size()), nullptr); |
| 1711 | |
| 1712 | if (sWayFeaturePairs.poFeaturecxx . . $ WayFeaturePair#poFeature. == nullptr) |
| 1713 | { |
| 1714 | continue; |
| 1715 | } |
| 1716 | |
| 1717 | OGRLineStringcxx . . $ OGRLineString# *poLS = new OGRLineStringcxx . . $ OGRLineString#OGRLineString(49f6e7a06ebc5aa8).(); |
| 1718 | OGRGeometrycxx . . $ OGRGeometry# *poGeom = poLS; |
| 1719 | |
| 1720 | const int nPoints = static_cast<int>(m_asLonLatCachecxx . . $ OGROSMDataSource#m_asLonLatCache..size()); |
| 1721 | poLS->setNumPointscxx . . $ OGRSimpleCurve#setNumPoints(cf9ef193275fa6d8).(nPoints, /*bZeroizeNewContent=*/false); |
| 1722 | for (int i = 0; i < nPoints; i++) |
| 1723 | { |
| 1724 | poLS->setPointcxx . . $ OGRSimpleCurve#setPoint(9f72e67440d8b329).(i, INT_TO_DBLcxx . . $ INT_TO_DBL(4badf5dbac1308a7).(m_asLonLatCachecxx . . $ OGROSMDataSource#m_asLonLatCache.[i].nLoncxx . . $ $anonymous_type_52aecf065e0c3ab0_5#nLon.), |
| 1725 | INT_TO_DBLcxx . . $ INT_TO_DBL(4badf5dbac1308a7).(m_asLonLatCachecxx . . $ OGROSMDataSource#m_asLonLatCache.[i].nLatcxx . . $ $anonymous_type_52aecf065e0c3ab0_5#nLat.)); |
| 1726 | } |
| 1727 | |
| 1728 | sWayFeaturePairs.poFeaturecxx . . $ WayFeaturePair#poFeature.->SetGeometryDirectlycxx . . $ OGRFeature#SetGeometryDirectly(cec3429dca426eb8).(poGeom); |
| 1729 | |
| 1730 | if (m_asLonLatCachecxx . . $ OGROSMDataSource#m_asLonLatCache..size() != sWayFeaturePairs.nRefscxx . . $ WayFeaturePair#nRefs.) |
| 1731 | CPLDebug("OSM", |
| 1732 | "For way " CPL_FRMT_GIBcxx . . $ `port/cpl_port.h:257:9`! |
| 1733 | ", got only %d nodes instead of %d", |
| 1734 | sWayFeaturePairs.nWayIDcxx . . $ WayFeaturePair#nWayID., nPoints, sWayFeaturePairs.nRefscxx . . $ WayFeaturePair#nRefs.); |
| 1735 | |
| 1736 | bool bFilteredOut = false; |
| 1737 | if (!m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers.[IDX_LYR_LINEScxx . . $ IDX_LYR_LINES.]->AddFeaturecxx . . $ OGROSMLayer#AddFeature(12b17bec2ef920e4).( |
| 1738 | stdcxx . . $ std/::move(sWayFeaturePairs.poFeaturecxx . . $ WayFeaturePair#poFeature.), |
| 1739 | sWayFeaturePairs.bAttrFilterAlreadyEvaluatedcxx . . $ WayFeaturePair#bAttrFilterAlreadyEvaluated., &bFilteredOut, |
| 1740 | !m_bFeatureAddedcxx . . $ OGROSMDataSource#m_bFeatureAdded.)) |
| 1741 | m_bStopParsingcxx . . $ OGROSMDataSource#m_bStopParsing. = true; |
| 1742 | else if (!bFilteredOut) |
| 1743 | m_bFeatureAddedcxx . . $ OGROSMDataSource#m_bFeatureAdded. = true; |
| 1744 | } |
| 1745 | |
| 1746 | if (m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers.[IDX_LYR_MULTIPOLYGONScxx . . $ IDX_LYR_MULTIPOLYGONS.]->IsUserInterestedcxx . . $ OGROSMLayer#IsUserInterested(50ce9a9e25b4a850).()) |
| 1747 | { |
| 1748 | for (WayFeaturePaircxx . . $ WayFeaturePair# &sWayFeaturePairs : m_asWayFeaturePairscxx . . $ OGROSMDataSource#m_asWayFeaturePairs.) |
| 1749 | { |
| 1750 | if (sWayFeaturePairs.bIsAreacxx . . $ WayFeaturePair#bIsArea. && |
| 1751 | (sWayFeaturePairs.nTagscxx . . $ WayFeaturePair#nTags. || m_bReportAllWayscxx . . $ OGROSMDataSource#m_bReportAllWays.)) |
| 1752 | { |
| 1753 | sqlite3_bind_int64(m_hInsertPolygonsStandaloneStmtcxx . . $ OGROSMDataSource#m_hInsertPolygonsStandaloneStmt., 1, |
| 1754 | sWayFeaturePairs.nWayIDcxx . . $ WayFeaturePair#nWayID.); |
| 1755 | |
| 1756 | int rc = sqlite3_step(m_hInsertPolygonsStandaloneStmtcxx . . $ OGROSMDataSource#m_hInsertPolygonsStandaloneStmt.); |
| 1757 | sqlite3_reset(m_hInsertPolygonsStandaloneStmtcxx . . $ OGROSMDataSource#m_hInsertPolygonsStandaloneStmt.); |
| 1758 | if (!(rc == SQLITE_OKcxx . . $ `<external>/2400532043262193228/sqlite3.h:449:9`! || rc == SQLITE_DONEcxx . . $ `<external>/2400532043262193228/sqlite3.h:480:9`!)) |
| 1759 | { |
| 1760 | CPLError(CE_Failure, CPLE_AppDefinedcxx . . $ `port/cpl_error.h:108:9`!, |
| 1761 | "Failed inserting into " |
| 1762 | "polygons_standalone " CPL_FRMT_GIBcxx . . $ `port/cpl_port.h:257:9`! ": %s", |
| 1763 | sWayFeaturePairs.nWayIDcxx . . $ WayFeaturePair#nWayID., sqlite3_errmsg(m_hDBcxx . . $ OGROSMDataSource#m_hDB.)); |
| 1764 | } |
| 1765 | } |
| 1766 | } |
| 1767 | } |
| 1768 | |
| 1769 | m_asWayFeaturePairscxx . . $ OGROSMDataSource#m_asWayFeaturePairs..clear(); |
| 1770 | m_nUnsortedReqIdscxx . . $ OGROSMDataSource#m_nUnsortedReqIds. = 0; |
| 1771 | |
| 1772 | m_nAccumulatedTagscxx . . $ OGROSMDataSource#m_nAccumulatedTags. = 0; |
| 1773 | nNonRedundantKeysLencxx . . $ OGROSMDataSource#nNonRedundantKeysLen. = 0; |
| 1774 | nNonRedundantValuesLencxx . . $ OGROSMDataSource#nNonRedundantValuesLen. = 0; |
| 1775 | } |
| 1776 | |
| 1777 | /************************************************************************/ |
| 1778 | /* IsClosedWayTaggedAsPolygon() */ |
| 1779 | /************************************************************************/ |
| 1780 | |
| 1781 | bool OGROSMDataSourcecxx . . $ OGROSMDataSource#::IsClosedWayTaggedAsPolygoncxx . . $ OGROSMDataSource#IsClosedWayTaggedAsPolygon(a4b3c0f14baeb322).(unsigned int nTags, |
| 1782 | const OSMTag *pasTags) |
| 1783 | { |
| 1784 | bool bIsArea = false; |
| 1785 | const int nSizeArea = 4; |
| 1786 | const int nStrnlenK = |
| 1787 | stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(nSizeArea, m_nMaxSizeKeysInSetClosedWaysArePolygonscxx . . $ OGROSMDataSource#m_nMaxSizeKeysInSetClosedWaysArePolygons.) + 1; |
| 1788 | stdcxx . . $ std/::string oTmpStr; |
| 1789 | oTmpStr.reserve(m_nMaxSizeKeysInSetClosedWaysArePolygonscxx . . $ OGROSMDataSource#m_nMaxSizeKeysInSetClosedWaysArePolygons.); |
| 1790 | for (unsigned int i = 0; i < nTags; i++) |
| 1791 | { |
| 1792 | const char *pszK = pasTags[i].pszK; |
| 1793 | const int nKLen = static_cast<int>(CPLStrnlen(pszK, nStrnlenK)); |
| 1794 | if (nKLen > m_nMaxSizeKeysInSetClosedWaysArePolygonscxx . . $ OGROSMDataSource#m_nMaxSizeKeysInSetClosedWaysArePolygons.) |
| 1795 | continue; |
| 1796 | |
| 1797 | if (nKLen == nSizeArea && strcmp(pszK, "area") == 0) |
| 1798 | { |
| 1799 | const char *pszV = pasTags[i].pszV; |
| 1800 | if (strcmp(pszV, "yes") == 0) |
| 1801 | { |
| 1802 | bIsArea = true; |
| 1803 | // final true. We can't have several area tags... |
| 1804 | break; |
| 1805 | } |
| 1806 | else if (strcmp(pszV, "no") == 0) |
| 1807 | { |
| 1808 | bIsArea = false; |
| 1809 | break; |
| 1810 | } |
| 1811 | } |
| 1812 | if (bIsArea) |
| 1813 | continue; |
| 1814 | |
| 1815 | if (nKLen >= m_nMinSizeKeysInSetClosedWaysArePolygonscxx . . $ OGROSMDataSource#m_nMinSizeKeysInSetClosedWaysArePolygons.) |
| 1816 | { |
| 1817 | oTmpStr.assign(pszK, nKLen); |
| 1818 | if (aoSetClosedWaysArePolygonscxx . . $ OGROSMDataSource#aoSetClosedWaysArePolygons..findcxx . . $ std/unordered_set#find(2e5c193be73a443f).(oTmpStr) !=cxx . . $ std/__detail/`operator!=`(6ab342297d2d0253). |
| 1819 | aoSetClosedWaysArePolygonscxx . . $ OGROSMDataSource#aoSetClosedWaysArePolygons..endcxx . . $ std/unordered_set#end(2c0786e257a8dc8e).()) |
| 1820 | { |
| 1821 | bIsArea = true; |
| 1822 | continue; |
| 1823 | } |
| 1824 | } |
| 1825 | |
| 1826 | const char *pszV = pasTags[i].pszV; |
| 1827 | const int nVLen = static_cast<int>(CPLStrnlen(pszV, nStrnlenK)); |
| 1828 | if (nKLen + 1 + nVLen >= m_nMinSizeKeysInSetClosedWaysArePolygonscxx . . $ OGROSMDataSource#m_nMinSizeKeysInSetClosedWaysArePolygons. && |
| 1829 | nKLen + 1 + nVLen <= m_nMaxSizeKeysInSetClosedWaysArePolygonscxx . . $ OGROSMDataSource#m_nMaxSizeKeysInSetClosedWaysArePolygons.) |
| 1830 | { |
| 1831 | oTmpStr.assign(pszK, nKLen); |
| 1832 | oTmpStr.append(1, '='); |
| 1833 | oTmpStr.append(pszV, nVLen); |
| 1834 | if (aoSetClosedWaysArePolygonscxx . . $ OGROSMDataSource#aoSetClosedWaysArePolygons..findcxx . . $ std/unordered_set#find(2e5c193be73a443f).(oTmpStr) !=cxx . . $ std/__detail/`operator!=`(6ab342297d2d0253). |
| 1835 | aoSetClosedWaysArePolygonscxx . . $ OGROSMDataSource#aoSetClosedWaysArePolygons..endcxx . . $ std/unordered_set#end(2c0786e257a8dc8e).()) |
| 1836 | { |
| 1837 | bIsArea = true; |
| 1838 | continue; |
| 1839 | } |
| 1840 | } |
| 1841 | } |
| 1842 | return bIsArea; |
| 1843 | } |
| 1844 | |
| 1845 | /************************************************************************/ |
| 1846 | /* NotifyWay() */ |
| 1847 | /************************************************************************/ |
| 1848 | |
| 1849 | void OGROSMDataSourcecxx . . $ OGROSMDataSource#::NotifyWaycxx . . $ OGROSMDataSource#NotifyWay(52e4c728d2f7219c).(const OSMWay *psWay) |
| 1850 | { |
| 1851 | m_nWaysProcessedcxx . . $ OGROSMDataSource#m_nWaysProcessed.++; |
| 1852 | if (m_nWaysProcessedcxx . . $ OGROSMDataSource#m_nWaysProcessed. % 10000 == 0) |
| 1853 | { |
| 1854 | CPLDebug("OSM", "Ways processed : %d", m_nWaysProcessedcxx . . $ OGROSMDataSource#m_nWaysProcessed.); |
| 1855 | #ifdef DEBUG_MEM_USAGE |
| 1856 | CPLDebug("OSM", "GetMaxTotalAllocs() = " CPL_FRMT_GUIB, |
| 1857 | static_cast<GUIntBig>(GetMaxTotalAllocs())); |
| 1858 | #endif |
| 1859 | } |
| 1860 | |
| 1861 | if (!m_bUsePointsIndexcxx . . $ OGROSMDataSource#m_bUsePointsIndex.) |
| 1862 | return; |
| 1863 | |
| 1864 | // printf("way %d : %d nodes\n", (int)psWay->nID, (int)psWay->nRefs); |
| 1865 | |
| 1866 | if (psWay->nRefs < 2) |
| 1867 | { |
| 1868 | CPLDebug("OSM", "Way " CPL_FRMT_GIBcxx . . $ `port/cpl_port.h:257:9`! " with %d nodes. Discarding it", |
| 1869 | psWay->nID, psWay->nRefs); |
| 1870 | return; |
| 1871 | } |
| 1872 | |
| 1873 | /* Is a closed way a polygon ? */ |
| 1874 | bool bIsArea = false; |
| 1875 | if (psWay->panNodeRefs[0] == psWay->panNodeRefs[psWay->nRefs - 1]) |
| 1876 | { |
| 1877 | bIsArea = IsClosedWayTaggedAsPolygoncxx . . $ OGROSMDataSource#IsClosedWayTaggedAsPolygon(a4b3c0f14baeb322).(psWay->nTags, psWay->pasTags); |
| 1878 | } |
| 1879 | |
| 1880 | bool bInterestingTag = m_bReportAllWayscxx . . $ OGROSMDataSource#m_bReportAllWays.; |
| 1881 | if (!bIsArea && !m_bReportAllWayscxx . . $ OGROSMDataSource#m_bReportAllWays.) |
| 1882 | { |
| 1883 | for (unsigned int i = 0; i < psWay->nTags; i++) |
| 1884 | { |
| 1885 | const char *pszK = psWay->pasTags[i].pszK; |
| 1886 | if (m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers.[IDX_LYR_LINEScxx . . $ IDX_LYR_LINES.]->IsSignificantKeycxx . . $ OGROSMLayer#IsSignificantKey(78f035161ffa9fe2).(pszK)) |
| 1887 | { |
| 1888 | bInterestingTag = true; |
| 1889 | break; |
| 1890 | } |
| 1891 | } |
| 1892 | } |
| 1893 | |
| 1894 | stdcxx . . $ std/::unique_ptr<OGRFeaturecxx . . $ OGRFeature#> poFeature; |
| 1895 | bool bAttrFilterAlreadyEvaluated = false; |
| 1896 | if (!bIsArea && m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers.[IDX_LYR_LINEScxx . . $ IDX_LYR_LINES.]->IsUserInterestedcxx . . $ OGROSMLayer#IsUserInterested(50ce9a9e25b4a850).() && |
| 1897 | bInterestingTag) |
| 1898 | { |
| 1899 | poFeature = stdcxx . . $ std/::make_unique<OGRFeaturecxx . . $ OGRFeature#>( |
| 1900 | m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers.[IDX_LYR_LINEScxx . . $ IDX_LYR_LINES.]->GetLayerDefncxx . . $ OGRLayer#GetLayerDefn(407fccde18759965).()); |
| 1901 | |
| 1902 | m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers.[IDX_LYR_LINEScxx . . $ IDX_LYR_LINES.]->SetFieldsFromTagscxx . . $ OGROSMLayer#SetFieldsFromTags(49bbf9dc4001c2e3).( |
| 1903 | poFeature.get(), psWay->nID, false, psWay->nTags, psWay->pasTags, |
| 1904 | &psWay->sInfo); |
| 1905 | |
| 1906 | // Optimization: if we have an attribute filter, that does not require |
| 1907 | // geometry, and if we don't need to index ways, then we can just |
| 1908 | // evaluate the attribute filter without the geometry. |
| 1909 | if (m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers.[IDX_LYR_LINEScxx . . $ IDX_LYR_LINES.]->HasAttributeFiltercxx . . $ OGROSMLayer#HasAttributeFilter(455f465bc33b4cdf).() && |
| 1910 | !m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers.[IDX_LYR_LINEScxx . . $ IDX_LYR_LINES.] |
| 1911 | ->AttributeFilterEvaluationNeedsGeometrycxx . . $ OGRLayer#AttributeFilterEvaluationNeedsGeometry(b126dc7c1de90089).() && |
| 1912 | !m_bIndexWayscxx . . $ OGROSMDataSource#m_bIndexWays.) |
| 1913 | { |
| 1914 | if (!m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers.[IDX_LYR_LINEScxx . . $ IDX_LYR_LINES.]->EvaluateAttributeFiltercxx . . $ OGROSMLayer#EvaluateAttributeFilter(2048609adab03aab).( |
| 1915 | poFeature.get())) |
| 1916 | { |
| 1917 | return; |
| 1918 | } |
| 1919 | bAttrFilterAlreadyEvaluated = true; |
| 1920 | } |
| 1921 | } |
| 1922 | else if (!m_bIndexWayscxx . . $ OGROSMDataSource#m_bIndexWays.) |
| 1923 | { |
| 1924 | return; |
| 1925 | } |
| 1926 | |
| 1927 | if (m_nUnsortedReqIdscxx . . $ OGROSMDataSource#m_nUnsortedReqIds. + psWay->nRefs > |
| 1928 | static_cast<unsigned int>(MAX_ACCUMULATED_NODEScxx . . $ MAX_ACCUMULATED_NODES.) || |
| 1929 | m_asWayFeaturePairscxx . . $ OGROSMDataSource#m_asWayFeaturePairs..size() == |
| 1930 | static_cast<size_t>(MAX_DELAYED_FEATUREScxx . . $ MAX_DELAYED_FEATURES.) || |
| 1931 | m_nAccumulatedTagscxx . . $ OGROSMDataSource#m_nAccumulatedTags. + psWay->nTags > |
| 1932 | static_cast<unsigned int>(MAX_ACCUMULATED_TAGScxx . . $ MAX_ACCUMULATED_TAGS.) || |
| 1933 | nNonRedundantKeysLencxx . . $ OGROSMDataSource#nNonRedundantKeysLen. + 1024 > MAX_NON_REDUNDANT_KEYScxx . . $ MAX_NON_REDUNDANT_KEYS. || |
| 1934 | nNonRedundantValuesLencxx . . $ OGROSMDataSource#nNonRedundantValuesLen. + 1024 > MAX_NON_REDUNDANT_VALUEScxx . . $ MAX_NON_REDUNDANT_VALUES.) |
| 1935 | { |
| 1936 | ProcessWaysBatchcxx . . $ OGROSMDataSource#ProcessWaysBatch(49f6e7a06ebc5aa8).(); |
| 1937 | } |
| 1938 | |
| 1939 | m_asWayFeaturePairscxx . . $ OGROSMDataSource#m_asWayFeaturePairs..push_back(WayFeaturePaircxx . . $ WayFeaturePair#()); |
| 1940 | WayFeaturePaircxx . . $ WayFeaturePair# &sWayFeaturePairs = m_asWayFeaturePairscxx . . $ OGROSMDataSource#m_asWayFeaturePairs..back(); |
| 1941 | |
| 1942 | sWayFeaturePairs.nWayIDcxx . . $ WayFeaturePair#nWayID. = psWay->nID; |
| 1943 | sWayFeaturePairs.nRefscxx . . $ WayFeaturePair#nRefs. = psWay->nRefs - (bIsArea ? 1 : 0); |
| 1944 | sWayFeaturePairs.panNodeRefscxx . . $ WayFeaturePair#panNodeRefs. = m_panUnsortedReqIdscxx . . $ OGROSMDataSource#m_panUnsortedReqIds. + m_nUnsortedReqIdscxx . . $ OGROSMDataSource#m_nUnsortedReqIds.; |
| 1945 | sWayFeaturePairs.poFeaturecxx . . $ WayFeaturePair#poFeature. = stdcxx . . $ std/::move(poFeature); |
| 1946 | sWayFeaturePairs.bIsAreacxx . . $ WayFeaturePair#bIsArea. = bIsArea; |
| 1947 | sWayFeaturePairs.bAttrFilterAlreadyEvaluatedcxx . . $ WayFeaturePair#bAttrFilterAlreadyEvaluated. = bAttrFilterAlreadyEvaluated; |
| 1948 | |
| 1949 | if (bIsArea && m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers.[IDX_LYR_MULTIPOLYGONScxx . . $ IDX_LYR_MULTIPOLYGONS.]->IsUserInterestedcxx . . $ OGROSMLayer#IsUserInterested(50ce9a9e25b4a850).()) |
| 1950 | { |
| 1951 | unsigned int nTagCount = 0; |
| 1952 | |
| 1953 | if (m_bNeedsToSaveWayInfocxx . . $ OGROSMDataSource#m_bNeedsToSaveWayInfo.) |
| 1954 | { |
| 1955 | if (!psWay->sInfo.bTimeStampIsStr) |
| 1956 | sWayFeaturePairs.sInfocxx . . $ WayFeaturePair#sInfo..ts.nTimeStamp = |
| 1957 | psWay->sInfo.ts.nTimeStamp; |
| 1958 | else |
| 1959 | { |
| 1960 | OGRField sField; |
| 1961 | if (OGRParseXMLDateTimecxx . . $ OGRParseXMLDateTime(c316f346bf930ae).(psWay->sInfo.ts.pszTimeStamp, &sField)) |
| 1962 | { |
| 1963 | struct tmcxx . . $ tm# brokendown; |
| 1964 | memset(&brokendown, 0, sizeof(brokendown)); |
| 1965 | brokendown.tm_yearcxx . . $ tm#tm_year. = sField.Date.Year - 1900; |
| 1966 | brokendown.tm_moncxx . . $ tm#tm_mon. = sField.Date.Month - 1; |
| 1967 | brokendown.tm_mdaycxx . . $ tm#tm_mday. = sField.Date.Day; |
| 1968 | brokendown.tm_hourcxx . . $ tm#tm_hour. = sField.Date.Hour; |
| 1969 | brokendown.tm_mincxx . . $ tm#tm_min. = sField.Date.Minute; |
| 1970 | brokendown.tm_seccxx . . $ tm#tm_sec. = |
| 1971 | static_cast<int>(sField.Date.Second + .5); |
| 1972 | sWayFeaturePairs.sInfocxx . . $ WayFeaturePair#sInfo..ts.nTimeStamp = |
| 1973 | CPLYMDHMSToUnixTimecxx . . $ CPLYMDHMSToUnixTime(c2c1c9b2168a19ef).(&brokendown); |
| 1974 | } |
| 1975 | else |
| 1976 | sWayFeaturePairs.sInfocxx . . $ WayFeaturePair#sInfo..ts.nTimeStamp = 0; |
| 1977 | } |
| 1978 | sWayFeaturePairs.sInfocxx . . $ WayFeaturePair#sInfo..nChangeset = psWay->sInfo.nChangeset; |
| 1979 | sWayFeaturePairs.sInfocxx . . $ WayFeaturePair#sInfo..nVersion = psWay->sInfo.nVersion; |
| 1980 | sWayFeaturePairs.sInfocxx . . $ WayFeaturePair#sInfo..nUID = psWay->sInfo.nUID; |
| 1981 | sWayFeaturePairs.sInfocxx . . $ WayFeaturePair#sInfo..bTimeStampIsStr = false; |
| 1982 | sWayFeaturePairs.sInfocxx . . $ WayFeaturePair#sInfo..pszUserSID = ""; // FIXME |
| 1983 | } |
| 1984 | else |
| 1985 | { |
| 1986 | sWayFeaturePairs.sInfocxx . . $ WayFeaturePair#sInfo..ts.nTimeStamp = 0; |
| 1987 | sWayFeaturePairs.sInfocxx . . $ WayFeaturePair#sInfo..nChangeset = 0; |
| 1988 | sWayFeaturePairs.sInfocxx . . $ WayFeaturePair#sInfo..nVersion = 0; |
| 1989 | sWayFeaturePairs.sInfocxx . . $ WayFeaturePair#sInfo..nUID = 0; |
| 1990 | sWayFeaturePairs.sInfocxx . . $ WayFeaturePair#sInfo..bTimeStampIsStr = false; |
| 1991 | sWayFeaturePairs.sInfocxx . . $ WayFeaturePair#sInfo..pszUserSID = ""; |
| 1992 | } |
| 1993 | |
| 1994 | sWayFeaturePairs.pasTagscxx . . $ WayFeaturePair#pasTags. = m_pasAccumulatedTagscxx . . $ OGROSMDataSource#m_pasAccumulatedTags. + m_nAccumulatedTagscxx . . $ OGROSMDataSource#m_nAccumulatedTags.; |
| 1995 | |
| 1996 | for (unsigned int iTag = 0; iTag < psWay->nTags; iTag++) |
| 1997 | { |
| 1998 | const char *pszK = psWay->pasTags[iTag].pszK; |
| 1999 | const char *pszV = psWay->pasTags[iTag].pszV; |
| 2000 | |
| 2001 | if (stdcxx . . $ std/::any_ofcxx . . $ std/any_of(f82cc6ce9cd000ea).(begin(m_ignoredKeyscxx . . $ OGROSMDataSource#m_ignoredKeys.), end(m_ignoredKeyscxx . . $ OGROSMDataSource#m_ignoredKeys.), |
| 2002 | [pszK](const char *pszIgnoredKey) |
| 2003 | { return strcmp(pszK, pszIgnoredKey) == 0; })) |
| 2004 | { |
| 2005 | continue; |
| 2006 | } |
| 2007 | |
| 2008 | auto oIterK = m_aoMapIndexedKeyscxx . . $ OGROSMDataSource#m_aoMapIndexedKeys..findcxx . . $ std/map#find(36f8d56706583706).(pszK); |
| 2009 | KeyDesccxx . . $ KeyDesc# *psKD = nullptr; |
| 2010 | if (oIterK ==cxx . . $ std/`operator==`(be6a71a859368080). m_aoMapIndexedKeyscxx . . $ OGROSMDataSource#m_aoMapIndexedKeys..endcxx . . $ std/map#end(7e4de33083b6e738).()) |
| 2011 | { |
| 2012 | if (m_apsKeyscxx . . $ OGROSMDataSource#m_apsKeys..size() >= 1 + MAX_INDEXED_KEYScxx . . $ OGROSMDataSource#MAX_INDEXED_KEYS.) |
| 2013 | { |
| 2014 | if (m_apsKeyscxx . . $ OGROSMDataSource#m_apsKeys..size() == 1 + MAX_INDEXED_KEYScxx . . $ OGROSMDataSource#MAX_INDEXED_KEYS.) |
| 2015 | { |
| 2016 | CPLDebug("OSM", "More than %d different keys found", |
| 2017 | MAX_INDEXED_KEYScxx . . $ OGROSMDataSource#MAX_INDEXED_KEYS.); |
| 2018 | // To avoid next warnings. |
| 2019 | m_apsKeyscxx . . $ OGROSMDataSource#m_apsKeys..push_back(nullptr); |
| 2020 | } |
| 2021 | |
| 2022 | const int nLenK = static_cast<int>(strlen(pszK)) + 1; |
| 2023 | if (nNonRedundantKeysLencxx . . $ OGROSMDataSource#nNonRedundantKeysLen. + nLenK > MAX_NON_REDUNDANT_KEYScxx . . $ MAX_NON_REDUNDANT_KEYS.) |
| 2024 | { |
| 2025 | CPLError(CE_Failure, CPLE_AppDefinedcxx . . $ `port/cpl_error.h:108:9`!, |
| 2026 | "Too many/too long keys found"); |
| 2027 | continue; |
| 2028 | } |
| 2029 | memcpy(pabyNonRedundantKeyscxx . . $ OGROSMDataSource#pabyNonRedundantKeys. + nNonRedundantKeysLencxx . . $ OGROSMDataSource#nNonRedundantKeysLen., pszK, |
| 2030 | nLenK); |
| 2031 | m_pasAccumulatedTagscxx . . $ OGROSMDataSource#m_pasAccumulatedTags.[m_nAccumulatedTagscxx . . $ OGROSMDataSource#m_nAccumulatedTags.].bKIsIndexcxx . . $ $anonymous_type_52aecf065e0c3ab0_0#bKIsIndex. = FALSEcxx . . $ `port/cpl_port.h:1180:9`!; |
| 2032 | m_pasAccumulatedTagscxx . . $ OGROSMDataSource#m_pasAccumulatedTags.[m_nAccumulatedTagscxx . . $ OGROSMDataSource#m_nAccumulatedTags.] |
| 2033 | .uKeycxx . . $ $anonymous_type_52aecf065e0c3ab0_0#uKey..nOffsetInpabyNonRedundantKeyscxx . . $ $anonymous_type_52aecf065e0c3ab0_0#$anonymous_type_1#nOffsetInpabyNonRedundantKeys. = |
| 2034 | nNonRedundantKeysLencxx . . $ OGROSMDataSource#nNonRedundantKeysLen.; |
| 2035 | nNonRedundantKeysLencxx . . $ OGROSMDataSource#nNonRedundantKeysLen. += nLenK; |
| 2036 | } |
| 2037 | else |
| 2038 | { |
| 2039 | psKD = new KeyDesccxx . . $ KeyDesc#(); |
| 2040 | psKD->pszKcxx . . $ KeyDesc#pszK. = CPLStrdup(pszK); |
| 2041 | psKD->nKeyIndexcxx . . $ KeyDesc#nKeyIndex. = static_cast<int>(m_apsKeyscxx . . $ OGROSMDataSource#m_apsKeys..size()); |
| 2042 | psKD->nOccurrencescxx . . $ KeyDesc#nOccurrences. = 0; |
| 2043 | psKD->apszValuescxx . . $ KeyDesc#apszValues..push_back(CPLStrdup( |
| 2044 | "")); // guard value to avoid index 0 to be used |
| 2045 | m_aoMapIndexedKeyscxx . . $ OGROSMDataSource#m_aoMapIndexedKeys.[cxx . . $ std/map#`operator[]`(bbd415b616967878).psKD->pszKcxx . . $ KeyDesc#pszK.] = psKD; |
| 2046 | m_apsKeyscxx . . $ OGROSMDataSource#m_apsKeys..push_back(psKD); |
| 2047 | } |
| 2048 | } |
| 2049 | else |
| 2050 | { |
| 2051 | psKD = oIterK->cxx . . $ std/_Rb_tree_iterator#`operator->`(34d6acfd341ba7ab).second; |
| 2052 | } |
| 2053 | |
| 2054 | if (psKD) |
| 2055 | { |
| 2056 | psKD->nOccurrencescxx . . $ KeyDesc#nOccurrences.++; |
| 2057 | m_pasAccumulatedTagscxx . . $ OGROSMDataSource#m_pasAccumulatedTags.[m_nAccumulatedTagscxx . . $ OGROSMDataSource#m_nAccumulatedTags.].bKIsIndexcxx . . $ $anonymous_type_52aecf065e0c3ab0_0#bKIsIndex. = TRUEcxx . . $ `port/cpl_port.h:1184:9`!; |
| 2058 | m_pasAccumulatedTagscxx . . $ OGROSMDataSource#m_pasAccumulatedTags.[m_nAccumulatedTagscxx . . $ OGROSMDataSource#m_nAccumulatedTags.].uKeycxx . . $ $anonymous_type_52aecf065e0c3ab0_0#uKey..nKeyIndexcxx . . $ $anonymous_type_52aecf065e0c3ab0_0#$anonymous_type_1#nKeyIndex. = |
| 2059 | psKD->nKeyIndexcxx . . $ KeyDesc#nKeyIndex.; |
| 2060 | } |
| 2061 | |
| 2062 | if (psKD != nullptr && |
| 2063 | psKD->apszValuescxx . . $ KeyDesc#apszValues..size() < 1 + MAX_INDEXED_VALUES_PER_KEYcxx . . $ OGROSMDataSource#MAX_INDEXED_VALUES_PER_KEY.) |
| 2064 | { |
| 2065 | int nValueIndex = 0; |
| 2066 | auto oIterV = psKD->anMapVcxx . . $ KeyDesc#anMapV..findcxx . . $ std/map#find(36f8d56706583706).(pszV); |
| 2067 | if (oIterV ==cxx . . $ std/`operator==`(be6a71a859368080). psKD->anMapVcxx . . $ KeyDesc#anMapV..endcxx . . $ std/map#end(7e4de33083b6e738).()) |
| 2068 | { |
| 2069 | char *pszVDup = CPLStrdup(pszV); |
| 2070 | nValueIndex = static_cast<int>(psKD->apszValuescxx . . $ KeyDesc#apszValues..size()); |
| 2071 | psKD->anMapVcxx . . $ KeyDesc#anMapV.[cxx . . $ std/map#`operator[]`(bbd415b616967878).pszVDup] = nValueIndex; |
| 2072 | psKD->apszValuescxx . . $ KeyDesc#apszValues..push_back(pszVDup); |
| 2073 | } |
| 2074 | else |
| 2075 | nValueIndex = oIterV->cxx . . $ std/_Rb_tree_iterator#`operator->`(34d6acfd341ba7ab).second; |
| 2076 | |
| 2077 | m_pasAccumulatedTagscxx . . $ OGROSMDataSource#m_pasAccumulatedTags.[m_nAccumulatedTagscxx . . $ OGROSMDataSource#m_nAccumulatedTags.].bVIsIndexcxx . . $ $anonymous_type_52aecf065e0c3ab0_0#bVIsIndex. = TRUEcxx . . $ `port/cpl_port.h:1184:9`!; |
| 2078 | m_pasAccumulatedTagscxx . . $ OGROSMDataSource#m_pasAccumulatedTags.[m_nAccumulatedTagscxx . . $ OGROSMDataSource#m_nAccumulatedTags.].uValcxx . . $ $anonymous_type_52aecf065e0c3ab0_0#uVal..nValueIndexcxx . . $ $anonymous_type_52aecf065e0c3ab0_0#$anonymous_type_2#nValueIndex. = |
| 2079 | nValueIndex; |
| 2080 | } |
| 2081 | else |
| 2082 | { |
| 2083 | const int nLenV = static_cast<int>(strlen(pszV)) + 1; |
| 2084 | |
| 2085 | if (psKD != nullptr && |
| 2086 | psKD->apszValuescxx . . $ KeyDesc#apszValues..size() == 1 + MAX_INDEXED_VALUES_PER_KEYcxx . . $ OGROSMDataSource#MAX_INDEXED_VALUES_PER_KEY.) |
| 2087 | { |
| 2088 | CPLDebug("OSM", "More than %d different values for tag %s", |
| 2089 | MAX_INDEXED_VALUES_PER_KEYcxx . . $ OGROSMDataSource#MAX_INDEXED_VALUES_PER_KEY., pszK); |
| 2090 | // To avoid next warnings. |
| 2091 | psKD->apszValuescxx . . $ KeyDesc#apszValues..push_back(CPLStrdup("")); |
| 2092 | } |
| 2093 | |
| 2094 | if (nNonRedundantValuesLencxx . . $ OGROSMDataSource#nNonRedundantValuesLen. + nLenV > MAX_NON_REDUNDANT_VALUEScxx . . $ MAX_NON_REDUNDANT_VALUES.) |
| 2095 | { |
| 2096 | CPLError(CE_Failure, CPLE_AppDefinedcxx . . $ `port/cpl_error.h:108:9`!, |
| 2097 | "Too many/too long values found"); |
| 2098 | continue; |
| 2099 | } |
| 2100 | memcpy(pabyNonRedundantValuescxx . . $ OGROSMDataSource#pabyNonRedundantValues. + nNonRedundantValuesLencxx . . $ OGROSMDataSource#nNonRedundantValuesLen., pszV, |
| 2101 | nLenV); |
| 2102 | m_pasAccumulatedTagscxx . . $ OGROSMDataSource#m_pasAccumulatedTags.[m_nAccumulatedTagscxx . . $ OGROSMDataSource#m_nAccumulatedTags.].bVIsIndexcxx . . $ $anonymous_type_52aecf065e0c3ab0_0#bVIsIndex. = FALSEcxx . . $ `port/cpl_port.h:1180:9`!; |
| 2103 | m_pasAccumulatedTagscxx . . $ OGROSMDataSource#m_pasAccumulatedTags.[m_nAccumulatedTagscxx . . $ OGROSMDataSource#m_nAccumulatedTags.] |
| 2104 | .uValcxx . . $ $anonymous_type_52aecf065e0c3ab0_0#uVal..nOffsetInpabyNonRedundantValuescxx . . $ $anonymous_type_52aecf065e0c3ab0_0#$anonymous_type_2#nOffsetInpabyNonRedundantValues. = |
| 2105 | nNonRedundantValuesLencxx . . $ OGROSMDataSource#nNonRedundantValuesLen.; |
| 2106 | nNonRedundantValuesLencxx . . $ OGROSMDataSource#nNonRedundantValuesLen. += nLenV; |
| 2107 | } |
| 2108 | m_nAccumulatedTagscxx . . $ OGROSMDataSource#m_nAccumulatedTags.++; |
| 2109 | |
| 2110 | nTagCount++; |
| 2111 | if (nTagCount == MAX_COUNT_FOR_TAGS_IN_WAYcxx . . $ MAX_COUNT_FOR_TAGS_IN_WAY.) |
| 2112 | break; |
| 2113 | } |
| 2114 | |
| 2115 | sWayFeaturePairs.nTagscxx . . $ WayFeaturePair#nTags. = nTagCount; |
| 2116 | } |
| 2117 | else |
| 2118 | { |
| 2119 | sWayFeaturePairs.sInfocxx . . $ WayFeaturePair#sInfo..ts.nTimeStamp = 0; |
| 2120 | sWayFeaturePairs.sInfocxx . . $ WayFeaturePair#sInfo..nChangeset = 0; |
| 2121 | sWayFeaturePairs.sInfocxx . . $ WayFeaturePair#sInfo..nVersion = 0; |
| 2122 | sWayFeaturePairs.sInfocxx . . $ WayFeaturePair#sInfo..nUID = 0; |
| 2123 | sWayFeaturePairs.sInfocxx . . $ WayFeaturePair#sInfo..bTimeStampIsStr = false; |
| 2124 | sWayFeaturePairs.sInfocxx . . $ WayFeaturePair#sInfo..pszUserSID = ""; |
| 2125 | |
| 2126 | sWayFeaturePairs.nTagscxx . . $ WayFeaturePair#nTags. = 0; |
| 2127 | sWayFeaturePairs.pasTagscxx . . $ WayFeaturePair#pasTags. = nullptr; |
| 2128 | } |
| 2129 | |
| 2130 | memcpy(m_panUnsortedReqIdscxx . . $ OGROSMDataSource#m_panUnsortedReqIds. + m_nUnsortedReqIdscxx . . $ OGROSMDataSource#m_nUnsortedReqIds., psWay->panNodeRefs, |
| 2131 | sizeof(GIntBigcxx . . $ GIntBig#) * (psWay->nRefs - (bIsArea ? 1 : 0))); |
| 2132 | m_nUnsortedReqIdscxx . . $ OGROSMDataSource#m_nUnsortedReqIds. += (psWay->nRefs - (bIsArea ? 1 : 0)); |
| 2133 | } |
| 2134 | |
| 2135 | static void OGROSMNotifyWaycxx . . $ OGROSMNotifyWay(a24678ce2f4cb2ed).(OSMWay *psWay, OSMContext * /* psOSMContext */, |
| 2136 | void *user_data) |
| 2137 | { |
| 2138 | static_cast<OGROSMDataSourcecxx . . $ OGROSMDataSource# *>(user_data)->NotifyWaycxx . . $ OGROSMDataSource#NotifyWay(52e4c728d2f7219c).(psWay); |
| 2139 | } |
| 2140 | |
| 2141 | /************************************************************************/ |
| 2142 | /* LookupWays() */ |
| 2143 | /************************************************************************/ |
| 2144 | |
| 2145 | unsigned int OGROSMDataSourcecxx . . $ OGROSMDataSource#::LookupWayscxx . . $ OGROSMDataSource#LookupWays(25f9d76f384ec7db).( |
| 2146 | stdcxx . . $ std/::mapcxx . . $ std/map#<GIntBigcxx . . $ GIntBig#, stdcxx . . $ std/::pair<int, void *>> &aoMapWays, |
| 2147 | const OSMRelation *psRelation) |
| 2148 | { |
| 2149 | unsigned int nFound = 0; |
| 2150 | unsigned int iCur = 0; |
| 2151 | |
| 2152 | while (iCur < psRelation->nMembers) |
| 2153 | { |
| 2154 | unsigned int nToQuery = 0; |
| 2155 | unsigned int i = iCur; // Used after for. |
| 2156 | for (; i < psRelation->nMembers; i++) |
| 2157 | { |
| 2158 | if (psRelation->pasMembers[i].eType == MEMBER_WAY && |
| 2159 | strcmp(psRelation->pasMembers[i].pszRole, "subarea") != 0) |
| 2160 | { |
| 2161 | nToQuery++; |
| 2162 | if (nToQuery == |
| 2163 | static_cast<unsigned int>(LIMIT_IDS_PER_REQUESTcxx . . $ LIMIT_IDS_PER_REQUEST.)) |
| 2164 | { |
| 2165 | break; |
| 2166 | } |
| 2167 | } |
| 2168 | } |
| 2169 | |
| 2170 | if (nToQuery == 0) |
| 2171 | break; |
| 2172 | |
| 2173 | unsigned int iLastI = (i == psRelation->nMembers) ? i : i + 1; |
| 2174 | |
| 2175 | sqlite3_stmt *hStmt = m_pahSelectWayStmtcxx . . $ OGROSMDataSource#m_pahSelectWayStmt.[nToQuery - 1]; |
| 2176 | unsigned int nBindIndex = 1; |
| 2177 | for (i = iCur; i < iLastI; i++) |
| 2178 | { |
| 2179 | if (psRelation->pasMembers[i].eType == MEMBER_WAY && |
| 2180 | strcmp(psRelation->pasMembers[i].pszRole, "subarea") != 0) |
| 2181 | { |
| 2182 | sqlite3_bind_int64(hStmt, nBindIndex, |
| 2183 | psRelation->pasMembers[i].nID); |
| 2184 | nBindIndex++; |
| 2185 | } |
| 2186 | } |
| 2187 | iCur = iLastI; |
| 2188 | |
| 2189 | while (sqlite3_step(hStmt) == SQLITE_ROWcxx . . $ `<external>/2400532043262193228/sqlite3.h:479:9`!) |
| 2190 | { |
| 2191 | GIntBigcxx . . $ GIntBig# id = sqlite3_column_int64(hStmt, 0); |
| 2192 | if (aoMapWays.findcxx . . $ std/map#find(36f8d56706583706).(id) ==cxx . . $ std/`operator==`(be6a71a859368080). aoMapWays.endcxx . . $ std/map#end(7e4de33083b6e738).()) |
| 2193 | { |
| 2194 | int nBlobSize = sqlite3_column_bytes(hStmt, 1); |
| 2195 | const void *blob = sqlite3_column_blob(hStmt, 1); |
| 2196 | void *blob_dup = CPLMalloc(nBlobSize); |
| 2197 | memcpy(blob_dup, blob, nBlobSize); |
| 2198 | aoMapWays[cxx . . $ std/map#`operator[]`(bbd415b616967878).id] = stdcxx . . $ std/::pair(nBlobSize, blob_dup); |
| 2199 | } |
| 2200 | nFound++; |
| 2201 | } |
| 2202 | |
| 2203 | sqlite3_reset(hStmt); |
| 2204 | } |
| 2205 | |
| 2206 | return nFound; |
| 2207 | } |
| 2208 | |
| 2209 | /************************************************************************/ |
| 2210 | /* BuildMultiPolygon() */ |
| 2211 | /************************************************************************/ |
| 2212 | |
| 2213 | OGRGeometrycxx . . $ OGRGeometry# *OGROSMDataSourcecxx . . $ OGROSMDataSource#::BuildMultiPolygoncxx . . $ OGROSMDataSource#BuildMultiPolygon(13633c47f921087c).(const OSMRelation *psRelation, |
| 2214 | unsigned int *pnTags, |
| 2215 | OSMTag *pasTags) |
| 2216 | { |
| 2217 | stdcxx . . $ std/::mapcxx . . $ std/map#<GIntBigcxx . . $ GIntBig#, stdcxx . . $ std/::pair<int, void *>> aoMapWayscxx . . $ std/map#map(49f6e7a06ebc5aa8).; |
| 2218 | LookupWayscxx . . $ OGROSMDataSource#LookupWays(25f9d76f384ec7db).(aoMapWays, psRelation); |
| 2219 | |
| 2220 | bool bMissing = false; |
| 2221 | |
| 2222 | for (unsigned int i = 0; i < psRelation->nMembers; i++) |
| 2223 | { |
| 2224 | if (psRelation->pasMembers[i].eType == MEMBER_WAY && |
| 2225 | strcmp(psRelation->pasMembers[i].pszRole, "subarea") != 0) |
| 2226 | { |
| 2227 | if (aoMapWays.findcxx . . $ std/map#find(36f8d56706583706).(psRelation->pasMembers[i].nID) ==cxx . . $ std/`operator==`(be6a71a859368080). |
| 2228 | aoMapWays.endcxx . . $ std/map#end(7e4de33083b6e738).()) |
| 2229 | { |
| 2230 | CPLDebug("OSM", |
| 2231 | "Relation " CPL_FRMT_GIBcxx . . $ `port/cpl_port.h:257:9`! |
| 2232 | " has missing ways. Ignoring it", |
| 2233 | psRelation->nID); |
| 2234 | bMissing = true; |
| 2235 | break; |
| 2236 | } |
| 2237 | } |
| 2238 | } |
| 2239 | |
| 2240 | if (bMissing) |
| 2241 | { |
| 2242 | // cppcheck-suppress constVariableReference |
| 2243 | for (auto &oIter : aoMapWays) |
| 2244 | CPLFreecxx . . $ `port/cpl_conv.h:97:9`!(oIter.second.second); |
| 2245 | |
| 2246 | return nullptr; |
| 2247 | } |
| 2248 | |
| 2249 | OGRMultiLineStringcxx . . $ OGRMultiLineString# oMLScxx . . $ OGRMultiLineString#OGRMultiLineString(49f6e7a06ebc5aa8).; |
| 2250 | stdcxx . . $ std/::vector<stdcxx . . $ std/::unique_ptr<OGRGeometrycxx . . $ OGRGeometry#>> apoPolygons; |
| 2251 | apoPolygons.reserve(psRelation->nMembers); |
| 2252 | |
| 2253 | if (pnTags != nullptr) |
| 2254 | *pnTags = 0; |
| 2255 | |
| 2256 | for (unsigned int i = 0; i < psRelation->nMembers; i++) |
| 2257 | { |
| 2258 | if (psRelation->pasMembers[i].eType == MEMBER_WAY && |
| 2259 | strcmp(psRelation->pasMembers[i].pszRole, "subarea") != 0) |
| 2260 | { |
| 2261 | const auto &oGeom = aoMapWays[cxx . . $ std/map#`operator[]`(bbd415b616967878).psRelation->pasMembers[i].nID]; |
| 2262 | |
| 2263 | if (pnTags != nullptr && *pnTags == 0 && |
| 2264 | strcmp(psRelation->pasMembers[i].pszRole, "outer") == 0) |
| 2265 | { |
| 2266 | // This backup in m_abyWayBuffer is crucial for safe memory |
| 2267 | // usage, as pasTags[].pszV will point to it ! |
| 2268 | m_abyWayBuffercxx . . $ OGROSMDataSource#m_abyWayBuffer..clear(); |
| 2269 | m_abyWayBuffercxx . . $ OGROSMDataSource#m_abyWayBuffer..insert(m_abyWayBuffercxx . . $ OGROSMDataSource#m_abyWayBuffer..end(), |
| 2270 | static_cast<const GBytecxx . . $ GByte# *>(oGeom.second), |
| 2271 | static_cast<const GBytecxx . . $ GByte# *>(oGeom.second) + |
| 2272 | oGeom.first); |
| 2273 | |
| 2274 | UncompressWaycxx . . $ OGROSMDataSource#UncompressWay(58972fd431d5ed14).(oGeom.first, m_abyWayBuffercxx . . $ OGROSMDataSource#m_abyWayBuffer..data(), nullptr, |
| 2275 | m_asLonLatCachecxx . . $ OGROSMDataSource#m_asLonLatCache., pnTags, pasTags, nullptr); |
| 2276 | } |
| 2277 | else |
| 2278 | { |
| 2279 | UncompressWaycxx . . $ OGROSMDataSource#UncompressWay(58972fd431d5ed14).(oGeom.first, |
| 2280 | static_cast<const GBytecxx . . $ GByte# *>(oGeom.second), nullptr, |
| 2281 | m_asLonLatCachecxx . . $ OGROSMDataSource#m_asLonLatCache., nullptr, nullptr, nullptr); |
| 2282 | } |
| 2283 | |
| 2284 | stdcxx . . $ std/::unique_ptr<OGRLineStringcxx . . $ OGRLineString#> poLS; |
| 2285 | stdcxx . . $ std/::unique_ptr<OGRLinearRingcxx . . $ OGRLinearRing#> poRing; |
| 2286 | OGRLineStringcxx . . $ OGRLineString# *poLSRaw; |
| 2287 | |
| 2288 | const bool bIsPoly = |
| 2289 | (!m_asLonLatCachecxx . . $ OGROSMDataSource#m_asLonLatCache..empty() && |
| 2290 | m_asLonLatCachecxx . . $ OGROSMDataSource#m_asLonLatCache..front().nLoncxx . . $ $anonymous_type_52aecf065e0c3ab0_5#nLon. == m_asLonLatCachecxx . . $ OGROSMDataSource#m_asLonLatCache..back().nLoncxx . . $ $anonymous_type_52aecf065e0c3ab0_5#nLon. && |
| 2291 | m_asLonLatCachecxx . . $ OGROSMDataSource#m_asLonLatCache..front().nLatcxx . . $ $anonymous_type_52aecf065e0c3ab0_5#nLat. == m_asLonLatCachecxx . . $ OGROSMDataSource#m_asLonLatCache..back().nLatcxx . . $ $anonymous_type_52aecf065e0c3ab0_5#nLat.); |
| 2292 | if (bIsPoly) |
| 2293 | { |
| 2294 | poRing = stdcxx . . $ std/::make_unique<OGRLinearRingcxx . . $ OGRLinearRing#>(); |
| 2295 | poLSRaw = poRing.get(); |
| 2296 | if (strcmp(psRelation->pasMembers[i].pszRole, "outer") == 0) |
| 2297 | { |
| 2298 | sqlite3_bind_int64(m_hDeletePolygonsStandaloneStmtcxx . . $ OGROSMDataSource#m_hDeletePolygonsStandaloneStmt., 1, |
| 2299 | psRelation->pasMembers[i].nID); |
| 2300 | CPL_IGNORE_RET_VAL( |
| 2301 | sqlite3_step(m_hDeletePolygonsStandaloneStmtcxx . . $ OGROSMDataSource#m_hDeletePolygonsStandaloneStmt.)); |
| 2302 | sqlite3_reset(m_hDeletePolygonsStandaloneStmtcxx . . $ OGROSMDataSource#m_hDeletePolygonsStandaloneStmt.); |
| 2303 | } |
| 2304 | } |
| 2305 | else |
| 2306 | { |
| 2307 | poLS = stdcxx . . $ std/::make_unique<OGRLineStringcxx . . $ OGRLineString#>(); |
| 2308 | poLSRaw = poLS.get(); |
| 2309 | } |
| 2310 | |
| 2311 | const int nPoints = static_cast<int>(m_asLonLatCachecxx . . $ OGROSMDataSource#m_asLonLatCache..size()); |
| 2312 | poLSRaw->setNumPointscxx . . $ OGRSimpleCurve#setNumPoints(cf9ef193275fa6d8).(nPoints, /*bZeroizeNewContent=*/false); |
| 2313 | for (int j = 0; j < nPoints; j++) |
| 2314 | { |
| 2315 | poLSRaw->setPointcxx . . $ OGRSimpleCurve#setPoint(9f72e67440d8b329).(j, INT_TO_DBLcxx . . $ INT_TO_DBL(4badf5dbac1308a7).(m_asLonLatCachecxx . . $ OGROSMDataSource#m_asLonLatCache.[j].nLoncxx . . $ $anonymous_type_52aecf065e0c3ab0_5#nLon.), |
| 2316 | INT_TO_DBLcxx . . $ INT_TO_DBL(4badf5dbac1308a7).(m_asLonLatCachecxx . . $ OGROSMDataSource#m_asLonLatCache.[j].nLatcxx . . $ $anonymous_type_52aecf065e0c3ab0_5#nLat.)); |
| 2317 | } |
| 2318 | |
| 2319 | if (poRing) |
| 2320 | { |
| 2321 | auto poPoly = stdcxx . . $ std/::make_unique<OGRPolygoncxx . . $ OGRPolygon#>(); |
| 2322 | poPoly->addRingcxx . . $ OGRCurvePolygon#addRing(4b4f83789b950964).(stdcxx . . $ std/::move(poRing)); |
| 2323 | apoPolygons.push_back(stdcxx . . $ std/::move(poPoly)); |
| 2324 | } |
| 2325 | else |
| 2326 | { |
| 2327 | oMLS.addGeometrycxx . . $ OGRGeometryCollection#addGeometry(409c5ef120a740b2).(stdcxx . . $ std/::move(poLS)); |
| 2328 | } |
| 2329 | } |
| 2330 | } |
| 2331 | |
| 2332 | if (oMLS.getNumGeometriescxx . . $ OGRGeometryCollection#getNumGeometries(455f465bc33b4cdf).() > 0) |
| 2333 | { |
| 2334 | auto poPolyFromEdges = stdcxx . . $ std/::unique_ptr<OGRGeometrycxx . . $ OGRGeometry#>( |
| 2335 | OGRGeometrycxx . . $ OGRGeometry#::FromHandlecxx . . $ OGRGeometry#FromHandle(6c331b48912c44c0).(OGRBuildPolygonFromEdges( |
| 2336 | OGRGeometrycxx . . $ OGRGeometry#::ToHandlecxx . . $ OGRGeometry#ToHandle(76b24ad94dcfe536).(&oMLS), TRUEcxx . . $ `port/cpl_port.h:1184:9`!, FALSEcxx . . $ `port/cpl_port.h:1180:9`!, 0, nullptr))); |
| 2337 | |
| 2338 | const auto AddPolygonDirectlyToPolyArray = |
| 2339 | [&apoPolygons](OGRPolygoncxx . . $ OGRPolygon# *poPoly) |
| 2340 | { |
| 2341 | const int nRings = |
| 2342 | poPoly->IsEmptycxx . . $ OGRCurvePolygon#IsEmpty(455f465bc33b4cdf).() ? 0 : 1 + poPoly->getNumInteriorRingscxx . . $ OGRCurvePolygon#getNumInteriorRings(455f465bc33b4cdf).(); |
| 2343 | for (int i = nRings - 1; i >= 0; --i) |
| 2344 | { |
| 2345 | auto poRing = stdcxx . . $ std/::unique_ptr<OGRLinearRingcxx . . $ OGRLinearRing#>( |
| 2346 | i > 0 ? poPoly->getInteriorRingcxx . . $ OGRPolygon#getInteriorRing(1626534c94686e39).(i - 1) |
| 2347 | : poPoly->getExteriorRingcxx . . $ OGRPolygon#getExteriorRing(ce08de107de86017).()); |
| 2348 | poPoly->removeRingcxx . . $ OGRCurvePolygon#removeRing(d455ce14f374a3ab).(i, /* bDelete = */ false); |
| 2349 | if (poRing != nullptr && poRing->getNumPointscxx . . $ OGRSimpleCurve#getNumPoints(455f465bc33b4cdf).() >= 4 && |
| 2350 | poRing->getXcxx . . $ OGRSimpleCurve#getX(8bbae5fb2e9ef7ac).(0) == |
| 2351 | poRing->getXcxx . . $ OGRSimpleCurve#getX(8bbae5fb2e9ef7ac).(poRing->getNumPointscxx . . $ OGRSimpleCurve#getNumPoints(455f465bc33b4cdf).() - 1) && |
| 2352 | poRing->getYcxx . . $ OGRSimpleCurve#getY(8bbae5fb2e9ef7ac).(0) == poRing->getYcxx . . $ OGRSimpleCurve#getY(8bbae5fb2e9ef7ac).(poRing->getNumPointscxx . . $ OGRSimpleCurve#getNumPoints(455f465bc33b4cdf).() - 1)) |
| 2353 | { |
| 2354 | auto poNewPoly = stdcxx . . $ std/::make_unique<OGRPolygoncxx . . $ OGRPolygon#>(); |
| 2355 | poNewPoly->addRingcxx . . $ OGRCurvePolygon#addRing(4b4f83789b950964).(stdcxx . . $ std/::move(poRing)); |
| 2356 | apoPolygons.push_back(stdcxx . . $ std/::move(poNewPoly)); |
| 2357 | } |
| 2358 | } |
| 2359 | }; |
| 2360 | |
| 2361 | if (poPolyFromEdges) |
| 2362 | { |
| 2363 | if (poPolyFromEdges->getGeometryTypecxx . . $ OGRGeometry#getGeometryType(5a40c54c5ff210ce).() == wkbPolygon) |
| 2364 | { |
| 2365 | AddPolygonDirectlyToPolyArray(cxx . . $ OGROSMDataSource#BuildMultiPolygon(13633c47f921087c).$anonymous_type_0#`operator()`(2bd7d989c4139ed2).poPolyFromEdges->toPolygoncxx . . $ OGRGeometry#toPolygon(46ffe497ccba7cf7).()); |
| 2366 | } |
| 2367 | else if (OGR_GT_IsSubClassOf(poPolyFromEdges->getGeometryTypecxx . . $ OGRGeometry#getGeometryType(5a40c54c5ff210ce).(), |
| 2368 | wkbGeometryCollection)) |
| 2369 | { |
| 2370 | auto poGC = poPolyFromEdges->toGeometryCollectioncxx . . $ OGRGeometry#toGeometryCollection(2dc35bba37476a41).(); |
| 2371 | for (auto *poPart : *poGC) |
| 2372 | { |
| 2373 | if (poPart->getGeometryTypecxx . . $ OGRGeometry#getGeometryType(5a40c54c5ff210ce).() == wkbPolygon) |
| 2374 | { |
| 2375 | AddPolygonDirectlyToPolyArray(cxx . . $ OGROSMDataSource#BuildMultiPolygon(13633c47f921087c).$anonymous_type_0#`operator()`(2bd7d989c4139ed2).poPart->toPolygoncxx . . $ OGRGeometry#toPolygon(46ffe497ccba7cf7).()); |
| 2376 | } |
| 2377 | } |
| 2378 | } |
| 2379 | } |
| 2380 | } |
| 2381 | |
| 2382 | stdcxx . . $ std/::unique_ptr<OGRGeometrycxx . . $ OGRGeometry#> poRet; |
| 2383 | |
| 2384 | if (!apoPolygons.empty()) |
| 2385 | { |
| 2386 | const char *const apszOptions[] = {"METHOD=DEFAULT", nullptr}; |
| 2387 | auto poGeom = OGRGeometryFactorycxx . . $ OGRGeometryFactory#::organizePolygonscxx . . $ OGRGeometryFactory#organizePolygons(36da63c1caf5e687).(apoPolygons, nullptr, |
| 2388 | apszOptions); |
| 2389 | if (poGeom && poGeom->getGeometryTypecxx . . $ OGRGeometry#getGeometryType(5a40c54c5ff210ce).() == wkbPolygon) |
| 2390 | { |
| 2391 | auto poMulti = stdcxx . . $ std/::make_unique<OGRMultiPolygoncxx . . $ OGRMultiPolygon#>(); |
| 2392 | poMulti->addGeometryDirectlycxx . . $ OGRGeometryCollection#addGeometryDirectly(cec3429dca426eb8).(poGeom.release()); |
| 2393 | poGeom = stdcxx . . $ std/::move(poMulti); |
| 2394 | } |
| 2395 | |
| 2396 | if (poGeom && poGeom->getGeometryTypecxx . . $ OGRGeometry#getGeometryType(5a40c54c5ff210ce).() == wkbMultiPolygon) |
| 2397 | { |
| 2398 | poRet = stdcxx . . $ std/::move(poGeom); |
| 2399 | } |
| 2400 | else |
| 2401 | { |
| 2402 | CPLDebug("OSM", |
| 2403 | "Relation " CPL_FRMT_GIBcxx . . $ `port/cpl_port.h:257:9`! |
| 2404 | ": Geometry has incompatible type : %s", |
| 2405 | psRelation->nID, |
| 2406 | poGeom ? OGR_G_GetGeometryName( |
| 2407 | OGRGeometrycxx . . $ OGRGeometry#::ToHandlecxx . . $ OGRGeometry#ToHandle(76b24ad94dcfe536).(poGeom.get())) |
| 2408 | : "null"); |
| 2409 | } |
| 2410 | } |
| 2411 | |
| 2412 | // cppcheck-suppress constVariableReference |
| 2413 | for (auto &oIter : aoMapWays) |
| 2414 | CPLFreecxx . . $ `port/cpl_conv.h:97:9`!(oIter.second.second); |
| 2415 | |
| 2416 | return poRet.release(); |
| 2417 | } |
| 2418 | |
| 2419 | /************************************************************************/ |
| 2420 | /* BuildGeometryCollection() */ |
| 2421 | /************************************************************************/ |
| 2422 | |
| 2423 | OGRGeometrycxx . . $ OGRGeometry# * |
| 2424 | OGROSMDataSourcecxx . . $ OGROSMDataSource#::BuildGeometryCollectioncxx . . $ OGROSMDataSource#BuildGeometryCollection(9c3d4e89c59c5332).(const OSMRelation *psRelation, |
| 2425 | bool bMultiLineString) |
| 2426 | { |
| 2427 | stdcxx . . $ std/::mapcxx . . $ std/map#<GIntBigcxx . . $ GIntBig#, stdcxx . . $ std/::pair<int, void *>> aoMapWayscxx . . $ std/map#map(49f6e7a06ebc5aa8).; |
| 2428 | LookupWayscxx . . $ OGROSMDataSource#LookupWays(25f9d76f384ec7db).(aoMapWays, psRelation); |
| 2429 | |
| 2430 | stdcxx . . $ std/::unique_ptr<OGRGeometryCollectioncxx . . $ OGRGeometryCollection#> poColl = |
| 2431 | bMultiLineString ? stdcxx . . $ std/::make_unique<OGRMultiLineStringcxx . . $ OGRMultiLineString#>() |
| 2432 | : stdcxx . . $ std/::make_unique<OGRGeometryCollectioncxx . . $ OGRGeometryCollection#>(); |
| 2433 | |
| 2434 | for (unsigned int i = 0; i < psRelation->nMembers; i++) |
| 2435 | { |
| 2436 | if (psRelation->pasMembers[i].eType == MEMBER_NODE && !bMultiLineString) |
| 2437 | { |
| 2438 | m_nUnsortedReqIdscxx . . $ OGROSMDataSource#m_nUnsortedReqIds. = 1; |
| 2439 | m_panUnsortedReqIdscxx . . $ OGROSMDataSource#m_panUnsortedReqIds.[0] = psRelation->pasMembers[i].nID; |
| 2440 | LookupNodescxx . . $ OGROSMDataSource#LookupNodes(49f6e7a06ebc5aa8).(); |
| 2441 | if (m_nReqIdscxx . . $ OGROSMDataSource#m_nReqIds. == 1) |
| 2442 | { |
| 2443 | poColl->addGeometryDirectlycxx . . $ OGRGeometryCollection#addGeometryDirectly(cec3429dca426eb8).( |
| 2444 | new OGRPointcxx . . $ OGRPoint#OGRPoint(bc12c9ec15586e6a).(INT_TO_DBLcxx . . $ INT_TO_DBL(4badf5dbac1308a7).(m_pasLonLatArraycxx . . $ OGROSMDataSource#m_pasLonLatArray.[0].nLoncxx . . $ $anonymous_type_52aecf065e0c3ab0_5#nLon.), |
| 2445 | INT_TO_DBLcxx . . $ INT_TO_DBL(4badf5dbac1308a7).(m_pasLonLatArraycxx . . $ OGROSMDataSource#m_pasLonLatArray.[0].nLatcxx . . $ $anonymous_type_52aecf065e0c3ab0_5#nLat.))); |
| 2446 | } |
| 2447 | } |
| 2448 | else if (psRelation->pasMembers[i].eType == MEMBER_WAY && |
| 2449 | strcmp(psRelation->pasMembers[i].pszRole, "subarea") != 0 && |
| 2450 | aoMapWays.findcxx . . $ std/map#find(36f8d56706583706).(psRelation->pasMembers[i].nID) !=cxx . . $ std/`operator!=`(be6a71a859368080). |
| 2451 | aoMapWays.endcxx . . $ std/map#end(7e4de33083b6e738).()) |
| 2452 | { |
| 2453 | const auto &oGeom = aoMapWays[cxx . . $ std/map#`operator[]`(bbd415b616967878).psRelation->pasMembers[i].nID]; |
| 2454 | |
| 2455 | bool bIsArea = false; |
| 2456 | UncompressWaycxx . . $ OGROSMDataSource#UncompressWay(58972fd431d5ed14).(oGeom.first, reinterpret_cast<GBytecxx . . $ GByte# *>(oGeom.second), |
| 2457 | &bIsArea, m_asLonLatCachecxx . . $ OGROSMDataSource#m_asLonLatCache., nullptr, nullptr, nullptr); |
| 2458 | OGRLineStringcxx . . $ OGRLineString# *poLS = nullptr; |
| 2459 | if (bIsArea && !bMultiLineString) |
| 2460 | { |
| 2461 | OGRLinearRingcxx . . $ OGRLinearRing# *poLR = new OGRLinearRingcxx . . $ OGRLinearRing#OGRLinearRing(49f6e7a06ebc5aa8).(); |
| 2462 | OGRPolygoncxx . . $ OGRPolygon# *poPoly = new OGRPolygoncxx . . $ OGRPolygon#OGRPolygon(49f6e7a06ebc5aa8).(); |
| 2463 | poPoly->addRingDirectlycxx . . $ OGRCurvePolygon#addRingDirectly(2f65f96c58d3f239).(poLR); |
| 2464 | poColl->addGeometryDirectlycxx . . $ OGRGeometryCollection#addGeometryDirectly(cec3429dca426eb8).(poPoly); |
| 2465 | poLS = poLR; |
| 2466 | } |
| 2467 | else |
| 2468 | { |
| 2469 | poLS = new OGRLineStringcxx . . $ OGRLineString#OGRLineString(49f6e7a06ebc5aa8).(); |
| 2470 | poColl->addGeometryDirectlycxx . . $ OGRGeometryCollection#addGeometryDirectly(cec3429dca426eb8).(poLS); |
| 2471 | } |
| 2472 | |
| 2473 | const int nPoints = static_cast<int>(m_asLonLatCachecxx . . $ OGROSMDataSource#m_asLonLatCache..size()); |
| 2474 | poLS->setNumPointscxx . . $ OGRSimpleCurve#setNumPoints(cf9ef193275fa6d8).(nPoints, /*bZeroizeNewContent=*/false); |
| 2475 | for (int j = 0; j < nPoints; j++) |
| 2476 | { |
| 2477 | poLS->setPointcxx . . $ OGRSimpleCurve#setPoint(9f72e67440d8b329).(j, INT_TO_DBLcxx . . $ INT_TO_DBL(4badf5dbac1308a7).(m_asLonLatCachecxx . . $ OGROSMDataSource#m_asLonLatCache.[j].nLoncxx . . $ $anonymous_type_52aecf065e0c3ab0_5#nLon.), |
| 2478 | INT_TO_DBLcxx . . $ INT_TO_DBL(4badf5dbac1308a7).(m_asLonLatCachecxx . . $ OGROSMDataSource#m_asLonLatCache.[j].nLatcxx . . $ $anonymous_type_52aecf065e0c3ab0_5#nLat.)); |
| 2479 | } |
| 2480 | } |
| 2481 | } |
| 2482 | |
| 2483 | if (poColl->getNumGeometriescxx . . $ OGRGeometryCollection#getNumGeometries(455f465bc33b4cdf).() == 0) |
| 2484 | { |
| 2485 | poColl.reset(); |
| 2486 | } |
| 2487 | |
| 2488 | // cppcheck-suppress constVariableReference |
| 2489 | for (auto &oIter : aoMapWays) |
| 2490 | CPLFreecxx . . $ `port/cpl_conv.h:97:9`!(oIter.second.second); |
| 2491 | |
| 2492 | return poColl.release(); |
| 2493 | } |
| 2494 | |
| 2495 | /************************************************************************/ |
| 2496 | /* NotifyRelation() */ |
| 2497 | /************************************************************************/ |
| 2498 | |
| 2499 | void OGROSMDataSourcecxx . . $ OGROSMDataSource#::NotifyRelationcxx . . $ OGROSMDataSource#NotifyRelation(16330359ea91767b).(const OSMRelation *psRelation) |
| 2500 | { |
| 2501 | if (!m_asWayFeaturePairscxx . . $ OGROSMDataSource#m_asWayFeaturePairs..empty()) |
| 2502 | ProcessWaysBatchcxx . . $ OGROSMDataSource#ProcessWaysBatch(49f6e7a06ebc5aa8).(); |
| 2503 | |
| 2504 | m_nRelationsProcessedcxx . . $ OGROSMDataSource#m_nRelationsProcessed.++; |
| 2505 | if ((m_nRelationsProcessedcxx . . $ OGROSMDataSource#m_nRelationsProcessed. % 10000) == 0) |
| 2506 | { |
| 2507 | CPLDebug("OSM", "Relations processed : %d", m_nRelationsProcessedcxx . . $ OGROSMDataSource#m_nRelationsProcessed.); |
| 2508 | #ifdef DEBUG_MEM_USAGE |
| 2509 | CPLDebug("OSM", "GetMaxTotalAllocs() = " CPL_FRMT_GUIB, |
| 2510 | static_cast<GUIntBig>(GetMaxTotalAllocs())); |
| 2511 | #endif |
| 2512 | } |
| 2513 | |
| 2514 | if (!m_bUseWaysIndexcxx . . $ OGROSMDataSource#m_bUseWaysIndex.) |
| 2515 | return; |
| 2516 | |
| 2517 | bool bMultiPolygon = false; |
| 2518 | bool bMultiLineString = false; |
| 2519 | bool bInterestingTagFound = false; |
| 2520 | const char *pszTypeV = nullptr; |
| 2521 | for (unsigned int i = 0; i < psRelation->nTags; i++) |
| 2522 | { |
| 2523 | const char *pszK = psRelation->pasTags[i].pszK; |
| 2524 | if (strcmp(pszK, "type") == 0) |
| 2525 | { |
| 2526 | const char *pszV = psRelation->pasTags[i].pszV; |
| 2527 | pszTypeV = pszV; |
| 2528 | if (strcmp(pszV, "multipolygon") == 0 || |
| 2529 | strcmp(pszV, "boundary") == 0) |
| 2530 | { |
| 2531 | bMultiPolygon = true; |
| 2532 | } |
| 2533 | else if (strcmp(pszV, "multilinestring") == 0 || |
| 2534 | strcmp(pszV, "route") == 0) |
| 2535 | { |
| 2536 | bMultiLineString = true; |
| 2537 | } |
| 2538 | } |
| 2539 | else if (strcmp(pszK, "created_by") != 0) |
| 2540 | bInterestingTagFound = true; |
| 2541 | } |
| 2542 | |
| 2543 | // Optimization: If we have an attribute filter, that does not require |
| 2544 | // geometry, then we can just evaluate the attribute filter without the |
| 2545 | // geometry. |
| 2546 | const int iCurLayer = bMultiPolygon ? IDX_LYR_MULTIPOLYGONScxx . . $ IDX_LYR_MULTIPOLYGONS. |
| 2547 | : bMultiLineString ? IDX_LYR_MULTILINESTRINGScxx . . $ IDX_LYR_MULTILINESTRINGS. |
| 2548 | : IDX_LYR_OTHER_RELATIONScxx . . $ IDX_LYR_OTHER_RELATIONS.; |
| 2549 | if (!m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers.[iCurLayer]->IsUserInterestedcxx . . $ OGROSMLayer#IsUserInterested(50ce9a9e25b4a850).()) |
| 2550 | return; |
| 2551 | |
| 2552 | stdcxx . . $ std/::unique_ptr<OGRFeaturecxx . . $ OGRFeature#> poFeature; |
| 2553 | |
| 2554 | if (!(bMultiPolygon && !bInterestingTagFound) && |
| 2555 | // We cannot do early filtering for multipolygon that has no |
| 2556 | // interesting tag, since we may fetch attributes from ways. |
| 2557 | m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers.[iCurLayer]->HasAttributeFiltercxx . . $ OGROSMLayer#HasAttributeFilter(455f465bc33b4cdf).() && |
| 2558 | !m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers.[iCurLayer]->AttributeFilterEvaluationNeedsGeometrycxx . . $ OGRLayer#AttributeFilterEvaluationNeedsGeometry(b126dc7c1de90089).()) |
| 2559 | { |
| 2560 | poFeature = stdcxx . . $ std/::make_unique<OGRFeaturecxx . . $ OGRFeature#>( |
| 2561 | m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers.[iCurLayer]->GetLayerDefncxx . . $ OGRLayer#GetLayerDefn(407fccde18759965).()); |
| 2562 | |
| 2563 | m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers.[iCurLayer]->SetFieldsFromTagscxx . . $ OGROSMLayer#SetFieldsFromTags(49bbf9dc4001c2e3).( |
| 2564 | poFeature.get(), psRelation->nID, false, psRelation->nTags, |
| 2565 | psRelation->pasTags, &psRelation->sInfo); |
| 2566 | |
| 2567 | if (!m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers.[iCurLayer]->EvaluateAttributeFiltercxx . . $ OGROSMLayer#EvaluateAttributeFilter(2048609adab03aab).(poFeature.get())) |
| 2568 | { |
| 2569 | return; |
| 2570 | } |
| 2571 | } |
| 2572 | |
| 2573 | OGRGeometrycxx . . $ OGRGeometry# *poGeom = nullptr; |
| 2574 | |
| 2575 | unsigned int nExtraTags = 0; |
| 2576 | OSMTag pasExtraTags[1 + MAX_COUNT_FOR_TAGS_IN_WAYcxx . . $ MAX_COUNT_FOR_TAGS_IN_WAY.]; |
| 2577 | |
| 2578 | if (bMultiPolygon) |
| 2579 | { |
| 2580 | if (!bInterestingTagFound) |
| 2581 | { |
| 2582 | poGeom = BuildMultiPolygoncxx . . $ OGROSMDataSource#BuildMultiPolygon(13633c47f921087c).(psRelation, &nExtraTags, pasExtraTags); |
| 2583 | CPLAssertcxx . . $ `port/cpl_error.h:353:9`!(nExtraTags <= MAX_COUNT_FOR_TAGS_IN_WAY); |
| 2584 | pasExtraTags[nExtraTags].pszK = "type"; |
| 2585 | pasExtraTags[nExtraTags].pszV = pszTypeV; |
| 2586 | nExtraTags++; |
| 2587 | } |
| 2588 | else |
| 2589 | poGeom = BuildMultiPolygoncxx . . $ OGROSMDataSource#BuildMultiPolygon(13633c47f921087c).(psRelation, nullptr, nullptr); |
| 2590 | } |
| 2591 | else |
| 2592 | poGeom = BuildGeometryCollectioncxx . . $ OGROSMDataSource#BuildGeometryCollection(9c3d4e89c59c5332).(psRelation, bMultiLineString); |
| 2593 | |
| 2594 | if (poGeom != nullptr) |
| 2595 | { |
| 2596 | bool bAttrFilterAlreadyEvaluated = true; |
| 2597 | if (poFeature == nullptr) |
| 2598 | { |
| 2599 | poFeature = stdcxx . . $ std/::make_unique<OGRFeaturecxx . . $ OGRFeature#>( |
| 2600 | m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers.[iCurLayer]->GetLayerDefncxx . . $ OGRLayer#GetLayerDefn(407fccde18759965).()); |
| 2601 | |
| 2602 | m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers.[iCurLayer]->SetFieldsFromTagscxx . . $ OGROSMLayer#SetFieldsFromTags(49bbf9dc4001c2e3).( |
| 2603 | poFeature.get(), psRelation->nID, false, |
| 2604 | nExtraTags ? nExtraTags : psRelation->nTags, |
| 2605 | nExtraTags ? pasExtraTags : psRelation->pasTags, |
| 2606 | &psRelation->sInfo); |
| 2607 | |
| 2608 | bAttrFilterAlreadyEvaluated = false; |
| 2609 | } |
| 2610 | |
| 2611 | poFeature->SetGeometryDirectlycxx . . $ OGRFeature#SetGeometryDirectly(cec3429dca426eb8).(poGeom); |
| 2612 | |
| 2613 | bool bFilteredOut = FALSEcxx . . $ `port/cpl_port.h:1180:9`!; |
| 2614 | if (!m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers.[iCurLayer]->AddFeaturecxx . . $ OGROSMLayer#AddFeature(12b17bec2ef920e4).( |
| 2615 | stdcxx . . $ std/::move(poFeature), bAttrFilterAlreadyEvaluated, |
| 2616 | &bFilteredOut, !m_bFeatureAddedcxx . . $ OGROSMDataSource#m_bFeatureAdded.)) |
| 2617 | m_bStopParsingcxx . . $ OGROSMDataSource#m_bStopParsing. = true; |
| 2618 | else if (!bFilteredOut) |
| 2619 | m_bFeatureAddedcxx . . $ OGROSMDataSource#m_bFeatureAdded. = true; |
| 2620 | } |
| 2621 | } |
| 2622 | |
| 2623 | static void OGROSMNotifyRelationcxx . . $ OGROSMNotifyRelation(cdf02cc57946e942).(OSMRelation *psRelation, |
| 2624 | OSMContext * /* psOSMContext */, |
| 2625 | void *user_data) |
| 2626 | { |
| 2627 | static_cast<OGROSMDataSourcecxx . . $ OGROSMDataSource# *>(user_data)->NotifyRelationcxx . . $ OGROSMDataSource#NotifyRelation(16330359ea91767b).(psRelation); |
| 2628 | } |
| 2629 | |
| 2630 | /************************************************************************/ |
| 2631 | /* ProcessPolygonsStandalone() */ |
| 2632 | /************************************************************************/ |
| 2633 | |
| 2634 | void OGROSMDataSourcecxx . . $ OGROSMDataSource#::ProcessPolygonsStandalonecxx . . $ OGROSMDataSource#ProcessPolygonsStandalone(49f6e7a06ebc5aa8).() |
| 2635 | { |
| 2636 | unsigned int nTags = 0; |
| 2637 | OSMTag pasTags[MAX_COUNT_FOR_TAGS_IN_WAYcxx . . $ MAX_COUNT_FOR_TAGS_IN_WAY.]; |
| 2638 | OSMInfo sInfo; |
| 2639 | |
| 2640 | sInfo.ts.nTimeStamp = 0; |
| 2641 | sInfo.nChangeset = 0; |
| 2642 | sInfo.nVersion = 0; |
| 2643 | sInfo.nUID = 0; |
| 2644 | sInfo.bTimeStampIsStr = false; |
| 2645 | sInfo.pszUserSID = ""; |
| 2646 | |
| 2647 | if (!m_bHasRowInPolygonsStandalonecxx . . $ OGROSMDataSource#m_bHasRowInPolygonsStandalone.) |
| 2648 | m_bHasRowInPolygonsStandalonecxx . . $ OGROSMDataSource#m_bHasRowInPolygonsStandalone. = |
| 2649 | sqlite3_step(m_hSelectPolygonsStandaloneStmtcxx . . $ OGROSMDataSource#m_hSelectPolygonsStandaloneStmt.) == SQLITE_ROWcxx . . $ `<external>/2400532043262193228/sqlite3.h:479:9`!; |
| 2650 | |
| 2651 | bool bFirst = true; |
| 2652 | |
| 2653 | while (m_bHasRowInPolygonsStandalonecxx . . $ OGROSMDataSource#m_bHasRowInPolygonsStandalone. && |
| 2654 | m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers.[IDX_LYR_MULTIPOLYGONScxx . . $ IDX_LYR_MULTIPOLYGONS.]->m_apoFeaturescxx . . $ OGROSMLayer#m_apoFeatures..size() < 10000) |
| 2655 | { |
| 2656 | if (bFirst) |
| 2657 | { |
| 2658 | CPLDebug("OSM", "Remaining standalone polygons"); |
| 2659 | bFirst = false; |
| 2660 | } |
| 2661 | |
| 2662 | GIntBigcxx . . $ GIntBig# id = sqlite3_column_int64(m_hSelectPolygonsStandaloneStmtcxx . . $ OGROSMDataSource#m_hSelectPolygonsStandaloneStmt., 0); |
| 2663 | |
| 2664 | sqlite3_bind_int64(m_pahSelectWayStmtcxx . . $ OGROSMDataSource#m_pahSelectWayStmt.[0], 1, id); |
| 2665 | if (sqlite3_step(m_pahSelectWayStmtcxx . . $ OGROSMDataSource#m_pahSelectWayStmt.[0]) == SQLITE_ROWcxx . . $ `<external>/2400532043262193228/sqlite3.h:479:9`!) |
| 2666 | { |
| 2667 | int nBlobSize = sqlite3_column_bytes(m_pahSelectWayStmtcxx . . $ OGROSMDataSource#m_pahSelectWayStmt.[0], 1); |
| 2668 | const void *blob = sqlite3_column_blob(m_pahSelectWayStmtcxx . . $ OGROSMDataSource#m_pahSelectWayStmt.[0], 1); |
| 2669 | |
| 2670 | UncompressWaycxx . . $ OGROSMDataSource#UncompressWay(58972fd431d5ed14).(nBlobSize, static_cast<const GBytecxx . . $ GByte# *>(blob), nullptr, |
| 2671 | m_asLonLatCachecxx . . $ OGROSMDataSource#m_asLonLatCache., &nTags, pasTags, &sInfo); |
| 2672 | CPLAssertcxx . . $ `port/cpl_error.h:353:9`!(nTags <= MAX_COUNT_FOR_TAGS_IN_WAY); |
| 2673 | |
| 2674 | OGRMultiPolygoncxx . . $ OGRMultiPolygon# *poMulti = new OGRMultiPolygoncxx . . $ OGRMultiPolygon#OGRMultiPolygon(49f6e7a06ebc5aa8).(); |
| 2675 | OGRPolygoncxx . . $ OGRPolygon# *poPoly = new OGRPolygoncxx . . $ OGRPolygon#OGRPolygon(49f6e7a06ebc5aa8).(); |
| 2676 | OGRLinearRingcxx . . $ OGRLinearRing# *poRing = new OGRLinearRingcxx . . $ OGRLinearRing#OGRLinearRing(49f6e7a06ebc5aa8).(); |
| 2677 | poMulti->addGeometryDirectlycxx . . $ OGRGeometryCollection#addGeometryDirectly(cec3429dca426eb8).(poPoly); |
| 2678 | poPoly->addRingDirectlycxx . . $ OGRCurvePolygon#addRingDirectly(2f65f96c58d3f239).(poRing); |
| 2679 | OGRLineStringcxx . . $ OGRLineString# *poLS = poRing; |
| 2680 | |
| 2681 | poLS->setNumPointscxx . . $ OGRSimpleCurve#setNumPoints(cf9ef193275fa6d8).(static_cast<int>(m_asLonLatCachecxx . . $ OGROSMDataSource#m_asLonLatCache..size()), |
| 2682 | /*bZeroizeNewContent=*/false); |
| 2683 | for (int j = 0; j < static_cast<int>(m_asLonLatCachecxx . . $ OGROSMDataSource#m_asLonLatCache..size()); j++) |
| 2684 | { |
| 2685 | poLS->setPointcxx . . $ OGRSimpleCurve#setPoint(9f72e67440d8b329).(j, INT_TO_DBLcxx . . $ INT_TO_DBL(4badf5dbac1308a7).(m_asLonLatCachecxx . . $ OGROSMDataSource#m_asLonLatCache.[j].nLoncxx . . $ $anonymous_type_52aecf065e0c3ab0_5#nLon.), |
| 2686 | INT_TO_DBLcxx . . $ INT_TO_DBL(4badf5dbac1308a7).(m_asLonLatCachecxx . . $ OGROSMDataSource#m_asLonLatCache.[j].nLatcxx . . $ $anonymous_type_52aecf065e0c3ab0_5#nLat.)); |
| 2687 | } |
| 2688 | |
| 2689 | auto poFeature = stdcxx . . $ std/::make_unique<OGRFeaturecxx . . $ OGRFeature#>( |
| 2690 | m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers.[IDX_LYR_MULTIPOLYGONScxx . . $ IDX_LYR_MULTIPOLYGONS.]->GetLayerDefncxx . . $ OGRLayer#GetLayerDefn(407fccde18759965).()); |
| 2691 | |
| 2692 | m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers.[IDX_LYR_MULTIPOLYGONScxx . . $ IDX_LYR_MULTIPOLYGONS.]->SetFieldsFromTagscxx . . $ OGROSMLayer#SetFieldsFromTags(49bbf9dc4001c2e3).( |
| 2693 | poFeature.get(), id, true, nTags, pasTags, &sInfo); |
| 2694 | |
| 2695 | poFeature->SetGeometryDirectlycxx . . $ OGRFeature#SetGeometryDirectly(cec3429dca426eb8).(poMulti); |
| 2696 | |
| 2697 | bool bFilteredOut = false; |
| 2698 | if (!m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers.[IDX_LYR_MULTIPOLYGONScxx . . $ IDX_LYR_MULTIPOLYGONS.]->AddFeaturecxx . . $ OGROSMLayer#AddFeature(12b17bec2ef920e4).( |
| 2699 | stdcxx . . $ std/::move(poFeature), FALSEcxx . . $ `port/cpl_port.h:1180:9`!, &bFilteredOut, |
| 2700 | !m_bFeatureAddedcxx . . $ OGROSMDataSource#m_bFeatureAdded.)) |
| 2701 | { |
| 2702 | m_bStopParsingcxx . . $ OGROSMDataSource#m_bStopParsing. = true; |
| 2703 | break; |
| 2704 | } |
| 2705 | else if (!bFilteredOut) |
| 2706 | { |
| 2707 | m_bFeatureAddedcxx . . $ OGROSMDataSource#m_bFeatureAdded. = true; |
| 2708 | } |
| 2709 | } |
| 2710 | else |
| 2711 | { |
| 2712 | CPLAssertcxx . . $ `port/cpl_error.h:353:9`!(false); |
| 2713 | } |
| 2714 | |
| 2715 | sqlite3_reset(m_pahSelectWayStmtcxx . . $ OGROSMDataSource#m_pahSelectWayStmt.[0]); |
| 2716 | |
| 2717 | m_bHasRowInPolygonsStandalonecxx . . $ OGROSMDataSource#m_bHasRowInPolygonsStandalone. = |
| 2718 | sqlite3_step(m_hSelectPolygonsStandaloneStmtcxx . . $ OGROSMDataSource#m_hSelectPolygonsStandaloneStmt.) == SQLITE_ROWcxx . . $ `<external>/2400532043262193228/sqlite3.h:479:9`!; |
| 2719 | } |
| 2720 | } |
| 2721 | |
| 2722 | /************************************************************************/ |
| 2723 | /* NotifyBounds() */ |
| 2724 | /************************************************************************/ |
| 2725 | |
| 2726 | void OGROSMDataSourcecxx . . $ OGROSMDataSource#::NotifyBoundscxx . . $ OGROSMDataSource#NotifyBounds(52a61fa14d44b641).(double dfXMin, double dfYMin, double dfXMax, |
| 2727 | double dfYMax) |
| 2728 | { |
| 2729 | m_sExtentcxx . . $ OGROSMDataSource#m_sExtent..MinX = dfXMin; |
| 2730 | m_sExtentcxx . . $ OGROSMDataSource#m_sExtent..MinY = dfYMin; |
| 2731 | m_sExtentcxx . . $ OGROSMDataSource#m_sExtent..MaxX = dfXMax; |
| 2732 | m_sExtentcxx . . $ OGROSMDataSource#m_sExtent..MaxY = dfYMax; |
| 2733 | m_bExtentValidcxx . . $ OGROSMDataSource#m_bExtentValid. = true; |
| 2734 | |
| 2735 | CPLDebug("OSM", "Got bounds : minx=%f, miny=%f, maxx=%f, maxy=%f", dfXMin, |
| 2736 | dfYMin, dfXMax, dfYMax); |
| 2737 | } |
| 2738 | |
| 2739 | static void OGROSMNotifyBoundscxx . . $ OGROSMNotifyBounds(c732a4249e1e03cf).(double dfXMin, double dfYMin, double dfXMax, |
| 2740 | double dfYMax, OSMContext * /* psCtxt */, |
| 2741 | void *user_data) |
| 2742 | { |
| 2743 | static_cast<OGROSMDataSourcecxx . . $ OGROSMDataSource# *>(user_data)->NotifyBoundscxx . . $ OGROSMDataSource#NotifyBounds(52a61fa14d44b641).(dfXMin, dfYMin, |
| 2744 | dfXMax, dfYMax); |
| 2745 | } |
| 2746 | |
| 2747 | /************************************************************************/ |
| 2748 | /* Open() */ |
| 2749 | /************************************************************************/ |
| 2750 | |
| 2751 | int OGROSMDataSourcecxx . . $ OGROSMDataSource#::Opencxx . . $ OGROSMDataSource#Open(5a7b06e3ce74da13).(const char *pszFilename, |
| 2752 | CSLConstListcxx . . $ CSLConstList# papszOpenOptionsIn) |
| 2753 | |
| 2754 | { |
| 2755 | m_psParsercxx . . $ OGROSMDataSource#m_psParser. = OSM_Open(pszFilename, OGROSMNotifyNodescxx . . $ OGROSMNotifyNodes(96d80dda9c2b6398)., OGROSMNotifyWaycxx . . $ OGROSMNotifyWay(a24678ce2f4cb2ed)., |
| 2756 | OGROSMNotifyRelationcxx . . $ OGROSMNotifyRelation(cdf02cc57946e942)., OGROSMNotifyBoundscxx . . $ OGROSMNotifyBounds(c732a4249e1e03cf)., this); |
| 2757 | if (m_psParsercxx . . $ OGROSMDataSource#m_psParser. == nullptr) |
| 2758 | return FALSEcxx . . $ `port/cpl_port.h:1180:9`!; |
| 2759 | |
| 2760 | if (CPLFetchBool(papszOpenOptionsIn, "INTERLEAVED_READING", false)) |
| 2761 | m_bInterleavedReadingcxx . . $ OGROSMDataSource#m_bInterleavedReading. = TRUEcxx . . $ `port/cpl_port.h:1184:9`!; |
| 2762 | |
| 2763 | /* The following 4 config options are only useful for debugging */ |
| 2764 | m_bIndexPointscxx . . $ OGROSMDataSource#m_bIndexPoints. = CPLTestBool(CPLGetConfigOption("OSM_INDEX_POINTS", "YES")); |
| 2765 | m_bUsePointsIndexcxx . . $ OGROSMDataSource#m_bUsePointsIndex. = |
| 2766 | CPLTestBool(CPLGetConfigOption("OSM_USE_POINTS_INDEX", "YES")); |
| 2767 | m_bIndexWayscxx . . $ OGROSMDataSource#m_bIndexWays. = CPLTestBool(CPLGetConfigOption("OSM_INDEX_WAYS", "YES")); |
| 2768 | m_bUseWaysIndexcxx . . $ OGROSMDataSource#m_bUseWaysIndex. = |
| 2769 | CPLTestBool(CPLGetConfigOption("OSM_USE_WAYS_INDEX", "YES")); |
| 2770 | |
| 2771 | m_bCustomIndexingcxx . . $ OGROSMDataSource#m_bCustomIndexing. = CPLTestBool(CSLFetchNameValueDef( |
| 2772 | papszOpenOptionsIn, "USE_CUSTOM_INDEXING", |
| 2773 | CPLGetConfigOption("OSM_USE_CUSTOM_INDEXING", "YES"))); |
| 2774 | if (!m_bCustomIndexingcxx . . $ OGROSMDataSource#m_bCustomIndexing.) |
| 2775 | CPLDebug("OSM", "Using SQLite indexing for points"); |
| 2776 | m_bCompressNodescxx . . $ OGROSMDataSource#m_bCompressNodes. = CPLTestBool( |
| 2777 | CSLFetchNameValueDef(papszOpenOptionsIn, "COMPRESS_NODES", |
| 2778 | CPLGetConfigOption("OSM_COMPRESS_NODES", "NO"))); |
| 2779 | if (m_bCompressNodescxx . . $ OGROSMDataSource#m_bCompressNodes.) |
| 2780 | CPLDebug("OSM", "Using compression for nodes DB"); |
| 2781 | |
| 2782 | // Do not change the below order without updating the IDX_LYR_ constants! |
| 2783 | m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers..emplace_back( |
| 2784 | stdcxx . . $ std/::make_unique<OGROSMLayercxx . . $ OGROSMLayer#>(this, IDX_LYR_POINTScxx . . $ IDX_LYR_POINTS., "points")); |
| 2785 | m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers..back()->GetLayerDefncxx . . $ OGRLayer#GetLayerDefn(407fccde18759965).()->SetGeomTypecxx . . $ OGRFeatureDefn#SetGeomType(f47ce3f1fe923726).(wkbPoint); |
| 2786 | |
| 2787 | m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers..emplace_back( |
| 2788 | stdcxx . . $ std/::make_unique<OGROSMLayercxx . . $ OGROSMLayer#>(this, IDX_LYR_LINEScxx . . $ IDX_LYR_LINES., "lines")); |
| 2789 | m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers..back()->GetLayerDefncxx . . $ OGRLayer#GetLayerDefn(407fccde18759965).()->SetGeomTypecxx . . $ OGRFeatureDefn#SetGeomType(f47ce3f1fe923726).(wkbLineString); |
| 2790 | |
| 2791 | m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers..emplace_back(stdcxx . . $ std/::make_unique<OGROSMLayercxx . . $ OGROSMLayer#>( |
| 2792 | this, IDX_LYR_MULTILINESTRINGScxx . . $ IDX_LYR_MULTILINESTRINGS., "multilinestrings")); |
| 2793 | m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers..back()->GetLayerDefncxx . . $ OGRLayer#GetLayerDefn(407fccde18759965).()->SetGeomTypecxx . . $ OGRFeatureDefn#SetGeomType(f47ce3f1fe923726).(wkbMultiLineString); |
| 2794 | |
| 2795 | m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers..emplace_back(stdcxx . . $ std/::make_unique<OGROSMLayercxx . . $ OGROSMLayer#>( |
| 2796 | this, IDX_LYR_MULTIPOLYGONScxx . . $ IDX_LYR_MULTIPOLYGONS., "multipolygons")); |
| 2797 | m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers..back()->GetLayerDefncxx . . $ OGRLayer#GetLayerDefn(407fccde18759965).()->SetGeomTypecxx . . $ OGRFeatureDefn#SetGeomType(f47ce3f1fe923726).(wkbMultiPolygon); |
| 2798 | |
| 2799 | m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers..emplace_back(stdcxx . . $ std/::make_unique<OGROSMLayercxx . . $ OGROSMLayer#>( |
| 2800 | this, IDX_LYR_OTHER_RELATIONScxx . . $ IDX_LYR_OTHER_RELATIONS., "other_relations")); |
| 2801 | m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers..back()->GetLayerDefncxx . . $ OGRLayer#GetLayerDefn(407fccde18759965).()->SetGeomTypecxx . . $ OGRFeatureDefn#SetGeomType(f47ce3f1fe923726).(wkbGeometryCollection); |
| 2802 | |
| 2803 | if (!ParseConfcxx . . $ OGROSMDataSource#ParseConf(b7c83bf152ed97ea).(papszOpenOptionsIn)) |
| 2804 | { |
| 2805 | CPLError(CE_Failure, CPLE_AppDefinedcxx . . $ `port/cpl_error.h:108:9`!, |
| 2806 | "Could not parse configuration file for OSM import"); |
| 2807 | return FALSEcxx . . $ `port/cpl_port.h:1180:9`!; |
| 2808 | } |
| 2809 | |
| 2810 | const char *pszTagsFormat = |
| 2811 | CSLFetchNameValue(papszOpenOptionsIn, "TAGS_FORMAT"); |
| 2812 | if (pszTagsFormat) |
| 2813 | { |
| 2814 | if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszTagsFormat, "JSON")) |
| 2815 | m_bTagsAsHSTOREcxx . . $ OGROSMDataSource#m_bTagsAsHSTORE. = false; |
| 2816 | else if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszTagsFormat, "HSTORE")) |
| 2817 | m_bTagsAsHSTOREcxx . . $ OGROSMDataSource#m_bTagsAsHSTORE. = true; |
| 2818 | else |
| 2819 | { |
| 2820 | CPLError(CE_Warning, CPLE_NotSupportedcxx . . $ `port/cpl_error.h:118:9`!, |
| 2821 | "Invalid value for TAGS_FORMAT open option: %s", |
| 2822 | pszTagsFormat); |
| 2823 | } |
| 2824 | } |
| 2825 | |
| 2826 | const auto eTagsSubType = m_bTagsAsHSTOREcxx . . $ OGROSMDataSource#m_bTagsAsHSTORE. ? OFSTNone : OFSTJSON; |
| 2827 | for (auto &&poLayer : m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers.) |
| 2828 | { |
| 2829 | if (poLayer->HasAllTagscxx . . $ OGROSMLayer#HasAllTags(50ce9a9e25b4a850).()) |
| 2830 | { |
| 2831 | poLayer->AddFieldcxx . . $ OGROSMLayer#AddField(121fc23317a1c8d0).("all_tags", OFTString, eTagsSubType); |
| 2832 | if (poLayer->HasOtherTagscxx . . $ OGROSMLayer#HasOtherTags(50ce9a9e25b4a850).()) |
| 2833 | { |
| 2834 | poLayer->SetHasOtherTagscxx . . $ OGROSMLayer#SetHasOtherTags(b45ddcbc8423892c).(false); |
| 2835 | } |
| 2836 | } |
| 2837 | else if (poLayer->HasOtherTagscxx . . $ OGROSMLayer#HasOtherTags(50ce9a9e25b4a850).()) |
| 2838 | poLayer->AddFieldcxx . . $ OGROSMLayer#AddField(121fc23317a1c8d0).("other_tags", OFTString, eTagsSubType); |
| 2839 | } |
| 2840 | |
| 2841 | m_bNeedsToSaveWayInfocxx . . $ OGROSMDataSource#m_bNeedsToSaveWayInfo. = |
| 2842 | (m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers.[IDX_LYR_MULTIPOLYGONScxx . . $ IDX_LYR_MULTIPOLYGONS.]->HasTimestampcxx . . $ OGROSMLayer#HasTimestamp(50ce9a9e25b4a850).() || |
| 2843 | m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers.[IDX_LYR_MULTIPOLYGONScxx . . $ IDX_LYR_MULTIPOLYGONS.]->HasChangesetcxx . . $ OGROSMLayer#HasChangeset(50ce9a9e25b4a850).() || |
| 2844 | m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers.[IDX_LYR_MULTIPOLYGONScxx . . $ IDX_LYR_MULTIPOLYGONS.]->HasVersioncxx . . $ OGROSMLayer#HasVersion(50ce9a9e25b4a850).() || |
| 2845 | m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers.[IDX_LYR_MULTIPOLYGONScxx . . $ IDX_LYR_MULTIPOLYGONS.]->HasUIDcxx . . $ OGROSMLayer#HasUID(50ce9a9e25b4a850).() || |
| 2846 | m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers.[IDX_LYR_MULTIPOLYGONScxx . . $ IDX_LYR_MULTIPOLYGONS.]->HasUsercxx . . $ OGROSMLayer#HasUser(50ce9a9e25b4a850).()); |
| 2847 | |
| 2848 | m_panReqIdscxx . . $ OGROSMDataSource#m_panReqIds. = static_cast<GIntBigcxx . . $ GIntBig# *>( |
| 2849 | VSI_MALLOC_VERBOSEcxx . . $ `port/cpl_vsi.h:375:9`!(MAX_ACCUMULATED_NODES * sizeof(GIntBig))); |
| 2850 | #ifdef ENABLE_NODE_LOOKUP_BY_HASHINGcxx . . $ `ogr/ogrsf_frmts/osm/ogr_osm.h:17:9`! |
| 2851 | m_panHashedIndexescxx . . $ OGROSMDataSource#m_panHashedIndexes. = static_cast<int *>( |
| 2852 | VSI_MALLOC_VERBOSEcxx . . $ `port/cpl_vsi.h:375:9`!(HASHED_INDEXES_ARRAY_SIZE * sizeof(int))); |
| 2853 | m_psCollisionBucketscxx . . $ OGROSMDataSource#m_psCollisionBuckets. = static_cast<CollisionBucketcxx . . $ CollisionBucket# *>(VSI_MALLOC_VERBOSEcxx . . $ `port/cpl_vsi.h:375:9`!( |
| 2854 | COLLISION_BUCKET_ARRAY_SIZE * sizeof(CollisionBucket))); |
| 2855 | #endif |
| 2856 | m_pasLonLatArraycxx . . $ OGROSMDataSource#m_pasLonLatArray. = static_cast<LonLatcxx . . $ LonLat# *>( |
| 2857 | VSI_MALLOC_VERBOSEcxx . . $ `port/cpl_vsi.h:375:9`!(MAX_ACCUMULATED_NODES * sizeof(LonLat))); |
| 2858 | m_panUnsortedReqIdscxx . . $ OGROSMDataSource#m_panUnsortedReqIds. = static_cast<GIntBigcxx . . $ GIntBig# *>( |
| 2859 | VSI_MALLOC_VERBOSEcxx . . $ `port/cpl_vsi.h:375:9`!(MAX_ACCUMULATED_NODES * sizeof(GIntBig))); |
| 2860 | try |
| 2861 | { |
| 2862 | m_asWayFeaturePairscxx . . $ OGROSMDataSource#m_asWayFeaturePairs..reserve(MAX_DELAYED_FEATUREScxx . . $ MAX_DELAYED_FEATURES.); |
| 2863 | } |
| 2864 | catch (const stdcxx . . $ std/::exception &) |
| 2865 | { |
| 2866 | CPLError(CE_Failure, CPLE_OutOfMemorycxx . . $ `port/cpl_error.h:110:9`!, |
| 2867 | "OGROSMDataSource::Open(): out of memory"); |
| 2868 | return FALSEcxx . . $ `port/cpl_port.h:1180:9`!; |
| 2869 | } |
| 2870 | m_pasAccumulatedTagscxx . . $ OGROSMDataSource#m_pasAccumulatedTags. = static_cast<IndexedKVPcxx . . $ IndexedKVP# *>( |
| 2871 | VSI_MALLOC_VERBOSEcxx . . $ `port/cpl_vsi.h:375:9`!(MAX_ACCUMULATED_TAGS * sizeof(IndexedKVP))); |
| 2872 | pabyNonRedundantValuescxx . . $ OGROSMDataSource#pabyNonRedundantValues. = |
| 2873 | static_cast<GBytecxx . . $ GByte# *>(VSI_MALLOC_VERBOSEcxx . . $ `port/cpl_vsi.h:375:9`!(MAX_NON_REDUNDANT_VALUES)); |
| 2874 | pabyNonRedundantKeyscxx . . $ OGROSMDataSource#pabyNonRedundantKeys. = |
| 2875 | static_cast<GBytecxx . . $ GByte# *>(VSI_MALLOC_VERBOSEcxx . . $ `port/cpl_vsi.h:375:9`!(MAX_NON_REDUNDANT_KEYS)); |
| 2876 | if (m_panReqIdscxx . . $ OGROSMDataSource#m_panReqIds. == nullptr || m_pasLonLatArraycxx . . $ OGROSMDataSource#m_pasLonLatArray. == nullptr || |
| 2877 | m_panUnsortedReqIdscxx . . $ OGROSMDataSource#m_panUnsortedReqIds. == nullptr || m_pasAccumulatedTagscxx . . $ OGROSMDataSource#m_pasAccumulatedTags. == nullptr || |
| 2878 | pabyNonRedundantValuescxx . . $ OGROSMDataSource#pabyNonRedundantValues. == nullptr || pabyNonRedundantKeyscxx . . $ OGROSMDataSource#pabyNonRedundantKeys. == nullptr) |
| 2879 | { |
| 2880 | return FALSEcxx . . $ `port/cpl_port.h:1180:9`!; |
| 2881 | } |
| 2882 | |
| 2883 | m_nMaxSizeForInMemoryDBInMBcxx . . $ OGROSMDataSource#m_nMaxSizeForInMemoryDBInMB. = atoicxx . . $ atoi(f5ecf3191ed0cd93).(CSLFetchNameValueDef( |
| 2884 | papszOpenOptionsIn, "MAX_TMPFILE_SIZE", |
| 2885 | CPLGetConfigOption("OSM_MAX_TMPFILE_SIZE", "100"))); |
| 2886 | if (m_nMaxSizeForInMemoryDBInMBcxx . . $ OGROSMDataSource#m_nMaxSizeForInMemoryDBInMB. == 0) |
| 2887 | m_nMaxSizeForInMemoryDBInMBcxx . . $ OGROSMDataSource#m_nMaxSizeForInMemoryDBInMB. = 1; |
| 2888 | GIntBigcxx . . $ GIntBig# nSize = |
| 2889 | static_cast<GIntBigcxx . . $ GIntBig#>(m_nMaxSizeForInMemoryDBInMBcxx . . $ OGROSMDataSource#m_nMaxSizeForInMemoryDBInMB.) * 1024 * 1024; |
| 2890 | if (nSize < 0 || |
| 2891 | static_cast<GUIntBigcxx . . $ GUIntBig#>(nSize) > stdcxx . . $ std/::numeric_limits<size_t>::max() / 2) |
| 2892 | { |
| 2893 | CPLError(CE_Failure, CPLE_AppDefinedcxx . . $ `port/cpl_error.h:108:9`!, |
| 2894 | "Invalid value for OSM_MAX_TMPFILE_SIZE. Using 100 instead."); |
| 2895 | m_nMaxSizeForInMemoryDBInMBcxx . . $ OGROSMDataSource#m_nMaxSizeForInMemoryDBInMB. = 100; |
| 2896 | nSize = static_cast<GIntBigcxx . . $ GIntBig#>(m_nMaxSizeForInMemoryDBInMBcxx . . $ OGROSMDataSource#m_nMaxSizeForInMemoryDBInMB.) * 1024 * 1024; |
| 2897 | } |
| 2898 | |
| 2899 | if (m_bCustomIndexingcxx . . $ OGROSMDataSource#m_bCustomIndexing.) |
| 2900 | { |
| 2901 | m_pabySectorcxx . . $ OGROSMDataSource#m_pabySector. = static_cast<GBytecxx . . $ GByte# *>(VSI_CALLOC_VERBOSEcxx . . $ `port/cpl_vsi.h:397:9`!(1, SECTOR_SIZE)); |
| 2902 | |
| 2903 | if (m_pabySectorcxx . . $ OGROSMDataSource#m_pabySector. == nullptr) |
| 2904 | { |
| 2905 | return FALSEcxx . . $ `port/cpl_port.h:1180:9`!; |
| 2906 | } |
| 2907 | |
| 2908 | m_bInMemoryNodesFilecxx . . $ OGROSMDataSource#m_bInMemoryNodesFile. = true; |
| 2909 | m_osNodesFilenamecxx . . $ OGROSMDataSource#m_osNodesFilename. = VSIMemGenerateHiddenFilename("osm_temp_nodes"); |
| 2910 | m_fpNodescxx . . $ OGROSMDataSource#m_fpNodes. = VSIFOpenL(m_osNodesFilenamecxx . . $ OGROSMDataSource#m_osNodesFilename., "wb+"); |
| 2911 | if (m_fpNodescxx . . $ OGROSMDataSource#m_fpNodes. == nullptr) |
| 2912 | { |
| 2913 | return FALSEcxx . . $ `port/cpl_port.h:1180:9`!; |
| 2914 | } |
| 2915 | |
| 2916 | CPLPushErrorHandler(CPLQuietErrorHandler); |
| 2917 | const bool bSuccess = |
| 2918 | VSIFTruncateL(m_fpNodescxx . . $ OGROSMDataSource#m_fpNodes., |
| 2919 | static_cast<vsi_l_offset>(nSize * 3 / 4)) == 0; |
| 2920 | CPLPopErrorHandler(); |
| 2921 | |
| 2922 | if (bSuccess) |
| 2923 | { |
| 2924 | VSIFTruncateL(m_fpNodescxx . . $ OGROSMDataSource#m_fpNodes., 0); |
| 2925 | } |
| 2926 | else |
| 2927 | { |
| 2928 | CPLDebug("OSM", "Not enough memory for in-memory file. " |
| 2929 | "Using disk temporary file instead."); |
| 2930 | |
| 2931 | VSIFCloseL(m_fpNodescxx . . $ OGROSMDataSource#m_fpNodes.); |
| 2932 | m_fpNodescxx . . $ OGROSMDataSource#m_fpNodes. = nullptr; |
| 2933 | VSIUnlink(m_osNodesFilenamecxx . . $ OGROSMDataSource#m_osNodesFilename.); |
| 2934 | |
| 2935 | m_bInMemoryNodesFilecxx . . $ OGROSMDataSource#m_bInMemoryNodesFile. = false; |
| 2936 | m_osNodesFilenamecxx . . $ OGROSMDataSource#m_osNodesFilename. = CPLGenerateTempFilenameSafe("osm_tmp_nodes"); |
| 2937 | |
| 2938 | m_fpNodescxx . . $ OGROSMDataSource#m_fpNodes. = VSIFOpenL(m_osNodesFilenamecxx . . $ OGROSMDataSource#m_osNodesFilename., "wb+"); |
| 2939 | if (m_fpNodescxx . . $ OGROSMDataSource#m_fpNodes. == nullptr) |
| 2940 | { |
| 2941 | return FALSEcxx . . $ `port/cpl_port.h:1180:9`!; |
| 2942 | } |
| 2943 | |
| 2944 | /* On Unix filesystems, you can remove a file even if it */ |
| 2945 | /* opened */ |
| 2946 | const char *pszVal = |
| 2947 | CPLGetConfigOption("OSM_UNLINK_TMPFILE", "YES"); |
| 2948 | if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszVal, "YES")) |
| 2949 | { |
| 2950 | CPLPushErrorHandler(CPLQuietErrorHandler); |
| 2951 | m_bMustUnlinkNodesFilecxx . . $ OGROSMDataSource#m_bMustUnlinkNodesFile. = VSIUnlink(m_osNodesFilenamecxx . . $ OGROSMDataSource#m_osNodesFilename.) != 0; |
| 2952 | CPLPopErrorHandler(); |
| 2953 | } |
| 2954 | |
| 2955 | return FALSEcxx . . $ `port/cpl_port.h:1180:9`!; |
| 2956 | } |
| 2957 | } |
| 2958 | |
| 2959 | const bool bRet = CreateTempDBcxx . . $ OGROSMDataSource#CreateTempDB(c9857a73d68e59ba).(); |
| 2960 | if (bRet) |
| 2961 | { |
| 2962 | CPLString osInterestLayers = |
| 2963 | GetInterestLayersForDSNamecxx . . $ GetInterestLayersForDSName(385147141d89f498).(GetDescriptioncxx . . $ GDALMajorObject#GetDescription(a9f41ea0e82d88cf).()); |
| 2964 | if (!osInterestLayers.empty()) |
| 2965 | { |
| 2966 | ReleaseResultSetcxx . . $ OGROSMDataSource#ReleaseResultSet(74233f8ea7d835ac).(ExecuteSQLcxx . . $ OGROSMDataSource#ExecuteSQL(1e911e025f8b6f61).(osInterestLayers, nullptr, nullptr)); |
| 2967 | } |
| 2968 | } |
| 2969 | return bRet; |
| 2970 | } |
| 2971 | |
| 2972 | /************************************************************************/ |
| 2973 | /* CreateTempDB() */ |
| 2974 | /************************************************************************/ |
| 2975 | |
| 2976 | bool OGROSMDataSourcecxx . . $ OGROSMDataSource#::CreateTempDBcxx . . $ OGROSMDataSource#CreateTempDB(c9857a73d68e59ba).() |
| 2977 | { |
| 2978 | char *pszErrMsg = nullptr; |
| 2979 | |
| 2980 | int rc = 0; |
| 2981 | bool bIsExisting = false; |
| 2982 | bool bSuccess = false; |
| 2983 | |
| 2984 | const char *pszExistingTmpFile = |
| 2985 | CPLGetConfigOption("OSM_EXISTING_TMPFILE", nullptr); |
| 2986 | if (pszExistingTmpFile != nullptr) |
| 2987 | { |
| 2988 | bSuccess = true; |
| 2989 | bIsExisting = true; |
| 2990 | rc = sqlite3_open_v2(pszExistingTmpFile, &m_hDBcxx . . $ OGROSMDataSource#m_hDB., |
| 2991 | SQLITE_OPEN_READWRITEcxx . . $ `<external>/2400532043262193228/sqlite3.h:604:9`! | SQLITE_OPEN_NOMUTEXcxx . . $ `<external>/2400532043262193228/sqlite3.h:618:9`!, |
| 2992 | nullptr); |
| 2993 | } |
| 2994 | else |
| 2995 | { |
| 2996 | m_osTmpDBNamecxx . . $ OGROSMDataSource#m_osTmpDBName. = VSIMemGenerateHiddenFilename("osm_temp.sqlite"); |
| 2997 | |
| 2998 | // On 32 bit, the virtual memory space is scarce, so we need to |
| 2999 | // reserve it right now. Will not hurt on 64 bit either. |
| 3000 | VSILFILE *fp = VSIFOpenL(m_osTmpDBNamecxx . . $ OGROSMDataSource#m_osTmpDBName., "wb"); |
| 3001 | if (fp) |
| 3002 | { |
| 3003 | vsi_l_offset nSize = |
| 3004 | static_cast<vsi_l_offset>(m_nMaxSizeForInMemoryDBInMBcxx . . $ OGROSMDataSource#m_nMaxSizeForInMemoryDBInMB.) * 1024 * |
| 3005 | 1024; |
| 3006 | if (m_bCustomIndexingcxx . . $ OGROSMDataSource#m_bCustomIndexing. && m_bInMemoryNodesFilecxx . . $ OGROSMDataSource#m_bInMemoryNodesFile.) |
| 3007 | nSize = nSize / 4; |
| 3008 | |
| 3009 | CPLPushErrorHandler(CPLQuietErrorHandler); |
| 3010 | bSuccess = VSIFTruncateL(fp, nSize) == 0; |
| 3011 | CPLPopErrorHandler(); |
| 3012 | |
| 3013 | if (bSuccess) |
| 3014 | bSuccess = VSIFTruncateL(fp, 0) == 0; |
| 3015 | |
| 3016 | VSIFCloseL(fp); |
| 3017 | |
| 3018 | if (!bSuccess) |
| 3019 | { |
| 3020 | CPLDebug("OSM", "Not enough memory for in-memory file. " |
| 3021 | "Using disk temporary file instead."); |
| 3022 | VSIUnlink(m_osTmpDBNamecxx . . $ OGROSMDataSource#m_osTmpDBName.); |
| 3023 | } |
| 3024 | } |
| 3025 | |
| 3026 | if (bSuccess) |
| 3027 | { |
| 3028 | m_bInMemoryTmpDBcxx . . $ OGROSMDataSource#m_bInMemoryTmpDB. = true; |
| 3029 | m_pMyVFScxx . . $ OGROSMDataSource#m_pMyVFS. = OGRSQLiteCreateVFScxx . . $ OGRSQLiteCreateVFS(1d6fedc16c708c0e).(nullptr, this); |
| 3030 | sqlite3_vfs_register(m_pMyVFScxx . . $ OGROSMDataSource#m_pMyVFS., 0); |
| 3031 | rc = sqlite3_open_v2(m_osTmpDBNamecxx . . $ OGROSMDataSource#m_osTmpDBName..c_str(), &m_hDBcxx . . $ OGROSMDataSource#m_hDB., |
| 3032 | SQLITE_OPEN_READWRITEcxx . . $ `<external>/2400532043262193228/sqlite3.h:604:9`! | SQLITE_OPEN_CREATEcxx . . $ `<external>/2400532043262193228/sqlite3.h:605:9`! | |
| 3033 | SQLITE_OPEN_NOMUTEXcxx . . $ `<external>/2400532043262193228/sqlite3.h:618:9`!, |
| 3034 | m_pMyVFScxx . . $ OGROSMDataSource#m_pMyVFS.->zNamecxx . . $ sqlite3_vfs#zName.); |
| 3035 | } |
| 3036 | } |
| 3037 | |
| 3038 | if (!bSuccess) |
| 3039 | { |
| 3040 | m_osTmpDBNamecxx . . $ OGROSMDataSource#m_osTmpDBName. = CPLGenerateTempFilenameSafe("osm_tmp"); |
| 3041 | rc = sqlite3_open(m_osTmpDBNamecxx . . $ OGROSMDataSource#m_osTmpDBName..c_str(), &m_hDBcxx . . $ OGROSMDataSource#m_hDB.); |
| 3042 | |
| 3043 | /* On Unix filesystems, you can remove a file even if it */ |
| 3044 | /* opened */ |
| 3045 | if (rc == SQLITE_OKcxx . . $ `<external>/2400532043262193228/sqlite3.h:449:9`!) |
| 3046 | { |
| 3047 | const char *pszVal = |
| 3048 | CPLGetConfigOption("OSM_UNLINK_TMPFILE", "YES"); |
| 3049 | if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszVal, "YES")) |
| 3050 | { |
| 3051 | CPLPushErrorHandler(CPLQuietErrorHandler); |
| 3052 | m_bMustUnlinkcxx . . $ OGROSMDataSource#m_bMustUnlink. = VSIUnlink(m_osTmpDBNamecxx . . $ OGROSMDataSource#m_osTmpDBName.) != 0; |
| 3053 | CPLPopErrorHandler(); |
| 3054 | } |
| 3055 | } |
| 3056 | } |
| 3057 | |
| 3058 | if (rc != SQLITE_OKcxx . . $ `<external>/2400532043262193228/sqlite3.h:449:9`!) |
| 3059 | { |
| 3060 | CPLError(CE_Failure, CPLE_OpenFailedcxx . . $ `port/cpl_error.h:114:9`!, "sqlite3_open(%s) failed: %s", |
| 3061 | m_osTmpDBNamecxx . . $ OGROSMDataSource#m_osTmpDBName..c_str(), sqlite3_errmsg(m_hDBcxx . . $ OGROSMDataSource#m_hDB.)); |
| 3062 | return false; |
| 3063 | } |
| 3064 | |
| 3065 | if (!SetDBOptionscxx . . $ OGROSMDataSource#SetDBOptions(c9857a73d68e59ba).()) |
| 3066 | { |
| 3067 | return false; |
| 3068 | } |
| 3069 | |
| 3070 | if (!bIsExisting) |
| 3071 | { |
| 3072 | rc = sqlite3_exec( |
| 3073 | m_hDBcxx . . $ OGROSMDataSource#m_hDB., "CREATE TABLE nodes (id INTEGER PRIMARY KEY, coords BLOB)", |
| 3074 | nullptr, nullptr, &pszErrMsg); |
| 3075 | if (rc != SQLITE_OKcxx . . $ `<external>/2400532043262193228/sqlite3.h:449:9`!) |
| 3076 | { |
| 3077 | CPLError(CE_Failure, CPLE_AppDefinedcxx . . $ `port/cpl_error.h:108:9`!, |
| 3078 | "Unable to create table nodes : %s", pszErrMsg); |
| 3079 | sqlite3_free(pszErrMsg); |
| 3080 | return false; |
| 3081 | } |
| 3082 | |
| 3083 | rc = sqlite3_exec( |
| 3084 | m_hDBcxx . . $ OGROSMDataSource#m_hDB., "CREATE TABLE ways (id INTEGER PRIMARY KEY, data BLOB)", |
| 3085 | nullptr, nullptr, &pszErrMsg); |
| 3086 | if (rc != SQLITE_OKcxx . . $ `<external>/2400532043262193228/sqlite3.h:449:9`!) |
| 3087 | { |
| 3088 | CPLError(CE_Failure, CPLE_AppDefinedcxx . . $ `port/cpl_error.h:108:9`!, |
| 3089 | "Unable to create table ways : %s", pszErrMsg); |
| 3090 | sqlite3_free(pszErrMsg); |
| 3091 | return false; |
| 3092 | } |
| 3093 | |
| 3094 | rc = sqlite3_exec( |
| 3095 | m_hDBcxx . . $ OGROSMDataSource#m_hDB., "CREATE TABLE polygons_standalone (id INTEGER PRIMARY KEY)", |
| 3096 | nullptr, nullptr, &pszErrMsg); |
| 3097 | if (rc != SQLITE_OKcxx . . $ `<external>/2400532043262193228/sqlite3.h:449:9`!) |
| 3098 | { |
| 3099 | CPLError(CE_Failure, CPLE_AppDefinedcxx . . $ `port/cpl_error.h:108:9`!, |
| 3100 | "Unable to create table polygons_standalone : %s", |
| 3101 | pszErrMsg); |
| 3102 | sqlite3_free(pszErrMsg); |
| 3103 | return false; |
| 3104 | } |
| 3105 | } |
| 3106 | |
| 3107 | return CreatePreparedStatementscxx . . $ OGROSMDataSource#CreatePreparedStatements(c9857a73d68e59ba).(); |
| 3108 | } |
| 3109 | |
| 3110 | /************************************************************************/ |
| 3111 | /* SetDBOptions() */ |
| 3112 | /************************************************************************/ |
| 3113 | |
| 3114 | bool OGROSMDataSourcecxx . . $ OGROSMDataSource#::SetDBOptionscxx . . $ OGROSMDataSource#SetDBOptions(c9857a73d68e59ba).() |
| 3115 | { |
| 3116 | char *pszErrMsg = nullptr; |
| 3117 | int rc = sqlite3_exec(m_hDBcxx . . $ OGROSMDataSource#m_hDB., "PRAGMA synchronous = OFF", nullptr, nullptr, |
| 3118 | &pszErrMsg); |
| 3119 | if (rc != SQLITE_OKcxx . . $ `<external>/2400532043262193228/sqlite3.h:449:9`!) |
| 3120 | { |
| 3121 | CPLError(CE_Failure, CPLE_AppDefinedcxx . . $ `port/cpl_error.h:108:9`!, |
| 3122 | "Unable to run PRAGMA synchronous : %s", pszErrMsg); |
| 3123 | sqlite3_free(pszErrMsg); |
| 3124 | return false; |
| 3125 | } |
| 3126 | |
| 3127 | rc = sqlite3_exec(m_hDBcxx . . $ OGROSMDataSource#m_hDB., "PRAGMA journal_mode = OFF", nullptr, nullptr, |
| 3128 | &pszErrMsg); |
| 3129 | if (rc != SQLITE_OKcxx . . $ `<external>/2400532043262193228/sqlite3.h:449:9`!) |
| 3130 | { |
| 3131 | CPLError(CE_Failure, CPLE_AppDefinedcxx . . $ `port/cpl_error.h:108:9`!, |
| 3132 | "Unable to run PRAGMA journal_mode : %s", pszErrMsg); |
| 3133 | sqlite3_free(pszErrMsg); |
| 3134 | return false; |
| 3135 | } |
| 3136 | |
| 3137 | rc = sqlite3_exec(m_hDBcxx . . $ OGROSMDataSource#m_hDB., "PRAGMA temp_store = MEMORY", nullptr, nullptr, |
| 3138 | &pszErrMsg); |
| 3139 | if (rc != SQLITE_OKcxx . . $ `<external>/2400532043262193228/sqlite3.h:449:9`!) |
| 3140 | { |
| 3141 | CPLError(CE_Failure, CPLE_AppDefinedcxx . . $ `port/cpl_error.h:108:9`!, |
| 3142 | "Unable to run PRAGMA temp_store : %s", pszErrMsg); |
| 3143 | sqlite3_free(pszErrMsg); |
| 3144 | return false; |
| 3145 | } |
| 3146 | |
| 3147 | SetCacheSizecxx . . $ OGROSMDataSource#SetCacheSize(49f6e7a06ebc5aa8).(); |
| 3148 | |
| 3149 | if (!StartTransactionCacheDBcxx . . $ OGROSMDataSource#StartTransactionCacheDB(c9857a73d68e59ba).()) |
| 3150 | return false; |
| 3151 | |
| 3152 | return true; |
| 3153 | } |
| 3154 | |
| 3155 | /************************************************************************/ |
| 3156 | /* SetCacheSize() */ |
| 3157 | /************************************************************************/ |
| 3158 | |
| 3159 | void OGROSMDataSourcecxx . . $ OGROSMDataSource#::SetCacheSizecxx . . $ OGROSMDataSource#SetCacheSize(49f6e7a06ebc5aa8).() |
| 3160 | { |
| 3161 | const char *pszSqliteCacheMB = |
| 3162 | CPLGetConfigOption("OSM_SQLITE_CACHE", nullptr); |
| 3163 | |
| 3164 | if (pszSqliteCacheMB == nullptr) |
| 3165 | return; |
| 3166 | |
| 3167 | char *pszErrMsg = nullptr; |
| 3168 | char **papszResult = nullptr; |
| 3169 | int nRowCount = 0; |
| 3170 | int nColCount = 0; |
| 3171 | int iSqlitePageSize = -1; |
| 3172 | const GIntBigcxx . . $ GIntBig# iSqliteCacheBytes = |
| 3173 | static_cast<GIntBigcxx . . $ GIntBig#>(atoicxx . . $ atoi(f5ecf3191ed0cd93).(pszSqliteCacheMB)) * 1024 * 1024; |
| 3174 | |
| 3175 | /* querying the current PageSize */ |
| 3176 | int rc = sqlite3_get_table(m_hDBcxx . . $ OGROSMDataSource#m_hDB., "PRAGMA page_size", &papszResult, |
| 3177 | &nRowCount, &nColCount, &pszErrMsg); |
| 3178 | if (rc == SQLITE_OKcxx . . $ `<external>/2400532043262193228/sqlite3.h:449:9`!) |
| 3179 | { |
| 3180 | for (int iRow = 1; iRow <= nRowCount; iRow++) |
| 3181 | { |
| 3182 | iSqlitePageSize = atoicxx . . $ atoi(f5ecf3191ed0cd93).(papszResult[(iRow * nColCount) + 0]); |
| 3183 | } |
| 3184 | sqlite3_free_table(papszResult); |
| 3185 | } |
| 3186 | if (iSqlitePageSize < 0) |
| 3187 | { |
| 3188 | CPLError(CE_Failure, CPLE_AppDefinedcxx . . $ `port/cpl_error.h:108:9`!, |
| 3189 | "Unable to run PRAGMA page_size : %s", |
| 3190 | pszErrMsg ? pszErrMsg : sqlite3_errmsg(m_hDBcxx . . $ OGROSMDataSource#m_hDB.)); |
| 3191 | sqlite3_free(pszErrMsg); |
| 3192 | return; |
| 3193 | } |
| 3194 | if (iSqlitePageSize == 0) |
| 3195 | return; |
| 3196 | |
| 3197 | /* computing the CacheSize as #Pages */ |
| 3198 | const int iSqliteCachePages = |
| 3199 | static_cast<int>(iSqliteCacheBytes / iSqlitePageSize); |
| 3200 | if (iSqliteCachePages <= 0) |
| 3201 | return; |
| 3202 | |
| 3203 | rc = sqlite3_exec(m_hDBcxx . . $ OGROSMDataSource#m_hDB., |
| 3204 | CPLSPrintf("PRAGMA cache_size = %d", iSqliteCachePages), |
| 3205 | nullptr, nullptr, &pszErrMsg); |
| 3206 | if (rc != SQLITE_OKcxx . . $ `<external>/2400532043262193228/sqlite3.h:449:9`!) |
| 3207 | { |
| 3208 | CPLError(CE_Warning, CPLE_AppDefinedcxx . . $ `port/cpl_error.h:108:9`!, |
| 3209 | "Unrecognized value for PRAGMA cache_size : %s", pszErrMsg); |
| 3210 | sqlite3_free(pszErrMsg); |
| 3211 | } |
| 3212 | } |
| 3213 | |
| 3214 | /************************************************************************/ |
| 3215 | /* CreatePreparedStatements() */ |
| 3216 | /************************************************************************/ |
| 3217 | |
| 3218 | bool OGROSMDataSourcecxx . . $ OGROSMDataSource#::CreatePreparedStatementscxx . . $ OGROSMDataSource#CreatePreparedStatements(c9857a73d68e59ba).() |
| 3219 | { |
| 3220 | int rc = |
| 3221 | sqlite3_prepare_v2(m_hDBcxx . . $ OGROSMDataSource#m_hDB., "INSERT INTO nodes (id, coords) VALUES (?,?)", |
| 3222 | -1, &m_hInsertNodeStmtcxx . . $ OGROSMDataSource#m_hInsertNodeStmt., nullptr); |
| 3223 | if (rc != SQLITE_OKcxx . . $ `<external>/2400532043262193228/sqlite3.h:449:9`!) |
| 3224 | { |
| 3225 | CPLError(CE_Failure, CPLE_AppDefinedcxx . . $ `port/cpl_error.h:108:9`!, |
| 3226 | "sqlite3_prepare_v2() failed : %s", sqlite3_errmsg(m_hDBcxx . . $ OGROSMDataSource#m_hDB.)); |
| 3227 | return false; |
| 3228 | } |
| 3229 | |
| 3230 | m_pahSelectNodeStmtcxx . . $ OGROSMDataSource#m_pahSelectNodeStmt. = static_cast<sqlite3_stmt **>( |
| 3231 | CPLCalloc(sizeof(sqlite3_stmt *), LIMIT_IDS_PER_REQUESTcxx . . $ LIMIT_IDS_PER_REQUEST.)); |
| 3232 | |
| 3233 | char szTmp[LIMIT_IDS_PER_REQUESTcxx . . $ LIMIT_IDS_PER_REQUEST. * 2 + 128]; |
| 3234 | strcpy(szTmp, "SELECT id, coords FROM nodes WHERE id IN ("); |
| 3235 | int nLen = static_cast<int>(strlen(szTmp)); |
| 3236 | for (int i = 0; i < LIMIT_IDS_PER_REQUESTcxx . . $ LIMIT_IDS_PER_REQUEST.; i++) |
| 3237 | { |
| 3238 | if (i == 0) |
| 3239 | { |
| 3240 | strcpy(szTmp + nLen, "?) ORDER BY id ASC"); |
| 3241 | nLen += 2; |
| 3242 | } |
| 3243 | else |
| 3244 | { |
| 3245 | strcpy(szTmp + nLen - 1, ",?) ORDER BY id ASC"); |
| 3246 | nLen += 2; |
| 3247 | } |
| 3248 | rc = sqlite3_prepare_v2(m_hDBcxx . . $ OGROSMDataSource#m_hDB., szTmp, -1, &m_pahSelectNodeStmtcxx . . $ OGROSMDataSource#m_pahSelectNodeStmt.[i], |
| 3249 | nullptr); |
| 3250 | if (rc != SQLITE_OKcxx . . $ `<external>/2400532043262193228/sqlite3.h:449:9`!) |
| 3251 | { |
| 3252 | CPLError(CE_Failure, CPLE_AppDefinedcxx . . $ `port/cpl_error.h:108:9`!, |
| 3253 | "sqlite3_prepare_v2() failed : %s", |
| 3254 | sqlite3_errmsg(m_hDBcxx . . $ OGROSMDataSource#m_hDB.)); |
| 3255 | return false; |
| 3256 | } |
| 3257 | } |
| 3258 | |
| 3259 | rc = sqlite3_prepare_v2(m_hDBcxx . . $ OGROSMDataSource#m_hDB., "INSERT INTO ways (id, data) VALUES (?,?)", |
| 3260 | -1, &m_hInsertWayStmtcxx . . $ OGROSMDataSource#m_hInsertWayStmt., nullptr); |
| 3261 | if (rc != SQLITE_OKcxx . . $ `<external>/2400532043262193228/sqlite3.h:449:9`!) |
| 3262 | { |
| 3263 | CPLError(CE_Failure, CPLE_AppDefinedcxx . . $ `port/cpl_error.h:108:9`!, |
| 3264 | "sqlite3_prepare_v2() failed : %s", sqlite3_errmsg(m_hDBcxx . . $ OGROSMDataSource#m_hDB.)); |
| 3265 | return false; |
| 3266 | } |
| 3267 | |
| 3268 | m_pahSelectWayStmtcxx . . $ OGROSMDataSource#m_pahSelectWayStmt. = static_cast<sqlite3_stmt **>( |
| 3269 | CPLCalloc(sizeof(sqlite3_stmt *), LIMIT_IDS_PER_REQUESTcxx . . $ LIMIT_IDS_PER_REQUEST.)); |
| 3270 | |
| 3271 | strcpy(szTmp, "SELECT id, data FROM ways WHERE id IN ("); |
| 3272 | nLen = static_cast<int>(strlen(szTmp)); |
| 3273 | for (int i = 0; i < LIMIT_IDS_PER_REQUESTcxx . . $ LIMIT_IDS_PER_REQUEST.; i++) |
| 3274 | { |
| 3275 | if (i == 0) |
| 3276 | { |
| 3277 | strcpy(szTmp + nLen, "?)"); |
| 3278 | nLen += 2; |
| 3279 | } |
| 3280 | else |
| 3281 | { |
| 3282 | strcpy(szTmp + nLen - 1, ",?)"); |
| 3283 | nLen += 2; |
| 3284 | } |
| 3285 | rc = sqlite3_prepare_v2(m_hDBcxx . . $ OGROSMDataSource#m_hDB., szTmp, -1, &m_pahSelectWayStmtcxx . . $ OGROSMDataSource#m_pahSelectWayStmt.[i], |
| 3286 | nullptr); |
| 3287 | if (rc != SQLITE_OKcxx . . $ `<external>/2400532043262193228/sqlite3.h:449:9`!) |
| 3288 | { |
| 3289 | CPLError(CE_Failure, CPLE_AppDefinedcxx . . $ `port/cpl_error.h:108:9`!, |
| 3290 | "sqlite3_prepare_v2() failed : %s", |
| 3291 | sqlite3_errmsg(m_hDBcxx . . $ OGROSMDataSource#m_hDB.)); |
| 3292 | return false; |
| 3293 | } |
| 3294 | } |
| 3295 | |
| 3296 | rc = sqlite3_prepare_v2(m_hDBcxx . . $ OGROSMDataSource#m_hDB., |
| 3297 | "INSERT INTO polygons_standalone (id) VALUES (?)", |
| 3298 | -1, &m_hInsertPolygonsStandaloneStmtcxx . . $ OGROSMDataSource#m_hInsertPolygonsStandaloneStmt., nullptr); |
| 3299 | if (rc != SQLITE_OKcxx . . $ `<external>/2400532043262193228/sqlite3.h:449:9`!) |
| 3300 | { |
| 3301 | CPLError(CE_Failure, CPLE_AppDefinedcxx . . $ `port/cpl_error.h:108:9`!, |
| 3302 | "sqlite3_prepare_v2() failed : %s", sqlite3_errmsg(m_hDBcxx . . $ OGROSMDataSource#m_hDB.)); |
| 3303 | return false; |
| 3304 | } |
| 3305 | |
| 3306 | rc = sqlite3_prepare_v2(m_hDBcxx . . $ OGROSMDataSource#m_hDB., |
| 3307 | "DELETE FROM polygons_standalone WHERE id = ?", -1, |
| 3308 | &m_hDeletePolygonsStandaloneStmtcxx . . $ OGROSMDataSource#m_hDeletePolygonsStandaloneStmt., nullptr); |
| 3309 | if (rc != SQLITE_OKcxx . . $ `<external>/2400532043262193228/sqlite3.h:449:9`!) |
| 3310 | { |
| 3311 | CPLError(CE_Failure, CPLE_AppDefinedcxx . . $ `port/cpl_error.h:108:9`!, |
| 3312 | "sqlite3_prepare_v2() failed : %s", sqlite3_errmsg(m_hDBcxx . . $ OGROSMDataSource#m_hDB.)); |
| 3313 | return false; |
| 3314 | } |
| 3315 | |
| 3316 | rc = sqlite3_prepare_v2(m_hDBcxx . . $ OGROSMDataSource#m_hDB., |
| 3317 | "SELECT id FROM polygons_standalone ORDER BY id", |
| 3318 | -1, &m_hSelectPolygonsStandaloneStmtcxx . . $ OGROSMDataSource#m_hSelectPolygonsStandaloneStmt., nullptr); |
| 3319 | if (rc != SQLITE_OKcxx . . $ `<external>/2400532043262193228/sqlite3.h:449:9`!) |
| 3320 | { |
| 3321 | CPLError(CE_Failure, CPLE_AppDefinedcxx . . $ `port/cpl_error.h:108:9`!, |
| 3322 | "sqlite3_prepare_v2() failed : %s", sqlite3_errmsg(m_hDBcxx . . $ OGROSMDataSource#m_hDB.)); |
| 3323 | return false; |
| 3324 | } |
| 3325 | |
| 3326 | return true; |
| 3327 | } |
| 3328 | |
| 3329 | /************************************************************************/ |
| 3330 | /* StartTransactionCacheDB() */ |
| 3331 | /************************************************************************/ |
| 3332 | |
| 3333 | bool OGROSMDataSourcecxx . . $ OGROSMDataSource#::StartTransactionCacheDBcxx . . $ OGROSMDataSource#StartTransactionCacheDB(c9857a73d68e59ba).() |
| 3334 | { |
| 3335 | if (m_bInTransactioncxx . . $ OGROSMDataSource#m_bInTransaction.) |
| 3336 | return false; |
| 3337 | |
| 3338 | char *pszErrMsg = nullptr; |
| 3339 | int rc = sqlite3_exec(m_hDBcxx . . $ OGROSMDataSource#m_hDB., "BEGIN", nullptr, nullptr, &pszErrMsg); |
| 3340 | if (rc != SQLITE_OKcxx . . $ `<external>/2400532043262193228/sqlite3.h:449:9`!) |
| 3341 | { |
| 3342 | CPLError(CE_Failure, CPLE_AppDefinedcxx . . $ `port/cpl_error.h:108:9`!, |
| 3343 | "Unable to start transaction : %s", pszErrMsg); |
| 3344 | sqlite3_free(pszErrMsg); |
| 3345 | return false; |
| 3346 | } |
| 3347 | |
| 3348 | m_bInTransactioncxx . . $ OGROSMDataSource#m_bInTransaction. = true; |
| 3349 | |
| 3350 | return true; |
| 3351 | } |
| 3352 | |
| 3353 | /************************************************************************/ |
| 3354 | /* CommitTransactionCacheDB() */ |
| 3355 | /************************************************************************/ |
| 3356 | |
| 3357 | bool OGROSMDataSourcecxx . . $ OGROSMDataSource#::CommitTransactionCacheDBcxx . . $ OGROSMDataSource#CommitTransactionCacheDB(c9857a73d68e59ba).() |
| 3358 | { |
| 3359 | if (!m_bInTransactioncxx . . $ OGROSMDataSource#m_bInTransaction.) |
| 3360 | return false; |
| 3361 | |
| 3362 | m_bInTransactioncxx . . $ OGROSMDataSource#m_bInTransaction. = false; |
| 3363 | |
| 3364 | char *pszErrMsg = nullptr; |
| 3365 | int rc = sqlite3_exec(m_hDBcxx . . $ OGROSMDataSource#m_hDB., "COMMIT", nullptr, nullptr, &pszErrMsg); |
| 3366 | if (rc != SQLITE_OKcxx . . $ `<external>/2400532043262193228/sqlite3.h:449:9`!) |
| 3367 | { |
| 3368 | CPLError(CE_Failure, CPLE_AppDefinedcxx . . $ `port/cpl_error.h:108:9`!, |
| 3369 | "Unable to commit transaction : %s", pszErrMsg); |
| 3370 | sqlite3_free(pszErrMsg); |
| 3371 | return false; |
| 3372 | } |
| 3373 | |
| 3374 | return true; |
| 3375 | } |
| 3376 | |
| 3377 | /************************************************************************/ |
| 3378 | /* AddComputedAttributes() */ |
| 3379 | /************************************************************************/ |
| 3380 | |
| 3381 | void OGROSMDataSourcecxx . . $ OGROSMDataSource#::AddComputedAttributescxx . . $ OGROSMDataSource#AddComputedAttributes(d2ee151f8be59f9e).( |
| 3382 | int iCurLayer, const stdcxx . . $ std/::vector<OGROSMComputedAttributecxx . . $ OGROSMComputedAttribute#> &oAttributes) |
| 3383 | { |
| 3384 | for (const auto &oAttribute : oAttributes) |
| 3385 | { |
| 3386 | if (!oAttribute.osSQLcxx . . $ OGROSMComputedAttribute#osSQL..empty()) |
| 3387 | { |
| 3388 | m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers.[iCurLayer]->AddComputedAttributecxx . . $ OGROSMLayer#AddComputedAttribute(42f5408446425ea6).( |
| 3389 | oAttribute.osNamecxx . . $ OGROSMComputedAttribute#osName., oAttribute.eTypecxx . . $ OGROSMComputedAttribute#eType., oAttribute.osSQLcxx . . $ OGROSMComputedAttribute#osSQL.); |
| 3390 | } |
| 3391 | } |
| 3392 | } |
| 3393 | |
| 3394 | /************************************************************************/ |
| 3395 | /* ParseConf() */ |
| 3396 | /************************************************************************/ |
| 3397 | |
| 3398 | bool OGROSMDataSourcecxx . . $ OGROSMDataSource#::ParseConfcxx . . $ OGROSMDataSource#ParseConf(b7c83bf152ed97ea).(CSLConstListcxx . . $ CSLConstList# papszOpenOptionsIn) |
| 3399 | { |
| 3400 | VSILFILE *fpConf = nullptr; |
| 3401 | |
| 3402 | const char *pszFilename = |
| 3403 | CSLFetchNameValueDef(papszOpenOptionsIn, "CONFIG_FILE", |
| 3404 | CPLGetConfigOption("OSM_CONFIG_FILE", nullptr)); |
| 3405 | if (pszFilename == nullptr) |
| 3406 | { |
| 3407 | #if !defined(USE_ONLY_EMBEDDED_RESOURCE_FILES) |
| 3408 | pszFilename = CPLFindFile("gdal", "osmconf.ini"); |
| 3409 | #endif |
| 3410 | #ifdef EMBED_RESOURCE_FILES |
| 3411 | if (!pszFilename || EQUAL(pszFilename, "osmconf.ini")) |
| 3412 | { |
| 3413 | static const bool bOnce [[maybe_unused]] = []() |
| 3414 | { |
| 3415 | CPLDebug("OSM", "Using embedded osmconf.ini"); |
| 3416 | return true; |
| 3417 | }(); |
| 3418 | fpConf = VSIFileFromMemBuffer( |
| 3419 | nullptr, |
| 3420 | const_cast<GByte *>( |
| 3421 | reinterpret_cast<const GByte *>(OSMGetOSMConfIni())), |
| 3422 | static_cast<int>(strlen(OSMGetOSMConfIni())), |
| 3423 | /* bTakeOwnership = */ false); |
| 3424 | } |
| 3425 | #else |
| 3426 | if (!pszFilename) |
| 3427 | { |
| 3428 | CPLError(CE_Warning, CPLE_AppDefinedcxx . . $ `port/cpl_error.h:108:9`!, |
| 3429 | "Cannot find osmconf.ini configuration file"); |
| 3430 | return false; |
| 3431 | } |
| 3432 | #endif |
| 3433 | } |
| 3434 | |
| 3435 | if (pszFilename) |
| 3436 | m_osConfigFilecxx . . $ OGROSMDataSource#m_osConfigFile. = pszFilename; |
| 3437 | |
| 3438 | #if defined(EMBED_RESOURCE_FILES) |
| 3439 | if (!fpConf) |
| 3440 | #endif |
| 3441 | { |
| 3442 | fpConf = VSIFOpenL(pszFilename, "rb"); |
| 3443 | if (fpConf == nullptr) |
| 3444 | return false; |
| 3445 | } |
| 3446 | |
| 3447 | const char *pszLine = nullptr; |
| 3448 | int iCurLayer = -1; |
| 3449 | stdcxx . . $ std/::vector<OGROSMComputedAttributecxx . . $ OGROSMComputedAttribute#> oAttributes; |
| 3450 | |
| 3451 | while ((pszLine = CPLReadLine2L(fpConf, -1, nullptr)) != nullptr) |
| 3452 | { |
| 3453 | if (pszLine[0] == '#') |
| 3454 | continue; |
| 3455 | if (pszLine[0] == '[' && pszLine[strlen(pszLine) - 1] == ']') |
| 3456 | { |
| 3457 | if (iCurLayer >= 0) |
| 3458 | AddComputedAttributescxx . . $ OGROSMDataSource#AddComputedAttributes(d2ee151f8be59f9e).(iCurLayer, oAttributes); |
| 3459 | oAttributes.resize(0); |
| 3460 | |
| 3461 | iCurLayer = -1; |
| 3462 | pszLine++; |
| 3463 | const_cast<char *>(pszLine)[strlen(pszLine) - 1] = |
| 3464 | '\0'; /* Evil but OK */ |
| 3465 | |
| 3466 | if (strcmp(pszLine, "general") == 0) |
| 3467 | { |
| 3468 | continue; |
| 3469 | } |
| 3470 | |
| 3471 | int i = 0; |
| 3472 | for (auto &&poLayer : m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers.) |
| 3473 | { |
| 3474 | if (strcmp(pszLine, poLayer->GetNamecxx . . $ OGRLayer#GetName(a9f41ea0e82d88cf).()) == 0) |
| 3475 | { |
| 3476 | iCurLayer = i; |
| 3477 | break; |
| 3478 | } |
| 3479 | ++i; |
| 3480 | } |
| 3481 | if (iCurLayer < 0) |
| 3482 | { |
| 3483 | CPLError(CE_Warning, CPLE_AppDefinedcxx . . $ `port/cpl_error.h:108:9`!, |
| 3484 | "Layer '%s' mentioned in %s is unknown to the driver", |
| 3485 | pszLine, pszFilename); |
| 3486 | } |
| 3487 | continue; |
| 3488 | } |
| 3489 | |
| 3490 | if (STARTS_WITHcxx . . $ `port/cpl_port.h:541:9`!(pszLine, "closed_ways_are_polygons=")) |
| 3491 | { |
| 3492 | char **papszTokens2 = CSLTokenizeString2( |
| 3493 | pszLine + strlen("closed_ways_are_polygons="), ",", 0); |
| 3494 | m_nMinSizeKeysInSetClosedWaysArePolygonscxx . . $ OGROSMDataSource#m_nMinSizeKeysInSetClosedWaysArePolygons. = INT_MAXcxx . . $ `<external>/2419331716647297546/limits.h:120:9`!; |
| 3495 | m_nMaxSizeKeysInSetClosedWaysArePolygonscxx . . $ OGROSMDataSource#m_nMaxSizeKeysInSetClosedWaysArePolygons. = 0; |
| 3496 | for (int i = 0; papszTokens2[i] != nullptr; i++) |
| 3497 | { |
| 3498 | const int nTokenSize = |
| 3499 | static_cast<int>(strlen(papszTokens2[i])); |
| 3500 | aoSetClosedWaysArePolygonscxx . . $ OGROSMDataSource#aoSetClosedWaysArePolygons..insertcxx . . $ std/unordered_set#insert(a28476a145336fa6).(papszTokens2[i]); |
| 3501 | m_nMinSizeKeysInSetClosedWaysArePolygonscxx . . $ OGROSMDataSource#m_nMinSizeKeysInSetClosedWaysArePolygons. = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).( |
| 3502 | m_nMinSizeKeysInSetClosedWaysArePolygonscxx . . $ OGROSMDataSource#m_nMinSizeKeysInSetClosedWaysArePolygons., nTokenSize); |
| 3503 | m_nMaxSizeKeysInSetClosedWaysArePolygonscxx . . $ OGROSMDataSource#m_nMaxSizeKeysInSetClosedWaysArePolygons. = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).( |
| 3504 | m_nMaxSizeKeysInSetClosedWaysArePolygonscxx . . $ OGROSMDataSource#m_nMaxSizeKeysInSetClosedWaysArePolygons., nTokenSize); |
| 3505 | } |
| 3506 | CSLDestroy(papszTokens2); |
| 3507 | } |
| 3508 | |
| 3509 | else if (STARTS_WITHcxx . . $ `port/cpl_port.h:541:9`!(pszLine, "report_all_tags=")) |
| 3510 | { |
| 3511 | if (strcmp(pszLine + strlen("report_all_tags="), "yes") == 0) |
| 3512 | { |
| 3513 | stdcxx . . $ std/::fillcxx . . $ std/fill(4a9bfaed88eccda7).(begin(m_ignoredKeyscxx . . $ OGROSMDataSource#m_ignoredKeys.), end(m_ignoredKeyscxx . . $ OGROSMDataSource#m_ignoredKeys.), ""); |
| 3514 | } |
| 3515 | } |
| 3516 | |
| 3517 | else if (STARTS_WITHcxx . . $ `port/cpl_port.h:541:9`!(pszLine, "report_all_nodes=")) |
| 3518 | { |
| 3519 | if (strcmp(pszLine + strlen("report_all_nodes="), "no") == 0) |
| 3520 | { |
| 3521 | m_bReportAllNodescxx . . $ OGROSMDataSource#m_bReportAllNodes. = false; |
| 3522 | } |
| 3523 | else if (strcmp(pszLine + strlen("report_all_nodes="), "yes") == 0) |
| 3524 | { |
| 3525 | m_bReportAllNodescxx . . $ OGROSMDataSource#m_bReportAllNodes. = true; |
| 3526 | } |
| 3527 | } |
| 3528 | |
| 3529 | else if (STARTS_WITHcxx . . $ `port/cpl_port.h:541:9`!(pszLine, "report_all_ways=")) |
| 3530 | { |
| 3531 | if (strcmp(pszLine + strlen("report_all_ways="), "no") == 0) |
| 3532 | { |
| 3533 | m_bReportAllWayscxx . . $ OGROSMDataSource#m_bReportAllWays. = false; |
| 3534 | } |
| 3535 | else if (strcmp(pszLine + strlen("report_all_ways="), "yes") == 0) |
| 3536 | { |
| 3537 | m_bReportAllWayscxx . . $ OGROSMDataSource#m_bReportAllWays. = true; |
| 3538 | } |
| 3539 | } |
| 3540 | |
| 3541 | else if (STARTS_WITHcxx . . $ `port/cpl_port.h:541:9`!(pszLine, "attribute_name_laundering=")) |
| 3542 | { |
| 3543 | if (strcmp(pszLine + strlen("attribute_name_laundering="), "no") == |
| 3544 | 0) |
| 3545 | { |
| 3546 | m_bAttributeNameLaunderingcxx . . $ OGROSMDataSource#m_bAttributeNameLaundering. = false; |
| 3547 | } |
| 3548 | else if (strcmp(pszLine + strlen("attribute_name_laundering="), |
| 3549 | "yes") == 0) |
| 3550 | { |
| 3551 | m_bAttributeNameLaunderingcxx . . $ OGROSMDataSource#m_bAttributeNameLaundering. = true; |
| 3552 | } |
| 3553 | } |
| 3554 | |
| 3555 | else if (STARTS_WITHcxx . . $ `port/cpl_port.h:541:9`!(pszLine, "tags_format=")) |
| 3556 | { |
| 3557 | if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszLine + strlen("tags_format="), "json")) |
| 3558 | { |
| 3559 | m_bTagsAsHSTOREcxx . . $ OGROSMDataSource#m_bTagsAsHSTORE. = false; |
| 3560 | } |
| 3561 | else if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszLine + strlen("tags_format="), "hstore")) |
| 3562 | { |
| 3563 | m_bTagsAsHSTOREcxx . . $ OGROSMDataSource#m_bTagsAsHSTORE. = true; |
| 3564 | } |
| 3565 | else |
| 3566 | { |
| 3567 | CPLError(CE_Warning, CPLE_NotSupportedcxx . . $ `port/cpl_error.h:118:9`!, |
| 3568 | "Unsupported value for tags_format: %s", |
| 3569 | pszLine + strlen("tags_format=")); |
| 3570 | } |
| 3571 | } |
| 3572 | |
| 3573 | else if (iCurLayer >= 0) |
| 3574 | { |
| 3575 | char **papszTokens = CSLTokenizeString2(pszLine, "=", 0); |
| 3576 | if (CSLCount(papszTokens) == 2 && |
| 3577 | strcmp(papszTokens[0], "other_tags") == 0) |
| 3578 | { |
| 3579 | if (strcmp(papszTokens[1], "no") == 0) |
| 3580 | m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers.[iCurLayer]->SetHasOtherTagscxx . . $ OGROSMLayer#SetHasOtherTags(b45ddcbc8423892c).(false); |
| 3581 | else if (strcmp(papszTokens[1], "yes") == 0) |
| 3582 | m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers.[iCurLayer]->SetHasOtherTagscxx . . $ OGROSMLayer#SetHasOtherTags(b45ddcbc8423892c).(true); |
| 3583 | } |
| 3584 | else if (CSLCount(papszTokens) == 2 && |
| 3585 | strcmp(papszTokens[0], "all_tags") == 0) |
| 3586 | { |
| 3587 | if (strcmp(papszTokens[1], "no") == 0) |
| 3588 | m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers.[iCurLayer]->SetHasAllTagscxx . . $ OGROSMLayer#SetHasAllTags(b45ddcbc8423892c).(false); |
| 3589 | else if (strcmp(papszTokens[1], "yes") == 0) |
| 3590 | m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers.[iCurLayer]->SetHasAllTagscxx . . $ OGROSMLayer#SetHasAllTags(b45ddcbc8423892c).(true); |
| 3591 | } |
| 3592 | else if (CSLCount(papszTokens) == 2 && |
| 3593 | strcmp(papszTokens[0], "osm_id") == 0) |
| 3594 | { |
| 3595 | if (strcmp(papszTokens[1], "no") == 0) |
| 3596 | m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers.[iCurLayer]->SetHasOSMIdcxx . . $ OGROSMLayer#SetHasOSMId(b45ddcbc8423892c).(false); |
| 3597 | else if (strcmp(papszTokens[1], "yes") == 0) |
| 3598 | { |
| 3599 | m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers.[iCurLayer]->SetHasOSMIdcxx . . $ OGROSMLayer#SetHasOSMId(b45ddcbc8423892c).(true); |
| 3600 | m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers.[iCurLayer]->AddFieldcxx . . $ OGROSMLayer#AddField(121fc23317a1c8d0).("osm_id", OFTString); |
| 3601 | |
| 3602 | if (iCurLayer == IDX_LYR_MULTIPOLYGONScxx . . $ IDX_LYR_MULTIPOLYGONS.) |
| 3603 | m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers.[iCurLayer]->AddFieldcxx . . $ OGROSMLayer#AddField(121fc23317a1c8d0).("osm_way_id", |
| 3604 | OFTString); |
| 3605 | } |
| 3606 | } |
| 3607 | else if (CSLCount(papszTokens) == 2 && |
| 3608 | strcmp(papszTokens[0], "osm_version") == 0) |
| 3609 | { |
| 3610 | if (strcmp(papszTokens[1], "no") == 0) |
| 3611 | m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers.[iCurLayer]->SetHasVersioncxx . . $ OGROSMLayer#SetHasVersion(b45ddcbc8423892c).(false); |
| 3612 | else if (strcmp(papszTokens[1], "yes") == 0) |
| 3613 | { |
| 3614 | m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers.[iCurLayer]->SetHasVersioncxx . . $ OGROSMLayer#SetHasVersion(b45ddcbc8423892c).(true); |
| 3615 | m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers.[iCurLayer]->AddFieldcxx . . $ OGROSMLayer#AddField(121fc23317a1c8d0).("osm_version", OFTInteger); |
| 3616 | } |
| 3617 | } |
| 3618 | else if (CSLCount(papszTokens) == 2 && |
| 3619 | strcmp(papszTokens[0], "osm_timestamp") == 0) |
| 3620 | { |
| 3621 | if (strcmp(papszTokens[1], "no") == 0) |
| 3622 | m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers.[iCurLayer]->SetHasTimestampcxx . . $ OGROSMLayer#SetHasTimestamp(b45ddcbc8423892c).(false); |
| 3623 | else if (strcmp(papszTokens[1], "yes") == 0) |
| 3624 | { |
| 3625 | m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers.[iCurLayer]->SetHasTimestampcxx . . $ OGROSMLayer#SetHasTimestamp(b45ddcbc8423892c).(true); |
| 3626 | m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers.[iCurLayer]->AddFieldcxx . . $ OGROSMLayer#AddField(121fc23317a1c8d0).("osm_timestamp", |
| 3627 | OFTDateTime); |
| 3628 | } |
| 3629 | } |
| 3630 | else if (CSLCount(papszTokens) == 2 && |
| 3631 | strcmp(papszTokens[0], "osm_uid") == 0) |
| 3632 | { |
| 3633 | if (strcmp(papszTokens[1], "no") == 0) |
| 3634 | m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers.[iCurLayer]->SetHasUIDcxx . . $ OGROSMLayer#SetHasUID(b45ddcbc8423892c).(false); |
| 3635 | else if (strcmp(papszTokens[1], "yes") == 0) |
| 3636 | { |
| 3637 | m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers.[iCurLayer]->SetHasUIDcxx . . $ OGROSMLayer#SetHasUID(b45ddcbc8423892c).(true); |
| 3638 | m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers.[iCurLayer]->AddFieldcxx . . $ OGROSMLayer#AddField(121fc23317a1c8d0).("osm_uid", OFTInteger); |
| 3639 | } |
| 3640 | } |
| 3641 | else if (CSLCount(papszTokens) == 2 && |
| 3642 | strcmp(papszTokens[0], "osm_user") == 0) |
| 3643 | { |
| 3644 | if (strcmp(papszTokens[1], "no") == 0) |
| 3645 | m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers.[iCurLayer]->SetHasUsercxx . . $ OGROSMLayer#SetHasUser(b45ddcbc8423892c).(false); |
| 3646 | else if (strcmp(papszTokens[1], "yes") == 0) |
| 3647 | { |
| 3648 | m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers.[iCurLayer]->SetHasUsercxx . . $ OGROSMLayer#SetHasUser(b45ddcbc8423892c).(true); |
| 3649 | m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers.[iCurLayer]->AddFieldcxx . . $ OGROSMLayer#AddField(121fc23317a1c8d0).("osm_user", OFTString); |
| 3650 | } |
| 3651 | } |
| 3652 | else if (CSLCount(papszTokens) == 2 && |
| 3653 | strcmp(papszTokens[0], "osm_changeset") == 0) |
| 3654 | { |
| 3655 | if (strcmp(papszTokens[1], "no") == 0) |
| 3656 | m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers.[iCurLayer]->SetHasChangesetcxx . . $ OGROSMLayer#SetHasChangeset(b45ddcbc8423892c).(false); |
| 3657 | else if (strcmp(papszTokens[1], "yes") == 0) |
| 3658 | { |
| 3659 | m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers.[iCurLayer]->SetHasChangesetcxx . . $ OGROSMLayer#SetHasChangeset(b45ddcbc8423892c).(true); |
| 3660 | m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers.[iCurLayer]->AddFieldcxx . . $ OGROSMLayer#AddField(121fc23317a1c8d0).("osm_changeset", |
| 3661 | OFTInteger); |
| 3662 | } |
| 3663 | } |
| 3664 | else if (CSLCount(papszTokens) == 2 && |
| 3665 | strcmp(papszTokens[0], "attributes") == 0) |
| 3666 | { |
| 3667 | char **papszTokens2 = |
| 3668 | CSLTokenizeString2(papszTokens[1], ",", 0); |
| 3669 | for (int i = 0; papszTokens2[i] != nullptr; i++) |
| 3670 | { |
| 3671 | m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers.[iCurLayer]->AddFieldcxx . . $ OGROSMLayer#AddField(121fc23317a1c8d0).(papszTokens2[i], |
| 3672 | OFTString); |
| 3673 | for (const char *&pszIgnoredKey : m_ignoredKeyscxx . . $ OGROSMDataSource#m_ignoredKeys.) |
| 3674 | { |
| 3675 | if (strcmp(papszTokens2[i], pszIgnoredKey) == 0) |
| 3676 | pszIgnoredKey = ""; |
| 3677 | } |
| 3678 | } |
| 3679 | CSLDestroy(papszTokens2); |
| 3680 | } |
| 3681 | else if (CSLCount(papszTokens) == 2 && |
| 3682 | (strcmp(papszTokens[0], "unsignificant") == 0 || |
| 3683 | strcmp(papszTokens[0], "insignificant") == 0)) |
| 3684 | { |
| 3685 | char **papszTokens2 = |
| 3686 | CSLTokenizeString2(papszTokens[1], ",", 0); |
| 3687 | for (int i = 0; papszTokens2[i] != nullptr; i++) |
| 3688 | { |
| 3689 | m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers.[iCurLayer]->AddInsignificantKeycxx . . $ OGROSMLayer#AddInsignificantKey(85c52e162fed56f9).( |
| 3690 | papszTokens2[i]); |
| 3691 | } |
| 3692 | CSLDestroy(papszTokens2); |
| 3693 | } |
| 3694 | else if (CSLCount(papszTokens) == 2 && |
| 3695 | strcmp(papszTokens[0], "ignore") == 0) |
| 3696 | { |
| 3697 | char **papszTokens2 = |
| 3698 | CSLTokenizeString2(papszTokens[1], ",", 0); |
| 3699 | for (int i = 0; papszTokens2[i] != nullptr; i++) |
| 3700 | { |
| 3701 | m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers.[iCurLayer]->AddIgnoreKeycxx . . $ OGROSMLayer#AddIgnoreKey(85c52e162fed56f9).(papszTokens2[i]); |
| 3702 | m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers.[iCurLayer]->AddWarnKeycxx . . $ OGROSMLayer#AddWarnKey(85c52e162fed56f9).(papszTokens2[i]); |
| 3703 | } |
| 3704 | CSLDestroy(papszTokens2); |
| 3705 | } |
| 3706 | else if (CSLCount(papszTokens) == 2 && |
| 3707 | strcmp(papszTokens[0], "computed_attributes") == 0) |
| 3708 | { |
| 3709 | char **papszTokens2 = |
| 3710 | CSLTokenizeString2(papszTokens[1], ",", 0); |
| 3711 | oAttributes.resize(0); |
| 3712 | for (int i = 0; papszTokens2[i] != nullptr; i++) |
| 3713 | { |
| 3714 | oAttributes.push_back( |
| 3715 | OGROSMComputedAttributecxx . . $ OGROSMComputedAttribute#(papszTokens2[i])); |
| 3716 | } |
| 3717 | CSLDestroy(papszTokens2); |
| 3718 | } |
| 3719 | else if (CSLCount(papszTokens) == 2 && |
| 3720 | strlen(papszTokens[0]) >= 5 && |
| 3721 | strcmp(papszTokens[0] + strlen(papszTokens[0]) - 5, |
| 3722 | "_type") == 0) |
| 3723 | { |
| 3724 | CPLString osName(papszTokens[0]); |
| 3725 | osName.resize(strlen(papszTokens[0]) - 5); |
| 3726 | const char *pszType = papszTokens[1]; |
| 3727 | bool bFound = false; |
| 3728 | OGRFieldType eType = OFTString; |
| 3729 | if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszType, "Integer")) |
| 3730 | eType = OFTInteger; |
| 3731 | else if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszType, "Integer64")) |
| 3732 | eType = OFTInteger64; |
| 3733 | else if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszType, "Real")) |
| 3734 | eType = OFTReal; |
| 3735 | else if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszType, "String")) |
| 3736 | eType = OFTString; |
| 3737 | else if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszType, "DateTime")) |
| 3738 | eType = OFTDateTime; |
| 3739 | else |
| 3740 | CPLError(CE_Warning, CPLE_AppDefinedcxx . . $ `port/cpl_error.h:108:9`!, |
| 3741 | "Unhandled type (%s) for attribute %s", pszType, |
| 3742 | osName.c_str()); |
| 3743 | for (size_t i = 0; i < oAttributes.size(); i++) |
| 3744 | { |
| 3745 | if (oAttributes[i].osNamecxx . . $ OGROSMComputedAttribute#osName. == osName) |
| 3746 | { |
| 3747 | bFound = true; |
| 3748 | oAttributes[i].eTypecxx . . $ OGROSMComputedAttribute#eType. = eType; |
| 3749 | break; |
| 3750 | } |
| 3751 | } |
| 3752 | if (!bFound) |
| 3753 | { |
| 3754 | const int idx = |
| 3755 | m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers.[iCurLayer]->GetLayerDefncxx . . $ OGRLayer#GetLayerDefn(407fccde18759965).()->GetFieldIndexcxx . . $ OGRFeatureDefn#GetFieldIndex(78f035161ffa9fe2).( |
| 3756 | osName); |
| 3757 | if (idx >= 0) |
| 3758 | { |
| 3759 | m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers.[iCurLayer] |
| 3760 | ->GetLayerDefncxx . . $ OGRLayer#GetLayerDefn(407fccde18759965).() |
| 3761 | ->GetFieldDefncxx . . $ OGRFeatureDefn#GetFieldDefn(2ec36f91b6ceefc7).(idx) |
| 3762 | ->SetTypecxx . . $ OGRFieldDefn#SetType(cc683e085121359d).(eType); |
| 3763 | bFound = true; |
| 3764 | } |
| 3765 | } |
| 3766 | if (!bFound) |
| 3767 | { |
| 3768 | CPLError(CE_Warning, CPLE_AppDefinedcxx . . $ `port/cpl_error.h:108:9`!, |
| 3769 | "Undeclared attribute : %s", osName.c_str()); |
| 3770 | } |
| 3771 | } |
| 3772 | else if (CSLCount(papszTokens) >= 2 && |
| 3773 | strlen(papszTokens[0]) >= 4 && |
| 3774 | strcmp(papszTokens[0] + strlen(papszTokens[0]) - 4, |
| 3775 | "_sql") == 0) |
| 3776 | { |
| 3777 | CPLString osName(papszTokens[0]); |
| 3778 | osName.resize(strlen(papszTokens[0]) - 4); |
| 3779 | size_t i = 0; // Used after for. |
| 3780 | for (; i < oAttributes.size(); i++) |
| 3781 | { |
| 3782 | if (oAttributes[i].osNamecxx . . $ OGROSMComputedAttribute#osName. == osName) |
| 3783 | { |
| 3784 | const char *pszSQL = strchr(pszLine, '=') + 1; |
| 3785 | while (*pszSQL == ' ') |
| 3786 | pszSQL++; |
| 3787 | bool bInQuotes = false; |
| 3788 | if (*pszSQL == '"') |
| 3789 | { |
| 3790 | bInQuotes = true; |
| 3791 | pszSQL++; |
| 3792 | } |
| 3793 | oAttributes[i].osSQLcxx . . $ OGROSMComputedAttribute#osSQL. = pszSQL; |
| 3794 | if (bInQuotes && oAttributes[i].osSQLcxx . . $ OGROSMComputedAttribute#osSQL..size() > 1 && |
| 3795 | oAttributes[i].osSQLcxx . . $ OGROSMComputedAttribute#osSQL..back() == '"') |
| 3796 | oAttributes[i].osSQLcxx . . $ OGROSMComputedAttribute#osSQL..resize( |
| 3797 | oAttributes[i].osSQLcxx . . $ OGROSMComputedAttribute#osSQL..size() - 1); |
| 3798 | break; |
| 3799 | } |
| 3800 | } |
| 3801 | if (i == oAttributes.size()) |
| 3802 | { |
| 3803 | CPLError(CE_Warning, CPLE_AppDefinedcxx . . $ `port/cpl_error.h:108:9`!, |
| 3804 | "Undeclared attribute : %s", osName.c_str()); |
| 3805 | } |
| 3806 | } |
| 3807 | CSLDestroy(papszTokens); |
| 3808 | } |
| 3809 | } |
| 3810 | |
| 3811 | if (iCurLayer >= 0) |
| 3812 | AddComputedAttributescxx . . $ OGROSMDataSource#AddComputedAttributes(d2ee151f8be59f9e).(iCurLayer, oAttributes); |
| 3813 | |
| 3814 | VSIFCloseL(fpConf); |
| 3815 | |
| 3816 | return true; |
| 3817 | } |
| 3818 | |
| 3819 | /************************************************************************/ |
| 3820 | /* MyResetReading() */ |
| 3821 | /************************************************************************/ |
| 3822 | |
| 3823 | int OGROSMDataSourcecxx . . $ OGROSMDataSource#::MyResetReadingcxx . . $ OGROSMDataSource#MyResetReading(b126dc7c1de90089).() |
| 3824 | { |
| 3825 | if (m_hDBcxx . . $ OGROSMDataSource#m_hDB. == nullptr) |
| 3826 | return FALSEcxx . . $ `port/cpl_port.h:1180:9`!; |
| 3827 | if (m_bCustomIndexingcxx . . $ OGROSMDataSource#m_bCustomIndexing. && m_fpNodescxx . . $ OGROSMDataSource#m_fpNodes. == nullptr) |
| 3828 | return FALSEcxx . . $ `port/cpl_port.h:1180:9`!; |
| 3829 | |
| 3830 | OSM_ResetReading(m_psParsercxx . . $ OGROSMDataSource#m_psParser.); |
| 3831 | |
| 3832 | char *pszErrMsg = nullptr; |
| 3833 | int rc = |
| 3834 | sqlite3_exec(m_hDBcxx . . $ OGROSMDataSource#m_hDB., "DELETE FROM nodes", nullptr, nullptr, &pszErrMsg); |
| 3835 | if (rc != SQLITE_OKcxx . . $ `<external>/2400532043262193228/sqlite3.h:449:9`!) |
| 3836 | { |
| 3837 | CPLError(CE_Failure, CPLE_AppDefinedcxx . . $ `port/cpl_error.h:108:9`!, |
| 3838 | "Unable to DELETE FROM nodes : %s", pszErrMsg); |
| 3839 | sqlite3_free(pszErrMsg); |
| 3840 | return FALSEcxx . . $ `port/cpl_port.h:1180:9`!; |
| 3841 | } |
| 3842 | |
| 3843 | rc = sqlite3_exec(m_hDBcxx . . $ OGROSMDataSource#m_hDB., "DELETE FROM ways", nullptr, nullptr, &pszErrMsg); |
| 3844 | if (rc != SQLITE_OKcxx . . $ `<external>/2400532043262193228/sqlite3.h:449:9`!) |
| 3845 | { |
| 3846 | CPLError(CE_Failure, CPLE_AppDefinedcxx . . $ `port/cpl_error.h:108:9`!, "Unable to DELETE FROM ways : %s", |
| 3847 | pszErrMsg); |
| 3848 | sqlite3_free(pszErrMsg); |
| 3849 | return FALSEcxx . . $ `port/cpl_port.h:1180:9`!; |
| 3850 | } |
| 3851 | |
| 3852 | rc = sqlite3_exec(m_hDBcxx . . $ OGROSMDataSource#m_hDB., "DELETE FROM polygons_standalone", nullptr, |
| 3853 | nullptr, &pszErrMsg); |
| 3854 | if (rc != SQLITE_OKcxx . . $ `<external>/2400532043262193228/sqlite3.h:449:9`!) |
| 3855 | { |
| 3856 | CPLError(CE_Failure, CPLE_AppDefinedcxx . . $ `port/cpl_error.h:108:9`!, |
| 3857 | "Unable to DELETE FROM polygons_standalone : %s", pszErrMsg); |
| 3858 | sqlite3_free(pszErrMsg); |
| 3859 | return FALSEcxx . . $ `port/cpl_port.h:1180:9`!; |
| 3860 | } |
| 3861 | m_bHasRowInPolygonsStandalonecxx . . $ OGROSMDataSource#m_bHasRowInPolygonsStandalone. = false; |
| 3862 | |
| 3863 | if (m_hSelectPolygonsStandaloneStmtcxx . . $ OGROSMDataSource#m_hSelectPolygonsStandaloneStmt. != nullptr) |
| 3864 | sqlite3_reset(m_hSelectPolygonsStandaloneStmtcxx . . $ OGROSMDataSource#m_hSelectPolygonsStandaloneStmt.); |
| 3865 | |
| 3866 | { |
| 3867 | m_asWayFeaturePairscxx . . $ OGROSMDataSource#m_asWayFeaturePairs..clear(); |
| 3868 | m_nUnsortedReqIdscxx . . $ OGROSMDataSource#m_nUnsortedReqIds. = 0; |
| 3869 | m_nReqIdscxx . . $ OGROSMDataSource#m_nReqIds. = 0; |
| 3870 | m_nAccumulatedTagscxx . . $ OGROSMDataSource#m_nAccumulatedTags. = 0; |
| 3871 | nNonRedundantKeysLencxx . . $ OGROSMDataSource#nNonRedundantKeysLen. = 0; |
| 3872 | nNonRedundantValuesLencxx . . $ OGROSMDataSource#nNonRedundantValuesLen. = 0; |
| 3873 | |
| 3874 | for (KeyDesccxx . . $ KeyDesc# *psKD : m_apsKeyscxx . . $ OGROSMDataSource#m_apsKeys.) |
| 3875 | { |
| 3876 | if (psKD) |
| 3877 | { |
| 3878 | CPLFreecxx . . $ `port/cpl_conv.h:97:9`!(psKD->pszKcxx . . $ KeyDesc#pszK.); |
| 3879 | for (auto *pszValue : psKD->apszValuescxx . . $ KeyDesc#apszValues.) |
| 3880 | CPLFreecxx . . $ `port/cpl_conv.h:97:9`!(pszValue); |
| 3881 | delete psKD; |
| 3882 | } |
| 3883 | } |
| 3884 | m_apsKeyscxx . . $ OGROSMDataSource#m_apsKeys..resize(1); // keep guard to avoid index 0 to be used |
| 3885 | m_aoMapIndexedKeyscxx . . $ OGROSMDataSource#m_aoMapIndexedKeys..clearcxx . . $ std/map#clear(ced63f7c635d850d).(); |
| 3886 | } |
| 3887 | |
| 3888 | if (m_bCustomIndexingcxx . . $ OGROSMDataSource#m_bCustomIndexing.) |
| 3889 | { |
| 3890 | m_nPrevNodeIdcxx . . $ OGROSMDataSource#m_nPrevNodeId. = -1; |
| 3891 | m_nBucketOldcxx . . $ OGROSMDataSource#m_nBucketOld. = -1; |
| 3892 | m_nOffInBucketReducedOldcxx . . $ OGROSMDataSource#m_nOffInBucketReducedOld. = -1; |
| 3893 | |
| 3894 | VSIFSeekLcxx . . $ VSIFSeekL(7b147a47904bd6c7).(m_fpNodescxx . . $ OGROSMDataSource#m_fpNodes., 0, SEEK_SETcxx . . $ `<external>/232824719582829767/stdio.h:114:9`!); |
| 3895 | VSIFTruncateL(m_fpNodescxx . . $ OGROSMDataSource#m_fpNodes., 0); |
| 3896 | m_nNodesFileSizecxx . . $ OGROSMDataSource#m_nNodesFileSize. = 0; |
| 3897 | |
| 3898 | memset(m_pabySectorcxx . . $ OGROSMDataSource#m_pabySector., 0, SECTOR_SIZEcxx . . $ SECTOR_SIZE.); |
| 3899 | |
| 3900 | for (auto &oIter : m_oMapBucketscxx . . $ OGROSMDataSource#m_oMapBuckets.) |
| 3901 | { |
| 3902 | Bucketcxx . . $ Bucket# &sBucket = oIter.second; |
| 3903 | sBucket.nOffcxx . . $ $anonymous_type_52aecf065e0c3ab0_3#nOff. = -1; |
| 3904 | if (m_bCompressNodescxx . . $ OGROSMDataSource#m_bCompressNodes.) |
| 3905 | { |
| 3906 | if (sBucket.ucxx . . $ $anonymous_type_52aecf065e0c3ab0_3#u..panSectorSizecxx . . $ $anonymous_type_52aecf065e0c3ab0_3#$anonymous_type_4#panSectorSize.) |
| 3907 | memset(sBucket.ucxx . . $ $anonymous_type_52aecf065e0c3ab0_3#u..panSectorSizecxx . . $ $anonymous_type_52aecf065e0c3ab0_3#$anonymous_type_4#panSectorSize., 0, |
| 3908 | BUCKET_SECTOR_SIZE_ARRAY_SIZEcxx . . $ BUCKET_SECTOR_SIZE_ARRAY_SIZE.); |
| 3909 | } |
| 3910 | else |
| 3911 | { |
| 3912 | if (sBucket.ucxx . . $ $anonymous_type_52aecf065e0c3ab0_3#u..pabyBitmapcxx . . $ $anonymous_type_52aecf065e0c3ab0_3#$anonymous_type_4#pabyBitmap.) |
| 3913 | memset(sBucket.ucxx . . $ $anonymous_type_52aecf065e0c3ab0_3#u..pabyBitmapcxx . . $ $anonymous_type_52aecf065e0c3ab0_3#$anonymous_type_4#pabyBitmap., 0, BUCKET_BITMAP_SIZEcxx . . $ BUCKET_BITMAP_SIZE.); |
| 3914 | } |
| 3915 | } |
| 3916 | } |
| 3917 | |
| 3918 | for (auto &&poLayer : m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers.) |
| 3919 | { |
| 3920 | poLayer->ForceResetReadingcxx . . $ OGROSMLayer#ForceResetReading(49f6e7a06ebc5aa8).(); |
| 3921 | } |
| 3922 | |
| 3923 | m_bStopParsingcxx . . $ OGROSMDataSource#m_bStopParsing. = false; |
| 3924 | m_poCurrentLayercxx . . $ OGROSMDataSource#m_poCurrentLayer. = nullptr; |
| 3925 | |
| 3926 | return TRUEcxx . . $ `port/cpl_port.h:1184:9`!; |
| 3927 | } |
| 3928 | |
| 3929 | /************************************************************************/ |
| 3930 | /* ResetReading() */ |
| 3931 | /************************************************************************/ |
| 3932 | |
| 3933 | void OGROSMDataSourcecxx . . $ OGROSMDataSource#::ResetReadingcxx . . $ OGROSMDataSource#ResetReading(49f6e7a06ebc5aa8).() |
| 3934 | { |
| 3935 | MyResetReadingcxx . . $ OGROSMDataSource#MyResetReading(b126dc7c1de90089).(); |
| 3936 | } |
| 3937 | |
| 3938 | /************************************************************************/ |
| 3939 | /* GetNextFeature() */ |
| 3940 | /************************************************************************/ |
| 3941 | |
| 3942 | OGRFeaturecxx . . $ OGRFeature# *OGROSMDataSourcecxx . . $ OGROSMDataSource#::GetNextFeaturecxx . . $ OGROSMDataSource#GetNextFeature(dc40b355e34ec6ef).(OGRLayercxx . . $ OGRLayer# **ppoBelongingLayer, |
| 3943 | double *pdfProgressPct, |
| 3944 | GDALProgressFunc pfnProgress, |
| 3945 | void *pProgressData) |
| 3946 | { |
| 3947 | m_bInterleavedReadingcxx . . $ OGROSMDataSource#m_bInterleavedReading. = TRUEcxx . . $ `port/cpl_port.h:1184:9`!; |
| 3948 | |
| 3949 | if (m_poCurrentLayercxx . . $ OGROSMDataSource#m_poCurrentLayer. == nullptr) |
| 3950 | { |
| 3951 | m_poCurrentLayercxx . . $ OGROSMDataSource#m_poCurrentLayer. = m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers.[0].get(); |
| 3952 | } |
| 3953 | if (pdfProgressPct != nullptr || pfnProgress != nullptr) |
| 3954 | { |
| 3955 | if (m_nFileSizecxx . . $ OGROSMDataSource#m_nFileSize. == FILESIZE_NOT_INITcxx . . $ OGROSMDataSource#FILESIZE_NOT_INIT.) |
| 3956 | { |
| 3957 | VSIStatBufL sStat; |
| 3958 | if (VSIStatL(GetDescriptioncxx . . $ GDALMajorObject#GetDescription(a9f41ea0e82d88cf).(), &sStat) == 0) |
| 3959 | { |
| 3960 | m_nFileSizecxx . . $ OGROSMDataSource#m_nFileSize. = static_cast<GIntBigcxx . . $ GIntBig#>(sStat.st_size); |
| 3961 | } |
| 3962 | else |
| 3963 | { |
| 3964 | m_nFileSizecxx . . $ OGROSMDataSource#m_nFileSize. = FILESIZE_INVALIDcxx . . $ OGROSMDataSource#FILESIZE_INVALID.; |
| 3965 | } |
| 3966 | } |
| 3967 | } |
| 3968 | |
| 3969 | while (true) |
| 3970 | { |
| 3971 | OGROSMLayercxx . . $ OGROSMLayer# *poNewCurLayer = nullptr; |
| 3972 | CPLAssertcxx . . $ `port/cpl_error.h:353:9`!(m_poCurrentLayer != nullptr); |
| 3973 | OGRFeaturecxx . . $ OGRFeature# *poFeature = m_poCurrentLayercxx . . $ OGROSMDataSource#m_poCurrentLayer.->MyGetNextFeaturecxx . . $ OGROSMLayer#MyGetNextFeature(a0a808bafa949dc2).( |
| 3974 | &poNewCurLayer, pfnProgress, pProgressData); |
| 3975 | m_poCurrentLayercxx . . $ OGROSMDataSource#m_poCurrentLayer. = poNewCurLayer; |
| 3976 | if (poFeature == nullptr) |
| 3977 | { |
| 3978 | if (m_poCurrentLayercxx . . $ OGROSMDataSource#m_poCurrentLayer. != nullptr) |
| 3979 | continue; |
| 3980 | if (ppoBelongingLayer != nullptr) |
| 3981 | *ppoBelongingLayer = nullptr; |
| 3982 | if (pdfProgressPct != nullptr) |
| 3983 | *pdfProgressPct = 1.0; |
| 3984 | return nullptr; |
| 3985 | } |
| 3986 | if (ppoBelongingLayer != nullptr) |
| 3987 | *ppoBelongingLayer = m_poCurrentLayercxx . . $ OGROSMDataSource#m_poCurrentLayer.; |
| 3988 | if (pdfProgressPct != nullptr) |
| 3989 | { |
| 3990 | if (m_nFileSizecxx . . $ OGROSMDataSource#m_nFileSize. != FILESIZE_INVALIDcxx . . $ OGROSMDataSource#FILESIZE_INVALID.) |
| 3991 | { |
| 3992 | *pdfProgressPct = |
| 3993 | 1.0 * OSM_GetBytesRead(m_psParsercxx . . $ OGROSMDataSource#m_psParser.) / m_nFileSizecxx . . $ OGROSMDataSource#m_nFileSize.; |
| 3994 | } |
| 3995 | else |
| 3996 | { |
| 3997 | *pdfProgressPct = -1.0; |
| 3998 | } |
| 3999 | } |
| 4000 | |
| 4001 | return poFeature; |
| 4002 | } |
| 4003 | } |
| 4004 | |
| 4005 | /************************************************************************/ |
| 4006 | /* ParseNextChunk() */ |
| 4007 | /************************************************************************/ |
| 4008 | |
| 4009 | bool OGROSMDataSourcecxx . . $ OGROSMDataSource#::ParseNextChunkcxx . . $ OGROSMDataSource#ParseNextChunk(acf787f211ac5ef5).(int nIdxLayer, |
| 4010 | GDALProgressFunc pfnProgress, |
| 4011 | void *pProgressData) |
| 4012 | { |
| 4013 | if (m_bStopParsingcxx . . $ OGROSMDataSource#m_bStopParsing.) |
| 4014 | return false; |
| 4015 | |
| 4016 | m_bHasParsedFirstChunkcxx . . $ OGROSMDataSource#m_bHasParsedFirstChunk. = true; |
| 4017 | m_bFeatureAddedcxx . . $ OGROSMDataSource#m_bFeatureAdded. = false; |
| 4018 | while (true) |
| 4019 | { |
| 4020 | #ifdef DEBUG_MEM_USAGE |
| 4021 | static int counter = 0; |
| 4022 | counter++; |
| 4023 | if ((counter % 1000) == 0) |
| 4024 | CPLDebug("OSM", "GetMaxTotalAllocs() = " CPL_FRMT_GUIB, |
| 4025 | static_cast<GUIntBig>(GetMaxTotalAllocs())); |
| 4026 | #endif |
| 4027 | |
| 4028 | OSMRetCode eRet = OSM_ProcessBlock(m_psParsercxx . . $ OGROSMDataSource#m_psParser.); |
| 4029 | if (pfnProgress != nullptr) |
| 4030 | { |
| 4031 | double dfPct = -1.0; |
| 4032 | if (m_nFileSizecxx . . $ OGROSMDataSource#m_nFileSize. != FILESIZE_INVALIDcxx . . $ OGROSMDataSource#FILESIZE_INVALID.) |
| 4033 | { |
| 4034 | dfPct = 1.0 * OSM_GetBytesRead(m_psParsercxx . . $ OGROSMDataSource#m_psParser.) / m_nFileSizecxx . . $ OGROSMDataSource#m_nFileSize.; |
| 4035 | } |
| 4036 | if (!pfnProgress(dfPct, "", pProgressData)) |
| 4037 | { |
| 4038 | m_bStopParsingcxx . . $ OGROSMDataSource#m_bStopParsing. = true; |
| 4039 | for (auto &&poLayer : m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers.) |
| 4040 | { |
| 4041 | poLayer->ForceResetReadingcxx . . $ OGROSMLayer#ForceResetReading(49f6e7a06ebc5aa8).(); |
| 4042 | } |
| 4043 | return false; |
| 4044 | } |
| 4045 | } |
| 4046 | |
| 4047 | if (eRet == OSM_EOF || eRet == OSM_ERROR) |
| 4048 | { |
| 4049 | if (eRet == OSM_EOF) |
| 4050 | { |
| 4051 | if (!m_asWayFeaturePairscxx . . $ OGROSMDataSource#m_asWayFeaturePairs..empty()) |
| 4052 | ProcessWaysBatchcxx . . $ OGROSMDataSource#ProcessWaysBatch(49f6e7a06ebc5aa8).(); |
| 4053 | |
| 4054 | ProcessPolygonsStandalonecxx . . $ OGROSMDataSource#ProcessPolygonsStandalone(49f6e7a06ebc5aa8).(); |
| 4055 | |
| 4056 | if (!m_bHasRowInPolygonsStandalonecxx . . $ OGROSMDataSource#m_bHasRowInPolygonsStandalone.) |
| 4057 | m_bStopParsingcxx . . $ OGROSMDataSource#m_bStopParsing. = true; |
| 4058 | |
| 4059 | if (!m_bInterleavedReadingcxx . . $ OGROSMDataSource#m_bInterleavedReading. && !m_bFeatureAddedcxx . . $ OGROSMDataSource#m_bFeatureAdded. && |
| 4060 | m_bHasRowInPolygonsStandalonecxx . . $ OGROSMDataSource#m_bHasRowInPolygonsStandalone. && |
| 4061 | nIdxLayer != IDX_LYR_MULTIPOLYGONScxx . . $ IDX_LYR_MULTIPOLYGONS.) |
| 4062 | { |
| 4063 | return false; |
| 4064 | } |
| 4065 | |
| 4066 | return m_bFeatureAddedcxx . . $ OGROSMDataSource#m_bFeatureAdded. || m_bHasRowInPolygonsStandalonecxx . . $ OGROSMDataSource#m_bHasRowInPolygonsStandalone.; |
| 4067 | } |
| 4068 | else |
| 4069 | { |
| 4070 | CPLError(CE_Failure, CPLE_AppDefinedcxx . . $ `port/cpl_error.h:108:9`!, |
| 4071 | "An error occurred during the parsing of data " |
| 4072 | "around byte " CPL_FRMT_GUIBcxx . . $ `port/cpl_port.h:259:9`!, |
| 4073 | OSM_GetBytesRead(m_psParsercxx . . $ OGROSMDataSource#m_psParser.)); |
| 4074 | |
| 4075 | m_bStopParsingcxx . . $ OGROSMDataSource#m_bStopParsing. = true; |
| 4076 | return false; |
| 4077 | } |
| 4078 | } |
| 4079 | else |
| 4080 | { |
| 4081 | if (m_bInMemoryTmpDBcxx . . $ OGROSMDataSource#m_bInMemoryTmpDB.) |
| 4082 | { |
| 4083 | if (!TransferToDiskIfNecesserarycxx . . $ OGROSMDataSource#TransferToDiskIfNecesserary(c9857a73d68e59ba).()) |
| 4084 | return false; |
| 4085 | } |
| 4086 | |
| 4087 | if (m_bFeatureAddedcxx . . $ OGROSMDataSource#m_bFeatureAdded.) |
| 4088 | break; |
| 4089 | } |
| 4090 | } |
| 4091 | |
| 4092 | return true; |
| 4093 | } |
| 4094 | |
| 4095 | /************************************************************************/ |
| 4096 | /* TransferToDiskIfNecesserary() */ |
| 4097 | /************************************************************************/ |
| 4098 | |
| 4099 | bool OGROSMDataSourcecxx . . $ OGROSMDataSource#::TransferToDiskIfNecesserarycxx . . $ OGROSMDataSource#TransferToDiskIfNecesserary(c9857a73d68e59ba).() |
| 4100 | { |
| 4101 | if (m_bInMemoryNodesFilecxx . . $ OGROSMDataSource#m_bInMemoryNodesFile.) |
| 4102 | { |
| 4103 | if (m_nNodesFileSizecxx . . $ OGROSMDataSource#m_nNodesFileSize. / 1024 / 1024 > |
| 4104 | 3 * m_nMaxSizeForInMemoryDBInMBcxx . . $ OGROSMDataSource#m_nMaxSizeForInMemoryDBInMB. / 4) |
| 4105 | { |
| 4106 | m_bInMemoryNodesFilecxx . . $ OGROSMDataSource#m_bInMemoryNodesFile. = false; |
| 4107 | |
| 4108 | VSIFCloseL(m_fpNodescxx . . $ OGROSMDataSource#m_fpNodes.); |
| 4109 | m_fpNodescxx . . $ OGROSMDataSource#m_fpNodes. = nullptr; |
| 4110 | |
| 4111 | const stdcxx . . $ std/::string osNewTmpDBName( |
| 4112 | CPLGenerateTempFilenameSafe("osm_tmp_nodes")); |
| 4113 | |
| 4114 | CPLDebug("OSM", |
| 4115 | "%s too big for RAM. Transferring it onto disk in %s", |
| 4116 | m_osNodesFilenamecxx . . $ OGROSMDataSource#m_osNodesFilename..c_str(), osNewTmpDBName.c_str()); |
| 4117 | |
| 4118 | if (CPLCopyFile(osNewTmpDBName.c_str(), m_osNodesFilenamecxx . . $ OGROSMDataSource#m_osNodesFilename.) != 0) |
| 4119 | { |
| 4120 | CPLError(CE_Failure, CPLE_AppDefinedcxx . . $ `port/cpl_error.h:108:9`!, "Cannot copy %s to %s", |
| 4121 | m_osNodesFilenamecxx . . $ OGROSMDataSource#m_osNodesFilename..c_str(), osNewTmpDBName.c_str()); |
| 4122 | VSIUnlink(osNewTmpDBName.c_str()); |
| 4123 | m_bStopParsingcxx . . $ OGROSMDataSource#m_bStopParsing. = true; |
| 4124 | return false; |
| 4125 | } |
| 4126 | |
| 4127 | VSIUnlink(m_osNodesFilenamecxx . . $ OGROSMDataSource#m_osNodesFilename.); |
| 4128 | |
| 4129 | if (m_bInMemoryTmpDBcxx . . $ OGROSMDataSource#m_bInMemoryTmpDB.) |
| 4130 | { |
| 4131 | /* Try to grow the sqlite in memory-db to the full space now */ |
| 4132 | /* it has been freed. */ |
| 4133 | VSILFILE *fp = VSIFOpenL(m_osTmpDBNamecxx . . $ OGROSMDataSource#m_osTmpDBName., "rb+"); |
| 4134 | if (fp) |
| 4135 | { |
| 4136 | VSIFSeekLcxx . . $ VSIFSeekL(7b147a47904bd6c7).(fp, 0, SEEK_ENDcxx . . $ `<external>/232824719582829767/stdio.h:116:9`!); |
| 4137 | vsi_l_offset nCurSize = VSIFTellL(fp); |
| 4138 | vsi_l_offset nNewSize = |
| 4139 | static_cast<vsi_l_offset>(m_nMaxSizeForInMemoryDBInMBcxx . . $ OGROSMDataSource#m_nMaxSizeForInMemoryDBInMB.) * |
| 4140 | 1024 * 1024; |
| 4141 | CPLPushErrorHandler(CPLQuietErrorHandler); |
| 4142 | const bool bSuccess = |
| 4143 | VSIFSeekL(fp, nNewSize, SEEK_SETcxx . . $ `<external>/232824719582829767/stdio.h:114:9`!) == 0; |
| 4144 | CPLPopErrorHandler(); |
| 4145 | |
| 4146 | if (bSuccess) |
| 4147 | VSIFTruncateL(fp, nCurSize); |
| 4148 | |
| 4149 | VSIFCloseL(fp); |
| 4150 | } |
| 4151 | } |
| 4152 | |
| 4153 | m_osNodesFilenamecxx . . $ OGROSMDataSource#m_osNodesFilename. = osNewTmpDBName; |
| 4154 | |
| 4155 | m_fpNodescxx . . $ OGROSMDataSource#m_fpNodes. = VSIFOpenL(m_osNodesFilenamecxx . . $ OGROSMDataSource#m_osNodesFilename., "rb+"); |
| 4156 | if (m_fpNodescxx . . $ OGROSMDataSource#m_fpNodes. == nullptr) |
| 4157 | { |
| 4158 | m_bStopParsingcxx . . $ OGROSMDataSource#m_bStopParsing. = true; |
| 4159 | return false; |
| 4160 | } |
| 4161 | |
| 4162 | VSIFSeekLcxx . . $ VSIFSeekL(7b147a47904bd6c7).(m_fpNodescxx . . $ OGROSMDataSource#m_fpNodes., 0, SEEK_ENDcxx . . $ `<external>/232824719582829767/stdio.h:116:9`!); |
| 4163 | |
| 4164 | /* On Unix filesystems, you can remove a file even if it */ |
| 4165 | /* opened */ |
| 4166 | const char *pszVal = |
| 4167 | CPLGetConfigOption("OSM_UNLINK_TMPFILE", "YES"); |
| 4168 | if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszVal, "YES")) |
| 4169 | { |
| 4170 | CPLPushErrorHandler(CPLQuietErrorHandler); |
| 4171 | m_bMustUnlinkNodesFilecxx . . $ OGROSMDataSource#m_bMustUnlinkNodesFile. = VSIUnlink(m_osNodesFilenamecxx . . $ OGROSMDataSource#m_osNodesFilename.) != 0; |
| 4172 | CPLPopErrorHandler(); |
| 4173 | } |
| 4174 | } |
| 4175 | } |
| 4176 | |
| 4177 | if (m_bInMemoryTmpDBcxx . . $ OGROSMDataSource#m_bInMemoryTmpDB.) |
| 4178 | { |
| 4179 | VSIStatBufL sStat; |
| 4180 | |
| 4181 | int nLimitMB = m_nMaxSizeForInMemoryDBInMBcxx . . $ OGROSMDataSource#m_nMaxSizeForInMemoryDBInMB.; |
| 4182 | if (m_bCustomIndexingcxx . . $ OGROSMDataSource#m_bCustomIndexing. && m_bInMemoryNodesFilecxx . . $ OGROSMDataSource#m_bInMemoryNodesFile.) |
| 4183 | nLimitMB = nLimitMB * 1 / 4; |
| 4184 | |
| 4185 | if (VSIStatL(m_osTmpDBNamecxx . . $ OGROSMDataSource#m_osTmpDBName., &sStat) == 0 && |
| 4186 | sStat.st_size / 1024 / 1024 > nLimitMB) |
| 4187 | { |
| 4188 | m_bInMemoryTmpDBcxx . . $ OGROSMDataSource#m_bInMemoryTmpDB. = false; |
| 4189 | |
| 4190 | CloseDBcxx . . $ OGROSMDataSource#CloseDB(49f6e7a06ebc5aa8).(); |
| 4191 | |
| 4192 | const stdcxx . . $ std/::string osNewTmpDBName( |
| 4193 | CPLGenerateTempFilenameSafe("osm_tmp")); |
| 4194 | |
| 4195 | CPLDebug("OSM", |
| 4196 | "%s too big for RAM. Transferring it onto disk in %s", |
| 4197 | m_osTmpDBNamecxx . . $ OGROSMDataSource#m_osTmpDBName..c_str(), osNewTmpDBName.c_str()); |
| 4198 | |
| 4199 | if (CPLCopyFile(osNewTmpDBName.c_str(), m_osTmpDBNamecxx . . $ OGROSMDataSource#m_osTmpDBName.) != 0) |
| 4200 | { |
| 4201 | CPLError(CE_Failure, CPLE_AppDefinedcxx . . $ `port/cpl_error.h:108:9`!, "Cannot copy %s to %s", |
| 4202 | m_osTmpDBNamecxx . . $ OGROSMDataSource#m_osTmpDBName..c_str(), osNewTmpDBName.c_str()); |
| 4203 | VSIUnlink(osNewTmpDBName.c_str()); |
| 4204 | m_bStopParsingcxx . . $ OGROSMDataSource#m_bStopParsing. = true; |
| 4205 | return false; |
| 4206 | } |
| 4207 | |
| 4208 | VSIUnlink(m_osTmpDBNamecxx . . $ OGROSMDataSource#m_osTmpDBName.); |
| 4209 | |
| 4210 | m_osTmpDBNamecxx . . $ OGROSMDataSource#m_osTmpDBName. = osNewTmpDBName; |
| 4211 | |
| 4212 | const int rc = sqlite3_open_v2( |
| 4213 | m_osTmpDBNamecxx . . $ OGROSMDataSource#m_osTmpDBName..c_str(), &m_hDBcxx . . $ OGROSMDataSource#m_hDB., |
| 4214 | SQLITE_OPEN_READWRITEcxx . . $ `<external>/2400532043262193228/sqlite3.h:604:9`! | SQLITE_OPEN_NOMUTEXcxx . . $ `<external>/2400532043262193228/sqlite3.h:618:9`!, nullptr); |
| 4215 | if (rc != SQLITE_OKcxx . . $ `<external>/2400532043262193228/sqlite3.h:449:9`!) |
| 4216 | { |
| 4217 | CPLError(CE_Failure, CPLE_OpenFailedcxx . . $ `port/cpl_error.h:114:9`!, |
| 4218 | "sqlite3_open(%s) failed: %s", m_osTmpDBNamecxx . . $ OGROSMDataSource#m_osTmpDBName..c_str(), |
| 4219 | sqlite3_errmsg(m_hDBcxx . . $ OGROSMDataSource#m_hDB.)); |
| 4220 | m_bStopParsingcxx . . $ OGROSMDataSource#m_bStopParsing. = true; |
| 4221 | CloseDBcxx . . $ OGROSMDataSource#CloseDB(49f6e7a06ebc5aa8).(); |
| 4222 | return false; |
| 4223 | } |
| 4224 | |
| 4225 | /* On Unix filesystems, you can remove a file even if it */ |
| 4226 | /* opened */ |
| 4227 | const char *pszVal = |
| 4228 | CPLGetConfigOption("OSM_UNLINK_TMPFILE", "YES"); |
| 4229 | if (EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszVal, "YES")) |
| 4230 | { |
| 4231 | CPLPushErrorHandler(CPLQuietErrorHandler); |
| 4232 | m_bMustUnlinkcxx . . $ OGROSMDataSource#m_bMustUnlink. = VSIUnlink(m_osTmpDBNamecxx . . $ OGROSMDataSource#m_osTmpDBName.) != 0; |
| 4233 | CPLPopErrorHandler(); |
| 4234 | } |
| 4235 | |
| 4236 | if (!SetDBOptionscxx . . $ OGROSMDataSource#SetDBOptions(c9857a73d68e59ba).() || !CreatePreparedStatementscxx . . $ OGROSMDataSource#CreatePreparedStatements(c9857a73d68e59ba).()) |
| 4237 | { |
| 4238 | m_bStopParsingcxx . . $ OGROSMDataSource#m_bStopParsing. = true; |
| 4239 | CloseDBcxx . . $ OGROSMDataSource#CloseDB(49f6e7a06ebc5aa8).(); |
| 4240 | return false; |
| 4241 | } |
| 4242 | } |
| 4243 | } |
| 4244 | |
| 4245 | return true; |
| 4246 | } |
| 4247 | |
| 4248 | /************************************************************************/ |
| 4249 | /* TestCapability() */ |
| 4250 | /************************************************************************/ |
| 4251 | |
| 4252 | int OGROSMDataSourcecxx . . $ OGROSMDataSource#::TestCapabilitycxx . . $ OGROSMDataSource#TestCapability(78f035161ffa9fe2).(const char *pszCap) const |
| 4253 | { |
| 4254 | return EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszCap, ODsCRandomLayerReadcxx . . $ `ogr/ogr_core.h:1061:9`!); |
| 4255 | } |
| 4256 | |
| 4257 | /************************************************************************/ |
| 4258 | /* GetLayer() */ |
| 4259 | /************************************************************************/ |
| 4260 | |
| 4261 | const OGRLayercxx . . $ OGRLayer# *OGROSMDataSourcecxx . . $ OGROSMDataSource#::GetLayercxx . . $ OGROSMDataSource#GetLayer(3ead67c79a3185c4).(int iLayer) const |
| 4262 | |
| 4263 | { |
| 4264 | if (iLayer < 0 || static_cast<size_t>(iLayer) >= m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers..size()) |
| 4265 | return nullptr; |
| 4266 | |
| 4267 | return m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers.[iLayer].get(); |
| 4268 | } |
| 4269 | |
| 4270 | /************************************************************************/ |
| 4271 | /* GetNativeExtent() */ |
| 4272 | /************************************************************************/ |
| 4273 | |
| 4274 | OGRErr OGROSMDataSourcecxx . . $ OGROSMDataSource#::GetNativeExtentcxx . . $ OGROSMDataSource#GetNativeExtent(12be09bb877578cd).(OGREnvelope *psExtent) |
| 4275 | { |
| 4276 | if (!m_bHasParsedFirstChunkcxx . . $ OGROSMDataSource#m_bHasParsedFirstChunk.) |
| 4277 | { |
| 4278 | m_bHasParsedFirstChunkcxx . . $ OGROSMDataSource#m_bHasParsedFirstChunk. = true; |
| 4279 | OSM_ProcessBlock(m_psParsercxx . . $ OGROSMDataSource#m_psParser.); |
| 4280 | } |
| 4281 | |
| 4282 | if (m_bExtentValidcxx . . $ OGROSMDataSource#m_bExtentValid.) |
| 4283 | { |
| 4284 | *psExtent = m_sExtentcxx . . $ OGROSMDataSource#m_sExtent.; |
| 4285 | return OGRERR_NONEcxx . . $ `ogr/ogr_core.h:390:9`!; |
| 4286 | } |
| 4287 | |
| 4288 | return OGRERR_FAILUREcxx . . $ `ogr/ogr_core.h:396:9`!; |
| 4289 | } |
| 4290 | |
| 4291 | /************************************************************************/ |
| 4292 | /* OGROSMSingleFeatureLayer */ |
| 4293 | /************************************************************************/ |
| 4294 | |
| 4295 | class OGROSMSingleFeatureLayercxx . . $ OGROSMSingleFeatureLayer# final : public OGRLayercxx . . $ OGRLayer# |
| 4296 | { |
| 4297 | private: |
| 4298 | int nValcxx . . $ OGROSMSingleFeatureLayer#nVal.; |
| 4299 | char *pszValcxx . . $ OGROSMSingleFeatureLayer#pszVal.; |
| 4300 | OGRFeatureDefncxx . . $ OGRFeatureDefn# *poFeatureDefncxx . . $ OGROSMSingleFeatureLayer#poFeatureDefn.; |
| 4301 | int iNextShapeIdcxx . . $ OGROSMSingleFeatureLayer#iNextShapeId.; |
| 4302 | |
| 4303 | OGROSMSingleFeatureLayercxx . . $ OGROSMSingleFeatureLayer#OGROSMSingleFeatureLayer(4c290b7eb7121df5).(const OGROSMSingleFeatureLayercxx . . $ OGROSMSingleFeatureLayer# &) = delete; |
| 4304 | OGROSMSingleFeatureLayercxx . . $ OGROSMSingleFeatureLayer# & |
| 4305 | operatorcxx . . $ OGROSMSingleFeatureLayer#`operator=`(49f98c6f85dee851).=(const OGROSMSingleFeatureLayercxx . . $ OGROSMSingleFeatureLayer# &) = delete; |
| 4306 | |
| 4307 | public: |
| 4308 | OGROSMSingleFeatureLayercxx . . $ OGROSMSingleFeatureLayer#OGROSMSingleFeatureLayer(34d26762b42c433a).(const char *pszLayerName, int nVal); |
| 4309 | OGROSMSingleFeatureLayercxx . . $ OGROSMSingleFeatureLayer#OGROSMSingleFeatureLayer(2fa786934fe80e24).(const char *pszLayerName, const char *pszVal); |
| 4310 | ~cxx . . $ OGROSMSingleFeatureLayer#`~OGROSMSingleFeatureLayer`(ced63f7c635d850d).OGROSMSingleFeatureLayercxx . . $ OGROSMSingleFeatureLayer#() override; |
| 4311 | |
| 4312 | void ResetReadingcxx . . $ OGROSMSingleFeatureLayer#ResetReading(49f6e7a06ebc5aa8).() override |
| 4313 | { |
| 4314 | iNextShapeIdcxx . . $ OGROSMSingleFeatureLayer#iNextShapeId. = 0; |
| 4315 | } |
| 4316 | |
| 4317 | OGRFeaturecxx . . $ OGRFeature# *GetNextFeaturecxx . . $ OGROSMSingleFeatureLayer#GetNextFeature(ec9eceddec1d9563).() override; |
| 4318 | |
| 4319 | const OGRFeatureDefncxx . . $ OGRFeatureDefn# *GetLayerDefncxx . . $ OGROSMSingleFeatureLayer#GetLayerDefn(448b209f43d15bcc).() const override |
| 4320 | { |
| 4321 | return poFeatureDefncxx . . $ OGROSMSingleFeatureLayer#poFeatureDefn.; |
| 4322 | } |
| 4323 | |
| 4324 | int TestCapabilitycxx . . $ OGROSMSingleFeatureLayer#TestCapability(78f035161ffa9fe2).(const char *) const override |
| 4325 | { |
| 4326 | return FALSEcxx . . $ `port/cpl_port.h:1180:9`!; |
| 4327 | } |
| 4328 | }; |
| 4329 | |
| 4330 | /************************************************************************/ |
| 4331 | /* OGROSMSingleFeatureLayer() */ |
| 4332 | /************************************************************************/ |
| 4333 | |
| 4334 | OGROSMSingleFeatureLayercxx . . $ OGROSMSingleFeatureLayer#::OGROSMSingleFeatureLayercxx . . $ OGROSMSingleFeatureLayer#OGROSMSingleFeatureLayer(34d26762b42c433a).(const char *pszLayerName, |
| 4335 | int nValIn) |
| 4336 | : nValcxx . . $ OGROSMSingleFeatureLayer#nVal.(nValIn), pszValcxx . . $ OGROSMSingleFeatureLayer#pszVal.(nullptr), |
| 4337 | poFeatureDefncxx . . $ OGROSMSingleFeatureLayer#poFeatureDefn.(new OGRFeatureDefncxx . . $ OGRFeatureDefn#("SELECT")), iNextShapeIdcxx . . $ OGROSMSingleFeatureLayer#iNextShapeId.(0) |
| 4338 | { |
| 4339 | poFeatureDefncxx . . $ OGROSMSingleFeatureLayer#poFeatureDefn.->Referencecxx . . $ OGRFeatureDefn#Reference(b126dc7c1de90089).(); |
| 4340 | OGRFieldDefncxx . . $ OGRFieldDefn# oFieldcxx . . $ OGRFieldDefn#OGRFieldDefn(786ecb48a0b3b841).(pszLayerName, OFTInteger); |
| 4341 | poFeatureDefncxx . . $ OGROSMSingleFeatureLayer#poFeatureDefn.->AddFieldDefncxx . . $ OGRFeatureDefn#AddFieldDefn(f8bad7d30df65bbb).(&oField); |
| 4342 | } |
| 4343 | |
| 4344 | /************************************************************************/ |
| 4345 | /* OGROSMSingleFeatureLayer() */ |
| 4346 | /************************************************************************/ |
| 4347 | |
| 4348 | OGROSMSingleFeatureLayercxx . . $ OGROSMSingleFeatureLayer#::OGROSMSingleFeatureLayercxx . . $ OGROSMSingleFeatureLayer#OGROSMSingleFeatureLayer(2fa786934fe80e24).(const char *pszLayerName, |
| 4349 | const char *pszValIn) |
| 4350 | : nValcxx . . $ OGROSMSingleFeatureLayer#nVal.(0), pszValcxx . . $ OGROSMSingleFeatureLayer#pszVal.(CPLStrdup(pszValIn)), |
| 4351 | poFeatureDefncxx . . $ OGROSMSingleFeatureLayer#poFeatureDefn.(new OGRFeatureDefncxx . . $ OGRFeatureDefn#("SELECT")), iNextShapeIdcxx . . $ OGROSMSingleFeatureLayer#iNextShapeId.(0) |
| 4352 | { |
| 4353 | poFeatureDefncxx . . $ OGROSMSingleFeatureLayer#poFeatureDefn.->Referencecxx . . $ OGRFeatureDefn#Reference(b126dc7c1de90089).(); |
| 4354 | OGRFieldDefncxx . . $ OGRFieldDefn# oFieldcxx . . $ OGRFieldDefn#OGRFieldDefn(786ecb48a0b3b841).(pszLayerName, OFTString); |
| 4355 | poFeatureDefncxx . . $ OGROSMSingleFeatureLayer#poFeatureDefn.->AddFieldDefncxx . . $ OGRFeatureDefn#AddFieldDefn(f8bad7d30df65bbb).(&oField); |
| 4356 | } |
| 4357 | |
| 4358 | /************************************************************************/ |
| 4359 | /* ~OGROSMSingleFeatureLayer() */ |
| 4360 | /************************************************************************/ |
| 4361 | |
| 4362 | OGROSMSingleFeatureLayercxx . . $ OGROSMSingleFeatureLayer#::~cxx . . $ OGROSMSingleFeatureLayer#`~OGROSMSingleFeatureLayer`(ced63f7c635d850d).OGROSMSingleFeatureLayercxx . . $ OGROSMSingleFeatureLayer#() |
| 4363 | { |
| 4364 | poFeatureDefncxx . . $ OGROSMSingleFeatureLayer#poFeatureDefn.->Releasecxx . . $ OGRFeatureDefn#Release(49f6e7a06ebc5aa8).(); |
| 4365 | CPLFreecxx . . $ `port/cpl_conv.h:97:9`!(pszValcxx . . $ OGROSMSingleFeatureLayer#pszVal.); |
| 4366 | } |
| 4367 | |
| 4368 | /************************************************************************/ |
| 4369 | /* GetNextFeature() */ |
| 4370 | /************************************************************************/ |
| 4371 | |
| 4372 | OGRFeaturecxx . . $ OGRFeature# *OGROSMSingleFeatureLayercxx . . $ OGROSMSingleFeatureLayer#::GetNextFeaturecxx . . $ OGROSMSingleFeatureLayer#GetNextFeature(ec9eceddec1d9563).() |
| 4373 | { |
| 4374 | if (iNextShapeIdcxx . . $ OGROSMSingleFeatureLayer#iNextShapeId. != 0) |
| 4375 | return nullptr; |
| 4376 | |
| 4377 | OGRFeaturecxx . . $ OGRFeature# *poFeature = new OGRFeaturecxx . . $ OGRFeature#OGRFeature(dc2636911e7adfe).(poFeatureDefncxx . . $ OGROSMSingleFeatureLayer#poFeatureDefn.); |
| 4378 | if (pszValcxx . . $ OGROSMSingleFeatureLayer#pszVal.) |
| 4379 | poFeature->SetFieldcxx . . $ OGRFeature#SetField(66835f578de1bcb3).(0, pszValcxx . . $ OGROSMSingleFeatureLayer#pszVal.); |
| 4380 | else |
| 4381 | poFeature->SetFieldcxx . . $ OGRFeature#SetField(3e454b8ccf442868).(0, nValcxx . . $ OGROSMSingleFeatureLayer#nVal.); |
| 4382 | poFeature->SetFIDcxx . . $ OGRFeature#SetFID(a070d6d14e988596).(iNextShapeIdcxx . . $ OGROSMSingleFeatureLayer#iNextShapeId.++); |
| 4383 | return poFeature; |
| 4384 | } |
| 4385 | |
| 4386 | /************************************************************************/ |
| 4387 | /* OGROSMResultLayerDecorator */ |
| 4388 | /************************************************************************/ |
| 4389 | |
| 4390 | class OGROSMResultLayerDecoratorcxx . . $ OGROSMResultLayerDecorator# final : public OGRLayerDecoratorcxx . . $ OGRLayerDecorator# |
| 4391 | { |
| 4392 | stdcxx . . $ std/::string osDSNamecxx . . $ OGROSMResultLayerDecorator#osDSName.; |
| 4393 | stdcxx . . $ std/::string osInterestLayerscxx . . $ OGROSMResultLayerDecorator#osInterestLayers.; |
| 4394 | |
| 4395 | public: |
| 4396 | OGROSMResultLayerDecoratorcxx . . $ OGROSMResultLayerDecorator#OGROSMResultLayerDecorator(df17eea2b56d29ee).(OGRLayercxx . . $ OGRLayer# *poLayer, const stdcxx . . $ std/::string &osDSNameIn, |
| 4397 | const stdcxx . . $ std/::string &osInterestLayersIn) |
| 4398 | : OGRLayerDecoratorcxx . . $ OGRLayerDecorator#(poLayer, TRUEcxx . . $ `port/cpl_port.h:1184:9`!), osDSNamecxx . . $ OGROSMResultLayerDecorator#osDSName.(osDSNameIn), |
| 4399 | osInterestLayerscxx . . $ OGROSMResultLayerDecorator#osInterestLayers.(osInterestLayersIn) |
| 4400 | { |
| 4401 | } |
| 4402 | |
| 4403 | GIntBigcxx . . $ GIntBig# GetFeatureCountcxx . . $ OGROSMResultLayerDecorator#GetFeatureCount(9ccc33c3ebad048d).(int bForce = TRUEcxx . . $ `port/cpl_port.h:1184:9`!) override; |
| 4404 | }; |
| 4405 | |
| 4406 | GIntBigcxx . . $ GIntBig# OGROSMResultLayerDecoratorcxx . . $ OGROSMResultLayerDecorator#::GetFeatureCountcxx . . $ OGROSMResultLayerDecorator#GetFeatureCount(9ccc33c3ebad048d).(int bForce) |
| 4407 | { |
| 4408 | /* When we run GetFeatureCount() with SQLite SQL dialect, */ |
| 4409 | /* the OSM dataset will be re-opened. Make sure that it is */ |
| 4410 | /* re-opened with the same interest layers */ |
| 4411 | AddInterestLayersForDSNamecxx . . $ AddInterestLayersForDSName(417a6461aa4d910b).(osDSNamecxx . . $ OGROSMResultLayerDecorator#osDSName., osInterestLayerscxx . . $ OGROSMResultLayerDecorator#osInterestLayers.); |
| 4412 | return OGRLayerDecoratorcxx . . $ OGRLayerDecorator#::GetFeatureCountcxx . . $ OGRLayerDecorator#GetFeatureCount(9ccc33c3ebad048d).(bForce); |
| 4413 | } |
| 4414 | |
| 4415 | /************************************************************************/ |
| 4416 | /* ExecuteSQL() */ |
| 4417 | /************************************************************************/ |
| 4418 | |
| 4419 | OGRLayercxx . . $ OGRLayer# *OGROSMDataSourcecxx . . $ OGROSMDataSource#::ExecuteSQLcxx . . $ OGROSMDataSource#ExecuteSQL(1e911e025f8b6f61).(const char *pszSQLCommand, |
| 4420 | OGRGeometrycxx . . $ OGRGeometry# *poSpatialFilter, |
| 4421 | const char *pszDialect) |
| 4422 | |
| 4423 | { |
| 4424 | /* -------------------------------------------------------------------- */ |
| 4425 | /* Special GetBytesRead() command */ |
| 4426 | /* -------------------------------------------------------------------- */ |
| 4427 | if (strcmp(pszSQLCommand, "GetBytesRead()") == 0) |
| 4428 | { |
| 4429 | char szVal[64] = {}; |
| 4430 | snprintf(szVal, sizeof(szVal), CPL_FRMT_GUIBcxx . . $ `port/cpl_port.h:259:9`!, |
| 4431 | OSM_GetBytesRead(m_psParsercxx . . $ OGROSMDataSource#m_psParser.)); |
| 4432 | return new OGROSMSingleFeatureLayercxx . . $ OGROSMSingleFeatureLayer#("GetBytesRead", szVal); |
| 4433 | } |
| 4434 | |
| 4435 | /* -------------------------------------------------------------------- */ |
| 4436 | /* Special SHOW config_file_path command */ |
| 4437 | /* -------------------------------------------------------------------- */ |
| 4438 | if (strcmp(pszSQLCommand, "SHOW config_file_path") == 0) |
| 4439 | { |
| 4440 | return new OGROSMSingleFeatureLayercxx . . $ OGROSMSingleFeatureLayer#("config_file_path", |
| 4441 | m_osConfigFilecxx . . $ OGROSMDataSource#m_osConfigFile..c_str()); |
| 4442 | } |
| 4443 | |
| 4444 | if (m_poResultSetLayercxx . . $ OGROSMDataSource#m_poResultSetLayer. != nullptr) |
| 4445 | { |
| 4446 | CPLError(CE_Failure, CPLE_NotSupportedcxx . . $ `port/cpl_error.h:118:9`!, |
| 4447 | "A SQL result layer is still in use. Please delete it first"); |
| 4448 | return nullptr; |
| 4449 | } |
| 4450 | |
| 4451 | /* -------------------------------------------------------------------- */ |
| 4452 | /* Special SET interest_layers = command */ |
| 4453 | /* -------------------------------------------------------------------- */ |
| 4454 | if (STARTS_WITHcxx . . $ `port/cpl_port.h:541:9`!(pszSQLCommand, "SET interest_layers =")) |
| 4455 | { |
| 4456 | char **papszTokens = |
| 4457 | CSLTokenizeString2(pszSQLCommand + 21, ",", |
| 4458 | CSLT_STRIPLEADSPACEScxx . . $ `port/cpl_string.h:78:9`! | CSLT_STRIPENDSPACEScxx . . $ `port/cpl_string.h:80:9`!); |
| 4459 | for (auto &&poLayer : m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers.) |
| 4460 | { |
| 4461 | poLayer->SetDeclareInterestcxx . . $ OGROSMLayer#SetDeclareInterest(b45ddcbc8423892c).(FALSEcxx . . $ `port/cpl_port.h:1180:9`!); |
| 4462 | } |
| 4463 | |
| 4464 | for (int i = 0; papszTokens[i] != nullptr; i++) |
| 4465 | { |
| 4466 | OGROSMLayercxx . . $ OGROSMLayer# *poLayer = |
| 4467 | dynamic_cast<OGROSMLayercxx . . $ OGROSMLayer# *>(GetLayerByNamecxx . . $ GDALDataset#GetLayerByName(5ddf27af0841fa5b).(papszTokens[i])); |
| 4468 | if (poLayer != nullptr) |
| 4469 | { |
| 4470 | poLayer->SetDeclareInterestcxx . . $ OGROSMLayer#SetDeclareInterest(b45ddcbc8423892c).(TRUEcxx . . $ `port/cpl_port.h:1184:9`!); |
| 4471 | } |
| 4472 | } |
| 4473 | |
| 4474 | if (m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers.[IDX_LYR_POINTScxx . . $ IDX_LYR_POINTS.]->IsUserInterestedcxx . . $ OGROSMLayer#IsUserInterested(50ce9a9e25b4a850).() && |
| 4475 | !m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers.[IDX_LYR_LINEScxx . . $ IDX_LYR_LINES.]->IsUserInterestedcxx . . $ OGROSMLayer#IsUserInterested(50ce9a9e25b4a850).() && |
| 4476 | !m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers.[IDX_LYR_MULTILINESTRINGScxx . . $ IDX_LYR_MULTILINESTRINGS.]->IsUserInterestedcxx . . $ OGROSMLayer#IsUserInterested(50ce9a9e25b4a850).() && |
| 4477 | !m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers.[IDX_LYR_MULTIPOLYGONScxx . . $ IDX_LYR_MULTIPOLYGONS.]->IsUserInterestedcxx . . $ OGROSMLayer#IsUserInterested(50ce9a9e25b4a850).() && |
| 4478 | !m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers.[IDX_LYR_OTHER_RELATIONScxx . . $ IDX_LYR_OTHER_RELATIONS.]->IsUserInterestedcxx . . $ OGROSMLayer#IsUserInterested(50ce9a9e25b4a850).()) |
| 4479 | { |
| 4480 | if (CPLGetConfigOption("OSM_INDEX_POINTS", nullptr) == nullptr) |
| 4481 | { |
| 4482 | CPLDebug("OSM", "Disabling indexing of nodes"); |
| 4483 | m_bIndexPointscxx . . $ OGROSMDataSource#m_bIndexPoints. = false; |
| 4484 | } |
| 4485 | if (CPLGetConfigOption("OSM_USE_POINTS_INDEX", nullptr) == nullptr) |
| 4486 | { |
| 4487 | m_bUsePointsIndexcxx . . $ OGROSMDataSource#m_bUsePointsIndex. = false; |
| 4488 | } |
| 4489 | if (CPLGetConfigOption("OSM_INDEX_WAYS", nullptr) == nullptr) |
| 4490 | { |
| 4491 | CPLDebug("OSM", "Disabling indexing of ways"); |
| 4492 | m_bIndexWayscxx . . $ OGROSMDataSource#m_bIndexWays. = false; |
| 4493 | } |
| 4494 | if (CPLGetConfigOption("OSM_USE_WAYS_INDEX", nullptr) == nullptr) |
| 4495 | { |
| 4496 | m_bUseWaysIndexcxx . . $ OGROSMDataSource#m_bUseWaysIndex. = false; |
| 4497 | } |
| 4498 | } |
| 4499 | else if (m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers.[IDX_LYR_LINEScxx . . $ IDX_LYR_LINES.]->IsUserInterestedcxx . . $ OGROSMLayer#IsUserInterested(50ce9a9e25b4a850).() && |
| 4500 | !m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers.[IDX_LYR_MULTILINESTRINGScxx . . $ IDX_LYR_MULTILINESTRINGS.]->IsUserInterestedcxx . . $ OGROSMLayer#IsUserInterested(50ce9a9e25b4a850).() && |
| 4501 | !m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers.[IDX_LYR_MULTIPOLYGONScxx . . $ IDX_LYR_MULTIPOLYGONS.]->IsUserInterestedcxx . . $ OGROSMLayer#IsUserInterested(50ce9a9e25b4a850).() && |
| 4502 | !m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers.[IDX_LYR_OTHER_RELATIONScxx . . $ IDX_LYR_OTHER_RELATIONS.]->IsUserInterestedcxx . . $ OGROSMLayer#IsUserInterested(50ce9a9e25b4a850).()) |
| 4503 | { |
| 4504 | if (CPLGetConfigOption("OSM_INDEX_WAYS", nullptr) == nullptr) |
| 4505 | { |
| 4506 | CPLDebug("OSM", "Disabling indexing of ways"); |
| 4507 | m_bIndexWayscxx . . $ OGROSMDataSource#m_bIndexWays. = false; |
| 4508 | } |
| 4509 | if (CPLGetConfigOption("OSM_USE_WAYS_INDEX", nullptr) == nullptr) |
| 4510 | { |
| 4511 | m_bUseWaysIndexcxx . . $ OGROSMDataSource#m_bUseWaysIndex. = false; |
| 4512 | } |
| 4513 | } |
| 4514 | |
| 4515 | CSLDestroy(papszTokens); |
| 4516 | |
| 4517 | return nullptr; |
| 4518 | } |
| 4519 | |
| 4520 | while (*pszSQLCommand == ' ') |
| 4521 | pszSQLCommand++; |
| 4522 | |
| 4523 | /* Try to analyse the SQL command to get the interest table */ |
| 4524 | if (STARTS_WITH_CIcxx . . $ `port/cpl_port.h:543:9`!(pszSQLCommand, "SELECT")) |
| 4525 | { |
| 4526 | bool bLayerAlreadyAdded = false; |
| 4527 | CPLString osInterestLayers = "SET interest_layers ="; |
| 4528 | |
| 4529 | if (pszDialect != nullptr && EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszDialect, "SQLITE")) |
| 4530 | { |
| 4531 | const auto oSetLayers = OGRSQLiteGetReferencedLayerscxx . . $ OGRSQLiteGetReferencedLayers(7e5de8f015d6a131).(pszSQLCommand); |
| 4532 | for (const LayerDesccxx . . $ LayerDesc# &oLayerDesc : oSetLayers) |
| 4533 | { |
| 4534 | if (oLayerDesc.osDSNamecxx . . $ LayerDesc#osDSName..empty()) |
| 4535 | { |
| 4536 | if (bLayerAlreadyAdded) |
| 4537 | osInterestLayers += ","; |
| 4538 | bLayerAlreadyAdded = true; |
| 4539 | osInterestLayers += oLayerDesc.osLayerNamecxx . . $ LayerDesc#osLayerName.; |
| 4540 | } |
| 4541 | } |
| 4542 | } |
| 4543 | else |
| 4544 | { |
| 4545 | swq_selectcxx . . $ swq_select# sSelectInfocxx . . $ swq_select#swq_select(49f6e7a06ebc5aa8).; |
| 4546 | |
| 4547 | CPLPushErrorHandler(CPLQuietErrorHandler); |
| 4548 | CPLErr eErr = sSelectInfo.preparsecxx . . $ swq_select#preparse(1b63f5c7dfea8a7d).(pszSQLCommand); |
| 4549 | CPLPopErrorHandler(); |
| 4550 | |
| 4551 | if (eErr == CE_None) |
| 4552 | { |
| 4553 | swq_selectcxx . . $ swq_select# *pCurSelect = &sSelectInfo; |
| 4554 | while (pCurSelect != nullptr) |
| 4555 | { |
| 4556 | for (int iTable = 0; iTable < pCurSelect->table_countcxx . . $ swq_select#table_count.; |
| 4557 | iTable++) |
| 4558 | { |
| 4559 | swq_table_defcxx . . $ swq_table_def# *psTableDef = |
| 4560 | pCurSelect->table_defscxx . . $ swq_select#table_defs. + iTable; |
| 4561 | if (psTableDef->data_sourcecxx . . $ $anonymous_type_a69ae1a4ba3d583e_4#data_source. == nullptr) |
| 4562 | { |
| 4563 | if (bLayerAlreadyAdded) |
| 4564 | osInterestLayers += ","; |
| 4565 | bLayerAlreadyAdded = true; |
| 4566 | osInterestLayers += psTableDef->table_namecxx . . $ $anonymous_type_a69ae1a4ba3d583e_4#table_name.; |
| 4567 | } |
| 4568 | } |
| 4569 | pCurSelect = pCurSelect->poOtherSelectcxx . . $ swq_select#poOtherSelect.; |
| 4570 | } |
| 4571 | } |
| 4572 | } |
| 4573 | |
| 4574 | if (bLayerAlreadyAdded) |
| 4575 | { |
| 4576 | /* Backup current optimization parameters */ |
| 4577 | m_abSavedDeclaredInterestcxx . . $ OGROSMDataSource#m_abSavedDeclaredInterest..resizecxx . . $ std/vector#resize(62a5225ebb2f873).(0); |
| 4578 | for (auto &&poLayer : m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers.) |
| 4579 | { |
| 4580 | m_abSavedDeclaredInterestcxx . . $ OGROSMDataSource#m_abSavedDeclaredInterest..push_backcxx . . $ std/vector#push_back(b45ddcbc8423892c).( |
| 4581 | poLayer->IsUserInterestedcxx . . $ OGROSMLayer#IsUserInterested(50ce9a9e25b4a850).()); |
| 4582 | } |
| 4583 | m_bIndexPointsBackupcxx . . $ OGROSMDataSource#m_bIndexPointsBackup. = m_bIndexPointscxx . . $ OGROSMDataSource#m_bIndexPoints.; |
| 4584 | m_bUsePointsIndexBackupcxx . . $ OGROSMDataSource#m_bUsePointsIndexBackup. = m_bUsePointsIndexcxx . . $ OGROSMDataSource#m_bUsePointsIndex.; |
| 4585 | m_bIndexWaysBackupcxx . . $ OGROSMDataSource#m_bIndexWaysBackup. = m_bIndexWayscxx . . $ OGROSMDataSource#m_bIndexWays.; |
| 4586 | m_bUseWaysIndexBackupcxx . . $ OGROSMDataSource#m_bUseWaysIndexBackup. = m_bUseWaysIndexcxx . . $ OGROSMDataSource#m_bUseWaysIndex.; |
| 4587 | |
| 4588 | /* Update optimization parameters */ |
| 4589 | delete ExecuteSQLcxx . . $ OGROSMDataSource#ExecuteSQL(1e911e025f8b6f61).(osInterestLayers, nullptr, nullptr); |
| 4590 | |
| 4591 | MyResetReadingcxx . . $ OGROSMDataSource#MyResetReading(b126dc7c1de90089).(); |
| 4592 | |
| 4593 | /* Run the request */ |
| 4594 | m_poResultSetLayercxx . . $ OGROSMDataSource#m_poResultSetLayer. = GDALDatasetcxx . . $ GDALDataset#::ExecuteSQLcxx . . $ GDALDataset#ExecuteSQL(1e911e025f8b6f61).( |
| 4595 | pszSQLCommand, poSpatialFilter, pszDialect); |
| 4596 | |
| 4597 | /* If the user explicitly run a COUNT() request, then do it ! */ |
| 4598 | if (m_poResultSetLayercxx . . $ OGROSMDataSource#m_poResultSetLayer.) |
| 4599 | { |
| 4600 | if (pszDialect != nullptr && EQUALcxx . . $ `port/cpl_port.h:532:9`!(pszDialect, "SQLITE")) |
| 4601 | { |
| 4602 | m_poResultSetLayercxx . . $ OGROSMDataSource#m_poResultSetLayer. = new OGROSMResultLayerDecoratorcxx . . $ OGROSMResultLayerDecorator#( |
| 4603 | m_poResultSetLayercxx . . $ OGROSMDataSource#m_poResultSetLayer., GetDescriptioncxx . . $ GDALMajorObject#GetDescription(a9f41ea0e82d88cf).(), osInterestLayers); |
| 4604 | } |
| 4605 | m_bIsFeatureCountEnabledcxx . . $ OGROSMDataSource#m_bIsFeatureCountEnabled. = true; |
| 4606 | } |
| 4607 | |
| 4608 | return m_poResultSetLayercxx . . $ OGROSMDataSource#m_poResultSetLayer.; |
| 4609 | } |
| 4610 | } |
| 4611 | |
| 4612 | return GDALDatasetcxx . . $ GDALDataset#::ExecuteSQLcxx . . $ GDALDataset#ExecuteSQL(1e911e025f8b6f61).(pszSQLCommand, poSpatialFilter, pszDialect); |
| 4613 | } |
| 4614 | |
| 4615 | /************************************************************************/ |
| 4616 | /* ReleaseResultSet() */ |
| 4617 | /************************************************************************/ |
| 4618 | |
| 4619 | void OGROSMDataSourcecxx . . $ OGROSMDataSource#::ReleaseResultSetcxx . . $ OGROSMDataSource#ReleaseResultSet(74233f8ea7d835ac).(OGRLayercxx . . $ OGRLayer# *poLayer) |
| 4620 | |
| 4621 | { |
| 4622 | if (poLayer != nullptr && poLayer == m_poResultSetLayercxx . . $ OGROSMDataSource#m_poResultSetLayer.) |
| 4623 | { |
| 4624 | m_poResultSetLayercxx . . $ OGROSMDataSource#m_poResultSetLayer. = nullptr; |
| 4625 | |
| 4626 | m_bIsFeatureCountEnabledcxx . . $ OGROSMDataSource#m_bIsFeatureCountEnabled. = false; |
| 4627 | |
| 4628 | /* Restore backup'ed optimization parameters */ |
| 4629 | int i = 0; |
| 4630 | for (auto &&poIterLayer : m_apoLayerscxx . . $ OGROSMDataSource#m_apoLayers.) |
| 4631 | { |
| 4632 | poIterLayer->SetDeclareInterestcxx . . $ OGROSMLayer#SetDeclareInterest(b45ddcbc8423892c).(m_abSavedDeclaredInterestcxx . . $ OGROSMDataSource#m_abSavedDeclaredInterest.[cxx . . $ std/vector#`operator[]`(1450282ea0befc17).i]); |
| 4633 | ++i; |
| 4634 | } |
| 4635 | if (m_bIndexPointsBackupcxx . . $ OGROSMDataSource#m_bIndexPointsBackup. && !m_bIndexPointscxx . . $ OGROSMDataSource#m_bIndexPoints.) |
| 4636 | CPLDebug("OSM", "Re-enabling indexing of nodes"); |
| 4637 | m_bIndexPointscxx . . $ OGROSMDataSource#m_bIndexPoints. = m_bIndexPointsBackupcxx . . $ OGROSMDataSource#m_bIndexPointsBackup.; |
| 4638 | m_bUsePointsIndexcxx . . $ OGROSMDataSource#m_bUsePointsIndex. = m_bUsePointsIndexBackupcxx . . $ OGROSMDataSource#m_bUsePointsIndexBackup.; |
| 4639 | if (m_bIndexWaysBackupcxx . . $ OGROSMDataSource#m_bIndexWaysBackup. && !m_bIndexWayscxx . . $ OGROSMDataSource#m_bIndexWays.) |
| 4640 | CPLDebug("OSM", "Re-enabling indexing of ways"); |
| 4641 | m_bIndexWayscxx . . $ OGROSMDataSource#m_bIndexWays. = m_bIndexWaysBackupcxx . . $ OGROSMDataSource#m_bIndexWaysBackup.; |
| 4642 | m_bUseWaysIndexcxx . . $ OGROSMDataSource#m_bUseWaysIndex. = m_bUseWaysIndexBackupcxx . . $ OGROSMDataSource#m_bUseWaysIndexBackup.; |
| 4643 | m_abSavedDeclaredInterestcxx . . $ OGROSMDataSource#m_abSavedDeclaredInterest..clearcxx . . $ std/vector#clear(ced63f7c635d850d).(); |
| 4644 | } |
| 4645 | |
| 4646 | delete poLayer; |
| 4647 | } |
| 4648 | |
| 4649 | /************************************************************************/ |
| 4650 | /* IsInterleavedReading() */ |
| 4651 | /************************************************************************/ |
| 4652 | |
| 4653 | int OGROSMDataSourcecxx . . $ OGROSMDataSource#::IsInterleavedReadingcxx . . $ OGROSMDataSource#IsInterleavedReading(b126dc7c1de90089).() |
| 4654 | { |
| 4655 | if (m_bInterleavedReadingcxx . . $ OGROSMDataSource#m_bInterleavedReading. < 0) |
| 4656 | { |
| 4657 | m_bInterleavedReadingcxx . . $ OGROSMDataSource#m_bInterleavedReading. = |
| 4658 | CPLTestBool(CPLGetConfigOption("OGR_INTERLEAVED_READING", "NO")); |
| 4659 | CPLDebug("OSM", "OGR_INTERLEAVED_READING = %d", m_bInterleavedReadingcxx . . $ OGROSMDataSource#m_bInterleavedReading.); |
| 4660 | } |
| 4661 | return m_bInterleavedReadingcxx . . $ OGROSMDataSource#m_bInterleavedReading.; |
| 4662 | } |