Statistics
| Revision:

gvsig-raster / org.gvsig.raster / branches / org.gvsig.raster.2.4 / org.gvsig.raster / org.gvsig.raster.tilecache / org.gvsig.raster.tilecache.provider / src / main / java / org / gvsig / raster / tilecache / provider / TileCacheStoreProviderParameters.java @ 6516

History | View | Annotate | Download (4.62 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.raster.tilecache.provider;
24

    
25
import java.io.File;
26
import java.io.IOException;
27
import java.util.List;
28

    
29
import org.apache.commons.io.FileUtils;
30
import org.apache.commons.io.FilenameUtils;
31
import org.apache.commons.lang3.StringUtils;
32
import org.cresques.cts.ICRSFactory;
33
import org.cresques.cts.IProjection;
34
import org.gvsig.fmap.crs.CRSFactory;
35
import org.gvsig.fmap.dal.FileHelper;
36
import org.gvsig.fmap.dal.OpenDataStoreParameters;
37
import org.gvsig.fmap.dal.raster.spi.OpenRasterStoreParameters;
38
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemStoreParameters;
39
import org.gvsig.fmap.dal.spi.AbstractDataParameters;
40
import org.gvsig.fmap.dal.spi.DataStoreProviderServices;
41
import org.gvsig.tools.dynobject.DelegatedDynObject;
42
import org.slf4j.Logger;
43
import org.slf4j.LoggerFactory;
44

    
45
/**
46
 * Parameters to create a TileCache Provider
47
 * @author dmartinezizquierdo
48
 *
49
 */
50
public class TileCacheStoreProviderParameters extends AbstractDataParameters implements
51
OpenRasterStoreParameters{
52

    
53
    private static final Logger logger = LoggerFactory.getLogger(TileCacheStoreProviderParameters.class);
54

    
55
    public static final String PARAMETERS_DEFINITION_NAME = "TileCacheStoreProviderParameters";
56
    public static final String TILECACHE_CACHEFOLDER_PARAMTER_NAME = "cacheFolder";
57
    public static final String CRS_PARAMTER_NAME = "crs";
58
    public static final String WLD_PARAMS_NAME= "wldParams";
59

    
60

    
61
    private DelegatedDynObject parameters;
62

    
63
    /**
64
     * Constructor
65
     */
66
    public TileCacheStoreProviderParameters() {
67
        this(PARAMETERS_DEFINITION_NAME);
68
    }
69

    
70
    protected TileCacheStoreProviderParameters(String parametersDefinitionName) {
71
        this(parametersDefinitionName, TileCacheStoreProvider.NAME);
72
    }
73

    
74

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

    
86
    @Override
87
    public String getDataStoreName() {
88
        return (String) this.getDynValue(DataStoreProviderServices.PROVIDER_PARAMTER_NAME);
89
    }
90

    
91
    @Override
92
    public boolean isValid() {
93
        return (this.getCacheFolder() != null);
94
    }
95

    
96
    @Override
97
    public String getDescription() {
98
        return this.getDynClass().getDescription();
99
    }
100

    
101
    public File getCacheFolder() {
102
        return (File) this.getDynValue(TILECACHE_CACHEFOLDER_PARAMTER_NAME);
103
    }
104

    
105
    public void setCacheFolder(File cacheFolder) {
106
        this.setDynValue(TILECACHE_CACHEFOLDER_PARAMTER_NAME, cacheFolder);
107
    }
108

    
109
    /**
110
     * Sets CRS
111
     * @param crsCode
112
     */
113
    public void setCRS(String crsCode) {
114
        IProjection crs=CRSFactory.getCRS(crsCode);
115
        setDynValue(CRS_PARAMTER_NAME, crs);
116
    }
117

    
118
    /**
119
     * Sets CRS
120
     * @param crs
121
     */
122
    public void setCRS(IProjection crs) {
123
        setDynValue(CRS_PARAMTER_NAME, crs);
124
    }
125

    
126

    
127
    /**
128
     * Gets CRS
129
     * @return IProjection
130
     */
131
    public IProjection getCRS() {
132
        return (IProjection) getDynValue(CRS_PARAMTER_NAME);
133
    }
134

    
135
    /**
136
     * Gets the 6 params of a WLD file as Strings.
137
     * @return Returns WLD parameters
138
     */
139
    public List<String> getWldParams(){
140
        return (List<String>) getDynValue(WLD_PARAMS_NAME);
141
    }
142

    
143
    /**
144
     * Sets the params of a wld file
145
     * @param wldParams
146
     */
147
    public void setWldParams(List<String> wldParams){
148
        setDynValue(WLD_PARAMS_NAME,wldParams);
149
    }
150

    
151
    @Override
152
    protected DelegatedDynObject getDelegatedDynObject() {
153
        return parameters;
154
    }
155

    
156
}