| 208 | } // namespace |
| 209 | |
| 210 | std::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 | |
| 238 | std::optional<std::pair<double, double>> GetWKBPointCoordinateXY(const ByteArray& value) { |
| 239 | if (value.len != kWkbPointXYSize) { |
no test coverage detected