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

Method extractMetadata

filters/StatsFilter.cpp:63–134  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

61
62
63void Summary::extractMetadata(MetadataNode &m)
64{
65 uint32_t cnt = static_cast<uint32_t>(count());
66 m.add("count", cnt, "count");
67 m.add("minimum", minimum(), "minimum");
68 m.add("maximum", maximum(), "maximum");
69 m.add("average", average(), "average");
70
71 double std = sampleStddev();
72 if (!std::isinf(std) && !std::isnan(std))
73 m.add("stddev", std, "standard deviation");
74
75 double v = sampleVariance();
76 if (!std::isinf(v) && !std::isnan(v))
77 m.add("variance", v, "variance");
78 m.add("name", m_name, "name");
79
80 if (m_advanced)
81 {
82 double k = sampleExcessKurtosis();
83 if (!std::isinf(k) && !std::isnan(k))
84 m.add("kurtosis", k, "kurtosis");
85
86 double sk = sampleSkewness();
87 if (!std::isinf(sk) && !std::isnan(sk))
88 m.add("skewness", sampleSkewness(), "skewness");
89 }
90
91 if (m_enumerate == Enumerate)
92 {
93 for (auto& v : m_values)
94 m.addList("values", v.first);
95 }
96 else if (m_enumerate == Global)
97 {
98 computeGlobalStats();
99 m.add("median", m_median);
100 m.add("mad", m_mad);
101 }
102 else if (m_enumerate == Count)
103 {
104 // For some reason we first started adding 'counts' items that look like this:
105 //
106 // "counts":
107 // [
108 // "1.000000/108",
109 // "7.000000/24",
110 // "9.000000/122704"
111 // ]
112
113 // But these are hard to use and require custom parsing. They aren't JSON. Why aren't
114 // they JSON?
115 //
116 // I'm adding a "bins" parameter that at least won't require custom parsing, but
117 // we are not simply replacing "counts" because people could now be parsing the silly
118 // things.
119 //
120 // "bins":

Callers

nothing calls this directly

Calls 15

minimumFunction · 0.85
maximumFunction · 0.85
averageFunction · 0.85
sampleStddevFunction · 0.85
sampleVarianceFunction · 0.85
sampleExcessKurtosisFunction · 0.85
sampleSkewnessFunction · 0.85
toMetadataFunction · 0.85
jsonMethod · 0.80
countFunction · 0.70
addMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected