MCPcopy Create free account
hub / github.com/OSGeo/gdal / LoadArray

Method LoadArray

frmts/zarr/zarr_v2_array.cpp:1413–2129  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1411/************************************************************************/
1412
1413std::shared_ptr<ZarrArray>
1414ZarrV2Group::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,

Callers

nothing calls this directly

Calls 15

CPLErrorFunction · 0.85
CPLFormFilenameSafeFunction · 0.85
CPLGetDirnameSafeFunction · 0.85
CPLSPrintfFunction · 0.85
CPLHasPathTraversalFunction · 0.85
VSIStatLFunction · 0.85
CPLJSONObjectClass · 0.85
CPLGetPathSafeFunction · 0.85
moveFunction · 0.85
ParseDtypeFunction · 0.85
SetGDALOffsetFunction · 0.85
CPLGetValueTypeFunction · 0.85

Tested by

no test coverage detected