Statistics
| Revision:

gvsig-osm / org.gvsig.raster.osm / trunk / org.gvsig.raster.osm / org.gvsig.raster.osm.io / src / main / java / org / gvsig / raster / osm / io / OSMDataParametersImpl.java @ 85

History | View | Annotate | Download (5 KB)

1
/* OSM layers for gvSIG. 
2
 * Geographic Information System of the Valencian Government
3
*
4
* Copyright (C) 2012 Nacho Brodin
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
package org.gvsig.raster.osm.io;
24

    
25
import org.gvsig.fmap.dal.coverage.store.RasterDataServerExplorer;
26
import org.gvsig.fmap.dal.coverage.store.parameter.RasterDataParameters;
27
import org.gvsig.raster.impl.store.AbstractRasterDataParameters;
28
import org.gvsig.tools.ToolsLocator;
29
import org.gvsig.tools.dynobject.DelegatedDynObject;
30
import org.gvsig.tools.dynobject.DynStruct;
31
import org.gvsig.tools.persistence.PersistenceManager;
32

    
33
/**
34
 * Parameters for OSM provider
35
 * @author Nacho Brodin (nachobrodin@gmail.com)
36
 */
37
public class OSMDataParametersImpl extends AbstractRasterDataParameters implements OSMDataParameters {
38
        private DelegatedDynObject            delegatedDynObject         = null;
39
        private static final String           FIELD_WIDTH                = "width";
40
        private static final String           FIELD_HEIGHT               = "height";
41
        private static final String           FIELD_MAX_RES_LEVEL        = "maxResolutionLevel";
42
        private static final String           FIELD_NAME                 = "name";
43
        private static final String           FIELD_SUFFIX               = "suffix";
44
        
45
        public OSMDataParametersImpl() {
46
                super();
47
                initialize();
48
        }
49
        
50
        protected void initialize() {
51
                this.delegatedDynObject = (DelegatedDynObject) ToolsLocator
52
                                .getDynObjectManager().createDynObject(registerDynClass());
53
        }
54
        
55
        public static DynStruct registerDynClass() {
56
                PersistenceManager manager = ToolsLocator.getPersistenceManager();
57
                DynStruct definition = manager.getDefinition("OSMDataParameters_Persistent");
58
                if( definition == null ) {
59
                        definition = manager.addDefinition(
60
                                        OSMDataParametersImpl.class,
61
                                        "OSMDataParameters_Persistent",
62
                                        "OSM DataParameters Persistency",
63
                                        null, 
64
                                        null
65
                        );
66
                }
67

    
68
                AbstractRasterDataParameters.registerDynClass(definition);
69

    
70
                definition.addDynFieldInt(FIELD_MAX_RES_LEVEL)
71
                .setDescription("Maximun levels of resolution")
72
                .setMandatory(false);
73

    
74
                definition.addDynFieldInt(FIELD_WIDTH)
75
                .setDescription("Width")
76
                .setMandatory(false);
77

    
78
                definition.addDynFieldInt(FIELD_HEIGHT)
79
                .setDescription("Height")
80
                .setMandatory(false);
81

    
82
                definition.addDynFieldString(FIELD_NAME)
83
                .setDescription("Layer name")
84
                .setMandatory(false);                
85

    
86
                definition.addDynFieldString(FIELD_SUFFIX)
87
                .setDescription("Field suffix")
88
                .setMandatory(false);
89

    
90
                return definition;
91
        }
92
        
93
        public void assignFields(RasterDataParameters par, RasterDataServerExplorer explorer) {
94
                super.assignFields(par, explorer);
95
                
96
                OSMDataParameters p = null;
97
                if(par instanceof OSMDataParameters)
98
                        p = (OSMDataParameters)par;
99
                else
100
                        return;
101
                
102
                setTileSuffix(p.getTileSuffix());
103
                setOSMLayerName(p.getOSMLayerName());
104
                setWidth(p.getWidth());
105
                setHeight(p.getHeight());
106
                setNumberOfLevels(p.getNumberOfLevels());
107
        }
108
        
109
        public String getDataStoreName() {
110
                return OSMProvider.NAME;
111
        }
112
        
113
        public String getDescription() {
114
                return OSMProvider.DESCRIPTION;
115
        }
116
        
117
        @Override
118
        protected DelegatedDynObject getDelegatedDynObject() {
119
                return delegatedDynObject;
120
        }
121

    
122
        public boolean isOverridingHost() {
123
                return false;
124
        }
125

    
126
        public void setOverrideHost(boolean over) {
127
                
128
        }
129
        
130
        public void setWidth(int w) {
131
                this.setDynValue(FIELD_WIDTH, new Integer(w));
132
        }
133
        
134
        public void setHeight(int h) {
135
                this.setDynValue(FIELD_HEIGHT, new Integer(h));
136
        }
137
        
138
        public int getWidth() {
139
                Integer b = (Integer)getDynValue(FIELD_WIDTH);
140
                if(b != null)
141
                        return ((Integer)b).intValue();
142
                return 0;
143
        }
144
        
145
        public int getHeight() {
146
                Integer b = (Integer)getDynValue(FIELD_HEIGHT);
147
                if(b != null)
148
                        return ((Integer)b).intValue();
149
                return 0;
150
        }
151
        
152
        public String getOSMLayerName() {
153
                String b = (String)getDynValue(FIELD_NAME);
154
                if(b != null)
155
                        return b;
156
                return null;
157
        }
158
        
159
        public void setOSMLayerName(String name) {
160
                this.setDynValue(FIELD_NAME, name);
161
        }
162
        
163
        public int getNumberOfLevels() {
164
                Integer b = (Integer)getDynValue(FIELD_MAX_RES_LEVEL);
165
                if(b != null)
166
                        return ((Integer)b).intValue();
167
                return 0;
168
        }
169
        
170
        public void setNumberOfLevels(int levels) {
171
                this.setDynValue(FIELD_MAX_RES_LEVEL, new Integer(levels));
172
        }
173
        
174
        public String getTileSuffix() {
175
                String b = (String)getDynValue(FIELD_SUFFIX);
176
                if(b != null)
177
                        return b;
178
                return null;
179
        }
180
        
181
        public void setTileSuffix(String suffix) {
182
                this.setDynValue(FIELD_SUFFIX, suffix);
183
        }
184
}