17 #ifndef GZ_COMMON_DATAFRAME_HH_
18 #define GZ_COMMON_DATAFRAME_HH_
25 #include <unordered_map>
41 template <
typename K,
typename V>
48 public:
bool Has(
const K &_key)
const
50 return this->storage.
count(_key) > 0;
59 return this->storage[_key];
68 return this->storage.
at(_key);
76 for (
auto &[k, _] : this->storage)
94 template <
typename K,
typename T,
typename V,
typename P>
126 if (it == header.
end())
129 sstream <<
"CSV data stream has no '"
130 << _timeColumnName <<
"' column";
133 const size_t timeIndex = it - header.
begin();
136 for (
size_t i = 0; i < _spatialColumnNames.
size(); ++i)
139 if (it == header.
end())
142 sstream <<
"CSV data stream has no '"
143 << _spatialColumnNames[i] <<
"' column";
146 spatialColumnIndices[i] = it - header.
begin();
149 return ReadFrom(_begin, _end, timeIndex, spatialColumnIndices);
167 const size_t &_timeColumnIndex = 0,
175 std::iota(dataColumnIndices.begin(), dataColumnIndices.end(), 0);
176 auto last = dataColumnIndices.end();
177 for (
size_t index : {_timeColumnIndex, _spatialColumnIndices[0],
178 _spatialColumnIndices[1], _spatialColumnIndices[2]})
180 auto it =
std::find(dataColumnIndices.begin(), last, index);
184 sstream <<
"Column index " << index <<
" is"
185 <<
"out of range for CSV data stream";
190 dataColumnIndices.erase(last, dataColumnIndices.end());
193 math::InMemoryTimeVaryingVolumetricGridFactory<T, V>;
195 for (
auto it =
std::next(_begin); it != _end; ++it)
198 const math::Vector3<P> position{
203 for (
size_t i = 0; i < dataColumnIndices.size(); ++i)
206 factories[i].AddPoint(time, position, value);
210 DataFrame<K, math::InMemoryTimeVaryingVolumetricGrid<T, V, P>> df;
211 for (
size_t i = 0; i < dataColumnIndices.size(); ++i)
214 _begin->
at(dataColumnIndices[i]) :