| 1411 | /************************************************************************/ |
| 1412 | |
| 1413 | std::shared_ptr<ZarrArray> |
| 1414 | ZarrV2Group::LoadArray(const std::string &osArrayName, |
| 1415 | const std::string &osZarrayFilename, |
| 1416 | const CPLJSONObject &oRoot, bool bLoadedFromZMetadata, |
| 1417 | const CPLJSONObject &oAttributesIn) const |
| 1418 | { |
| 1419 | // Add osZarrayFilename to m_poSharedResource during the scope |
| 1420 | // of this function call. |
| 1421 | ZarrSharedResource::SetFilenameAdder filenameAdder(m_poSharedResource, |
| 1422 | osZarrayFilename); |
| 1423 | if (!filenameAdder.ok()) |
| 1424 | return nullptr; |
| 1425 | |
| 1426 | const auto osFormat = oRoot["zarr_format"].ToString(); |
| 1427 | if (osFormat != "2") |
| 1428 | { |
| 1429 | CPLError(CE_Failure, CPLE_NotSupported, |
| 1430 | "Invalid value for zarr_format: %s", osFormat.c_str()); |
| 1431 | return nullptr; |
| 1432 | } |
| 1433 | |
| 1434 | bool bFortranOrder = false; |
| 1435 | const char *orderKey = "order"; |
| 1436 | const auto osOrder = oRoot[orderKey].ToString(); |
| 1437 | if (osOrder == "C") |
| 1438 | { |
| 1439 | // ok |
| 1440 | } |
| 1441 | else if (osOrder == "F") |
| 1442 | { |
| 1443 | bFortranOrder = true; |
| 1444 | } |
| 1445 | else |
| 1446 | { |
| 1447 | CPLError(CE_Failure, CPLE_NotSupported, "Invalid value for %s", |
| 1448 | orderKey); |
| 1449 | return nullptr; |
| 1450 | } |
| 1451 | |
| 1452 | const auto oShape = oRoot["shape"].ToArray(); |
| 1453 | if (!oShape.IsValid()) |
| 1454 | { |
| 1455 | CPLError(CE_Failure, CPLE_AppDefined, "shape missing or not an array"); |
| 1456 | return nullptr; |
| 1457 | } |
| 1458 | |
| 1459 | const char *chunksKey = "chunks"; |
| 1460 | const auto oChunks = oRoot[chunksKey].ToArray(); |
| 1461 | if (!oChunks.IsValid()) |
| 1462 | { |
| 1463 | CPLError(CE_Failure, CPLE_AppDefined, "%s missing or not an array", |
| 1464 | chunksKey); |
| 1465 | return nullptr; |
| 1466 | } |
| 1467 | |
| 1468 | if (oShape.Size() != oChunks.Size()) |
| 1469 | { |
| 1470 | CPLError(CE_Failure, CPLE_AppDefined, |
nothing calls this directly
no test coverage detected