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

Method validate

io/private/stac/Collection.cpp:50–95  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

48Collection::~Collection() {}
49
50void Collection::validate() {
51 nlohmann::json_schema::json_validator val(
52 [this](const nlohmann::json_uri& json_uri, nlohmann::json& json) {
53 json = m_connector.getJson(json_uri.url());
54 },
55 [](const std::string &, const std::string &) {}
56 );
57
58 // Validate against base Collection schema first
59 NL::json schemaJson = m_connector.getJson(m_schemaUrls.collection);
60 val.set_root_schema(schemaJson);
61 try {
62 val.validate(m_json);
63 }
64 catch (std::exception &e)
65 {
66 throw stac_error(m_id, "collection",
67 "STAC schema validation Error in root schema: " +
68 m_schemaUrls.collection + ". \n\n" + e.what());
69 }
70
71 // Validate against stac extensions if present
72 if (m_json.contains("stac_extensions"))
73 {
74 NL::json extensions = stacValue(m_json, "stac_extensions");
75 for (auto& extSchemaUrl: extensions)
76 {
77 std::string url = stacValue<std::string>(extSchemaUrl,
78 "", m_json);
79
80 try {
81 NL::json schemaJson = m_connector.getJson(url);
82 val.set_root_schema(schemaJson);
83 val.validate(m_json);
84 }
85 catch (std::exception& e) {
86 std::string msg =
87 "STAC Validation Error in extension: " + url +
88 ". Errors found: \n" + e.what();
89 throw stac_error(m_id, "collection", msg);
90
91 }
92 }
93
94 }
95}
96
97
98}//stac

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected