LCOV - code coverage report
Current view: top level - gcore - tilematrixset.hpp (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 15 15 100.0 %
Date: 2024-05-03 15:49:35 Functions: 8 8 100.0 %

          Line data    Source code
       1             : /******************************************************************************
       2             :  *
       3             :  * Project:  GDAL
       4             :  * Purpose:  Class to handle TileMatrixSet
       5             :  * Author:   Even Rouault, <even dot rouault at spatialys.com>
       6             :  *
       7             :  ******************************************************************************
       8             :  * Copyright (c) 2020, Even Rouault <even dot rouault at spatialys.com>
       9             :  *
      10             :  * Permission is hereby granted, free of charge, to any person obtaining a
      11             :  * copy of this software and associated documentation files (the "Software"),
      12             :  * to deal in the Software without restriction, including without limitation
      13             :  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
      14             :  * and/or sell copies of the Software, and to permit persons to whom the
      15             :  * Software is furnished to do so, subject to the following conditions:
      16             :  *
      17             :  * The above copyright notice and this permission notice shall be included
      18             :  * in all copies or substantial portions of the Software.
      19             :  *
      20             :  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
      21             :  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
      22             :  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
      23             :  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
      24             :  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
      25             :  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
      26             :  * DEALINGS IN THE SOFTWARE.
      27             :  ****************************************************************************/
      28             : 
      29             : #ifndef TILEMATRIXSET_HPP_INCLUDED
      30             : #define TILEMATRIXSET_HPP_INCLUDED
      31             : 
      32             : #include "cpl_port.h"
      33             : 
      34             : #include <memory>
      35             : #include <limits>
      36             : #include <set>
      37             : #include <string>
      38             : #include <vector>
      39             : 
      40             : //! @cond Doxygen_Suppress
      41             : 
      42             : namespace gdal
      43             : {
      44             : 
      45             : class CPL_DLL TileMatrixSet
      46             : {
      47             :     static constexpr double NaN = std::numeric_limits<double>::quiet_NaN();
      48             : 
      49             :   public:
      50           2 :     const std::string &identifier() const
      51             :     {
      52           2 :         return mIdentifier;
      53             :     }
      54             : 
      55           2 :     const std::string &title() const
      56             :     {
      57           2 :         return mTitle;
      58             :     }
      59             : 
      60             :     //! "abstract" in TMS v1 / "description" in TMS v2
      61           2 :     const std::string &abstract() const
      62             :     {
      63           2 :         return mAbstract;
      64             :     }
      65             : 
      66             :     struct CPL_DLL BoundingBox
      67             :     {
      68             :         std::string mCrs{};
      69             :         double mLowerCornerX{NaN};
      70             :         double mLowerCornerY{NaN};
      71             :         double mUpperCornerX{NaN};
      72             :         double mUpperCornerY{NaN};
      73             :     };
      74             : 
      75          32 :     const BoundingBox &bbox() const
      76             :     {
      77          32 :         return mBbox;
      78             :     }
      79             : 
      80         236 :     const std::string &crs() const
      81             :     {
      82         236 :         return mCrs;
      83             :     }
      84             : 
      85           2 :     const std::string &wellKnownScaleSet() const
      86             :     {
      87           2 :         return mWellKnownScaleSet;
      88             :     }
      89             : 
      90             :     struct CPL_DLL TileMatrix
      91             :     {
      92             :         std::string mId{};
      93             :         double mScaleDenominator{NaN};
      94             :         double mResX{
      95             :             NaN};  // computed from mScaleDenominator and CRS definition
      96             :         double mResY{
      97             :             NaN};  // computed from mScaleDenominator and CRS definition
      98             :         double mTopLeftX{NaN};
      99             :         double mTopLeftY{NaN};
     100             :         int mTileWidth{};
     101             :         int mTileHeight{};
     102             :         int mMatrixWidth{};
     103             :         int mMatrixHeight{};
     104             : 
     105             :         struct CPL_DLL VariableMatrixWidth
     106             :         {
     107             :             int mCoalesce{};
     108             :             int mMinTileRow{};
     109             :             int mMaxTileRow{};
     110             :         };
     111             : 
     112             :         std::vector<VariableMatrixWidth> mVariableMatrixWidthList{};
     113             :     };
     114             : 
     115         168 :     const std::vector<TileMatrix> &tileMatrixList() const
     116             :     {
     117         168 :         return mTileMatrixList;
     118             :     }
     119             : 
     120             :     /** Parse a TileMatrixSet definition, passed inline or by filename,
     121             :      * corresponding to the JSON encoding of the OGC Two Dimensional Tile Matrix
     122             :      * Set: http://docs.opengeospatial.org/is/17-083r2/17-083r2.html */
     123             :     static std::unique_ptr<TileMatrixSet> parse(const char *fileOrDef);
     124             : 
     125             :     /** Return hardcoded tile matrix set names (such as GoogleMapsCompatible),
     126             :      * as well as XXX for each tms_XXXX.json in GDAL data directory */
     127             :     static std::set<std::string> listPredefinedTileMatrixSets();
     128             : 
     129             :     bool haveAllLevelsSameTopLeft() const;
     130             : 
     131             :     bool haveAllLevelsSameTileSize() const;
     132             : 
     133             :     bool hasOnlyPowerOfTwoVaryingScales() const;
     134             : 
     135             :     bool hasVariableMatrixWidth() const;
     136             : 
     137             :   private:
     138         415 :     TileMatrixSet() = default;
     139             : 
     140             :     std::string mIdentifier{};
     141             :     std::string mTitle{};
     142             :     std::string mAbstract{};
     143             :     BoundingBox mBbox{};
     144             :     std::string mCrs{};
     145             :     std::string mWellKnownScaleSet{};
     146             :     std::vector<TileMatrix> mTileMatrixList{};
     147             : };
     148             : 
     149             : }  // namespace gdal
     150             : 
     151             : //! @endcond
     152             : 
     153             : #endif  // TILEMATRIXSET_HPP_INCLUDED

Generated by: LCOV version 1.14