MCPcopy Create free account
hub / github.com/apache/arrow / MakeWKBPoint

Function MakeWKBPoint

cpp/src/parquet/test_util.cc:210–236  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

208} // namespace
209
210std::string MakeWKBPoint(const std::vector<double>& xyzm, bool has_z, bool has_m) {
211 // 1:endianness + 4:type + 8:x + 8:y
212 int num_bytes =
213 kWkbPointXYSize + (has_z ? sizeof(double) : 0) + (has_m ? sizeof(double) : 0);
214 std::string wkb(num_bytes, 0);
215 char* ptr = wkb.data();
216
217 ptr[0] = kWkbNativeEndianness;
218 uint32_t geom_type = GeometryTypeToWKB(geospatial::GeometryType::kPoint, has_z, has_m);
219 std::memcpy(&ptr[1], &geom_type, 4);
220 std::memcpy(&ptr[5], &xyzm[0], 8);
221 std::memcpy(&ptr[13], &xyzm[1], 8);
222 ptr += 21;
223
224 if (has_z) {
225 std::memcpy(ptr, &xyzm[2], 8);
226 ptr += 8;
227 }
228
229 if (has_m) {
230 std::memcpy(ptr, &xyzm[3], 8);
231 ptr += 8;
232 }
233
234 DCHECK_EQ(static_cast<size_t>(ptr - wkb.data()), wkb.length());
235 return wkb;
236}
237
238std::optional<std::pair<double, double>> GetWKBPointCoordinateXY(const ByteArray& value) {
239 if (value.len != kWkbPointXYSize) {

Callers 6

ASSERT_OK_AND_ASSIGNFunction · 0.85
TEST_FFunction · 0.85
TEST_PFunction · 0.85
TESTFunction · 0.85

Calls 3

GeometryTypeToWKBFunction · 0.85
dataMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected