MCPcopy Create free account
hub / github.com/Kitware/VTK / _exportToJSON

Method _exportToJSON

ThirdParty/libproj/vtklibproj/src/iso19111/common.cpp:255–299  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

253// ---------------------------------------------------------------------------
254
255void UnitOfMeasure::_exportToJSON(
256 JSONFormatter *formatter) const // throw(FormattingException)
257{
258 auto writer = formatter->writer();
259 const auto &l_codeSpace = codeSpace();
260 auto objContext(
261 formatter->MakeObjectContext(nullptr, !l_codeSpace.empty()));
262 writer->AddObjKey("type");
263 const auto l_type = type();
264 if (l_type == Type::LINEAR) {
265 writer->Add("LinearUnit");
266 } else if (l_type == Type::ANGULAR) {
267 writer->Add("AngularUnit");
268 } else if (l_type == Type::SCALE) {
269 writer->Add("ScaleUnit");
270 } else if (l_type == Type::TIME) {
271 writer->Add("TimeUnit");
272 } else if (l_type == Type::PARAMETRIC) {
273 writer->Add("ParametricUnit");
274 } else {
275 writer->Add("Unit");
276 }
277
278 writer->AddObjKey("name");
279 const auto &l_name = name();
280 writer->Add(l_name);
281
282 const auto &factor = conversionToSI();
283 writer->AddObjKey("conversion_factor");
284 writer->Add(factor, 15);
285
286 if (!l_codeSpace.empty() && formatter->outputId()) {
287 writer->AddObjKey("id");
288 auto idContext(formatter->MakeObjectContext(nullptr, false));
289 writer->AddObjKey("authority");
290 writer->Add(l_codeSpace);
291 writer->AddObjKey("code");
292 const auto &l_code = code();
293 try {
294 writer->Add(std::stoi(l_code));
295 } catch (const std::exception &) {
296 writer->Add(l_code);
297 }
298 }
299}
300
301//! @endcond
302

Callers 2

formatIDMethod · 0.45
baseExportToJSONMethod · 0.45

Calls 15

AddObjKeyMethod · 0.80
outputIdMethod · 0.80
has_valueMethod · 0.80
southBoundLatitudeMethod · 0.80
westBoundLongitudeMethod · 0.80
northBoundLatitudeMethod · 0.80
eastBoundLongitudeMethod · 0.80
typeEnum · 0.50
nameClass · 0.50
codeEnum · 0.50
writerMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected