From 22792cd55ba41ffadb248c246cc871612a5139c1 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Fri, 6 Dec 2019 18:03:14 +0100 Subject: Add a Grid base class for HorizontalShiftGrid and VerticalShiftGrid --- src/grids.hpp | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) (limited to 'src/grids.hpp') diff --git a/src/grids.hpp b/src/grids.hpp index 975f7716..65bf502b 100644 --- a/src/grids.hpp +++ b/src/grids.hpp @@ -49,26 +49,36 @@ struct ExtentAndRes { // --------------------------------------------------------------------------- -class VerticalShiftGrid { +class Grid { protected: int m_width; int m_height; ExtentAndRes m_extent; - std::vector> m_children{}; + + Grid(int widthIn, int heightIn, const ExtentAndRes &extentIn); public: - VerticalShiftGrid(int widthIn, int heightIn, const ExtentAndRes &extentIn); - virtual ~VerticalShiftGrid(); + virtual ~Grid(); int width() const { return m_width; } int height() const { return m_height; } const ExtentAndRes &extentAndRes() const { return m_extent; } + virtual bool isNullGrid() const { return false; } +}; + +// --------------------------------------------------------------------------- + +class VerticalShiftGrid : public Grid { + protected: + std::vector> m_children{}; + + public: + VerticalShiftGrid(int widthIn, int heightIn, const ExtentAndRes &extentIn); + const VerticalShiftGrid *gridAt(double lon, double lat) const; - virtual bool isNodata(float /*val*/, double /* multiplier */) const { - return false; - } + virtual bool isNodata(float /*val*/, double /* multiplier */) const; // x = 0 is western-most column, y = 0 is southern-most line virtual bool valueAt(int x, int y, float &out) const = 0; @@ -99,26 +109,17 @@ class VerticalShiftGridSet { // --------------------------------------------------------------------------- -class HorizontalShiftGrid { +class HorizontalShiftGrid : public Grid { protected: - int m_width; - int m_height; - ExtentAndRes m_extent; std::vector> m_children{}; public: HorizontalShiftGrid(int widthIn, int heightIn, const ExtentAndRes &extentIn); - virtual ~HorizontalShiftGrid(); - - int width() const { return m_width; } - int height() const { return m_height; } - const ExtentAndRes &extentAndRes() const { return m_extent; } + ~HorizontalShiftGrid() override; const HorizontalShiftGrid *gridAt(double lon, double lat) const; - virtual bool isNullGrid() const { return false; } - // x = 0 is western-most column, y = 0 is southern-most line virtual bool valueAt(int x, int y, float &lonShift, float &latShift) const = 0; -- cgit v1.2.3