MCPcopy Create free account
hub / github.com/PDAL/PDAL / validate

Method validate

io/private/stac/Item.cpp:157–202  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

155}
156
157void Item::validate()
158{
159
160 nlohmann::json_schema::json_validator val(
161 [this](const nlohmann::json_uri& json_uri, nlohmann::json& json) {
162 json = m_connector.getJson(json_uri.url());
163 },
164 [](const std::string &, const std::string &) {}
165 );
166
167 // Validate against base Item schema first
168 NL::json schemaJson = m_connector.getJson(m_schemaUrls.item);
169 val.set_root_schema(schemaJson);
170 try {
171 val.validate(m_json);
172 }
173 catch (std::exception &e)
174 {
175 throw stac_error(m_id, "item",
176 "STAC schema validation Error in root schema: " +
177 m_schemaUrls.item + ". \n\n" + e.what());
178 }
179
180 // Validate against stac extensions if present
181 if (m_json.contains("stac_extensions"))
182 {
183 NL::json extensions = stacValue(m_json, "stac_extensions");
184 for (auto& extSchemaUrl: extensions)
185 {
186 std::string url = stacValue<std::string>(extSchemaUrl, "", m_json);
187
188 try {
189 NL::json schemaJson = m_connector.getJson(url);
190 val.set_root_schema(schemaJson);
191 val.validate(m_json);
192 }
193 catch (std::exception& e) {
194 std::string msg =
195 "STAC Validation Error in extension: " + url +
196 ". Errors found: \n" + e.what();
197 throw stac_error(m_id, "item", msg);
198
199 }
200 }
201 }
202}
203
204void validateForFilter(NL::json json)
205{

Callers 1

initializeLocalMethod · 0.45

Calls 5

stac_errorFunction · 0.85
stacValueFunction · 0.85
getJsonMethod · 0.80
whatMethod · 0.45
containsMethod · 0.45

Tested by

no test coverage detected