| 60 | } |
| 61 | |
| 62 | bool ItemCollection::init(const Filters& filters, NL::json rawReaderArgs, |
| 63 | SchemaUrls schemaUrls) |
| 64 | { |
| 65 | const NL::json itemList = stacValue(m_json, "features"); |
| 66 | for (const NL::json& itemJson: itemList) |
| 67 | { |
| 68 | Item item(itemJson, m_path, m_connector, m_validate); |
| 69 | if (item.init(*filters.itemFilters, rawReaderArgs, schemaUrls)) |
| 70 | { |
| 71 | m_itemList.push_back(item); |
| 72 | } |
| 73 | } |
| 74 | if (m_json.contains("links")) |
| 75 | { |
| 76 | const NL::json links = stacValue(m_json, "links"); |
| 77 | for (const NL::json& link: links) |
| 78 | { |
| 79 | std::string target = stacValue<std::string>( |
| 80 | link, "rel", m_json); |
| 81 | if (target == "next") |
| 82 | { |
| 83 | std::string nextLinkPath = stacValue<std::string>( |
| 84 | link, "href", m_json); |
| 85 | std::string nextAbsPath = |
| 86 | handleRelativePath(m_path, nextLinkPath); |
| 87 | NL::json nextJson = m_connector.getJson(nextAbsPath); |
| 88 | |
| 89 | ItemCollection ic(nextJson, nextAbsPath, m_connector, m_validate); |
| 90 | |
| 91 | if (ic.init(filters, rawReaderArgs, schemaUrls)) |
| 92 | for (auto& item: ic.items()) |
| 93 | m_itemList.push_back(item); |
| 94 | } |
| 95 | } |
| 96 | } |
| 97 | return true; |
| 98 | } |
| 99 | |
| 100 | }//stac |
| 101 |
nothing calls this directly
no test coverage detected