MCPcopy Create free account
hub / github.com/OSGeo/PROJ / _exportToJSON

Method _exportToJSON

src/iso19111/common.cpp:256–300  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 2

formatIDMethod · 0.45
baseExportToJSONMethod · 0.45

Calls 15

writerMethod · 0.80
AddObjKeyMethod · 0.80
AddMethod · 0.80
outputIdMethod · 0.80
has_valueMethod · 0.80
sizeMethod · 0.80
southBoundLatitudeMethod · 0.80
westBoundLongitudeMethod · 0.80
northBoundLatitudeMethod · 0.80
eastBoundLongitudeMethod · 0.80
minimumValueMethod · 0.80
maximumValueMethod · 0.80

Tested by

no test coverage detected