| 223 | } |
| 224 | |
| 225 | void WKBGeometryBounder::mergeGeometryInternal(WKBBuffer* src, bool recordWkbType) { |
| 226 | uint8_t endian = src->readUInt8(); |
| 227 | bool swap = endian != 0x00; |
| 228 | if (isLittleEndian()) { |
| 229 | swap = endian != 0x01; |
| 230 | } |
| 231 | |
| 232 | uint32_t wkbGeometryType = src->readUInt32(swap); |
| 233 | auto geometryTypeAndDimensions = parseGeometryType(wkbGeometryType); |
| 234 | if (!geometryTypeAndDimensions.has_value()) { |
| 235 | invalidate(); |
| 236 | return; |
| 237 | } |
| 238 | auto& [geometry_type, dimensions] = geometryTypeAndDimensions.value(); |
| 239 | |
| 240 | // Keep track of geometry types encountered if at the top level |
| 241 | if (recordWkbType) { |
| 242 | geospatialTypes_.insert(static_cast<int32_t>(wkbGeometryType)); |
| 243 | } |
| 244 | |
| 245 | switch (geometry_type) { |
| 246 | case GeometryType::POINT: |
| 247 | mergeSequence(src, dimensions, 1, swap); |
| 248 | break; |
| 249 | |
| 250 | case GeometryType::LINESTRING: { |
| 251 | uint32_t nCoords = src->readUInt32(swap); |
| 252 | mergeSequence(src, dimensions, nCoords, swap); |
| 253 | break; |
| 254 | } |
| 255 | case GeometryType::POLYGON: { |
| 256 | uint32_t n_parts = src->readUInt32(swap); |
| 257 | for (uint32_t i = 0; i < n_parts; i++) { |
| 258 | uint32_t nCoords = src->readUInt32(swap); |
| 259 | mergeSequence(src, dimensions, nCoords, swap); |
| 260 | } |
| 261 | break; |
| 262 | } |
| 263 | |
| 264 | // These are all encoded the same in WKB, even though this encoding would |
| 265 | // allow for parts to be of a different geometry type or different dimensions. |
| 266 | // For the purposes of bounding, this does not cause us problems. We pass |
| 267 | // record_wkb_type = false because we do not want the child geometry to be |
| 268 | // added to the geometry_types list (e.g., for a MultiPoint, we only want |
| 269 | // the code for MultiPoint to be added, not the code for Point). |
| 270 | case GeometryType::MULTIPOINT: |
| 271 | case GeometryType::MULTILINESTRING: |
| 272 | case GeometryType::MULTIPOLYGON: |
| 273 | case GeometryType::GEOMETRYCOLLECTION: { |
| 274 | uint32_t n_parts = src->readUInt32(swap); |
| 275 | for (uint32_t i = 0; i < n_parts; i++) { |
| 276 | mergeGeometryInternal(src, /*record_wkb_type*/ false); |
| 277 | } |
| 278 | break; |
| 279 | } |
| 280 | } |
| 281 | } |
| 282 |
nothing calls this directly
no test coverage detected