Statistics
| Revision:

gvsig-raster / org.gvsig.raster / branches / org.gvsig.raster.2.4 / org.gvsig.wms / org.gvsig.wms.provider / src / main / java / org / gvsig / wms / provider / WMSRasterProviderParameters.java @ 8690

History | View | Annotate | Download (7.33 KB)

1
/* gvSIG. Desktop Geographic Information System.
2
 *
3
 * Copyright ? 2007-2016 gvSIG Association
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18
 * MA  02110-1301, USA.
19
 *
20
 * For any additional information, do not hesitate to contact us
21
 * at info AT gvsig.com, or visit our website www.gvsig.com.
22
 */
23
package org.gvsig.wms.provider;
24

    
25
import java.net.URL;
26
import java.util.List;
27

    
28
import org.apache.commons.lang3.StringUtils;
29
import org.cresques.cts.IProjection;
30
import org.slf4j.Logger;
31
import org.slf4j.LoggerFactory;
32

    
33
import org.gvsig.fmap.crs.CRSFactory;
34
import org.gvsig.fmap.dal.FileHelper;
35
import org.gvsig.fmap.dal.raster.OpenRasterStoreParameters;
36
import org.gvsig.fmap.dal.spi.AbstractDataParameters;
37
import org.gvsig.fmap.dal.spi.DataStoreProviderServices;
38
import org.gvsig.tools.dynobject.DelegatedDynObject;
39

    
40

    
41
/**
42
 * @author fdiaz
43
 *
44
 */
