Statistics
| Revision:

gvsig-raster / org.gvsig.raster.wmts / trunk / org.gvsig.raster.wmts / org.gvsig.raster.wmts.ogc / org.gvsig.raster.wmts.ogc.impl / src / main / java / org / gvsig / raster / wmts / ogc / impl / base / WMTSServiceInformation.java @ 1806

History | View | Annotate | Download (6.79 KB)

1
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* of the Valencian Government (CIT)
5
* 
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
10
* 
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
* GNU General Public License for more details.
15
* 
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
19
* MA  02110-1301, USA.
20
* 
21
*/
22

    
23
/*
24
* AUTHORS (In addition to CIT):
25
* 2009 Iver T.I.  {{Task}}
26
*/
27
 
28
package org.gvsig.raster.wmts.ogc.impl.base;
29

    
30
import java.util.HashMap;
31
import java.util.Hashtable;
32
import java.util.Iterator;
33
import java.util.Vector;
34

    
35
import org.gvsig.raster.wmts.ogc.impl.Tags;
36

    
37
/**
38
 * Class that represents the description of the WMS metadata.
39
 * The first part of the capabilities will return the service information
40
 * from the WMS, this class will hold this information.
41
 * 
42
 * @author Nacho Brodin (nachobrodin@gmail.com)
43
 */
44
public class WMTSServiceInformation {
45
        public String online_resource = null;
46
        protected HashMap operationsGet = new HashMap();
47
        protected HashMap operationsPost = new HashMap();
48
        public String version;
49
        public String name;
50
        public String scope;
51
        public String title;
52
        public String abstr;
53
        public String keywords;
54
        public String fees;
55
        public String operationsInfo;
56
        public String personname;
57
        public String organization;
58
        public String function;
59
        public String addresstype;
60
        public String address;
61
        public String place;
62
        public String province;
63
        public String postcode;
64
        public String country;
65
        public String phone;
66
        public String fax;
67
        public String email;
68
        public Vector formats;
69

    
70
        public WMTSServiceInformation() {
71
                version = new String();
72
                name = new String();
73
                scope = new String();
74
                title = new String();
75
                abstr = new String();
76
                keywords = new String();
77
                fees = new String();
78
                operationsInfo = new String();
79
                personname = new String();
80
                organization = new String();
81
                function = new String();
82
                addresstype = new String();
83
                address = new String();
84
                place = new String();
85
                province = new String();
86
                postcode = new String();
87
                country = new String();
88
                phone = new String();
89
                fax = new String();
90
                email = new String();
91
                formats = new Vector();       
92
        }
93

    
94
        /**
95
         * @return Returns the online_resource.
96
         */
97
         public String getOnline_resource() {
98
                return online_resource;
99
        }
100

    
101
        /**
102
         * Add a new supported operation
103
         * @param operation
104
         * The operation to support
105
         * @param protocol
106
         * The HTTP protocol (Get or Post)
107
         */
108
         public void addOperation(String operation, int protocol){
109
                 if (protocol == Tags.PROTOCOL_GET){
110
                         operationsGet.put(operation, createOperation(operation));                        
111
                 }else if (protocol == Tags.PROTOCOL_POST){
112
                         operationsPost.put(operation, createOperation(operation));
113
                 }
114
         }
115

    
116
         /**
117
          * Add a new supported operation
118
          * @param operation
119
          * The operation to support
120
          * @param protocol
121
          * The HTTP protocol (Get or Post)
122
          * @param onlineResource
123
          * The online resource
124
          */
125
         public void addOperation(String operation, int protocol, String onlineResource){
126
                 if (protocol == Tags.PROTOCOL_GET){
127
                         operationsGet.put(operation, createOperation(operation, onlineResource));
128
                 }else if (protocol == Tags.PROTOCOL_POST){
129
                         operationsPost.put(operation, createOperation(operation, onlineResource));
130
                 }
131
         }
132

    
133
         /**
134
          * Gest the online resource for a concrete operation
135
          * @param operation
136
          * The operation
137
          * @param protocol
138
          * The HTTP protocol (Get or Post)
139
          * @return
140
          * The online resource
141
          */
142
         public String getOnlineResource(String operation, int protocol){
143
                 WMTSOperation op = null;
144
                 if (protocol == Tags.PROTOCOL_GET){
145
                         op = (WMTSOperation)operationsGet.get(operation);
146
                 }else if (protocol == Tags.PROTOCOL_POST){
147
                         op = (WMTSOperation)operationsPost.get(operation);
148
                 }
149
                 if ((op == null) ||
150
                                 (op.getOnlineResource() == null) || 
151
                                 (op.getOnlineResource().equals(""))){
152
                         return null;
153
                 }
154
                 return op.getOnlineResource();
155
         }
156

    
157
         /**
158
          * Gets the online resource for a concrete operation.
159
          * The default protocol is GET
160
          * @param operation
161
          * The operation
162
          * @return
163
          * The online resource
164
          */
165
         public String getOnlineResource(String operation){
166
                 return getOnlineResource(operation, Tags.PROTOCOL_GET);
167
         }
168

    
169
         /**
170
          * Get a hash map with the supported operations
171
          * @return
172
          */
173
         public Hashtable getSupportedOperationsByName(){
174
                 Hashtable operations = new Hashtable();
175
                 Iterator getIt = operationsGet.keySet().iterator();
176
                 while (getIt.hasNext()){
177
                         String id = (String)getIt.next();
178
                         WMTSOperation operation = (WMTSOperation)operationsGet.get(id);
179
                         operations.put(operation.getOperationName(),
180
                                         operation.getOnlineResource());
181
                 }
182
                 return operations;
183
         }
184

    
185
         public boolean isOperationSupported(String operationName){
186
                 if (operationsGet.containsKey(operationName)){
187
                         return true;
188
                 }
189
                 if (operationsPost.containsKey(operationName)){
190
                         return true;
191
                 }
192
                 return false;
193
         }        
194

    
195
         public boolean isQueryable() {
196
                 if (getOnlineResource(Tags.GETFEATUREINFO) != null)            
197
                         return true;
198
                 else
199
                         return false;
200
         }
201

    
202
    public boolean hasLegendGraphic() {
203
            if (getOnlineResource(Tags.GETLEGENDGRAPHIC) != null) 
204
                    return true;
205
            else
206
                    return false;
207
    }
208
    
209
    public void clear() {
210
            version = new String();
211
        name = new String();
212
        scope = new String();
213
        title = new String();
214
        abstr = new String();
215
        keywords = new String();
216
        fees = new String();
217
        operationsInfo = new String();
218
        personname = new String();
219
        organization = new String();
220
        function = new String();
221
        addresstype = new String();
222
        address = new String();
223
        place = new String();
224
        province = new String();
225
        postcode = new String();
226
        country = new String();
227
        phone = new String();
228
        fax = new String();
229
        email = new String();
230
        formats = new Vector();        
231
    }      
232
    
233
        /* (non-Javadoc)
234
         * @see org.gvsig.remoteClient.ogc.OGCServiceInformation#createOperation(java.lang.String)
235
         */        
236
        public WMTSOperation createOperation(String name) {
237
                return new WMTSOperation(name); 
238
        }
239

    
240
        /* (non-Javadoc)
241
         * @see org.gvsig.remoteClient.ogc.OGCServiceInformation#createOperation(java.lang.String, java.lang.String)
242
         */        
243
        public WMTSOperation createOperation(String name, String onlineResource) {
244
                return new WMTSOperation(name, onlineResource);
245
        }        
246

    
247
 }
248