Statistics
| Revision:

gvsig-raster / org.gvsig.raster.reproject / branches / org.gvsig.raster.reproject_proyeccion_al_vuelo / org.gvsig.raster.reproject.app.reprojectclient / src / main / java / org / gvsig / raster / reproject / app / PrepareLayerAskProjection.java @ 5468

History | View | Annotate | Download (3.54 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
package org.gvsig.raster.reproject.app;
23

    
24
import java.util.Map;
25

    
26
import org.cresques.cts.IProjection;
27
import org.gvsig.app.prepareAction.PrepareContext;
28
import org.gvsig.app.prepareAction.PrepareContextView;
29
import org.gvsig.app.prepareAction.PrepareDataStoreParameters;
30
import org.gvsig.app.prepareAction.PrepareLayer;
31
import org.gvsig.fmap.dal.DALLocator;
32
import org.gvsig.fmap.dal.DataManager;
33
import org.gvsig.fmap.dal.DataStoreParameters;
34
import org.gvsig.fmap.dal.coverage.RasterException;
35
import org.gvsig.fmap.dal.coverage.exception.RmfSerializerException;
36
import org.gvsig.fmap.dal.coverage.store.RasterDataStore;
37
import org.gvsig.fmap.dal.coverage.store.parameter.RasterDataParameters;
38
import org.gvsig.fmap.mapcontext.layers.FLayer;
39
import org.gvsig.fmap.mapcontext.layers.operations.SingleLayer;
40
import org.gvsig.geoprocess.lib.sextante.dataObjects.FLyrRasterIRasterLayer;
41
import org.gvsig.raster.fmap.layers.DefaultFLyrRaster;
42
import org.gvsig.raster.fmap.layers.FLyrRaster;
43
import org.gvsig.tools.exception.BaseException;
44

    
45
import es.unex.sextante.gui.cmd.bshcommands.data;
46

    
47
/**
48
 * Entity to configure data store parameters when raster is projected on the fly
49
 * before open store.
50
 * 
51
 * @author <a href="mailto:lmarques@disid.com">Lluis Marques</a>
52
 *
53
 */
54
public class PrepareLayerAskProjection implements PrepareDataStoreParameters {
55

    
56
    public DataStoreParameters prepare(DataStoreParameters storeParameters, PrepareContext context)
57
        throws BaseException {
58

    
59
        if (storeParameters instanceof RasterDataParameters) {
60
            RasterDataParameters rasterParameters = (RasterDataParameters) storeParameters;
61
            
62
            DataManager dataManager = DALLocator.getDataManager();
63
            RasterDataStore store =
64
                (RasterDataStore) dataManager.openStore(rasterParameters.getDataStoreName(),
65
                    rasterParameters);
66
            IProjection projection = store.getProjection();
67
            store.dispose();
68
            
69
            if(projection != null){
70
                rasterParameters.setSRS(projection);
71
            }
72
        }
73

    
74
        return storeParameters;
75
    }
76
    
77
    public void pre(DataStoreParameters storeParameters, PrepareContext context) {
78
    }
79

    
80
    public void post(DataStoreParameters storeParameters, PrepareContext context) {
81
    }
82

    
83
    public String getDescription() {
84
        return "Prepare projection for Raster Layer";
85
    }
86

    
87
    public String getName() {
88
        return "PrepareRasterLayerProjection";
89
    }
90

    
91
    public Object create() {
92
        return this;
93
    }
94

    
95
    public Object create(Object[] args) {
96
        return this;
97
    }
98

    
99
    @SuppressWarnings("rawtypes")
100
    public Object create(Map args) {
101
        return this;
102
    }
103
}