45342 {
45343
45344
45346
45347 unique_ptr<CoordinateReferenceSystem> duckdb_crs;
45348
45349 if (!extension_metadata.empty()) {
45351 duckdb_yyjson::yyjson_read(extension_metadata.data(), extension_metadata.size(),
45352 duckdb_yyjson::YYJSON_READ_NOFLAG),
45353 duckdb_yyjson::yyjson_doc_free);
45354 if (!doc) {
45355 throw SerializationException("Invalid JSON in GeoArrow metadata");
45356 }
45357
45359 if (!yyjson_is_obj(val)) {
45360 throw SerializationException("Invalid GeoArrow metadata: not a JSON object");
45361 }
45362
45364 if (edges && yyjson_is_str(edges) && std::strcmp(yyjson_get_str(edges), "planar") != 0) {
45365 throw NotImplementedException("Can't import non-planar edges");
45366 }
45367
45368
45370
45371 if (crs) {
45372 if (duckdb_yyjson::yyjson_is_str(crs)) {
45373 const char *crs_str = duckdb_yyjson::yyjson_get_str(crs);
45375 } else if (duckdb_yyjson::yyjson_is_obj(crs)) {
45376
45377 duckdb_yyjson::yyjson_write_flag write_flags = duckdb_yyjson::YYJSON_WRITE_NOFLAG;
45378 size_t len = 0;
45379 const auto crs_str = duckdb_yyjson::yyjson_val_write(crs, write_flags, &len);
45380 if (crs_str) {
45381 const auto str = string(crs_str, len);
45382 free(crs_str);
45384 } else {
45385 throw SerializationException("Could not serialize CRS object from GeoArrow metadata");
45386 }
45387 }
45388 }
45389 }
45390
45391
45392 auto geo_type = duckdb_crs ? LogicalType::GEOMETRY(*duckdb_crs) : LogicalType::GEOMETRY();
45393
45394 const auto format = string(schema.
format);
45395 if (format == "z") {
45396 return make_uniq<ArrowType>(std::move(geo_type), make_uniq<ArrowStringInfo>(ArrowVariableSizeType::NORMAL));
45397 }
45398 if (format == "Z") {
45399 return make_uniq<ArrowType>(std::move(geo_type),
45400 make_uniq<ArrowStringInfo>(ArrowVariableSizeType::SUPER_SIZE));
45401 }
45402 if (format == "vz") {
45403 return make_uniq<ArrowType>(std::move(geo_type), make_uniq<ArrowStringInfo>(ArrowVariableSizeType::VIEW));
45404 }
45405 throw InvalidInputException("Arrow extension type \"%s\" not supported for geoarrow.wkb", format.c_str());
45406 }
static unique_ptr< CoordinateReferenceSystem > TryIdentify(ClientContext &context, const string &source_crs)
const char * format
Array type description.
Definition duckdb.hpp:11265
Definition duckdb.cpp:41548
Definition duckdb.cpp:41543