MCPcopy Create free account
hub / github.com/Project-OSRM/osrm-backend / Execute

Method Execute

src/nodejs/node_osrm.cpp:134–177  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

132 }
133
134 void Execute() override
135 try
136 {
137 switch (
138 params->format.value_or(osrm::engine::api::BaseParameters::OutputFormatType::JSON))
139 {
140 case osrm::engine::api::BaseParameters::OutputFormatType::JSON:
141 {
142 osrm::engine::api::ResultT r;
143 r = osrm::util::json::Object();
144 const auto status = ((*osrm).*(service))(*params, r);
145 auto &json_result = std::get<osrm::json::Object>(r);
146 ParseResult(status, json_result);
147 if (pluginParams.renderToBuffer)
148 {
149 std::string json_string;
150 osrm::util::json::render(json_string, json_result);
151 result = std::move(json_string);
152 }
153 else
154 {
155 result = std::move(json_result);
156 }
157 }
158 break;
159 case osrm::engine::api::BaseParameters::OutputFormatType::FLATBUFFERS:
160 {
161 osrm::engine::api::ResultT r = flatbuffers::FlatBufferBuilder();
162 const auto status = ((*osrm).*(service))(*params, r);
163 const auto &fbs_result = std::get<flatbuffers::FlatBufferBuilder>(r);
164 ParseResult(status, fbs_result);
165 BOOST_ASSERT(pluginParams.renderToBuffer);
166 std::string result_str(
167 reinterpret_cast<const char *>(fbs_result.GetBufferPointer()),
168 fbs_result.GetSize());
169 result = std::move(result_str);
170 }
171 break;
172 }
173 }
174 catch (const std::exception &e)
175 {
176 SetError(e.what());
177 }
178
179 void OnOK() override
180 {

Callers

nothing calls this directly

Calls 5

ParseResultFunction · 0.85
GetSizeMethod · 0.80
whatMethod · 0.80
ObjectClass · 0.50
renderFunction · 0.50

Tested by

no test coverage detected