Statistics
| Revision:

gvsig-raster / org.gvsig.raster.wms / trunk / org.gvsig.raster.wms / org.gvsig.raster.wms.io / src / main / java / org / gvsig / raster / wms / io / WMSServerExplorerParameters.java @ 3325

History | View | Annotate | Download (5.49 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.wms.io;
29

    
30
import org.gvsig.fmap.dal.DataServerExplorerParameters;
31
import org.gvsig.fmap.dal.spi.AbstractDataParameters;
32
import org.gvsig.raster.impl.store.AbstractRasterDataParameters;
33
import org.gvsig.tools.ToolsLocator;
34
import org.gvsig.tools.dynobject.DelegatedDynObject;
35
import org.gvsig.tools.dynobject.DynClass;
36
import org.gvsig.tools.dynobject.DynStruct;
37
import org.gvsig.tools.persistence.PersistenceManager;
38

    
39
/**
40
 * Parameters for the WMS provider
41
 * @author Nacho Brodin (nachobrodin@gmail.com)
42
 */
43
public class WMSServerExplorerParameters extends AbstractDataParameters implements DataServerExplorerParameters {
44
        protected static final String  FIELD_HOST          = "host";
45
        protected static DynClass      DYNCLASS            = null;
46
        private DelegatedDynObject     delegatedDynObject  = null;
47
        private static final String    FIELD_XYAXISORDER          = "xyaxisorder";
48
        
49
        public WMSServerExplorerParameters() {
50
                super();
51
                initialize();
52
        }
53

    
54
        protected void initialize() {
55
                this.delegatedDynObject = (DelegatedDynObject) ToolsLocator
56
                                .getDynObjectManager().createDynObject(
57
                                                registerDynClass());
58
        }
59
        
60
        public static DynStruct registerDynClass() {
61
                PersistenceManager manager = ToolsLocator.getPersistenceManager();
62
                DynStruct definition = manager.getDefinition("WMSServerExplorerParameters_Persistent");
63
                if( definition == null ) {
64
                        definition = manager.addDefinition(
65
                                        WMSServerExplorerParameters.class,
66
                                        "WMSServerExplorerParameters_Persistent",
67
                                        "WMS Explorer DataParameters Persistency",
68
                                        null, 
69
                                        null
70
                        );
71
                }
72

    
73
                AbstractRasterDataParameters.registerDynClass(definition);
74

    
75
                definition.addDynFieldBoolean(FIELD_XYAXISORDER)
76
                .setDescription("Longitude first in axis order")
77
                .setMandatory(false);
78

    
79
                definition.addDynFieldString(FIELD_HOST)
80
                .setDescription("Uniform Resource Identifier (File name or URL)")
81
                .setMandatory(false);                
82
                return definition;
83
        }
84
        
85
        protected DelegatedDynObject getDelegatedDynObject() {
86
                return delegatedDynObject;
87
        }
88
        
89
        /**
90
         * Gets the assigned host
91
         * @return
92
         */
93
        public String getHost() {
94
                return (String) this.getDynValue(FIELD_HOST);
95
        }
96

    
97
        /**
98
         * Assign the host to this explorer
99
         * @param host
100
         */
101
        public void setHost(String host) {
102
                this.setDynValue(FIELD_HOST, host);
103
        }
104

    
105
        public String getDataStoreName() {
106
                return WMSProvider.NAME;
107
        }
108
        
109
        public String getDescription() {
110
                return WMSProvider.DESCRIPTION;
111
        }
112

    
113
        public String getExplorerName() {
114
                return WMSServerExplorer.NAME;
115
        }
116

    
117
        /**
118
         * <p>Gets the behaviour of the WMS client with regards the axis order</p>
119
         * 
120
         * <p>Returns <code>true</code> if the WMS parser should assume that the
121
         * order of the coordinates follows the XY axis order
122
         * (the first coordinate corresponds to the horizontal X
123
         * axis, while the second  coordinate corresponds to the
124
         * vertical Y axis), regardless the protocol version and CRS in use.</p>
125
         * 
126
         * <p>Returns <code>false</code> if the WMS parser should decide the
127
         * axis order based on the protocol version and the coordinate
128
         * reference system (CRS) in use. In particular, if protocol
129
         * version is >= 1.3.0, then the WMS parser assumes
130
         * the axis order defined in the official EPSG registry for the
131
         * CRS in use. For versions < 1.3.0, the XY axis order is assumed.</p>
132
         * 
133
         * <p>The default value is <code>false</code></p>.
134
         * @see #setXyAxisOrder(boolean)
135
         * @return
136
         */
137
        public boolean isXyAxisOrder() {
138
                if (hasDynValue(FIELD_XYAXISORDER)) {
139
                        Object obj = getDynValue(FIELD_XYAXISORDER);
140
                        if(obj instanceof Boolean) {
141
                                Boolean b = (Boolean)getDynValue(FIELD_XYAXISORDER);
142
                                if(b != null)
143
                                        return ((Boolean)b).booleanValue();
144
                        }
145
                        if(obj instanceof String) {
146
                                String b = (String)getDynValue(FIELD_XYAXISORDER);
147
                                if(b != null)
148
                                        return new Boolean(((String)b));
149
                        }
150
                }
151
                return false;
152
        }
153

    
154
        /**
155
         * <p>Sets the behaviour of the WMS client with regards the axis order.<p>
156
         * 
157
         * <p>If set to <code>true</code>, then the XY axis order
158
         * is assumed for all the WMS
159
         * protocol versions and coordinate reference systems.</p>
160
         * 
161
         * <p>If set to <code>false</code>
162
         * then the WMS parser will decide the axis order based on
163
         * the protocol version and the coordinate reference system (CRS)
164
         * in use. In particular, if protocol
165
         * version is >= 1.3.0, then the WMS parser assumes
166
         * the axis order defined in the official EPSG registry for the
167
         * CRS in use. For versions < 1.3.0, the XY axis order is assumed.</p>
168
         * 
169
         * 
170
         * @param assumeXY
171
         * @see #isXyAxisOrder()
172
         */
173
        public void setXyAxisOrder(boolean assumeXY) {
174
                this.setDynValue(FIELD_XYAXISORDER, new Boolean(assumeXY));
175
        }
176
}