LCOV - code coverage report
Current view: directory - frmts/wms - wmsdriver.h (source / functions) Found Hit Coverage
Test: gdal_filtered.info Lines: 2 2 100.0 %
Date: 2010-01-09 Functions: 1 1 100.0 %

       1                 : /******************************************************************************
       2                 :  * $Id: wmsdriver.h 18020 2009-11-14 14:33:20Z rouault $
       3                 :  *
       4                 :  * Project:  WMS Client Driver
       5                 :  * Purpose:  Implementation of Dataset and RasterBand classes for WMS
       6                 :  *           and other similar services.
       7                 :  * Author:   Adam Nowacki, nowak@xpam.de
       8                 :  *
       9                 :  ******************************************************************************
      10                 :  * Copyright (c) 2007, Adam Nowacki
      11                 :  *
      12                 :  * Permission is hereby granted, free of charge, to any person obtaining a
      13                 :  * copy of this software and associated documentation files (the "Software"),
      14                 :  * to deal in the Software without restriction, including without limitation
      15                 :  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
      16                 :  * and/or sell copies of the Software, and to permit persons to whom the
      17                 :  * Software is furnished to do so, subject to the following conditions:
      18                 :  *
      19                 :  * The above copyright notice and this permission notice shall be included
      20                 :  * in all copies or substantial portions of the Software.
      21                 :  *
      22                 :  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
      23                 :  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
      24                 :  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
      25                 :  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
      26                 :  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
      27                 :  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
      28                 :  * DEALINGS IN THE SOFTWARE.
      29                 :  ****************************************************************************/
      30                 : 
      31                 : class GDALWMSDataset;
      32                 : class GDALWMSRasterBand;
      33                 : 
      34                 : CPLString MD5String(const char *s);
      35                 : CPLString ProjToWKT(const CPLString &proj);
      36                 : void URLAppend(CPLString *url, const char *s);
      37                 : void URLAppendF(CPLString *url, const char *s, ...);
      38                 : void URLAppend(CPLString *url, const CPLString &s);
      39                 : CPLString BufferToVSIFile(GByte *buffer, size_t size);
      40                 : CPLErr MakeDirs(const char *path);
      41                 : int StrToBool(const char *p);
      42                 : int URLSearchAndReplace (CPLString *base, const char *search, const char *fmt, ...);
      43                 : 
      44                 : /* Convert a.b.c.d to a * 0x1000000 + b * 0x10000 + c * 0x100 + d */
      45                 : int VersionStringToInt(const char *version);
      46                 : 
      47                 : 
      48                 : class GDALWMSImageRequestInfo {
      49                 : public:
      50                 :     double m_x0, m_y0;
      51                 :     double m_x1, m_y1;
      52                 :     int m_sx, m_sy;
      53                 : };
      54                 : 
      55                 : class GDALWMSDataWindow {
      56                 : public:
      57                 :     double m_x0, m_y0;
      58                 :     double m_x1, m_y1;
      59                 :     int m_sx, m_sy;
      60                 :     int m_tx, m_ty, m_tlevel;
      61                 :     enum { BOTTOM = -1, DEFAULT = 0, TOP = 1 } m_y_origin;
      62                 : };
      63                 : 
      64                 : class GDALWMSTiledImageRequestInfo {
      65                 : public:
      66                 :     int m_x, m_y;
      67                 :     int m_level;
      68                 : };
      69                 : 
      70                 : class GDALWMSRasterIOHint {
      71                 : public:
      72                 :     int m_x0, m_y0;
      73                 :     int m_sx, m_sy;
      74                 :     int m_overview;
      75                 :     bool m_valid;
      76                 : };
      77                 : 
      78                 : class GDALWMSMiniDriverCapabilities {
      79                 : public:
      80                 : /* Version N capabilities require all version N and earlier variables to be set to correct values */
      81                 :     int m_capabilities_version;
      82                 : 
      83                 : /* Version 1 capabilities */
      84                 :     int m_has_image_request;            // 1 if ImageRequest method is implemented
      85                 :     int m_has_tiled_image_requeset;     // 1 if TiledImageRequest method is implemented
      86                 :     int m_has_arb_overviews;            // 1 if ImageRequest method supports arbitrary overviews / resolutions
      87                 :     int m_max_overview_count;               // Maximum number of overviews supported if known, -1 otherwise
      88                 : };
      89                 : 
      90                 : /* All data returned by mini-driver as pointer should remain valid for mini-driver lifetime
      91                 :    and should be freed by mini-driver destructor unless otherwise specified. */
      92                 : class GDALWMSMiniDriver {
      93                 : friend class GDALWMSDataset;
      94                 : public:
      95                 :     GDALWMSMiniDriver();
      96                 :     virtual ~GDALWMSMiniDriver();
      97                 : 
      98                 : public:
      99                 : /* Read mini-driver specific configuration. */
     100                 :     virtual CPLErr Initialize(CPLXMLNode *config);
     101                 : 
     102                 : public:
     103                 :     virtual void GetCapabilities(GDALWMSMiniDriverCapabilities *caps);
     104                 :     virtual void ImageRequest(CPLString *url, const GDALWMSImageRequestInfo &iri);
     105                 :     virtual void TiledImageRequest(CPLString *url, const GDALWMSImageRequestInfo &iri, const GDALWMSTiledImageRequestInfo &tiri);
     106                 : 
     107                 : /* Return data projection in WKT format, NULL or empty string if unknown */
     108                 :     virtual const char *GetProjectionInWKT();
     109                 : 
     110                 : protected:
     111                 :     GDALWMSDataset *m_parent_dataset;
     112                 : };
     113                 : 
     114                 : class GDALWMSMiniDriverFactory {
     115                 : public:
     116                 :     GDALWMSMiniDriverFactory();
     117                 :     virtual ~GDALWMSMiniDriverFactory();
     118                 : 
     119                 : public:
     120                 :     virtual GDALWMSMiniDriver* New() = 0;
     121                 :     virtual void Delete(GDALWMSMiniDriver *instance) = 0;
     122                 : 
     123                 : public:
     124              12 :     const CPLString &GetName() {
     125              12 :         return m_name;
     126                 :     }
     127                 : 
     128                 : protected:
     129                 :     CPLString m_name;
     130                 : };
     131                 : 
     132                 : class GDALWMSMiniDriverManager {
     133                 : public:
     134                 :     GDALWMSMiniDriverManager();
     135                 :     ~GDALWMSMiniDriverManager();
     136                 : 
     137                 : public:
     138                 :     void Register(GDALWMSMiniDriverFactory *mdf);
     139                 :     GDALWMSMiniDriverFactory *Find(const CPLString &name);
     140                 : 
     141                 : protected:
     142                 :     std::list<GDALWMSMiniDriverFactory *> m_mdfs;
     143                 : };
     144                 : 
     145                 : #define H_GDALWMSMiniDriverFactory(name) \
     146                 : class GDALWMSMiniDriverFactory_##name : public GDALWMSMiniDriverFactory { \
     147                 : public: \
     148                 :     GDALWMSMiniDriverFactory_##name(); \
     149                 :     virtual ~GDALWMSMiniDriverFactory_##name(); \
     150                 :     \
     151                 : public: \
     152                 :     virtual GDALWMSMiniDriver* New(); \
     153                 :     virtual void Delete(GDALWMSMiniDriver *instance); \
     154                 : };
     155                 : 
     156                 : #define CPP_GDALWMSMiniDriverFactory(name) \
     157                 :     GDALWMSMiniDriverFactory_##name::GDALWMSMiniDriverFactory_##name() { \
     158                 :     m_name = #name;\
     159                 : } \
     160                 :     \
     161                 :     GDALWMSMiniDriverFactory_##name::~GDALWMSMiniDriverFactory_##name() { \
     162                 : } \
     163                 :     \
     164                 :     GDALWMSMiniDriver* GDALWMSMiniDriverFactory_##name::New() { \
     165                 :     return new GDALWMSMiniDriver_##name(); \
     166                 : } \
     167                 :     \
     168                 :     void GDALWMSMiniDriverFactory_##name::Delete(GDALWMSMiniDriver *instance) { \
     169                 :     delete instance; \
     170                 : }
     171                 : 
     172                 : class GDALWMSCache {
     173                 : public:
     174                 :     GDALWMSCache();
     175                 :     ~GDALWMSCache();
     176                 : 
     177                 : public:
     178                 :     CPLErr Initialize(CPLXMLNode *config);
     179                 :     CPLErr Write(const char *key, const CPLString &file_name);
     180                 :     CPLErr Read(const char *key, CPLString *file_name);
     181                 : 
     182                 : protected:
     183                 :     CPLString KeyToCacheFile(const char *key);
     184                 : 
     185                 : protected:
     186                 :     CPLString m_cache_path;
     187                 :     CPLString m_postfix;
     188                 :     int m_cache_depth;
     189                 : };
     190                 : 
     191                 : class GDALWMSDataset : public GDALPamDataset {
     192                 :     friend class GDALWMSRasterBand;
     193                 :     friend GDALDataset *GDALWMSDatasetOpen(GDALOpenInfo *poOpenInfo);
     194                 : 
     195                 : public:
     196                 :     GDALWMSDataset();
     197                 :     virtual ~GDALWMSDataset();
     198                 : 
     199                 : public:
     200                 :     virtual const char *GetProjectionRef();
     201                 :     virtual CPLErr SetProjection(const char *proj);
     202                 :     virtual CPLErr GetGeoTransform(double *gt);
     203                 :     virtual CPLErr SetGeoTransform(double *gt);
     204                 :     virtual CPLErr AdviseRead(int x0, int y0, int sx, int sy, int bsx, int bsy, GDALDataType bdt, int band_count, int *band_map, char **options);
     205                 : 
     206                 : protected:
     207                 :     virtual CPLErr IRasterIO(GDALRWFlag rw, int x0, int y0, int sx, int sy, void *buffer, int bsx, int bsy, GDALDataType bdt, int band_count, int *band_map, int pixel_space, int line_space, int band_space);
     208                 : 
     209                 : protected:
     210                 :     CPLErr Initialize(CPLXMLNode *config);
     211                 : 
     212                 : public:
     213                 :     const GDALWMSDataWindow *WMSGetDataWindow() const;
     214                 :     int WMSGetBlockSizeX() const;
     215                 :     int WMSGetBlockSizeY() const;
     216                 : 
     217                 : protected:
     218                 :     GDALWMSDataWindow m_data_window;
     219                 :     GDALWMSMiniDriver *m_mini_driver;
     220                 :     GDALWMSMiniDriverCapabilities m_mini_driver_caps;
     221                 :     GDALWMSCache *m_cache;
     222                 :     CPLString m_projection;
     223                 :     int m_overview_count;
     224                 :     GDALDataType m_data_type;
     225                 :     int m_block_size_x, m_block_size_y;
     226                 :     GDALWMSRasterIOHint m_hint;
     227                 :     int m_use_advise_read;
     228                 :     int m_verify_advise_read;
     229                 :     int m_offline_mode;
     230                 :     int m_http_max_conn;
     231                 :     int m_http_timeout;
     232                 :     int m_clamp_requests;
     233                 : };
     234                 : 
     235                 : class GDALWMSRasterBand : public GDALPamRasterBand {
     236                 :     friend class GDALWMSDataset;
     237                 : 
     238                 : public:
     239                 :     GDALWMSRasterBand(GDALWMSDataset *parent_dataset, int band, double scale);
     240                 :     virtual ~GDALWMSRasterBand();
     241                 : 
     242                 : public:
     243                 :     virtual CPLErr AdviseRead(int x0, int y0, int sx, int sy, int bsx, int bsy, GDALDataType bdt, char **options);
     244                 : 
     245                 : protected:
     246                 :     CPLErr ReadBlocks(int x, int y, void *buffer, int bx0, int by0, int bx1, int by1, int advise_read);
     247                 :     virtual CPLErr IReadBlock(int x, int y, void *buffer);
     248                 :     virtual CPLErr IRasterIO(GDALRWFlag rw, int x0, int y0, int sx, int sy, void *buffer, int bsx, int bsy, GDALDataType bdt, int pixel_space, int line_space);
     249                 :     virtual int HasArbitraryOverviews();
     250                 :     virtual int GetOverviewCount();
     251                 :     virtual GDALRasterBand *GetOverview(int n);
     252                 :     void AddOverview(double scale);
     253                 :     bool IsBlockInCache(int x, int y);
     254                 :     void AskMiniDriverForBlock(CPLString *url, int x, int y);
     255                 :     CPLErr ReadBlockFromFile(int x, int y, const char *file_name, int to_buffer_band, void *buffer, int advise_read);
     256                 :     CPLErr ZeroBlock(int x, int y, int to_buffer_band, void *buffer);
     257                 :     CPLErr ReportWMSException(const char *file_name);
     258                 : 
     259                 : protected:
     260                 :     GDALWMSDataset *m_parent_dataset;
     261                 :     double m_scale;
     262                 :     std::vector<GDALWMSRasterBand *> m_overviews;
     263                 :     int m_overview;
     264                 : };
     265                 : 
     266                 : GDALDataset *GDALWMSDatasetOpen(GDALOpenInfo *poOpenInfo);
     267                 : GDALWMSMiniDriverManager *GetGDALWMSMiniDriverManager();
     268                 : void DestroyWMSMiniDriverManager(void);

Generated by: LCOV version 1.7