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

Function parsePipeline

pdal/PipelineReaderJSON.cpp:66–160  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

64void handleInputTag(const std::string& tag, const TagMap& tags, std::vector<Stage *>& inputs);
65
66void parsePipeline(NL::json& tree, PipelineManager& manager)
67{
68 TagMap tags;
69 std::vector<Stage*> inputs;
70
71 size_t last = tree.size() - 1;
72 for (size_t i = 0; i < tree.size(); ++i)
73 {
74 NL::json& node = tree.at(i);
75
76 FileSpec spec;
77 std::string tag;
78 std::string type;
79 std::vector<Stage*> specifiedInputs;
80 Options options;
81
82 // strings are assumed to be filenames
83 if (node.is_string())
84 {
85 spec.ingest(node.get<std::string>());
86 }
87 else
88 {
89 type = extractType(node);
90 spec = extractFilename(node);
91 tag = extractTag(node, tags);
92 specifiedInputs = extractInputs(node, tags);
93 if (!specifiedInputs.empty())
94 inputs = specifiedInputs;
95 options = extractOptions(node);
96 }
97
98 Stage *s = nullptr;
99
100 // The type is inferred from a filename as a reader if it's not
101 // the last stage or if there's only one.
102 if ((type.empty() && (i == 0 || i != last)) ||
103 Utils::startsWith(type, "readers."))
104 {
105 StringList files = Utils::glob(spec.u8string());
106 if (files.empty())
107 files.push_back(spec.u8string());
108
109 for (const std::string& path : files)
110 {
111 spec.setFilePath(path);
112 ReaderCreationOptions ops { spec, type, nullptr, options, tag };
113 s = &manager.makeReader(ops);
114
115 if (specifiedInputs.size())
116 throw pdal_error("JSON pipeline: Inputs not permitted for "
117 " reader: '" + path + "'.");
118 inputs.push_back(s);
119 }
120 }
121 else if (type.empty() || Utils::startsWith(type, "writers."))
122 {
123 StageCreationOptions ops { spec.u8string(), type, nullptr, options, tag };

Callers 1

readPipelineMethod · 0.85

Calls 15

extractTypeFunction · 0.85
extractFilenameFunction · 0.85
extractTagFunction · 0.85
extractInputsFunction · 0.85
extractOptionsFunction · 0.85
startsWithFunction · 0.85
atMethod · 0.80
ingestMethod · 0.80
u8stringMethod · 0.80
setFilePathMethod · 0.80
makeReaderMethod · 0.80
leavesMethod · 0.80

Tested by

no test coverage detected