Statistics
| Revision:

gvsig-catalog / org.gvsig.catalog / branches / org.gvsig.catalog-CSW2.0.2 / org.gvsig.catalog / org.gvsig.catalog.extension / src / main / java / org / gvsig / catalog / loaders / WMSLayerLoader.java @ 62

History | View | Annotate | Download (4.14 KB)

1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
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., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 *
19
 * For more information, contact:
20
 *
21
 *  Generalitat Valenciana
22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Ib??ez, 50
24
 *   46010 VALENCIA
25
 *   SPAIN
26
 *
27
 *      +34 963862235
28
 *   gvsig@gva.es
29
 *      www.gvsig.gva.es
30
 *
31
 *    or
32
 *
33
 *   IVER T.I. S.A
34
 *   Salamanca 50
35
 *   46005 Valencia
36
 *   Spain
37
 *
38
 *   +34 963163400
39
 *   dac@iver.es
40
 */
41
package org.gvsig.catalog.loaders;
42

    
43

    
44
import java.util.HashMap;
45
import java.util.Map;
46

    
47
import org.gvsig.andami.PluginServices;
48
import org.gvsig.app.project.documents.view.gui.AbstractViewPanel;
49
import org.gvsig.catalog.schemas.Resource;
50
import org.gvsig.fmap.dal.DataStoreParameters;
51
import org.gvsig.fmap.dal.exception.InitializeException;
52
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException;
53
import org.gvsig.i18n.Messages;
54

    
55

    
56
/**
57
 * This class is used to load a WMS layer in gvSIG
58
 * 
59
 * @author Jorge Piera Llodra (piera_jor@gva.es)
60
 */
61
public class WMSLayerLoader extends GvSigLayerLoader{
62
    private static final String FIELD_NAME = "name";
63
    private static final String FIELD_SRSSTR = "srsstr";
64
    private static final String FIELD_FORMAT = "format";
65
    private static final String FIELD_TRANSPARENCY = "transparency";
66
    private static final String FIELD_LAYERQUERY = "layer_query";
67
    private static final String FIELD_URI = "uri";
68
    private static final String FIELD_ONLINERESOURC = "onlineresources";
69
    private static final String FIELD_DELETECACHE     = "deletecache";
70
    
71
    public WMSLayerLoader(Resource resource) {
72
        super(resource);                
73
    }        
74

    
75
    protected boolean hasSpecificLayer() {        
76
        return true;
77
    }
78

    
79
    protected String getLayerName() {      
80
        return getResource().getName();
81
    }    
82

    
83
    protected DataStoreParameters createDataStoreParameters()
84
        throws InitializeException, ProviderNotRegisteredException {
85
        DataStoreParameters dataStoreParameters = DATA_MANAGER.createStoreParameters("Wms Store");        
86
        dataStoreParameters.setDynValue(FIELD_URI, getResource().getLinkage());
87
        dataStoreParameters.setDynValue(FIELD_FORMAT, "image/png");
88
        dataStoreParameters.setDynValue(FIELD_LAYERQUERY, getResource().getName());
89
        AbstractViewPanel activeView = 
90
            (AbstractViewPanel) PluginServices.getMDIManager().getActiveWindow();
91
        dataStoreParameters.setDynValue(FIELD_SRSSTR, activeView.getProjection().getAbrev());
92
        dataStoreParameters.setDynValue(FIELD_TRANSPARENCY, Boolean.TRUE);
93
        dataStoreParameters.setDynValue(FIELD_NAME, getLayerName());
94
        dataStoreParameters.setDynValue(FIELD_ONLINERESOURC, createOnlineResources());
95
        dataStoreParameters.setDynValue(FIELD_DELETECACHE, new Boolean(true));
96
        return dataStoreParameters;
97
    }   
98
    
99
    protected Map createOnlineResources() {
100
        Map args = new HashMap();
101
        args.put("GepMap", getResource().getLinkage());      
102
        return args;
103
    }
104
   
105
    protected String extensionPointName() {
106
        return "OGC:WMS";
107
    }
108

    
109
    protected String getErrorMessage() {
110
        return Messages.getText("wmsError") + ".\n" +
111
        Messages.getText("server") + ": " + 
112
        getResource().getLinkage() + "\n" +
113
        Messages.getText("layer") + ": " +
114
        getResource().getName();                
115
    }
116

    
117
    protected String getWindowMessage() {
118
        return Messages.getText("loadWMS");
119
    }
120
}