From fd7d7f8a5f0fa71163333cf5476a35b5ed08c04b Mon Sep 17 00:00:00 2001 From: Michael Uleysky Date: Sun, 30 Jul 2023 17:25:34 +1000 Subject: [PATCH] Interfaces of UVData classes made more consistent with interfaces of BaseData classes --- include/uvdata.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/include/uvdata.h b/include/uvdata.h index 889b066..d98e2c8 100644 --- a/include/uvdata.h +++ b/include/uvdata.h @@ -21,6 +21,7 @@ class UVDataStorage std::vector u, v, u2; size_t nx = 0, ny = 0; Metric metric; + MString unit; UVDataStorage() = default; real D(real lon1, real lat1, real lon2, real lat2) const @@ -38,6 +39,8 @@ class UVDataStorage real Ud(size_t ix, size_t iy) const { return IsCoast(ix, iy) ? 0.0 : U(ix, iy); } real Vd(size_t ix, size_t iy) const { return IsCoast(ix, iy) ? 0.0 : V(ix, iy); } + void SetUnit(const MString& str) { unit = str; } + public: enum STPOINT { @@ -82,7 +85,22 @@ class UVDataStorage bool IsCoast(size_t i) const { return U(i) == fillval || V(i) == fillval; } bool IsCoast(size_t ix, size_t iy) const { return U(ix, iy) == fillval || V(ix, iy) == fillval; } + bool IsFill(size_t i) const { return IsCoast(i); } + bool IsFill(size_t ix, size_t iy) const { return IsCoast(ix, iy); } + static real Fillval() { return fillval; } + + const MString& Unit() const { return unit; } + + const MString DUnit() const + { + switch(metric) + { + case(Metric::EUCLID): return ""; + case(Metric::SPHERIC): return "km"; + } + return ""; + } }; template class UVDataDims; @@ -128,6 +146,7 @@ template class UVDataDims: public UVDataStor U2(i) = u(i) * u(i) + v(i) * v(i); } } + SetUnit(u.Unit()); } public: @@ -138,6 +157,9 @@ template class UVDataDims: public UVDataStor real XStep() const { return xstep; } real YStep() const { return ystep; } + + real Ix2Lon(size_t ix) const { return x0 + ix * xstep; } + real Iy2Lat(size_t iy) const { return y0 + iy * ystep; } }; template class UVDataDims: public UVDataStorage