45
public class WMSRasterProviderParameters extends AbstractDataParameters implements OpenRasterStoreParameters {
46

    
47
    private static final Logger logger = LoggerFactory.getLogger(WMSRasterProviderParameters.class);
48

    
49
    public static final String PARAMETERS_DEFINITION_NAME = "WMSRasterProviderParameters";
50

    
51
    public static final String WMS_SERVICE_PARAMETER_NAME = "service";
52
    public static final String WMS_OVERRIDE_CAPABILITIES_PARAMETER_NAME = "override_capabilities";
53
    public static final String WMS_LAYERS_PARAMETER_NAME = "layers";
54
    public static final String WMS_STYLES_PARAMETER_NAME = "styles";
55
    public static final String WMS_FORMAT_PARAMETER_NAME = "format";
56
    public static final String WMS_CRS_PARAMETER_NAME = "crs";
57
    public static final String WMS_INFO_FORMAT_PARAMETER_NAME = "info_format";
58
    public static final String WMS_XYAXISORDER_PARAMETER_NAME = "xyaxisorder";
59
    public static final String WMS_TRANSPARENCY_PARAMETER_NAME = "transparency";
60
//    public static final String WMS_DIMENSIONS_PARAMETER_NAME = "dimensions";
61

    
62

    
63
    private DelegatedDynObject parameters;
64

    
65
    /**
66
     * Constructor
67
     */
68
    public WMSRasterProviderParameters() {
69
        this(PARAMETERS_DEFINITION_NAME);
70
    }
71

    
72
    protected WMSRasterProviderParameters(String parametersDefinitionName) {
73
        this(parametersDefinitionName, WMSRasterProvider.NAME);
74
    }
75

    
76

    
77
    /**
78
     * Constructor
79
     * @param parametersDefinitionName
80
     * @param name
81
     */
82
    public WMSRasterProviderParameters(String parametersDefinitionName, String name) {
83
        super();
84
        this.parameters = (DelegatedDynObject) FileHelper.newParameters(parametersDefinitionName);
85
        this.setDynValue(DataStoreProviderServices.PROVIDER_PARAMTER_NAME, name);
86
    }
87

    
88
    /* (non-Javadoc)
89
     * @see org.gvsig.fmap.dal.DataStoreParameters#getDataStoreName()
90
     */
91
    @Override
92
    public String getDataStoreName() {
93
        return (String) this.getDynValue(DataStoreProviderServices.PROVIDER_PARAMTER_NAME);
94
    }
95

    
96
    @Override
97
    public boolean isValid() {
98
        //FIXME: ?m?s comprobaciones?
99
        return !StringUtils.isEmpty(this.getService().toString());
100
    }
101

    
102
    @Override
103
    public String getDescription() {
104
        return this.getDynClass().getDescription();
105
    }
106

    
107
    /**
108
     * @return service parameter.
109
     */
110
    public URL getService() {
111
        return (URL)this.getDynValue(WMS_SERVICE_PARAMETER_NAME);
112
    }
113

    
114
    /**
115
     * @param service
116
     */
117
    public void setService(URL service) {
118
        this.setDynValue(WMS_SERVICE_PARAMETER_NAME, service);
119
    }
120

    
121
    /**
122
     * @return layers parameter.
123
     */
124
    @SuppressWarnings("unchecked")
125
    public List<String> getLayers() {
126
        return (List<String>) this.getDynValue(WMS_LAYERS_PARAMETER_NAME);
127
    }
128

    
129
    /**
130
     * @param layers
131
     */
132
    public void setLayers(List<String> layers) {
133
        this.setDynValue(WMS_LAYERS_PARAMETER_NAME, layers);
134
    }
135

    
136
    /**
137
     * @return styles parameter.
138
     */
139
    @SuppressWarnings("unchecked")
140
    public List<String> getStyles() {
141
        return (List<String>) this.getDynValue(WMS_STYLES_PARAMETER_NAME);
142
    }
143

    
144
    /**
145
     * @param styles
146
     */
147
    public void setStyles(List<String> styles) {
148
        this.setDynValue(WMS_STYLES_PARAMETER_NAME, styles);
149
    }
150

    
151
    /**
152
     * @return format parameter.
153
     */
154
    public String getFormat() {
155
        return (String) this.getDynValue(WMS_FORMAT_PARAMETER_NAME);
156
    }
157

    
158
    /**
159
     * @param format
160
     */
161
    public void setFormat(String format) {
162
        this.setDynValue(WMS_FORMAT_PARAMETER_NAME, format);
163
    }
164

    
165
    /**
166
     * Sets CRS
167
     * @param crsCode
168
     */
169
    public void setCRS(String crsCode) {
170
        IProjection crs=CRSFactory.getCRS(crsCode);
171
        setDynValue(WMS_CRS_PARAMETER_NAME, crs);
172
    }
173

    
174
    /**
175
     * Sets CRS
176
     * @param crs
177
     */
178
    public void setCRS(IProjection crs) {
179
        setDynValue(WMS_CRS_PARAMETER_NAME, crs);
180
    }
181

    
182

    
183
    /**
184
     * Gets CRS
185
     * @return IProjection
186
     */
187
    public IProjection getCRS() {
188
        return (IProjection) getDynValue(WMS_CRS_PARAMETER_NAME);
189
    }
190

    
191

    
192
    /**
193
     * @return format of info parameter.
194
     */
195
    public String getInfoFormat() {
196
        return (String) this.getDynValue(WMS_INFO_FORMAT_PARAMETER_NAME);
197
    }
198

    
199
    /**
200
     * @param infoFormat
201
     */
202
    public void setInfoFormat(String infoFormat) {
203
        this.setDynValue(WMS_INFO_FORMAT_PARAMETER_NAME, infoFormat);
204
    }
205

    
206
    @Override
207
    protected DelegatedDynObject getDelegatedDynObject() {
208
        return parameters;
209
    }
210

    
211
    /**
212
     * @return xyaxisorder parameter.
213
     */
214
    public boolean getXYAxisOrder() {
215
        return (Boolean) this.getDynValue(WMS_XYAXISORDER_PARAMETER_NAME);
216
    }
217

    
218
    /**
219
     * @param xyAxisOrder
220
     */
221
    public void setXYAxisOrder(boolean xyAxisOrder) {
222
        this.setDynValue(WMS_XYAXISORDER_PARAMETER_NAME, xyAxisOrder);
223
    }
224

    
225
    /**
226
     * @return xyaxisorder parameter.
227
     */
228
    public boolean getTransparency() {
229
        return (Boolean) this.getDynValue(WMS_TRANSPARENCY_PARAMETER_NAME);
230
    }
231

    
232
    /**
233
     * @param transparency
234
     */
235
    public void setTransparency(boolean transparency) {
236
        this.setDynValue(WMS_TRANSPARENCY_PARAMETER_NAME, transparency);
237
    }
238

    
239
//    /**
240
//     * @return dimensions parameter.
241
//     */
242
//    public List getDimensions() {
243
//        return (List) this.getDynValue(WMS_DIMENSIONS_PARAMETER_NAME);
244
//    }
245
//
246
//    /**
247
//     * @param styles
248
//     */
249
//    public void setDimensions(List dimensions) {
250
//        this.setDynValue(WMS_DIMENSIONS_PARAMETER_NAME, dimensions);
251
//    }
252

    
253
    /**
254
     * @return override cached capabilities file parameter.
255
     */
256
    public URL getOverride() {
257
        return (URL) this.getDynValue(WMS_OVERRIDE_CAPABILITIES_PARAMETER_NAME);
258
    }
259

    
260
    /**
261
     * @param service
262
     */
263
    public void setOverride(boolean override) {
264
        this.setDynValue(WMS_OVERRIDE_CAPABILITIES_PARAMETER_NAME, override);
265
    }
266

    
267

    
268

    
269
}