blob: aebb72747a735882f276ebfb328033560984669a (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ORC_GEOSPATIAL_IMPL_HH
#define ORC_GEOSPATIAL_IMPL_HH
#include "orc/Geospatial.hh"
#include <unordered_set>
#include <vector>
namespace orc {
namespace geospatial {
class WKBBuffer;
class WKBGeometryBounder {
public:
void mergeGeometry(std::string_view bytesWkb);
void mergeGeometry(const uint8_t* bytesWkb, size_t bytesSize);
void mergeBox(const BoundingBox& box) {
box_.merge(box);
}
void mergeGeometryTypes(const std::vector<int>& geospatialTypes) {
geospatialTypes_.insert(geospatialTypes.begin(), geospatialTypes.end());
}
void merge(const WKBGeometryBounder& other) {
if (!isValid() || !other.isValid()) {
invalidate();
return;
}
box_.merge(other.box_);
geospatialTypes_.insert(other.geospatialTypes_.begin(), other.geospatialTypes_.end());
}
// Get the bounding box for the merged geometries.
const BoundingBox& bounds() const {
return box_;
}
// Get the set of geometry types encountered during merging.
// Returns a sorted vector of geometry type IDs.
std::vector<int32_t> geometryTypes() const;
void reset() {
isValid_ = true;
box_.reset();
geospatialTypes_.clear();
}
bool isValid() const {
return isValid_;
}
void invalidate() {
isValid_ = false;
box_.invalidate();
geospatialTypes_.clear();
}
private:
BoundingBox box_;
std::unordered_set<int32_t> geospatialTypes_;
bool isValid_ = true;
void mergeGeometryInternal(WKBBuffer* src, bool recordWkbType);
void mergeSequence(WKBBuffer* src, Dimensions dimensions, uint32_t nCoords, bool swap);
};
} // namespace geospatial
} // namespace orc
#endif
|