1 /******************************************************************************
2  * $Id: wmsmetadataset.h 27044 2014-03-16 23:41:27Z rouault $
3  *
4  * Project:  WMS Client Driver
5  * Purpose:  Declaration of GDALWMSMetaDataset class
6  * Author:   Even Rouault, <even dot rouault at mines dash paris dot org>
7  *
8  ******************************************************************************
9  * Copyright (c) 2011-2013, Even Rouault <even dot rouault at mines-paris dot org>
10  *
11  * Permission is hereby granted, free of charge, to any person obtaining a
12  * copy of this software and associated documentation files (the "Software"),
13  * to deal in the Software without restriction, including without limitation
14  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
15  * and/or sell copies of the Software, and to permit persons to whom the
16  * Software is furnished to do so, subject to the following conditions:
17  *
18  * The above copyright notice and this permission notice shall be included
19  * in all copies or substantial portions of the Software.
20  *
21  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
22  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
24  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
27  * DEALINGS IN THE SOFTWARE.
28  ****************************************************************************/
29 
30 #ifndef _WMS_METADATASET_H_INCLUDED
31 #define _WMS_METADATASET_H_INCLUDED
32 
33 #include "gdal_pam.h"
34 #include "cpl_string.h"
35 #include "cpl_http.h"
36 #include <map>
37 
38 class WMSCTileSetDesc
39 {
40     public:
41         CPLString osLayers;
42         CPLString osSRS;
43         CPLString osMinX, osMinY, osMaxX, osMaxY;
44         double    dfMinX, dfMinY, dfMaxX, dfMaxY;
45         int       nResolutions;
46         double    dfMinResolution;
47         CPLString osFormat;
48         CPLString osStyle;
49         int       nTileWidth, nTileHeight;
50 };
51 
52 /************************************************************************/
53 /* ==================================================================== */
54 /*                          GDALWMSMetaDataset                          */
55 /* ==================================================================== */
56 /************************************************************************/
57 
58 class GDALWMSMetaDataset : public GDALPamDataset
59 {
60   private:
61     CPLString osGetURL;
62     CPLString osVersion;
63     CPLString osXMLEncoding;
64     char** papszSubDatasets;
65 
66     typedef std::pair<CPLString, CPLString> WMSCKeyType;
67     std::map<WMSCKeyType, WMSCTileSetDesc> osMapWMSCTileSet;
68 
69     void                AddSubDataset(const char* pszName,
70                                       const char* pszDesc);
71 
72     void                AddSubDataset(const char* pszLayerName,
73                                       const char* pszTitle,
74                                       const char* pszAbstract,
75                                       const char* pszSRS,
76                                       const char* pszMinX,
77                                       const char* pszMinY,
78                                       const char* pszMaxX,
79                                       const char* pszMaxY,
80                                       CPLString osFormat,
81                                       CPLString osTransparent);
82 
83     void                ExploreLayer(CPLXMLNode* psXML,
84                                      CPLString osFormat,
85                                      CPLString osTransparent,
86                                      CPLString osPreferredSRS,
87                                      const char* pszSRS = NULL,
88                                      const char* pszMinX = NULL,
89                                      const char* pszMinY = NULL,
90                                      const char* pszMaxX = NULL,
91                                      const char* pszMaxY = NULL);
92 
93     void                AddTiledSubDataset(const char* pszTiledGroupName,
94                                            const char* pszTitle);
95 
96     void                AnalyzeGetTileServiceRecurse(CPLXMLNode* psXML);
97 
98     void                AddWMSCSubDataset(WMSCTileSetDesc& oWMSCTileSetDesc,
99                                           const char* pszTitle,
100                                           CPLString osTransparent);
101 
102     void                ParseWMSCTileSets(CPLXMLNode* psXML);
103 
104   public:
105         GDALWMSMetaDataset();
106        ~GDALWMSMetaDataset();
107 
108     virtual char      **GetMetadataDomainList();
109     virtual char      **GetMetadata( const char * pszDomain = "" );
110 
111     static GDALDataset* AnalyzeGetCapabilities(CPLXMLNode* psXML,
112                                                CPLString osFormat = "",
113                                                CPLString osTransparent = "",
114                                                CPLString osPreferredSRS = "");
115     static GDALDataset* AnalyzeGetTileService(CPLXMLNode* psXML);
116     static GDALDataset* AnalyzeTileMapService(CPLXMLNode* psXML);
117 
118     static GDALDataset* DownloadGetCapabilities(GDALOpenInfo *poOpenInfo);
119     static GDALDataset* DownloadGetTileService(GDALOpenInfo *poOpenInfo);
120 };
121 
122 #endif // _WMS_METADATASET_H_INCLUDED
123